// Code generated for linux/ppc64le by 'generator --prefix-external=X --prefix-field=F --prefix-static-internal=_ --prefix-static-none=_ --prefix-tagged-struct=T --prefix-tagged-union=T --prefix-typename=T --prefix-undefined=_ -eval-all-macros -extended-errors -ignore-link-errors -ignore-unsupported-alignment -I /home/debian/src/modernc.org/builder/.exclude/modernc.org/libfontconfig/include/linux/ppc64le -I /home/debian/.config/ccgo/v4/libtcl9.0/linux/ppc64le/tcl9.0.1/generic -I /home/debian/src/modernc.org/builder/.exclude/modernc.org/libX11/include/linux/ppc64le -I /home/debian/src/modernc.org/builder/.exclude/modernc.org/libXft/include/linux/ppc64le -lX11 -lXft -lfontconfig -ltcl9.0 -o libtk.a.go --package-name libtk9_0 libtcl9tk9.0.a', DO NOT EDIT. //go:build linux && ppc64le package libtk9_0 import ( "reflect" "unsafe" "modernc.org/libX11" "modernc.org/libc" "modernc.org/libtcl9.0" ) var _ reflect.Type var _ unsafe.Pointer const ALL_BUTTONS = 31465216 const ALT_MASK = 131072 const ARG_MAX = 131072 const AT_EACCESS = 512 const AT_EMPTY_PATH = 4096 const AT_FDCWD = -100 const AT_NO_AUTOMOUNT = 2048 const AT_RECURSIVE = 32768 const AT_REMOVEDIR = 512 const AT_STATX_DONT_SYNC = 16384 const AT_STATX_FORCE_SYNC = 8192 const AT_STATX_SYNC_AS_STAT = 0 const AT_STATX_SYNC_TYPE = 24576 const AT_SYMLINK_FOLLOW = 1024 const AT_SYMLINK_NOFOLLOW = 256 const Above = 0 const ActivateMask = 536870912 const ActivateNotify = 36 const AllHints = 127 const AllTemporary = 0 const AllValues = 15 const AllocAll = 1 const AllocNone = 0 const AllowExposures = 1 const AlreadyGrabbed = 1 const Always = 2 const AnyButton = 0 const AnyKey = 0 const AnyModifier = 32768 const AnyPropertyType = 0 const ArcChord = 0 const ArcPieSlice = 1 const AsyncBoth = 6 const AsyncKeyboard = 3 const AsyncPointer = 0 const AutoRepeatModeDefault = 2 const AutoRepeatModeOff = 0 const AutoRepeatModeOn = 1 const BC_BASE_MAX = 99 const BC_DIM_MAX = 2048 const BC_SCALE_MAX = 99 const BC_STRING_MAX = 1000 const BIG_ENDIAN = 4321 const BUFSIZ = 1024 const BUILD_tk = 1 const BYTE_ORDER = 1234 const BadAccess = 10 const BadAlloc = 11 const BadAtom = 5 const BadColor = 12 const BadCursor = 6 const BadDrawable = 9 const BadFont = 7 const BadGC = 13 const BadIDChoice = 14 const BadImplementation = 17 const BadLength = 16 const BadMatch = 8 const BadName = 15 const BadPixmap = 4 const BadRequest = 1 const BadValue = 2 const BadWindow = 3 const Below = 1 const BitmapFileInvalid = 2 const BitmapNoMemory = 3 const BitmapOpenFailed = 1 const BitmapSuccess = 0 const Bool = 0 const BottomIf = 3 const Button1 = 1 const Button1Mask = 256 const Button1MotionMask = 256 const Button2 = 2 const Button2Mask = 512 const Button2MotionMask = 512 const Button3 = 3 const Button3Mask = 1024 const Button3MotionMask = 1024 const Button4 = 4 const Button4Mask = 2048 const Button4MotionMask = 2048 const Button5 = 5 const Button5Mask = 4096 const Button5MotionMask = 4096 const Button6Mask = 2097152 const Button7Mask = 4194304 const Button8 = 8 const Button8Mask = 8388608 const Button9 = 9 const Button9Mask = 16777216 const ButtonMotionMask = 8192 const ButtonPress = 4 const ButtonPressMask = 4 const ButtonRelease = 5 const ButtonReleaseMask = 8 const CHARCLASS_NAME_MAX = 14 const CHAR_BIT = 8 const CHAR_MAX = 255 const CHAR_MIN = 0 const CLOCKS_PER_SEC = 1000000 const CLOCK_BOOTTIME = 7 const CLOCK_BOOTTIME_ALARM = 9 const CLOCK_MONOTONIC = 1 const CLOCK_MONOTONIC_COARSE = 6 const CLOCK_MONOTONIC_RAW = 4 const CLOCK_PROCESS_CPUTIME_ID = 2 const CLOCK_REALTIME = 0 const CLOCK_REALTIME_ALARM = 8 const CLOCK_REALTIME_COARSE = 5 const CLOCK_SGI_CYCLE = 10 const CLOCK_TAI = 11 const CLOCK_THREAD_CPUTIME_ID = 3 const COLL_WEIGHTS_MAX = 2 const COLORREF = 0 const CONST86 = 0 const CWBackPixel = 2 const CWBackPixmap = 1 const CWBackingPixel = 256 const CWBackingPlanes = 128 const CWBackingStore = 64 const CWBitGravity = 16 const CWBorderPixel = 8 const CWBorderPixmap = 4 const CWBorderWidth = 16 const CWColormap = 8192 const CWCursor = 16384 const CWDontPropagate = 4096 const CWEventMask = 2048 const CWHeight = 8 const CWOverrideRedirect = 512 const CWSaveUnder = 1024 const CWSibling = 32 const CWStackMode = 64 const CWWidth = 4 const CWWinGravity = 32 const CWX = 1 const CWY = 2 const CapButt = 1 const CapNotLast = 0 const CapProjecting = 3 const CapRound = 2 const CenterGravity = 5 const CirculateNotify = 26 const CirculateRequest = 27 const ClientMessage = 33 const ClipByChildren = 0 const ColormapChangeMask = 8388608 const ColormapInstalled = 1 const ColormapNotify = 32 const ColormapUninstalled = 0 const Complex = 0 const ConfigureNotify = 22 const ConfigureRequest = 23 const ControlMapIndex = 2 const ControlMask = 4 const Convex = 2 const CoordModeOrigin = 0 const CoordModePrevious = 1 const CopyFromParent = 0 const CreateNotify = 16 const CurrentTime = 0 const CursorShape = 0 const DELAYTIMER_MAX = 2147483647 const DN_ACCESS = 1 const DN_ATTRIB = 32 const DN_CREATE = 4 const DN_DELETE = 8 const DN_MODIFY = 2 const DN_MULTISHOT = 2147483648 const DN_RENAME = 16 const DeactivateNotify = 37 const DefaultBlanking = 2 const DefaultExposures = 2 const DestroyAll = 0 const DestroyNotify = 17 const DirectColor = 5 const DisableAccess = 0 const DisableScreenInterval = 0 const DisableScreenSaver = 0 const DoBlue = 4 const DoGreen = 2 const DoRed = 1 const DontAllowExposures = 0 const DontCareState = 0 const DontPreferBlanking = 0 const E2BIG = 7 const EACCES = 13 const EADDRINUSE = 98 const EADDRNOTAVAIL = 99 const EADV = 68 const EAFNOSUPPORT = 97 const EAGAIN = 11 const EALREADY = 114 const EBADE = 52 const EBADF = 9 const EBADFD = 77 const EBADMSG = 74 const EBADR = 53 const EBADRQC = 56 const EBADSLT = 57 const EBFONT = 59 const EBUSY = 16 const ECANCELED = 125 const ECHILD = 10 const ECHRNG = 44 const ECOMM = 70 const ECONNABORTED = 103 const ECONNREFUSED = 111 const ECONNRESET = 104 const EDEADLK = 35 const EDEADLOCK = 58 const EDESTADDRREQ = 89 const EDOM = 33 const EDOTDOT = 73 const EDQUOT = 122 const EEXIST = 17 const EFAULT = 14 const EFBIG = 27 const EHOSTDOWN = 112 const EHOSTUNREACH = 113 const EHWPOISON = 133 const EIDRM = 43 const EILSEQ = 84 const EINPROGRESS = 115 const EINTR = 4 const EINVAL = 22 const EIO = 5 const EISCONN = 106 const EISDIR = 21 const EISNAM = 120 const EKEYEXPIRED = 127 const EKEYREJECTED = 129 const EKEYREVOKED = 128 const EL2HLT = 51 const EL2NSYNC = 45 const EL3HLT = 46 const EL3RST = 47 const ELFlagFocus = 1 const ELFlagSameScreen = 2 const ELIBACC = 79 const ELIBBAD = 80 const ELIBEXEC = 83 const ELIBMAX = 82 const ELIBSCN = 81 const ELNRNG = 48 const ELOOP = 40 const EMBEDDED_APP_WANTS_FOCUS = 20 const EMEDIUMTYPE = 124 const EMFILE = 24 const EMLINK = 31 const EMSGSIZE = 90 const EMULTIHOP = 72 const ENAMETOOLONG = 36 const ENAVAIL = 119 const ENETDOWN = 100 const ENETRESET = 102 const ENETUNREACH = 101 const ENFILE = 23 const ENOANO = 55 const ENOBUFS = 105 const ENOCSI = 50 const ENODATA = 61 const ENODEV = 19 const ENOENT = 2 const ENOEXEC = 8 const ENOKEY = 126 const ENOLCK = 37 const ENOLINK = 67 const ENOMEDIUM = 123 const ENOMEM = 12 const ENOMSG = 42 const ENONET = 64 const ENOPKG = 65 const ENOPROTOOPT = 92 const ENOSPC = 28 const ENOSR = 63 const ENOSTR = 60 const ENOSYS = 38 const ENOTBLK = 15 const ENOTCONN = 107 const ENOTDIR = 20 const ENOTEMPTY = 39 const ENOTNAM = 118 const ENOTRECOVERABLE = 131 const ENOTSOCK = 88 const ENOTSUP = 95 const ENOTTY = 25 const ENOTUNIQ = 76 const ENXIO = 6 const EOPNOTSUPP = 95 const EOVERFLOW = 75 const EOWNERDEAD = 130 const EPERM = 1 const EPFNOSUPPORT = 96 const EPIPE = 32 const EPROTO = 71 const EPROTONOSUPPORT = 93 const EPROTOTYPE = 91 const ERANGE = 34 const EREMCHG = 78 const EREMOTE = 66 const EREMOTEIO = 121 const ERESTART = 85 const ERFKILL = 132 const EROFS = 30 const ESHUTDOWN = 108 const ESOCKTNOSUPPORT = 94 const ESPIPE = 29 const ESRCH = 3 const ESRMNT = 69 const ESTALE = 116 const ESTRPIPE = 86 const ETIME = 62 const ETIMEDOUT = 110 const ETOOMANYREFS = 109 const ETXTBSY = 26 const EUCLEAN = 117 const EUNATCH = 49 const EUSERS = 87 const EWOULDBLOCK = 11 const EXDEV = 18 const EXFULL = 54 const EXIT_FAILURE = 1 const EXIT_SUCCESS = 0 const EXPR_NEST_MAX = 32 const EXTENDED_MASK = 262144 const EXTERN = 0 const EastGravity = 6 const EnableAccess = 1 const EnterNotify = 7 const EnterWindowMask = 16 const EvenOddRule = 0 const Expose = 12 const ExposureMask = 32768 const FALLOC_FL_KEEP_SIZE = 1 const FALLOC_FL_PUNCH_HOLE = 2 const FAPPEND = 1024 const FASYNC = 8192 const FD_CLOEXEC = 1 const FD_SETSIZE = 1024 const FFSYNC = 1052672 const FILENAME_MAX = 4096 const FILESIZEBITS = 64 const FNDELAY = 2048 const FNONBLOCK = 2048 const FOPEN_MAX = 1000 const FP_FAST_FMA = 1 const FP_FAST_FMAF = 1 const FP_FAST_FMAL = 1 const FP_ILOGB0 = -2147483648 const FP_ILOGBNAN = -2147483648 const FP_INFINITE = 1 const FP_NAN = 0 const FP_NORMAL = 4 const FP_SUBNORMAL = 3 const FP_ZERO = 2 const FUNCPROTO = 15 const F_ADD_SEALS = 1033 const F_CANCELLK = 1029 const F_DUPFD = 0 const F_DUPFD_CLOEXEC = 1030 const F_GETFD = 1 const F_GETFL = 3 const F_GETLEASE = 1025 const F_GETLK = 5 const F_GETLK64 = 5 const F_GETOWN = 9 const F_GETOWNER_UIDS = 17 const F_GETOWN_EX = 16 const F_GETPIPE_SZ = 1032 const F_GETSIG = 11 const F_GET_FILE_RW_HINT = 1037 const F_GET_RW_HINT = 1035 const F_GET_SEALS = 1034 const F_LOCK = 1 const F_NOTIFY = 1026 const F_OFD_GETLK = 36 const F_OFD_SETLK = 37 const F_OFD_SETLKW = 38 const F_OK = 0 const F_OWNER_GID = 2 const F_OWNER_PGRP = 2 const F_OWNER_PID = 1 const F_OWNER_TID = 0 const F_RDLCK = 0 const F_SEAL_FUTURE_WRITE = 16 const F_SEAL_GROW = 4 const F_SEAL_SEAL = 1 const F_SEAL_SHRINK = 2 const F_SEAL_WRITE = 8 const F_SETFD = 2 const F_SETFL = 4 const F_SETLEASE = 1024 const F_SETLK = 6 const F_SETLK64 = 6 const F_SETLKW = 7 const F_SETLKW64 = 7 const F_SETOWN = 8 const F_SETOWN_EX = 15 const F_SETPIPE_SZ = 1031 const F_SETSIG = 10 const F_SET_FILE_RW_HINT = 1038 const F_SET_RW_HINT = 1036 const F_TEST = 3 const F_TLOCK = 2 const F_ULOCK = 0 const F_UNLCK = 2 const F_WRLCK = 1 const False = 0 const FamilyChaos = 2 const FamilyDECnet = 1 const FamilyInternet = 0 const FamilyInternet6 = 6 const FamilyServerInterpreted = 5 const FillOpaqueStippled = 3 const FillSolid = 0 const FillStippled = 2 const FillTiled = 1 const FirstExtensionError = 128 const FocusChangeMask = 2097152 const FocusIn = 9 const FocusOut = 10 const FontChange = 255 const FontLeftToRight = 0 const FontRightToLeft = 1 const ForgetGravity = 0 const GCArcMode = 4194304 const GCBackground = 8 const GCCapStyle = 64 const GCClipMask = 524288 const GCClipXOrigin = 131072 const GCClipYOrigin = 262144 const GCDashList = 2097152 const GCDashOffset = 1048576 const GCFillRule = 512 const GCFillStyle = 256 const GCFont = 16384 const GCForeground = 4 const GCFunction = 1 const GCGraphicsExposures = 65536 const GCJoinStyle = 128 const GCLastBit = 22 const GCLineStyle = 32 const GCLineWidth = 16 const GCPlaneMask = 2 const GCStipple = 2048 const GCSubwindowMode = 32768 const GCTile = 1024 const GCTileStipXOrigin = 4096 const GCTileStipYOrigin = 8192 const GXand = 1 const GXandInverted = 4 const GXandReverse = 2 const GXclear = 0 const GXcopy = 3 const GXcopyInverted = 12 const GXequiv = 9 const GXinvert = 10 const GXnand = 14 const GXnoop = 5 const GXnor = 8 const GXor = 7 const GXorInverted = 13 const GXorReverse = 11 const GXset = 15 const GXxor = 6 const GenericEvent = 35 const GrabFrozen = 4 const GrabInvalidTime = 2 const GrabModeAsync = 1 const GrabModeSync = 0 const GrabNotViewable = 3 const GrabSuccess = 0 const GraphicsExpose = 13 const GravityNotify = 24 const GrayScale = 1 const HAVE_CAST_TO_UNION = 1 const HAVE_HIDDEN = 1 const HAVE_INTPTR_T = 1 const HAVE_INTTYPES_H = 1 const HAVE_POSIX_SPAWNATTR_SETFLAGS = 1 const HAVE_POSIX_SPAWNP = 1 const HAVE_POSIX_SPAWN_FILE_ACTIONS_ADDDUP2 = 1 const HAVE_PW_GECOS = 1 const HAVE_STDBOOL_H = 1 const HAVE_STDINT_H = 1 const HAVE_STDIO_H = 1 const HAVE_STDLIB_H = 1 const HAVE_STRINGS_H = 1 const HAVE_STRING_H = 1 const HAVE_SYS_STAT_H = 1 const HAVE_SYS_TIME_H = 1 const HAVE_SYS_TYPES_H = 1 const HAVE_UINTPTR_T = 1 const HAVE_UNISTD_H = 1 const HAVE_VFORK = 1 const HDC = 0 const HINSTANCE = 0 const HMENU = 0 const HOST_NAME_MAX = 255 const HPALETTE = 0 const HUGE = 0 const HUGE_VALF = 0 const HWND = 0 const HeightValue = 8 const HostDelete = 1 const HostInsert = 0 const INFINITY = 0 const INT16_MAX = 32767 const INT16_MIN = -32768 const INT32_MAX = 2147483647 const INT32_MIN = -2147483648 const INT64_MAX = 9223372036854775807 const INT64_MIN = -9223372036854775808 const INT8_MAX = 127 const INT8_MIN = -128 const INTMAX_MAX = 9223372036854775807 const INTMAX_MIN = -9223372036854775808 const INTPTR_MAX = 9223372036854775807 const INTPTR_MIN = -9223372036854775808 const INT_FAST16_MAX = 2147483647 const INT_FAST16_MIN = -2147483648 const INT_FAST32_MAX = 2147483647 const INT_FAST32_MIN = -2147483648 const INT_FAST64_MAX = 9223372036854775807 const INT_FAST64_MIN = -9223372036854775808 const INT_FAST8_MAX = 127 const INT_FAST8_MIN = -128 const INT_LEAST16_MAX = 32767 const INT_LEAST16_MIN = -32768 const INT_LEAST32_MAX = 2147483647 const INT_LEAST32_MIN = -2147483648 const INT_LEAST64_MAX = 9223372036854775807 const INT_LEAST64_MIN = -9223372036854775808 const INT_LEAST8_MAX = 127 const INT_LEAST8_MIN = -128 const INT_MAX = 2147483647 const INT_MIN = -2147483648 const IOV_MAX = 1024 const ITIMER_PROF = 2 const ITIMER_REAL = 0 const ITIMER_VIRTUAL = 1 const IconMaskHint = 32 const IconPixmapHint = 4 const IconPositionHint = 16 const IconWindowHint = 8 const IconicState = 3 const InactiveState = 4 const IncludeInferiors = 1 const InputFocus = 1 const InputHint = 1 const InputOnly = 2 const InputOutput = 1 const IsUnmapped = 0 const IsUnviewable = 1 const IsViewable = 2 const JoinBevel = 2 const JoinMiter = 0 const JoinRound = 1 const KBAutoRepeatMode = 128 const KBBellDuration = 8 const KBBellPercent = 2 const KBBellPitch = 4 const KBKey = 64 const KBKeyClickPercent = 1 const KBLed = 16 const KBLedMode = 32 const KeyPress = 2 const KeyPressMask = 1 const KeyRelease = 3 const KeyReleaseMask = 2 const KeymapNotify = 11 const KeymapStateMask = 16384 const LASTEvent = 36 const LINE_MAX = 4096 const LITTLE_ENDIAN = 1234 const LLONG_MAX = 9223372036854775807 const LLONG_MIN = -9223372036854775808 const LOCK_EX = 2 const LOCK_NB = 4 const LOCK_SH = 1 const LOCK_UN = 8 const LOGIN_NAME_MAX = 256 const LONG_BIT = 64 const LONG_MAX = 9223372036854775807 const LONG_MIN = -9223372036854775808 const LPARAM = 0 const LRESULT = 0 const LSBFirst = 0 const L_INCR = 1 const L_SET = 0 const L_XTND = 2 const L_ctermid = 20 const L_cuserid = 20 const L_tmpnam = 20 const LastExtensionError = 255 const LeaveNotify = 8 const LeaveWindowMask = 32 const LedModeOff = 0 const LedModeOn = 1 const LineDoubleDash = 2 const LineOnOffDash = 1 const LineSolid = 0 const LockMapIndex = 1 const LockMask = 2 const LowerHighest = 1 const MATH_ERREXCEPT = 2 const MATH_ERRNO = 1 const MAX_HANDLE_SZ = 128 const MAX_INTENSITY = 65535 const MB_CUR_MAX = 0 const MB_LEN_MAX = 4 const META_MASK = 65536 const MQ_PRIO_MAX = 32768 const MSBFirst = 1 const M_1_PI = 0 const M_2_PI = 0 const M_2_SQRTPI = 0 const M_E = 0 const M_LN10 = 0 const M_LN2 = 0 const M_LOG10E = 0 const M_LOG2E = 0 const M_PI = 0 const M_PI_2 = 0 const M_PI_4 = 0 const M_SQRT1_2 = 0 const M_SQRT2 = 0 const MapNotify = 19 const MapRequest = 20 const MappingBusy = 1 const MappingFailed = 2 const MappingKeyboard = 1 const MappingModifier = 0 const MappingNotify = 34 const MappingPointer = 2 const MappingSuccess = 0 const Mod1MapIndex = 3 const Mod1Mask = 8 const Mod2MapIndex = 4 const Mod2Mask = 16 const Mod3MapIndex = 5 const Mod3Mask = 32 const Mod4MapIndex = 6 const Mod4Mask = 64 const Mod5MapIndex = 7 const Mod5Mask = 128 const MotionNotify = 6 const MouseWheelEvent = 38 const MouseWheelMask = 268435456 const NAME_MAX = 255 const NAN = 0 const NBBY = 8 const NDEBUG = 1 const NGROUPS_MAX = 32 const NL_ARGMAX = 9 const NL_LANGMAX = 32 const NL_MSGMAX = 32767 const NL_NMAX = 16 const NL_SETMAX = 255 const NL_TEXTMAX = 2048 const NUM_STATIC_TOKENS = 20 const NZERO = 20 const NeedFunctionPrototypes = 1 const NeedNestedPrototypes = 1 const NeedVarargsPrototypes = 1 const NeedWidePrototypes = 0 const NoEventMask = 0 const NoExpose = 14 const NoSymbol = 0 const NoValue = 0 const Nonconvex = 1 const None = 0 const NormalState = 1 const NorthEastGravity = 3 const NorthGravity = 2 const NorthWestGravity = 1 const NotUseful = 0 const NotifyAncestor = 0 const NotifyDetailNone = 7 const NotifyGrab = 1 const NotifyHint = 1 const NotifyInferior = 2 const NotifyNonlinear = 3 const NotifyNonlinearVirtual = 4 const NotifyNormal = 0 const NotifyPointer = 5 const NotifyPointerRoot = 6 const NotifyUngrab = 2 const NotifyVirtual = 1 const NotifyWhileGrabbed = 3 const O_ACCMODE = 2097155 const O_APPEND = 1024 const O_ASYNC = 8192 const O_CLOEXEC = 524288 const O_CREAT = 64 const O_DIRECT = 131072 const O_DIRECTORY = 16384 const O_DSYNC = 4096 const O_EXCL = 128 const O_EXEC = 2097152 const O_LARGEFILE = 65536 const O_NDELAY = 2048 const O_NOATIME = 262144 const O_NOCTTY = 256 const O_NOFOLLOW = 32768 const O_NONBLOCK = 2048 const O_PATH = 2097152 const O_RDONLY = 0 const O_RDWR = 2 const O_RSYNC = 1052672 const O_SEARCH = 2097152 const O_SYNC = 1052672 const O_TMPFILE = 4210688 const O_TRUNC = 512 const O_TTY_INIT = 0 const O_WRONLY = 1 const Opposite = 4 const OwnerGrabButtonMask = 16777216 const PACKAGE_BUGREPORT = "" const PACKAGE_NAME = "tk" const PACKAGE_STRING = "tk 9.0" const PACKAGE_TARNAME = "tk" const PACKAGE_URL = "" const PACKAGE_VERSION = "9.0" const PATH_MAX = 4096 const PAllHints = 252 const PAspect = 128 const PBaseSize = 256 const PDP_ENDIAN = 3412 const PI = 0 const PIPE_BUF = 4096 const PMaxSize = 32 const PMinSize = 16 const POSIX_CLOSE_RESTART = 0 const POSIX_FADV_DONTNEED = 4 const POSIX_FADV_NOREUSE = 5 const POSIX_FADV_NORMAL = 0 const POSIX_FADV_RANDOM = 1 const POSIX_FADV_SEQUENTIAL = 2 const POSIX_FADV_WILLNEED = 3 const PPosition = 4 const PRIX16 = "X" const PRIX32 = "X" const PRIX8 = "X" const PRIXFAST16 = "X" const PRIXFAST32 = "X" const PRIXFAST8 = "X" const PRIXLEAST16 = "X" const PRIXLEAST32 = "X" const PRIXLEAST8 = "X" const PRId16 = "d" const PRId32 = "d" const PRId8 = "d" const PRIdFAST16 = "d" const PRIdFAST32 = "d" const PRIdFAST8 = "d" const PRIdLEAST16 = "d" const PRIdLEAST32 = "d" const PRIdLEAST8 = "d" const PRIi16 = "i" const PRIi32 = "i" const PRIi8 = "i" const PRIiFAST16 = "i" const PRIiFAST32 = "i" const PRIiFAST8 = "i" const PRIiLEAST16 = "i" const PRIiLEAST32 = "i" const PRIiLEAST8 = "i" const PRIo16 = "o" const PRIo32 = "o" const PRIo8 = "o" const PRIoFAST16 = "o" const PRIoFAST32 = "o" const PRIoFAST8 = "o" const PRIoLEAST16 = "o" const PRIoLEAST32 = "o" const PRIoLEAST8 = "o" const PRIu16 = "u" const PRIu32 = "u" const PRIu8 = "u" const PRIuFAST16 = "u" const PRIuFAST32 = "u" const PRIuFAST8 = "u" const PRIuLEAST16 = "u" const PRIuLEAST32 = "u" const PRIuLEAST8 = "u" const PRIx16 = "x" const PRIx32 = "x" const PRIx8 = "x" const PRIxFAST16 = "x" const PRIxFAST32 = "x" const PRIxFAST8 = "x" const PRIxLEAST16 = "x" const PRIxLEAST32 = "x" const PRIxLEAST8 = "x" const PResizeInc = 64 const PSize = 8 const PTHREAD_DESTRUCTOR_ITERATIONS = 4 const PTHREAD_KEYS_MAX = 128 const PTHREAD_STACK_MIN = 2048 const PTRDIFF_MAX = 9223372036854775807 const PTRDIFF_MIN = -9223372036854775808 const PWinGravity = 512 const P_tmpdir = "/tmp" const ParentRelative = 1 const PlaceOnBottom = 1 const PlaceOnTop = 0 const PointerMotionHintMask = 128 const PointerMotionMask = 64 const PointerRoot = 1 const PointerWindow = 0 const PreferBlanking = 1 const PropModeAppend = 2 const PropModePrepend = 1 const PropModeReplace = 0 const PropertyChangeMask = 4194304 const PropertyDelete = 1 const PropertyNewValue = 0 const PropertyNotify = 28 const PseudoColor = 3 const QueuedAfterFlush = 2 const QueuedAfterReading = 1 const QueuedAlready = 0 const RAND_MAX = 2147483647 const RE_DUP_MAX = 255 const RWF_WRITE_LIFE_NOT_SET = 0 const RWH_WRITE_LIFE_EXTREME = 5 const RWH_WRITE_LIFE_LONG = 4 const RWH_WRITE_LIFE_MEDIUM = 3 const RWH_WRITE_LIFE_NONE = 1 const RWH_WRITE_LIFE_SHORT = 2 const R_OK = 4 const RaiseLowest = 0 const RectangleIn = 1 const RectangleOut = 0 const RectanglePart = 2 const ReparentNotify = 21 const ReplayKeyboard = 5 const ReplayPointer = 2 const ResizeRedirectMask = 262144 const ResizeRequest = 25 const RetainPermanent = 1 const RetainTemporary = 2 const RevertToParent = 2 const SCHAR_MAX = 127 const SCHAR_MIN = -128 const SCNd16 = "hd" const SCNd32 = "d" const SCNd8 = "hhd" const SCNdFAST16 = "d" const SCNdFAST32 = "d" const SCNdFAST8 = "hhd" const SCNdLEAST16 = "hd" const SCNdLEAST32 = "d" const SCNdLEAST8 = "hhd" const SCNi16 = "hi" const SCNi32 = "i" const SCNi8 = "hhi" const SCNiFAST16 = "i" const SCNiFAST32 = "i" const SCNiFAST8 = "hhi" const SCNiLEAST16 = "hi" const SCNiLEAST32 = "i" const SCNiLEAST8 = "hhi" const SCNo16 = "ho" const SCNo32 = "o" const SCNo8 = "hho" const SCNoFAST16 = "o" const SCNoFAST32 = "o" const SCNoFAST8 = "hho" const SCNoLEAST16 = "ho" const SCNoLEAST32 = "o" const SCNoLEAST8 = "hho" const SCNu16 = "hu" const SCNu32 = "u" const SCNu8 = "hhu" const SCNuFAST16 = "u" const SCNuFAST32 = "u" const SCNuFAST8 = "hhu" const SCNuLEAST16 = "hu" const SCNuLEAST32 = "u" const SCNuLEAST8 = "hhu" const SCNx16 = "hx" const SCNx32 = "x" const SCNx8 = "hhx" const SCNxFAST16 = "x" const SCNxFAST32 = "x" const SCNxFAST8 = "hhx" const SCNxLEAST16 = "hx" const SCNxLEAST32 = "x" const SCNxLEAST8 = "hhx" const SEEK_DATA = 3 const SEEK_HOLE = 4 const SELECT_MASK = 0 const SEM_NSEMS_MAX = 256 const SEM_VALUE_MAX = 2147483647 const SHRT_MAX = 32767 const SHRT_MIN = -32768 const SIG_ATOMIC_MAX = 2147483647 const SIG_ATOMIC_MIN = -2147483648 const SIZE_MAX = 18446744073709551615 const SPLICE_F_GIFT = 8 const SPLICE_F_MORE = 4 const SPLICE_F_MOVE = 1 const SPLICE_F_NONBLOCK = 2 const SSIZE_MAX = 9223372036854775807 const STATIC_BUILD = 1 const STATX_ALL = 4095 const STATX_ATIME = 32 const STATX_BASIC_STATS = 2047 const STATX_BLOCKS = 1024 const STATX_BTIME = 2048 const STATX_CTIME = 128 const STATX_GID = 16 const STATX_INO = 256 const STATX_MODE = 2 const STATX_MTIME = 64 const STATX_NLINK = 4 const STATX_SIZE = 512 const STATX_TYPE = 1 const STATX_UID = 8 const STDC_HEADERS = 1 const STDERR_FILENO = 2 const STDIN_FILENO = 0 const STDOUT_FILENO = 1 const SYMLOOP_MAX = 40 const SYNC_FILE_RANGE_WAIT_AFTER = 4 const SYNC_FILE_RANGE_WAIT_BEFORE = 1 const SYNC_FILE_RANGE_WRITE = 2 const S_IEXEC = 64 const S_IFBLK = 24576 const S_IFCHR = 8192 const S_IFDIR = 16384 const S_IFIFO = 4096 const S_IFLNK = 40960 const S_IFMT = 61440 const S_IFREG = 32768 const S_IFSOCK = 49152 const S_IREAD = 256 const S_IRGRP = 32 const S_IROTH = 4 const S_IRUSR = 256 const S_IRWXG = 56 const S_IRWXO = 7 const S_IRWXU = 448 const S_ISGID = 1024 const S_ISUID = 2048 const S_ISVTX = 512 const S_IWGRP = 16 const S_IWOTH = 2 const S_IWRITE = 128 const S_IWUSR = 128 const S_IXGRP = 8 const S_IXOTH = 1 const S_IXUSR = 64 const ScreenSaverActive = 1 const ScreenSaverReset = 0 const SelectionClear = 29 const SelectionNotify = 31 const SelectionRequest = 30 const SetModeDelete = 1 const SetModeInsert = 0 const ShiftMapIndex = 0 const ShiftMask = 1 const SouthEastGravity = 9 const SouthGravity = 8 const SouthWestGravity = 7 const StateHint = 2 const StaticColor = 2 const StaticGravity = 10 const StaticGray = 0 const Status = 0 const StippleShape = 2 const StructureNotifyMask = 131072 const SubstructureNotifyMask = 524288 const SubstructureRedirectMask = 1048576 const Success = 0 const SyncBoth = 7 const SyncKeyboard = 4 const SyncPointer = 1 const TCL_ALLOW_INLINE_COMPILATION = 131072 const TCL_ALL_EVENTS = -3 const TCL_ALPHA_RELEASE = 0 const TCL_APPEND_VALUE = 4 const TCL_ARGV_CONSTANT = 15 const TCL_ARGV_END = 23 const TCL_ARGV_FLOAT = 19 const TCL_ARGV_FUNC = 20 const TCL_ARGV_GENFUNC = 21 const TCL_ARGV_HELP = 22 const TCL_ARGV_INT = 16 const TCL_ARGV_REST = 18 const TCL_ARGV_STRING = 17 const TCL_AUTO_LENGTH = -1 const TCL_BETA_RELEASE = 1 const TCL_BREAK = 3 const TCL_CANCEL_UNWIND = 1048576 const TCL_CFGVAL_ENCODING = "utf-8" const TCL_CFG_DO64BIT = 1 const TCL_CFG_OPTIMIZED = 1 const TCL_CHANNEL_THREAD_INSERT = 0 const TCL_CHANNEL_THREAD_REMOVE = 1 const TCL_CLOSE2PROC = "NULL" const TCL_CLOSE_READ = 2 const TCL_CLOSE_WRITE = 4 const TCL_CODE_USER_MAX = 1073741823 const TCL_CODE_USER_MIN = 5 const TCL_COMBINE = 16777216 const TCL_CONTINUE = 4 const TCL_CONVERT_MULTIBYTE = -1 const TCL_CONVERT_NOSPACE = -4 const TCL_CONVERT_SYNTAX = -2 const TCL_CONVERT_UNKNOWN = -3 const TCL_CREATE_HARD_LINK = 2 const TCL_CREATE_SYMBOLIC_LINK = 1 const TCL_CUSTOM_PTR_KEYS = -1 const TCL_CUSTOM_TYPE_KEYS = -2 const TCL_DONT_QUOTE_HASH = 8 const TCL_DONT_USE_BRACES = 1 const TCL_DONT_WAIT = 2 const TCL_DOUBLE_SPACE = 27 const TCL_DSTRING_STATIC_SIZE = 200 const TCL_ENCODING_CHAR_LIMIT = 16 const TCL_ENCODING_END = 2 const TCL_ENCODING_INTERNAL_USE_MASK = 65280 const TCL_ENCODING_NO_TERMINATE = 8 const TCL_ENCODING_PROFILE_REPLACE = 33554432 const TCL_ENCODING_PROFILE_STRICT = 0 const TCL_ENCODING_PROFILE_TCL8 = 16777216 const TCL_ENCODING_START = 1 const TCL_ENCODING_STOPONERROR = 0 const TCL_ENFORCE_MODE = 16 const TCL_ENSEMBLE_PREFIX = 2 const TCL_ERROR = 1 const TCL_EVAL_DIRECT = 262144 const TCL_EVAL_GLOBAL = 131072 const TCL_EVAL_INVOKE = 524288 const TCL_EVAL_NOERR = 2097152 const TCL_EXACT = 1 const TCL_EXCEPTION = 8 const TCL_FILE_EVENTS = 8 const TCL_FINAL_RELEASE = 2 const TCL_GLOBAL_ONLY = 1 const TCL_GLOB_PERM_HIDDEN = 2 const TCL_GLOB_PERM_R = 4 const TCL_GLOB_PERM_RONLY = 1 const TCL_GLOB_PERM_W = 8 const TCL_GLOB_PERM_X = 16 const TCL_GLOB_TYPE_BLOCK = 1 const TCL_GLOB_TYPE_CHAR = 2 const TCL_GLOB_TYPE_DIR = 4 const TCL_GLOB_TYPE_FILE = 16 const TCL_GLOB_TYPE_LINK = 32 const TCL_GLOB_TYPE_MOUNT = 128 const TCL_GLOB_TYPE_PIPE = 8 const TCL_GLOB_TYPE_SOCK = 64 const TCL_HASH_KEY_DIRECT_COMPARE = 4 const TCL_HASH_KEY_RANDOMIZE_HASH = 1 const TCL_HASH_KEY_SYSTEM_HASH = 2 const TCL_HASH_KEY_TYPE_VERSION = 1 const TCL_HASH_TYPE = 0 const TCL_IDLE_EVENTS = 32 const TCL_INDEX_NONE = -1 const TCL_INDEX_TEMP_TABLE = 64 const TCL_IO_FAILURE = -1 const TCL_LEAVE_ERR_MSG = 512 const TCL_LIMIT_COMMANDS = 1 const TCL_LIMIT_TIME = 2 const TCL_LINK_BINARY = 16 const TCL_LINK_BOOLEAN = 3 const TCL_LINK_CHAR = 6 const TCL_LINK_CHARS = 15 const TCL_LINK_DOUBLE = 2 const TCL_LINK_FLOAT = 13 const TCL_LINK_INT = 1 const TCL_LINK_LONG = 1 const TCL_LINK_READ_ONLY = 128 const TCL_LINK_SHORT = 8 const TCL_LINK_STRING = 4 const TCL_LINK_UCHAR = 7 const TCL_LINK_UINT = 10 const TCL_LINK_ULONG = 10 const TCL_LINK_USHORT = 9 const TCL_LINK_WIDE_INT = 5 const TCL_LINK_WIDE_UINT = 14 const TCL_LIST_ELEMENT = 8 const TCL_LOAD_GLOBAL = 1 const TCL_LOAD_LAZY = 2 const TCL_MAJOR_VERSION = 9 const TCL_MATCH_NOCASE = 1 const TCL_MAX_PREC = 17 const TCL_MINOR_VERSION = 0 const TCL_MODE_BLOCKING = 0 const TCL_MODE_NONBLOCKING = 1 const TCL_NAMESPACE_ONLY = 2 const TCL_NO_EVAL = 65536 const TCL_NULL_OK = 32 const TCL_NUMBER_BIG = 3 const TCL_NUMBER_DOUBLE = 4 const TCL_NUMBER_INT = 2 const TCL_NUMBER_NAN = 5 const TCL_OBJTYPE_V0 = 0 const TCL_OK = 0 const TCL_ONE_WORD_KEYS = 1 const TCL_PARSE_BAD_NUMBER = 9 const TCL_PARSE_BRACE_EXTRA = 2 const TCL_PARSE_MISSING_BRACE = 3 const TCL_PARSE_MISSING_BRACKET = 4 const TCL_PARSE_MISSING_PAREN = 5 const TCL_PARSE_MISSING_QUOTE = 6 const TCL_PARSE_MISSING_VAR_BRACE = 7 const TCL_PARSE_QUOTE_EXTRA = 1 const TCL_PARSE_SUCCESS = 0 const TCL_PARSE_SYNTAX = 8 const TCL_PATCH_LEVEL = "9.0.1" const TCL_READABLE = 2 const TCL_REG_ADVANCED = 3 const TCL_REG_ADVF = 2 const TCL_REG_BASIC = 0 const TCL_REG_CANMATCH = 512 const TCL_REG_EXPANDED = 32 const TCL_REG_EXTENDED = 1 const TCL_REG_NEWLINE = 192 const TCL_REG_NLANCH = 128 const TCL_REG_NLSTOP = 64 const TCL_REG_NOCASE = 8 const TCL_REG_NOSUB = 16 const TCL_REG_NOTBOL = 1 const TCL_REG_NOTEOL = 2 const TCL_REG_QUOTE = 4 const TCL_RELEASE_LEVEL = 2 const TCL_RELEASE_SERIAL = 1 const TCL_RETURN = 2 const TCL_SERVICE_ALL = 1 const TCL_SERVICE_NONE = 0 const TCL_SHLIB_EXT = ".so" const TCL_SIZE_MODIFIER = "TCL_T_MODIFIER" const TCL_SMALL_HASH_TABLE = 4 const TCL_STDERR = 8 const TCL_STDIN = 2 const TCL_STDOUT = 4 const TCL_STRING_KEYS = 0 const TCL_SUBST_ALL = 7 const TCL_SUBST_BACKSLASHES = 4 const TCL_SUBST_COMMANDS = 1 const TCL_SUBST_VARIABLES = 2 const TCL_TCPSERVER_REUSEADDR = 1 const TCL_TCPSERVER_REUSEPORT = 2 const TCL_THREAD_JOINABLE = 1 const TCL_THREAD_NOFLAGS = 0 const TCL_THREAD_STACK_DEFAULT = 0 const TCL_TIMER_EVENTS = 16 const TCL_TOKEN_BS = 8 const TCL_TOKEN_COMMAND = 16 const TCL_TOKEN_EXPAND_WORD = 256 const TCL_TOKEN_OPERATOR = 128 const TCL_TOKEN_SIMPLE_WORD = 2 const TCL_TOKEN_SUB_EXPR = 64 const TCL_TOKEN_TEXT = 4 const TCL_TOKEN_VARIABLE = 32 const TCL_TOKEN_WORD = 1 const TCL_TRACE_ARRAY = 2048 const TCL_TRACE_DELETE = 16384 const TCL_TRACE_DESTROYED = 128 const TCL_TRACE_READS = 16 const TCL_TRACE_RENAME = 8192 const TCL_TRACE_RESULT_DYNAMIC = 32768 const TCL_TRACE_RESULT_OBJECT = 65536 const TCL_TRACE_UNSETS = 64 const TCL_TRACE_WRITES = 32 const TCL_T_MODIFIER = "t" const TCL_UNLOAD_DETACH_FROM_INTERPRETER = 1 const TCL_UNLOAD_DETACH_FROM_PROCESS = 2 const TCL_UTF_MAX = 4 const TCL_VERSION = "9.0" const TCL_WIDE_INT_IS_LONG = 1 const TCL_WINDOW_EVENTS = 4 const TCL_WRITABLE = 4 const TCL_ZLIB_COMPRESS_BEST = 9 const TCL_ZLIB_COMPRESS_DEFAULT = -1 const TCL_ZLIB_COMPRESS_FAST = 1 const TCL_ZLIB_COMPRESS_NONE = 0 const TCL_ZLIB_FINALIZE = 4 const TCL_ZLIB_FLUSH = 2 const TCL_ZLIB_FORMAT_AUTO = 8 const TCL_ZLIB_FORMAT_GZIP = 4 const TCL_ZLIB_FORMAT_RAW = 1 const TCL_ZLIB_FORMAT_ZLIB = 2 const TCL_ZLIB_FULLFLUSH = 3 const TCL_ZLIB_NO_FLUSH = 0 const TCL_ZLIB_STREAM_DEFLATE = 16 const TCL_ZLIB_STREAM_INFLATE = 32 const TCL_Z_MODIFIER = "z" const TIMER_ABSTIME = 1 const TIME_UTC = 1 const TKP_CLIP_PIXMAP = 0 const TKP_CLIP_REGION = 1 const TK_3D_DARK_GC = 3 const TK_3D_FLAT_GC = 1 const TK_3D_LIGHT_GC = 2 const TK_ALREADY_DEAD = 4 const TK_ALWAYS_REDRAW = 1 const TK_ANONYMOUS_WINDOW = 16384 const TK_ARGV_CONSTANT = 15 const TK_ARGV_CONST_OPTION = 24 const TK_ARGV_DONT_SKIP_FIRST_ARG = 8 const TK_ARGV_END = 27 const TK_ARGV_FLOAT = 20 const TK_ARGV_FUNC = 21 const TK_ARGV_GENFUNC = 22 const TK_ARGV_HELP = 23 const TK_ARGV_INT = 16 const TK_ARGV_NO_ABBREV = 4 const TK_ARGV_NO_DEFAULTS = 1 const TK_ARGV_NO_LEFTOVERS = 2 const TK_ARGV_OPTION_NAME_VALUE = 26 const TK_ARGV_OPTION_VALUE = 25 const TK_ARGV_REST = 19 const TK_ARGV_STRING = 17 const TK_ARGV_UID = 18 const TK_AT_LEAST_ONE = 2 const TK_BOTH_HALVES = 1024 const TK_CAN_INPUT_TEXT = 1048576 const TK_CHECKED_IC = 32 const TK_CONFIG_ARGV_ONLY = 1 const TK_CONFIG_COLOR_ONLY = 2 const TK_CONFIG_DONT_SET_DEFAULT = 8 const TK_CONFIG_MONO_ONLY = 4 const TK_CONFIG_NULL_OK = 32 const TK_CONFIG_OBJS = 128 const TK_CONFIG_USER_BIT = 256 const TK_CONTAINER = 512 const TK_DISPLAY_COLLAPSE_MOTION_EVENTS = 1 const TK_DISPLAY_USE_IM = 2 const TK_DISPLAY_WM_TRACING = 8 const TK_DONT_DESTROY_WINDOW = 64 const TK_ELEMENT_STATE_ACTIVE = 1 const TK_ELEMENT_STATE_DISABLED = 2 const TK_ELEMENT_STATE_FOCUS = 4 const TK_ELEMENT_STATE_PRESSED = 8 const TK_EMBEDDED = 256 const TK_GRAB_ANCESTOR = 2 const TK_GRAB_EXCLUDED = 3 const TK_GRAB_FLAG = 16 const TK_GRAB_IN_TREE = 1 const TK_GRAB_NONE = 0 const TK_HAS_WRAPPER = 32768 const TK_IGNORE_NEWLINES = 16 const TK_IGNORE_TABS = 8 const TK_INTERACTIVE_PRIO = 80 const TK_ISOLATE_END = 32 const TK_ITEM_DONT_REDRAW = 2 const TK_ITEM_STATE_DEPENDANT = 1 const TK_LASTEVENT = 40 const TK_MAJOR_VERSION = 9 const TK_MAKE_MENU_DROPDOWN = 2 const TK_MAKE_MENU_POPUP = 1 const TK_MAKE_MENU_TEAROFF = 0 const TK_MAPPED = 1 const TK_MAX_PRIO = 100 const TK_MINOR_VERSION = 0 const TK_MOVABLE_POINTS = 2 const TK_NEED_CONFIG_NOTIFY = 8 const TK_NOTIFY_SHARE = 20 const TK_NUM_SAVED_OPTIONS = 20 const TK_OFFSET_BOTTOM = 128 const TK_OFFSET_CENTER = 8 const TK_OFFSET_INDEX = 1 const TK_OFFSET_LEFT = 4 const TK_OFFSET_MIDDLE = 64 const TK_OFFSET_RELATIVE = 2 const TK_OFFSET_RIGHT = 16 const TK_OFFSET_TOP = 32 const TK_OPTION_DONT_SET_DEFAULT = 8 const TK_OPTION_NULL_OK = 32 const TK_PARTIAL_OK = 4 const TK_PATCH_LEVEL = "9.0.1" const TK_PHOTO_COMPOSITE_OVERLAY = 0 const TK_PHOTO_COMPOSITE_SET = 1 const TK_PROP_PROPCHANGE = 262144 const TK_RELEASE_LEVEL = 2 const TK_RELEASE_SERIAL = 1 const TK_RELIEF_FLAT = 0 const TK_RELIEF_GROOVE = 1 const TK_RELIEF_NULL = -1 const TK_RELIEF_RAISED = 2 const TK_RELIEF_RIDGE = 3 const TK_RELIEF_SOLID = 4 const TK_RELIEF_SUNKEN = 5 const TK_REPARENTED = 8192 const TK_SCROLL_ERROR = 4 const TK_SCROLL_MOVETO = 1 const TK_SCROLL_PAGES = 2 const TK_SCROLL_UNITS = 3 const TK_STARTUP_FILE_PRIO = 40 const TK_STYLE_VERSION = 1 const TK_STYLE_VERSION_1 = 1 const TK_TAG_SPACE = 3 const TK_TOP_HIERARCHY = 131072 const TK_TOP_LEVEL = 2 const TK_USER_DEFAULT_PRIO = 60 const TK_VERSION = "9.0" const TK_WHOLE_WORDS = 1 const TK_WIDGET_DEFAULT_PRIO = 20 const TK_WIN_MANAGED = 65536 const TK_WM_COLORMAP_WINDOW = 128 const TK_WM_MANAGEABLE = 524288 const TK_WRAPPER = 4096 const TMP_MAX = 10000 const TTY_NAME_MAX = 32 const TZNAME_MAX = 6 const Tcl_CreateSlave = 0 const Tcl_EncodingFreeProc = 0 const Tcl_ExitProc = 0 const Tcl_FSFreeInternalRepProc = 0 const Tcl_FileFreeProc = 0 const Tcl_GetMaster = 0 const Tcl_GetSlave = 0 const Tcl_LimitHandlerDeleteProc = 0 const Tcl_PackageInitProc = 0 const Tcl_PackageUnloadProc = 0 const Tcl_StaticPackage = 0 const Tcl_ThreadCreateType = 0 const TileShape = 1 const TkClipBox = 0 const TkCreateRegion = 0 const TkDestroyRegion = 0 const TkIntersectRegion = 0 const TkRectInRegion = 0 const TkRegion = 0 const TkSetRegion = 0 const TkSubtractRegion = 0 const TkUnionRectWithRegion = 0 const TkWinDCState = 0 const Tk_GeomLostSlaveProc = 0 const Tk_GetImageMasterData = 0 const Tk_ImageMaster = 0 const TopIf = 2 const TouchpadScroll = 39 const TouchpadScrollMask = 134217728 const True = 1 const TrueColor = 4 const UCHAR_MAX = 255 const UINT16_MAX = 65535 const UINT32_MAX = 4294967295 const UINT64_MAX = 18446744073709551615 const UINT8_MAX = 255 const UINTMAX_MAX = 18446744073709551615 const UINTPTR_MAX = 18446744073709551615 const UINT_FAST16_MAX = 4294967295 const UINT_FAST32_MAX = 4294967295 const UINT_FAST64_MAX = 18446744073709551615 const UINT_FAST8_MAX = 255 const UINT_LEAST16_MAX = 65535 const UINT_LEAST32_MAX = 4294967295 const UINT_LEAST64_MAX = 18446744073709551615 const UINT_LEAST8_MAX = 255 const UINT_MAX = 4294967295 const ULLONG_MAX = 18446744073709551615 const ULONG_MAX = 18446744073709551615 const USHRT_MAX = 65535 const USPosition = 1 const USSize = 2 const UTIME_NOW = 1073741823 const UTIME_OMIT = 1073741822 const UnmapGravity = 0 const UnmapNotify = 18 const Unsorted = 0 const VirtualEvent = 35 const VirtualEventMask = 1073741824 const VisibilityChangeMask = 65536 const VisibilityFullyObscured = 2 const VisibilityNotify = 15 const VisibilityPartiallyObscured = 1 const VisibilityUnobscured = 0 const VisualAllMask = 511 const VisualBitsPerRGBMask = 256 const VisualBlueMaskMask = 64 const VisualClassMask = 8 const VisualColormapSizeMask = 128 const VisualDepthMask = 4 const VisualGreenMaskMask = 32 const VisualIDMask = 1 const VisualNoMask = 0 const VisualRedMaskMask = 16 const VisualScreenMask = 2 const WCHAR_MAX = 2147483647 const WCHAR_MIN = -2147483648 const WINT_MAX = 4294967295 const WINT_MIN = 0 const WNDPROC = 0 const WNOHANG = 1 const WORD_BIT = 32 const WPARAM = 0 const WUNTRACED = 2 const W_OK = 2 const WestGravity = 4 const WhenMapped = 1 const WidthValue = 4 const WindingRule = 1 const WindowGroupHint = 64 const WithdrawnState = 0 const XATOM_H = 1 const XBufferOverflow = -1 const XCNOENT = 2 const XCNOMEM = 1 const XCSUCCESS = 0 const XC_X_cursor = 0 const XC_arrow = 2 const XC_based_arrow_down = 4 const XC_based_arrow_up = 6 const XC_boat = 8 const XC_bogosity = 10 const XC_bottom_left_corner = 12 const XC_bottom_right_corner = 14 const XC_bottom_side = 16 const XC_bottom_tee = 18 const XC_box_spiral = 20 const XC_center_ptr = 22 const XC_circle = 24 const XC_clock = 26 const XC_coffee_mug = 28 const XC_cross = 30 const XC_cross_reverse = 32 const XC_crosshair = 34 const XC_diamond_cross = 36 const XC_dot = 38 const XC_dotbox = 40 const XC_double_arrow = 42 const XC_draft_large = 44 const XC_draft_small = 46 const XC_draped_box = 48 const XC_exchange = 50 const XC_fleur = 52 const XC_gobbler = 54 const XC_gumby = 56 const XC_hand1 = 58 const XC_hand2 = 60 const XC_heart = 62 const XC_icon = 64 const XC_iron_cross = 66 const XC_left_ptr = 68 const XC_left_side = 70 const XC_left_tee = 72 const XC_leftbutton = 74 const XC_ll_angle = 76 const XC_lr_angle = 78 const XC_man = 80 const XC_middlebutton = 82 const XC_mouse = 84 const XC_num_glyphs = 154 const XC_pencil = 86 const XC_pirate = 88 const XC_plus = 90 const XC_question_arrow = 92 const XC_right_ptr = 94 const XC_right_side = 96 const XC_right_tee = 98 const XC_rightbutton = 100 const XC_rtl_logo = 102 const XC_sailboat = 104 const XC_sb_down_arrow = 106 const XC_sb_h_double_arrow = 108 const XC_sb_left_arrow = 110 const XC_sb_right_arrow = 112 const XC_sb_up_arrow = 114 const XC_sb_v_double_arrow = 116 const XC_shuttle = 118 const XC_sizing = 120 const XC_spider = 122 const XC_spraycan = 124 const XC_star = 126 const XC_target = 128 const XC_tcross = 130 const XC_top_left_arrow = 132 const XC_top_left_corner = 134 const XC_top_right_corner = 136 const XC_top_side = 138 const XC_top_tee = 140 const XC_trek = 142 const XC_ul_angle = 144 const XC_umbrella = 146 const XC_ur_angle = 148 const XC_watch = 150 const XC_xterm = 152 const XConverterNotFound = -3 const XEventSize = 0 const XIMHighlight = 4 const XIMHotKeyStateOFF = 2 const XIMHotKeyStateON = 1 const XIMInitialState = 1 const XIMPreeditArea = 1 const XIMPreeditCallbacks = 2 const XIMPreeditDisable = 2 const XIMPreeditEnable = 1 const XIMPreeditNone = 16 const XIMPreeditNothing = 8 const XIMPreeditPosition = 4 const XIMPreeditUnKnown = 0 const XIMPreserveState = 2 const XIMPrimary = 32 const XIMReverse = 1 const XIMSecondary = 64 const XIMStatusArea = 256 const XIMStatusCallbacks = 512 const XIMStatusNone = 2048 const XIMStatusNothing = 1024 const XIMStringConversionBottomEdge = 8 const XIMStringConversionBuffer = 1 const XIMStringConversionChar = 4 const XIMStringConversionConcealed = 16 const XIMStringConversionLeftEdge = 1 const XIMStringConversionLine = 2 const XIMStringConversionRetrieval = 2 const XIMStringConversionRightEdge = 2 const XIMStringConversionSubstitution = 1 const XIMStringConversionTopEdge = 4 const XIMStringConversionWord = 3 const XIMStringConversionWrapped = 32 const XIMTertiary = 128 const XIMUnderline = 2 const XIMVisibleToBackword = 512 const XIMVisibleToCenter = 1024 const XIMVisibleToForward = 256 const XK_0 = 48 const XK_1 = 49 const XK_2 = 50 const XK_3 = 51 const XK_4 = 52 const XK_5 = 53 const XK_6 = 54 const XK_7 = 55 const XK_8 = 56 const XK_9 = 57 const XK_A = 65 const XK_AE = 198 const XK_Aacute = 193 const XK_Abelowdot = 16785056 const XK_Abreve = 451 const XK_Abreveacute = 16785070 const XK_Abrevebelowdot = 16785078 const XK_Abrevegrave = 16785072 const XK_Abrevehook = 16785074 const XK_Abrevetilde = 16785076 const XK_AccessX_Enable = 65136 const XK_AccessX_Feedback_Enable = 65137 const XK_Acircumflex = 194 const XK_Acircumflexacute = 16785060 const XK_Acircumflexbelowdot = 16785068 const XK_Acircumflexgrave = 16785062 const XK_Acircumflexhook = 16785064 const XK_Acircumflextilde = 16785066 const XK_Adiaeresis = 196 const XK_Agrave = 192 const XK_Ahook = 16785058 const XK_Alt_L = 65513 const XK_Alt_R = 65514 const XK_Amacron = 960 const XK_Aogonek = 417 const XK_Arabic_0 = 16778848 const XK_Arabic_1 = 16778849 const XK_Arabic_2 = 16778850 const XK_Arabic_3 = 16778851 const XK_Arabic_4 = 16778852 const XK_Arabic_5 = 16778853 const XK_Arabic_6 = 16778854 const XK_Arabic_7 = 16778855 const XK_Arabic_8 = 16778856 const XK_Arabic_9 = 16778857 const XK_Arabic_ain = 1497 const XK_Arabic_alef = 1479 const XK_Arabic_alefmaksura = 1513 const XK_Arabic_beh = 1480 const XK_Arabic_comma = 1452 const XK_Arabic_dad = 1494 const XK_Arabic_dal = 1487 const XK_Arabic_damma = 1519 const XK_Arabic_dammatan = 1516 const XK_Arabic_ddal = 16778888 const XK_Arabic_farsi_yeh = 16778956 const XK_Arabic_fatha = 1518 const XK_Arabic_fathatan = 1515 const XK_Arabic_feh = 1505 const XK_Arabic_fullstop = 16778964 const XK_Arabic_gaf = 16778927 const XK_Arabic_ghain = 1498 const XK_Arabic_ha = 1511 const XK_Arabic_hah = 1485 const XK_Arabic_hamza = 1473 const XK_Arabic_hamza_above = 16778836 const XK_Arabic_hamza_below = 16778837 const XK_Arabic_hamzaonalef = 1475 const XK_Arabic_hamzaonwaw = 1476 const XK_Arabic_hamzaonyeh = 1478 const XK_Arabic_hamzaunderalef = 1477 const XK_Arabic_heh = 1511 const XK_Arabic_heh_doachashmee = 16778942 const XK_Arabic_heh_goal = 16778945 const XK_Arabic_jeem = 1484 const XK_Arabic_jeh = 16778904 const XK_Arabic_kaf = 1507 const XK_Arabic_kasra = 1520 const XK_Arabic_kasratan = 1517 const XK_Arabic_keheh = 16778921 const XK_Arabic_khah = 1486 const XK_Arabic_lam = 1508 const XK_Arabic_madda_above = 16778835 const XK_Arabic_maddaonalef = 1474 const XK_Arabic_meem = 1509 const XK_Arabic_noon = 1510 const XK_Arabic_noon_ghunna = 16778938 const XK_Arabic_peh = 16778878 const XK_Arabic_percent = 16778858 const XK_Arabic_qaf = 1506 const XK_Arabic_question_mark = 1471 const XK_Arabic_ra = 1489 const XK_Arabic_rreh = 16778897 const XK_Arabic_sad = 1493 const XK_Arabic_seen = 1491 const XK_Arabic_semicolon = 1467 const XK_Arabic_shadda = 1521 const XK_Arabic_sheen = 1492 const XK_Arabic_sukun = 1522 const XK_Arabic_superscript_alef = 16778864 const XK_Arabic_switch = 65406 const XK_Arabic_tah = 1495 const XK_Arabic_tatweel = 1504 const XK_Arabic_tcheh = 16778886 const XK_Arabic_teh = 1482 const XK_Arabic_tehmarbuta = 1481 const XK_Arabic_thal = 1488 const XK_Arabic_theh = 1483 const XK_Arabic_tteh = 16778873 const XK_Arabic_veh = 16778916 const XK_Arabic_waw = 1512 const XK_Arabic_yeh = 1514 const XK_Arabic_yeh_baree = 16778962 const XK_Arabic_zah = 1496 const XK_Arabic_zain = 1490 const XK_Aring = 197 const XK_Armenian_AT = 16778552 const XK_Armenian_AYB = 16778545 const XK_Armenian_BEN = 16778546 const XK_Armenian_CHA = 16778569 const XK_Armenian_DA = 16778548 const XK_Armenian_DZA = 16778561 const XK_Armenian_E = 16778551 const XK_Armenian_FE = 16778582 const XK_Armenian_GHAT = 16778562 const XK_Armenian_GIM = 16778547 const XK_Armenian_HI = 16778565 const XK_Armenian_HO = 16778560 const XK_Armenian_INI = 16778555 const XK_Armenian_JE = 16778571 const XK_Armenian_KE = 16778580 const XK_Armenian_KEN = 16778559 const XK_Armenian_KHE = 16778557 const XK_Armenian_LYUN = 16778556 const XK_Armenian_MEN = 16778564 const XK_Armenian_NU = 16778566 const XK_Armenian_O = 16778581 const XK_Armenian_PE = 16778570 const XK_Armenian_PYUR = 16778579 const XK_Armenian_RA = 16778572 const XK_Armenian_RE = 16778576 const XK_Armenian_SE = 16778573 const XK_Armenian_SHA = 16778567 const XK_Armenian_TCHE = 16778563 const XK_Armenian_TO = 16778553 const XK_Armenian_TSA = 16778558 const XK_Armenian_TSO = 16778577 const XK_Armenian_TYUN = 16778575 const XK_Armenian_VEV = 16778574 const XK_Armenian_VO = 16778568 const XK_Armenian_VYUN = 16778578 const XK_Armenian_YECH = 16778549 const XK_Armenian_ZA = 16778550 const XK_Armenian_ZHE = 16778554 const XK_Armenian_accent = 16778587 const XK_Armenian_amanak = 16778588 const XK_Armenian_apostrophe = 16778586 const XK_Armenian_at = 16778600 const XK_Armenian_ayb = 16778593 const XK_Armenian_ben = 16778594 const XK_Armenian_but = 16778589 const XK_Armenian_cha = 16778617 const XK_Armenian_da = 16778596 const XK_Armenian_dza = 16778609 const XK_Armenian_e = 16778599 const XK_Armenian_exclam = 16778588 const XK_Armenian_fe = 16778630 const XK_Armenian_full_stop = 16778633 const XK_Armenian_ghat = 16778610 const XK_Armenian_gim = 16778595 const XK_Armenian_hi = 16778613 const XK_Armenian_ho = 16778608 const XK_Armenian_hyphen = 16778634 const XK_Armenian_ini = 16778603 const XK_Armenian_je = 16778619 const XK_Armenian_ke = 16778628 const XK_Armenian_ken = 16778607 const XK_Armenian_khe = 16778605 const XK_Armenian_ligature_ew = 16778631 const XK_Armenian_lyun = 16778604 const XK_Armenian_men = 16778612 const XK_Armenian_nu = 16778614 const XK_Armenian_o = 16778629 const XK_Armenian_paruyk = 16778590 const XK_Armenian_pe = 16778618 const XK_Armenian_pyur = 16778627 const XK_Armenian_question = 16778590 const XK_Armenian_ra = 16778620 const XK_Armenian_re = 16778624 const XK_Armenian_se = 16778621 const XK_Armenian_separation_mark = 16778589 const XK_Armenian_sha = 16778615 const XK_Armenian_shesht = 16778587 const XK_Armenian_tche = 16778611 const XK_Armenian_to = 16778601 const XK_Armenian_tsa = 16778606 const XK_Armenian_tso = 16778625 const XK_Armenian_tyun = 16778623 const XK_Armenian_verjaket = 16778633 const XK_Armenian_vev = 16778622 const XK_Armenian_vo = 16778616 const XK_Armenian_vyun = 16778626 const XK_Armenian_yech = 16778597 const XK_Armenian_yentamna = 16778634 const XK_Armenian_za = 16778598 const XK_Armenian_zhe = 16778602 const XK_Atilde = 195 const XK_AudibleBell_Enable = 65146 const XK_B = 66 const XK_Babovedot = 16784898 const XK_BackSpace = 65288 const XK_Begin = 65368 const XK_BounceKeys_Enable = 65140 const XK_Break = 65387 const XK_Byelorussian_SHORTU = 1726 const XK_Byelorussian_shortu = 1710 const XK_C = 67 const XK_CH = 65186 const XK_C_H = 65189 const XK_C_h = 65188 const XK_Cabovedot = 709 const XK_Cacute = 454 const XK_Cancel = 65385 const XK_Caps_Lock = 65509 const XK_Ccaron = 456 const XK_Ccedilla = 199 const XK_Ccircumflex = 710 const XK_Ch = 65185 const XK_Clear = 65291 const XK_Codeinput = 65335 const XK_ColonSign = 16785569 const XK_Control_L = 65507 const XK_Control_R = 65508 const XK_CruzeiroSign = 16785570 const XK_Cyrillic_A = 1761 const XK_Cyrillic_BE = 1762 const XK_Cyrillic_CHE = 1790 const XK_Cyrillic_CHE_descender = 16778422 const XK_Cyrillic_CHE_vertstroke = 16778424 const XK_Cyrillic_DE = 1764 const XK_Cyrillic_DZHE = 1727 const XK_Cyrillic_E = 1788 const XK_Cyrillic_EF = 1766 const XK_Cyrillic_EL = 1772 const XK_Cyrillic_EM = 1773 const XK_Cyrillic_EN = 1774 const XK_Cyrillic_EN_descender = 16778402 const XK_Cyrillic_ER = 1778 const XK_Cyrillic_ES = 1779 const XK_Cyrillic_GHE = 1767 const XK_Cyrillic_GHE_bar = 16778386 const XK_Cyrillic_HA = 1768 const XK_Cyrillic_HARDSIGN = 1791 const XK_Cyrillic_HA_descender = 16778418 const XK_Cyrillic_I = 1769 const XK_Cyrillic_IE = 1765 const XK_Cyrillic_IO = 1715 const XK_Cyrillic_I_macron = 16778466 const XK_Cyrillic_JE = 1720 const XK_Cyrillic_KA = 1771 const XK_Cyrillic_KA_descender = 16778394 const XK_Cyrillic_KA_vertstroke = 16778396 const XK_Cyrillic_LJE = 1721 const XK_Cyrillic_NJE = 1722 const XK_Cyrillic_O = 1775 const XK_Cyrillic_O_bar = 16778472 const XK_Cyrillic_PE = 1776 const XK_Cyrillic_SCHWA = 16778456 const XK_Cyrillic_SHA = 1787 const XK_Cyrillic_SHCHA = 1789 const XK_Cyrillic_SHHA = 16778426 const XK_Cyrillic_SHORTI = 1770 const XK_Cyrillic_SOFTSIGN = 1784 const XK_Cyrillic_TE = 1780 const XK_Cyrillic_TSE = 1763 const XK_Cyrillic_U = 1781 const XK_Cyrillic_U_macron = 16778478 const XK_Cyrillic_U_straight = 16778414 const XK_Cyrillic_U_straight_bar = 16778416 const XK_Cyrillic_VE = 1783 const XK_Cyrillic_YA = 1777 const XK_Cyrillic_YERU = 1785 const XK_Cyrillic_YU = 1760 const XK_Cyrillic_ZE = 1786 const XK_Cyrillic_ZHE = 1782 const XK_Cyrillic_ZHE_descender = 16778390 const XK_Cyrillic_a = 1729 const XK_Cyrillic_be = 1730 const XK_Cyrillic_che = 1758 const XK_Cyrillic_che_descender = 16778423 const XK_Cyrillic_che_vertstroke = 16778425 const XK_Cyrillic_de = 1732 const XK_Cyrillic_dzhe = 1711 const XK_Cyrillic_e = 1756 const XK_Cyrillic_ef = 1734 const XK_Cyrillic_el = 1740 const XK_Cyrillic_em = 1741 const XK_Cyrillic_en = 1742 const XK_Cyrillic_en_descender = 16778403 const XK_Cyrillic_er = 1746 const XK_Cyrillic_es = 1747 const XK_Cyrillic_ghe = 1735 const XK_Cyrillic_ghe_bar = 16778387 const XK_Cyrillic_ha = 1736 const XK_Cyrillic_ha_descender = 16778419 const XK_Cyrillic_hardsign = 1759 const XK_Cyrillic_i = 1737 const XK_Cyrillic_i_macron = 16778467 const XK_Cyrillic_ie = 1733 const XK_Cyrillic_io = 1699 const XK_Cyrillic_je = 1704 const XK_Cyrillic_ka = 1739 const XK_Cyrillic_ka_descender = 16778395 const XK_Cyrillic_ka_vertstroke = 16778397 const XK_Cyrillic_lje = 1705 const XK_Cyrillic_nje = 1706 const XK_Cyrillic_o = 1743 const XK_Cyrillic_o_bar = 16778473 const XK_Cyrillic_pe = 1744 const XK_Cyrillic_schwa = 16778457 const XK_Cyrillic_sha = 1755 const XK_Cyrillic_shcha = 1757 const XK_Cyrillic_shha = 16778427 const XK_Cyrillic_shorti = 1738 const XK_Cyrillic_softsign = 1752 const XK_Cyrillic_te = 1748 const XK_Cyrillic_tse = 1731 const XK_Cyrillic_u = 1749 const XK_Cyrillic_u_macron = 16778479 const XK_Cyrillic_u_straight = 16778415 const XK_Cyrillic_u_straight_bar = 16778417 const XK_Cyrillic_ve = 1751 const XK_Cyrillic_ya = 1745 const XK_Cyrillic_yeru = 1753 const XK_Cyrillic_yu = 1728 const XK_Cyrillic_ze = 1754 const XK_Cyrillic_zhe = 1750 const XK_Cyrillic_zhe_descender = 16778391 const XK_D = 68 const XK_Dabovedot = 16784906 const XK_Dcaron = 463 const XK_Delete = 65535 const XK_DongSign = 16785579 const XK_Down = 65364 const XK_Dstroke = 464 const XK_E = 69 const XK_ENG = 957 const XK_ETH = 208 const XK_EZH = 16777655 const XK_Eabovedot = 972 const XK_Eacute = 201 const XK_Ebelowdot = 16785080 const XK_Ecaron = 460 const XK_Ecircumflex = 202 const XK_Ecircumflexacute = 16785086 const XK_Ecircumflexbelowdot = 16785094 const XK_Ecircumflexgrave = 16785088 const XK_Ecircumflexhook = 16785090 const XK_Ecircumflextilde = 16785092 const XK_EcuSign = 16785568 const XK_Ediaeresis = 203 const XK_Egrave = 200 const XK_Ehook = 16785082 const XK_Eisu_Shift = 65327 const XK_Eisu_toggle = 65328 const XK_Emacron = 938 const XK_End = 65367 const XK_Eogonek = 458 const XK_Escape = 65307 const XK_Eth = 208 const XK_Etilde = 16785084 const XK_EuroSign = 8364 const XK_Execute = 65378 const XK_F = 70 const XK_F1 = 65470 const XK_F10 = 65479 const XK_F11 = 65480 const XK_F12 = 65481 const XK_F13 = 65482 const XK_F14 = 65483 const XK_F15 = 65484 const XK_F16 = 65485 const XK_F17 = 65486 const XK_F18 = 65487 const XK_F19 = 65488 const XK_F2 = 65471 const XK_F20 = 65489 const XK_F21 = 65490 const XK_F22 = 65491 const XK_F23 = 65492 const XK_F24 = 65493 const XK_F25 = 65494 const XK_F26 = 65495 const XK_F27 = 65496 const XK_F28 = 65497 const XK_F29 = 65498 const XK_F3 = 65472 const XK_F30 = 65499 const XK_F31 = 65500 const XK_F32 = 65501 const XK_F33 = 65502 const XK_F34 = 65503 const XK_F35 = 65504 const XK_F4 = 65473 const XK_F5 = 65474 const XK_F6 = 65475 const XK_F7 = 65476 const XK_F8 = 65477 const XK_F9 = 65478 const XK_FFrancSign = 16785571 const XK_Fabovedot = 16784926 const XK_Farsi_0 = 16778992 const XK_Farsi_1 = 16778993 const XK_Farsi_2 = 16778994 const XK_Farsi_3 = 16778995 const XK_Farsi_4 = 16778996 const XK_Farsi_5 = 16778997 const XK_Farsi_6 = 16778998 const XK_Farsi_7 = 16778999 const XK_Farsi_8 = 16779000 const XK_Farsi_9 = 16779001 const XK_Farsi_yeh = 16778956 const XK_Find = 65384 const XK_First_Virtual_Screen = 65232 const XK_G = 71 const XK_Gabovedot = 725 const XK_Gbreve = 683 const XK_Gcaron = 16777702 const XK_Gcedilla = 939 const XK_Gcircumflex = 728 const XK_Georgian_an = 16781520 const XK_Georgian_ban = 16781521 const XK_Georgian_can = 16781546 const XK_Georgian_char = 16781549 const XK_Georgian_chin = 16781545 const XK_Georgian_cil = 16781548 const XK_Georgian_don = 16781523 const XK_Georgian_en = 16781524 const XK_Georgian_fi = 16781558 const XK_Georgian_gan = 16781522 const XK_Georgian_ghan = 16781542 const XK_Georgian_hae = 16781552 const XK_Georgian_har = 16781556 const XK_Georgian_he = 16781553 const XK_Georgian_hie = 16781554 const XK_Georgian_hoe = 16781557 const XK_Georgian_in = 16781528 const XK_Georgian_jhan = 16781551 const XK_Georgian_jil = 16781547 const XK_Georgian_kan = 16781529 const XK_Georgian_khar = 16781541 const XK_Georgian_las = 16781530 const XK_Georgian_man = 16781531 const XK_Georgian_nar = 16781532 const XK_Georgian_on = 16781533 const XK_Georgian_par = 16781534 const XK_Georgian_phar = 16781540 const XK_Georgian_qar = 16781543 const XK_Georgian_rae = 16781536 const XK_Georgian_san = 16781537 const XK_Georgian_shin = 16781544 const XK_Georgian_tan = 16781527 const XK_Georgian_tar = 16781538 const XK_Georgian_un = 16781539 const XK_Georgian_vin = 16781525 const XK_Georgian_we = 16781555 const XK_Georgian_xan = 16781550 const XK_Georgian_zen = 16781526 const XK_Georgian_zhar = 16781535 const XK_Greek_ALPHA = 1985 const XK_Greek_ALPHAaccent = 1953 const XK_Greek_BETA = 1986 const XK_Greek_CHI = 2007 const XK_Greek_DELTA = 1988 const XK_Greek_EPSILON = 1989 const XK_Greek_EPSILONaccent = 1954 const XK_Greek_ETA = 1991 const XK_Greek_ETAaccent = 1955 const XK_Greek_GAMMA = 1987 const XK_Greek_IOTA = 1993 const XK_Greek_IOTAaccent = 1956 const XK_Greek_IOTAdiaeresis = 1957 const XK_Greek_IOTAdieresis = 1957 const XK_Greek_KAPPA = 1994 const XK_Greek_LAMBDA = 1995 const XK_Greek_LAMDA = 1995 const XK_Greek_MU = 1996 const XK_Greek_NU = 1997 const XK_Greek_OMEGA = 2009 const XK_Greek_OMEGAaccent = 1963 const XK_Greek_OMICRON = 1999 const XK_Greek_OMICRONaccent = 1959 const XK_Greek_PHI = 2006 const XK_Greek_PI = 2000 const XK_Greek_PSI = 2008 const XK_Greek_RHO = 2001 const XK_Greek_SIGMA = 2002 const XK_Greek_TAU = 2004 const XK_Greek_THETA = 1992 const XK_Greek_UPSILON = 2005 const XK_Greek_UPSILONaccent = 1960 const XK_Greek_UPSILONdieresis = 1961 const XK_Greek_XI = 1998 const XK_Greek_ZETA = 1990 const XK_Greek_accentdieresis = 1966 const XK_Greek_alpha = 2017 const XK_Greek_alphaaccent = 1969 const XK_Greek_beta = 2018 const XK_Greek_chi = 2039 const XK_Greek_delta = 2020 const XK_Greek_epsilon = 2021 const XK_Greek_epsilonaccent = 1970 const XK_Greek_eta = 2023 const XK_Greek_etaaccent = 1971 const XK_Greek_finalsmallsigma = 2035 const XK_Greek_gamma = 2019 const XK_Greek_horizbar = 1967 const XK_Greek_iota = 2025 const XK_Greek_iotaaccent = 1972 const XK_Greek_iotaaccentdieresis = 1974 const XK_Greek_iotadieresis = 1973 const XK_Greek_kappa = 2026 const XK_Greek_lambda = 2027 const XK_Greek_lamda = 2027 const XK_Greek_mu = 2028 const XK_Greek_nu = 2029 const XK_Greek_omega = 2041 const XK_Greek_omegaaccent = 1979 const XK_Greek_omicron = 2031 const XK_Greek_omicronaccent = 1975 const XK_Greek_phi = 2038 const XK_Greek_pi = 2032 const XK_Greek_psi = 2040 const XK_Greek_rho = 2033 const XK_Greek_sigma = 2034 const XK_Greek_switch = 65406 const XK_Greek_tau = 2036 const XK_Greek_theta = 2024 const XK_Greek_upsilon = 2037 const XK_Greek_upsilonaccent = 1976 const XK_Greek_upsilonaccentdieresis = 1978 const XK_Greek_upsilondieresis = 1977 const XK_Greek_xi = 2030 const XK_Greek_zeta = 2022 const XK_H = 72 const XK_Hangul = 65329 const XK_Hangul_A = 3775 const XK_Hangul_AE = 3776 const XK_Hangul_AraeA = 3830 const XK_Hangul_AraeAE = 3831 const XK_Hangul_Banja = 65337 const XK_Hangul_Cieuc = 3770 const XK_Hangul_Codeinput = 65335 const XK_Hangul_Dikeud = 3751 const XK_Hangul_E = 3780 const XK_Hangul_EO = 3779 const XK_Hangul_EU = 3793 const XK_Hangul_End = 65331 const XK_Hangul_Hanja = 65332 const XK_Hangul_Hieuh = 3774 const XK_Hangul_I = 3795 const XK_Hangul_Ieung = 3767 const XK_Hangul_J_Cieuc = 3818 const XK_Hangul_J_Dikeud = 3802 const XK_Hangul_J_Hieuh = 3822 const XK_Hangul_J_Ieung = 3816 const XK_Hangul_J_Jieuj = 3817 const XK_Hangul_J_Khieuq = 3819 const XK_Hangul_J_Kiyeog = 3796 const XK_Hangul_J_KiyeogSios = 3798 const XK_Hangul_J_KkogjiDalrinIeung = 3833 const XK_Hangul_J_Mieum = 3811 const XK_Hangul_J_Nieun = 3799 const XK_Hangul_J_NieunHieuh = 3801 const XK_Hangul_J_NieunJieuj = 3800 const XK_Hangul_J_PanSios = 3832 const XK_Hangul_J_Phieuf = 3821 const XK_Hangul_J_Pieub = 3812 const XK_Hangul_J_PieubSios = 3813 const XK_Hangul_J_Rieul = 3803 const XK_Hangul_J_RieulHieuh = 3810 const XK_Hangul_J_RieulKiyeog = 3804 const XK_Hangul_J_RieulMieum = 3805 const XK_Hangul_J_RieulPhieuf = 3809 const XK_Hangul_J_RieulPieub = 3806 const XK_Hangul_J_RieulSios = 3807 const XK_Hangul_J_RieulTieut = 3808 const XK_Hangul_J_Sios = 3814 const XK_Hangul_J_SsangKiyeog = 3797 const XK_Hangul_J_SsangSios = 3815 const XK_Hangul_J_Tieut = 3820 const XK_Hangul_J_YeorinHieuh = 3834 const XK_Hangul_Jamo = 65333 const XK_Hangul_Jeonja = 65336 const XK_Hangul_Jieuj = 3768 const XK_Hangul_Khieuq = 3771 const XK_Hangul_Kiyeog = 3745 const XK_Hangul_KiyeogSios = 3747 const XK_Hangul_KkogjiDalrinIeung = 3827 const XK_Hangul_Mieum = 3761 const XK_Hangul_MultipleCandidate = 65341 const XK_Hangul_Nieun = 3748 const XK_Hangul_NieunHieuh = 3750 const XK_Hangul_NieunJieuj = 3749 const XK_Hangul_O = 3783 const XK_Hangul_OE = 3786 const XK_Hangul_PanSios = 3826 const XK_Hangul_Phieuf = 3773 const XK_Hangul_Pieub = 3762 const XK_Hangul_PieubSios = 3764 const XK_Hangul_PostHanja = 65339 const XK_Hangul_PreHanja = 65338 const XK_Hangul_PreviousCandidate = 65342 const XK_Hangul_Rieul = 3753 const XK_Hangul_RieulHieuh = 3760 const XK_Hangul_RieulKiyeog = 3754 const XK_Hangul_RieulMieum = 3755 const XK_Hangul_RieulPhieuf = 3759 const XK_Hangul_RieulPieub = 3756 const XK_Hangul_RieulSios = 3757 const XK_Hangul_RieulTieut = 3758 const XK_Hangul_RieulYeorinHieuh = 3823 const XK_Hangul_Romaja = 65334 const XK_Hangul_SingleCandidate = 65340 const XK_Hangul_Sios = 3765 const XK_Hangul_Special = 65343 const XK_Hangul_SsangDikeud = 3752 const XK_Hangul_SsangJieuj = 3769 const XK_Hangul_SsangKiyeog = 3746 const XK_Hangul_SsangPieub = 3763 const XK_Hangul_SsangSios = 3766 const XK_Hangul_Start = 65330 const XK_Hangul_SunkyeongeumMieum = 3824 const XK_Hangul_SunkyeongeumPhieuf = 3828 const XK_Hangul_SunkyeongeumPieub = 3825 const XK_Hangul_Tieut = 3772 const XK_Hangul_U = 3788 const XK_Hangul_WA = 3784 const XK_Hangul_WAE = 3785 const XK_Hangul_WE = 3790 const XK_Hangul_WEO = 3789 const XK_Hangul_WI = 3791 const XK_Hangul_YA = 3777 const XK_Hangul_YAE = 3778 const XK_Hangul_YE = 3782 const XK_Hangul_YEO = 3781 const XK_Hangul_YI = 3794 const XK_Hangul_YO = 3787 const XK_Hangul_YU = 3792 const XK_Hangul_YeorinHieuh = 3829 const XK_Hangul_switch = 65406 const XK_Hankaku = 65321 const XK_Hcircumflex = 678 const XK_Hebrew_switch = 65406 const XK_Help = 65386 const XK_Henkan = 65315 const XK_Henkan_Mode = 65315 const XK_Hiragana = 65317 const XK_Hiragana_Katakana = 65319 const XK_Home = 65360 const XK_Hstroke = 673 const XK_Hyper_L = 65517 const XK_Hyper_R = 65518 const XK_I = 73 const XK_ISO_Center_Object = 65075 const XK_ISO_Continuous_Underline = 65072 const XK_ISO_Discontinuous_Underline = 65073 const XK_ISO_Emphasize = 65074 const XK_ISO_Enter = 65076 const XK_ISO_Fast_Cursor_Down = 65071 const XK_ISO_Fast_Cursor_Left = 65068 const XK_ISO_Fast_Cursor_Right = 65069 const XK_ISO_Fast_Cursor_Up = 65070 const XK_ISO_First_Group = 65036 const XK_ISO_First_Group_Lock = 65037 const XK_ISO_Group_Latch = 65030 const XK_ISO_Group_Lock = 65031 const XK_ISO_Group_Shift = 65406 const XK_ISO_Last_Group = 65038 const XK_ISO_Last_Group_Lock = 65039 const XK_ISO_Left_Tab = 65056 const XK_ISO_Level2_Latch = 65026 const XK_ISO_Level3_Latch = 65028 const XK_ISO_Level3_Lock = 65029 const XK_ISO_Level3_Shift = 65027 const XK_ISO_Level5_Latch = 65042 const XK_ISO_Level5_Lock = 65043 const XK_ISO_Level5_Shift = 65041 const XK_ISO_Lock = 65025 const XK_ISO_Move_Line_Down = 65058 const XK_ISO_Move_Line_Up = 65057 const XK_ISO_Next_Group = 65032 const XK_ISO_Next_Group_Lock = 65033 const XK_ISO_Partial_Line_Down = 65060 const XK_ISO_Partial_Line_Up = 65059 const XK_ISO_Partial_Space_Left = 65061 const XK_ISO_Partial_Space_Right = 65062 const XK_ISO_Prev_Group = 65034 const XK_ISO_Prev_Group_Lock = 65035 const XK_ISO_Release_Both_Margins = 65067 const XK_ISO_Release_Margin_Left = 65065 const XK_ISO_Release_Margin_Right = 65066 const XK_ISO_Set_Margin_Left = 65063 const XK_ISO_Set_Margin_Right = 65064 const XK_Iabovedot = 681 const XK_Iacute = 205 const XK_Ibelowdot = 16785098 const XK_Ibreve = 16777516 const XK_Icircumflex = 206 const XK_Idiaeresis = 207 const XK_Igrave = 204 const XK_Ihook = 16785096 const XK_Imacron = 975 const XK_Insert = 65379 const XK_Iogonek = 967 const XK_Itilde = 933 const XK_J = 74 const XK_Jcircumflex = 684 const XK_K = 75 const XK_KP_0 = 65456 const XK_KP_1 = 65457 const XK_KP_2 = 65458 const XK_KP_3 = 65459 const XK_KP_4 = 65460 const XK_KP_5 = 65461 const XK_KP_6 = 65462 const XK_KP_7 = 65463 const XK_KP_8 = 65464 const XK_KP_9 = 65465 const XK_KP_Add = 65451 const XK_KP_Begin = 65437 const XK_KP_Decimal = 65454 const XK_KP_Delete = 65439 const XK_KP_Divide = 65455 const XK_KP_Down = 65433 const XK_KP_End = 65436 const XK_KP_Enter = 65421 const XK_KP_Equal = 65469 const XK_KP_F1 = 65425 const XK_KP_F2 = 65426 const XK_KP_F3 = 65427 const XK_KP_F4 = 65428 const XK_KP_Home = 65429 const XK_KP_Insert = 65438 const XK_KP_Left = 65430 const XK_KP_Multiply = 65450 const XK_KP_Next = 65435 const XK_KP_Page_Down = 65435 const XK_KP_Page_Up = 65434 const XK_KP_Prior = 65434 const XK_KP_Right = 65432 const XK_KP_Separator = 65452 const XK_KP_Space = 65408 const XK_KP_Subtract = 65453 const XK_KP_Tab = 65417 const XK_KP_Up = 65431 const XK_Kana_Lock = 65325 const XK_Kana_Shift = 65326 const XK_Kanji = 65313 const XK_Kanji_Bangou = 65335 const XK_Katakana = 65318 const XK_Kcedilla = 979 const XK_Korean_Won = 3839 const XK_L = 76 const XK_L1 = 65480 const XK_L10 = 65489 const XK_L2 = 65481 const XK_L3 = 65482 const XK_L4 = 65483 const XK_L5 = 65484 const XK_L6 = 65485 const XK_L7 = 65486 const XK_L8 = 65487 const XK_L9 = 65488 const XK_Lacute = 453 const XK_Last_Virtual_Screen = 65236 const XK_Lbelowdot = 16784950 const XK_Lcaron = 421 const XK_Lcedilla = 934 const XK_Left = 65361 const XK_Linefeed = 65290 const XK_LiraSign = 16785572 const XK_Lstroke = 419 const XK_M = 77 const XK_Mabovedot = 16784960 const XK_Macedonia_DSE = 1717 const XK_Macedonia_GJE = 1714 const XK_Macedonia_KJE = 1724 const XK_Macedonia_dse = 1701 const XK_Macedonia_gje = 1698 const XK_Macedonia_kje = 1708 const XK_Mae_Koho = 65342 const XK_Massyo = 65324 const XK_Menu = 65383 const XK_Meta_L = 65511 const XK_Meta_R = 65512 const XK_MillSign = 16785573 const XK_Mode_switch = 65406 const XK_MouseKeys_Accel_Enable = 65143 const XK_MouseKeys_Enable = 65142 const XK_Muhenkan = 65314 const XK_Multi_key = 65312 const XK_MultipleCandidate = 65341 const XK_N = 78 const XK_Nacute = 465 const XK_NairaSign = 16785574 const XK_Ncaron = 466 const XK_Ncedilla = 977 const XK_NewSheqelSign = 16785578 const XK_Next = 65366 const XK_Next_Virtual_Screen = 65234 const XK_Ntilde = 209 const XK_Num_Lock = 65407 const XK_O = 79 const XK_OE = 5052 const XK_Oacute = 211 const XK_Obarred = 16777631 const XK_Obelowdot = 16785100 const XK_Ocaron = 16777681 const XK_Ocircumflex = 212 const XK_Ocircumflexacute = 16785104 const XK_Ocircumflexbelowdot = 16785112 const XK_Ocircumflexgrave = 16785106 const XK_Ocircumflexhook = 16785108 const XK_Ocircumflextilde = 16785110 const XK_Odiaeresis = 214 const XK_Odoubleacute = 469 const XK_Ograve = 210 const XK_Ohook = 16785102 const XK_Ohorn = 16777632 const XK_Ohornacute = 16785114 const XK_Ohornbelowdot = 16785122 const XK_Ohorngrave = 16785116 const XK_Ohornhook = 16785118 const XK_Ohorntilde = 16785120 const XK_Omacron = 978 const XK_Ooblique = 216 const XK_Oslash = 216 const XK_Otilde = 213 const XK_Overlay1_Enable = 65144 const XK_Overlay2_Enable = 65145 const XK_P = 80 const XK_Pabovedot = 16784982 const XK_Page_Down = 65366 const XK_Page_Up = 65365 const XK_Pause = 65299 const XK_PesetaSign = 16785575 const XK_Pointer_Accelerate = 65274 const XK_Pointer_Button1 = 65257 const XK_Pointer_Button2 = 65258 const XK_Pointer_Button3 = 65259 const XK_Pointer_Button4 = 65260 const XK_Pointer_Button5 = 65261 const XK_Pointer_Button_Dflt = 65256 const XK_Pointer_DblClick1 = 65263 const XK_Pointer_DblClick2 = 65264 const XK_Pointer_DblClick3 = 65265 const XK_Pointer_DblClick4 = 65266 const XK_Pointer_DblClick5 = 65267 const XK_Pointer_DblClick_Dflt = 65262 const XK_Pointer_DfltBtnNext = 65275 const XK_Pointer_DfltBtnPrev = 65276 const XK_Pointer_Down = 65251 const XK_Pointer_DownLeft = 65254 const XK_Pointer_DownRight = 65255 const XK_Pointer_Drag1 = 65269 const XK_Pointer_Drag2 = 65270 const XK_Pointer_Drag3 = 65271 const XK_Pointer_Drag4 = 65272 const XK_Pointer_Drag5 = 65277 const XK_Pointer_Drag_Dflt = 65268 const XK_Pointer_EnableKeys = 65273 const XK_Pointer_Left = 65248 const XK_Pointer_Right = 65249 const XK_Pointer_Up = 65250 const XK_Pointer_UpLeft = 65252 const XK_Pointer_UpRight = 65253 const XK_Prev_Virtual_Screen = 65233 const XK_PreviousCandidate = 65342 const XK_Print = 65377 const XK_Prior = 65365 const XK_Q = 81 const XK_R = 82 const XK_R1 = 65490 const XK_R10 = 65499 const XK_R11 = 65500 const XK_R12 = 65501 const XK_R13 = 65502 const XK_R14 = 65503 const XK_R15 = 65504 const XK_R2 = 65491 const XK_R3 = 65492 const XK_R4 = 65493 const XK_R5 = 65494 const XK_R6 = 65495 const XK_R7 = 65496 const XK_R8 = 65497 const XK_R9 = 65498 const XK_Racute = 448 const XK_Rcaron = 472 const XK_Rcedilla = 931 const XK_Redo = 65382 const XK_RepeatKeys_Enable = 65138 const XK_Return = 65293 const XK_Right = 65363 const XK_Romaji = 65316 const XK_RupeeSign = 16785576 const XK_S = 83 const XK_SCHWA = 16777615 const XK_Sabovedot = 16784992 const XK_Sacute = 422 const XK_Scaron = 425 const XK_Scedilla = 426 const XK_Scircumflex = 734 const XK_Scroll_Lock = 65300 const XK_Select = 65376 const XK_Serbian_DJE = 1713 const XK_Serbian_DZE = 1727 const XK_Serbian_JE = 1720 const XK_Serbian_LJE = 1721 const XK_Serbian_NJE = 1722 const XK_Serbian_TSHE = 1723 const XK_Serbian_dje = 1697 const XK_Serbian_dze = 1711 const XK_Serbian_je = 1704 const XK_Serbian_lje = 1705 const XK_Serbian_nje = 1706 const XK_Serbian_tshe = 1707 const XK_Shift_L = 65505 const XK_Shift_Lock = 65510 const XK_Shift_R = 65506 const XK_SingleCandidate = 65340 const XK_Sinh_a = 16780677 const XK_Sinh_aa = 16780678 const XK_Sinh_aa2 = 16780751 const XK_Sinh_ae = 16780679 const XK_Sinh_ae2 = 16780752 const XK_Sinh_aee = 16780680 const XK_Sinh_aee2 = 16780753 const XK_Sinh_ai = 16780691 const XK_Sinh_ai2 = 16780763 const XK_Sinh_al = 16780746 const XK_Sinh_au = 16780694 const XK_Sinh_au2 = 16780766 const XK_Sinh_ba = 16780726 const XK_Sinh_bha = 16780727 const XK_Sinh_ca = 16780704 const XK_Sinh_cha = 16780705 const XK_Sinh_dda = 16780713 const XK_Sinh_ddha = 16780714 const XK_Sinh_dha = 16780719 const XK_Sinh_dhha = 16780720 const XK_Sinh_e = 16780689 const XK_Sinh_e2 = 16780761 const XK_Sinh_ee = 16780690 const XK_Sinh_ee2 = 16780762 const XK_Sinh_fa = 16780742 const XK_Sinh_ga = 16780700 const XK_Sinh_gha = 16780701 const XK_Sinh_h2 = 16780675 const XK_Sinh_ha = 16780740 const XK_Sinh_i = 16780681 const XK_Sinh_i2 = 16780754 const XK_Sinh_ii = 16780682 const XK_Sinh_ii2 = 16780755 const XK_Sinh_ja = 16780706 const XK_Sinh_jha = 16780707 const XK_Sinh_jnya = 16780709 const XK_Sinh_ka = 16780698 const XK_Sinh_kha = 16780699 const XK_Sinh_kunddaliya = 16780788 const XK_Sinh_la = 16780733 const XK_Sinh_lla = 16780741 const XK_Sinh_lu = 16780687 const XK_Sinh_lu2 = 16780767 const XK_Sinh_luu = 16780688 const XK_Sinh_luu2 = 16780787 const XK_Sinh_ma = 16780728 const XK_Sinh_mba = 16780729 const XK_Sinh_na = 16780721 const XK_Sinh_ndda = 16780716 const XK_Sinh_ndha = 16780723 const XK_Sinh_ng = 16780674 const XK_Sinh_ng2 = 16780702 const XK_Sinh_nga = 16780703 const XK_Sinh_nja = 16780710 const XK_Sinh_nna = 16780715 const XK_Sinh_nya = 16780708 const XK_Sinh_o = 16780692 const XK_Sinh_o2 = 16780764 const XK_Sinh_oo = 16780693 const XK_Sinh_oo2 = 16780765 const XK_Sinh_pa = 16780724 const XK_Sinh_pha = 16780725 const XK_Sinh_ra = 16780731 const XK_Sinh_ri = 16780685 const XK_Sinh_rii = 16780686 const XK_Sinh_ru2 = 16780760 const XK_Sinh_ruu2 = 16780786 const XK_Sinh_sa = 16780739 const XK_Sinh_sha = 16780737 const XK_Sinh_ssha = 16780738 const XK_Sinh_tha = 16780717 const XK_Sinh_thha = 16780718 const XK_Sinh_tta = 16780711 const XK_Sinh_ttha = 16780712 const XK_Sinh_u = 16780683 const XK_Sinh_u2 = 16780756 const XK_Sinh_uu = 16780684 const XK_Sinh_uu2 = 16780758 const XK_Sinh_va = 16780736 const XK_Sinh_ya = 16780730 const XK_SlowKeys_Enable = 65139 const XK_StickyKeys_Enable = 65141 const XK_Super_L = 65515 const XK_Super_R = 65516 const XK_Sys_Req = 65301 const XK_T = 84 const XK_THORN = 222 const XK_Tab = 65289 const XK_Tabovedot = 16785002 const XK_Tcaron = 427 const XK_Tcedilla = 478 const XK_Terminate_Server = 65237 const XK_Thai_baht = 3551 const XK_Thai_bobaimai = 3514 const XK_Thai_chochan = 3496 const XK_Thai_chochang = 3498 const XK_Thai_choching = 3497 const XK_Thai_chochoe = 3500 const XK_Thai_dochada = 3502 const XK_Thai_dodek = 3508 const XK_Thai_fofa = 3517 const XK_Thai_fofan = 3519 const XK_Thai_hohip = 3531 const XK_Thai_honokhuk = 3534 const XK_Thai_khokhai = 3490 const XK_Thai_khokhon = 3493 const XK_Thai_khokhuat = 3491 const XK_Thai_khokhwai = 3492 const XK_Thai_khorakhang = 3494 const XK_Thai_kokai = 3489 const XK_Thai_lakkhangyao = 3557 const XK_Thai_lekchet = 3575 const XK_Thai_lekha = 3573 const XK_Thai_lekhok = 3574 const XK_Thai_lekkao = 3577 const XK_Thai_leknung = 3569 const XK_Thai_lekpaet = 3576 const XK_Thai_leksam = 3571 const XK_Thai_leksi = 3572 const XK_Thai_leksong = 3570 const XK_Thai_leksun = 3568 const XK_Thai_lochula = 3532 const XK_Thai_loling = 3525 const XK_Thai_lu = 3526 const XK_Thai_maichattawa = 3563 const XK_Thai_maiek = 3560 const XK_Thai_maihanakat = 3537 const XK_Thai_maihanakat_maitho = 3550 const XK_Thai_maitaikhu = 3559 const XK_Thai_maitho = 3561 const XK_Thai_maitri = 3562 const XK_Thai_maiyamok = 3558 const XK_Thai_moma = 3521 const XK_Thai_ngongu = 3495 const XK_Thai_nikhahit = 3565 const XK_Thai_nonen = 3507 const XK_Thai_nonu = 3513 const XK_Thai_oang = 3533 const XK_Thai_paiyannoi = 3535 const XK_Thai_phinthu = 3546 const XK_Thai_phophan = 3518 const XK_Thai_phophung = 3516 const XK_Thai_phosamphao = 3520 const XK_Thai_popla = 3515 const XK_Thai_rorua = 3523 const XK_Thai_ru = 3524 const XK_Thai_saraa = 3536 const XK_Thai_saraaa = 3538 const XK_Thai_saraae = 3553 const XK_Thai_saraaimaimalai = 3556 const XK_Thai_saraaimaimuan = 3555 const XK_Thai_saraam = 3539 const XK_Thai_sarae = 3552 const XK_Thai_sarai = 3540 const XK_Thai_saraii = 3541 const XK_Thai_sarao = 3554 const XK_Thai_sarau = 3544 const XK_Thai_saraue = 3542 const XK_Thai_sarauee = 3543 const XK_Thai_sarauu = 3545 const XK_Thai_sorusi = 3529 const XK_Thai_sosala = 3528 const XK_Thai_soso = 3499 const XK_Thai_sosua = 3530 const XK_Thai_thanthakhat = 3564 const XK_Thai_thonangmontho = 3505 const XK_Thai_thophuthao = 3506 const XK_Thai_thothahan = 3511 const XK_Thai_thothan = 3504 const XK_Thai_thothong = 3512 const XK_Thai_thothung = 3510 const XK_Thai_topatak = 3503 const XK_Thai_totao = 3509 const XK_Thai_wowaen = 3527 const XK_Thai_yoyak = 3522 const XK_Thai_yoying = 3501 const XK_Thorn = 222 const XK_Touroku = 65323 const XK_Tslash = 940 const XK_U = 85 const XK_Uacute = 218 const XK_Ubelowdot = 16785124 const XK_Ubreve = 733 const XK_Ucircumflex = 219 const XK_Udiaeresis = 220 const XK_Udoubleacute = 475 const XK_Ugrave = 217 const XK_Uhook = 16785126 const XK_Uhorn = 16777647 const XK_Uhornacute = 16785128 const XK_Uhornbelowdot = 16785136 const XK_Uhorngrave = 16785130 const XK_Uhornhook = 16785132 const XK_Uhorntilde = 16785134 const XK_Ukrainian_GHE_WITH_UPTURN = 1725 const XK_Ukrainian_I = 1718 const XK_Ukrainian_IE = 1716 const XK_Ukrainian_YI = 1719 const XK_Ukrainian_ghe_with_upturn = 1709 const XK_Ukrainian_i = 1702 const XK_Ukrainian_ie = 1700 const XK_Ukrainian_yi = 1703 const XK_Ukranian_I = 1718 const XK_Ukranian_JE = 1716 const XK_Ukranian_YI = 1719 const XK_Ukranian_i = 1702 const XK_Ukranian_je = 1700 const XK_Ukranian_yi = 1703 const XK_Umacron = 990 const XK_Undo = 65381 const XK_Uogonek = 985 const XK_Up = 65362 const XK_Uring = 473 const XK_Utilde = 989 const XK_V = 86 const XK_VoidSymbol = 16777215 const XK_W = 87 const XK_Wacute = 16785026 const XK_Wcircumflex = 16777588 const XK_Wdiaeresis = 16785028 const XK_Wgrave = 16785024 const XK_WonSign = 16785577 const XK_X = 88 const XK_Xabovedot = 16785034 const XK_Y = 89 const XK_Yacute = 221 const XK_Ybelowdot = 16785140 const XK_Ycircumflex = 16777590 const XK_Ydiaeresis = 5054 const XK_Ygrave = 16785138 const XK_Yhook = 16785142 const XK_Ytilde = 16785144 const XK_Z = 90 const XK_Zabovedot = 431 const XK_Zacute = 428 const XK_Zcaron = 430 const XK_Zen_Koho = 65341 const XK_Zenkaku = 65320 const XK_Zenkaku_Hankaku = 65322 const XK_Zstroke = 16777653 const XK_a = 97 const XK_aacute = 225 const XK_abelowdot = 16785057 const XK_abovedot = 511 const XK_abreve = 483 const XK_abreveacute = 16785071 const XK_abrevebelowdot = 16785079 const XK_abrevegrave = 16785073 const XK_abrevehook = 16785075 const XK_abrevetilde = 16785077 const XK_acircumflex = 226 const XK_acircumflexacute = 16785061 const XK_acircumflexbelowdot = 16785069 const XK_acircumflexgrave = 16785063 const XK_acircumflexhook = 16785065 const XK_acircumflextilde = 16785067 const XK_acute = 180 const XK_adiaeresis = 228 const XK_ae = 230 const XK_agrave = 224 const XK_ahook = 16785059 const XK_amacron = 992 const XK_ampersand = 38 const XK_aogonek = 433 const XK_apostrophe = 39 const XK_approxeq = 16785992 const XK_aring = 229 const XK_asciicircum = 94 const XK_asciitilde = 126 const XK_asterisk = 42 const XK_at = 64 const XK_atilde = 227 const XK_b = 98 const XK_babovedot = 16784899 const XK_backslash = 92 const XK_bar = 124 const XK_because = 16785973 const XK_braceleft = 123 const XK_braceright = 125 const XK_bracketleft = 91 const XK_bracketright = 93 const XK_braille_blank = 16787456 const XK_braille_dot_1 = 65521 const XK_braille_dot_10 = 65530 const XK_braille_dot_2 = 65522 const XK_braille_dot_3 = 65523 const XK_braille_dot_4 = 65524 const XK_braille_dot_5 = 65525 const XK_braille_dot_6 = 65526 const XK_braille_dot_7 = 65527 const XK_braille_dot_8 = 65528 const XK_braille_dot_9 = 65529 const XK_braille_dots_1 = 16787457 const XK_braille_dots_12 = 16787459 const XK_braille_dots_123 = 16787463 const XK_braille_dots_1234 = 16787471 const XK_braille_dots_12345 = 16787487 const XK_braille_dots_123456 = 16787519 const XK_braille_dots_1234567 = 16787583 const XK_braille_dots_12345678 = 16787711 const XK_braille_dots_1234568 = 16787647 const XK_braille_dots_123457 = 16787551 const XK_braille_dots_1234578 = 16787679 const XK_braille_dots_123458 = 16787615 const XK_braille_dots_12346 = 16787503 const XK_braille_dots_123467 = 16787567 const XK_braille_dots_1234678 = 16787695 const XK_braille_dots_123468 = 16787631 const XK_braille_dots_12347 = 16787535 const XK_braille_dots_123478 = 16787663 const XK_braille_dots_12348 = 16787599 const XK_braille_dots_1235 = 16787479 const XK_braille_dots_12356 = 16787511 const XK_braille_dots_123567 = 16787575 const XK_braille_dots_1235678 = 16787703 const XK_braille_dots_123568 = 16787639 const XK_braille_dots_12357 = 16787543 const XK_braille_dots_123578 = 16787671 const XK_braille_dots_12358 = 16787607 const XK_braille_dots_1236 = 16787495 const XK_braille_dots_12367 = 16787559 const XK_braille_dots_123678 = 16787687 const XK_braille_dots_12368 = 16787623 const XK_braille_dots_1237 = 16787527 const XK_braille_dots_12378 = 16787655 const XK_braille_dots_1238 = 16787591 const XK_braille_dots_124 = 16787467 const XK_braille_dots_1245 = 16787483 const XK_braille_dots_12456 = 16787515 const XK_braille_dots_124567 = 16787579 const XK_braille_dots_1245678 = 16787707 const XK_braille_dots_124568 = 16787643 const XK_braille_dots_12457 = 16787547 const XK_braille_dots_124578 = 16787675 const XK_braille_dots_12458 = 16787611 const XK_braille_dots_1246 = 16787499 const XK_braille_dots_12467 = 16787563 const XK_braille_dots_124678 = 16787691 const XK_braille_dots_12468 = 16787627 const XK_braille_dots_1247 = 16787531 const XK_braille_dots_12478 = 16787659 const XK_braille_dots_1248 = 16787595 const XK_braille_dots_125 = 16787475 const XK_braille_dots_1256 = 16787507 const XK_braille_dots_12567 = 16787571 const XK_braille_dots_125678 = 16787699 const XK_braille_dots_12568 = 16787635 const XK_braille_dots_1257 = 16787539 const XK_braille_dots_12578 = 16787667 const XK_braille_dots_1258 = 16787603 const XK_braille_dots_126 = 16787491 const XK_braille_dots_1267 = 16787555 const XK_braille_dots_12678 = 16787683 const XK_braille_dots_1268 = 16787619 const XK_braille_dots_127 = 16787523 const XK_braille_dots_1278 = 16787651 const XK_braille_dots_128 = 16787587 const XK_braille_dots_13 = 16787461 const XK_braille_dots_134 = 16787469 const XK_braille_dots_1345 = 16787485 const XK_braille_dots_13456 = 16787517 const XK_braille_dots_134567 = 16787581 const XK_braille_dots_1345678 = 16787709 const XK_braille_dots_134568 = 16787645 const XK_braille_dots_13457 = 16787549 const XK_braille_dots_134578 = 16787677 const XK_braille_dots_13458 = 16787613 const XK_braille_dots_1346 = 16787501 const XK_braille_dots_13467 = 16787565 const XK_braille_dots_134678 = 16787693 const XK_braille_dots_13468 = 16787629 const XK_braille_dots_1347 = 16787533 const XK_braille_dots_13478 = 16787661 const XK_braille_dots_1348 = 16787597 const XK_braille_dots_135 = 16787477 const XK_braille_dots_1356 = 16787509 const XK_braille_dots_13567 = 16787573 const XK_braille_dots_135678 = 16787701 const XK_braille_dots_13568 = 16787637 const XK_braille_dots_1357 = 16787541 const XK_braille_dots_13578 = 16787669 const XK_braille_dots_1358 = 16787605 const XK_braille_dots_136 = 16787493 const XK_braille_dots_1367 = 16787557 const XK_braille_dots_13678 = 16787685 const XK_braille_dots_1368 = 16787621 const XK_braille_dots_137 = 16787525 const XK_braille_dots_1378 = 16787653 const XK_braille_dots_138 = 16787589 const XK_braille_dots_14 = 16787465 const XK_braille_dots_145 = 16787481 const XK_braille_dots_1456 = 16787513 const XK_braille_dots_14567 = 16787577 const XK_braille_dots_145678 = 16787705 const XK_braille_dots_14568 = 16787641 const XK_braille_dots_1457 = 16787545 const XK_braille_dots_14578 = 16787673 const XK_braille_dots_1458 = 16787609 const XK_braille_dots_146 = 16787497 const XK_braille_dots_1467 = 16787561 const XK_braille_dots_14678 = 16787689 const XK_braille_dots_1468 = 16787625 const XK_braille_dots_147 = 16787529 const XK_braille_dots_1478 = 16787657 const XK_braille_dots_148 = 16787593 const XK_braille_dots_15 = 16787473 const XK_braille_dots_156 = 16787505 const XK_braille_dots_1567 = 16787569 const XK_braille_dots_15678 = 16787697 const XK_braille_dots_1568 = 16787633 const XK_braille_dots_157 = 16787537 const XK_braille_dots_1578 = 16787665 const XK_braille_dots_158 = 16787601 const XK_braille_dots_16 = 16787489 const XK_braille_dots_167 = 16787553 const XK_braille_dots_1678 = 16787681 const XK_braille_dots_168 = 16787617 const XK_braille_dots_17 = 16787521 const XK_braille_dots_178 = 16787649 const XK_braille_dots_18 = 16787585 const XK_braille_dots_2 = 16787458 const XK_braille_dots_23 = 16787462 const XK_braille_dots_234 = 16787470 const XK_braille_dots_2345 = 16787486 const XK_braille_dots_23456 = 16787518 const XK_braille_dots_234567 = 16787582 const XK_braille_dots_2345678 = 16787710 const XK_braille_dots_234568 = 16787646 const XK_braille_dots_23457 = 16787550 const XK_braille_dots_234578 = 16787678 const XK_braille_dots_23458 = 16787614 const XK_braille_dots_2346 = 16787502 const XK_braille_dots_23467 = 16787566 const XK_braille_dots_234678 = 16787694 const XK_braille_dots_23468 = 16787630 const XK_braille_dots_2347 = 16787534 const XK_braille_dots_23478 = 16787662 const XK_braille_dots_2348 = 16787598 const XK_braille_dots_235 = 16787478 const XK_braille_dots_2356 = 16787510 const XK_braille_dots_23567 = 16787574 const XK_braille_dots_235678 = 16787702 const XK_braille_dots_23568 = 16787638 const XK_braille_dots_2357 = 16787542 const XK_braille_dots_23578 = 16787670 const XK_braille_dots_2358 = 16787606 const XK_braille_dots_236 = 16787494 const XK_braille_dots_2367 = 16787558 const XK_braille_dots_23678 = 16787686 const XK_braille_dots_2368 = 16787622 const XK_braille_dots_237 = 16787526 const XK_braille_dots_2378 = 16787654 const XK_braille_dots_238 = 16787590 const XK_braille_dots_24 = 16787466 const XK_braille_dots_245 = 16787482 const XK_braille_dots_2456 = 16787514 const XK_braille_dots_24567 = 16787578 const XK_braille_dots_245678 = 16787706 const XK_braille_dots_24568 = 16787642 const XK_braille_dots_2457 = 16787546 const XK_braille_dots_24578 = 16787674 const XK_braille_dots_2458 = 16787610 const XK_braille_dots_246 = 16787498 const XK_braille_dots_2467 = 16787562 const XK_braille_dots_24678 = 16787690 const XK_braille_dots_2468 = 16787626 const XK_braille_dots_247 = 16787530 const XK_braille_dots_2478 = 16787658 const XK_braille_dots_248 = 16787594 const XK_braille_dots_25 = 16787474 const XK_braille_dots_256 = 16787506 const XK_braille_dots_2567 = 16787570 const XK_braille_dots_25678 = 16787698 const XK_braille_dots_2568 = 16787634 const XK_braille_dots_257 = 16787538 const XK_braille_dots_2578 = 16787666 const XK_braille_dots_258 = 16787602 const XK_braille_dots_26 = 16787490 const XK_braille_dots_267 = 16787554 const XK_braille_dots_2678 = 16787682 const XK_braille_dots_268 = 16787618 const XK_braille_dots_27 = 16787522 const XK_braille_dots_278 = 16787650 const XK_braille_dots_28 = 16787586 const XK_braille_dots_3 = 16787460 const XK_braille_dots_34 = 16787468 const XK_braille_dots_345 = 16787484 const XK_braille_dots_3456 = 16787516 const XK_braille_dots_34567 = 16787580 const XK_braille_dots_345678 = 16787708 const XK_braille_dots_34568 = 16787644 const XK_braille_dots_3457 = 16787548 const XK_braille_dots_34578 = 16787676 const XK_braille_dots_3458 = 16787612 const XK_braille_dots_346 = 16787500 const XK_braille_dots_3467 = 16787564 const XK_braille_dots_34678 = 16787692 const XK_braille_dots_3468 = 16787628 const XK_braille_dots_347 = 16787532 const XK_braille_dots_3478 = 16787660 const XK_braille_dots_348 = 16787596 const XK_braille_dots_35 = 16787476 const XK_braille_dots_356 = 16787508 const XK_braille_dots_3567 = 16787572 const XK_braille_dots_35678 = 16787700 const XK_braille_dots_3568 = 16787636 const XK_braille_dots_357 = 16787540 const XK_braille_dots_3578 = 16787668 const XK_braille_dots_358 = 16787604 const XK_braille_dots_36 = 16787492 const XK_braille_dots_367 = 16787556 const XK_braille_dots_3678 = 16787684 const XK_braille_dots_368 = 16787620 const XK_braille_dots_37 = 16787524 const XK_braille_dots_378 = 16787652 const XK_braille_dots_38 = 16787588 const XK_braille_dots_4 = 16787464 const XK_braille_dots_45 = 16787480 const XK_braille_dots_456 = 16787512 const XK_braille_dots_4567 = 16787576 const XK_braille_dots_45678 = 16787704 const XK_braille_dots_4568 = 16787640 const XK_braille_dots_457 = 16787544 const XK_braille_dots_4578 = 16787672 const XK_braille_dots_458 = 16787608 const XK_braille_dots_46 = 16787496 const XK_braille_dots_467 = 16787560 const XK_braille_dots_4678 = 16787688 const XK_braille_dots_468 = 16787624 const XK_braille_dots_47 = 16787528 const XK_braille_dots_478 = 16787656 const XK_braille_dots_48 = 16787592 const XK_braille_dots_5 = 16787472 const XK_braille_dots_56 = 16787504 const XK_braille_dots_567 = 16787568 const XK_braille_dots_5678 = 16787696 const XK_braille_dots_568 = 16787632 const XK_braille_dots_57 = 16787536 const XK_braille_dots_578 = 16787664 const XK_braille_dots_58 = 16787600 const XK_braille_dots_6 = 16787488 const XK_braille_dots_67 = 16787552 const XK_braille_dots_678 = 16787680 const XK_braille_dots_68 = 16787616 const XK_braille_dots_7 = 16787520 const XK_braille_dots_78 = 16787648 const XK_braille_dots_8 = 16787584 const XK_breve = 418 const XK_brokenbar = 166 const XK_c = 99 const XK_c_h = 65187 const XK_cabovedot = 741 const XK_cacute = 486 const XK_caron = 439 const XK_ccaron = 488 const XK_ccedilla = 231 const XK_ccircumflex = 742 const XK_cedilla = 184 const XK_cent = 162 const XK_ch = 65184 const XK_colon = 58 const XK_comma = 44 const XK_containsas = 16785931 const XK_copyright = 169 const XK_cuberoot = 16785947 const XK_currency = 164 const XK_d = 100 const XK_dabovedot = 16784907 const XK_dcaron = 495 const XK_dead_A = 65153 const XK_dead_E = 65155 const XK_dead_I = 65157 const XK_dead_O = 65159 const XK_dead_U = 65161 const XK_dead_a = 65152 const XK_dead_abovecomma = 65124 const XK_dead_abovedot = 65110 const XK_dead_abovereversedcomma = 65125 const XK_dead_abovering = 65112 const XK_dead_aboveverticalline = 65169 const XK_dead_acute = 65105 const XK_dead_belowbreve = 65131 const XK_dead_belowcircumflex = 65129 const XK_dead_belowcomma = 65134 const XK_dead_belowdiaeresis = 65132 const XK_dead_belowdot = 65120 const XK_dead_belowmacron = 65128 const XK_dead_belowring = 65127 const XK_dead_belowtilde = 65130 const XK_dead_belowverticalline = 65170 const XK_dead_breve = 65109 const XK_dead_capital_schwa = 65163 const XK_dead_caron = 65114 const XK_dead_cedilla = 65115 const XK_dead_circumflex = 65106 const XK_dead_currency = 65135 const XK_dead_dasia = 65125 const XK_dead_diaeresis = 65111 const XK_dead_doubleacute = 65113 const XK_dead_doublegrave = 65126 const XK_dead_e = 65154 const XK_dead_grave = 65104 const XK_dead_greek = 65164 const XK_dead_hook = 65121 const XK_dead_horn = 65122 const XK_dead_i = 65156 const XK_dead_invertedbreve = 65133 const XK_dead_iota = 65117 const XK_dead_longsolidusoverlay = 65171 const XK_dead_lowline = 65168 const XK_dead_macron = 65108 const XK_dead_o = 65158 const XK_dead_ogonek = 65116 const XK_dead_perispomeni = 65107 const XK_dead_psili = 65124 const XK_dead_semivoiced_sound = 65119 const XK_dead_small_schwa = 65162 const XK_dead_stroke = 65123 const XK_dead_tilde = 65107 const XK_dead_u = 65160 const XK_dead_voiced_sound = 65118 const XK_degree = 176 const XK_diaeresis = 168 const XK_dintegral = 16785964 const XK_division = 247 const XK_dollar = 36 const XK_doubleacute = 445 const XK_dstroke = 496 const XK_e = 101 const XK_eabovedot = 1004 const XK_eacute = 233 const XK_ebelowdot = 16785081 const XK_ecaron = 492 const XK_ecircumflex = 234 const XK_ecircumflexacute = 16785087 const XK_ecircumflexbelowdot = 16785095 const XK_ecircumflexgrave = 16785089 const XK_ecircumflexhook = 16785091 const XK_ecircumflextilde = 16785093 const XK_ediaeresis = 235 const XK_egrave = 232 const XK_ehook = 16785083 const XK_eightsubscript = 16785544 const XK_eightsuperior = 16785528 const XK_elementof = 16785928 const XK_emacron = 954 const XK_emptyset = 16785925 const XK_eng = 959 const XK_eogonek = 490 const XK_equal = 61 const XK_eth = 240 const XK_etilde = 16785085 const XK_exclam = 33 const XK_exclamdown = 161 const XK_ezh = 16777874 const XK_f = 102 const XK_fabovedot = 16784927 const XK_fivesubscript = 16785541 const XK_fivesuperior = 16785525 const XK_foursubscript = 16785540 const XK_foursuperior = 16785524 const XK_fourthroot = 16785948 const XK_g = 103 const XK_gabovedot = 757 const XK_gbreve = 699 const XK_gcaron = 16777703 const XK_gcedilla = 955 const XK_gcircumflex = 760 const XK_grave = 96 const XK_greater = 62 const XK_guillemotleft = 171 const XK_guillemotright = 187 const XK_h = 104 const XK_hcircumflex = 694 const XK_hebrew_aleph = 3296 const XK_hebrew_ayin = 3314 const XK_hebrew_bet = 3297 const XK_hebrew_beth = 3297 const XK_hebrew_chet = 3303 const XK_hebrew_dalet = 3299 const XK_hebrew_daleth = 3299 const XK_hebrew_doublelowline = 3295 const XK_hebrew_finalkaph = 3306 const XK_hebrew_finalmem = 3309 const XK_hebrew_finalnun = 3311 const XK_hebrew_finalpe = 3315 const XK_hebrew_finalzade = 3317 const XK_hebrew_finalzadi = 3317 const XK_hebrew_gimel = 3298 const XK_hebrew_gimmel = 3298 const XK_hebrew_he = 3300 const XK_hebrew_het = 3303 const XK_hebrew_kaph = 3307 const XK_hebrew_kuf = 3319 const XK_hebrew_lamed = 3308 const XK_hebrew_mem = 3310 const XK_hebrew_nun = 3312 const XK_hebrew_pe = 3316 const XK_hebrew_qoph = 3319 const XK_hebrew_resh = 3320 const XK_hebrew_samech = 3313 const XK_hebrew_samekh = 3313 const XK_hebrew_shin = 3321 const XK_hebrew_taf = 3322 const XK_hebrew_taw = 3322 const XK_hebrew_tet = 3304 const XK_hebrew_teth = 3304 const XK_hebrew_waw = 3301 const XK_hebrew_yod = 3305 const XK_hebrew_zade = 3318 const XK_hebrew_zadi = 3318 const XK_hebrew_zain = 3302 const XK_hebrew_zayin = 3302 const XK_hstroke = 689 const XK_hyphen = 173 const XK_i = 105 const XK_iacute = 237 const XK_ibelowdot = 16785099 const XK_ibreve = 16777517 const XK_icircumflex = 238 const XK_idiaeresis = 239 const XK_idotless = 697 const XK_igrave = 236 const XK_ihook = 16785097 const XK_imacron = 1007 const XK_iogonek = 999 const XK_itilde = 949 const XK_j = 106 const XK_jcircumflex = 700 const XK_k = 107 const XK_kana_A = 1201 const XK_kana_CHI = 1217 const XK_kana_E = 1204 const XK_kana_FU = 1228 const XK_kana_HA = 1226 const XK_kana_HE = 1229 const XK_kana_HI = 1227 const XK_kana_HO = 1230 const XK_kana_HU = 1228 const XK_kana_I = 1202 const XK_kana_KA = 1206 const XK_kana_KE = 1209 const XK_kana_KI = 1207 const XK_kana_KO = 1210 const XK_kana_KU = 1208 const XK_kana_MA = 1231 const XK_kana_ME = 1234 const XK_kana_MI = 1232 const XK_kana_MO = 1235 const XK_kana_MU = 1233 const XK_kana_N = 1245 const XK_kana_NA = 1221 const XK_kana_NE = 1224 const XK_kana_NI = 1222 const XK_kana_NO = 1225 const XK_kana_NU = 1223 const XK_kana_O = 1205 const XK_kana_RA = 1239 const XK_kana_RE = 1242 const XK_kana_RI = 1240 const XK_kana_RO = 1243 const XK_kana_RU = 1241 const XK_kana_SA = 1211 const XK_kana_SE = 1214 const XK_kana_SHI = 1212 const XK_kana_SO = 1215 const XK_kana_SU = 1213 const XK_kana_TA = 1216 const XK_kana_TE = 1219 const XK_kana_TI = 1217 const XK_kana_TO = 1220 const XK_kana_TSU = 1218 const XK_kana_TU = 1218 const XK_kana_U = 1203 const XK_kana_WA = 1244 const XK_kana_WO = 1190 const XK_kana_YA = 1236 const XK_kana_YO = 1238 const XK_kana_YU = 1237 const XK_kana_a = 1191 const XK_kana_closingbracket = 1187 const XK_kana_comma = 1188 const XK_kana_conjunctive = 1189 const XK_kana_e = 1194 const XK_kana_fullstop = 1185 const XK_kana_i = 1192 const XK_kana_middledot = 1189 const XK_kana_o = 1195 const XK_kana_openingbracket = 1186 const XK_kana_switch = 65406 const XK_kana_tsu = 1199 const XK_kana_tu = 1199 const XK_kana_u = 1193 const XK_kana_ya = 1196 const XK_kana_yo = 1198 const XK_kana_yu = 1197 const XK_kappa = 930 const XK_kcedilla = 1011 const XK_kra = 930 const XK_l = 108 const XK_lacute = 485 const XK_lbelowdot = 16784951 const XK_lcaron = 437 const XK_lcedilla = 950 const XK_less = 60 const XK_lstroke = 435 const XK_m = 109 const XK_mabovedot = 16784961 const XK_macron = 175 const XK_masculine = 186 const XK_minus = 45 const XK_mu = 181 const XK_multiply = 215 const XK_n = 110 const XK_nacute = 497 const XK_ncaron = 498 const XK_ncedilla = 1009 const XK_ninesubscript = 16785545 const XK_ninesuperior = 16785529 const XK_nobreakspace = 160 const XK_notapproxeq = 16785991 const XK_notelementof = 16785929 const XK_notidentical = 16786018 const XK_notsign = 172 const XK_ntilde = 241 const XK_numbersign = 35 const XK_numerosign = 1712 const XK_o = 111 const XK_oacute = 243 const XK_obarred = 16777845 const XK_obelowdot = 16785101 const XK_ocaron = 16777682 const XK_ocircumflex = 244 const XK_ocircumflexacute = 16785105 const XK_ocircumflexbelowdot = 16785113 const XK_ocircumflexgrave = 16785107 const XK_ocircumflexhook = 16785109 const XK_ocircumflextilde = 16785111 const XK_odiaeresis = 246 const XK_odoubleacute = 501 const XK_oe = 5053 const XK_ogonek = 434 const XK_ograve = 242 const XK_ohook = 16785103 const XK_ohorn = 16777633 const XK_ohornacute = 16785115 const XK_ohornbelowdot = 16785123 const XK_ohorngrave = 16785117 const XK_ohornhook = 16785119 const XK_ohorntilde = 16785121 const XK_omacron = 1010 const XK_onehalf = 189 const XK_onequarter = 188 const XK_onesubscript = 16785537 const XK_onesuperior = 185 const XK_ooblique = 248 const XK_ordfeminine = 170 const XK_oslash = 248 const XK_otilde = 245 const XK_overline = 1150 const XK_p = 112 const XK_pabovedot = 16784983 const XK_paragraph = 182 const XK_parenleft = 40 const XK_parenright = 41 const XK_partdifferential = 16785922 const XK_percent = 37 const XK_period = 46 const XK_periodcentered = 183 const XK_plus = 43 const XK_plusminus = 177 const XK_prolongedsound = 1200 const XK_q = 113 const XK_question = 63 const XK_questiondown = 191 const XK_quotedbl = 34 const XK_quoteleft = 96 const XK_quoteright = 39 const XK_r = 114 const XK_racute = 480 const XK_rcaron = 504 const XK_rcedilla = 947 const XK_registered = 174 const XK_s = 115 const XK_sabovedot = 16784993 const XK_sacute = 438 const XK_scaron = 441 const XK_scedilla = 442 const XK_schwa = 16777817 const XK_scircumflex = 766 const XK_script_switch = 65406 const XK_section = 167 const XK_semicolon = 59 const XK_semivoicedsound = 1247 const XK_sevensubscript = 16785543 const XK_sevensuperior = 16785527 const XK_sixsubscript = 16785542 const XK_sixsuperior = 16785526 const XK_slash = 47 const XK_space = 32 const XK_squareroot = 16785946 const XK_ssharp = 223 const XK_sterling = 163 const XK_stricteq = 16786019 const XK_t = 116 const XK_tabovedot = 16785003 const XK_tcaron = 443 const XK_tcedilla = 510 const XK_thorn = 254 const XK_threequarters = 190 const XK_threesubscript = 16785539 const XK_threesuperior = 179 const XK_tintegral = 16785965 const XK_tslash = 956 const XK_twosubscript = 16785538 const XK_twosuperior = 178 const XK_u = 117 const XK_uacute = 250 const XK_ubelowdot = 16785125 const XK_ubreve = 765 const XK_ucircumflex = 251 const XK_udiaeresis = 252 const XK_udoubleacute = 507 const XK_ugrave = 249 const XK_uhook = 16785127 const XK_uhorn = 16777648 const XK_uhornacute = 16785129 const XK_uhornbelowdot = 16785137 const XK_uhorngrave = 16785131 const XK_uhornhook = 16785133 const XK_uhorntilde = 16785135 const XK_umacron = 1022 const XK_underscore = 95 const XK_uogonek = 1017 const XK_uring = 505 const XK_utilde = 1021 const XK_v = 118 const XK_voicedsound = 1246 const XK_w = 119 const XK_wacute = 16785027 const XK_wcircumflex = 16777589 const XK_wdiaeresis = 16785029 const XK_wgrave = 16785025 const XK_x = 120 const XK_xabovedot = 16785035 const XK_y = 121 const XK_yacute = 253 const XK_ybelowdot = 16785141 const XK_ycircumflex = 16777591 const XK_ydiaeresis = 255 const XK_yen = 165 const XK_ygrave = 16785139 const XK_yhook = 16785143 const XK_ytilde = 16785145 const XK_z = 122 const XK_zabovedot = 447 const XK_zacute = 444 const XK_zcaron = 446 const XK_zerosubscript = 16785536 const XK_zerosuperior = 16785520 const XK_zstroke = 16777654 const XLocaleNotSupported = -2 const XLookupBoth = 4 const XLookupChars = 2 const XLookupKeySym = 3 const XLookupNone = 1 const XMD_H = 1 const XNArea = "area" const XNAreaNeeded = "areaNeeded" const XNBackground = "background" const XNBackgroundPixmap = "backgroundPixmap" const XNBaseFontName = "baseFontName" const XNClientWindow = "clientWindow" const XNColormap = "colorMap" const XNContextualDrawing = "contextualDrawing" const XNCursor = "cursor" const XNDefaultString = "defaultString" const XNDestroyCallback = "destroyCallback" const XNDirectionalDependentDrawing = "directionalDependentDrawing" const XNFilterEvents = "filterEvents" const XNFocusWindow = "focusWindow" const XNFontInfo = "fontInfo" const XNFontSet = "fontSet" const XNForeground = "foreground" const XNGeometryCallback = "geometryCallback" const XNHotKey = "hotKey" const XNHotKeyState = "hotKeyState" const XNInputStyle = "inputStyle" const XNLineSpace = "lineSpace" const XNMissingCharSet = "missingCharSet" const XNOMAutomatic = "omAutomatic" const XNOrientation = "orientation" const XNPreeditAttributes = "preeditAttributes" const XNPreeditCaretCallback = "preeditCaretCallback" const XNPreeditDoneCallback = "preeditDoneCallback" const XNPreeditDrawCallback = "preeditDrawCallback" const XNPreeditStartCallback = "preeditStartCallback" const XNPreeditState = "preeditState" const XNPreeditStateNotifyCallback = "preeditStateNotifyCallback" const XNQueryICValuesList = "queryICValuesList" const XNQueryIMValuesList = "queryIMValuesList" const XNQueryInputStyle = "queryInputStyle" const XNQueryOrientation = "queryOrientation" const XNR6PreeditCallback = "r6PreeditCallback" const XNRequiredCharSet = "requiredCharSet" const XNResetState = "resetState" const XNResourceClass = "resourceClass" const XNResourceName = "resourceName" const XNSeparatorofNestedList = "separatorofNestedList" const XNSpotLocation = "spotLocation" const XNStatusAttributes = "statusAttributes" const XNStatusDoneCallback = "statusDoneCallback" const XNStatusDrawCallback = "statusDrawCallback" const XNStatusStartCallback = "statusStartCallback" const XNStdColormap = "stdColorMap" const XNStringConversion = "stringConversion" const XNStringConversionCallback = "stringConversionCallback" const XNVaNestedList = "XNVaNestedList" const XNVisiblePosition = "visiblePosition" const XNegative = 16 const XNoMemory = -1 const XUrgencyHint = 256 const XValue = 1 const XYBitmap = 0 const XYPixmap = 1 const X_AllocColor = 84 const X_AllocColorCells = 86 const X_AllocColorPlanes = 87 const X_AllocNamedColor = 85 const X_AllowEvents = 35 const X_Bell = 104 const X_ChangeActivePointerGrab = 30 const X_ChangeGC = 56 const X_ChangeHosts = 109 const X_ChangeKeyboardControl = 102 const X_ChangeKeyboardMapping = 100 const X_ChangePointerControl = 105 const X_ChangeProperty = 18 const X_ChangeSaveSet = 6 const X_ChangeWindowAttributes = 2 const X_CirculateWindow = 13 const X_ClearArea = 61 const X_CloseFont = 46 const X_ConfigureWindow = 12 const X_ConvertSelection = 24 const X_CopyArea = 62 const X_CopyColormapAndFree = 80 const X_CopyGC = 57 const X_CopyPlane = 63 const X_CreateColormap = 78 const X_CreateCursor = 93 const X_CreateGC = 55 const X_CreateGlyphCursor = 94 const X_CreatePixmap = 53 const X_CreateWindow = 1 const X_DeleteProperty = 19 const X_DestroySubwindows = 5 const X_DestroyWindow = 4 const X_Error = 0 const X_FillPoly = 69 const X_ForceScreenSaver = 115 const X_FreeColormap = 79 const X_FreeColors = 88 const X_FreeCursor = 95 const X_FreeGC = 60 const X_FreePixmap = 54 const X_GetAtomName = 17 const X_GetFontPath = 52 const X_GetGeometry = 14 const X_GetImage = 73 const X_GetInputFocus = 43 const X_GetKeyboardControl = 103 const X_GetKeyboardMapping = 101 const X_GetModifierMapping = 119 const X_GetMotionEvents = 39 const X_GetPointerControl = 106 const X_GetPointerMapping = 117 const X_GetProperty = 20 const X_GetScreenSaver = 108 const X_GetSelectionOwner = 23 const X_GetWindowAttributes = 3 const X_GrabButton = 28 const X_GrabKey = 33 const X_GrabKeyboard = 31 const X_GrabPointer = 26 const X_GrabServer = 36 const X_HAVE_UTF8_STRING = 1 const X_ImageText16 = 77 const X_ImageText8 = 76 const X_InstallColormap = 81 const X_InternAtom = 16 const X_KillClient = 113 const X_ListExtensions = 99 const X_ListFonts = 49 const X_ListFontsWithInfo = 50 const X_ListHosts = 110 const X_ListInstalledColormaps = 83 const X_ListProperties = 21 const X_LookupColor = 92 const X_MapSubwindows = 9 const X_MapWindow = 8 const X_NoOperation = 127 const X_OK = 1 const X_OpenFont = 45 const X_PROTOCOL = 11 const X_PROTOCOL_REVISION = 0 const X_PolyArc = 68 const X_PolyFillArc = 71 const X_PolyFillRectangle = 70 const X_PolyLine = 65 const X_PolyPoint = 64 const X_PolyRectangle = 67 const X_PolySegment = 66 const X_PolyText16 = 75 const X_PolyText8 = 74 const X_PutImage = 72 const X_QueryBestSize = 97 const X_QueryColors = 91 const X_QueryExtension = 98 const X_QueryFont = 47 const X_QueryKeymap = 44 const X_QueryPointer = 38 const X_QueryTextExtents = 48 const X_QueryTree = 15 const X_RecolorCursor = 96 const X_ReparentWindow = 7 const X_Reply = 1 const X_RotateProperties = 114 const X_SendEvent = 25 const X_SetAccessControl = 111 const X_SetClipRectangles = 59 const X_SetCloseDownMode = 112 const X_SetDashes = 58 const X_SetFontPath = 51 const X_SetInputFocus = 42 const X_SetModifierMapping = 118 const X_SetPointerMapping = 116 const X_SetScreenSaver = 107 const X_SetSelectionOwner = 22 const X_StoreColors = 89 const X_StoreNamedColor = 90 const X_TCP_PORT = 6000 const X_TranslateCoords = 40 const X_UngrabButton = 29 const X_UngrabKey = 34 const X_UngrabKeyboard = 32 const X_UngrabPointer = 27 const X_UngrabServer = 37 const X_UninstallColormap = 82 const X_UnmapSubwindows = 11 const X_UnmapWindow = 10 const X_WarpPointer = 41 const XlibSpecificationRelease = 6 const XrmEnumAllLevels = 0 const XrmEnumOneLevel = 1 const YNegative = 32 const YSorted = 1 const YValue = 2 const YXBanded = 3 const YXSorted = 2 const ZIPFS_BUILD = 2 const ZPixmap = 2 const ZoomState = 2 const _ARCH_PPC = 1 const _ARCH_PPC64 = 1 const _ARCH_PPCGR = 1 const _ARCH_PPCSQ = 1 const _ARCH_PWR4 = 1 const _ARCH_PWR5 = 1 const _ARCH_PWR5X = 1 const _ARCH_PWR6 = 1 const _ARCH_PWR7 = 1 const _ARCH_PWR8 = 1 const _CALL_ELF = 2 const _CALL_LINUX = 1 const _CS_GNU_LIBC_VERSION = 2 const _CS_GNU_LIBPTHREAD_VERSION = 3 const _CS_PATH = 0 const _CS_POSIX_V5_WIDTH_RESTRICTED_ENVS = 4 const _CS_POSIX_V6_ILP32_OFF32_CFLAGS = 1116 const _CS_POSIX_V6_ILP32_OFF32_LDFLAGS = 1117 const _CS_POSIX_V6_ILP32_OFF32_LIBS = 1118 const _CS_POSIX_V6_ILP32_OFF32_LINTFLAGS = 1119 const _CS_POSIX_V6_ILP32_OFFBIG_CFLAGS = 1120 const _CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS = 1121 const _CS_POSIX_V6_ILP32_OFFBIG_LIBS = 1122 const _CS_POSIX_V6_ILP32_OFFBIG_LINTFLAGS = 1123 const _CS_POSIX_V6_LP64_OFF64_CFLAGS = 1124 const _CS_POSIX_V6_LP64_OFF64_LDFLAGS = 1125 const _CS_POSIX_V6_LP64_OFF64_LIBS = 1126 const _CS_POSIX_V6_LP64_OFF64_LINTFLAGS = 1127 const _CS_POSIX_V6_LPBIG_OFFBIG_CFLAGS = 1128 const _CS_POSIX_V6_LPBIG_OFFBIG_LDFLAGS = 1129 const _CS_POSIX_V6_LPBIG_OFFBIG_LIBS = 1130 const _CS_POSIX_V6_LPBIG_OFFBIG_LINTFLAGS = 1131 const _CS_POSIX_V6_WIDTH_RESTRICTED_ENVS = 1 const _CS_POSIX_V7_ILP32_OFF32_CFLAGS = 1132 const _CS_POSIX_V7_ILP32_OFF32_LDFLAGS = 1133 const _CS_POSIX_V7_ILP32_OFF32_LIBS = 1134 const _CS_POSIX_V7_ILP32_OFF32_LINTFLAGS = 1135 const _CS_POSIX_V7_ILP32_OFFBIG_CFLAGS = 1136 const _CS_POSIX_V7_ILP32_OFFBIG_LDFLAGS = 1137 const _CS_POSIX_V7_ILP32_OFFBIG_LIBS = 1138 const _CS_POSIX_V7_ILP32_OFFBIG_LINTFLAGS = 1139 const _CS_POSIX_V7_LP64_OFF64_CFLAGS = 1140 const _CS_POSIX_V7_LP64_OFF64_LDFLAGS = 1141 const _CS_POSIX_V7_LP64_OFF64_LIBS = 1142 const _CS_POSIX_V7_LP64_OFF64_LINTFLAGS = 1143 const _CS_POSIX_V7_LPBIG_OFFBIG_CFLAGS = 1144 const _CS_POSIX_V7_LPBIG_OFFBIG_LDFLAGS = 1145 const _CS_POSIX_V7_LPBIG_OFFBIG_LIBS = 1146 const _CS_POSIX_V7_LPBIG_OFFBIG_LINTFLAGS = 1147 const _CS_POSIX_V7_THREADS_CFLAGS = 1150 const _CS_POSIX_V7_THREADS_LDFLAGS = 1151 const _CS_POSIX_V7_WIDTH_RESTRICTED_ENVS = 5 const _CS_V6_ENV = 1148 const _CS_V7_ENV = 1149 const _GNU_SOURCE = 1 const _IOFBF = 0 const _IOLBF = 1 const _IONBF = 2 const _LARGEFILE64_SOURCE = 1 const _LITTLE_ENDIAN = 1 const _LP64 = 1 const _PC_2_SYMLINKS = 20 const _PC_ALLOC_SIZE_MIN = 18 const _PC_ASYNC_IO = 10 const _PC_CHOWN_RESTRICTED = 6 const _PC_FILESIZEBITS = 13 const _PC_LINK_MAX = 0 const _PC_MAX_CANON = 1 const _PC_MAX_INPUT = 2 const _PC_NAME_MAX = 3 const _PC_NO_TRUNC = 7 const _PC_PATH_MAX = 4 const _PC_PIPE_BUF = 5 const _PC_PRIO_IO = 11 const _PC_REC_INCR_XFER_SIZE = 14 const _PC_REC_MAX_XFER_SIZE = 15 const _PC_REC_MIN_XFER_SIZE = 16 const _PC_REC_XFER_ALIGN = 17 const _PC_SOCK_MAXBUF = 12 const _PC_SYMLINK_MAX = 19 const _PC_SYNC_IO = 9 const _PC_VDISABLE = 8 const _POSIX2_BC_BASE_MAX = 99 const _POSIX2_BC_DIM_MAX = 2048 const _POSIX2_BC_SCALE_MAX = 99 const _POSIX2_BC_STRING_MAX = 1000 const _POSIX2_CHARCLASS_NAME_MAX = 14 const _POSIX2_COLL_WEIGHTS_MAX = 2 const _POSIX2_C_BIND = 200809 const _POSIX2_EXPR_NEST_MAX = 32 const _POSIX2_LINE_MAX = 2048 const _POSIX2_RE_DUP_MAX = 255 const _POSIX2_VERSION = 200809 const _POSIX_ADVISORY_INFO = 200809 const _POSIX_AIO_LISTIO_MAX = 2 const _POSIX_AIO_MAX = 1 const _POSIX_ARG_MAX = 4096 const _POSIX_ASYNCHRONOUS_IO = 200809 const _POSIX_BARRIERS = 200809 const _POSIX_CHILD_MAX = 25 const _POSIX_CHOWN_RESTRICTED = 1 const _POSIX_CLOCKRES_MIN = 20000000 const _POSIX_CLOCK_SELECTION = 200809 const _POSIX_CPUTIME = 200809 const _POSIX_DELAYTIMER_MAX = 32 const _POSIX_FSYNC = 200809 const _POSIX_HOST_NAME_MAX = 255 const _POSIX_IPV6 = 200809 const _POSIX_JOB_CONTROL = 1 const _POSIX_LINK_MAX = 8 const _POSIX_LOGIN_NAME_MAX = 9 const _POSIX_MAPPED_FILES = 200809 const _POSIX_MAX_CANON = 255 const _POSIX_MAX_INPUT = 255 const _POSIX_MEMLOCK = 200809 const _POSIX_MEMLOCK_RANGE = 200809 const _POSIX_MEMORY_PROTECTION = 200809 const _POSIX_MESSAGE_PASSING = 200809 const _POSIX_MONOTONIC_CLOCK = 200809 const _POSIX_MQ_OPEN_MAX = 8 const _POSIX_MQ_PRIO_MAX = 32 const _POSIX_NAME_MAX = 14 const _POSIX_NGROUPS_MAX = 8 const _POSIX_NO_TRUNC = 1 const _POSIX_OPEN_MAX = 20 const _POSIX_PATH_MAX = 256 const _POSIX_PIPE_BUF = 512 const _POSIX_RAW_SOCKETS = 200809 const _POSIX_READER_WRITER_LOCKS = 200809 const _POSIX_REALTIME_SIGNALS = 200809 const _POSIX_REGEXP = 1 const _POSIX_RE_DUP_MAX = 255 const _POSIX_RTSIG_MAX = 8 const _POSIX_SAVED_IDS = 1 const _POSIX_SEMAPHORES = 200809 const _POSIX_SEM_NSEMS_MAX = 256 const _POSIX_SEM_VALUE_MAX = 32767 const _POSIX_SHARED_MEMORY_OBJECTS = 200809 const _POSIX_SHELL = 1 const _POSIX_SIGQUEUE_MAX = 32 const _POSIX_SPAWN = 200809 const _POSIX_SPIN_LOCKS = 200809 const _POSIX_SSIZE_MAX = 32767 const _POSIX_SS_REPL_MAX = 4 const _POSIX_STREAM_MAX = 8 const _POSIX_SYMLINK_MAX = 255 const _POSIX_SYMLOOP_MAX = 8 const _POSIX_THREADS = 200809 const _POSIX_THREAD_ATTR_STACKADDR = 200809 const _POSIX_THREAD_ATTR_STACKSIZE = 200809 const _POSIX_THREAD_CPUTIME = 200809 const _POSIX_THREAD_DESTRUCTOR_ITERATIONS = 4 const _POSIX_THREAD_KEYS_MAX = 128 const _POSIX_THREAD_PRIORITY_SCHEDULING = 200809 const _POSIX_THREAD_PROCESS_SHARED = 200809 const _POSIX_THREAD_SAFE_FUNCTIONS = 200809 const _POSIX_THREAD_THREADS_MAX = 64 const _POSIX_TIMEOUTS = 200809 const _POSIX_TIMERS = 200809 const _POSIX_TIMER_MAX = 32 const _POSIX_TRACE_EVENT_NAME_MAX = 30 const _POSIX_TRACE_NAME_MAX = 8 const _POSIX_TRACE_SYS_MAX = 8 const _POSIX_TRACE_USER_EVENT_MAX = 32 const _POSIX_TTY_NAME_MAX = 9 const _POSIX_TZNAME_MAX = 6 const _POSIX_V6_LP64_OFF64 = 1 const _POSIX_V7_LP64_OFF64 = 1 const _POSIX_VDISABLE = 0 const _POSIX_VERSION = 200809 const _SC_2_CHAR_TERM = 95 const _SC_2_C_BIND = 47 const _SC_2_C_DEV = 48 const _SC_2_FORT_DEV = 49 const _SC_2_FORT_RUN = 50 const _SC_2_LOCALEDEF = 52 const _SC_2_PBS = 168 const _SC_2_PBS_ACCOUNTING = 169 const _SC_2_PBS_CHECKPOINT = 175 const _SC_2_PBS_LOCATE = 170 const _SC_2_PBS_MESSAGE = 171 const _SC_2_PBS_TRACK = 172 const _SC_2_SW_DEV = 51 const _SC_2_UPE = 97 const _SC_2_VERSION = 46 const _SC_ADVISORY_INFO = 132 const _SC_AIO_LISTIO_MAX = 23 const _SC_AIO_MAX = 24 const _SC_AIO_PRIO_DELTA_MAX = 25 const _SC_ARG_MAX = 0 const _SC_ASYNCHRONOUS_IO = 12 const _SC_ATEXIT_MAX = 87 const _SC_AVPHYS_PAGES = 86 const _SC_BARRIERS = 133 const _SC_BC_BASE_MAX = 36 const _SC_BC_DIM_MAX = 37 const _SC_BC_SCALE_MAX = 38 const _SC_BC_STRING_MAX = 39 const _SC_CHILD_MAX = 1 const _SC_CLK_TCK = 2 const _SC_CLOCK_SELECTION = 137 const _SC_COLL_WEIGHTS_MAX = 40 const _SC_CPUTIME = 138 const _SC_DELAYTIMER_MAX = 26 const _SC_EXPR_NEST_MAX = 42 const _SC_FSYNC = 15 const _SC_GETGR_R_SIZE_MAX = 69 const _SC_GETPW_R_SIZE_MAX = 70 const _SC_HOST_NAME_MAX = 180 const _SC_IOV_MAX = 60 const _SC_IPV6 = 235 const _SC_JOB_CONTROL = 7 const _SC_LINE_MAX = 43 const _SC_LOGIN_NAME_MAX = 71 const _SC_MAPPED_FILES = 16 const _SC_MEMLOCK = 17 const _SC_MEMLOCK_RANGE = 18 const _SC_MEMORY_PROTECTION = 19 const _SC_MESSAGE_PASSING = 20 const _SC_MINSIGSTKSZ = 249 const _SC_MONOTONIC_CLOCK = 149 const _SC_MQ_OPEN_MAX = 27 const _SC_MQ_PRIO_MAX = 28 const _SC_NGROUPS_MAX = 3 const _SC_NPROCESSORS_CONF = 83 const _SC_NPROCESSORS_ONLN = 84 const _SC_NZERO = 109 const _SC_OPEN_MAX = 4 const _SC_PAGESIZE = 30 const _SC_PAGE_SIZE = 30 const _SC_PASS_MAX = 88 const _SC_PHYS_PAGES = 85 const _SC_PRIORITIZED_IO = 13 const _SC_PRIORITY_SCHEDULING = 10 const _SC_RAW_SOCKETS = 236 const _SC_READER_WRITER_LOCKS = 153 const _SC_REALTIME_SIGNALS = 9 const _SC_REGEXP = 155 const _SC_RE_DUP_MAX = 44 const _SC_RTSIG_MAX = 31 const _SC_SAVED_IDS = 8 const _SC_SEMAPHORES = 21 const _SC_SEM_NSEMS_MAX = 32 const _SC_SEM_VALUE_MAX = 33 const _SC_SHARED_MEMORY_OBJECTS = 22 const _SC_SHELL = 157 const _SC_SIGQUEUE_MAX = 34 const _SC_SIGSTKSZ = 250 const _SC_SPAWN = 159 const _SC_SPIN_LOCKS = 154 const _SC_SPORADIC_SERVER = 160 const _SC_SS_REPL_MAX = 241 const _SC_STREAMS = 174 const _SC_STREAM_MAX = 5 const _SC_SYMLOOP_MAX = 173 const _SC_SYNCHRONIZED_IO = 14 const _SC_THREADS = 67 const _SC_THREAD_ATTR_STACKADDR = 77 const _SC_THREAD_ATTR_STACKSIZE = 78 const _SC_THREAD_CPUTIME = 139 const _SC_THREAD_DESTRUCTOR_ITERATIONS = 73 const _SC_THREAD_KEYS_MAX = 74 const _SC_THREAD_PRIORITY_SCHEDULING = 79 const _SC_THREAD_PRIO_INHERIT = 80 const _SC_THREAD_PRIO_PROTECT = 81 const _SC_THREAD_PROCESS_SHARED = 82 const _SC_THREAD_ROBUST_PRIO_INHERIT = 247 const _SC_THREAD_ROBUST_PRIO_PROTECT = 248 const _SC_THREAD_SAFE_FUNCTIONS = 68 const _SC_THREAD_SPORADIC_SERVER = 161 const _SC_THREAD_STACK_MIN = 75 const _SC_THREAD_THREADS_MAX = 76 const _SC_TIMEOUTS = 164 const _SC_TIMERS = 11 const _SC_TIMER_MAX = 35 const _SC_TRACE = 181 const _SC_TRACE_EVENT_FILTER = 182 const _SC_TRACE_EVENT_NAME_MAX = 242 const _SC_TRACE_INHERIT = 183 const _SC_TRACE_LOG = 184 const _SC_TRACE_NAME_MAX = 243 const _SC_TRACE_SYS_MAX = 244 const _SC_TRACE_USER_EVENT_MAX = 245 const _SC_TTY_NAME_MAX = 72 const _SC_TYPED_MEMORY_OBJECTS = 165 const _SC_TZNAME_MAX = 6 const _SC_UIO_MAXIOV = 60 const _SC_V6_ILP32_OFF32 = 176 const _SC_V6_ILP32_OFFBIG = 177 const _SC_V6_LP64_OFF64 = 178 const _SC_V6_LPBIG_OFFBIG = 179 const _SC_V7_ILP32_OFF32 = 237 const _SC_V7_ILP32_OFFBIG = 238 const _SC_V7_LP64_OFF64 = 239 const _SC_V7_LPBIG_OFFBIG = 240 const _SC_VERSION = 29 const _SC_XBS5_ILP32_OFF32 = 125 const _SC_XBS5_ILP32_OFFBIG = 126 const _SC_XBS5_LP64_OFF64 = 127 const _SC_XBS5_LPBIG_OFFBIG = 128 const _SC_XOPEN_CRYPT = 92 const _SC_XOPEN_ENH_I18N = 93 const _SC_XOPEN_LEGACY = 129 const _SC_XOPEN_REALTIME = 130 const _SC_XOPEN_REALTIME_THREADS = 131 const _SC_XOPEN_SHM = 94 const _SC_XOPEN_STREAMS = 246 const _SC_XOPEN_UNIX = 91 const _SC_XOPEN_VERSION = 89 const _SC_XOPEN_XCU_VERSION = 90 const _SC_XOPEN_XPG2 = 98 const _SC_XOPEN_XPG3 = 99 const _SC_XOPEN_XPG4 = 100 const _STDC_PREDEF_H = 1 const _XOPEN_ENH_I18N = 1 const _XOPEN_IOV_MAX = 16 const _XOPEN_NAME_MAX = 255 const _XOPEN_PATH_MAX = 1024 const _XOPEN_UNIX = 1 const _XOPEN_VERSION = 700 const _X_INLINE = 0 const _X_RESTRICT_KYWD = 0 const _Xconst = 0 const __ALTIVEC__ = 1 const __APPLE_ALTIVEC__ = 1 const __ATOMIC_ACQUIRE = 2 const __ATOMIC_ACQ_REL = 4 const __ATOMIC_CONSUME = 1 const __ATOMIC_RELAXED = 0 const __ATOMIC_RELEASE = 3 const __ATOMIC_SEQ_CST = 5 const __BIGGEST_ALIGNMENT__ = 16 const __BIG_ENDIAN = 4321 const __BUILTIN_CPU_SUPPORTS__ = 1 const __BYTE_ORDER = 1234 const __BYTE_ORDER__ = 1234 const __CCGO__ = 1 const __CHAR_BIT__ = 8 const __CHAR_UNSIGNED__ = 1 const __CMODEL_MEDIUM__ = 1 const __CRYPTO__ = 1 const __DBL_DECIMAL_DIG__ = 17 const __DBL_DIG__ = 15 const __DBL_HAS_DENORM__ = 1 const __DBL_HAS_INFINITY__ = 1 const __DBL_HAS_QUIET_NAN__ = 1 const __DBL_MANT_DIG__ = 53 const __DBL_MAX_10_EXP__ = 308 const __DBL_MAX_EXP__ = 1024 const __DBL_MIN_10_EXP__ = -307 const __DBL_MIN_EXP__ = -1021 const __DEC128_EPSILON__ = 0 const __DEC128_MANT_DIG__ = 34 const __DEC128_MAX_EXP__ = 6145 const __DEC128_MAX__ = 0 const __DEC128_MIN_EXP__ = -6142 const __DEC128_MIN__ = 0 const __DEC128_SUBNORMAL_MIN__ = 0 const __DEC32_EPSILON__ = 0 const __DEC32_MANT_DIG__ = 7 const __DEC32_MAX_EXP__ = 97 const __DEC32_MAX__ = 0 const __DEC32_MIN_EXP__ = -94 const __DEC32_MIN__ = 0 const __DEC32_SUBNORMAL_MIN__ = 0 const __DEC64_EPSILON__ = 0 const __DEC64_MANT_DIG__ = 16 const __DEC64_MAX_EXP__ = 385 const __DEC64_MAX__ = 0 const __DEC64_MIN_EXP__ = -382 const __DEC64_MIN__ = 0 const __DEC64_SUBNORMAL_MIN__ = 0 const __DECIMAL_DIG__ = 17 const __DEC_EVAL_METHOD__ = 2 const __ELF__ = 1 const __FINITE_MATH_ONLY__ = 0 const __FLOAT128_TYPE__ = 1 const __FLOAT128__ = 1 const __FLOAT_WORD_ORDER__ = 1234 const __FLT128_DECIMAL_DIG__ = 36 const __FLT128_DENORM_MIN__ = 0 const __FLT128_DIG__ = 33 const __FLT128_EPSILON__ = 0 const __FLT128_HAS_DENORM__ = 1 const __FLT128_HAS_INFINITY__ = 1 const __FLT128_HAS_QUIET_NAN__ = 1 const __FLT128_MANT_DIG__ = 113 const __FLT128_MAX_10_EXP__ = 4932 const __FLT128_MAX_EXP__ = 16384 const __FLT128_MAX__ = 0 const __FLT128_MIN_10_EXP__ = -4931 const __FLT128_MIN_EXP__ = -16381 const __FLT128_MIN__ = 0 const __FLT128_NORM_MAX__ = 0 const __FLT32X_DECIMAL_DIG__ = 17 const __FLT32X_DENORM_MIN__ = 0 const __FLT32X_DIG__ = 15 const __FLT32X_EPSILON__ = 0 const __FLT32X_HAS_DENORM__ = 1 const __FLT32X_HAS_INFINITY__ = 1 const __FLT32X_HAS_QUIET_NAN__ = 1 const __FLT32X_MANT_DIG__ = 53 const __FLT32X_MAX_10_EXP__ = 308 const __FLT32X_MAX_EXP__ = 1024 const __FLT32X_MAX__ = 0 const __FLT32X_MIN_10_EXP__ = -307 const __FLT32X_MIN_EXP__ = -1021 const __FLT32X_MIN__ = 0 const __FLT32X_NORM_MAX__ = 0 const __FLT32_DECIMAL_DIG__ = 9 const __FLT32_DENORM_MIN__ = 0 const __FLT32_DIG__ = 6 const __FLT32_EPSILON__ = 0 const __FLT32_HAS_DENORM__ = 1 const __FLT32_HAS_INFINITY__ = 1 const __FLT32_HAS_QUIET_NAN__ = 1 const __FLT32_MANT_DIG__ = 24 const __FLT32_MAX_10_EXP__ = 38 const __FLT32_MAX_EXP__ = 128 const __FLT32_MAX__ = 0 const __FLT32_MIN_10_EXP__ = -37 const __FLT32_MIN_EXP__ = -125 const __FLT32_MIN__ = 0 const __FLT32_NORM_MAX__ = 0 const __FLT64X_DECIMAL_DIG__ = 36 const __FLT64X_DENORM_MIN__ = 0 const __FLT64X_DIG__ = 33 const __FLT64X_EPSILON__ = 0 const __FLT64X_HAS_DENORM__ = 1 const __FLT64X_HAS_INFINITY__ = 1 const __FLT64X_HAS_QUIET_NAN__ = 1 const __FLT64X_MANT_DIG__ = 113 const __FLT64X_MAX_10_EXP__ = 4932 const __FLT64X_MAX_EXP__ = 16384 const __FLT64X_MAX__ = 0 const __FLT64X_MIN_10_EXP__ = -4931 const __FLT64X_MIN_EXP__ = -16381 const __FLT64X_MIN__ = 0 const __FLT64X_NORM_MAX__ = 0 const __FLT64_DECIMAL_DIG__ = 17 const __FLT64_DENORM_MIN__ = 0 const __FLT64_DIG__ = 15 const __FLT64_EPSILON__ = 0 const __FLT64_HAS_DENORM__ = 1 const __FLT64_HAS_INFINITY__ = 1 const __FLT64_HAS_QUIET_NAN__ = 1 const __FLT64_MANT_DIG__ = 53 const __FLT64_MAX_10_EXP__ = 308 const __FLT64_MAX_EXP__ = 1024 const __FLT64_MAX__ = 0 const __FLT64_MIN_10_EXP__ = -307 const __FLT64_MIN_EXP__ = -1021 const __FLT64_MIN__ = 0 const __FLT64_NORM_MAX__ = 0 const __FLT_DECIMAL_DIG__ = 9 const __FLT_DENORM_MIN__ = 0 const __FLT_DIG__ = 6 const __FLT_EPSILON__ = 0 const __FLT_EVAL_METHOD_TS_18661_3__ = 0 const __FLT_EVAL_METHOD__ = 0 const __FLT_HAS_DENORM__ = 1 const __FLT_HAS_INFINITY__ = 1 const __FLT_HAS_QUIET_NAN__ = 1 const __FLT_MANT_DIG__ = 24 const __FLT_MAX_10_EXP__ = 38 const __FLT_MAX_EXP__ = 128 const __FLT_MAX__ = 0 const __FLT_MIN_10_EXP__ = -37 const __FLT_MIN_EXP__ = -125 const __FLT_MIN__ = 0 const __FLT_NORM_MAX__ = 0 const __FLT_RADIX__ = 2 const __FP_FAST_FMA = 1 const __FP_FAST_FMAF = 1 const __FP_FAST_FMAF32 = 1 const __FP_FAST_FMAF32x = 1 const __FP_FAST_FMAF64 = 1 const __FP_FAST_FMAL = 1 const __FUNCTION__ = 0 const __GCC_ATOMIC_BOOL_LOCK_FREE = 2 const __GCC_ATOMIC_CHAR16_T_LOCK_FREE = 2 const __GCC_ATOMIC_CHAR32_T_LOCK_FREE = 2 const __GCC_ATOMIC_CHAR_LOCK_FREE = 2 const __GCC_ATOMIC_INT_LOCK_FREE = 2 const __GCC_ATOMIC_LLONG_LOCK_FREE = 2 const __GCC_ATOMIC_LONG_LOCK_FREE = 2 const __GCC_ATOMIC_POINTER_LOCK_FREE = 2 const __GCC_ATOMIC_SHORT_LOCK_FREE = 2 const __GCC_ATOMIC_TEST_AND_SET_TRUEVAL = 1 const __GCC_ATOMIC_WCHAR_T_LOCK_FREE = 2 const __GCC_HAVE_DWARF2_CFI_ASM = 1 const __GCC_HAVE_SYNC_COMPARE_AND_SWAP_1 = 1 const __GCC_HAVE_SYNC_COMPARE_AND_SWAP_16 = 1 const __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2 = 1 const __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 = 1 const __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8 = 1 const __GCC_IEC_559 = 2 const __GCC_IEC_559_COMPLEX = 2 const __GNUC_MINOR__ = 2 const __GNUC_PATCHLEVEL__ = 1 const __GNUC_STDC_INLINE__ = 1 const __GNUC__ = 10 const __GXX_ABI_VERSION = 1014 const __HAVE_BSWAP__ = 1 const __HAVE_SPECULATION_SAFE_VALUE = 1 const __HTM__ = 1 const __INT16_MAX__ = 32767 const __INT32_MAX__ = 2147483647 const __INT32_TYPE__ = 0 const __INT64_MAX__ = 9223372036854775807 const __INT8_MAX__ = 127 const __INTMAX_MAX__ = 9223372036854775807 const __INTMAX_WIDTH__ = 64 const __INTPTR_MAX__ = 9223372036854775807 const __INTPTR_WIDTH__ = 64 const __INT_FAST16_MAX__ = 9223372036854775807 const __INT_FAST16_WIDTH__ = 64 const __INT_FAST32_MAX__ = 9223372036854775807 const __INT_FAST32_WIDTH__ = 64 const __INT_FAST64_MAX__ = 9223372036854775807 const __INT_FAST64_WIDTH__ = 64 const __INT_FAST8_MAX__ = 127 const __INT_FAST8_WIDTH__ = 8 const __INT_LEAST16_MAX__ = 32767 const __INT_LEAST16_WIDTH__ = 16 const __INT_LEAST32_MAX__ = 2147483647 const __INT_LEAST32_TYPE__ = 0 const __INT_LEAST32_WIDTH__ = 32 const __INT_LEAST64_MAX__ = 9223372036854775807 const __INT_LEAST64_WIDTH__ = 64 const __INT_LEAST8_MAX__ = 127 const __INT_LEAST8_WIDTH__ = 8 const __INT_MAX__ = 2147483647 const __INT_WIDTH__ = 32 const __LDBL_DECIMAL_DIG__ = 17 const __LDBL_DENORM_MIN__ = 0 const __LDBL_DIG__ = 15 const __LDBL_EPSILON__ = 0 const __LDBL_HAS_DENORM__ = 1 const __LDBL_HAS_INFINITY__ = 1 const __LDBL_HAS_QUIET_NAN__ = 1 const __LDBL_MANT_DIG__ = 53 const __LDBL_MAX_10_EXP__ = 308 const __LDBL_MAX_EXP__ = 1024 const __LDBL_MAX__ = 0 const __LDBL_MIN_10_EXP__ = -307 const __LDBL_MIN_EXP__ = -1021 const __LDBL_MIN__ = 0 const __LDBL_NORM_MAX__ = 0 const __LITTLE_ENDIAN = 1234 const __LITTLE_ENDIAN__ = 1 const __LONG_LONG_MAX__ = 9223372036854775807 const __LONG_LONG_WIDTH__ = 64 const __LONG_MAX = 9223372036854775807 const __LONG_MAX__ = 9223372036854775807 const __LONG_WIDTH__ = 64 const __LP64__ = 1 const __OPTIMIZE__ = 1 const __ORDER_BIG_ENDIAN__ = 4321 const __ORDER_LITTLE_ENDIAN__ = 1234 const __ORDER_PDP_ENDIAN__ = 3412 const __PDP_ENDIAN = 3412 const __PIC__ = 2 const __PIE__ = 2 const __POWER8_VECTOR__ = 1 const __PPC64__ = 1 const __PPC__ = 1 const __PRAGMA_REDEFINE_EXTNAME = 1 const __PRETTY_FUNCTION__ = 0 const __PRI64 = "l" const __PRIPTR = "l" const __PTRDIFF_MAX__ = 9223372036854775807 const __PTRDIFF_WIDTH__ = 64 const __QUAD_MEMORY_ATOMIC__ = 1 const __RECIPF__ = 1 const __RECIP_PRECISION__ = 1 const __RECIP__ = 1 const __RSQRTEF__ = 1 const __RSQRTE__ = 1 const __SCHAR_MAX__ = 127 const __SCHAR_WIDTH__ = 8 const __SHRT_MAX__ = 32767 const __SHRT_WIDTH__ = 16 const __SIG_ATOMIC_MAX__ = 2147483647 const __SIG_ATOMIC_MIN__ = -2147483648 const __SIG_ATOMIC_TYPE__ = 0 const __SIG_ATOMIC_WIDTH__ = 32 const __SIZEOF_DOUBLE__ = 8 const __SIZEOF_FLOAT__ = 4 const __SIZEOF_INT128__ = 16 const __SIZEOF_INT__ = 4 const __SIZEOF_LONG_DOUBLE__ = 8 const __SIZEOF_LONG_LONG__ = 8 const __SIZEOF_LONG__ = 8 const __SIZEOF_POINTER__ = 8 const __SIZEOF_PTRDIFF_T__ = 8 const __SIZEOF_SHORT__ = 2 const __SIZEOF_SIZE_T__ = 8 const __SIZEOF_WCHAR_T__ = 4 const __SIZEOF_WINT_T__ = 4 const __SIZE_MAX__ = 18446744073709551615 const __SIZE_WIDTH__ = 64 const __STDC_HOSTED__ = 1 const __STDC_IEC_559_COMPLEX__ = 1 const __STDC_IEC_559__ = 1 const __STDC_ISO_10646__ = 201706 const __STDC_UTF_16__ = 1 const __STDC_UTF_32__ = 1 const __STDC_VERSION__ = 201710 const __STDC__ = 1 const __STRUCT_PARM_ALIGN__ = 16 const __TM_FENCE__ = 1 const __UINT16_MAX__ = 65535 const __UINT32_MAX__ = 4294967295 const __UINT64_MAX__ = 18446744073709551615 const __UINT8_MAX__ = 255 const __UINTMAX_MAX__ = 18446744073709551615 const __UINTPTR_MAX__ = 18446744073709551615 const __UINT_FAST16_MAX__ = 18446744073709551615 const __UINT_FAST32_MAX__ = 18446744073709551615 const __UINT_FAST64_MAX__ = 18446744073709551615 const __UINT_FAST8_MAX__ = 255 const __UINT_LEAST16_MAX__ = 65535 const __UINT_LEAST32_MAX__ = 4294967295 const __UINT_LEAST64_MAX__ = 18446744073709551615 const __UINT_LEAST8_MAX__ = 255 const __UNIX__ = 1 const __USE_TIME_BITS64 = 1 const __VEC_ELEMENT_REG_ORDER__ = 1234 const __VEC__ = 10206 const __VERSION__ = "10.2.1 20210110" const __VSX__ = 1 const __WCHAR_MAX__ = 2147483647 const __WCHAR_MIN__ = -2147483648 const __WCHAR_TYPE__ = 0 const __WCHAR_WIDTH__ = 32 const __WINT_MAX__ = 4294967295 const __WINT_MIN__ = 0 const __WINT_WIDTH__ = 32 const __builtin_copysignq = 0 const __builtin_fabsq = 0 const __builtin_huge_valq = 0 const __builtin_infq = 0 const __builtin_nanq = 0 const __builtin_nansq = 0 const __builtin_vsx_vperm = 0 const __builtin_vsx_xvmaddadp = 0 const __builtin_vsx_xvmaddasp = 0 const __builtin_vsx_xvmaddmdp = 0 const __builtin_vsx_xvmaddmsp = 0 const __builtin_vsx_xvmsubadp = 0 const __builtin_vsx_xvmsubasp = 0 const __builtin_vsx_xvmsubmdp = 0 const __builtin_vsx_xvmsubmsp = 0 const __builtin_vsx_xvnmaddadp = 0 const __builtin_vsx_xvnmaddasp = 0 const __builtin_vsx_xvnmaddmdp = 0 const __builtin_vsx_xvnmaddmsp = 0 const __builtin_vsx_xvnmsubadp = 0 const __builtin_vsx_xvnmsubasp = 0 const __builtin_vsx_xvnmsubmdp = 0 const __builtin_vsx_xvnmsubmsp = 0 const __builtin_vsx_xxland = 0 const __builtin_vsx_xxlandc = 0 const __builtin_vsx_xxlnor = 0 const __builtin_vsx_xxlor = 0 const __builtin_vsx_xxlxor = 0 const __builtin_vsx_xxsel = 0 const __float128 = 0 const __gnu_linux__ = 1 const __inline = 0 const __linux = 1 const __linux__ = 1 const __pic__ = 2 const __pie__ = 2 const __powerpc64__ = 1 const __powerpc__ = 1 const __restrict = 0 const __restrict_arr = 0 const __tm_gmtoff = 0 const __tm_zone = 0 const __unix = 1 const __unix__ = 1 const alloca = 0 const attemptckalloc = 0 const attemptckrealloc = 0 const blkcnt64_t = 0 const c_class = 0 const ckalloc = 0 const ckfree = 0 const ckrealloc = 0 const creat64 = 0 const errno = 0 const fallocate64 = 0 const fgetpos64 = 0 const flock64 = 0 const fopen64 = 0 const fpos64_t = 0 const freopen64 = 0 const fsblkcnt64_t = 0 const fseeko64 = 0 const fsetpos64 = 0 const fsfilcnt64_t = 0 const fstat64 = 0 const fstatat64 = 0 const ftello64 = 0 const ftruncate64 = 0 const ino64_t = 0 const linux = 1 const lockf64 = 0 const loff_t = 0 const lseek64 = 0 const lstat64 = 0 const math_errhandling = 2 const mkostemp64 = 0 const mkostemps64 = 0 const mkstemp64 = 0 const mkstemps64 = 0 const off64_t = 0 const open64 = 0 const openat64 = 0 const posix_fadvise64 = 0 const posix_fallocate64 = 0 const pread64 = 0 const pwrite64 = 0 const stat64 = 0 const static_assert = 0 const sz_xAllocColorCellsReply = 32 const sz_xAllocColorCellsReq = 12 const sz_xAllocColorPlanesReply = 32 const sz_xAllocColorPlanesReq = 16 const sz_xAllocColorReply = 32 const sz_xAllocColorReq = 16 const sz_xAllocNamedColorReply = 32 const sz_xAllocNamedColorReq = 12 const sz_xAllowEventsReq = 8 const sz_xArc = 12 const sz_xBellReq = 4 const sz_xChangeActivePointerGrabReq = 16 const sz_xChangeGCReq = 12 const sz_xChangeHostsReq = 8 const sz_xChangeKeyboardControlReq = 8 const sz_xChangeKeyboardMappingReq = 8 const sz_xChangeModeReq = 4 const sz_xChangePointerControlReq = 12 const sz_xChangePropertyReq = 24 const sz_xChangeSaveSetReq = 8 const sz_xChangeWindowAttributesReq = 12 const sz_xCharInfo = 12 const sz_xCirculateWindowReq = 8 const sz_xClearAreaReq = 16 const sz_xColorItem = 12 const sz_xConfigureWindowReq = 12 const sz_xConnClientPrefix = 12 const sz_xConnSetup = 32 const sz_xConnSetupPrefix = 8 const sz_xConvertSelectionReq = 24 const sz_xCopyAreaReq = 28 const sz_xCopyColormapAndFreeReq = 12 const sz_xCopyGCReq = 16 const sz_xCopyPlaneReq = 32 const sz_xCreateColormapReq = 16 const sz_xCreateCursorReq = 32 const sz_xCreateGCReq = 16 const sz_xCreateGlyphCursorReq = 32 const sz_xCreatePixmapReq = 16 const sz_xCreateWindowReq = 32 const sz_xDeletePropertyReq = 12 const sz_xDepth = 8 const sz_xError = 32 const sz_xEvent = 32 const sz_xFillPolyReq = 16 const sz_xFontProp = 8 const sz_xForceScreenSaverReq = 4 const sz_xFreeColorsReq = 12 const sz_xGenericReply = 32 const sz_xGetAtomNameReply = 32 const sz_xGetFontPathReply = 32 const sz_xGetGeometryReply = 32 const sz_xGetImageReply = 32 const sz_xGetImageReq = 20 const sz_xGetInputFocusReply = 32 const sz_xGetKeyboardControlReply = 52 const sz_xGetKeyboardMappingReply = 32 const sz_xGetKeyboardMappingReq = 8 const sz_xGetModifierMappingReply = 32 const sz_xGetMotionEventsReply = 32 const sz_xGetMotionEventsReq = 16 const sz_xGetPointerControlReply = 32 const sz_xGetPointerMappingReply = 32 const sz_xGetPropertyReply = 32 const sz_xGetPropertyReq = 24 const sz_xGetScreenSaverReply = 32 const sz_xGetSelectionOwnerReply = 32 const sz_xGetWindowAttributesReply = 44 const sz_xGrabButtonReq = 24 const sz_xGrabKeyReq = 16 const sz_xGrabKeyboardReply = 32 const sz_xGrabKeyboardReq = 16 const sz_xGrabPointerReply = 32 const sz_xGrabPointerReq = 24 const sz_xHostEntry = 4 const sz_xImageText16Req = 16 const sz_xImageText8Req = 16 const sz_xImageTextReq = 16 const sz_xInternAtomReply = 32 const sz_xInternAtomReq = 8 const sz_xKeymapEvent = 32 const sz_xListExtensionsReply = 32 const sz_xListFontsReply = 32 const sz_xListFontsReq = 8 const sz_xListFontsWithInfoReply = 60 const sz_xListFontsWithInfoReq = 8 const sz_xListHostsReply = 32 const sz_xListHostsReq = 4 const sz_xListInstalledColormapsReply = 32 const sz_xListPropertiesReply = 32 const sz_xLookupColorReply = 32 const sz_xLookupColorReq = 12 const sz_xOpenFontReq = 12 const sz_xPixmapFormat = 8 const sz_xPoint = 4 const sz_xPolyArcReq = 12 const sz_xPolyFillArcReq = 12 const sz_xPolyFillRectangleReq = 12 const sz_xPolyLineReq = 12 const sz_xPolyPointReq = 12 const sz_xPolyRectangleReq = 12 const sz_xPolySegmentReq = 12 const sz_xPolyText16Req = 16 const sz_xPolyText8Req = 16 const sz_xPolyTextReq = 16 const sz_xPropIconSize = 24 const sz_xPutImageReq = 24 const sz_xQueryBestSizeReply = 32 const sz_xQueryBestSizeReq = 12 const sz_xQueryColorsReply = 32 const sz_xQueryColorsReq = 8 const sz_xQueryExtensionReply = 32 const sz_xQueryExtensionReq = 8 const sz_xQueryFontReply = 60 const sz_xQueryKeymapReply = 40 const sz_xQueryPointerReply = 32 const sz_xQueryTextExtentsReply = 32 const sz_xQueryTextExtentsReq = 8 const sz_xQueryTreeReply = 32 const sz_xRecolorCursorReq = 20 const sz_xRectangle = 8 const sz_xReparentWindowReq = 16 const sz_xReply = 32 const sz_xReq = 4 const sz_xResourceReq = 8 const sz_xRotatePropertiesReq = 12 const sz_xSegment = 8 const sz_xSendEventReq = 44 const sz_xSetAccessControlReq = 4 const sz_xSetClipRectanglesReq = 12 const sz_xSetCloseDownModeReq = 4 const sz_xSetDashesReq = 12 const sz_xSetFontPathReq = 8 const sz_xSetInputFocusReq = 12 const sz_xSetMappingReply = 32 const sz_xSetModifierMappingReply = 32 const sz_xSetModifierMappingReq = 4 const sz_xSetPointerMappingReply = 32 const sz_xSetPointerMappingReq = 4 const sz_xSetScreenSaverReq = 12 const sz_xSetSelectionOwnerReq = 16 const sz_xStoreColorsReq = 8 const sz_xStoreNamedColorReq = 16 const sz_xTextElt = 2 const sz_xTimecoord = 8 const sz_xTranslateCoordsReply = 32 const sz_xTranslateCoordsReq = 16 const sz_xUngrabButtonReq = 12 const sz_xUngrabKeyReq = 12 const sz_xVisualType = 24 const sz_xWarpPointerReq = 24 const sz_xWindowRoot = 40 const sz_xrgb = 8 const tmpfile64 = 0 const truncate64 = 0 const unix = 1 const xFalse = 0 const xTrue = 1 type T__builtin_va_list = uintptr type T__predefined_size_t = uint64 type T__predefined_wchar_t = int32 type T__predefined_ptrdiff_t = int64 type Tsize_t = uint64 type Tssize_t = int64 type Toff_t = int64 type Tva_list = uintptr type T__isoc_va_list = uintptr type Tfpos_t = struct { F__lldata [0]int64 F__align [0]float64 F__opaque [16]uint8 } type T_G_fpos64_t = Tfpos_t type Tcookie_io_functions_t = struct { Fread uintptr Fwrite uintptr Fseek uintptr Fclose1 uintptr } type T_IO_cookie_io_functions_t = Tcookie_io_functions_t type Twchar_t = int32 type Tmax_align_t = struct { F__ll int64 F__ld float64 } type Tptrdiff_t = int64 type TClientData = uintptr type TTcl_WideInt = int64 type TTcl_WideUInt = uint64 type TTcl_Size = int64 type TTcl_StatBuf = struct { Fst_dev Tdev_t Fst_ino Tino_t Fst_nlink Tnlink_t Fst_mode Tmode_t Fst_uid Tuid_t Fst_gid Tgid_t Fst_rdev Tdev_t Fst_size Toff_t Fst_blksize Tblksize_t Fst_blocks Tblkcnt_t Fst_atim Ttimespec Fst_mtim Ttimespec Fst_ctim Ttimespec F__unused [3]uint64 } type Tstat = TTcl_StatBuf type TTcl_AsyncHandler = uintptr type TTcl_Channel = uintptr type TTcl_ChannelTypeVersion = uintptr type TTcl_Command = uintptr type TTcl_Condition = uintptr type TTcl_Dict = uintptr type TTcl_EncodingState = uintptr type TTcl_Encoding = uintptr type TTcl_Event = struct { Fproc uintptr FnextPtr uintptr } type TTcl_InterpState = uintptr type TTcl_LoadHandle = uintptr type TTcl_Mutex = uintptr type TTcl_Pid = uintptr type TTcl_RegExp = uintptr type TTcl_ThreadDataKey = uintptr type TTcl_ThreadId = uintptr type TTcl_TimerToken = uintptr type TTcl_Trace = uintptr type TTcl_Var = uintptr type TTcl_ZlibStream = uintptr type TTcl_RegExpIndices = struct { Fstart TTcl_Size Fend TTcl_Size } type TTcl_RegExpInfo = struct { Fnsubs TTcl_Size Fmatches uintptr FextendStart TTcl_Size } type TTcl_Stat_ = uintptr type TTcl_OldStat_ = uintptr type TTcl_Obj1 = struct { FrefCount TTcl_Size Fbytes uintptr Flength TTcl_Size FtypePtr uintptr FinternalRep TTcl_ObjInternalRep } type TTcl_ObjType = struct { Fname uintptr FfreeIntRepProc uintptr FdupIntRepProc uintptr FupdateStringProc uintptr FsetFromAnyProc uintptr Fversion Tsize_t FlengthProc uintptr FindexProc uintptr FsliceProc uintptr FreverseProc uintptr FgetElementsProc uintptr FsetElementProc uintptr FreplaceProc uintptr FinOperProc uintptr } type TTcl_ObjInternalRep = struct { FdoubleValue [0]float64 FotherValuePtr [0]uintptr FwideValue [0]TTcl_WideInt FtwoPtrValue [0]struct { Fptr1 uintptr Fptr2 uintptr } FptrAndLongRep [0]struct { Fptr uintptr Fvalue uint64 } FptrAndSize [0]struct { Fptr uintptr Fsize TTcl_Size } FlongValue int64 F__ccgo_pad7 [8]byte } type TTcl_Obj = struct { FrefCount TTcl_Size Fbytes uintptr Flength TTcl_Size FtypePtr uintptr FinternalRep TTcl_ObjInternalRep } type TTcl_Namespace = struct { Fname uintptr FfullName uintptr FclientData uintptr FdeleteProc uintptr FparentPtr uintptr } type TTcl_CallFrame = struct { FnsPtr uintptr Fdummy1 int32 Fdummy2 TTcl_Size Fdummy3 uintptr Fdummy4 uintptr Fdummy5 uintptr Fdummy6 TTcl_Size Fdummy7 uintptr Fdummy8 uintptr Fdummy9 TTcl_Size Fdummy10 uintptr Fdummy11 uintptr Fdummy12 uintptr Fdummy13 uintptr } type TTcl_CmdInfo = struct { FisNativeObjectProc int32 FobjProc uintptr FobjClientData uintptr Fproc uintptr FclientData uintptr FdeleteProc uintptr FdeleteData uintptr FnamespacePtr uintptr FobjProc2 uintptr FobjClientData2 uintptr } type TTcl_DString = struct { Fstring1 uintptr Flength TTcl_Size FspaceAvl TTcl_Size FstaticSpace [200]uint8 } type TTcl_HashKeyType = struct { Fversion int32 Fflags int32 FhashKeyProc uintptr FcompareKeysProc uintptr FallocEntryProc uintptr FfreeEntryProc uintptr } type TTcl_HashTable = struct { Fbuckets uintptr FstaticBuckets [4]uintptr FnumBuckets TTcl_Size FnumEntries TTcl_Size FrebuildSize TTcl_Size Fmask Tsize_t FdownShift int32 FkeyType int32 FfindProc uintptr FcreateProc uintptr FtypePtr uintptr } type TTcl_HashEntry = struct { FnextPtr uintptr FtablePtr uintptr Fhash Tsize_t FclientData uintptr Fkey struct { FobjPtr [0]uintptr Fwords [0][1]int32 Fstring1 [0][1]uint8 FoneWordValue uintptr } } type TTcl_HashEntry1 = struct { FnextPtr uintptr FtablePtr uintptr Fhash Tsize_t FclientData uintptr Fkey struct { FobjPtr [0]uintptr Fwords [0][1]int32 Fstring1 [0][1]uint8 FoneWordValue uintptr } } type TTcl_HashKeyType1 = struct { Fversion int32 Fflags int32 FhashKeyProc uintptr FcompareKeysProc uintptr FallocEntryProc uintptr FfreeEntryProc uintptr } type TTcl_HashTable1 = struct { Fbuckets uintptr FstaticBuckets [4]uintptr FnumBuckets TTcl_Size FnumEntries TTcl_Size FrebuildSize TTcl_Size Fmask Tsize_t FdownShift int32 FkeyType int32 FfindProc uintptr FcreateProc uintptr FtypePtr uintptr } type TTcl_HashSearch = struct { FtablePtr uintptr FnextIndex TTcl_Size FnextEntryPtr uintptr } type TTcl_DictSearch = struct { Fnext uintptr Fepoch Tsize_t FdictionaryPtr TTcl_Dict } type TTcl_Event1 = struct { Fproc uintptr FnextPtr uintptr } type TTcl_QueuePosition = int32 const TCL_QUEUE_TAIL = 0 const TCL_QUEUE_HEAD = 1 const TCL_QUEUE_MARK = 2 const TCL_QUEUE_ALERT_IF_EMPTY = 4 type TTcl_Time = struct { Fsec int64 Fusec int64 } type TTcl_DriverCloseProc = struct{} type TTcl_DriverSeekProc = struct{} type TTcl_ChannelType = struct { FtypeName uintptr Fversion TTcl_ChannelTypeVersion FcloseProc uintptr FinputProc uintptr FoutputProc uintptr FseekProc uintptr FsetOptionProc uintptr FgetOptionProc uintptr FwatchProc uintptr FgetHandleProc uintptr Fclose2Proc uintptr FblockModeProc uintptr FflushProc uintptr FhandlerProc uintptr FwideSeekProc uintptr FthreadActionProc uintptr FtruncateProc uintptr } type TTcl_PathType = int32 type Tcl_PathType = int32 const TCL_PATH_ABSOLUTE = 0 const TCL_PATH_RELATIVE = 1 const TCL_PATH_VOLUME_RELATIVE = 2 type TTcl_GlobTypeData = struct { Ftype1 int32 Fperm int32 FmacType uintptr FmacCreator uintptr } type TTcl_FSVersion = uintptr type TTcl_Filesystem = struct { FtypeName uintptr FstructureLength TTcl_Size Fversion TTcl_FSVersion FpathInFilesystemProc uintptr FdupInternalRepProc uintptr FfreeInternalRepProc uintptr FinternalToNormalizedProc uintptr FcreateInternalRepProc uintptr FnormalizePathProc uintptr FfilesystemPathTypeProc uintptr FfilesystemSeparatorProc uintptr FstatProc uintptr FaccessProc uintptr FopenFileChannelProc uintptr FmatchInDirectoryProc uintptr FutimeProc uintptr FlinkProc uintptr FlistVolumesProc uintptr FfileAttrStringsProc uintptr FfileAttrsGetProc uintptr FfileAttrsSetProc uintptr FcreateDirectoryProc uintptr FremoveDirectoryProc uintptr FdeleteFileProc uintptr FcopyFileProc uintptr FrenameFileProc uintptr FcopyDirectoryProc uintptr FlstatProc uintptr FloadFileProc uintptr FgetCwdProc uintptr FchdirProc uintptr } type TTcl_NotifierProcs = struct { FsetTimerProc uintptr FwaitForEventProc uintptr FcreateFileHandlerProc uintptr FdeleteFileHandlerProc uintptr FinitNotifierProc uintptr FfinalizeNotifierProc uintptr FalertNotifierProc uintptr FserviceModeHookProc uintptr } type TTcl_Token = struct { Ftype1 int32 Fstart uintptr Fsize TTcl_Size FnumComponents TTcl_Size } type TTcl_Parse = struct { FcommentStart uintptr FcommentSize TTcl_Size FcommandStart uintptr FcommandSize TTcl_Size FnumWords TTcl_Size FtokenPtr uintptr FnumTokens TTcl_Size FtokensAvailable TTcl_Size FerrorType int32 Fincomplete int32 Fstring1 uintptr Fend uintptr Finterp uintptr Fterm uintptr FstaticTokens [20]TTcl_Token } type TTcl_EncodingType = struct { FencodingName uintptr FtoUtfProc uintptr FfromUtfProc uintptr FfreeProc uintptr FclientData uintptr FnullSize TTcl_Size } type TTcl_UniChar = int32 type TTcl_Config = struct { Fkey uintptr Fvalue uintptr } type TTcl_ArgvInfo = struct { Ftype1 int32 FkeyStr uintptr FsrcPtr uintptr FdstPtr uintptr FhelpStr uintptr FclientData uintptr } type TTclStubHooks = struct { FtclPlatStubs uintptr FtclIntStubs uintptr FtclIntPlatStubs uintptr } type TTclStubs = struct { Fmagic int32 Fhooks uintptr Ftcl_PkgProvideEx uintptr Ftcl_PkgRequireEx uintptr Ftcl_Panic uintptr Ftcl_Alloc uintptr Ftcl_Free uintptr Ftcl_Realloc uintptr Ftcl_DbCkalloc uintptr Ftcl_DbCkfree uintptr Ftcl_DbCkrealloc uintptr Ftcl_CreateFileHandler uintptr Ftcl_DeleteFileHandler uintptr Ftcl_SetTimer uintptr Ftcl_Sleep uintptr Ftcl_WaitForEvent uintptr Ftcl_AppendAllObjTypes uintptr Ftcl_AppendStringsToObj uintptr Ftcl_AppendToObj uintptr Ftcl_ConcatObj uintptr Ftcl_ConvertToType uintptr Ftcl_DbDecrRefCount uintptr Ftcl_DbIncrRefCount uintptr Ftcl_DbIsShared uintptr Freserved22 uintptr Ftcl_DbNewByteArrayObj uintptr Ftcl_DbNewDoubleObj uintptr Ftcl_DbNewListObj uintptr Freserved26 uintptr Ftcl_DbNewObj uintptr Ftcl_DbNewStringObj uintptr Ftcl_DuplicateObj uintptr FtclFreeObj uintptr Ftcl_GetBoolean uintptr Ftcl_GetBooleanFromObj uintptr Ftcl_GetByteArrayFromObj uintptr Ftcl_GetDouble uintptr Ftcl_GetDoubleFromObj uintptr Freserved36 uintptr Ftcl_GetInt uintptr Ftcl_GetIntFromObj uintptr Ftcl_GetLongFromObj uintptr Ftcl_GetObjType uintptr FtclGetStringFromObj uintptr Ftcl_InvalidateStringRep uintptr Ftcl_ListObjAppendList uintptr Ftcl_ListObjAppendElement uintptr FtclListObjGetElements uintptr Ftcl_ListObjIndex uintptr FtclListObjLength uintptr Ftcl_ListObjReplace uintptr Freserved49 uintptr Ftcl_NewByteArrayObj uintptr Ftcl_NewDoubleObj uintptr Freserved52 uintptr Ftcl_NewListObj uintptr Freserved54 uintptr Ftcl_NewObj uintptr Ftcl_NewStringObj uintptr Freserved57 uintptr Ftcl_SetByteArrayLength uintptr Ftcl_SetByteArrayObj uintptr Ftcl_SetDoubleObj uintptr Freserved61 uintptr Ftcl_SetListObj uintptr Freserved63 uintptr Ftcl_SetObjLength uintptr Ftcl_SetStringObj uintptr Freserved66 uintptr Freserved67 uintptr Ftcl_AllowExceptions uintptr Ftcl_AppendElement uintptr Ftcl_AppendResult uintptr Ftcl_AsyncCreate uintptr Ftcl_AsyncDelete uintptr Ftcl_AsyncInvoke uintptr Ftcl_AsyncMark uintptr Ftcl_AsyncReady uintptr Freserved76 uintptr Freserved77 uintptr Ftcl_BadChannelOption uintptr Ftcl_CallWhenDeleted uintptr Ftcl_CancelIdleCall uintptr Ftcl_Close uintptr Ftcl_CommandComplete uintptr Ftcl_Concat uintptr Ftcl_ConvertElement uintptr Ftcl_ConvertCountedElement uintptr Ftcl_CreateAlias uintptr Ftcl_CreateAliasObj uintptr Ftcl_CreateChannel uintptr Ftcl_CreateChannelHandler uintptr Ftcl_CreateCloseHandler uintptr Ftcl_CreateCommand uintptr Ftcl_CreateEventSource uintptr Ftcl_CreateExitHandler uintptr Ftcl_CreateInterp uintptr Freserved95 uintptr Ftcl_CreateObjCommand uintptr Ftcl_CreateChild uintptr Ftcl_CreateTimerHandler uintptr Ftcl_CreateTrace uintptr Ftcl_DeleteAssocData uintptr Ftcl_DeleteChannelHandler uintptr Ftcl_DeleteCloseHandler uintptr Ftcl_DeleteCommand uintptr Ftcl_DeleteCommandFromToken uintptr Ftcl_DeleteEvents uintptr Ftcl_DeleteEventSource uintptr Ftcl_DeleteExitHandler uintptr Ftcl_DeleteHashEntry uintptr Ftcl_DeleteHashTable uintptr Ftcl_DeleteInterp uintptr Ftcl_DetachPids uintptr Ftcl_DeleteTimerHandler uintptr Ftcl_DeleteTrace uintptr Ftcl_DontCallWhenDeleted uintptr Ftcl_DoOneEvent uintptr Ftcl_DoWhenIdle uintptr Ftcl_DStringAppend uintptr Ftcl_DStringAppendElement uintptr Ftcl_DStringEndSublist uintptr Ftcl_DStringFree uintptr Ftcl_DStringGetResult uintptr Ftcl_DStringInit uintptr Ftcl_DStringResult uintptr Ftcl_DStringSetLength uintptr Ftcl_DStringStartSublist uintptr Ftcl_Eof uintptr Ftcl_ErrnoId uintptr Ftcl_ErrnoMsg uintptr Freserved129 uintptr Ftcl_EvalFile uintptr Freserved131 uintptr Ftcl_EventuallyFree uintptr Ftcl_Exit uintptr Ftcl_ExposeCommand uintptr Ftcl_ExprBoolean uintptr Ftcl_ExprBooleanObj uintptr Ftcl_ExprDouble uintptr Ftcl_ExprDoubleObj uintptr Ftcl_ExprLong uintptr Ftcl_ExprLongObj uintptr Ftcl_ExprObj uintptr Ftcl_ExprString uintptr Ftcl_Finalize uintptr Freserved144 uintptr Ftcl_FirstHashEntry uintptr Ftcl_Flush uintptr Freserved147 uintptr Freserved148 uintptr FtclGetAliasObj uintptr Ftcl_GetAssocData uintptr Ftcl_GetChannel uintptr Ftcl_GetChannelBufferSize uintptr Ftcl_GetChannelHandle uintptr Ftcl_GetChannelInstanceData uintptr Ftcl_GetChannelMode uintptr Ftcl_GetChannelName uintptr Ftcl_GetChannelOption uintptr Ftcl_GetChannelType uintptr Ftcl_GetCommandInfo uintptr Ftcl_GetCommandName uintptr Ftcl_GetErrno uintptr Ftcl_GetHostName uintptr Ftcl_GetInterpPath uintptr Ftcl_GetParent uintptr Ftcl_GetNameOfExecutable uintptr Ftcl_GetObjResult uintptr Ftcl_GetOpenFile uintptr Ftcl_GetPathType uintptr Ftcl_Gets uintptr Ftcl_GetsObj uintptr Ftcl_GetServiceMode uintptr Ftcl_GetChild uintptr Ftcl_GetStdChannel uintptr Freserved174 uintptr Freserved175 uintptr Ftcl_GetVar2 uintptr Freserved177 uintptr Freserved178 uintptr Ftcl_HideCommand uintptr Ftcl_Init uintptr Ftcl_InitHashTable uintptr Ftcl_InputBlocked uintptr Ftcl_InputBuffered uintptr Ftcl_InterpDeleted uintptr Ftcl_IsSafe uintptr Ftcl_JoinPath uintptr Ftcl_LinkVar uintptr Freserved188 uintptr Ftcl_MakeFileChannel uintptr Freserved190 uintptr Ftcl_MakeTcpClientChannel uintptr Ftcl_Merge uintptr Ftcl_NextHashEntry uintptr Ftcl_NotifyChannel uintptr Ftcl_ObjGetVar2 uintptr Ftcl_ObjSetVar2 uintptr Ftcl_OpenCommandChannel uintptr Ftcl_OpenFileChannel uintptr Ftcl_OpenTcpClient uintptr Ftcl_OpenTcpServer uintptr Ftcl_Preserve uintptr Ftcl_PrintDouble uintptr Ftcl_PutEnv uintptr Ftcl_PosixError uintptr Ftcl_QueueEvent uintptr Ftcl_Read uintptr Ftcl_ReapDetachedProcs uintptr Ftcl_RecordAndEval uintptr Ftcl_RecordAndEvalObj uintptr Ftcl_RegisterChannel uintptr Ftcl_RegisterObjType uintptr Ftcl_RegExpCompile uintptr Ftcl_RegExpExec uintptr Ftcl_RegExpMatch uintptr Ftcl_RegExpRange uintptr Ftcl_Release uintptr Ftcl_ResetResult uintptr Ftcl_ScanElement uintptr Ftcl_ScanCountedElement uintptr Freserved220 uintptr Ftcl_ServiceAll uintptr Ftcl_ServiceEvent uintptr Ftcl_SetAssocData uintptr Ftcl_SetChannelBufferSize uintptr Ftcl_SetChannelOption uintptr Ftcl_SetCommandInfo uintptr Ftcl_SetErrno uintptr Ftcl_SetErrorCode uintptr Ftcl_SetMaxBlockTime uintptr Freserved230 uintptr Ftcl_SetRecursionLimit uintptr Freserved232 uintptr Ftcl_SetServiceMode uintptr Ftcl_SetObjErrorCode uintptr Ftcl_SetObjResult uintptr Ftcl_SetStdChannel uintptr Freserved237 uintptr Ftcl_SetVar2 uintptr Ftcl_SignalId uintptr Ftcl_SignalMsg uintptr Ftcl_SourceRCFile uintptr FtclSplitList uintptr FtclSplitPath uintptr Freserved244 uintptr Freserved245 uintptr Freserved246 uintptr Freserved247 uintptr Ftcl_TraceVar2 uintptr Ftcl_TranslateFileName uintptr Ftcl_Ungets uintptr Ftcl_UnlinkVar uintptr Ftcl_UnregisterChannel uintptr Freserved253 uintptr Ftcl_UnsetVar2 uintptr Freserved255 uintptr Ftcl_UntraceVar2 uintptr Ftcl_UpdateLinkedVar uintptr Freserved258 uintptr Ftcl_UpVar2 uintptr Ftcl_VarEval uintptr Freserved261 uintptr Ftcl_VarTraceInfo2 uintptr Ftcl_Write uintptr Ftcl_WrongNumArgs uintptr Ftcl_DumpActiveMemory uintptr Ftcl_ValidateAllMemory uintptr Freserved267 uintptr Freserved268 uintptr Ftcl_HashStats uintptr Ftcl_ParseVar uintptr Freserved271 uintptr Ftcl_PkgPresentEx uintptr Freserved273 uintptr Freserved274 uintptr Freserved275 uintptr Freserved276 uintptr Ftcl_WaitPid uintptr Freserved278 uintptr Ftcl_GetVersion uintptr Ftcl_InitMemory uintptr Ftcl_StackChannel uintptr Ftcl_UnstackChannel uintptr Ftcl_GetStackedChannel uintptr Ftcl_SetMainLoop uintptr Ftcl_GetAliasObj uintptr Ftcl_AppendObjToObj uintptr Ftcl_CreateEncoding uintptr Ftcl_CreateThreadExitHandler uintptr Ftcl_DeleteThreadExitHandler uintptr Freserved290 uintptr Ftcl_EvalEx uintptr Ftcl_EvalObjv uintptr Ftcl_EvalObjEx uintptr Ftcl_ExitThread uintptr Ftcl_ExternalToUtf uintptr Ftcl_ExternalToUtfDString uintptr Ftcl_FinalizeThread uintptr Ftcl_FinalizeNotifier uintptr Ftcl_FreeEncoding uintptr Ftcl_GetCurrentThread uintptr Ftcl_GetEncoding uintptr Ftcl_GetEncodingName uintptr Ftcl_GetEncodingNames uintptr Ftcl_GetIndexFromObjStruct uintptr Ftcl_GetThreadData uintptr Ftcl_GetVar2Ex uintptr Ftcl_InitNotifier uintptr Ftcl_MutexLock uintptr Ftcl_MutexUnlock uintptr Ftcl_ConditionNotify uintptr Ftcl_ConditionWait uintptr FtclNumUtfChars uintptr Ftcl_ReadChars uintptr Freserved314 uintptr Freserved315 uintptr Ftcl_SetSystemEncoding uintptr Ftcl_SetVar2Ex uintptr Ftcl_ThreadAlert uintptr Ftcl_ThreadQueueEvent uintptr Ftcl_UniCharAtIndex uintptr Ftcl_UniCharToLower uintptr Ftcl_UniCharToTitle uintptr Ftcl_UniCharToUpper uintptr Ftcl_UniCharToUtf uintptr FtclUtfAtIndex uintptr FtclUtfCharComplete uintptr Ftcl_UtfBackslash uintptr Ftcl_UtfFindFirst uintptr Ftcl_UtfFindLast uintptr FtclUtfNext uintptr FtclUtfPrev uintptr Ftcl_UtfToExternal uintptr Ftcl_UtfToExternalDString uintptr Ftcl_UtfToLower uintptr Ftcl_UtfToTitle uintptr Ftcl_UtfToChar16 uintptr Ftcl_UtfToUpper uintptr Ftcl_WriteChars uintptr Ftcl_WriteObj uintptr Ftcl_GetString uintptr Freserved341 uintptr Freserved342 uintptr Ftcl_AlertNotifier uintptr Ftcl_ServiceModeHook uintptr Ftcl_UniCharIsAlnum uintptr Ftcl_UniCharIsAlpha uintptr Ftcl_UniCharIsDigit uintptr Ftcl_UniCharIsLower uintptr Ftcl_UniCharIsSpace uintptr Ftcl_UniCharIsUpper uintptr Ftcl_UniCharIsWordChar uintptr Ftcl_Char16Len uintptr Freserved353 uintptr Ftcl_Char16ToUtfDString uintptr Ftcl_UtfToChar16DString uintptr Ftcl_GetRegExpFromObj uintptr Freserved357 uintptr Ftcl_FreeParse uintptr Ftcl_LogCommandInfo uintptr Ftcl_ParseBraces uintptr Ftcl_ParseCommand uintptr Ftcl_ParseExpr uintptr Ftcl_ParseQuotedString uintptr Ftcl_ParseVarName uintptr Ftcl_GetCwd uintptr Ftcl_Chdir uintptr Ftcl_Access uintptr Ftcl_Stat uintptr FtclUtfNcmp uintptr FtclUtfNcasecmp uintptr Ftcl_StringCaseMatch uintptr Ftcl_UniCharIsControl uintptr Ftcl_UniCharIsGraph uintptr Ftcl_UniCharIsPrint uintptr Ftcl_UniCharIsPunct uintptr Ftcl_RegExpExecObj uintptr Ftcl_RegExpGetInfo uintptr Ftcl_NewUnicodeObj uintptr Ftcl_SetUnicodeObj uintptr FtclGetCharLength uintptr FtclGetUniChar uintptr Freserved382 uintptr FtclGetRange uintptr Ftcl_AppendUnicodeToObj uintptr Ftcl_RegExpMatchObj uintptr Ftcl_SetNotifier uintptr Ftcl_GetAllocMutex uintptr Ftcl_GetChannelNames uintptr Ftcl_GetChannelNamesEx uintptr Ftcl_ProcObjCmd uintptr Ftcl_ConditionFinalize uintptr Ftcl_MutexFinalize uintptr Ftcl_CreateThread uintptr Ftcl_ReadRaw uintptr Ftcl_WriteRaw uintptr Ftcl_GetTopChannel uintptr Ftcl_ChannelBuffered uintptr Ftcl_ChannelName uintptr Ftcl_ChannelVersion uintptr Ftcl_ChannelBlockModeProc uintptr Freserved401 uintptr Ftcl_ChannelClose2Proc uintptr Ftcl_ChannelInputProc uintptr Ftcl_ChannelOutputProc uintptr Freserved405 uintptr Ftcl_ChannelSetOptionProc uintptr Ftcl_ChannelGetOptionProc uintptr Ftcl_ChannelWatchProc uintptr Ftcl_ChannelGetHandleProc uintptr Ftcl_ChannelFlushProc uintptr Ftcl_ChannelHandlerProc uintptr Ftcl_JoinThread uintptr Ftcl_IsChannelShared uintptr Ftcl_IsChannelRegistered uintptr Ftcl_CutChannel uintptr Ftcl_SpliceChannel uintptr Ftcl_ClearChannelHandlers uintptr Ftcl_IsChannelExisting uintptr Freserved419 uintptr Freserved420 uintptr Freserved421 uintptr Freserved422 uintptr Ftcl_InitCustomHashTable uintptr Ftcl_InitObjHashTable uintptr Ftcl_CommandTraceInfo uintptr Ftcl_TraceCommand uintptr Ftcl_UntraceCommand uintptr Ftcl_AttemptAlloc uintptr Ftcl_AttemptDbCkalloc uintptr Ftcl_AttemptRealloc uintptr Ftcl_AttemptDbCkrealloc uintptr Ftcl_AttemptSetObjLength uintptr Ftcl_GetChannelThread uintptr FtclGetUnicodeFromObj uintptr Freserved435 uintptr Freserved436 uintptr Ftcl_SubstObj uintptr Ftcl_DetachChannel uintptr Ftcl_IsStandardChannel uintptr Ftcl_FSCopyFile uintptr Ftcl_FSCopyDirectory uintptr Ftcl_FSCreateDirectory uintptr Ftcl_FSDeleteFile uintptr Ftcl_FSLoadFile uintptr Ftcl_FSMatchInDirectory uintptr Ftcl_FSLink uintptr Ftcl_FSRemoveDirectory uintptr Ftcl_FSRenameFile uintptr Ftcl_FSLstat uintptr Ftcl_FSUtime uintptr Ftcl_FSFileAttrsGet uintptr Ftcl_FSFileAttrsSet uintptr Ftcl_FSFileAttrStrings uintptr Ftcl_FSStat uintptr Ftcl_FSAccess uintptr Ftcl_FSOpenFileChannel uintptr Ftcl_FSGetCwd uintptr Ftcl_FSChdir uintptr Ftcl_FSConvertToPathType uintptr Ftcl_FSJoinPath uintptr FtclFSSplitPath uintptr Ftcl_FSEqualPaths uintptr Ftcl_FSGetNormalizedPath uintptr Ftcl_FSJoinToPath uintptr Ftcl_FSGetInternalRep uintptr Ftcl_FSGetTranslatedPath uintptr Ftcl_FSEvalFile uintptr Ftcl_FSNewNativePath uintptr Ftcl_FSGetNativePath uintptr Ftcl_FSFileSystemInfo uintptr Ftcl_FSPathSeparator uintptr Ftcl_FSListVolumes uintptr Ftcl_FSRegister uintptr Ftcl_FSUnregister uintptr Ftcl_FSData uintptr Ftcl_FSGetTranslatedStringPath uintptr Ftcl_FSGetFileSystemForPath uintptr Ftcl_FSGetPathType uintptr Ftcl_OutputBuffered uintptr Ftcl_FSMountsChanged uintptr Ftcl_EvalTokensStandard uintptr Ftcl_GetTime uintptr Ftcl_CreateObjTrace uintptr Ftcl_GetCommandInfoFromToken uintptr Ftcl_SetCommandInfoFromToken uintptr Ftcl_DbNewWideIntObj uintptr Ftcl_GetWideIntFromObj uintptr Ftcl_NewWideIntObj uintptr Ftcl_SetWideIntObj uintptr Ftcl_AllocStatBuf uintptr Ftcl_Seek uintptr Ftcl_Tell uintptr Ftcl_ChannelWideSeekProc uintptr Ftcl_DictObjPut uintptr Ftcl_DictObjGet uintptr Ftcl_DictObjRemove uintptr FtclDictObjSize uintptr Ftcl_DictObjFirst uintptr Ftcl_DictObjNext uintptr Ftcl_DictObjDone uintptr Ftcl_DictObjPutKeyList uintptr Ftcl_DictObjRemoveKeyList uintptr Ftcl_NewDictObj uintptr Ftcl_DbNewDictObj uintptr Ftcl_RegisterConfig uintptr Ftcl_CreateNamespace uintptr Ftcl_DeleteNamespace uintptr Ftcl_AppendExportList uintptr Ftcl_Export uintptr Ftcl_Import uintptr Ftcl_ForgetImport uintptr Ftcl_GetCurrentNamespace uintptr Ftcl_GetGlobalNamespace uintptr Ftcl_FindNamespace uintptr Ftcl_FindCommand uintptr Ftcl_GetCommandFromObj uintptr Ftcl_GetCommandFullName uintptr Ftcl_FSEvalFileEx uintptr Freserved519 uintptr Ftcl_LimitAddHandler uintptr Ftcl_LimitRemoveHandler uintptr Ftcl_LimitReady uintptr Ftcl_LimitCheck uintptr Ftcl_LimitExceeded uintptr Ftcl_LimitSetCommands uintptr Ftcl_LimitSetTime uintptr Ftcl_LimitSetGranularity uintptr Ftcl_LimitTypeEnabled uintptr Ftcl_LimitTypeExceeded uintptr Ftcl_LimitTypeSet uintptr Ftcl_LimitTypeReset uintptr Ftcl_LimitGetCommands uintptr Ftcl_LimitGetTime uintptr Ftcl_LimitGetGranularity uintptr Ftcl_SaveInterpState uintptr Ftcl_RestoreInterpState uintptr Ftcl_DiscardInterpState uintptr Ftcl_SetReturnOptions uintptr Ftcl_GetReturnOptions uintptr Ftcl_IsEnsemble uintptr Ftcl_CreateEnsemble uintptr Ftcl_FindEnsemble uintptr Ftcl_SetEnsembleSubcommandList uintptr Ftcl_SetEnsembleMappingDict uintptr Ftcl_SetEnsembleUnknownHandler uintptr Ftcl_SetEnsembleFlags uintptr Ftcl_GetEnsembleSubcommandList uintptr Ftcl_GetEnsembleMappingDict uintptr Ftcl_GetEnsembleUnknownHandler uintptr Ftcl_GetEnsembleFlags uintptr Ftcl_GetEnsembleNamespace uintptr Ftcl_SetTimeProc uintptr Ftcl_QueryTimeProc uintptr Ftcl_ChannelThreadActionProc uintptr Ftcl_NewBignumObj uintptr Ftcl_DbNewBignumObj uintptr Ftcl_SetBignumObj uintptr Ftcl_GetBignumFromObj uintptr Ftcl_TakeBignumFromObj uintptr Ftcl_TruncateChannel uintptr Ftcl_ChannelTruncateProc uintptr Ftcl_SetChannelErrorInterp uintptr Ftcl_GetChannelErrorInterp uintptr Ftcl_SetChannelError uintptr Ftcl_GetChannelError uintptr Ftcl_InitBignumFromDouble uintptr Ftcl_GetNamespaceUnknownHandler uintptr Ftcl_SetNamespaceUnknownHandler uintptr Ftcl_GetEncodingFromObj uintptr Ftcl_GetEncodingSearchPath uintptr Ftcl_SetEncodingSearchPath uintptr Ftcl_GetEncodingNameFromEnvironment uintptr Ftcl_PkgRequireProc uintptr Ftcl_AppendObjToErrorInfo uintptr Ftcl_AppendLimitedToObj uintptr Ftcl_Format uintptr Ftcl_AppendFormatToObj uintptr Ftcl_ObjPrintf uintptr Ftcl_AppendPrintfToObj uintptr Ftcl_CancelEval uintptr Ftcl_Canceled uintptr Ftcl_CreatePipe uintptr Ftcl_NRCreateCommand uintptr Ftcl_NREvalObj uintptr Ftcl_NREvalObjv uintptr Ftcl_NRCmdSwap uintptr Ftcl_NRAddCallback uintptr Ftcl_NRCallObjProc uintptr Ftcl_GetFSDeviceFromStat uintptr Ftcl_GetFSInodeFromStat uintptr Ftcl_GetModeFromStat uintptr Ftcl_GetLinkCountFromStat uintptr Ftcl_GetUserIdFromStat uintptr Ftcl_GetGroupIdFromStat uintptr Ftcl_GetDeviceTypeFromStat uintptr Ftcl_GetAccessTimeFromStat uintptr Ftcl_GetModificationTimeFromStat uintptr Ftcl_GetChangeTimeFromStat uintptr Ftcl_GetSizeFromStat uintptr Ftcl_GetBlocksFromStat uintptr Ftcl_GetBlockSizeFromStat uintptr Ftcl_SetEnsembleParameterList uintptr Ftcl_GetEnsembleParameterList uintptr FtclParseArgsObjv uintptr Ftcl_GetErrorLine uintptr Ftcl_SetErrorLine uintptr Ftcl_TransferResult uintptr Ftcl_InterpActive uintptr Ftcl_BackgroundException uintptr Ftcl_ZlibDeflate uintptr Ftcl_ZlibInflate uintptr Ftcl_ZlibCRC32 uintptr Ftcl_ZlibAdler32 uintptr Ftcl_ZlibStreamInit uintptr Ftcl_ZlibStreamGetCommandName uintptr Ftcl_ZlibStreamEof uintptr Ftcl_ZlibStreamChecksum uintptr Ftcl_ZlibStreamPut uintptr Ftcl_ZlibStreamGet uintptr Ftcl_ZlibStreamClose uintptr Ftcl_ZlibStreamReset uintptr Ftcl_SetStartupScript uintptr Ftcl_GetStartupScript uintptr Ftcl_CloseEx uintptr Ftcl_NRExprObj uintptr Ftcl_NRSubstObj uintptr Ftcl_LoadFile uintptr Ftcl_FindSymbol uintptr Ftcl_FSUnloadFile uintptr Ftcl_ZlibStreamSetCompressionDictionary uintptr Ftcl_OpenTcpServerEx uintptr FtclZipfs_Mount uintptr FtclZipfs_Unmount uintptr FtclZipfs_TclLibrary uintptr FtclZipfs_MountBuffer uintptr Ftcl_FreeInternalRep uintptr Ftcl_InitStringRep uintptr Ftcl_FetchInternalRep uintptr Ftcl_StoreInternalRep uintptr Ftcl_HasStringRep uintptr Ftcl_IncrRefCount uintptr Ftcl_DecrRefCount uintptr Ftcl_IsShared uintptr Ftcl_LinkArray uintptr Ftcl_GetIntForIndex uintptr Ftcl_UtfToUniChar uintptr Ftcl_UniCharToUtfDString uintptr Ftcl_UtfToUniCharDString uintptr FtclGetBytesFromObj uintptr Ftcl_GetBytesFromObj uintptr Ftcl_GetStringFromObj uintptr Ftcl_GetUnicodeFromObj uintptr Ftcl_GetSizeIntFromObj uintptr Ftcl_UtfCharComplete uintptr Ftcl_UtfNext uintptr Ftcl_UtfPrev uintptr Ftcl_FSTildeExpand uintptr Ftcl_ExternalToUtfDStringEx uintptr Ftcl_UtfToExternalDStringEx uintptr Ftcl_AsyncMarkFromSignal uintptr Ftcl_ListObjGetElements uintptr Ftcl_ListObjLength uintptr Ftcl_DictObjSize uintptr Ftcl_SplitList uintptr Ftcl_SplitPath uintptr Ftcl_FSSplitPath uintptr Ftcl_ParseArgsObjv uintptr Ftcl_UniCharLen uintptr Ftcl_NumUtfChars uintptr Ftcl_GetCharLength uintptr Ftcl_UtfAtIndex uintptr Ftcl_GetRange uintptr Ftcl_GetUniChar uintptr Ftcl_GetBool uintptr Ftcl_GetBoolFromObj uintptr Ftcl_CreateObjCommand2 uintptr Ftcl_CreateObjTrace2 uintptr Ftcl_NRCreateCommand2 uintptr Ftcl_NRCallObjProc2 uintptr Ftcl_GetNumberFromObj uintptr Ftcl_GetNumber uintptr Ftcl_RemoveChannelMode uintptr Ftcl_GetEncodingNulLength uintptr Ftcl_GetWideUIntFromObj uintptr Ftcl_DStringToObj uintptr Ftcl_UtfNcmp uintptr Ftcl_UtfNcasecmp uintptr Ftcl_NewWideUIntObj uintptr Ftcl_SetWideUIntObj uintptr FtclUnusedStubEntry uintptr } type TTclPlatStubs = struct { Fmagic int32 Fhooks uintptr Freserved0 uintptr Ftcl_MacOSXOpenVersionedBundleResources uintptr Ftcl_MacOSXNotifierAddRunLoopMode uintptr Ftcl_WinConvertError uintptr } type Tregister_t = int64 type Ttime_t = int64 type Tsuseconds_t = int64 type Tint8_t = int8 type Tint16_t = int16 type Tint32_t = int32 type Tint64_t = int64 type Tu_int64_t = uint64 type Tmode_t = uint32 type Tnlink_t = uint64 type Tino_t = uint64 type Tdev_t = uint64 type Tblksize_t = int64 type Tblkcnt_t = int64 type Tfsblkcnt_t = uint64 type Tfsfilcnt_t = uint64 type Ttimer_t = uintptr type Tclockid_t = int32 type Tclock_t = int64 type Tpid_t = int32 type Tid_t = uint32 type Tuid_t = uint32 type Tgid_t = uint32 type Tkey_t = int32 type Tuseconds_t = uint32 type Tpthread_t = uintptr type Tpthread_once_t = int32 type Tpthread_key_t = uint32 type Tpthread_spinlock_t = int32 type Tpthread_mutexattr_t = struct { F__attr uint32 } type Tpthread_condattr_t = struct { F__attr uint32 } type Tpthread_barrierattr_t = struct { F__attr uint32 } type Tpthread_rwlockattr_t = struct { F__attr [2]uint32 } type Tpthread_attr_t = struct { F__u struct { F__vi [0][14]int32 F__s [0][7]uint64 F__i [14]int32 } } type Tpthread_mutex_t = struct { F__u struct { F__vi [0][10]int32 F__p [0][5]uintptr F__i [10]int32 } } type Tpthread_cond_t = struct { F__u struct { F__vi [0][12]int32 F__p [0][6]uintptr F__i [12]int32 } } type Tpthread_rwlock_t = struct { F__u struct { F__vi [0][14]int32 F__p [0][7]uintptr F__i [14]int32 } } type Tpthread_barrier_t = struct { F__u struct { F__vi [0][8]int32 F__p [0][4]uintptr F__i [8]int32 } } type Tu_int8_t = uint8 type Tu_int16_t = uint16 type Tu_int32_t = uint32 type Tcaddr_t = uintptr type Tu_char = uint8 type Tu_short = uint16 type Tushort = uint16 type Tu_int = uint32 type Tuint = uint32 type Tu_long = uint64 type Tulong = uint64 type Tquad_t = int64 type Tu_quad_t = uint64 type Tuint16_t = uint16 type Tuint32_t = uint32 type Tuint64_t = uint64 type Ttimeval = struct { Ftv_sec Ttime_t Ftv_usec Tsuseconds_t } type Ttimespec = struct { Ftv_sec Ttime_t Ftv_nsec int64 } type Tsigset_t = struct { F__bits [16]uint64 } type T__sigset_t = Tsigset_t type Tfd_mask = uint64 type Tfd_set = struct { Ffds_bits [16]uint64 } type TXID = uint64 type TMask = uint64 type TAtom = uint64 type TVisualID = uint64 type TTime = uint64 type TWindow = uint64 type TDrawable = uint64 type TFont = uint64 type TPixmap = uint64 type TCursor = uint64 type TColormap = uint64 type TGContext = uint64 type TKeySym = uint64 type TKeyCode = uint8 type TXPointer = uintptr type TXExtData = struct { Fnumber int32 Fnext uintptr Ffree_private uintptr Fprivate_data TXPointer } type T_XExtData = TXExtData type TXExtCodes = struct { Fextension int32 Fmajor_opcode int32 Ffirst_event int32 Ffirst_error int32 } type TXPixmapFormatValues = struct { Fdepth int32 Fbits_per_pixel int32 Fscanline_pad int32 } type TXGCValues = struct { Ffunction int32 Fplane_mask uint64 Fforeground uint64 Fbackground uint64 Fline_width int32 Fline_style int32 Fcap_style int32 Fjoin_style int32 Ffill_style int32 Ffill_rule int32 Farc_mode int32 Ftile TPixmap Fstipple TPixmap Fts_x_origin int32 Fts_y_origin int32 Ffont TFont Fsubwindow_mode int32 Fgraphics_exposures int32 Fclip_x_origin int32 Fclip_y_origin int32 Fclip_mask TPixmap Fdash_offset int32 Fdashes uint8 } type TGC = uintptr type TVisual = struct { Fext_data uintptr Fvisualid TVisualID Fclass int32 Fred_mask uint64 Fgreen_mask uint64 Fblue_mask uint64 Fbits_per_rgb int32 Fmap_entries int32 } type TDepth = struct { Fdepth int32 Fnvisuals int32 Fvisuals uintptr } type TScreen = struct { Fext_data uintptr Fdisplay uintptr Froot TWindow Fwidth int32 Fheight int32 Fmwidth int32 Fmheight int32 Fndepths int32 Fdepths uintptr Froot_depth int32 Froot_visual uintptr Fdefault_gc TGC Fcmap TColormap Fwhite_pixel uint64 Fblack_pixel uint64 Fmax_maps int32 Fmin_maps int32 Fbacking_store int32 Fsave_unders int32 Froot_input_mask int64 } type TScreenFormat = struct { Fext_data uintptr Fdepth int32 Fbits_per_pixel int32 Fscanline_pad int32 } type TXSetWindowAttributes = struct { Fbackground_pixmap TPixmap Fbackground_pixel uint64 Fborder_pixmap TPixmap Fborder_pixel uint64 Fbit_gravity int32 Fwin_gravity int32 Fbacking_store int32 Fbacking_planes uint64 Fbacking_pixel uint64 Fsave_under int32 Fevent_mask int64 Fdo_not_propagate_mask int64 Foverride_redirect int32 Fcolormap TColormap Fcursor TCursor } type TXWindowAttributes = struct { Fx int32 Fy int32 Fwidth int32 Fheight int32 Fborder_width int32 Fdepth int32 Fvisual uintptr Froot TWindow Fclass int32 Fbit_gravity int32 Fwin_gravity int32 Fbacking_store int32 Fbacking_planes uint64 Fbacking_pixel uint64 Fsave_under int32 Fcolormap TColormap Fmap_installed int32 Fmap_state int32 Fall_event_masks int64 Fyour_event_mask int64 Fdo_not_propagate_mask int64 Foverride_redirect int32 Fscreen uintptr } type TXHostAddress = struct { Ffamily int32 Flength int32 Faddress uintptr } type TXServerInterpretedAddress = struct { Ftypelength int32 Fvaluelength int32 Ftype1 uintptr Fvalue uintptr } type TXImage = struct { Fwidth int32 Fheight int32 Fxoffset int32 Fformat int32 Fdata uintptr Fbyte_order int32 Fbitmap_unit int32 Fbitmap_bit_order int32 Fbitmap_pad int32 Fdepth int32 Fbytes_per_line int32 Fbits_per_pixel int32 Fred_mask uint64 Fgreen_mask uint64 Fblue_mask uint64 Fobdata TXPointer Ff Tfuncs } type T_XImage = TXImage type TXWindowChanges = struct { Fx int32 Fy int32 Fwidth int32 Fheight int32 Fborder_width int32 Fsibling TWindow Fstack_mode int32 } type TXColor = struct { Fpixel uint64 Fred uint16 Fgreen uint16 Fblue uint16 Fflags uint8 Fpad uint8 } type TXSegment = struct { Fx1 int16 Fy1 int16 Fx2 int16 Fy2 int16 } type TXPoint = struct { Fx int16 Fy int16 } type TXRectangle = struct { Fx int16 Fy int16 Fwidth uint16 Fheight uint16 } type TXArc = struct { Fx int16 Fy int16 Fwidth uint16 Fheight uint16 Fangle1 int16 Fangle2 int16 } type TXKeyboardControl = struct { Fkey_click_percent int32 Fbell_percent int32 Fbell_pitch int32 Fbell_duration int32 Fled int32 Fled_mode int32 Fkey int32 Fauto_repeat_mode int32 } type TXKeyboardState = struct { Fkey_click_percent int32 Fbell_percent int32 Fbell_pitch uint32 Fbell_duration uint32 Fled_mask uint64 Fglobal_auto_repeat int32 Fauto_repeats [32]uint8 } type TXTimeCoord = struct { Ftime TTime Fx int16 Fy int16 } type TXModifierKeymap = struct { Fmax_keypermod int32 Fmodifiermap uintptr } type T_XPrivDisplay = uintptr type TXKeyEvent = struct { Ftype1 int32 Fserial uint64 Fsend_event int32 Fdisplay uintptr Fwindow TWindow Froot TWindow Fsubwindow TWindow Ftime TTime Fx int32 Fy int32 Fx_root int32 Fy_root int32 Fstate uint32 Fkeycode uint32 Fsame_screen int32 } type TXKeyPressedEvent = struct { Ftype1 int32 Fserial uint64 Fsend_event int32 Fdisplay uintptr Fwindow TWindow Froot TWindow Fsubwindow TWindow Ftime TTime Fx int32 Fy int32 Fx_root int32 Fy_root int32 Fstate uint32 Fkeycode uint32 Fsame_screen int32 } type TXKeyReleasedEvent = struct { Ftype1 int32 Fserial uint64 Fsend_event int32 Fdisplay uintptr Fwindow TWindow Froot TWindow Fsubwindow TWindow Ftime TTime Fx int32 Fy int32 Fx_root int32 Fy_root int32 Fstate uint32 Fkeycode uint32 Fsame_screen int32 } type TXButtonEvent = struct { Ftype1 int32 Fserial uint64 Fsend_event int32 Fdisplay uintptr Fwindow TWindow Froot TWindow Fsubwindow TWindow Ftime TTime Fx int32 Fy int32 Fx_root int32 Fy_root int32 Fstate uint32 Fbutton uint32 Fsame_screen int32 } type TXButtonPressedEvent = struct { Ftype1 int32 Fserial uint64 Fsend_event int32 Fdisplay uintptr Fwindow TWindow Froot TWindow Fsubwindow TWindow Ftime TTime Fx int32 Fy int32 Fx_root int32 Fy_root int32 Fstate uint32 Fbutton uint32 Fsame_screen int32 } type TXButtonReleasedEvent = struct { Ftype1 int32 Fserial uint64 Fsend_event int32 Fdisplay uintptr Fwindow TWindow Froot TWindow Fsubwindow TWindow Ftime TTime Fx int32 Fy int32 Fx_root int32 Fy_root int32 Fstate uint32 Fbutton uint32 Fsame_screen int32 } type TXMotionEvent = struct { Ftype1 int32 Fserial uint64 Fsend_event int32 Fdisplay uintptr Fwindow TWindow Froot TWindow Fsubwindow TWindow Ftime TTime Fx int32 Fy int32 Fx_root int32 Fy_root int32 Fstate uint32 Fis_hint uint8 Fsame_screen int32 } type TXPointerMovedEvent = struct { Ftype1 int32 Fserial uint64 Fsend_event int32 Fdisplay uintptr Fwindow TWindow Froot TWindow Fsubwindow TWindow Ftime TTime Fx int32 Fy int32 Fx_root int32 Fy_root int32 Fstate uint32 Fis_hint uint8 Fsame_screen int32 } type TXCrossingEvent = struct { Ftype1 int32 Fserial uint64 Fsend_event int32 Fdisplay uintptr Fwindow TWindow Froot TWindow Fsubwindow TWindow Ftime TTime Fx int32 Fy int32 Fx_root int32 Fy_root int32 Fmode int32 Fdetail int32 Fsame_screen int32 Ffocus int32 Fstate uint32 } type TXEnterWindowEvent = struct { Ftype1 int32 Fserial uint64 Fsend_event int32 Fdisplay uintptr Fwindow TWindow Froot TWindow Fsubwindow TWindow Ftime TTime Fx int32 Fy int32 Fx_root int32 Fy_root int32 Fmode int32 Fdetail int32 Fsame_screen int32 Ffocus int32 Fstate uint32 } type TXLeaveWindowEvent = struct { Ftype1 int32 Fserial uint64 Fsend_event int32 Fdisplay uintptr Fwindow TWindow Froot TWindow Fsubwindow TWindow Ftime TTime Fx int32 Fy int32 Fx_root int32 Fy_root int32 Fmode int32 Fdetail int32 Fsame_screen int32 Ffocus int32 Fstate uint32 } type TXFocusChangeEvent = struct { Ftype1 int32 Fserial uint64 Fsend_event int32 Fdisplay uintptr Fwindow TWindow Fmode int32 Fdetail int32 } type TXFocusInEvent = struct { Ftype1 int32 Fserial uint64 Fsend_event int32 Fdisplay uintptr Fwindow TWindow Fmode int32 Fdetail int32 } type TXFocusOutEvent = struct { Ftype1 int32 Fserial uint64 Fsend_event int32 Fdisplay uintptr Fwindow TWindow Fmode int32 Fdetail int32 } type TXKeymapEvent = struct { Ftype1 int32 Fserial uint64 Fsend_event int32 Fdisplay uintptr Fwindow TWindow Fkey_vector [32]uint8 } type TXExposeEvent = struct { Ftype1 int32 Fserial uint64 Fsend_event int32 Fdisplay uintptr Fwindow TWindow Fx int32 Fy int32 Fwidth int32 Fheight int32 Fcount int32 } type TXGraphicsExposeEvent = struct { Ftype1 int32 Fserial uint64 Fsend_event int32 Fdisplay uintptr Fdrawable TDrawable Fx int32 Fy int32 Fwidth int32 Fheight int32 Fcount int32 Fmajor_code int32 Fminor_code int32 } type TXNoExposeEvent = struct { Ftype1 int32 Fserial uint64 Fsend_event int32 Fdisplay uintptr Fdrawable TDrawable Fmajor_code int32 Fminor_code int32 } type TXVisibilityEvent = struct { Ftype1 int32 Fserial uint64 Fsend_event int32 Fdisplay uintptr Fwindow TWindow Fstate int32 } type TXCreateWindowEvent = struct { Ftype1 int32 Fserial uint64 Fsend_event int32 Fdisplay uintptr Fparent TWindow Fwindow TWindow Fx int32 Fy int32 Fwidth int32 Fheight int32 Fborder_width int32 Foverride_redirect int32 } type TXDestroyWindowEvent = struct { Ftype1 int32 Fserial uint64 Fsend_event int32 Fdisplay uintptr Fevent TWindow Fwindow TWindow } type TXUnmapEvent = struct { Ftype1 int32 Fserial uint64 Fsend_event int32 Fdisplay uintptr Fevent TWindow Fwindow TWindow Ffrom_configure int32 } type TXMapEvent = struct { Ftype1 int32 Fserial uint64 Fsend_event int32 Fdisplay uintptr Fevent TWindow Fwindow TWindow Foverride_redirect int32 } type TXMapRequestEvent = struct { Ftype1 int32 Fserial uint64 Fsend_event int32 Fdisplay uintptr Fparent TWindow Fwindow TWindow } type TXReparentEvent = struct { Ftype1 int32 Fserial uint64 Fsend_event int32 Fdisplay uintptr Fevent TWindow Fwindow TWindow Fparent TWindow Fx int32 Fy int32 Foverride_redirect int32 } type TXConfigureEvent = struct { Ftype1 int32 Fserial uint64 Fsend_event int32 Fdisplay uintptr Fevent TWindow Fwindow TWindow Fx int32 Fy int32 Fwidth int32 Fheight int32 Fborder_width int32 Fabove TWindow Foverride_redirect int32 } type TXGravityEvent = struct { Ftype1 int32 Fserial uint64 Fsend_event int32 Fdisplay uintptr Fevent TWindow Fwindow TWindow Fx int32 Fy int32 } type TXResizeRequestEvent = struct { Ftype1 int32 Fserial uint64 Fsend_event int32 Fdisplay uintptr Fwindow TWindow Fwidth int32 Fheight int32 } type TXConfigureRequestEvent = struct { Ftype1 int32 Fserial uint64 Fsend_event int32 Fdisplay uintptr Fparent TWindow Fwindow TWindow Fx int32 Fy int32 Fwidth int32 Fheight int32 Fborder_width int32 Fabove TWindow Fdetail int32 Fvalue_mask uint64 } type TXCirculateEvent = struct { Ftype1 int32 Fserial uint64 Fsend_event int32 Fdisplay uintptr Fevent TWindow Fwindow TWindow Fplace int32 } type TXCirculateRequestEvent = struct { Ftype1 int32 Fserial uint64 Fsend_event int32 Fdisplay uintptr Fparent TWindow Fwindow TWindow Fplace int32 } type TXPropertyEvent = struct { Ftype1 int32 Fserial uint64 Fsend_event int32 Fdisplay uintptr Fwindow TWindow Fatom TAtom Ftime TTime Fstate int32 } type TXSelectionClearEvent = struct { Ftype1 int32 Fserial uint64 Fsend_event int32 Fdisplay uintptr Fwindow TWindow Fselection TAtom Ftime TTime } type TXSelectionRequestEvent = struct { Ftype1 int32 Fserial uint64 Fsend_event int32 Fdisplay uintptr Fowner TWindow Frequestor TWindow Fselection TAtom Ftarget TAtom Fproperty TAtom Ftime TTime } type TXSelectionEvent = struct { Ftype1 int32 Fserial uint64 Fsend_event int32 Fdisplay uintptr Frequestor TWindow Fselection TAtom Ftarget TAtom Fproperty TAtom Ftime TTime } type TXColormapEvent = struct { Ftype1 int32 Fserial uint64 Fsend_event int32 Fdisplay uintptr Fwindow TWindow Fcolormap TColormap Fnew1 int32 Fstate int32 } type TXClientMessageEvent = struct { Ftype1 int32 Fserial uint64 Fsend_event int32 Fdisplay uintptr Fwindow TWindow Fmessage_type TAtom Fformat int32 Fdata struct { Fs [0][10]int16 Fl [0][5]int64 Fb [20]uint8 F__ccgo_pad3 [20]byte } } type TXMappingEvent = struct { Ftype1 int32 Fserial uint64 Fsend_event int32 Fdisplay uintptr Fwindow TWindow Frequest int32 Ffirst_keycode int32 Fcount int32 } type TXErrorEvent = struct { Ftype1 int32 Fdisplay uintptr Fresourceid TXID Fserial uint64 Ferror_code uint8 Frequest_code uint8 Fminor_code uint8 } type TXAnyEvent = struct { Ftype1 int32 Fserial uint64 Fsend_event int32 Fdisplay uintptr Fwindow TWindow } type TXGenericEvent = struct { Ftype1 int32 Fserial uint64 Fsend_event int32 Fdisplay uintptr Fextension int32 Fevtype int32 } type TXGenericEventCookie = struct { Ftype1 int32 Fserial uint64 Fsend_event int32 Fdisplay uintptr Fextension int32 Fevtype int32 Fcookie uint32 Fdata uintptr } type TXEvent = struct { Fxany [0]TXAnyEvent Fxkey [0]TXKeyEvent Fxbutton [0]TXButtonEvent Fxmotion [0]TXMotionEvent Fxcrossing [0]TXCrossingEvent Fxfocus [0]TXFocusChangeEvent Fxexpose [0]TXExposeEvent Fxgraphicsexpose [0]TXGraphicsExposeEvent Fxnoexpose [0]TXNoExposeEvent Fxvisibility [0]TXVisibilityEvent Fxcreatewindow [0]TXCreateWindowEvent Fxdestroywindow [0]TXDestroyWindowEvent Fxunmap [0]TXUnmapEvent Fxmap [0]TXMapEvent Fxmaprequest [0]TXMapRequestEvent Fxreparent [0]TXReparentEvent Fxconfigure [0]TXConfigureEvent Fxgravity [0]TXGravityEvent Fxresizerequest [0]TXResizeRequestEvent Fxconfigurerequest [0]TXConfigureRequestEvent Fxcirculate [0]TXCirculateEvent Fxcirculaterequest [0]TXCirculateRequestEvent Fxproperty [0]TXPropertyEvent Fxselectionclear [0]TXSelectionClearEvent Fxselectionrequest [0]TXSelectionRequestEvent Fxselection [0]TXSelectionEvent Fxcolormap [0]TXColormapEvent Fxclient [0]TXClientMessageEvent Fxmapping [0]TXMappingEvent Fxerror [0]TXErrorEvent Fxkeymap [0]TXKeymapEvent Fxgeneric [0]TXGenericEvent Fxcookie [0]TXGenericEventCookie Fpad [0][24]int64 Ftype1 int32 F__ccgo_pad35 [188]byte } type T_XEvent = TXEvent type TXCharStruct = struct { Flbearing int16 Frbearing int16 Fwidth int16 Fascent int16 Fdescent int16 Fattributes uint16 } type TXFontProp = struct { Fname TAtom Fcard32 uint64 } type TXFontStruct = struct { Fext_data uintptr Ffid TFont Fdirection uint32 Fmin_char_or_byte2 uint32 Fmax_char_or_byte2 uint32 Fmin_byte1 uint32 Fmax_byte1 uint32 Fall_chars_exist int32 Fdefault_char uint32 Fn_properties int32 Fproperties uintptr Fmin_bounds TXCharStruct Fmax_bounds TXCharStruct Fper_char uintptr Fascent int32 Fdescent int32 } type TXTextItem = struct { Fchars uintptr Fnchars int32 Fdelta int32 Ffont TFont } type TXChar2b = struct { Fbyte1 uint8 Fbyte2 uint8 } type TXTextItem16 = struct { Fchars uintptr Fnchars int32 Fdelta int32 Ffont TFont } type TXEDataObject = struct { Fgc [0]TGC Fvisual [0]uintptr Fscreen [0]uintptr Fpixmap_format [0]uintptr Ffont [0]uintptr Fdisplay uintptr } type TXFontSetExtents = struct { Fmax_ink_extent TXRectangle Fmax_logical_extent TXRectangle } type TXOM = uintptr type TXOC = uintptr type TXFontSet = uintptr type TXmbTextItem = struct { Fchars uintptr Fnchars int32 Fdelta int32 Ffont_set TXFontSet } type TXwcTextItem = struct { Fchars uintptr Fnchars int32 Fdelta int32 Ffont_set TXFontSet } type TXOMCharSetList = struct { Fcharset_count int32 Fcharset_list uintptr } type TXOrientation = int32 const XOMOrientation_LTR_TTB = 0 const XOMOrientation_RTL_TTB = 1 const XOMOrientation_TTB_LTR = 2 const XOMOrientation_TTB_RTL = 3 const XOMOrientation_Context = 4 type TXOMOrientation = struct { Fnum_orientation int32 Forientation uintptr } type TXOMFontInfo = struct { Fnum_font int32 Ffont_struct_list uintptr Ffont_name_list uintptr } type TXIM = uintptr type TXIC = uintptr type TXIMProc = uintptr type TXICProc = uintptr type TXIDProc = uintptr type TXIMStyle = uint64 type TXIMStyles = struct { Fcount_styles uint16 Fsupported_styles uintptr } type TXVaNestedList = uintptr type TXIMCallback = struct { Fclient_data TXPointer Fcallback TXIMProc } type TXICCallback = struct { Fclient_data TXPointer Fcallback TXICProc } type TXIMFeedback = uint64 type TXIMText = struct { Flength uint16 Ffeedback uintptr Fencoding_is_wchar int32 Fstring1 struct { Fwide_char [0]uintptr Fmulti_byte uintptr } } type T_XIMText = TXIMText type TXIMPreeditState = uint64 type TXIMPreeditStateNotifyCallbackStruct = struct { Fstate TXIMPreeditState } type T_XIMPreeditStateNotifyCallbackStruct = TXIMPreeditStateNotifyCallbackStruct type TXIMResetState = uint64 type TXIMStringConversionFeedback = uint64 type TXIMStringConversionText = struct { Flength uint16 Ffeedback uintptr Fencoding_is_wchar int32 Fstring1 struct { Fwcs [0]uintptr Fmbs uintptr } } type T_XIMStringConversionText = TXIMStringConversionText type TXIMStringConversionPosition = uint16 type TXIMStringConversionType = uint16 type TXIMStringConversionOperation = uint16 type TXIMCaretDirection = int32 const XIMForwardChar = 0 const XIMBackwardChar = 1 const XIMForwardWord = 2 const XIMBackwardWord = 3 const XIMCaretUp = 4 const XIMCaretDown = 5 const XIMNextLine = 6 const XIMPreviousLine = 7 const XIMLineStart = 8 const XIMLineEnd = 9 const XIMAbsolutePosition = 10 const XIMDontChange = 11 type TXIMStringConversionCallbackStruct = struct { Fposition TXIMStringConversionPosition Fdirection TXIMCaretDirection Foperation TXIMStringConversionOperation Ffactor uint16 Ftext uintptr } type T_XIMStringConversionCallbackStruct = TXIMStringConversionCallbackStruct type TXIMPreeditDrawCallbackStruct = struct { Fcaret int32 Fchg_first int32 Fchg_length int32 Ftext uintptr } type T_XIMPreeditDrawCallbackStruct = TXIMPreeditDrawCallbackStruct type TXIMCaretStyle = int32 const XIMIsInvisible = 0 const XIMIsPrimary = 1 const XIMIsSecondary = 2 type TXIMPreeditCaretCallbackStruct = struct { Fposition int32 Fdirection TXIMCaretDirection Fstyle TXIMCaretStyle } type T_XIMPreeditCaretCallbackStruct = TXIMPreeditCaretCallbackStruct type TXIMStatusDataType = int32 const XIMTextType = 0 const XIMBitmapType = 1 type TXIMStatusDrawCallbackStruct = struct { Ftype1 TXIMStatusDataType Fdata struct { Fbitmap [0]TPixmap Ftext uintptr } } type T_XIMStatusDrawCallbackStruct = TXIMStatusDrawCallbackStruct type TXIMHotKeyTrigger = struct { Fkeysym TKeySym Fmodifier int32 Fmodifier_mask int32 } type T_XIMHotKeyTrigger = TXIMHotKeyTrigger type TXIMHotKeyTriggers = struct { Fnum_hot_key int32 Fkey uintptr } type T_XIMHotKeyTriggers = TXIMHotKeyTriggers type TXIMHotKeyState = uint64 type TXIMValuesList = struct { Fcount_values uint16 Fsupported_values uintptr } type TXErrorHandler = uintptr type TXIOErrorHandler = uintptr type TXIOErrorExitHandler = uintptr type TXConnectionWatchProc = uintptr type TTk_BindingTable = uintptr type TTk_Canvas = uintptr type TTk_Cursor = uintptr type TTk_ErrorHandler = uintptr type TTk_Font = uintptr type TTk_Image = uintptr type TTk_ImageModel = uintptr type TTk_OptionTable = uintptr type TTk_PostscriptInfo = uintptr type TTk_TextLayout = uintptr type TTk_Window = uintptr type TTk_3DBorder = uintptr type TTk_Style = uintptr type TTk_StyleEngine = uintptr type TTk_StyledElement = uintptr type TTk_Uid = uintptr type TTk_OptionType = int32 const TK_OPTION_BOOLEAN = 0 const TK_OPTION_INT = 1 const TK_OPTION_DOUBLE = 2 const TK_OPTION_STRING = 3 const TK_OPTION_STRING_TABLE = 4 const TK_OPTION_COLOR = 5 const TK_OPTION_FONT = 6 const TK_OPTION_BITMAP = 7 const TK_OPTION_BORDER = 8 const TK_OPTION_RELIEF = 9 const TK_OPTION_CURSOR = 10 const TK_OPTION_JUSTIFY = 11 const TK_OPTION_ANCHOR = 12 const TK_OPTION_SYNONYM = 13 const TK_OPTION_PIXELS = 14 const TK_OPTION_WINDOW = 15 const TK_OPTION_END = 16 const TK_OPTION_CUSTOM = 17 const TK_OPTION_STYLE = 18 const TK_OPTION_INDEX = 19 type TTk_OptionSpec = struct { Ftype1 TTk_OptionType FoptionName uintptr FdbName uintptr FdbClass uintptr FdefValue uintptr FobjOffset TTcl_Size FinternalOffset TTcl_Size Fflags int32 FclientData uintptr FtypeMask int32 } type TTk_ObjCustomOption = struct { Fname uintptr FsetProc uintptr FgetProc uintptr FrestoreProc uintptr FfreeProc uintptr FclientData uintptr } type TTk_SavedOption = struct { FoptionPtr uintptr FvaluePtr uintptr FinternalForm float64 } type TTk_SavedOptions = struct { FrecordPtr uintptr Ftkwin TTk_Window FnumItems TTcl_Size Fitems [20]TTk_SavedOption FnextPtr uintptr } type TTk_CustomOption = struct { FparseProc uintptr FprintProc uintptr FclientData uintptr } type TTk_ConfigSpec = struct { Ftype1 int32 FargvName uintptr FdbName TTk_Uid FdbClass TTk_Uid FdefValue TTk_Uid Foffset TTcl_Size FspecFlags int32 FcustomPtr uintptr } type TTk_ConfigTypes = int32 const TK_CONFIG_BOOLEAN = 0 const TK_CONFIG_INT = 1 const TK_CONFIG_DOUBLE = 2 const TK_CONFIG_STRING = 3 const TK_CONFIG_UID = 4 const TK_CONFIG_COLOR = 5 const TK_CONFIG_FONT = 6 const TK_CONFIG_BITMAP = 7 const TK_CONFIG_BORDER = 8 const TK_CONFIG_RELIEF = 9 const TK_CONFIG_CURSOR = 10 const TK_CONFIG_ACTIVE_CURSOR = 11 const TK_CONFIG_JUSTIFY = 12 const TK_CONFIG_ANCHOR = 13 const TK_CONFIG_SYNONYM = 14 const TK_CONFIG_CAP_STYLE = 15 const TK_CONFIG_JOIN_STYLE = 16 const TK_CONFIG_PIXELS = 17 const TK_CONFIG_MM = 18 const TK_CONFIG_WINDOW = 19 const TK_CONFIG_CUSTOM = 20 const TK_CONFIG_END = 21 type TTk_ArgvInfo = struct { Fkey uintptr Ftype1 int32 Fsrc uintptr Fdst uintptr Fhelp uintptr } type TTk_RestrictAction = int32 const TK_DEFER_EVENT = 0 const TK_PROCESS_EVENT = 1 const TK_DISCARD_EVENT = 2 type TTk_Anchor = int32 const TK_ANCHOR_NULL = -1 const TK_ANCHOR_N = 0 const TK_ANCHOR_NE = 1 const TK_ANCHOR_E = 2 const TK_ANCHOR_SE = 3 const TK_ANCHOR_S = 4 const TK_ANCHOR_SW = 5 const TK_ANCHOR_W = 6 const TK_ANCHOR_NW = 7 const TK_ANCHOR_CENTER = 8 type TTk_Justify = int32 const TK_JUSTIFY_NULL = -1 const TK_JUSTIFY_LEFT = 0 const TK_JUSTIFY_RIGHT = 1 const TK_JUSTIFY_CENTER = 2 type TTk_FontMetrics = struct { Fascent int32 Fdescent int32 Flinespace int32 } type TTk_ClassProcs = struct { Fsize TTcl_Size FworldChangedProc uintptr FcreateProc uintptr FmodalProc uintptr } type TTk_GeomMgr = struct { Fname uintptr FrequestProc uintptr FlostContentProc uintptr } type TXVirtualEvent = struct { Ftype1 int32 Fserial uint64 Fsend_event int32 Fdisplay uintptr Fevent TWindow Froot TWindow Fsubwindow TWindow Ftime TTime Fx int32 Fy int32 Fx_root int32 Fy_root int32 Fstate uint32 Fname TTk_Uid Fsame_screen int32 Fuser_data uintptr } type TXActivateDeactivateEvent = struct { Ftype1 int32 Fserial uint64 Fsend_event int32 Fdisplay uintptr Fwindow TWindow } type TXActivateEvent = struct { Ftype1 int32 Fserial uint64 Fsend_event int32 Fdisplay uintptr Fwindow TWindow } type TXDeactivateEvent = struct { Ftype1 int32 Fserial uint64 Fsend_event int32 Fdisplay uintptr Fwindow TWindow } type TTk_FakeWin = struct { Fdisplay uintptr Fdummy1 uintptr FscreenNum int32 Fvisual uintptr Fdepth int32 Fwindow TWindow Fdummy2 uintptr Fdummy3 uintptr FparentPtr TTk_Window Fdummy4 uintptr Fdummy5 uintptr FpathName uintptr FnameUid TTk_Uid FclassUid TTk_Uid Fchanges TXWindowChanges Fdummy6 uint32 Fatts TXSetWindowAttributes Fdummy7 uint64 Fflags uint32 Fdummy8 uintptr Fdummy9 TXIC Fdummy10 uintptr Fdummy11 TTcl_Size Fdummy12 TTcl_Size Fdummy13 uintptr Fdummy14 uintptr Fdummy15 uintptr FreqWidth int32 FreqHeight int32 FinternalBorderLeft int32 Fdummy16 uintptr Fdummy17 uintptr Fdummy18 uintptr Fdummy19 uintptr FinternalBorderRight int32 FinternalBorderTop int32 FinternalBorderBottom int32 FminReqWidth int32 FminReqHeight int32 Fdummy20 int32 Fdummy21 uintptr Fdummy22 TTk_Window } type TTk_State = int32 const TK_STATE_NULL = -1 const TK_STATE_ACTIVE = 0 const TK_STATE_DISABLED = 1 const TK_STATE_NORMAL = 2 const TK_STATE_HIDDEN = 3 type TTk_SmoothMethod = struct { Fname uintptr FcoordProc uintptr FpostscriptProc uintptr } type TTk_Item = struct { Fid TTcl_Size FnextPtr uintptr FstaticTagSpace [3]TTk_Uid FtagPtr uintptr FtagSpace TTcl_Size FnumTags TTcl_Size FtypePtr uintptr Fx1 int32 Fy1 int32 Fx2 int32 Fy2 int32 FprevPtr uintptr Fstate TTk_State Freserved1 uintptr Fredraw_flags int32 } type TTk_ItemType = struct { Fname uintptr FitemSize TTcl_Size FcreateProc uintptr FconfigSpecs uintptr FconfigProc uintptr FcoordProc uintptr FdeleteProc uintptr FdisplayProc uintptr Fflags int32 FpointProc uintptr FareaProc uintptr FpostscriptProc uintptr FscaleProc uintptr FtranslateProc uintptr FindexProc uintptr FicursorProc uintptr FselectionProc uintptr FinsertProc uintptr FdCharsProc uintptr FnextPtr uintptr FrotateProc uintptr Freserved2 int32 Freserved3 uintptr Freserved4 uintptr } type TTk_CanvasTextInfo = struct { FselBorder TTk_3DBorder FselBorderWidth int32 FselFgColorPtr uintptr FselItemPtr uintptr FselectFirst TTcl_Size FselectLast TTcl_Size FanchorItemPtr uintptr FselectAnchor TTcl_Size FinsertBorder TTk_3DBorder FinsertWidth int32 FinsertBorderWidth int32 FfocusItemPtr uintptr FgotFocus int32 FcursorOn int32 Freserved1 uintptr Freserved2 uintptr Freserved3 uintptr } type TTk_Dash = struct { Fnumber int32 Fpattern struct { Farray [0][8]uint8 Fpt uintptr } } type TTk_TSOffset = struct { Fflags int32 Fxoffset int32 Fyoffset int32 } type TTk_Outline = struct { Fgc TGC Fwidth float64 FactiveWidth float64 FdisabledWidth float64 Foffset int32 Fdash TTk_Dash FactiveDash TTk_Dash FdisabledDash TTk_Dash FoffsetObj uintptr Freserved2 uintptr Freserved3 uintptr Ftsoffset TTk_TSOffset Fcolor uintptr FactiveColor uintptr FdisabledColor uintptr Fstipple TPixmap FactiveStipple TPixmap FdisabledStipple TPixmap } type TTk_ImageType = struct { Fname uintptr FcreateProc uintptr FgetProc uintptr FdisplayProc uintptr FfreeProc uintptr FdeleteProc uintptr FpostscriptProc uintptr FnextPtr uintptr Freserved uintptr } type TTk_ImageType1 = struct { Fname uintptr FcreateProc uintptr FgetProc uintptr FdisplayProc uintptr FfreeProc uintptr FdeleteProc uintptr FpostscriptProc uintptr FnextPtr uintptr Freserved uintptr } type TTk_PhotoHandle = uintptr type TTk_PhotoImageBlock = struct { FpixelPtr uintptr Fwidth int32 Fheight int32 Fpitch int32 FpixelSize int32 Foffset [4]int32 } type TTk_PhotoImageFormat = struct { Fname uintptr FfileMatchProc uintptr FstringMatchProc uintptr FfileReadProc uintptr FstringReadProc uintptr FfileWriteProc uintptr FstringWriteProc uintptr FnextPtr uintptr } type TTk_PhotoImageFormatVersion3 = struct { Fname uintptr FfileMatchProc uintptr FstringMatchProc uintptr FfileReadProc uintptr FstringReadProc uintptr FfileWriteProc uintptr FstringWriteProc uintptr FnextPtr uintptr } type TTk_PhotoImageFormat1 = struct { Fname uintptr FfileMatchProc uintptr FstringMatchProc uintptr FfileReadProc uintptr FstringReadProc uintptr FfileWriteProc uintptr FstringWriteProc uintptr FnextPtr uintptr } type TTk_PhotoImageFormatVersion31 = struct { Fname uintptr FfileMatchProc uintptr FstringMatchProc uintptr FfileReadProc uintptr FstringReadProc uintptr FfileWriteProc uintptr FstringWriteProc uintptr FnextPtr uintptr } type TTk_ElementOptionSpec = struct { Fname uintptr Ftype1 TTk_OptionType } type TTk_ElementSpec = struct { Fversion int32 Fname uintptr Foptions uintptr FgetSize uintptr FgetBox uintptr FgetBorderWidth uintptr Fdraw uintptr } type TTkStubHooks = struct { FtkPlatStubs uintptr FtkIntStubs uintptr FtkIntPlatStubs uintptr FtkIntXlibStubs uintptr } type TTkStubs = struct { Fmagic int32 Fhooks uintptr Ftk_MainLoop uintptr Ftk_3DBorderColor uintptr Ftk_3DBorderGC uintptr Ftk_3DHorizontalBevel uintptr Ftk_3DVerticalBevel uintptr Ftk_AddOption uintptr Ftk_BindEvent uintptr Ftk_CanvasDrawableCoords uintptr Ftk_CanvasEventuallyRedraw uintptr Ftk_CanvasGetCoord uintptr Ftk_CanvasGetTextInfo uintptr Ftk_CanvasPsBitmap uintptr Ftk_CanvasPsColor uintptr Ftk_CanvasPsFont uintptr Ftk_CanvasPsPath uintptr Ftk_CanvasPsStipple uintptr Ftk_CanvasPsY uintptr Ftk_CanvasSetStippleOrigin uintptr Ftk_CanvasTagsParseProc uintptr Ftk_CanvasTagsPrintProc uintptr Ftk_CanvasTkwin uintptr Ftk_CanvasWindowCoords uintptr Ftk_ChangeWindowAttributes uintptr Ftk_CharBbox uintptr Ftk_ClearSelection uintptr Ftk_ClipboardAppend uintptr Ftk_ClipboardClear uintptr Ftk_ConfigureInfo uintptr Ftk_ConfigureValue uintptr Ftk_ConfigureWidget uintptr Ftk_ConfigureWindow uintptr Ftk_ComputeTextLayout uintptr Ftk_CoordsToWindow uintptr Ftk_CreateBinding uintptr Ftk_CreateBindingTable uintptr Ftk_CreateErrorHandler uintptr Ftk_CreateEventHandler uintptr Ftk_CreateGenericHandler uintptr Ftk_CreateImageType uintptr Ftk_CreateItemType uintptr Ftk_CreatePhotoImageFormat uintptr Ftk_CreateSelHandler uintptr Ftk_CreateWindow uintptr Ftk_CreateWindowFromPath uintptr Ftk_DefineBitmap uintptr Ftk_DefineCursor uintptr Ftk_DeleteAllBindings uintptr Ftk_DeleteBinding uintptr Ftk_DeleteBindingTable uintptr Ftk_DeleteErrorHandler uintptr Ftk_DeleteEventHandler uintptr Ftk_DeleteGenericHandler uintptr Ftk_DeleteImage uintptr Ftk_DeleteSelHandler uintptr Ftk_DestroyWindow uintptr Ftk_DisplayName uintptr Ftk_DistanceToTextLayout uintptr Ftk_Draw3DPolygon uintptr Ftk_Draw3DRectangle uintptr Ftk_DrawChars uintptr Ftk_DrawFocusHighlight uintptr Ftk_DrawTextLayout uintptr Ftk_Fill3DPolygon uintptr Ftk_Fill3DRectangle uintptr Ftk_FindPhoto uintptr Ftk_FontId uintptr Ftk_Free3DBorder uintptr Ftk_FreeBitmap uintptr Ftk_FreeColor uintptr Ftk_FreeColormap uintptr Ftk_FreeCursor uintptr Ftk_FreeFont uintptr Ftk_FreeGC uintptr Ftk_FreeImage uintptr Ftk_FreeOptions uintptr Ftk_FreePixmap uintptr Ftk_FreeTextLayout uintptr Freserved77 uintptr Ftk_GCForColor uintptr Ftk_GeometryRequest uintptr Ftk_Get3DBorder uintptr Ftk_GetAllBindings uintptr Ftk_GetAnchor uintptr Ftk_GetAtomName uintptr Ftk_GetBinding uintptr Ftk_GetBitmap uintptr Ftk_GetBitmapFromData uintptr Ftk_GetCapStyle uintptr Ftk_GetColor uintptr Ftk_GetColorByValue uintptr Ftk_GetColormap uintptr Ftk_GetCursor uintptr Ftk_GetCursorFromData uintptr Ftk_GetFont uintptr Ftk_GetFontFromObj uintptr Ftk_GetFontMetrics uintptr Ftk_GetGC uintptr Ftk_GetImage uintptr Ftk_GetImageModelData uintptr Ftk_GetItemTypes uintptr Ftk_GetJoinStyle uintptr Ftk_GetJustify uintptr Ftk_GetNumMainWindows uintptr Ftk_GetOption uintptr Ftk_GetPixels uintptr Ftk_GetPixmap uintptr Ftk_GetRelief uintptr Ftk_GetRootCoords uintptr Ftk_GetScrollInfo uintptr Ftk_GetScreenMM uintptr Ftk_GetSelection uintptr Ftk_GetUid uintptr Ftk_GetVisual uintptr Ftk_GetVRootGeometry uintptr Ftk_Grab uintptr Ftk_HandleEvent uintptr Ftk_IdToWindow uintptr Ftk_ImageChanged uintptr Freserved118 uintptr Ftk_InternAtom uintptr Ftk_IntersectTextLayout uintptr Ftk_MaintainGeometry uintptr Ftk_MainWindow uintptr Ftk_MakeWindowExist uintptr Ftk_ManageGeometry uintptr Ftk_MapWindow uintptr Ftk_MeasureChars uintptr Ftk_MoveResizeWindow uintptr Ftk_MoveWindow uintptr Ftk_MoveToplevelWindow uintptr Ftk_NameOf3DBorder uintptr Ftk_NameOfAnchor uintptr Ftk_NameOfBitmap uintptr Ftk_NameOfCapStyle uintptr Ftk_NameOfColor uintptr Ftk_NameOfCursor uintptr Ftk_NameOfFont uintptr Ftk_NameOfImage uintptr Ftk_NameOfJoinStyle uintptr Ftk_NameOfJustify uintptr Ftk_NameOfRelief uintptr Ftk_NameToWindow uintptr Ftk_OwnSelection uintptr Ftk_ParseArgv uintptr Freserved144 uintptr Freserved145 uintptr Ftk_PhotoGetImage uintptr Ftk_PhotoBlank uintptr Freserved148 uintptr Ftk_PhotoGetSize uintptr Freserved150 uintptr Ftk_PointToChar uintptr Ftk_PostscriptFontName uintptr Ftk_PreserveColormap uintptr Ftk_QueueWindowEvent uintptr Ftk_RedrawImage uintptr Ftk_ResizeWindow uintptr Ftk_RestackWindow uintptr Ftk_RestrictEvents uintptr Freserved159 uintptr Ftk_SetAppName uintptr Ftk_SetBackgroundFromBorder uintptr Ftk_SetClass uintptr Ftk_SetGrid uintptr Ftk_SetInternalBorder uintptr Ftk_SetWindowBackground uintptr Ftk_SetWindowBackgroundPixmap uintptr Ftk_SetWindowBorder uintptr Ftk_SetWindowBorderWidth uintptr Ftk_SetWindowBorderPixmap uintptr Ftk_SetWindowColormap uintptr Ftk_SetWindowVisual uintptr Ftk_SizeOfBitmap uintptr Ftk_SizeOfImage uintptr Ftk_StrictMotif uintptr Ftk_TextLayoutToPostscript uintptr Ftk_TextWidth uintptr Ftk_UndefineCursor uintptr Ftk_UnderlineChars uintptr Ftk_UnderlineTextLayout uintptr Ftk_Ungrab uintptr Ftk_UnmaintainGeometry uintptr Ftk_UnmapWindow uintptr Ftk_UnsetGrid uintptr Ftk_UpdatePointer uintptr Ftk_AllocBitmapFromObj uintptr Ftk_Alloc3DBorderFromObj uintptr Ftk_AllocColorFromObj uintptr Ftk_AllocCursorFromObj uintptr Ftk_AllocFontFromObj uintptr Ftk_CreateOptionTable uintptr Ftk_DeleteOptionTable uintptr Ftk_Free3DBorderFromObj uintptr Ftk_FreeBitmapFromObj uintptr Ftk_FreeColorFromObj uintptr Ftk_FreeConfigOptions uintptr Ftk_FreeSavedOptions uintptr Ftk_FreeCursorFromObj uintptr Ftk_FreeFontFromObj uintptr Ftk_Get3DBorderFromObj uintptr Ftk_GetAnchorFromObj uintptr Ftk_GetBitmapFromObj uintptr Ftk_GetColorFromObj uintptr Ftk_GetCursorFromObj uintptr Ftk_GetOptionInfo uintptr Ftk_GetOptionValue uintptr Ftk_GetJustifyFromObj uintptr Ftk_GetMMFromObj uintptr Ftk_GetPixelsFromObj uintptr Ftk_GetReliefFromObj uintptr Ftk_GetScrollInfoObj uintptr Ftk_InitOptions uintptr Freserved212 uintptr Ftk_RestoreSavedOptions uintptr Ftk_SetOptions uintptr Ftk_InitConsoleChannels uintptr Freserved216 uintptr Ftk_CreateSmoothMethod uintptr Freserved218 uintptr Freserved219 uintptr Ftk_GetDash uintptr Ftk_CreateOutline uintptr Ftk_DeleteOutline uintptr Ftk_ConfigOutlineGC uintptr Ftk_ChangeOutlineGC uintptr Ftk_ResetOutlineGC uintptr Ftk_CanvasPsOutline uintptr Ftk_SetTSOrigin uintptr Ftk_CanvasGetCoordFromObj uintptr Ftk_CanvasSetOffset uintptr Ftk_DitherPhoto uintptr Ftk_PostscriptBitmap uintptr Ftk_PostscriptColor uintptr Ftk_PostscriptFont uintptr Ftk_PostscriptImage uintptr Ftk_PostscriptPath uintptr Ftk_PostscriptStipple uintptr Ftk_PostscriptY uintptr Ftk_PostscriptPhoto uintptr Ftk_CreateClientMessageHandler uintptr Ftk_DeleteClientMessageHandler uintptr Ftk_CreateAnonymousWindow uintptr Ftk_SetClassProcs uintptr Ftk_SetInternalBorderEx uintptr Ftk_SetMinimumRequestSize uintptr Ftk_SetCaretPos uintptr Freserved246 uintptr Freserved247 uintptr Ftk_CollapseMotionEvents uintptr Ftk_RegisterStyleEngine uintptr Ftk_GetStyleEngine uintptr Ftk_RegisterStyledElement uintptr Ftk_GetElementId uintptr Ftk_CreateStyle uintptr Ftk_GetStyle uintptr Ftk_FreeStyle uintptr Ftk_NameOfStyle uintptr Ftk_AllocStyleFromObj uintptr Freserved258 uintptr Freserved259 uintptr Ftk_GetStyledElement uintptr Ftk_GetElementSize uintptr Ftk_GetElementBox uintptr Ftk_GetElementBorderWidth uintptr Ftk_DrawElement uintptr Ftk_PhotoExpand uintptr Ftk_PhotoPutBlock uintptr Ftk_PhotoPutZoomedBlock uintptr Ftk_PhotoSetSize uintptr Ftk_GetUserInactiveTime uintptr Ftk_ResetUserInactiveTime uintptr Ftk_Interp uintptr Freserved272 uintptr Freserved273 uintptr Ftk_AlwaysShowSelection uintptr Ftk_GetButtonMask uintptr Ftk_GetDoublePixelsFromObj uintptr Ftk_NewWindowObj uintptr Ftk_SendVirtualEvent uintptr Ftk_FontGetDescription uintptr Ftk_CreatePhotoImageFormatVersion3 uintptr Ftk_DrawHighlightBorder uintptr Ftk_SetMainMenubar uintptr Ftk_SetWindowMenubar uintptr Ftk_ClipDrawableToRect uintptr Ftk_GetSystemDefault uintptr Ftk_UseWindow uintptr Ftk_MakeContainer uintptr Ftk_GetOtherWindow uintptr Ftk_Get3DBorderColors uintptr Ftk_MakeWindow uintptr Ftk_UnderlineCharsInContext uintptr Ftk_DrawCharsInContext uintptr Ftk_MeasureCharsInContext uintptr FtkUnusedStubEntry uintptr } type Tpasswd = struct { Fpw_name uintptr Fpw_passwd uintptr Fpw_uid Tuid_t Fpw_gid Tgid_t Fpw_gecos uintptr Fpw_dir uintptr Fpw_shell uintptr } type Tiovec = struct { Fiov_base uintptr Fiov_len Tsize_t } type Tflock = struct { Fl_type int16 Fl_whence int16 Fl_start Toff_t Fl_len Toff_t Fl_pid Tpid_t } type Tfile_handle = struct { Fhandle_bytes uint32 Fhandle_type int32 } type Tf_owner_ex = struct { Ftype1 int32 Fpid Tpid_t } type Tlocale_t = uintptr type Tfloat_t = float32 type Tdouble_t = float64 type Tstatx_timestamp = struct { Ftv_sec Tint64_t Ftv_nsec Tuint32_t F__pad Tuint32_t } type Tstatx = struct { Fstx_mask Tuint32_t Fstx_blksize Tuint32_t Fstx_attributes Tuint64_t Fstx_nlink Tuint32_t Fstx_uid Tuint32_t Fstx_gid Tuint32_t Fstx_mode Tuint16_t F__pad0 [1]Tuint16_t Fstx_ino Tuint64_t Fstx_size Tuint64_t Fstx_blocks Tuint64_t Fstx_attributes_mask Tuint64_t Fstx_atime Tstatx_timestamp Fstx_btime Tstatx_timestamp Fstx_ctime Tstatx_timestamp Fstx_mtime Tstatx_timestamp Fstx_rdev_major Tuint32_t Fstx_rdev_minor Tuint32_t Fstx_dev_major Tuint32_t Fstx_dev_minor Tuint32_t F__pad1 [14]Tuint64_t } type Titimerval = struct { Fit_interval Ttimeval Fit_value Ttimeval } type Ttimezone = struct { Ftz_minuteswest int32 Ftz_dsttime int32 } type Ttm = struct { Ftm_sec int32 Ftm_min int32 Ftm_hour int32 Ftm_mday int32 Ftm_mon int32 Ftm_year int32 Ftm_wday int32 Ftm_yday int32 Ftm_isdst int32 Ftm_gmtoff int64 Ftm_zone uintptr } type Titimerspec = struct { Fit_interval Ttimespec Fit_value Ttimespec } type Tuintptr_t = uint64 type Tintptr_t = int64 type Tintmax_t = int64 type Tuint8_t = uint8 type Tuintmax_t = uint64 type Tint_fast8_t = int8 type Tint_fast64_t = int64 type Tint_least8_t = int8 type Tint_least16_t = int16 type Tint_least32_t = int32 type Tint_least64_t = int64 type Tuint_fast8_t = uint8 type Tuint_fast64_t = uint64 type Tuint_least8_t = uint8 type Tuint_least16_t = uint16 type Tuint_least32_t = uint32 type Tuint_least64_t = uint64 type Tint_fast16_t = int32 type Tint_fast32_t = int32 type Tuint_fast16_t = uint32 type Tuint_fast32_t = uint32 type Timaxdiv_t = struct { Fquot Tintmax_t Frem Tintmax_t } type TINT64 = int64 type TINT32 = int32 type TINT16 = int16 type TINT8 = int8 type TCARD64 = uint64 type TCARD32 = uint32 type TCARD16 = uint16 type TCARD8 = uint8 type TBITS32 = uint32 type TBITS16 = uint16 type TBYTE = uint8 type TBOOL = uint8 type TxSegment = struct { Fx1 TINT16 Fy1 TINT16 Fx2 TINT16 Fy2 TINT16 } type T_xSegment = TxSegment type TxPoint = struct { Fx TINT16 Fy TINT16 } type T_xPoint = TxPoint type TxRectangle = struct { Fx TINT16 Fy TINT16 Fwidth TCARD16 Fheight TCARD16 } type T_xRectangle = TxRectangle type TxArc = struct { Fx TINT16 Fy TINT16 Fwidth TCARD16 Fheight TCARD16 Fangle1 TINT16 Fangle2 TINT16 } type T_xArc = TxArc type TKeyButMask = uint16 type TxConnClientPrefix = struct { FbyteOrder TCARD8 Fpad TBYTE FmajorVersion TCARD16 FminorVersion TCARD16 FnbytesAuthProto TCARD16 FnbytesAuthString TCARD16 Fpad2 TCARD16 } type TxConnSetupPrefix = struct { Fsuccess TCARD8 FlengthReason TBYTE FmajorVersion TCARD16 FminorVersion TCARD16 Flength TCARD16 } type TxConnSetup = struct { Frelease TCARD32 FridBase TCARD32 FridMask TCARD32 FmotionBufferSize TCARD32 FnbytesVendor TCARD16 FmaxRequestSize TCARD16 FnumRoots TCARD8 FnumFormats TCARD8 FimageByteOrder TCARD8 FbitmapBitOrder TCARD8 FbitmapScanlineUnit TCARD8 FbitmapScanlinePad TCARD8 FminKeyCode TCARD8 FmaxKeyCode TCARD8 Fpad2 TCARD32 } type TxPixmapFormat = struct { Fdepth TCARD8 FbitsPerPixel TCARD8 FscanLinePad TCARD8 Fpad1 TCARD8 Fpad2 TCARD32 } type TxDepth = struct { Fdepth TCARD8 Fpad1 TCARD8 FnVisuals TCARD16 Fpad2 TCARD32 } type TxVisualType = struct { FvisualID TCARD32 Fclass TCARD8 FbitsPerRGB TCARD8 FcolormapEntries TCARD16 FredMask TCARD32 FgreenMask TCARD32 FblueMask TCARD32 Fpad TCARD32 } type TxWindowRoot = struct { FwindowId TCARD32 FdefaultColormap TCARD32 FwhitePixel TCARD32 FblackPixel TCARD32 FcurrentInputMask TCARD32 FpixWidth TCARD16 FpixHeight TCARD16 FmmWidth TCARD16 FmmHeight TCARD16 FminInstalledMaps TCARD16 FmaxInstalledMaps TCARD16 FrootVisualID TCARD32 FbackingStore TCARD8 FsaveUnders TBOOL FrootDepth TCARD8 FnDepths TCARD8 } type TxTimecoord = struct { Ftime TCARD32 Fx TINT16 Fy TINT16 } type TxHostEntry = struct { Ffamily TCARD8 Fpad TBYTE Flength TCARD16 } type TxCharInfo = struct { FleftSideBearing TINT16 FrightSideBearing TINT16 FcharacterWidth TINT16 Fascent TINT16 Fdescent TINT16 Fattributes TCARD16 } type TxFontProp = struct { Fname TCARD32 Fvalue TCARD32 } type TxTextElt = struct { Flen1 TCARD8 Fdelta TINT8 } type TxColorItem = struct { Fpixel TCARD32 Fred TCARD16 Fgreen TCARD16 Fblue TCARD16 Fflags TCARD8 Fpad TCARD8 } type Txrgb = struct { Fred TCARD16 Fgreen TCARD16 Fblue TCARD16 Fpad TCARD16 } type TKEYCODE = uint8 type TxGenericReply = struct { Ftype1 TBYTE Fdata1 TBYTE FsequenceNumber TCARD16 Flength TCARD32 Fdata00 TCARD32 Fdata01 TCARD32 Fdata02 TCARD32 Fdata03 TCARD32 Fdata04 TCARD32 Fdata05 TCARD32 } type TxGetWindowAttributesReply = struct { Ftype1 TBYTE FbackingStore TCARD8 FsequenceNumber TCARD16 Flength TCARD32 FvisualID TCARD32 Fclass TCARD16 FbitGravity TCARD8 FwinGravity TCARD8 FbackingBitPlanes TCARD32 FbackingPixel TCARD32 FsaveUnder TBOOL FmapInstalled TBOOL FmapState TCARD8 Foverride TBOOL Fcolormap TCARD32 FallEventMasks TCARD32 FyourEventMask TCARD32 FdoNotPropagateMask TCARD16 Fpad TCARD16 } type TxGetGeometryReply = struct { Ftype1 TBYTE Fdepth TCARD8 FsequenceNumber TCARD16 Flength TCARD32 Froot TCARD32 Fx TINT16 Fy TINT16 Fwidth TCARD16 Fheight TCARD16 FborderWidth TCARD16 Fpad1 TCARD16 Fpad2 TCARD32 Fpad3 TCARD32 } type TxQueryTreeReply = struct { Ftype1 TBYTE Fpad1 TBYTE FsequenceNumber TCARD16 Flength TCARD32 Froot TCARD32 Fparent TCARD32 FnChildren TCARD16 Fpad2 TCARD16 Fpad3 TCARD32 Fpad4 TCARD32 Fpad5 TCARD32 } type TxInternAtomReply = struct { Ftype1 TBYTE Fpad1 TBYTE FsequenceNumber TCARD16 Flength TCARD32 Fatom TCARD32 Fpad2 TCARD32 Fpad3 TCARD32 Fpad4 TCARD32 Fpad5 TCARD32 Fpad6 TCARD32 } type TxGetAtomNameReply = struct { Ftype1 TBYTE Fpad1 TBYTE FsequenceNumber TCARD16 Flength TCARD32 FnameLength TCARD16 Fpad2 TCARD16 Fpad3 TCARD32 Fpad4 TCARD32 Fpad5 TCARD32 Fpad6 TCARD32 Fpad7 TCARD32 } type TxGetPropertyReply = struct { Ftype1 TBYTE Fformat TCARD8 FsequenceNumber TCARD16 Flength TCARD32 FpropertyType TCARD32 FbytesAfter TCARD32 FnItems TCARD32 Fpad1 TCARD32 Fpad2 TCARD32 Fpad3 TCARD32 } type TxListPropertiesReply = struct { Ftype1 TBYTE Fpad1 TBYTE FsequenceNumber TCARD16 Flength TCARD32 FnProperties TCARD16 Fpad2 TCARD16 Fpad3 TCARD32 Fpad4 TCARD32 Fpad5 TCARD32 Fpad6 TCARD32 Fpad7 TCARD32 } type TxGetSelectionOwnerReply = struct { Ftype1 TBYTE Fpad1 TBYTE FsequenceNumber TCARD16 Flength TCARD32 Fowner TCARD32 Fpad2 TCARD32 Fpad3 TCARD32 Fpad4 TCARD32 Fpad5 TCARD32 Fpad6 TCARD32 } type TxGrabPointerReply = struct { Ftype1 TBYTE Fstatus TBYTE FsequenceNumber TCARD16 Flength TCARD32 Fpad1 TCARD32 Fpad2 TCARD32 Fpad3 TCARD32 Fpad4 TCARD32 Fpad5 TCARD32 Fpad6 TCARD32 } type TxGrabKeyboardReply = struct { Ftype1 TBYTE Fstatus TBYTE FsequenceNumber TCARD16 Flength TCARD32 Fpad1 TCARD32 Fpad2 TCARD32 Fpad3 TCARD32 Fpad4 TCARD32 Fpad5 TCARD32 Fpad6 TCARD32 } type TxQueryPointerReply = struct { Ftype1 TBYTE FsameScreen TBOOL FsequenceNumber TCARD16 Flength TCARD32 Froot TCARD32 Fchild TCARD32 FrootX TINT16 FrootY TINT16 FwinX TINT16 FwinY TINT16 Fmask TCARD16 Fpad1 TCARD16 Fpad TCARD32 } type TxGetMotionEventsReply = struct { Ftype1 TBYTE Fpad1 TBYTE FsequenceNumber TCARD16 Flength TCARD32 FnEvents TCARD32 Fpad2 TCARD32 Fpad3 TCARD32 Fpad4 TCARD32 Fpad5 TCARD32 Fpad6 TCARD32 } type TxTranslateCoordsReply = struct { Ftype1 TBYTE FsameScreen TBOOL FsequenceNumber TCARD16 Flength TCARD32 Fchild TCARD32 FdstX TINT16 FdstY TINT16 Fpad2 TCARD32 Fpad3 TCARD32 Fpad4 TCARD32 Fpad5 TCARD32 } type TxGetInputFocusReply = struct { Ftype1 TBYTE FrevertTo TCARD8 FsequenceNumber TCARD16 Flength TCARD32 Ffocus TCARD32 Fpad1 TCARD32 Fpad2 TCARD32 Fpad3 TCARD32 Fpad4 TCARD32 Fpad5 TCARD32 } type TxQueryKeymapReply = struct { Ftype1 TBYTE Fpad1 TBYTE FsequenceNumber TCARD16 Flength TCARD32 Fmap1 [32]TBYTE } type TxQueryFontReply = struct { Ftype1 TBYTE Fpad1 TBYTE FsequenceNumber TCARD16 Flength TCARD32 FminBounds TxCharInfo Fwalign1 TCARD32 FmaxBounds TxCharInfo Fwalign2 TCARD32 FminCharOrByte2 TCARD16 FmaxCharOrByte2 TCARD16 FdefaultChar TCARD16 FnFontProps TCARD16 FdrawDirection TCARD8 FminByte1 TCARD8 FmaxByte1 TCARD8 FallCharsExist TBOOL FfontAscent TINT16 FfontDescent TINT16 FnCharInfos TCARD32 } type T_xQueryFontReply = TxQueryFontReply type TxQueryTextExtentsReply = struct { Ftype1 TBYTE FdrawDirection TCARD8 FsequenceNumber TCARD16 Flength TCARD32 FfontAscent TINT16 FfontDescent TINT16 FoverallAscent TINT16 FoverallDescent TINT16 FoverallWidth TINT32 FoverallLeft TINT32 FoverallRight TINT32 Fpad TCARD32 } type TxListFontsReply = struct { Ftype1 TBYTE Fpad1 TBYTE FsequenceNumber TCARD16 Flength TCARD32 FnFonts TCARD16 Fpad2 TCARD16 Fpad3 TCARD32 Fpad4 TCARD32 Fpad5 TCARD32 Fpad6 TCARD32 Fpad7 TCARD32 } type TxListFontsWithInfoReply = struct { Ftype1 TBYTE FnameLength TCARD8 FsequenceNumber TCARD16 Flength TCARD32 FminBounds TxCharInfo Fwalign1 TCARD32 FmaxBounds TxCharInfo Fwalign2 TCARD32 FminCharOrByte2 TCARD16 FmaxCharOrByte2 TCARD16 FdefaultChar TCARD16 FnFontProps TCARD16 FdrawDirection TCARD8 FminByte1 TCARD8 FmaxByte1 TCARD8 FallCharsExist TBOOL FfontAscent TINT16 FfontDescent TINT16 FnReplies TCARD32 } type TxGetFontPathReply = struct { Ftype1 TBYTE Fpad1 TBYTE FsequenceNumber TCARD16 Flength TCARD32 FnPaths TCARD16 Fpad2 TCARD16 Fpad3 TCARD32 Fpad4 TCARD32 Fpad5 TCARD32 Fpad6 TCARD32 Fpad7 TCARD32 } type TxGetImageReply = struct { Ftype1 TBYTE Fdepth TCARD8 FsequenceNumber TCARD16 Flength TCARD32 Fvisual TCARD32 Fpad3 TCARD32 Fpad4 TCARD32 Fpad5 TCARD32 Fpad6 TCARD32 Fpad7 TCARD32 } type TxListInstalledColormapsReply = struct { Ftype1 TBYTE Fpad1 TBYTE FsequenceNumber TCARD16 Flength TCARD32 FnColormaps TCARD16 Fpad2 TCARD16 Fpad3 TCARD32 Fpad4 TCARD32 Fpad5 TCARD32 Fpad6 TCARD32 Fpad7 TCARD32 } type TxAllocColorReply = struct { Ftype1 TBYTE Fpad1 TBYTE FsequenceNumber TCARD16 Flength TCARD32 Fred TCARD16 Fgreen TCARD16 Fblue TCARD16 Fpad2 TCARD16 Fpixel TCARD32 Fpad3 TCARD32 Fpad4 TCARD32 Fpad5 TCARD32 } type TxAllocNamedColorReply = struct { Ftype1 TBYTE Fpad1 TBYTE FsequenceNumber TCARD16 Flength TCARD32 Fpixel TCARD32 FexactRed TCARD16 FexactGreen TCARD16 FexactBlue TCARD16 FscreenRed TCARD16 FscreenGreen TCARD16 FscreenBlue TCARD16 Fpad2 TCARD32 Fpad3 TCARD32 } type TxAllocColorCellsReply = struct { Ftype1 TBYTE Fpad1 TBYTE FsequenceNumber TCARD16 Flength TCARD32 FnPixels TCARD16 FnMasks TCARD16 Fpad3 TCARD32 Fpad4 TCARD32 Fpad5 TCARD32 Fpad6 TCARD32 Fpad7 TCARD32 } type TxAllocColorPlanesReply = struct { Ftype1 TBYTE Fpad1 TBYTE FsequenceNumber TCARD16 Flength TCARD32 FnPixels TCARD16 Fpad2 TCARD16 FredMask TCARD32 FgreenMask TCARD32 FblueMask TCARD32 Fpad3 TCARD32 Fpad4 TCARD32 } type TxQueryColorsReply = struct { Ftype1 TBYTE Fpad1 TBYTE FsequenceNumber TCARD16 Flength TCARD32 FnColors TCARD16 Fpad2 TCARD16 Fpad3 TCARD32 Fpad4 TCARD32 Fpad5 TCARD32 Fpad6 TCARD32 Fpad7 TCARD32 } type TxLookupColorReply = struct { Ftype1 TBYTE Fpad1 TBYTE FsequenceNumber TCARD16 Flength TCARD32 FexactRed TCARD16 FexactGreen TCARD16 FexactBlue TCARD16 FscreenRed TCARD16 FscreenGreen TCARD16 FscreenBlue TCARD16 Fpad3 TCARD32 Fpad4 TCARD32 Fpad5 TCARD32 } type TxQueryBestSizeReply = struct { Ftype1 TBYTE Fpad1 TBYTE FsequenceNumber TCARD16 Flength TCARD32 Fwidth TCARD16 Fheight TCARD16 Fpad3 TCARD32 Fpad4 TCARD32 Fpad5 TCARD32 Fpad6 TCARD32 Fpad7 TCARD32 } type TxQueryExtensionReply = struct { Ftype1 TBYTE Fpad1 TBYTE FsequenceNumber TCARD16 Flength TCARD32 Fpresent TBOOL Fmajor_opcode TCARD8 Ffirst_event TCARD8 Ffirst_error TCARD8 Fpad3 TCARD32 Fpad4 TCARD32 Fpad5 TCARD32 Fpad6 TCARD32 Fpad7 TCARD32 } type TxListExtensionsReply = struct { Ftype1 TBYTE FnExtensions TCARD8 FsequenceNumber TCARD16 Flength TCARD32 Fpad2 TCARD32 Fpad3 TCARD32 Fpad4 TCARD32 Fpad5 TCARD32 Fpad6 TCARD32 Fpad7 TCARD32 } type TxSetMappingReply = struct { Ftype1 TBYTE Fsuccess TCARD8 FsequenceNumber TCARD16 Flength TCARD32 Fpad2 TCARD32 Fpad3 TCARD32 Fpad4 TCARD32 Fpad5 TCARD32 Fpad6 TCARD32 Fpad7 TCARD32 } type TxSetPointerMappingReply = struct { Ftype1 TBYTE Fsuccess TCARD8 FsequenceNumber TCARD16 Flength TCARD32 Fpad2 TCARD32 Fpad3 TCARD32 Fpad4 TCARD32 Fpad5 TCARD32 Fpad6 TCARD32 Fpad7 TCARD32 } type TxSetModifierMappingReply = struct { Ftype1 TBYTE Fsuccess TCARD8 FsequenceNumber TCARD16 Flength TCARD32 Fpad2 TCARD32 Fpad3 TCARD32 Fpad4 TCARD32 Fpad5 TCARD32 Fpad6 TCARD32 Fpad7 TCARD32 } type TxGetPointerMappingReply = struct { Ftype1 TBYTE FnElts TCARD8 FsequenceNumber TCARD16 Flength TCARD32 Fpad2 TCARD32 Fpad3 TCARD32 Fpad4 TCARD32 Fpad5 TCARD32 Fpad6 TCARD32 Fpad7 TCARD32 } type TxGetKeyboardMappingReply = struct { Ftype1 TBYTE FkeySymsPerKeyCode TCARD8 FsequenceNumber TCARD16 Flength TCARD32 Fpad2 TCARD32 Fpad3 TCARD32 Fpad4 TCARD32 Fpad5 TCARD32 Fpad6 TCARD32 Fpad7 TCARD32 } type TxGetModifierMappingReply = struct { Ftype1 TBYTE FnumKeyPerModifier TCARD8 FsequenceNumber TCARD16 Flength TCARD32 Fpad1 TCARD32 Fpad2 TCARD32 Fpad3 TCARD32 Fpad4 TCARD32 Fpad5 TCARD32 Fpad6 TCARD32 } type TxGetKeyboardControlReply = struct { Ftype1 TBYTE FglobalAutoRepeat TBOOL FsequenceNumber TCARD16 Flength TCARD32 FledMask TCARD32 FkeyClickPercent TCARD8 FbellPercent TCARD8 FbellPitch TCARD16 FbellDuration TCARD16 Fpad TCARD16 Fmap1 [32]TBYTE } type TxGetPointerControlReply = struct { Ftype1 TBYTE Fpad1 TBYTE FsequenceNumber TCARD16 Flength TCARD32 FaccelNumerator TCARD16 FaccelDenominator TCARD16 Fthreshold TCARD16 Fpad2 TCARD16 Fpad3 TCARD32 Fpad4 TCARD32 Fpad5 TCARD32 Fpad6 TCARD32 } type TxGetScreenSaverReply = struct { Ftype1 TBYTE Fpad1 TBYTE FsequenceNumber TCARD16 Flength TCARD32 Ftimeout TCARD16 Finterval TCARD16 FpreferBlanking TBOOL FallowExposures TBOOL Fpad2 TCARD16 Fpad3 TCARD32 Fpad4 TCARD32 Fpad5 TCARD32 Fpad6 TCARD32 } type TxListHostsReply = struct { Ftype1 TBYTE Fenabled TBOOL FsequenceNumber TCARD16 Flength TCARD32 FnHosts TCARD16 Fpad1 TCARD16 Fpad3 TCARD32 Fpad4 TCARD32 Fpad5 TCARD32 Fpad6 TCARD32 Fpad7 TCARD32 } type TxError = struct { Ftype1 TBYTE FerrorCode TBYTE FsequenceNumber TCARD16 FresourceID TCARD32 FminorCode TCARD16 FmajorCode TCARD8 Fpad1 TBYTE Fpad3 TCARD32 Fpad4 TCARD32 Fpad5 TCARD32 Fpad6 TCARD32 Fpad7 TCARD32 } type TxEvent = struct { Fu struct { FkeyButtonPointer [0]struct { Fpad00 TCARD32 Ftime TCARD32 Froot TCARD32 Fevent TCARD32 Fchild TCARD32 FrootX TINT16 FrootY TINT16 FeventX TINT16 FeventY TINT16 Fstate TKeyButMask FsameScreen TBOOL Fpad1 TBYTE } FenterLeave [0]struct { Fpad00 TCARD32 Ftime TCARD32 Froot TCARD32 Fevent TCARD32 Fchild TCARD32 FrootX TINT16 FrootY TINT16 FeventX TINT16 FeventY TINT16 Fstate TKeyButMask Fmode TBYTE Fflags TBYTE } Ffocus [0]struct { Fpad00 TCARD32 Fwindow TCARD32 Fmode TBYTE Fpad1 TBYTE Fpad2 TBYTE Fpad3 TBYTE } Fexpose [0]struct { Fpad00 TCARD32 Fwindow TCARD32 Fx TCARD16 Fy TCARD16 Fwidth TCARD16 Fheight TCARD16 Fcount TCARD16 Fpad2 TCARD16 } FgraphicsExposure [0]struct { Fpad00 TCARD32 Fdrawable TCARD32 Fx TCARD16 Fy TCARD16 Fwidth TCARD16 Fheight TCARD16 FminorEvent TCARD16 Fcount TCARD16 FmajorEvent TBYTE Fpad1 TBYTE Fpad2 TBYTE Fpad3 TBYTE } FnoExposure [0]struct { Fpad00 TCARD32 Fdrawable TCARD32 FminorEvent TCARD16 FmajorEvent TBYTE Fbpad TBYTE } Fvisibility [0]struct { Fpad00 TCARD32 Fwindow TCARD32 Fstate TCARD8 Fpad1 TBYTE Fpad2 TBYTE Fpad3 TBYTE } FcreateNotify [0]struct { Fpad00 TCARD32 Fparent TCARD32 Fwindow TCARD32 Fx TINT16 Fy TINT16 Fwidth TCARD16 Fheight TCARD16 FborderWidth TCARD16 Foverride TBOOL Fbpad TBYTE } FdestroyNotify [0]struct { Fpad00 TCARD32 Fevent TCARD32 Fwindow TCARD32 } FunmapNotify [0]struct { Fpad00 TCARD32 Fevent TCARD32 Fwindow TCARD32 FfromConfigure TBOOL Fpad1 TBYTE Fpad2 TBYTE Fpad3 TBYTE } FmapNotify [0]struct { Fpad00 TCARD32 Fevent TCARD32 Fwindow TCARD32 Foverride TBOOL Fpad1 TBYTE Fpad2 TBYTE Fpad3 TBYTE } FmapRequest [0]struct { Fpad00 TCARD32 Fparent TCARD32 Fwindow TCARD32 } Freparent [0]struct { Fpad00 TCARD32 Fevent TCARD32 Fwindow TCARD32 Fparent TCARD32 Fx TINT16 Fy TINT16 Foverride TBOOL Fpad1 TBYTE Fpad2 TBYTE Fpad3 TBYTE } FconfigureNotify [0]struct { Fpad00 TCARD32 Fevent TCARD32 Fwindow TCARD32 FaboveSibling TCARD32 Fx TINT16 Fy TINT16 Fwidth TCARD16 Fheight TCARD16 FborderWidth TCARD16 Foverride TBOOL Fbpad TBYTE } FconfigureRequest [0]struct { Fpad00 TCARD32 Fparent TCARD32 Fwindow TCARD32 Fsibling TCARD32 Fx TINT16 Fy TINT16 Fwidth TCARD16 Fheight TCARD16 FborderWidth TCARD16 FvalueMask TCARD16 Fpad1 TCARD32 } Fgravity [0]struct { Fpad00 TCARD32 Fevent TCARD32 Fwindow TCARD32 Fx TINT16 Fy TINT16 Fpad1 TCARD32 Fpad2 TCARD32 Fpad3 TCARD32 Fpad4 TCARD32 } FresizeRequest [0]struct { Fpad00 TCARD32 Fwindow TCARD32 Fwidth TCARD16 Fheight TCARD16 } Fcirculate [0]struct { Fpad00 TCARD32 Fevent TCARD32 Fwindow TCARD32 Fparent TCARD32 Fplace TBYTE Fpad1 TBYTE Fpad2 TBYTE Fpad3 TBYTE } Fproperty [0]struct { Fpad00 TCARD32 Fwindow TCARD32 Fatom TCARD32 Ftime TCARD32 Fstate TBYTE Fpad1 TBYTE Fpad2 TCARD16 } FselectionClear [0]struct { Fpad00 TCARD32 Ftime TCARD32 Fwindow TCARD32 Fatom TCARD32 } FselectionRequest [0]struct { Fpad00 TCARD32 Ftime TCARD32 Fowner TCARD32 Frequestor TCARD32 Fselection TCARD32 Ftarget TCARD32 Fproperty TCARD32 } FselectionNotify [0]struct { Fpad00 TCARD32 Ftime TCARD32 Frequestor TCARD32 Fselection TCARD32 Ftarget TCARD32 Fproperty TCARD32 } Fcolormap [0]struct { Fpad00 TCARD32 Fwindow TCARD32 Fcolormap TCARD32 Fnew1 TBOOL Fstate TBYTE Fpad1 TBYTE Fpad2 TBYTE } FmappingNotify [0]struct { Fpad00 TCARD32 Frequest TCARD8 FfirstKeyCode TCARD8 Fcount TCARD8 Fpad1 TBYTE } FclientMessage [0]struct { Fpad00 TCARD32 Fwindow TCARD32 Fu struct { Fs [0]struct { Ftype1 TCARD32 Fshorts0 TINT16 Fshorts1 TINT16 Fshorts2 TINT16 Fshorts3 TINT16 Fshorts4 TINT16 Fshorts5 TINT16 Fshorts6 TINT16 Fshorts7 TINT16 Fshorts8 TINT16 Fshorts9 TINT16 } Fb [0]struct { Ftype1 TCARD32 Fbytes [20]TINT8 } Fl struct { Ftype1 TCARD32 Flongs0 TINT32 Flongs1 TINT32 Flongs2 TINT32 Flongs3 TINT32 Flongs4 TINT32 } } } Fu struct { Ftype1 TBYTE Fdetail TBYTE FsequenceNumber TCARD16 } F__ccgo_pad26 [28]byte } } type T_xEvent = TxEvent type TxGenericEvent = struct { Ftype1 TBYTE Fextension TCARD8 FsequenceNumber TCARD16 Flength TCARD32 Fevtype TCARD16 Fpad2 TCARD16 Fpad3 TCARD32 Fpad4 TCARD32 Fpad5 TCARD32 Fpad6 TCARD32 Fpad7 TCARD32 } type TxKeymapEvent = struct { Ftype1 TBYTE Fmap1 [31]TBYTE } type TxReply = struct { Fgeom [0]TxGetGeometryReply Ftree [0]TxQueryTreeReply Fatom [0]TxInternAtomReply FatomName [0]TxGetAtomNameReply Fproperty [0]TxGetPropertyReply FlistProperties [0]TxListPropertiesReply Fselection [0]TxGetSelectionOwnerReply FgrabPointer [0]TxGrabPointerReply FgrabKeyboard [0]TxGrabKeyboardReply Fpointer [0]TxQueryPointerReply FmotionEvents [0]TxGetMotionEventsReply Fcoords [0]TxTranslateCoordsReply FinputFocus [0]TxGetInputFocusReply FtextExtents [0]TxQueryTextExtentsReply Ffonts [0]TxListFontsReply FfontPath [0]TxGetFontPathReply Fimage [0]TxGetImageReply Fcolormaps [0]TxListInstalledColormapsReply FallocColor [0]TxAllocColorReply FallocNamedColor [0]TxAllocNamedColorReply FcolorCells [0]TxAllocColorCellsReply FcolorPlanes [0]TxAllocColorPlanesReply Fcolors [0]TxQueryColorsReply FlookupColor [0]TxLookupColorReply FbestSize [0]TxQueryBestSizeReply Fextension [0]TxQueryExtensionReply Fextensions [0]TxListExtensionsReply FsetModifierMapping [0]TxSetModifierMappingReply FgetModifierMapping [0]TxGetModifierMappingReply FsetPointerMapping [0]TxSetPointerMappingReply FgetKeyboardMapping [0]TxGetKeyboardMappingReply FgetPointerMapping [0]TxGetPointerMappingReply FpointerControl [0]TxGetPointerControlReply FscreenSaver [0]TxGetScreenSaverReply Fhosts [0]TxListHostsReply Ferror1 [0]TxError Fevent [0]TxEvent Fgeneric TxGenericReply } type TxReq = struct { FreqType TCARD8 Fdata TCARD8 Flength TCARD16 } type T_xReq = TxReq type TxResourceReq = struct { FreqType TCARD8 Fpad TBYTE Flength TCARD16 Fid TCARD32 } type TxCreateWindowReq = struct { FreqType TCARD8 Fdepth TCARD8 Flength TCARD16 Fwid TCARD32 Fparent TCARD32 Fx TINT16 Fy TINT16 Fwidth TCARD16 Fheight TCARD16 FborderWidth TCARD16 Fclass TCARD16 Fvisual TCARD32 Fmask TCARD32 } type TxChangeWindowAttributesReq = struct { FreqType TCARD8 Fpad TBYTE Flength TCARD16 Fwindow TCARD32 FvalueMask TCARD32 } type TxChangeSaveSetReq = struct { FreqType TCARD8 Fmode TBYTE Flength TCARD16 Fwindow TCARD32 } type TxReparentWindowReq = struct { FreqType TCARD8 Fpad TBYTE Flength TCARD16 Fwindow TCARD32 Fparent TCARD32 Fx TINT16 Fy TINT16 } type TxConfigureWindowReq = struct { FreqType TCARD8 Fpad TCARD8 Flength TCARD16 Fwindow TCARD32 Fmask TCARD16 Fpad2 TCARD16 } type TxCirculateWindowReq = struct { FreqType TCARD8 Fdirection TCARD8 Flength TCARD16 Fwindow TCARD32 } type TxInternAtomReq = struct { FreqType TCARD8 FonlyIfExists TBOOL Flength TCARD16 Fnbytes TCARD16 Fpad TCARD16 } type TxChangePropertyReq = struct { FreqType TCARD8 Fmode TCARD8 Flength TCARD16 Fwindow TCARD32 Fproperty TCARD32 Ftype1 TCARD32 Fformat TCARD8 Fpad [3]TBYTE FnUnits TCARD32 } type TxDeletePropertyReq = struct { FreqType TCARD8 Fpad TBYTE Flength TCARD16 Fwindow TCARD32 Fproperty TCARD32 } type TxGetPropertyReq = struct { FreqType TCARD8 Fdelete1 TBOOL Flength TCARD16 Fwindow TCARD32 Fproperty TCARD32 Ftype1 TCARD32 FlongOffset TCARD32 FlongLength TCARD32 } type TxSetSelectionOwnerReq = struct { FreqType TCARD8 Fpad TBYTE Flength TCARD16 Fwindow TCARD32 Fselection TCARD32 Ftime TCARD32 } type TxConvertSelectionReq = struct { FreqType TCARD8 Fpad TBYTE Flength TCARD16 Frequestor TCARD32 Fselection TCARD32 Ftarget TCARD32 Fproperty TCARD32 Ftime TCARD32 } type TxSendEventReq = struct { FreqType TCARD8 Fpropagate TBOOL Flength TCARD16 Fdestination TCARD32 FeventMask TCARD32 Fevent TxEvent } type TxGrabPointerReq = struct { FreqType TCARD8 FownerEvents TBOOL Flength TCARD16 FgrabWindow TCARD32 FeventMask TCARD16 FpointerMode TBYTE FkeyboardMode TBYTE FconfineTo TCARD32 Fcursor TCARD32 Ftime TCARD32 } type TxGrabButtonReq = struct { FreqType TCARD8 FownerEvents TBOOL Flength TCARD16 FgrabWindow TCARD32 FeventMask TCARD16 FpointerMode TBYTE FkeyboardMode TBYTE FconfineTo TCARD32 Fcursor TCARD32 Fbutton TCARD8 Fpad TBYTE Fmodifiers TCARD16 } type TxUngrabButtonReq = struct { FreqType TCARD8 Fbutton TCARD8 Flength TCARD16 FgrabWindow TCARD32 Fmodifiers TCARD16 Fpad TCARD16 } type TxChangeActivePointerGrabReq = struct { FreqType TCARD8 Fpad TBYTE Flength TCARD16 Fcursor TCARD32 Ftime TCARD32 FeventMask TCARD16 Fpad2 TCARD16 } type TxGrabKeyboardReq = struct { FreqType TCARD8 FownerEvents TBOOL Flength TCARD16 FgrabWindow TCARD32 Ftime TCARD32 FpointerMode TBYTE FkeyboardMode TBYTE Fpad TCARD16 } type TxGrabKeyReq = struct { FreqType TCARD8 FownerEvents TBOOL Flength TCARD16 FgrabWindow TCARD32 Fmodifiers TCARD16 Fkey TCARD8 FpointerMode TBYTE FkeyboardMode TBYTE Fpad1 TBYTE Fpad2 TBYTE Fpad3 TBYTE } type TxUngrabKeyReq = struct { FreqType TCARD8 Fkey TCARD8 Flength TCARD16 FgrabWindow TCARD32 Fmodifiers TCARD16 Fpad TCARD16 } type TxAllowEventsReq = struct { FreqType TCARD8 Fmode TCARD8 Flength TCARD16 Ftime TCARD32 } type TxGetMotionEventsReq = struct { FreqType TCARD8 Fpad TBYTE Flength TCARD16 Fwindow TCARD32 Fstart TCARD32 Fstop TCARD32 } type TxTranslateCoordsReq = struct { FreqType TCARD8 Fpad TBYTE Flength TCARD16 FsrcWid TCARD32 FdstWid TCARD32 FsrcX TINT16 FsrcY TINT16 } type TxWarpPointerReq = struct { FreqType TCARD8 Fpad TBYTE Flength TCARD16 FsrcWid TCARD32 FdstWid TCARD32 FsrcX TINT16 FsrcY TINT16 FsrcWidth TCARD16 FsrcHeight TCARD16 FdstX TINT16 FdstY TINT16 } type TxSetInputFocusReq = struct { FreqType TCARD8 FrevertTo TCARD8 Flength TCARD16 Ffocus TCARD32 Ftime TCARD32 } type TxOpenFontReq = struct { FreqType TCARD8 Fpad TBYTE Flength TCARD16 Ffid TCARD32 Fnbytes TCARD16 Fpad1 TBYTE Fpad2 TBYTE } type TxQueryTextExtentsReq = struct { FreqType TCARD8 FoddLength TBOOL Flength TCARD16 Ffid TCARD32 } type TxListFontsReq = struct { FreqType TCARD8 Fpad TBYTE Flength TCARD16 FmaxNames TCARD16 Fnbytes TCARD16 } type TxListFontsWithInfoReq = struct { FreqType TCARD8 Fpad TBYTE Flength TCARD16 FmaxNames TCARD16 Fnbytes TCARD16 } type TxSetFontPathReq = struct { FreqType TCARD8 Fpad TBYTE Flength TCARD16 FnFonts TCARD16 Fpad1 TBYTE Fpad2 TBYTE } type TxCreatePixmapReq = struct { FreqType TCARD8 Fdepth TCARD8 Flength TCARD16 Fpid TCARD32 Fdrawable TCARD32 Fwidth TCARD16 Fheight TCARD16 } type TxCreateGCReq = struct { FreqType TCARD8 Fpad TBYTE Flength TCARD16 Fgc TCARD32 Fdrawable TCARD32 Fmask TCARD32 } type TxChangeGCReq = struct { FreqType TCARD8 Fpad TBYTE Flength TCARD16 Fgc TCARD32 Fmask TCARD32 } type TxCopyGCReq = struct { FreqType TCARD8 Fpad TBYTE Flength TCARD16 FsrcGC TCARD32 FdstGC TCARD32 Fmask TCARD32 } type TxSetDashesReq = struct { FreqType TCARD8 Fpad TBYTE Flength TCARD16 Fgc TCARD32 FdashOffset TCARD16 FnDashes TCARD16 } type TxSetClipRectanglesReq = struct { FreqType TCARD8 Fordering TBYTE Flength TCARD16 Fgc TCARD32 FxOrigin TINT16 FyOrigin TINT16 } type TxClearAreaReq = struct { FreqType TCARD8 Fexposures TBOOL Flength TCARD16 Fwindow TCARD32 Fx TINT16 Fy TINT16 Fwidth TCARD16 Fheight TCARD16 } type TxCopyAreaReq = struct { FreqType TCARD8 Fpad TBYTE Flength TCARD16 FsrcDrawable TCARD32 FdstDrawable TCARD32 Fgc TCARD32 FsrcX TINT16 FsrcY TINT16 FdstX TINT16 FdstY TINT16 Fwidth TCARD16 Fheight TCARD16 } type TxCopyPlaneReq = struct { FreqType TCARD8 Fpad TBYTE Flength TCARD16 FsrcDrawable TCARD32 FdstDrawable TCARD32 Fgc TCARD32 FsrcX TINT16 FsrcY TINT16 FdstX TINT16 FdstY TINT16 Fwidth TCARD16 Fheight TCARD16 FbitPlane TCARD32 } type TxPolyPointReq = struct { FreqType TCARD8 FcoordMode TBYTE Flength TCARD16 Fdrawable TCARD32 Fgc TCARD32 } type TxPolyLineReq = struct { FreqType TCARD8 FcoordMode TBYTE Flength TCARD16 Fdrawable TCARD32 Fgc TCARD32 } type TxPolySegmentReq = struct { FreqType TCARD8 Fpad TBYTE Flength TCARD16 Fdrawable TCARD32 Fgc TCARD32 } type TxPolyArcReq = struct { FreqType TCARD8 Fpad TBYTE Flength TCARD16 Fdrawable TCARD32 Fgc TCARD32 } type TxPolyRectangleReq = struct { FreqType TCARD8 Fpad TBYTE Flength TCARD16 Fdrawable TCARD32 Fgc TCARD32 } type TxPolyFillRectangleReq = struct { FreqType TCARD8 Fpad TBYTE Flength TCARD16 Fdrawable TCARD32 Fgc TCARD32 } type TxPolyFillArcReq = struct { FreqType TCARD8 Fpad TBYTE Flength TCARD16 Fdrawable TCARD32 Fgc TCARD32 } type TxFillPolyReq = struct { FreqType TCARD8 Fpad TBYTE Flength TCARD16 Fdrawable TCARD32 Fgc TCARD32 Fshape TBYTE FcoordMode TBYTE Fpad1 TCARD16 } type T_FillPolyReq = TxFillPolyReq type TxPutImageReq = struct { FreqType TCARD8 Fformat TCARD8 Flength TCARD16 Fdrawable TCARD32 Fgc TCARD32 Fwidth TCARD16 Fheight TCARD16 FdstX TINT16 FdstY TINT16 FleftPad TCARD8 Fdepth TCARD8 Fpad TCARD16 } type T_PutImageReq = TxPutImageReq type TxGetImageReq = struct { FreqType TCARD8 Fformat TCARD8 Flength TCARD16 Fdrawable TCARD32 Fx TINT16 Fy TINT16 Fwidth TCARD16 Fheight TCARD16 FplaneMask TCARD32 } type TxPolyTextReq = struct { FreqType TCARD8 Fpad TCARD8 Flength TCARD16 Fdrawable TCARD32 Fgc TCARD32 Fx TINT16 Fy TINT16 } type TxPolyText8Req = struct { FreqType TCARD8 Fpad TCARD8 Flength TCARD16 Fdrawable TCARD32 Fgc TCARD32 Fx TINT16 Fy TINT16 } type TxPolyText16Req = struct { FreqType TCARD8 Fpad TCARD8 Flength TCARD16 Fdrawable TCARD32 Fgc TCARD32 Fx TINT16 Fy TINT16 } type TxImageTextReq = struct { FreqType TCARD8 FnChars TBYTE Flength TCARD16 Fdrawable TCARD32 Fgc TCARD32 Fx TINT16 Fy TINT16 } type TxImageText8Req = struct { FreqType TCARD8 FnChars TBYTE Flength TCARD16 Fdrawable TCARD32 Fgc TCARD32 Fx TINT16 Fy TINT16 } type TxImageText16Req = struct { FreqType TCARD8 FnChars TBYTE Flength TCARD16 Fdrawable TCARD32 Fgc TCARD32 Fx TINT16 Fy TINT16 } type TxCreateColormapReq = struct { FreqType TCARD8 Falloc TBYTE Flength TCARD16 Fmid TCARD32 Fwindow TCARD32 Fvisual TCARD32 } type TxCopyColormapAndFreeReq = struct { FreqType TCARD8 Fpad TBYTE Flength TCARD16 Fmid TCARD32 FsrcCmap TCARD32 } type TxAllocColorReq = struct { FreqType TCARD8 Fpad TBYTE Flength TCARD16 Fcmap TCARD32 Fred TCARD16 Fgreen TCARD16 Fblue TCARD16 Fpad2 TCARD16 } type TxAllocNamedColorReq = struct { FreqType TCARD8 Fpad TBYTE Flength TCARD16 Fcmap TCARD32 Fnbytes TCARD16 Fpad1 TBYTE Fpad2 TBYTE } type TxAllocColorCellsReq = struct { FreqType TCARD8 Fcontiguous TBOOL Flength TCARD16 Fcmap TCARD32 Fcolors TCARD16 Fplanes TCARD16 } type TxAllocColorPlanesReq = struct { FreqType TCARD8 Fcontiguous TBOOL Flength TCARD16 Fcmap TCARD32 Fcolors TCARD16 Fred TCARD16 Fgreen TCARD16 Fblue TCARD16 } type TxFreeColorsReq = struct { FreqType TCARD8 Fpad TBYTE Flength TCARD16 Fcmap TCARD32 FplaneMask TCARD32 } type TxStoreColorsReq = struct { FreqType TCARD8 Fpad TBYTE Flength TCARD16 Fcmap TCARD32 } type TxStoreNamedColorReq = struct { FreqType TCARD8 Fflags TCARD8 Flength TCARD16 Fcmap TCARD32 Fpixel TCARD32 Fnbytes TCARD16 Fpad1 TBYTE Fpad2 TBYTE } type TxQueryColorsReq = struct { FreqType TCARD8 Fpad TBYTE Flength TCARD16 Fcmap TCARD32 } type TxLookupColorReq = struct { FreqType TCARD8 Fpad TBYTE Flength TCARD16 Fcmap TCARD32 Fnbytes TCARD16 Fpad1 TBYTE Fpad2 TBYTE } type TxCreateCursorReq = struct { FreqType TCARD8 Fpad TBYTE Flength TCARD16 Fcid TCARD32 Fsource TCARD32 Fmask TCARD32 FforeRed TCARD16 FforeGreen TCARD16 FforeBlue TCARD16 FbackRed TCARD16 FbackGreen TCARD16 FbackBlue TCARD16 Fx TCARD16 Fy TCARD16 } type TxCreateGlyphCursorReq = struct { FreqType TCARD8 Fpad TBYTE Flength TCARD16 Fcid TCARD32 Fsource TCARD32 Fmask TCARD32 FsourceChar TCARD16 FmaskChar TCARD16 FforeRed TCARD16 FforeGreen TCARD16 FforeBlue TCARD16 FbackRed TCARD16 FbackGreen TCARD16 FbackBlue TCARD16 } type TxRecolorCursorReq = struct { FreqType TCARD8 Fpad TBYTE Flength TCARD16 Fcursor TCARD32 FforeRed TCARD16 FforeGreen TCARD16 FforeBlue TCARD16 FbackRed TCARD16 FbackGreen TCARD16 FbackBlue TCARD16 } type TxQueryBestSizeReq = struct { FreqType TCARD8 Fclass TCARD8 Flength TCARD16 Fdrawable TCARD32 Fwidth TCARD16 Fheight TCARD16 } type TxQueryExtensionReq = struct { FreqType TCARD8 Fpad TBYTE Flength TCARD16 Fnbytes TCARD16 Fpad1 TBYTE Fpad2 TBYTE } type TxSetModifierMappingReq = struct { FreqType TCARD8 FnumKeyPerModifier TCARD8 Flength TCARD16 } type TxSetPointerMappingReq = struct { FreqType TCARD8 FnElts TCARD8 Flength TCARD16 } type TxGetKeyboardMappingReq = struct { FreqType TCARD8 Fpad TBYTE Flength TCARD16 FfirstKeyCode TCARD8 Fcount TCARD8 Fpad1 TCARD16 } type TxChangeKeyboardMappingReq = struct { FreqType TCARD8 FkeyCodes TCARD8 Flength TCARD16 FfirstKeyCode TCARD8 FkeySymsPerKeyCode TCARD8 Fpad1 TCARD16 } type TxChangeKeyboardControlReq = struct { FreqType TCARD8 Fpad TBYTE Flength TCARD16 Fmask TCARD32 } type TxBellReq = struct { FreqType TCARD8 Fpercent TINT8 Flength TCARD16 } type TxChangePointerControlReq = struct { FreqType TCARD8 Fpad TBYTE Flength TCARD16 FaccelNum TINT16 FaccelDenum TINT16 Fthreshold TINT16 FdoAccel TBOOL FdoThresh TBOOL } type TxSetScreenSaverReq = struct { FreqType TCARD8 Fpad TBYTE Flength TCARD16 Ftimeout TINT16 Finterval TINT16 FpreferBlank TBYTE FallowExpose TBYTE Fpad2 TCARD16 } type TxChangeHostsReq = struct { FreqType TCARD8 Fmode TBYTE Flength TCARD16 FhostFamily TCARD8 Fpad TBYTE FhostLength TCARD16 } type TxListHostsReq = struct { FreqType TCARD8 Fpad TBYTE Flength TCARD16 } type TxChangeModeReq = struct { FreqType TCARD8 Fmode TBYTE Flength TCARD16 } type TxSetAccessControlReq = struct { FreqType TCARD8 Fmode TBYTE Flength TCARD16 } type TxSetCloseDownModeReq = struct { FreqType TCARD8 Fmode TBYTE Flength TCARD16 } type TxForceScreenSaverReq = struct { FreqType TCARD8 Fmode TBYTE Flength TCARD16 } type TxRotatePropertiesReq = struct { FreqType TCARD8 Fpad TBYTE Flength TCARD16 Fwindow TCARD32 FnAtoms TCARD16 FnPositions TINT16 } type TXrmQuark = int32 type TXrmQuarkList = uintptr type TXrmString = uintptr type TXrmBinding = int32 const XrmBindTightly = 0 const XrmBindLoosely = 1 type TXrmBindingList = uintptr type TXrmName = int32 type TXrmNameList = uintptr type TXrmClass = int32 type TXrmClassList = uintptr type TXrmRepresentation = int32 type TXrmValue = struct { Fsize uint32 Faddr TXPointer } type TXrmValuePtr = uintptr type TXrmHashBucket = uintptr type TXrmHashTable = uintptr type TXrmDatabase = uintptr type TXrmOptionKind = int32 const XrmoptionNoArg = 0 const XrmoptionIsArg = 1 const XrmoptionStickyArg = 2 const XrmoptionSepArg = 3 const XrmoptionResArg = 4 const XrmoptionSkipArg = 5 const XrmoptionSkipLine = 6 const XrmoptionSkipNArgs = 7 type TXrmOptionDescRec = struct { Foption uintptr Fspecifier uintptr FargKind TXrmOptionKind Fvalue TXPointer } type TXrmOptionDescList = uintptr type TXSizeHints = struct { Fflags int64 Fx int32 Fy int32 Fwidth int32 Fheight int32 Fmin_width int32 Fmin_height int32 Fmax_width int32 Fmax_height int32 Fwidth_inc int32 Fheight_inc int32 Fmin_aspect struct { Fx int32 Fy int32 } Fmax_aspect struct { Fx int32 Fy int32 } Fbase_width int32 Fbase_height int32 Fwin_gravity int32 } type TXWMHints = struct { Fflags int64 Finput int32 Finitial_state int32 Ficon_pixmap TPixmap Ficon_window TWindow Ficon_x int32 Ficon_y int32 Ficon_mask TPixmap Fwindow_group TXID } type TXTextProperty = struct { Fvalue uintptr Fencoding TAtom Fformat int32 Fnitems uint64 } type TXICCEncodingStyle = int32 const XStringStyle = 0 const XCompoundTextStyle = 1 const XTextStyle = 2 const XStdICCTextStyle = 3 const XUTF8StringStyle = 4 type TXIconSize = struct { Fmin_width int32 Fmin_height int32 Fmax_width int32 Fmax_height int32 Fwidth_inc int32 Fheight_inc int32 } type TXClassHint = struct { Fres_name uintptr Fres_class uintptr } type TXComposeStatus = struct { Fcompose_ptr TXPointer Fchars_matched int32 } type T_XComposeStatus = TXComposeStatus type TRegion = uintptr type TXVisualInfo = struct { Fvisual uintptr Fvisualid TVisualID Fscreen int32 Fdepth int32 Fclass int32 Fred_mask uint64 Fgreen_mask uint64 Fblue_mask uint64 Fcolormap_size int32 Fbits_per_rgb int32 } type TXStandardColormap = struct { Fcolormap TColormap Fred_max uint64 Fred_mult uint64 Fgreen_max uint64 Fgreen_mult uint64 Fblue_max uint64 Fblue_mult uint64 Fbase_pixel uint64 Fvisualid TVisualID Fkillid TXID } type TXContext = int32 type TXAfterFunction = uintptr type TTkIntXlibStubs = struct { Fmagic int32 Fhooks uintptr } type Tdiv_t = struct { Fquot int32 Frem int32 } type Tldiv_t = struct { Fquot int64 Frem int64 } type Tlldiv_t = struct { Fquot int64 Frem int64 } type TTkpCursor = uintptr type TTkBindInfo = uintptr type TTkBusy = uintptr type TTkCursor = struct { Fcursor TTk_Cursor Fdisplay uintptr FresourceRefCount TTcl_Size FobjRefCount TTcl_Size FotherTable uintptr FhashPtr uintptr FidHashPtr uintptr FnextPtr uintptr } type TTkCaret = struct { FwinPtr uintptr Fx int32 Fy int32 Fheight int32 } type TTkLockUsage = int32 type TkLockUsage = int32 const LU_IGNORE = 0 const LU_CAPS = 1 const LU_SHIFT = 2 type TTkDisplay = struct { Fdisplay uintptr FnextPtr uintptr Fname uintptr FlastEventTime TTime FborderInit int32 FborderTable TTcl_HashTable FatomInit int32 FnameTable TTcl_HashTable FatomTable TTcl_HashTable FbindInfoStale int32 FmodeModMask uint32 FmetaModMask uint32 FaltModMask uint32 FlockUsage TTkLockUsage FnumModKeyCodes TTcl_Size FmodKeyCodes uintptr FbitmapInit int32 FbitmapAutoNumber int32 FbitmapNameTable TTcl_HashTable FbitmapIdTable TTcl_HashTable FbitmapDataTable TTcl_HashTable FnumIdSearches int32 FnumSlowSearches int32 FcolorInit int32 FstressPtr uintptr FcolorNameTable TTcl_HashTable FcolorValueTable TTcl_HashTable FcursorInit int32 FcursorNameTable TTcl_HashTable FcursorDataTable TTcl_HashTable FcursorIdTable TTcl_HashTable FcursorString [20]uint8 FcursorFont TFont FerrorPtr uintptr FdeleteCount TTcl_Size FdelayedMotionPtr uintptr FfocusDebug int32 FimplicitWinPtr uintptr FfocusPtr uintptr FgcValueTable TTcl_HashTable FgcIdTable TTcl_HashTable FgcInit int32 FmaintainHashTable TTcl_HashTable FgeomInit int32 FuidTable TTcl_HashTable FuidInit int32 FgrabWinPtr uintptr FeventualGrabWinPtr uintptr FbuttonWinPtr uintptr FserverWinPtr uintptr FfirstGrabEventPtr uintptr FlastGrabEventPtr uintptr FgrabFlags int32 FgridInit int32 FgridHashTable TTcl_HashTable FimageId int32 FpostCommandGeneration int32 FpackInit int32 FpackerHashTable TTcl_HashTable FplaceInit int32 FcontainerTable TTcl_HashTable FcontentTable TTcl_HashTable FselectionInfoPtr uintptr FmultipleAtom TAtom FincrAtom TAtom FtargetsAtom TAtom FtimestampAtom TAtom FtextAtom TAtom FcompoundTextAtom TAtom FapplicationAtom TAtom FwindowAtom TAtom FclipboardAtom TAtom Futf8Atom TAtom FatomPairAtom TAtom FclipWindow TTk_Window FclipboardActive int32 FclipboardAppPtr uintptr FclipTargetPtr uintptr FcommTkwin TTk_Window FcommProperty TAtom FregistryProperty TAtom FappNameProperty TAtom FfirstWmPtr uintptr FforegroundWmPtr uintptr FcmapPtr uintptr FinputMethod TXIM FinputStyle TXIMStyle FinputXfs TXFontSet FwinTable TTcl_HashTable FrefCount TTcl_Size FwarpWindow TTk_Window FwarpMainwin TTk_Window FwarpX int32 FwarpY int32 Fflags uint32 Fcaret TTkCaret FiconDataSize int32 FiconDataPtr uintptr FximGeneration int32 } type TTkErrorHandler = struct { FdispPtr uintptr FfirstRequest uint64 FlastRequest uint64 Ferror1 int32 Frequest int32 FminorCode int32 FerrorProc uintptr FclientData uintptr FnextPtr uintptr } type TTkEventHandler = struct { Fmask uint64 Fproc uintptr FclientData uintptr FnextPtr uintptr } type TTkMainInfo = struct { FrefCount TTcl_Size FwinPtr uintptr Finterp uintptr FnameTable TTcl_HashTable FdeletionEpoch Tsize_t FbindingTable TTk_BindingTable FbindInfo TTkBindInfo FfontInfoPtr uintptr FtlFocusPtr uintptr FdisplayFocusPtr uintptr FoptionRootPtr uintptr FimageTable TTcl_HashTable FstrictMotif int32 FalwaysShowSelection int32 FnextPtr uintptr FbusyTable TTcl_HashTable FtclUpdateObjProc uintptr FtclUpdateObjProc2 uintptr FttkNbTabsStickBit uint32 FtroughInnerX int32 FtroughInnerY int32 FtroughInnerWidth int32 FtroughInnerHeight int32 } type TTkPredefBitmap = struct { Fsource uintptr Fwidth int32 Fheight int32 Fnative int32 } type TTkWindow = struct { Fdisplay uintptr FdispPtr uintptr FscreenNum int32 Fvisual uintptr Fdepth int32 Fwindow TWindow FchildList uintptr FlastChildPtr uintptr FparentPtr uintptr FnextPtr uintptr FmainPtr uintptr FpathName uintptr FnameUid TTk_Uid FclassUid TTk_Uid Fchanges TXWindowChanges FdirtyChanges uint32 Fatts TXSetWindowAttributes FdirtyAtts uint64 Fflags uint32 FhandlerList uintptr FinputContext TXIC FtagPtr uintptr FnumTags TTcl_Size FoptionLevel TTcl_Size FselHandlerList uintptr FgeomMgrPtr uintptr FgeomData uintptr FreqWidth int32 FreqHeight int32 FinternalBorderLeft int32 FwmInfoPtr uintptr FclassProcsPtr uintptr FinstanceData uintptr FprivatePtr uintptr FinternalBorderRight int32 FinternalBorderTop int32 FinternalBorderBottom int32 FminReqWidth int32 FminReqHeight int32 FximGeneration int32 FgeomMgrName uintptr FmaintainerPtr uintptr } type TTkKeyEvent = struct { FkeyEvent TXKeyEvent FcharValuePtr uintptr FcharValueLen TTcl_Size Fkeysym TKeySym } type TTkEnsemble = struct { Fname uintptr Fproc uintptr Fsubensemble uintptr } type TTkStateMap = struct { FnumKey int32 FstrKey uintptr } type TTkpClipMask = struct { Ftype1 int32 Fvalue struct { Fregion [0]TRegion Fpixmap TPixmap } } type TTkObjType = struct { FobjType TTcl_ObjType Fversion Tsize_t } type TTkTextBTree = uintptr type TTkIntStubs = struct { Fmagic int32 Fhooks uintptr FtkAllocWindow uintptr FtkBezierPoints uintptr FtkBezierScreenPoints uintptr Freserved3 uintptr FtkBindEventProc uintptr FtkBindFree uintptr FtkBindInit uintptr FtkChangeEventWindow uintptr FtkClipInit uintptr FtkComputeAnchor uintptr Freserved10 uintptr Freserved11 uintptr FtkCreateCursorFromData uintptr FtkCreateFrame uintptr FtkCreateMainWindow uintptr FtkCurrentTime uintptr FtkDeleteAllImages uintptr FtkDoConfigureNotify uintptr FtkDrawInsetFocusHighlight uintptr FtkEventDeadWindow uintptr FtkFillPolygon uintptr FtkFindStateNum uintptr FtkFindStateString uintptr FtkFocusDeadWindow uintptr FtkFocusFilterEvent uintptr FtkFocusKeyEvent uintptr FtkFontPkgInit uintptr FtkFontPkgFree uintptr FtkFreeBindingTags uintptr FtkpFreeCursor uintptr FtkGetBitmapData uintptr FtkGetButtPoints uintptr FtkGetCursorByName uintptr FtkGetDefaultScreenName uintptr FtkGetDisplay uintptr FtkGetDisplayOf uintptr FtkGetFocusWin uintptr FtkGetInterpNames uintptr FtkGetMiterPoints uintptr FtkGetPointerCoords uintptr FtkGetServerInfo uintptr FtkGrabDeadWindow uintptr FtkGrabState uintptr FtkIncludePoint uintptr FtkInOutEvents uintptr FtkInstallFrameMenu uintptr FtkKeysymToString uintptr FtkLineToArea uintptr FtkLineToPoint uintptr FtkMakeBezierCurve uintptr FtkMakeBezierPostscript uintptr FtkOptionClassChanged uintptr FtkOptionDeadWindow uintptr FtkOvalToArea uintptr FtkOvalToPoint uintptr FtkpChangeFocus uintptr FtkpCloseDisplay uintptr FtkpClaimFocus uintptr FtkpDisplayWarning uintptr FtkpGetAppName uintptr Freserved60 uintptr FtkpGetWrapperWindow uintptr FtkpInit uintptr FtkpInitializeMenuBindings uintptr Freserved64 uintptr FtkpMakeMenuWindow uintptr Freserved66 uintptr FtkpMenuNotifyToplevelCreate uintptr FtkpOpenDisplay uintptr FtkPointerEvent uintptr FtkPolygonToArea uintptr FtkPolygonToPoint uintptr FtkPositionInTree uintptr FtkpRedirectKeyEvent uintptr Freserved74 uintptr Freserved75 uintptr Freserved76 uintptr FtkQueueEventForAllChildren uintptr FtkReadBitmapFile uintptr FtkScrollWindow uintptr FtkSelDeadWindow uintptr FtkSelEventProc uintptr FtkSelInit uintptr FtkSelPropProc uintptr Freserved84 uintptr Freserved85 uintptr FtkStringToKeysym uintptr FtkThickPolyLineToArea uintptr FtkWmAddToColormapWindows uintptr FtkWmDeadWindow uintptr FtkWmFocusToplevel uintptr FtkWmMapWindow uintptr FtkWmNewWindow uintptr FtkWmProtocolEventProc uintptr FtkWmRemoveFromColormapWindows uintptr FtkWmRestackToplevel uintptr FtkWmSetClass uintptr FtkWmUnmapWindow uintptr FtkDebugBitmap uintptr FtkDebugBorder uintptr FtkDebugCursor uintptr FtkDebugColor uintptr FtkDebugConfig uintptr FtkDebugFont uintptr FtkFindStateNumObj uintptr FtkGetBitmapPredefTable uintptr FtkGetDisplayList uintptr FtkGetMainInfoList uintptr FtkGetWindowFromObj uintptr FtkpGetString uintptr FtkpGetSubFonts uintptr Freserved111 uintptr FtkpMenuThreadInit uintptr FxClipBox uintptr FxCreateRegion uintptr FxDestroyRegion uintptr FxIntersectRegion uintptr FxRectInRegion uintptr FxSetRegion uintptr FxUnionRectWithRegion uintptr Freserved120 uintptr FtkpCreateNativeBitmap uintptr FtkpDefineNativeBitmaps uintptr Freserved123 uintptr FtkpGetNativeAppBitmap uintptr Freserved125 uintptr Freserved126 uintptr Freserved127 uintptr Freserved128 uintptr Freserved129 uintptr Freserved130 uintptr Freserved131 uintptr Freserved132 uintptr Freserved133 uintptr Freserved134 uintptr Freserved135 uintptr FtkSetFocusWin uintptr FtkpSetKeycodeAndState uintptr FtkpGetKeySym uintptr FtkpInitKeymapInfo uintptr FtkPhotoGetValidRegion uintptr FtkWmStackorderToplevel uintptr FtkFocusFree uintptr FtkClipCleanup uintptr FtkGCCleanup uintptr FxSubtractRegion uintptr FtkStylePkgInit uintptr FtkStylePkgFree uintptr FtkToplevelWindowForCommand uintptr FtkGetOptionSpec uintptr FtkMakeRawCurve uintptr FtkMakeRawCurvePostscript uintptr FtkpDrawFrame uintptr FtkCreateThreadExitHandler uintptr FtkDeleteThreadExitHandler uintptr Freserved155 uintptr FtkpTestembedCmd uintptr FtkpTesttextCmd uintptr FtkSelGetSelection uintptr FtkTextGetIndex uintptr FtkTextIndexBackBytes uintptr FtkTextIndexForwBytes uintptr FtkTextMakeByteIndex uintptr FtkTextPrintIndex uintptr FtkTextSetMark uintptr FtkTextXviewCmd uintptr FtkTextChanged uintptr FtkBTreeNumLines uintptr FtkTextInsertDisplayProc uintptr FtkStateParseProc uintptr FtkStatePrintProc uintptr FtkCanvasDashParseProc uintptr FtkCanvasDashPrintProc uintptr FtkOffsetParseProc uintptr FtkOffsetPrintProc uintptr FtkPixelParseProc uintptr FtkPixelPrintProc uintptr FtkOrientParseProc uintptr FtkOrientPrintProc uintptr FtkSmoothParseProc uintptr FtkSmoothPrintProc uintptr FtkDrawAngledTextLayout uintptr FtkUnderlineAngledTextLayout uintptr FtkIntersectAngledTextLayout uintptr FtkDrawAngledChars uintptr FtkpRedrawWidget uintptr FtkpWillDrawWidget uintptr FtkDebugPhotoStringMatchDef uintptr } type TTkBorder = struct { Fscreen uintptr Fvisual uintptr Fdepth int32 Fcolormap TColormap FresourceRefCount TTcl_Size FobjRefCount TTcl_Size FbgColorPtr uintptr FdarkColorPtr uintptr FlightColorPtr uintptr Fshadow TPixmap FbgGC TGC FdarkGC TGC FlightGC TGC FhashPtr uintptr FnextPtr uintptr } func init() { p := unsafe.Pointer(&XtkBorderObjType) *(*uintptr)(unsafe.Add(p, 8)) = __ccgo_fp(_FreeBorderObjProc) *(*uintptr)(unsafe.Add(p, 16)) = __ccgo_fp(_DupBorderObjProc) } /* *---------------------------------------------------------------------- * * Tk_Alloc3DBorderFromObj -- * * Given a Tcl_Obj *, map the value to a corresponding Tk_3DBorder * structure based on the tkwin given. * * Results: * The return value is a token for a data structure describing a 3-D * border. This token may be passed to functions such as * Tk_Draw3DRectangle and Tk_Free3DBorder. If an error prevented the * border from being created then NULL is returned and an error message * will be left in the interp's result. * * Side effects: * The border is added to an internal database with a reference count. * For each call to this function, there should eventually be a call to * FreeBorderObj so that the database is cleaned up when borders aren't * in use anymore. * *---------------------------------------------------------------------- */ func XTk_Alloc3DBorderFromObj(tls *libc.TLS, interp uintptr, tkwin TTk_Window, objPtr uintptr) (r TTk_3DBorder) { /* Object giving name of color for window * background. */ var borderPtr, firstBorderPtr uintptr _, _ = borderPtr, firstBorderPtr if (*TTcl_Obj)(unsafe.Pointer(objPtr)).FtypePtr != uintptr(unsafe.Pointer(&XtkBorderObjType)) { _InitBorderObj(tls, objPtr) } borderPtr = (*(*struct { Fptr1 uintptr Fptr2 uintptr })(unsafe.Pointer(objPtr + 32))).Fptr1 /* * If the object currently points to a TkBorder, see if it's the one we * want. If so, increment its reference count and return. */ if borderPtr != libc.UintptrFromInt32(0) { if (*TTkBorder)(unsafe.Pointer(borderPtr)).FresourceRefCount == 0 { /* * This is a stale reference: it refers to a border that's no * longer in use. Clear the reference. */ _FreeBorderObj(tls, objPtr) borderPtr = libc.UintptrFromInt32(0) } else { if (*struct { Fext_data uintptr Fprivate1 uintptr Ffd int32 Fprivate2 int32 Fproto_major_version int32 Fproto_minor_version int32 Fvendor uintptr Fprivate3 TXID Fprivate4 TXID Fprivate5 TXID Fprivate6 int32 Fresource_alloc uintptr Fbyte_order int32 Fbitmap_unit int32 Fbitmap_pad int32 Fbitmap_bit_order int32 Fnformats int32 Fpixmap_format uintptr Fprivate8 int32 Frelease int32 Fprivate9 uintptr Fprivate10 uintptr Fqlen int32 Flast_request_read uint64 Frequest uint64 Fprivate11 TXPointer Fprivate12 TXPointer Fprivate13 TXPointer Fprivate14 TXPointer Fmax_request_size uint32 Fdb uintptr Fprivate15 uintptr Fdisplay_name uintptr Fdefault_screen int32 Fnscreens int32 Fscreens uintptr Fmotion_buffer uint64 Fprivate16 uint64 Fmin_keycode int32 Fmax_keycode int32 Fprivate17 TXPointer Fprivate18 TXPointer Fprivate19 int32 Fxdefaults uintptr })(unsafe.Pointer((*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fdisplay)).Fscreens+uintptr((*TTk_FakeWin)(unsafe.Pointer(tkwin)).FscreenNum)*128 == (*TTkBorder)(unsafe.Pointer(borderPtr)).Fscreen && (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fatts.Fcolormap == (*TTkBorder)(unsafe.Pointer(borderPtr)).Fcolormap { (*TTkBorder)(unsafe.Pointer(borderPtr)).FresourceRefCount++ return borderPtr } } } /* * The object didn't point to the border that we wanted. Search the list * of borders with the same name to see if one of the others is the right * one. * * If the cached value is NULL, either the object type was not a color * going in, or the object is a color type but had previously been freed. * * If the value is not NULL, the internal rep is the value of the color * the last time this object was accessed. Check the screen and colormap * of the last access, and if they match, we are done. */ if borderPtr != libc.UintptrFromInt32(0) { firstBorderPtr = (*TTcl_HashEntry)(unsafe.Pointer((*TTkBorder)(unsafe.Pointer(borderPtr)).FhashPtr)).FclientData _FreeBorderObj(tls, objPtr) borderPtr = firstBorderPtr for { if !(borderPtr != libc.UintptrFromInt32(0)) { break } if (*struct { Fext_data uintptr Fprivate1 uintptr Ffd int32 Fprivate2 int32 Fproto_major_version int32 Fproto_minor_version int32 Fvendor uintptr Fprivate3 TXID Fprivate4 TXID Fprivate5 TXID Fprivate6 int32 Fresource_alloc uintptr Fbyte_order int32 Fbitmap_unit int32 Fbitmap_pad int32 Fbitmap_bit_order int32 Fnformats int32 Fpixmap_format uintptr Fprivate8 int32 Frelease int32 Fprivate9 uintptr Fprivate10 uintptr Fqlen int32 Flast_request_read uint64 Frequest uint64 Fprivate11 TXPointer Fprivate12 TXPointer Fprivate13 TXPointer Fprivate14 TXPointer Fmax_request_size uint32 Fdb uintptr Fprivate15 uintptr Fdisplay_name uintptr Fdefault_screen int32 Fnscreens int32 Fscreens uintptr Fmotion_buffer uint64 Fprivate16 uint64 Fmin_keycode int32 Fmax_keycode int32 Fprivate17 TXPointer Fprivate18 TXPointer Fprivate19 int32 Fxdefaults uintptr })(unsafe.Pointer((*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fdisplay)).Fscreens+uintptr((*TTk_FakeWin)(unsafe.Pointer(tkwin)).FscreenNum)*128 == (*TTkBorder)(unsafe.Pointer(borderPtr)).Fscreen && (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fatts.Fcolormap == (*TTkBorder)(unsafe.Pointer(borderPtr)).Fcolormap { (*TTkBorder)(unsafe.Pointer(borderPtr)).FresourceRefCount++ (*TTkBorder)(unsafe.Pointer(borderPtr)).FobjRefCount++ (*(*struct { Fptr1 uintptr Fptr2 uintptr })(unsafe.Pointer(objPtr + 32))).Fptr1 = borderPtr return borderPtr } goto _1 _1: ; borderPtr = (*TTkBorder)(unsafe.Pointer(borderPtr)).FnextPtr } } /* * Still no luck. Call Tk_Get3DBorder to allocate a new border. */ borderPtr = XTk_Get3DBorder(tls, interp, tkwin, libtcl9_0.XTcl_GetStringFromObj(tls, objPtr, libc.UintptrFromInt32(0))) (*(*struct { Fptr1 uintptr Fptr2 uintptr })(unsafe.Pointer(objPtr + 32))).Fptr1 = borderPtr if borderPtr != libc.UintptrFromInt32(0) { (*TTkBorder)(unsafe.Pointer(borderPtr)).FobjRefCount++ } return borderPtr } /* *-------------------------------------------------------------- * * Tk_Get3DBorder -- * * Create a data structure for displaying a 3-D border. * * Results: * The return value is a token for a data structure describing a 3-D * border. This token may be passed to functions such as * Tk_Draw3DRectangle and Tk_Free3DBorder. If an error prevented the * border from being created then NULL is returned and an error message * will be left in the interp's result. * * Side effects: * Data structures, graphics contexts, etc. are allocated. It is the * caller's responsibility to eventually call Tk_Free3DBorder to release * the resources. * *-------------------------------------------------------------- */ func XTk_Get3DBorder(tls *libc.TLS, interp uintptr, tkwin TTk_Window, colorName uintptr) (r TTk_3DBorder) { bp := tls.Alloc(144) defer tls.Free(144) /* String giving name of color for window * background. */ var bgColorPtr, borderPtr, dispPtr, existingBorderPtr, hashPtr uintptr var _ /* gcValues at bp+8 */ TXGCValues var _ /* isNew at bp+0 */ int32 _, _, _, _, _ = bgColorPtr, borderPtr, dispPtr, existingBorderPtr, hashPtr dispPtr = (*TTkWindow)(unsafe.Pointer(tkwin)).FdispPtr if !((*TTkDisplay)(unsafe.Pointer(dispPtr)).FborderInit != 0) { _BorderInit(tls, dispPtr) } hashPtr = (*(*func(*libc.TLS, uintptr, uintptr, uintptr) uintptr)(unsafe.Pointer(&struct{ uintptr }{(*TTcl_HashTable)(unsafe.Pointer(dispPtr + 40)).FcreateProc})))(tls, dispPtr+40, colorName, bp) if !(*(*int32)(unsafe.Pointer(bp)) != 0) { existingBorderPtr = (*TTcl_HashEntry)(unsafe.Pointer(hashPtr)).FclientData borderPtr = existingBorderPtr for { if !(borderPtr != libc.UintptrFromInt32(0)) { break } if (*struct { Fext_data uintptr Fprivate1 uintptr Ffd int32 Fprivate2 int32 Fproto_major_version int32 Fproto_minor_version int32 Fvendor uintptr Fprivate3 TXID Fprivate4 TXID Fprivate5 TXID Fprivate6 int32 Fresource_alloc uintptr Fbyte_order int32 Fbitmap_unit int32 Fbitmap_pad int32 Fbitmap_bit_order int32 Fnformats int32 Fpixmap_format uintptr Fprivate8 int32 Frelease int32 Fprivate9 uintptr Fprivate10 uintptr Fqlen int32 Flast_request_read uint64 Frequest uint64 Fprivate11 TXPointer Fprivate12 TXPointer Fprivate13 TXPointer Fprivate14 TXPointer Fmax_request_size uint32 Fdb uintptr Fprivate15 uintptr Fdisplay_name uintptr Fdefault_screen int32 Fnscreens int32 Fscreens uintptr Fmotion_buffer uint64 Fprivate16 uint64 Fmin_keycode int32 Fmax_keycode int32 Fprivate17 TXPointer Fprivate18 TXPointer Fprivate19 int32 Fxdefaults uintptr })(unsafe.Pointer((*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fdisplay)).Fscreens+uintptr((*TTk_FakeWin)(unsafe.Pointer(tkwin)).FscreenNum)*128 == (*TTkBorder)(unsafe.Pointer(borderPtr)).Fscreen && (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fatts.Fcolormap == (*TTkBorder)(unsafe.Pointer(borderPtr)).Fcolormap { (*TTkBorder)(unsafe.Pointer(borderPtr)).FresourceRefCount++ return borderPtr } goto _1 _1: ; borderPtr = (*TTkBorder)(unsafe.Pointer(borderPtr)).FnextPtr } } else { existingBorderPtr = libc.UintptrFromInt32(0) } /* * No satisfactory border exists yet. Initialize a new one. */ bgColorPtr = XTk_GetColor(tls, interp, tkwin, colorName) if bgColorPtr == libc.UintptrFromInt32(0) { if *(*int32)(unsafe.Pointer(bp)) != 0 { libtcl9_0.XTcl_DeleteHashEntry(tls, hashPtr) } return libc.UintptrFromInt32(0) } borderPtr = XTkpGetBorder(tls) (*TTkBorder)(unsafe.Pointer(borderPtr)).Fscreen = (*struct { Fext_data uintptr Fprivate1 uintptr Ffd int32 Fprivate2 int32 Fproto_major_version int32 Fproto_minor_version int32 Fvendor uintptr Fprivate3 TXID Fprivate4 TXID Fprivate5 TXID Fprivate6 int32 Fresource_alloc uintptr Fbyte_order int32 Fbitmap_unit int32 Fbitmap_pad int32 Fbitmap_bit_order int32 Fnformats int32 Fpixmap_format uintptr Fprivate8 int32 Frelease int32 Fprivate9 uintptr Fprivate10 uintptr Fqlen int32 Flast_request_read uint64 Frequest uint64 Fprivate11 TXPointer Fprivate12 TXPointer Fprivate13 TXPointer Fprivate14 TXPointer Fmax_request_size uint32 Fdb uintptr Fprivate15 uintptr Fdisplay_name uintptr Fdefault_screen int32 Fnscreens int32 Fscreens uintptr Fmotion_buffer uint64 Fprivate16 uint64 Fmin_keycode int32 Fmax_keycode int32 Fprivate17 TXPointer Fprivate18 TXPointer Fprivate19 int32 Fxdefaults uintptr })(unsafe.Pointer((*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fdisplay)).Fscreens + uintptr((*TTk_FakeWin)(unsafe.Pointer(tkwin)).FscreenNum)*128 (*TTkBorder)(unsafe.Pointer(borderPtr)).Fvisual = (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fvisual (*TTkBorder)(unsafe.Pointer(borderPtr)).Fdepth = (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fdepth (*TTkBorder)(unsafe.Pointer(borderPtr)).Fcolormap = (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fatts.Fcolormap (*TTkBorder)(unsafe.Pointer(borderPtr)).FresourceRefCount = int64(1) (*TTkBorder)(unsafe.Pointer(borderPtr)).FobjRefCount = 0 (*TTkBorder)(unsafe.Pointer(borderPtr)).FbgColorPtr = bgColorPtr (*TTkBorder)(unsafe.Pointer(borderPtr)).FdarkColorPtr = libc.UintptrFromInt32(0) (*TTkBorder)(unsafe.Pointer(borderPtr)).FlightColorPtr = libc.UintptrFromInt32(0) (*TTkBorder)(unsafe.Pointer(borderPtr)).Fshadow = uint64(0) (*TTkBorder)(unsafe.Pointer(borderPtr)).FbgGC = libc.UintptrFromInt32(0) (*TTkBorder)(unsafe.Pointer(borderPtr)).FdarkGC = libc.UintptrFromInt32(0) (*TTkBorder)(unsafe.Pointer(borderPtr)).FlightGC = libc.UintptrFromInt32(0) (*TTkBorder)(unsafe.Pointer(borderPtr)).FhashPtr = hashPtr (*TTkBorder)(unsafe.Pointer(borderPtr)).FnextPtr = existingBorderPtr (*TTcl_HashEntry)(unsafe.Pointer(hashPtr)).FclientData = borderPtr /* * Create the information for displaying the background color, but delay * the allocation of shadows until they are actually needed for drawing. */ (*(*TXGCValues)(unsafe.Pointer(bp + 8))).Fforeground = (*TXColor)(unsafe.Pointer((*TTkBorder)(unsafe.Pointer(borderPtr)).FbgColorPtr)).Fpixel (*TTkBorder)(unsafe.Pointer(borderPtr)).FbgGC = XTk_GetGC(tls, tkwin, libc.Uint64FromInt64(libc.Int64FromInt64(1)< int64(1) { return } prevPtr = (*TTcl_HashEntry)(unsafe.Pointer((*TTkBorder)(unsafe.Pointer(borderPtr)).FhashPtr)).FclientData XTkpFreeBorder(tls, borderPtr) if (*TTkBorder)(unsafe.Pointer(borderPtr)).FbgColorPtr != libc.UintptrFromInt32(0) { XTk_FreeColor(tls, (*TTkBorder)(unsafe.Pointer(borderPtr)).FbgColorPtr) } if (*TTkBorder)(unsafe.Pointer(borderPtr)).FdarkColorPtr != libc.UintptrFromInt32(0) { XTk_FreeColor(tls, (*TTkBorder)(unsafe.Pointer(borderPtr)).FdarkColorPtr) } if (*TTkBorder)(unsafe.Pointer(borderPtr)).FlightColorPtr != libc.UintptrFromInt32(0) { XTk_FreeColor(tls, (*TTkBorder)(unsafe.Pointer(borderPtr)).FlightColorPtr) } if (*TTkBorder)(unsafe.Pointer(borderPtr)).Fshadow != uint64(0) { XTk_FreeBitmap(tls, display, (*TTkBorder)(unsafe.Pointer(borderPtr)).Fshadow) } if (*TTkBorder)(unsafe.Pointer(borderPtr)).FbgGC != libc.UintptrFromInt32(0) { XTk_FreeGC(tls, display, (*TTkBorder)(unsafe.Pointer(borderPtr)).FbgGC) } if (*TTkBorder)(unsafe.Pointer(borderPtr)).FdarkGC != libc.UintptrFromInt32(0) { XTk_FreeGC(tls, display, (*TTkBorder)(unsafe.Pointer(borderPtr)).FdarkGC) } if (*TTkBorder)(unsafe.Pointer(borderPtr)).FlightGC != libc.UintptrFromInt32(0) { XTk_FreeGC(tls, display, (*TTkBorder)(unsafe.Pointer(borderPtr)).FlightGC) } if prevPtr == borderPtr { if (*TTkBorder)(unsafe.Pointer(borderPtr)).FnextPtr == libc.UintptrFromInt32(0) { libtcl9_0.XTcl_DeleteHashEntry(tls, (*TTkBorder)(unsafe.Pointer(borderPtr)).FhashPtr) } else { (*TTcl_HashEntry)(unsafe.Pointer((*TTkBorder)(unsafe.Pointer(borderPtr)).FhashPtr)).FclientData = (*TTkBorder)(unsafe.Pointer(borderPtr)).FnextPtr } } else { for (*TTkBorder)(unsafe.Pointer(prevPtr)).FnextPtr != borderPtr { prevPtr = (*TTkBorder)(unsafe.Pointer(prevPtr)).FnextPtr } (*TTkBorder)(unsafe.Pointer(prevPtr)).FnextPtr = (*TTkBorder)(unsafe.Pointer(borderPtr)).FnextPtr } if (*TTkBorder)(unsafe.Pointer(borderPtr)).FobjRefCount == 0 { libtcl9_0.XTcl_Free(tls, borderPtr) } } /* *---------------------------------------------------------------------- * * Tk_Free3DBorderFromObj -- * * This function is called to release a border allocated by * Tk_Alloc3DBorderFromObj. It does not throw away the Tcl_Obj *; it only * gets rid of the hash table entry for this border and clears the cached * value that is normally stored in the object. * * Results: * None. * * Side effects: * The reference count associated with the border represented by objPtr * is decremented, and the border's resources are released to X if there * are no remaining uses for it. * *---------------------------------------------------------------------- */ func XTk_Free3DBorderFromObj(tls *libc.TLS, tkwin TTk_Window, objPtr uintptr) { /* The Tcl_Obj * to be freed. */ XTk_Free3DBorder(tls, XTk_Get3DBorderFromObj(tls, tkwin, objPtr)) _FreeBorderObj(tls, objPtr) } /* *--------------------------------------------------------------------------- * * FreeBorderObjProc, FreeBorderObj -- * * This proc is called to release an object reference to a border. Called * when the object's internal rep is released or when the cached * borderPtr needs to be changed. * * Results: * None. * * Side effects: * The object reference count is decremented. When both it and the hash * ref count go to zero, the border's resources are released. * *--------------------------------------------------------------------------- */ func _FreeBorderObjProc(tls *libc.TLS, objPtr uintptr) { /* The object we are releasing. */ _FreeBorderObj(tls, objPtr) (*TTcl_Obj)(unsafe.Pointer(objPtr)).FtypePtr = libc.UintptrFromInt32(0) } func _FreeBorderObj(tls *libc.TLS, objPtr uintptr) { /* The object we are releasing. */ var borderPtr uintptr _ = borderPtr borderPtr = (*(*struct { Fptr1 uintptr Fptr2 uintptr })(unsafe.Pointer(objPtr + 32))).Fptr1 if borderPtr != libc.UintptrFromInt32(0) { (*TTkBorder)(unsafe.Pointer(borderPtr)).FobjRefCount-- if (*TTkBorder)(unsafe.Pointer(borderPtr)).FobjRefCount == 0 && (*TTkBorder)(unsafe.Pointer(borderPtr)).FresourceRefCount == 0 { libtcl9_0.XTcl_Free(tls, borderPtr) } (*(*struct { Fptr1 uintptr Fptr2 uintptr })(unsafe.Pointer(objPtr + 32))).Fptr1 = libc.UintptrFromInt32(0) } } /* *--------------------------------------------------------------------------- * * DupBorderObjProc -- * * When a cached border object is duplicated, this is called to update * the internal reps. * * Results: * None. * * Side effects: * The border's objRefCount is incremented and the internal rep of the * copy is set to point to it. * *--------------------------------------------------------------------------- */ func _DupBorderObjProc(tls *libc.TLS, srcObjPtr uintptr, dupObjPtr uintptr) { /* The object we are copying to. */ var borderPtr uintptr _ = borderPtr borderPtr = (*(*struct { Fptr1 uintptr Fptr2 uintptr })(unsafe.Pointer(srcObjPtr + 32))).Fptr1 (*TTcl_Obj)(unsafe.Pointer(dupObjPtr)).FtypePtr = (*TTcl_Obj)(unsafe.Pointer(srcObjPtr)).FtypePtr (*(*struct { Fptr1 uintptr Fptr2 uintptr })(unsafe.Pointer(dupObjPtr + 32))).Fptr1 = borderPtr if borderPtr != libc.UintptrFromInt32(0) { (*TTkBorder)(unsafe.Pointer(borderPtr)).FobjRefCount++ } } /* *---------------------------------------------------------------------- * * Tk_SetBackgroundFromBorder -- * * Change the background of a window to one appropriate for a given 3-D * border. * * Results: * None. * * Side effects: * Tkwin's background gets modified. * *---------------------------------------------------------------------- */ func XTk_SetBackgroundFromBorder(tls *libc.TLS, tkwin TTk_Window, border TTk_3DBorder) { /* Token for border. */ var borderPtr uintptr _ = borderPtr borderPtr = border XTk_SetWindowBackground(tls, tkwin, (*TXColor)(unsafe.Pointer((*TTkBorder)(unsafe.Pointer(borderPtr)).FbgColorPtr)).Fpixel) } /* *---------------------------------------------------------------------- * * Tk_GetReliefFromObj -- * * Return an integer value based on the value of the objPtr. * * Results: * The return value is a standard Tcl result. If an error occurs during * conversion, an error message is left in the interpreter's result * unless "interp" is NULL. * * Side effects: * The object gets converted by Tcl_GetIndexFromObj. * *---------------------------------------------------------------------- */ func XTk_GetReliefFromObj(tls *libc.TLS, interp uintptr, objPtr uintptr, resultPtr uintptr) (r int32) { /* Where to place the answer. */ return libtcl9_0.XTcl_GetIndexFromObjStruct(tls, interp, objPtr, uintptr(unsafe.Pointer(&XtkReliefStrings)), libc.Int64FromUint64(libc.Uint64FromInt64(8)), __ccgo_ts+82, libc.Int32FromInt32(0)|libc.Int32FromUint64(libc.Uint64FromInt64(4)<= uint64(2) { relief = int32(TK_RELIEF_RAISED) } else { if libc.Int32FromUint8(c) == int32('r') && libc.Xstrncmp(tls, name, __ccgo_ts+19, length) == 0 && length >= uint64(2) { relief = int32(TK_RELIEF_RIDGE) } else { if libc.Int32FromUint8(c) == int32('s') && libc.Xstrncmp(tls, name, __ccgo_ts+25, length) == 0 && length >= uint64(2) { relief = int32(TK_RELIEF_SOLID) } else { if libc.Int32FromUint8(c) == int32('s') && libc.Xstrncmp(tls, name, __ccgo_ts+31, length) == 0 && length >= uint64(2) { relief = int32(TK_RELIEF_SUNKEN) } else { if interp != 0 { ambigeous = libc.BoolInt32((libc.Int32FromUint8(c) == int32('r') || libc.Int32FromUint8(c) == int32('s')) && libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(name + 1))) == int32('\000')) if ambigeous != 0 { v1 = __ccgo_ts + 89 } else { v1 = __ccgo_ts + 99 } libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+103, libc.VaList(bp+8, v1, name, __ccgo_ts+133))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+8, __ccgo_ts+179, __ccgo_ts+182, __ccgo_ts+188, libc.UintptrFromInt32(0))) } return int32(TCL_ERROR) } } } } } } if reliefPtr != 0 { *(*int32)(unsafe.Pointer(reliefPtr)) = relief } return TCL_OK } /* *-------------------------------------------------------------- * * Tk_NameOfRelief -- * * Given a relief value, produce a string describing that relief value. * * Results: * The return value is a static string that is equivalent to relief. * * Side effects: * None. * *-------------------------------------------------------------- */ func XTk_NameOfRelief(tls *libc.TLS, relief int32) (r uintptr) { /* One of TK_RELIEF_FLAT, TK_RELIEF_RAISED, or * TK_RELIEF_SUNKEN. */ if relief == TK_RELIEF_FLAT { return __ccgo_ts } else { if relief == int32(TK_RELIEF_SUNKEN) { return __ccgo_ts + 31 } else { if relief == int32(TK_RELIEF_RAISED) { return __ccgo_ts + 12 } else { if relief == int32(TK_RELIEF_GROOVE) { return __ccgo_ts + 5 } else { if relief == int32(TK_RELIEF_RIDGE) { return __ccgo_ts + 19 } else { if relief == int32(TK_RELIEF_SOLID) { return __ccgo_ts + 25 } else { if relief == -int32(1) { return __ccgo_ts + 195 } else { return __ccgo_ts + 196 } } } } } } } return r } /* *-------------------------------------------------------------- * * Tk_Draw3DPolygon -- * * Draw a border with 3-D appearance around the edge of a given polygon. * * Results: * None. * * Side effects: * Information is drawn in "drawable" in the form of a 3-D border * borderWidth units width wide on the left of the trajectory given by * pointPtr and numPoints (or -borderWidth units wide on the right side, * if borderWidth is negative). * *-------------------------------------------------------------- */ func XTk_Draw3DPolygon(tls *libc.TLS, tkwin TTk_Window, drawable TDrawable, border TTk_3DBorder, pointPtr uintptr, numPoints TTcl_Size, borderWidth int32, leftRelief int32) { bp := tls.Alloc(48) defer tls.Free(48) /* TK_RELIEF_RAISED or TK_RELIEF_SUNKEN: * indicates how stuff to left of trajectory * looks relative to stuff on right. */ var borderPtr, display, p1Ptr, p2Ptr uintptr var dx, dy, halfWidth, lightOnLeft, parallel, pointsSeen, v1, v2 int32 var gc TGC var i TTcl_Size var _ /* b1 at bp+16 */ TXPoint var _ /* b2 at bp+20 */ TXPoint var _ /* c at bp+36 */ TXPoint var _ /* newB1 at bp+24 */ TXPoint var _ /* newB2 at bp+28 */ TXPoint var _ /* perp at bp+32 */ TXPoint var _ /* poly at bp+0 */ [4]TXPoint var _ /* shift1 at bp+40 */ TXPoint var _ /* shift2 at bp+44 */ TXPoint _, _, _, _, _, _, _, _, _, _, _, _, _, _ = borderPtr, display, dx, dy, gc, halfWidth, i, lightOnLeft, p1Ptr, p2Ptr, parallel, pointsSeen, v1, v2 borderPtr = border display = (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fdisplay if (*TTkBorder)(unsafe.Pointer(borderPtr)).FlightGC == libc.UintptrFromInt32(0) { XTkpGetShadows(tls, borderPtr, tkwin) } /* * Handle grooves and ridges with recursive calls. */ if leftRelief == int32(TK_RELIEF_GROOVE) || leftRelief == int32(TK_RELIEF_RIDGE) { halfWidth = borderWidth / int32(2) if leftRelief == int32(TK_RELIEF_GROOVE) { v1 = int32(TK_RELIEF_RAISED) } else { v1 = int32(TK_RELIEF_SUNKEN) } XTk_Draw3DPolygon(tls, tkwin, drawable, border, pointPtr, numPoints, halfWidth, v1) if leftRelief == int32(TK_RELIEF_GROOVE) { v2 = int32(TK_RELIEF_SUNKEN) } else { v2 = int32(TK_RELIEF_RAISED) } XTk_Draw3DPolygon(tls, tkwin, drawable, border, pointPtr, numPoints, -halfWidth, v2) return } /* * If the polygon is already closed, drop the last point from it (we'll * close it automatically). */ p1Ptr = pointPtr + uintptr(numPoints-int64(1))*4 p2Ptr = pointPtr if int32((*TXPoint)(unsafe.Pointer(p1Ptr)).Fx) == int32((*TXPoint)(unsafe.Pointer(p2Ptr)).Fx) && int32((*TXPoint)(unsafe.Pointer(p1Ptr)).Fy) == int32((*TXPoint)(unsafe.Pointer(p2Ptr)).Fy) { numPoints-- } /* * The loop below is executed once for each vertex in the polgon. At the * beginning of each iteration things look like this: * * poly[1] / * * / * | / * b1 * poly[0] (pointPtr[i-1]) * | | * | | * | | * | | * | | * | | *p1Ptr *p2Ptr * b2 *--------------------* * | * | * x------------------------- * * The job of this iteration is to do the following: * (a) Compute x (the border corner corresponding to pointPtr[i]) and put * it in poly[2]. As part of this, compute a new b1 and b2 value for * the next side of the polygon. * (b) Put pointPtr[i] into poly[3]. * (c) Draw the polygon given by poly[0..3]. * (d) Advance poly[0], poly[1], b1, and b2 for the next side of the * polygon. */ /* * The above situation doesn't first come into existence until two points * have been processed; the first two points are used to "prime the pump", * so some parts of the processing are ommitted for these points. The * variable "pointsSeen" keeps track of the priming process; it has to be * separate from i in order to be able to ignore duplicate points in the * polygon. */ pointsSeen = 0 i = 0 p1Ptr = pointPtr + uintptr(numPoints-int64(2))*4 p2Ptr = p1Ptr + libc.UintptrFromInt32(1)*4 for { if !(i < numPoints+int64(2)) { break } if i == int64(1) || i == numPoints+int64(1) { p2Ptr = pointPtr } if int32((*TXPoint)(unsafe.Pointer(p2Ptr)).Fx) == int32((*TXPoint)(unsafe.Pointer(p1Ptr)).Fx) && int32((*TXPoint)(unsafe.Pointer(p2Ptr)).Fy) == int32((*TXPoint)(unsafe.Pointer(p1Ptr)).Fy) { /* * Ignore duplicate points (they'd cause core dumps in ShiftLine * calls below). */ goto _3 } _ShiftLine(tls, p1Ptr, p2Ptr, borderWidth, bp+24) (*(*TXPoint)(unsafe.Pointer(bp + 28))).Fx = int16(int32((*(*TXPoint)(unsafe.Pointer(bp + 24))).Fx) + (int32((*TXPoint)(unsafe.Pointer(p2Ptr)).Fx) - int32((*TXPoint)(unsafe.Pointer(p1Ptr)).Fx))) (*(*TXPoint)(unsafe.Pointer(bp + 28))).Fy = int16(int32((*(*TXPoint)(unsafe.Pointer(bp + 24))).Fy) + (int32((*TXPoint)(unsafe.Pointer(p2Ptr)).Fy) - int32((*TXPoint)(unsafe.Pointer(p1Ptr)).Fy))) (*(*[4]TXPoint)(unsafe.Pointer(bp)))[int32(3)] = *(*TXPoint)(unsafe.Pointer(p1Ptr)) parallel = 0 if pointsSeen >= int32(1) { parallel = _Intersect(tls, bp+24, bp+28, bp+16, bp+20, bp+2*4) /* * If two consecutive segments of the polygon are parallel, then * things get more complex. Consider the following diagram: * * poly[1] * *----b1-----------b2------a * * * *---------*----------* b * poly[0] *p2Ptr *p1Ptr / * / * --*--------*----c * newB1 newB2 * * Instead of using x and *p1Ptr for poly[2] and poly[3], as in * the original diagram, use a and b as above. Then instead of * using x and *p1Ptr for the new poly[0] and poly[1], use b and c * as above. * * Do the computation in three stages: * 1. Compute a point "perp" such that the line p1Ptr-perp is * perpendicular to p1Ptr-p2Ptr. * 2. Compute the points a and c by intersecting the lines b1-b2 * and newB1-newB2 with p1Ptr-perp. * 3. Compute b by shifting p1Ptr-perp to the right and * intersecting it with p1Ptr-p2Ptr. */ if parallel != 0 { (*(*TXPoint)(unsafe.Pointer(bp + 32))).Fx = int16(int32((*TXPoint)(unsafe.Pointer(p1Ptr)).Fx) + (int32((*TXPoint)(unsafe.Pointer(p2Ptr)).Fy) - int32((*TXPoint)(unsafe.Pointer(p1Ptr)).Fy))) (*(*TXPoint)(unsafe.Pointer(bp + 32))).Fy = int16(int32((*TXPoint)(unsafe.Pointer(p1Ptr)).Fy) - (int32((*TXPoint)(unsafe.Pointer(p2Ptr)).Fx) - int32((*TXPoint)(unsafe.Pointer(p1Ptr)).Fx))) _Intersect(tls, p1Ptr, bp+32, bp+16, bp+20, bp+2*4) _Intersect(tls, p1Ptr, bp+32, bp+24, bp+28, bp+36) _ShiftLine(tls, p1Ptr, bp+32, borderWidth, bp+40) (*(*TXPoint)(unsafe.Pointer(bp + 44))).Fx = int16(int32((*(*TXPoint)(unsafe.Pointer(bp + 40))).Fx) + (int32((*(*TXPoint)(unsafe.Pointer(bp + 32))).Fx) - int32((*TXPoint)(unsafe.Pointer(p1Ptr)).Fx))) (*(*TXPoint)(unsafe.Pointer(bp + 44))).Fy = int16(int32((*(*TXPoint)(unsafe.Pointer(bp + 40))).Fy) + (int32((*(*TXPoint)(unsafe.Pointer(bp + 32))).Fy) - int32((*TXPoint)(unsafe.Pointer(p1Ptr)).Fy))) _Intersect(tls, p1Ptr, p2Ptr, bp+40, bp+44, bp+3*4) } } if pointsSeen >= int32(2) { dx = int32((*(*[4]TXPoint)(unsafe.Pointer(bp)))[int32(3)].Fx) - int32((*(*[4]TXPoint)(unsafe.Pointer(bp)))[0].Fx) dy = int32((*(*[4]TXPoint)(unsafe.Pointer(bp)))[int32(3)].Fy) - int32((*(*[4]TXPoint)(unsafe.Pointer(bp)))[0].Fy) if dx > 0 { lightOnLeft = libc.BoolInt32(dy <= dx) } else { lightOnLeft = libc.BoolInt32(dy < dx) } if lightOnLeft^libc.BoolInt32(leftRelief == int32(TK_RELIEF_RAISED)) != 0 { gc = (*TTkBorder)(unsafe.Pointer(borderPtr)).FlightGC } else { gc = (*TTkBorder)(unsafe.Pointer(borderPtr)).FdarkGC } libx11.XXFillPolygon(tls, display, drawable, gc, bp, int32(4), int32(Convex), CoordModeOrigin) } (*(*TXPoint)(unsafe.Pointer(bp + 16))).Fx = (*(*TXPoint)(unsafe.Pointer(bp + 24))).Fx (*(*TXPoint)(unsafe.Pointer(bp + 16))).Fy = (*(*TXPoint)(unsafe.Pointer(bp + 24))).Fy (*(*TXPoint)(unsafe.Pointer(bp + 20))).Fx = (*(*TXPoint)(unsafe.Pointer(bp + 28))).Fx (*(*TXPoint)(unsafe.Pointer(bp + 20))).Fy = (*(*TXPoint)(unsafe.Pointer(bp + 28))).Fy (*(*[4]TXPoint)(unsafe.Pointer(bp)))[0].Fx = (*(*[4]TXPoint)(unsafe.Pointer(bp)))[int32(3)].Fx (*(*[4]TXPoint)(unsafe.Pointer(bp)))[0].Fy = (*(*[4]TXPoint)(unsafe.Pointer(bp)))[int32(3)].Fy if parallel != 0 { (*(*[4]TXPoint)(unsafe.Pointer(bp)))[int32(1)].Fx = (*(*TXPoint)(unsafe.Pointer(bp + 36))).Fx (*(*[4]TXPoint)(unsafe.Pointer(bp)))[int32(1)].Fy = (*(*TXPoint)(unsafe.Pointer(bp + 36))).Fy } else { if pointsSeen >= int32(1) { (*(*[4]TXPoint)(unsafe.Pointer(bp)))[int32(1)].Fx = (*(*[4]TXPoint)(unsafe.Pointer(bp)))[int32(2)].Fx (*(*[4]TXPoint)(unsafe.Pointer(bp)))[int32(1)].Fy = (*(*[4]TXPoint)(unsafe.Pointer(bp)))[int32(2)].Fy } } pointsSeen++ goto _3 _3: ; i++ p1Ptr = p2Ptr p2Ptr += 4 } } /* *---------------------------------------------------------------------- * * Tk_Fill3DRectangle -- * * Fill a rectangular area, supplying a 3D border if desired. * * Results: * None. * * Side effects: * Information gets drawn on the screen. * *---------------------------------------------------------------------- */ func XTk_Fill3DRectangle(tls *libc.TLS, tkwin TTk_Window, drawable TDrawable, border TTk_3DBorder, x int32, y int32, width int32, height int32, borderWidth int32, relief int32) { /* Indicates 3D effect: TK_RELIEF_FLAT, * TK_RELIEF_RAISED, or TK_RELIEF_SUNKEN. */ var borderPtr uintptr var doubleBorder int32 _, _ = borderPtr, doubleBorder borderPtr = border /* * This code is slightly tricky because it only draws the background in * areas not covered by the 3D border. This avoids flashing effects on the * screen for the border region. */ if relief == TK_RELIEF_FLAT { borderWidth = 0 } else { /* * We need to make this extra check, otherwise we will leave garbage * in thin frames [Bug: 3596] */ if width < int32(2)*borderWidth { borderWidth = width / int32(2) } if height < int32(2)*borderWidth { borderWidth = height / int32(2) } } doubleBorder = int32(2) * borderWidth if width > doubleBorder && height > doubleBorder { libx11.XXFillRectangle(tls, (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fdisplay, drawable, (*TTkBorder)(unsafe.Pointer(borderPtr)).FbgGC, x+borderWidth, y+borderWidth, libc.Uint32FromInt32(width-doubleBorder), libc.Uint32FromInt32(height-doubleBorder)) } if borderWidth != 0 { XTk_Draw3DRectangle(tls, tkwin, drawable, border, x, y, width, height, borderWidth, relief) } } /* *---------------------------------------------------------------------- * * Tk_Fill3DPolygon -- * * Fill a polygonal area, supplying a 3D border if desired. * * Results: * None. * * Side effects: * Information gets drawn on the screen. * *---------------------------------------------------------------------- */ func XTk_Fill3DPolygon(tls *libc.TLS, tkwin TTk_Window, drawable TDrawable, border TTk_3DBorder, pointPtr uintptr, numPoints TTcl_Size, borderWidth int32, leftRelief int32) { /* Indicates 3D effect of left side of * trajectory relative to right: * TK_RELIEF_FLAT, TK_RELIEF_RAISED, or * TK_RELIEF_SUNKEN. */ var borderPtr uintptr _ = borderPtr borderPtr = border libx11.XXFillPolygon(tls, (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fdisplay, drawable, (*TTkBorder)(unsafe.Pointer(borderPtr)).FbgGC, pointPtr, int32(numPoints), Complex, CoordModeOrigin) if leftRelief != TK_RELIEF_FLAT { XTk_Draw3DPolygon(tls, tkwin, drawable, border, pointPtr, numPoints, borderWidth, leftRelief) } } /* *-------------------------------------------------------------- * * BorderInit -- * * Initialize the structures used for border management. * * Results: * None. * * Side effects: * Read the code. * *------------------------------------------------------------- */ func _BorderInit(tls *libc.TLS, dispPtr uintptr) { /* Used to access thread-specific data. */ (*TTkDisplay)(unsafe.Pointer(dispPtr)).FborderInit = int32(1) libtcl9_0.XTcl_InitHashTable(tls, dispPtr+40, TCL_STRING_KEYS) } /* *-------------------------------------------------------------- * * ShiftLine -- * * Given two points on a line, compute a point on a new line that is * parallel to the given line and a given distance away from it. * * Results: * None. * * Side effects: * None. * *-------------------------------------------------------------- */ func _ShiftLine(tls *libc.TLS, p1Ptr uintptr, p2Ptr uintptr, distance int32, p3Ptr uintptr) { /* Store coords of point on new line here. */ var cosine, tangent float64 var dx, dxNeg, dy, dyNeg, i int32 var p2, p3 uintptr _, _, _, _, _, _, _, _, _ = cosine, dx, dxNeg, dy, dyNeg, i, tangent, p2, p3 /* * Initialize the table if this is the first time it is used. */ if _shiftTable[0] == 0 { i = 0 for { if !(i <= int32(128)) { break } tangent = float64(i) / float64(128) cosine = libc.Float64FromInt32(128)/libc.Xcos(tls, libc.Xatan(tls, tangent)) + float64(0.5) _shiftTable[i] = int32(cosine) goto _1 _1: ; i++ } } *(*TXPoint)(unsafe.Pointer(p3Ptr)) = *(*TXPoint)(unsafe.Pointer(p1Ptr)) dx = int32((*TXPoint)(unsafe.Pointer(p2Ptr)).Fx) - int32((*TXPoint)(unsafe.Pointer(p1Ptr)).Fx) dy = int32((*TXPoint)(unsafe.Pointer(p2Ptr)).Fy) - int32((*TXPoint)(unsafe.Pointer(p1Ptr)).Fy) if dy < 0 { dyNeg = int32(1) dy = -dy } else { dyNeg = 0 } if dx < 0 { dxNeg = int32(1) dx = -dx } else { dxNeg = 0 } if dy <= dx { dy = (distance*_shiftTable[dy<> int32(7) if !(dxNeg != 0) { dy = -dy } p2 = p3Ptr + 2 *(*int16)(unsafe.Pointer(p2)) = int16(int32(*(*int16)(unsafe.Pointer(p2))) + dy) } else { dx = (distance*_shiftTable[dx<> int32(7) if dyNeg != 0 { dx = -dx } p3 = p3Ptr *(*int16)(unsafe.Pointer(p3)) = int16(int32(*(*int16)(unsafe.Pointer(p3))) + dx) } } var _shiftTable [129]int32 /* Used for a quick approximation in computing * the new point. An index into the table is * 128 times the slope of the original line * (the slope must always be between 0 and 1). * The value of the table entry is 128 times * the amount to displace the new line in y * for each unit of perpendicular distance. In * other words, the table maps from the * tangent of an angle to the inverse of its * cosine. If the slope of the original line * is greater than 1, then the displacement is * done in x rather than in y. */ /* *-------------------------------------------------------------- * * Intersect -- * * Find the intersection point between two lines. * * Results: * Under normal conditions 0 is returned and the point at *iPtr is filled * in with the intersection between the two lines. If the two lines are * parallel, then -1 is returned and *iPtr isn't modified. * * Side effects: * None. * *-------------------------------------------------------------- */ func _Intersect(tls *libc.TLS, a1Ptr uintptr, a2Ptr uintptr, b1Ptr uintptr, b2Ptr uintptr, iPtr uintptr) (r int32) { /* Filled in with intersection point. */ var dxadxb, dxadyb, dxbdya, dyadyb, p, q int32 _, _, _, _, _, _ = dxadxb, dxadyb, dxbdya, dyadyb, p, q /* * The code below is just a straightforward manipulation of two equations * of the form y = (x-x1)*(y2-y1)/(x2-x1) + y1 to solve for the * x-coordinate of intersection, then the y-coordinate. */ dxadyb = (int32((*TXPoint)(unsafe.Pointer(a2Ptr)).Fx) - int32((*TXPoint)(unsafe.Pointer(a1Ptr)).Fx)) * (int32((*TXPoint)(unsafe.Pointer(b2Ptr)).Fy) - int32((*TXPoint)(unsafe.Pointer(b1Ptr)).Fy)) dxbdya = (int32((*TXPoint)(unsafe.Pointer(b2Ptr)).Fx) - int32((*TXPoint)(unsafe.Pointer(b1Ptr)).Fx)) * (int32((*TXPoint)(unsafe.Pointer(a2Ptr)).Fy) - int32((*TXPoint)(unsafe.Pointer(a1Ptr)).Fy)) dxadxb = (int32((*TXPoint)(unsafe.Pointer(a2Ptr)).Fx) - int32((*TXPoint)(unsafe.Pointer(a1Ptr)).Fx)) * (int32((*TXPoint)(unsafe.Pointer(b2Ptr)).Fx) - int32((*TXPoint)(unsafe.Pointer(b1Ptr)).Fx)) dyadyb = (int32((*TXPoint)(unsafe.Pointer(a2Ptr)).Fy) - int32((*TXPoint)(unsafe.Pointer(a1Ptr)).Fy)) * (int32((*TXPoint)(unsafe.Pointer(b2Ptr)).Fy) - int32((*TXPoint)(unsafe.Pointer(b1Ptr)).Fy)) if dxadyb == dxbdya { return -int32(1) } p = int32((*TXPoint)(unsafe.Pointer(a1Ptr)).Fx)*dxbdya - int32((*TXPoint)(unsafe.Pointer(b1Ptr)).Fx)*dxadyb + (int32((*TXPoint)(unsafe.Pointer(b1Ptr)).Fy)-int32((*TXPoint)(unsafe.Pointer(a1Ptr)).Fy))*dxadxb q = dxbdya - dxadyb if q < 0 { p = -p q = -q } if p < 0 { (*TXPoint)(unsafe.Pointer(iPtr)).Fx = int16(-((-p + q/int32(2)) / q)) } else { (*TXPoint)(unsafe.Pointer(iPtr)).Fx = int16((p + q/int32(2)) / q) } p = int32((*TXPoint)(unsafe.Pointer(a1Ptr)).Fy)*dxadyb - int32((*TXPoint)(unsafe.Pointer(b1Ptr)).Fy)*dxbdya + (int32((*TXPoint)(unsafe.Pointer(b1Ptr)).Fx)-int32((*TXPoint)(unsafe.Pointer(a1Ptr)).Fx))*dyadyb q = dxadyb - dxbdya if q < 0 { p = -p q = -q } if p < 0 { (*TXPoint)(unsafe.Pointer(iPtr)).Fy = int16(-((-p + q/int32(2)) / q)) } else { (*TXPoint)(unsafe.Pointer(iPtr)).Fy = int16((p + q/int32(2)) / q) } return 0 } /* *---------------------------------------------------------------------- * * Tk_Get3DBorderFromObj -- * * Returns the border referred to by a Tcl object. The border must * already have been allocated via a call to Tk_Alloc3DBorderFromObj or * Tk_Get3DBorder. * * Results: * Returns the Tk_3DBorder that matches the tkwin and the string rep of * the name of the border given in objPtr. * * Side effects: * If the object is not already a border, the conversion will free any * old internal representation. * *---------------------------------------------------------------------- */ func XTk_Get3DBorderFromObj(tls *libc.TLS, tkwin TTk_Window, objPtr uintptr) (r TTk_3DBorder) { /* The object whose string value selects a * border. */ var borderPtr, dispPtr, hashPtr uintptr _, _, _ = borderPtr, dispPtr, hashPtr borderPtr = libc.UintptrFromInt32(0) dispPtr = (*TTkWindow)(unsafe.Pointer(tkwin)).FdispPtr if (*TTcl_Obj)(unsafe.Pointer(objPtr)).FtypePtr != uintptr(unsafe.Pointer(&XtkBorderObjType)) { _InitBorderObj(tls, objPtr) } /* * If we are lucky (and the user doesn't use too many different displays, * screens, or colormaps...) then the TkBorder structure we need will be * cached in the internal representation of the Tcl_Obj. Check it out... */ borderPtr = (*(*struct { Fptr1 uintptr Fptr2 uintptr })(unsafe.Pointer(objPtr + 32))).Fptr1 if borderPtr != libc.UintptrFromInt32(0) && (*TTkBorder)(unsafe.Pointer(borderPtr)).FresourceRefCount > 0 && (*struct { Fext_data uintptr Fprivate1 uintptr Ffd int32 Fprivate2 int32 Fproto_major_version int32 Fproto_minor_version int32 Fvendor uintptr Fprivate3 TXID Fprivate4 TXID Fprivate5 TXID Fprivate6 int32 Fresource_alloc uintptr Fbyte_order int32 Fbitmap_unit int32 Fbitmap_pad int32 Fbitmap_bit_order int32 Fnformats int32 Fpixmap_format uintptr Fprivate8 int32 Frelease int32 Fprivate9 uintptr Fprivate10 uintptr Fqlen int32 Flast_request_read uint64 Frequest uint64 Fprivate11 TXPointer Fprivate12 TXPointer Fprivate13 TXPointer Fprivate14 TXPointer Fmax_request_size uint32 Fdb uintptr Fprivate15 uintptr Fdisplay_name uintptr Fdefault_screen int32 Fnscreens int32 Fscreens uintptr Fmotion_buffer uint64 Fprivate16 uint64 Fmin_keycode int32 Fmax_keycode int32 Fprivate17 TXPointer Fprivate18 TXPointer Fprivate19 int32 Fxdefaults uintptr })(unsafe.Pointer((*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fdisplay)).Fscreens+uintptr((*TTk_FakeWin)(unsafe.Pointer(tkwin)).FscreenNum)*128 == (*TTkBorder)(unsafe.Pointer(borderPtr)).Fscreen && (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fatts.Fcolormap == (*TTkBorder)(unsafe.Pointer(borderPtr)).Fcolormap { /* * The object already points to the right border structure. Just * return it. */ return borderPtr } /* * If we make it here, it means we aren't so lucky. Either there was no * cached TkBorder in the Tcl_Obj, or the TkBorder that was there is for * the wrong screen/colormap. Either way, we have to search for the right * TkBorder. For each color name, there is linked list of TkBorder * structures, one structure for each screen/colormap combination. The * head of the linked list is recorded in a hash table (where the key is * the color name) attached to the TkDisplay structure. Walk this list to * find the right TkBorder structure. */ hashPtr = (*(*func(*libc.TLS, uintptr, uintptr) uintptr)(unsafe.Pointer(&struct{ uintptr }{(*TTcl_HashTable)(unsafe.Pointer(dispPtr + 40)).FfindProc})))(tls, dispPtr+40, libtcl9_0.XTcl_GetStringFromObj(tls, objPtr, libc.UintptrFromInt32(0))) if hashPtr == libc.UintptrFromInt32(0) { goto error } borderPtr = (*TTcl_HashEntry)(unsafe.Pointer(hashPtr)).FclientData for { if !(borderPtr != libc.UintptrFromInt32(0)) { break } if (*struct { Fext_data uintptr Fprivate1 uintptr Ffd int32 Fprivate2 int32 Fproto_major_version int32 Fproto_minor_version int32 Fvendor uintptr Fprivate3 TXID Fprivate4 TXID Fprivate5 TXID Fprivate6 int32 Fresource_alloc uintptr Fbyte_order int32 Fbitmap_unit int32 Fbitmap_pad int32 Fbitmap_bit_order int32 Fnformats int32 Fpixmap_format uintptr Fprivate8 int32 Frelease int32 Fprivate9 uintptr Fprivate10 uintptr Fqlen int32 Flast_request_read uint64 Frequest uint64 Fprivate11 TXPointer Fprivate12 TXPointer Fprivate13 TXPointer Fprivate14 TXPointer Fmax_request_size uint32 Fdb uintptr Fprivate15 uintptr Fdisplay_name uintptr Fdefault_screen int32 Fnscreens int32 Fscreens uintptr Fmotion_buffer uint64 Fprivate16 uint64 Fmin_keycode int32 Fmax_keycode int32 Fprivate17 TXPointer Fprivate18 TXPointer Fprivate19 int32 Fxdefaults uintptr })(unsafe.Pointer((*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fdisplay)).Fscreens+uintptr((*TTk_FakeWin)(unsafe.Pointer(tkwin)).FscreenNum)*128 == (*TTkBorder)(unsafe.Pointer(borderPtr)).Fscreen && (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fatts.Fcolormap == (*TTkBorder)(unsafe.Pointer(borderPtr)).Fcolormap { _FreeBorderObj(tls, objPtr) (*(*struct { Fptr1 uintptr Fptr2 uintptr })(unsafe.Pointer(objPtr + 32))).Fptr1 = borderPtr (*TTkBorder)(unsafe.Pointer(borderPtr)).FobjRefCount++ return borderPtr } goto _1 _1: ; borderPtr = (*TTkBorder)(unsafe.Pointer(borderPtr)).FnextPtr } goto error error: ; libtcl9_0.XTcl_Panic(tls, __ccgo_ts+211, 0) /* * The following code isn't reached; it's just there to please compilers. */ return libc.UintptrFromInt32(0) } /* *---------------------------------------------------------------------- * * InitBorderObj -- * * Attempt to generate a border internal form for the Tcl object * "objPtr". * * Results: * The return value is a standard Tcl result. If an error occurs during * conversion, an error message is left in the interpreter's result * unless "interp" is NULL. * * Side effects: * If no error occurs, a blank internal format for a border value is * initialized. The final form cannot be done without a Tk_Window. * *---------------------------------------------------------------------- */ func _InitBorderObj(tls *libc.TLS, objPtr uintptr) { /* The object to convert. */ var typePtr uintptr _ = typePtr /* * Free the old internalRep before setting the new one. */ libtcl9_0.XTcl_GetStringFromObj(tls, objPtr, libc.UintptrFromInt32(0)) typePtr = (*TTcl_Obj)(unsafe.Pointer(objPtr)).FtypePtr if typePtr != libc.UintptrFromInt32(0) && (*TTcl_ObjType)(unsafe.Pointer(typePtr)).FfreeIntRepProc != libc.UintptrFromInt32(0) { (*(*func(*libc.TLS, uintptr))(unsafe.Pointer(&struct{ uintptr }{(*TTcl_ObjType)(unsafe.Pointer(typePtr)).FfreeIntRepProc})))(tls, objPtr) } (*TTcl_Obj)(unsafe.Pointer(objPtr)).FtypePtr = uintptr(unsafe.Pointer(&XtkBorderObjType)) (*(*struct { Fptr1 uintptr Fptr2 uintptr })(unsafe.Pointer(objPtr + 32))).Fptr1 = libc.UintptrFromInt32(0) } /* *---------------------------------------------------------------------- * * TkDebugBorder -- * * This function returns debugging information about a border. * * Results: * The return value is a list with one sublist for each TkBorder * corresponding to "name". Each sublist has two elements that contain * the resourceRefCount and objRefCount fields from the TkBorder * structure. * * Side effects: * None. * *---------------------------------------------------------------------- */ func XTkDebugBorder(tls *libc.TLS, tkwin TTk_Window, name uintptr) (r uintptr) { /* Name of the desired color. */ var borderPtr, dispPtr, hashPtr, objPtr, resultPtr uintptr _, _, _, _, _ = borderPtr, dispPtr, hashPtr, objPtr, resultPtr dispPtr = (*TTkWindow)(unsafe.Pointer(tkwin)).FdispPtr resultPtr = libtcl9_0.XTcl_NewObj(tls) hashPtr = (*(*func(*libc.TLS, uintptr, uintptr) uintptr)(unsafe.Pointer(&struct{ uintptr }{(*TTcl_HashTable)(unsafe.Pointer(dispPtr + 40)).FfindProc})))(tls, dispPtr+40, name) if hashPtr != libc.UintptrFromInt32(0) { borderPtr = (*TTcl_HashEntry)(unsafe.Pointer(hashPtr)).FclientData if borderPtr == libc.UintptrFromInt32(0) { libtcl9_0.XTcl_Panic(tls, __ccgo_ts+266, 0) } for { if !(borderPtr != libc.UintptrFromInt32(0)) { break } objPtr = libtcl9_0.XTcl_NewObj(tls) libtcl9_0.XTcl_ListObjAppendElement(tls, libc.UintptrFromInt32(0), objPtr, libtcl9_0.XTcl_NewWideIntObj(tls, (*TTkBorder)(unsafe.Pointer(borderPtr)).FresourceRefCount)) libtcl9_0.XTcl_ListObjAppendElement(tls, libc.UintptrFromInt32(0), objPtr, libtcl9_0.XTcl_NewWideIntObj(tls, (*TTkBorder)(unsafe.Pointer(borderPtr)).FobjRefCount)) libtcl9_0.XTcl_ListObjAppendElement(tls, libc.UintptrFromInt32(0), resultPtr, objPtr) goto _1 _1: ; borderPtr = (*TTkBorder)(unsafe.Pointer(borderPtr)).FnextPtr } } return resultPtr } /* *-------------------------------------------------------------- * * Tk_Get3BorderColors -- * * Given a Tk_3DBorder determine its 3 colors. * * Results: * None. * * Side effects: * None. * *-------------------------------------------------------------- */ func XTk_Get3DBorderColors(tls *libc.TLS, border TTk_3DBorder, bgColorPtr uintptr, darkColorPtr uintptr, lightColorPtr uintptr) { if bgColorPtr != 0 { *(*TXColor)(unsafe.Pointer(bgColorPtr)) = *(*TXColor)(unsafe.Pointer((*TTkBorder)(unsafe.Pointer(border)).FbgColorPtr)) } if darkColorPtr != 0 { *(*TXColor)(unsafe.Pointer(darkColorPtr)) = *(*TXColor)(unsafe.Pointer((*TTkBorder)(unsafe.Pointer(border)).FdarkColorPtr)) } if lightColorPtr != 0 { *(*TXColor)(unsafe.Pointer(lightColorPtr)) = *(*TXColor)(unsafe.Pointer((*TTkBorder)(unsafe.Pointer(border)).FlightColorPtr)) } } type Tfuncs = struct { Fcreate_image uintptr Fdestroy_image uintptr Fget_pixel uintptr Fput_pixel uintptr Fsub_image uintptr Fadd_pixel uintptr } /* * Local Variables: * mode: c * c-basic-offset: 4 * fill-column: 78 * End: */ /* * Default table of argument descriptors. These are normally available in * every application. */ var _defaultTable = [2]TTk_ArgvInfo{ 0: { Fkey: __ccgo_ts + 309, Ftype1: int32(TK_ARGV_HELP), Fhelp: __ccgo_ts + 315, }, 1: { Ftype1: int32(TK_ARGV_END), }, } /* *---------------------------------------------------------------------- * * Tk_ParseArgv -- * * Process an argv array according to a table of expected command-line * options. See the manual page for more details. * * Results: * The return value is a standard Tcl return value. If an error occurs * then an error message is left in the interp's result. Under normal * conditions, both *argcPtr and *argv are modified to return the * arguments that couldn't be processed here (they didn't match the * option table, or followed an TK_ARGV_REST argument). * * Side effects: * Variables may be modified, resources may be entered for tkwin, or * functions may be called. It all depends on the arguments and their * entries in argTable. See the user documentation for details. * *---------------------------------------------------------------------- */ func XTk_ParseArgv(tls *libc.TLS, interp uintptr, tkwin TTk_Window, argcPtr uintptr, argv uintptr, argTable uintptr, flags int32) (r int32) { bp := tls.Alloc(48) defer tls.Free(48) /* Or'ed combination of various flag bits, * such as TK_ARGV_NO_DEFAULTS. */ var argc, dstIndex, i, srcIndex, v1, v2 int32 var c uint8 var curArg, handlerProc, handlerProc1, infoPtr, matchPtr uintptr var length Tsize_t _, _, _, _, _, _, _, _, _, _, _, _, _ = argc, c, curArg, dstIndex, handlerProc, handlerProc1, i, infoPtr, length, matchPtr, srcIndex, v1, v2 if flags&int32(TK_ARGV_DONT_SKIP_FIRST_ARG) != 0 { v1 = libc.Int32FromInt32(0) dstIndex = v1 srcIndex = v1 argc = *(*int32)(unsafe.Pointer(argcPtr)) } else { v2 = libc.Int32FromInt32(1) dstIndex = v2 srcIndex = v2 argc = *(*int32)(unsafe.Pointer(argcPtr)) - int32(1) } for argc > 0 { curArg = *(*uintptr)(unsafe.Pointer(argv + uintptr(srcIndex)*8)) srcIndex++ argc-- length = libc.Xstrlen(tls, curArg) if length > uint64(0) { c = *(*uint8)(unsafe.Pointer(curArg + 1)) } else { c = uint8(0) } /* * Loop through the argument descriptors searching for one with the * matching key string. If found, leave a pointer to it in matchPtr. */ matchPtr = libc.UintptrFromInt32(0) i = 0 for { if !(i < int32(2)) { break } if i == 0 { infoPtr = argTable } else { infoPtr = uintptr(unsafe.Pointer(&_defaultTable)) } for { if !(infoPtr != libc.UintptrFromInt32(0) && (*TTk_ArgvInfo)(unsafe.Pointer(infoPtr)).Ftype1 != int32(TK_ARGV_END)) { break } if (*TTk_ArgvInfo)(unsafe.Pointer(infoPtr)).Fkey == libc.UintptrFromInt32(0) { goto _4 } if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer((*TTk_ArgvInfo)(unsafe.Pointer(infoPtr)).Fkey + 1))) != libc.Int32FromUint8(c) || libc.Xstrncmp(tls, (*TTk_ArgvInfo)(unsafe.Pointer(infoPtr)).Fkey, curArg, length) != 0 { goto _4 } if tkwin == libc.UintptrFromInt32(0) && ((*TTk_ArgvInfo)(unsafe.Pointer(infoPtr)).Ftype1 == int32(TK_ARGV_CONST_OPTION) || (*TTk_ArgvInfo)(unsafe.Pointer(infoPtr)).Ftype1 == int32(TK_ARGV_OPTION_VALUE) || (*TTk_ArgvInfo)(unsafe.Pointer(infoPtr)).Ftype1 == int32(TK_ARGV_OPTION_NAME_VALUE)) { goto _4 } if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer((*TTk_ArgvInfo)(unsafe.Pointer(infoPtr)).Fkey + uintptr(length)))) == 0 { matchPtr = infoPtr goto gotMatch } if flags&int32(TK_ARGV_NO_ABBREV) != 0 { goto _4 } if matchPtr != libc.UintptrFromInt32(0) { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+363, libc.VaList(bp+8, curArg))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+8, __ccgo_ts+179, __ccgo_ts+385, __ccgo_ts+389, curArg, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) } matchPtr = infoPtr goto _4 _4: ; infoPtr += 40 } goto _3 _3: ; i++ } if matchPtr == libc.UintptrFromInt32(0) { /* * Unrecognized argument. Just copy it down, unless the caller * prefers an error to be registered. */ if flags&int32(TK_ARGV_NO_LEFTOVERS) != 0 { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+399, libc.VaList(bp+8, curArg))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+8, __ccgo_ts+179, __ccgo_ts+385, __ccgo_ts+426, curArg, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) } *(*uintptr)(unsafe.Pointer(argv + uintptr(dstIndex)*8)) = curArg dstIndex++ continue } /* * Take the appropriate action based on the option type */ goto gotMatch gotMatch: ; infoPtr = matchPtr switch (*TTk_ArgvInfo)(unsafe.Pointer(infoPtr)).Ftype1 { case int32(TK_ARGV_CONSTANT): *(*int32)(unsafe.Pointer((*TTk_ArgvInfo)(unsafe.Pointer(infoPtr)).Fdst)) = int32(int64((*TTk_ArgvInfo)(unsafe.Pointer(infoPtr)).Fsrc)) case int32(TK_ARGV_INT): if argc == 0 { goto missingArg } if libtcl9_0.XTcl_GetInt(tls, interp, *(*uintptr)(unsafe.Pointer(argv + uintptr(srcIndex)*8)), (*TTk_ArgvInfo)(unsafe.Pointer(infoPtr)).Fdst) != TCL_OK { return int32(TCL_ERROR) } srcIndex++ argc-- case int32(TK_ARGV_STRING): if argc == 0 { goto missingArg } *(*uintptr)(unsafe.Pointer((*TTk_ArgvInfo)(unsafe.Pointer(infoPtr)).Fdst)) = *(*uintptr)(unsafe.Pointer(argv + uintptr(srcIndex)*8)) srcIndex++ argc-- case int32(TK_ARGV_UID): if argc == 0 { goto missingArg } *(*TTk_Uid)(unsafe.Pointer((*TTk_ArgvInfo)(unsafe.Pointer(infoPtr)).Fdst)) = XTk_GetUid(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(srcIndex)*8))) srcIndex++ argc-- case int32(TK_ARGV_REST): *(*int32)(unsafe.Pointer((*TTk_ArgvInfo)(unsafe.Pointer(infoPtr)).Fdst)) = dstIndex goto argsDone case int32(TK_ARGV_FLOAT): if argc == 0 { goto missingArg } if libtcl9_0.XTcl_GetDouble(tls, interp, *(*uintptr)(unsafe.Pointer(argv + uintptr(srcIndex)*8)), (*TTk_ArgvInfo)(unsafe.Pointer(infoPtr)).Fdst) != TCL_OK { return int32(TCL_ERROR) } srcIndex++ argc-- case int32(TK_ARGV_FUNC): handlerProc = (*TTk_ArgvInfo)(unsafe.Pointer(infoPtr)).Fsrc if (*(*func(*libc.TLS, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{handlerProc})))(tls, (*TTk_ArgvInfo)(unsafe.Pointer(infoPtr)).Fdst, (*TTk_ArgvInfo)(unsafe.Pointer(infoPtr)).Fkey, *(*uintptr)(unsafe.Pointer(argv + uintptr(srcIndex)*8))) != 0 { srcIndex++ argc-- } case int32(TK_ARGV_GENFUNC): handlerProc1 = (*TTk_ArgvInfo)(unsafe.Pointer(infoPtr)).Fsrc argc = (*(*func(*libc.TLS, uintptr, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{handlerProc1})))(tls, (*TTk_ArgvInfo)(unsafe.Pointer(infoPtr)).Fdst, interp, (*TTk_ArgvInfo)(unsafe.Pointer(infoPtr)).Fkey, argc, argv+uintptr(srcIndex)*8) if argc < 0 { return int32(TCL_ERROR) } case int32(TK_ARGV_HELP): _PrintUsage(tls, interp, argTable, flags) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+8, __ccgo_ts+179, __ccgo_ts+385, __ccgo_ts+439, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) case int32(TK_ARGV_CONST_OPTION): XTk_AddOption(tls, tkwin, (*TTk_ArgvInfo)(unsafe.Pointer(infoPtr)).Fdst, (*TTk_ArgvInfo)(unsafe.Pointer(infoPtr)).Fsrc, int32(TK_INTERACTIVE_PRIO)) case int32(TK_ARGV_OPTION_VALUE): if argc < int32(1) { goto missingArg } XTk_AddOption(tls, tkwin, (*TTk_ArgvInfo)(unsafe.Pointer(infoPtr)).Fdst, *(*uintptr)(unsafe.Pointer(argv + uintptr(srcIndex)*8)), int32(TK_INTERACTIVE_PRIO)) srcIndex++ argc-- case int32(TK_ARGV_OPTION_NAME_VALUE): if argc < int32(2) { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+444, libc.VaList(bp+8, curArg))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+8, __ccgo_ts+179, __ccgo_ts+385, __ccgo_ts+489, curArg, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) } XTk_AddOption(tls, tkwin, *(*uintptr)(unsafe.Pointer(argv + uintptr(srcIndex)*8)), *(*uintptr)(unsafe.Pointer(argv + uintptr(srcIndex+int32(1))*8)), int32(TK_INTERACTIVE_PRIO)) srcIndex += int32(2) argc -= int32(2) default: libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+500, libc.VaList(bp+8, (*TTk_ArgvInfo)(unsafe.Pointer(infoPtr)).Ftype1))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+8, __ccgo_ts+179, __ccgo_ts+536, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) } } /* * If we broke out of the loop because of an OPT_REST argument, copy the * remaining arguments down. */ goto argsDone argsDone: ; for argc != 0 { *(*uintptr)(unsafe.Pointer(argv + uintptr(dstIndex)*8)) = *(*uintptr)(unsafe.Pointer(argv + uintptr(srcIndex)*8)) srcIndex++ dstIndex++ argc-- } *(*uintptr)(unsafe.Pointer(argv + uintptr(dstIndex)*8)) = libc.UintptrFromInt32(0) *(*int32)(unsafe.Pointer(argcPtr)) = dstIndex return TCL_OK goto missingArg missingArg: ; libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+546, libc.VaList(bp+8, curArg))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+8, __ccgo_ts+179, __ccgo_ts+385, __ccgo_ts+590, curArg, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) } /* *---------------------------------------------------------------------- * * PrintUsage -- * * Generate a help string describing command-line options. * * Results: * The interp's result will be modified to hold a help string describing * all the options in argTable, plus all those in the default table * unless TK_ARGV_NO_DEFAULTS is specified in flags. * * Side effects: * None. * *---------------------------------------------------------------------- */ func _PrintUsage(tls *libc.TLS, interp uintptr, argTable uintptr, flags int32) { bp := tls.Alloc(16) defer tls.Free(16) /* If the TK_ARGV_NO_DEFAULTS bit is set in * this word, then don't generate information * for default options. */ var i, length, numSpaces, width, v7 Tsize_t var infoPtr, message, string1, v3, v6 uintptr _, _, _, _, _, _, _, _, _, _ = i, infoPtr, length, message, numSpaces, string1, width, v3, v6, v7 /* * First, compute the width of the widest option key, so that we can make * everything line up. */ width = uint64(4) i = uint64(0) for { if !(i < uint64(2)) { break } if i != 0 { v3 = uintptr(unsafe.Pointer(&_defaultTable)) } else { v3 = argTable } infoPtr = v3 for { if !((*TTk_ArgvInfo)(unsafe.Pointer(infoPtr)).Ftype1 != int32(TK_ARGV_END)) { break } if (*TTk_ArgvInfo)(unsafe.Pointer(infoPtr)).Fkey == libc.UintptrFromInt32(0) { goto _2 } length = libc.Xstrlen(tls, (*TTk_ArgvInfo)(unsafe.Pointer(infoPtr)).Fkey) if length > width { width = length } goto _2 _2: ; infoPtr += 40 } goto _1 _1: ; i++ } message = libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+598, int64(-libc.Int32FromInt32(1))) i = uint64(0) for { if i != 0 { v6 = uintptr(unsafe.Pointer(&_defaultTable)) } else { v6 = argTable } infoPtr = v6 for { if !((*TTk_ArgvInfo)(unsafe.Pointer(infoPtr)).Ftype1 != int32(TK_ARGV_END)) { break } if (*TTk_ArgvInfo)(unsafe.Pointer(infoPtr)).Ftype1 == int32(TK_ARGV_HELP) && (*TTk_ArgvInfo)(unsafe.Pointer(infoPtr)).Fkey == libc.UintptrFromInt32(0) { libtcl9_0.XTcl_AppendPrintfToObj(tls, message, __ccgo_ts+624, libc.VaList(bp+8, (*TTk_ArgvInfo)(unsafe.Pointer(infoPtr)).Fhelp)) goto _5 } libtcl9_0.XTcl_AppendPrintfToObj(tls, message, __ccgo_ts+628, libc.VaList(bp+8, (*TTk_ArgvInfo)(unsafe.Pointer(infoPtr)).Fkey)) numSpaces = width + uint64(1) - libc.Xstrlen(tls, (*TTk_ArgvInfo)(unsafe.Pointer(infoPtr)).Fkey) for { v7 = numSpaces numSpaces-- if !(v7 > uint64(0)) { break } libtcl9_0.XTcl_AppendToObj(tls, message, __ccgo_ts+634, int64(1)) } libtcl9_0.XTcl_AppendToObj(tls, message, (*TTk_ArgvInfo)(unsafe.Pointer(infoPtr)).Fhelp, int64(-libc.Int32FromInt32(1))) switch (*TTk_ArgvInfo)(unsafe.Pointer(infoPtr)).Ftype1 { case int32(TK_ARGV_INT): libtcl9_0.XTcl_AppendPrintfToObj(tls, message, __ccgo_ts+636, libc.VaList(bp+8, *(*int32)(unsafe.Pointer((*TTk_ArgvInfo)(unsafe.Pointer(infoPtr)).Fdst)))) case int32(TK_ARGV_FLOAT): libtcl9_0.XTcl_AppendPrintfToObj(tls, message, __ccgo_ts+657, libc.VaList(bp+8, *(*float64)(unsafe.Pointer((*TTk_ArgvInfo)(unsafe.Pointer(infoPtr)).Fdst)))) case int32(TK_ARGV_STRING): string1 = *(*uintptr)(unsafe.Pointer((*TTk_ArgvInfo)(unsafe.Pointer(infoPtr)).Fdst)) if string1 != libc.UintptrFromInt32(0) { libtcl9_0.XTcl_AppendPrintfToObj(tls, message, __ccgo_ts+678, libc.VaList(bp+8, string1)) } default: break } goto _5 _5: ; infoPtr += 40 } if flags&int32(TK_ARGV_NO_DEFAULTS) != 0 || i > uint64(0) { break } libtcl9_0.XTcl_AppendToObj(tls, message, __ccgo_ts+701, int64(-libc.Int32FromInt32(1))) goto _4 _4: ; i++ } libtcl9_0.XTcl_SetObjResult(tls, interp, message) } /* * Local Variables: * mode: c * c-basic-offset: 4 * fill-column: 78 * End: */ /* * The following are a list of the predefined atom strings. They should match * those found in xatom.h */ var _atomNameArray = [69]uintptr{ 0: __ccgo_ts + 736, 1: __ccgo_ts + 744, 2: __ccgo_ts + 754, 3: __ccgo_ts + 758, 4: __ccgo_ts + 763, 5: __ccgo_ts + 770, 6: __ccgo_ts + 779, 7: __ccgo_ts + 788, 8: __ccgo_ts + 795, 9: __ccgo_ts + 807, 10: __ccgo_ts + 819, 11: __ccgo_ts + 831, 12: __ccgo_ts + 843, 13: __ccgo_ts + 855, 14: __ccgo_ts + 867, 15: __ccgo_ts + 879, 16: __ccgo_ts + 891, 17: __ccgo_ts + 900, 18: __ccgo_ts + 905, 19: __ccgo_ts + 913, 20: __ccgo_ts + 920, 21: __ccgo_ts + 926, 22: __ccgo_ts + 936, 23: __ccgo_ts + 953, 24: __ccgo_ts + 967, 25: __ccgo_ts + 980, 26: __ccgo_ts + 993, 27: __ccgo_ts + 1009, 28: __ccgo_ts + 1022, 29: __ccgo_ts + 1036, 30: __ccgo_ts + 1048, 31: __ccgo_ts + 1055, 32: __ccgo_ts + 1064, 33: __ccgo_ts + 1071, 34: __ccgo_ts + 1082, 35: __ccgo_ts + 1091, 36: __ccgo_ts + 1109, 37: __ccgo_ts + 1122, 38: __ccgo_ts + 1135, 39: __ccgo_ts + 1143, 40: __ccgo_ts + 1159, 41: __ccgo_ts + 1173, 42: __ccgo_ts + 1187, 43: __ccgo_ts + 1197, 44: __ccgo_ts + 1208, 45: __ccgo_ts + 1218, 46: __ccgo_ts + 1228, 47: __ccgo_ts + 1242, 48: __ccgo_ts + 1256, 49: __ccgo_ts + 1268, 50: __ccgo_ts + 1280, 51: __ccgo_ts + 1299, 52: __ccgo_ts + 1319, 53: __ccgo_ts + 1336, 54: __ccgo_ts + 1354, 55: __ccgo_ts + 1367, 56: __ccgo_ts + 1376, 57: __ccgo_ts + 1387, 58: __ccgo_ts + 1394, 59: __ccgo_ts + 1405, 60: __ccgo_ts + 1416, 61: __ccgo_ts + 1426, 62: __ccgo_ts + 1433, 63: __ccgo_ts + 1443, 64: __ccgo_ts + 1455, 65: __ccgo_ts + 1465, 66: __ccgo_ts + 1476, 67: __ccgo_ts + 1485, 68: libc.UintptrFromInt32(0), } /* *-------------------------------------------------------------- * * Tk_InternAtom -- * * Given a string, produce the equivalent X atom. This function is * equivalent to XInternAtom, except that it keeps a local cache of * atoms. Once a name is known, the server need not be contacted again * for that name. * * Results: * The return value is the Atom corresponding to name. * * Side effects: * A new entry may be added to the local atom cache. * *-------------------------------------------------------------- */ func XTk_InternAtom(tls *libc.TLS, tkwin TTk_Window, name uintptr) (r TAtom) { bp := tls.Alloc(16) defer tls.Free(16) /* Name to turn into atom. */ var atom TAtom var dispPtr, hPtr, hPtr2, v1 uintptr var _ /* isNew at bp+0 */ int32 _, _, _, _, _ = atom, dispPtr, hPtr, hPtr2, v1 dispPtr = (*TTkWindow)(unsafe.Pointer(tkwin)).FdispPtr if !((*TTkDisplay)(unsafe.Pointer(dispPtr)).FatomInit != 0) { _AtomInit(tls, dispPtr) } hPtr = (*(*func(*libc.TLS, uintptr, uintptr, uintptr) uintptr)(unsafe.Pointer(&struct{ uintptr }{(*TTcl_HashTable)(unsafe.Pointer(dispPtr + 152)).FcreateProc})))(tls, dispPtr+152, name, bp) if *(*int32)(unsafe.Pointer(bp)) != 0 { atom = libx11.XXInternAtom(tls, (*TTkDisplay)(unsafe.Pointer(dispPtr)).Fdisplay, name, False) (*TTcl_HashEntry)(unsafe.Pointer(hPtr)).FclientData = uintptr(libc.Int64FromUint64(atom)) hPtr2 = (*(*func(*libc.TLS, uintptr, uintptr, uintptr) uintptr)(unsafe.Pointer(&struct{ uintptr }{(*TTcl_HashTable)(unsafe.Pointer(dispPtr + 256)).FcreateProc})))(tls, dispPtr+256, uintptr(libc.Int64FromUint64(atom)), bp) if (*TTcl_HashTable)(unsafe.Pointer(dispPtr+152)).FkeyType == int32(TCL_ONE_WORD_KEYS) || (*TTcl_HashTable)(unsafe.Pointer(dispPtr+152)).FkeyType == -int32(1) { v1 = *(*uintptr)(unsafe.Pointer(hPtr + 32)) } else { v1 = hPtr + 32 } (*TTcl_HashEntry)(unsafe.Pointer(hPtr2)).FclientData = v1 } return libc.Uint64FromInt64(int64((*TTcl_HashEntry)(unsafe.Pointer(hPtr)).FclientData)) } /* *-------------------------------------------------------------- * * Tk_GetAtomName -- * * This function is equivalent to XGetAtomName except that it uses the * local atom cache to avoid contacting the server. * * Results: * The return value is a character string corresponding to the atom given * by "atom". This string's storage space is static: it need not be freed * by the caller, and should not be modified by the caller. If "atom" * doesn't exist on tkwin's display, then the string "?bad atom?" is * returned. * * Side effects: * None. * *-------------------------------------------------------------- */ func XTk_GetAtomName(tls *libc.TLS, tkwin TTk_Window, atom TAtom) (r uintptr) { bp := tls.Alloc(16) defer tls.Free(16) /* Atom whose name is wanted. */ var dispPtr, hPtr, mustFree, name, v1, v2 uintptr var handler TTk_ErrorHandler var _ /* isNew at bp+0 */ int32 _, _, _, _, _, _, _ = dispPtr, hPtr, handler, mustFree, name, v1, v2 dispPtr = (*TTkWindow)(unsafe.Pointer(tkwin)).FdispPtr if !((*TTkDisplay)(unsafe.Pointer(dispPtr)).FatomInit != 0) { _AtomInit(tls, dispPtr) } hPtr = (*(*func(*libc.TLS, uintptr, uintptr) uintptr)(unsafe.Pointer(&struct{ uintptr }{(*TTcl_HashTable)(unsafe.Pointer(dispPtr + 256)).FfindProc})))(tls, dispPtr+256, uintptr(libc.Int64FromUint64(atom))) if hPtr == libc.UintptrFromInt32(0) { mustFree = libc.UintptrFromInt32(0) handler = XTk_CreateErrorHandler(tls, (*TTkDisplay)(unsafe.Pointer(dispPtr)).Fdisplay, int32(BadAtom), -int32(1), -int32(1), libc.UintptrFromInt32(0), libc.UintptrFromInt32(0)) v1 = libx11.XXGetAtomName(tls, (*TTkDisplay)(unsafe.Pointer(dispPtr)).Fdisplay, atom) mustFree = v1 name = v1 if name == libc.UintptrFromInt32(0) { name = __ccgo_ts + 1502 } XTk_DeleteErrorHandler(tls, handler) hPtr = (*(*func(*libc.TLS, uintptr, uintptr, uintptr) uintptr)(unsafe.Pointer(&struct{ uintptr }{(*TTcl_HashTable)(unsafe.Pointer(dispPtr + 152)).FcreateProc})))(tls, dispPtr+152, name, bp) (*TTcl_HashEntry)(unsafe.Pointer(hPtr)).FclientData = uintptr(libc.Int64FromUint64(atom)) if mustFree != 0 { libx11.XXFree(tls, mustFree) } if (*TTcl_HashTable)(unsafe.Pointer(dispPtr+152)).FkeyType == int32(TCL_ONE_WORD_KEYS) || (*TTcl_HashTable)(unsafe.Pointer(dispPtr+152)).FkeyType == -int32(1) { v2 = *(*uintptr)(unsafe.Pointer(hPtr + 32)) } else { v2 = hPtr + 32 } name = v2 hPtr = (*(*func(*libc.TLS, uintptr, uintptr, uintptr) uintptr)(unsafe.Pointer(&struct{ uintptr }{(*TTcl_HashTable)(unsafe.Pointer(dispPtr + 256)).FcreateProc})))(tls, dispPtr+256, uintptr(libc.Int64FromUint64(atom)), bp) (*TTcl_HashEntry)(unsafe.Pointer(hPtr)).FclientData = name } return (*TTcl_HashEntry)(unsafe.Pointer(hPtr)).FclientData } /* *-------------------------------------------------------------- * * AtomInit -- * * Initialize atom-related information for a display. * * Results: * None. * * Side effects: * Tables get initialized, etc. etc.. * *-------------------------------------------------------------- */ func _AtomInit(tls *libc.TLS, dispPtr uintptr) { bp := tls.Alloc(16) defer tls.Free(16) /* Display to initialize. */ var atom TAtom var hPtr, name, v2 uintptr var _ /* isNew at bp+0 */ int32 _, _, _, _ = atom, hPtr, name, v2 (*TTkDisplay)(unsafe.Pointer(dispPtr)).FatomInit = int32(1) libtcl9_0.XTcl_InitHashTable(tls, dispPtr+152, TCL_STRING_KEYS) libtcl9_0.XTcl_InitHashTable(tls, dispPtr+256, int32(TCL_ONE_WORD_KEYS)) atom = uint64(1) for { if !(atom <= libc.Uint64FromInt32(68)) { break } hPtr = (*(*func(*libc.TLS, uintptr, uintptr) uintptr)(unsafe.Pointer(&struct{ uintptr }{(*TTcl_HashTable)(unsafe.Pointer(dispPtr + 256)).FfindProc})))(tls, dispPtr+256, uintptr(libc.Int64FromUint64(atom))) if hPtr != libc.UintptrFromInt32(0) { goto _1 } name = _atomNameArray[atom-uint64(1)] hPtr = (*(*func(*libc.TLS, uintptr, uintptr, uintptr) uintptr)(unsafe.Pointer(&struct{ uintptr }{(*TTcl_HashTable)(unsafe.Pointer(dispPtr + 152)).FcreateProc})))(tls, dispPtr+152, name, bp) (*TTcl_HashEntry)(unsafe.Pointer(hPtr)).FclientData = uintptr(libc.Int64FromUint64(atom)) if (*TTcl_HashTable)(unsafe.Pointer(dispPtr+152)).FkeyType == int32(TCL_ONE_WORD_KEYS) || (*TTcl_HashTable)(unsafe.Pointer(dispPtr+152)).FkeyType == -int32(1) { v2 = *(*uintptr)(unsafe.Pointer(hPtr + 32)) } else { v2 = hPtr + 32 } name = v2 hPtr = (*(*func(*libc.TLS, uintptr, uintptr, uintptr) uintptr)(unsafe.Pointer(&struct{ uintptr }{(*TTcl_HashTable)(unsafe.Pointer(dispPtr + 256)).FcreateProc})))(tls, dispPtr+256, uintptr(libc.Int64FromUint64(atom)), bp) (*TTcl_HashEntry)(unsafe.Pointer(hPtr)).FclientData = name goto _1 _1: ; atom++ } } const ACTIVATE = 262144 const BUTTON = 2 const CAN_WARP = 524295 const CIRC = 16384 const CIRCREQ = 8388608 const COLORMAP = 65536 const CONFIG = 4096 const CONFIGREQ = 2097152 const CREATE = 128 const CROSSING = 8 const DESTROY = 256 const DOUBLE = 1 const EXPOSE = 32 const FOCUS = 16 const GRAVITY = 8192 const HAS_XKEY_HEAD = 655375 const HAS_XKEY_HEAD_AND_STATE = 655367 const KEY = 1 const MAP = 1024 const MAPREQ = 1048576 const MAX_MOD_MASK_ARR_SIZE = 8 const MOTION = 4 const MULT_CLICKS = 7 const NEARBY_MS = 500 const NEARBY_PIXELS = 5 const PRINT_SHORT_MOTION_SYNTAX = 0 const PROP = 32768 const QUADRUPLE = 4 const REPARENT = 2048 const RESIZEREQ = 4194304 const SUPPORT_DEBUGGING = 0 const TRIPLE = 2 const TkMacOSXDrawable = 0 const UNMAP = 512 const VIRTUAL = 131072 const VISIBILITY = 64 const WHEEL = 524288 type TTk_BindingTable_ = struct { FeventInfo [40]TEvent FpromArr uintptr FcurEvent uintptr FcurModMask uint32 FlookupTables TLookupTables FobjectTable TTcl_HashTable Finterp uintptr } type TTkBindInfo_ = struct { FvirtualEventTable TVirtualEventTable FscreenInfo TScreenInfo Fdeleted int32 FlastEventTime TTime FlastCurrentTime TTime } type TTkIntPlatStubs = struct { Fmagic int32 Fhooks uintptr FtkCreateXEventSource uintptr Freserved1 uintptr FtkGenerateActivateEvents uintptr Freserved3 uintptr Freserved4 uintptr Freserved5 uintptr FtkpScanWindowId uintptr Freserved7 uintptr Freserved8 uintptr FtkpWmSetState uintptr Freserved10 uintptr Freserved11 uintptr Freserved12 uintptr Freserved13 uintptr Freserved14 uintptr Freserved15 uintptr Freserved16 uintptr Freserved17 uintptr Freserved18 uintptr Freserved19 uintptr Freserved20 uintptr Freserved21 uintptr Freserved22 uintptr Freserved23 uintptr Freserved24 uintptr Freserved25 uintptr Freserved26 uintptr Freserved27 uintptr Freserved28 uintptr Freserved29 uintptr Freserved30 uintptr Freserved31 uintptr Freserved32 uintptr Freserved33 uintptr Freserved34 uintptr Freserved35 uintptr Freserved36 uintptr Freserved37 uintptr FtkpCmapStressed uintptr FtkpSync uintptr FtkUnixContainerId uintptr FtkUnixDoOneXEvent uintptr FtkUnixSetMenubar uintptr FtkWmCleanup uintptr FtkSendCleanup uintptr FtkpTestsendCmd uintptr } /* * Local Variables: * mode: c * c-basic-offset: 4 * fill-column: 78 * End: */ /* * File structure: * * Structure definitions and static variables. * * Init/Free this package. * * Tcl "bind" command (actually located in tkCmds.c) core implementation, plus helpers. * * Tcl "event" command implementation, plus helpers. * * Package-specific common helpers. * * Non-package-specific helpers. */ /* * The output for motion events is of the type . This can be changed to become * instead by setting PRINT_SHORT_MOTION_SYNTAX to 1, however this would be a * backwards incompatibility. */ /* * For debugging only, normally set to zero. */ /* * Test validity of PSEntry items. */ /* * The following union is used to hold the detail information from an XEvent * (including Tk's XVirtualEvent extension). */ type TInfo = uint64 type TDetail = struct { Fname [0]TTk_Uid Finfo TInfo } /* * We need an extended event definition. */ type TEvent = struct { Fxev TXEvent Fdetail TDetail FcountAny uint32 FcountDetailed uint32 } type TPatSeq1 = struct { FnumPats uint32 Fcount uint32 Fnumber uint32 F__ccgo12 uint8 Fscript uintptr Fobject uintptr FnextSeqPtr uintptr FhPtr uintptr Fptr struct { FnextObj [0]uintptr Fowners uintptr } Fpats [1]TTkPattern } /* forward declaration */ // C documentation // // /* We need this array for bookkeeping the last matching modifier mask per pattern. */ // /* AT = type of array */ // /* ------------------------------------------------------------------------- */ type TPSModMaskArr = struct { Fsize Tsize_t Fcapacity Tsize_t Fbuf [1]uint32 } func _PSModMaskArr_Init(tls *libc.TLS, arr uintptr) { (*TPSModMaskArr)(unsafe.Pointer(arr)).Fsize = uint64(0) (*TPSModMaskArr)(unsafe.Pointer(arr)).Fcapacity = uint64(0) } func _PSModMaskArr_ElemSize(tls *libc.TLS) (r Tsize_t) { return uint64(4) } func _PSModMaskArr_BufferSize(tls *libc.TLS, numElems Tsize_t) (r Tsize_t) { return numElems * uint64(4) } func _PSModMaskArr_IsEmpty(tls *libc.TLS, arr uintptr) (r int32) { return libc.BoolInt32(!(arr != 0) || (*TPSModMaskArr)(unsafe.Pointer(arr)).Fsize == 0) } func _PSModMaskArr_Size(tls *libc.TLS, arr uintptr) (r Tsize_t) { var v1 uint64 _ = v1 if arr != 0 { v1 = (*TPSModMaskArr)(unsafe.Pointer(arr)).Fsize } else { v1 = 0 } return v1 } func _PSModMaskArr_Capacity(tls *libc.TLS, arr uintptr) (r Tsize_t) { var v1 uint64 _ = v1 if arr != 0 { v1 = (*TPSModMaskArr)(unsafe.Pointer(arr)).Fcapacity } else { v1 = 0 } return v1 } func _PSModMaskArr_First(tls *libc.TLS, arr uintptr) (r uintptr) { var v1 uintptr _ = v1 if arr != 0 { v1 = arr + 16 } else { v1 = libc.UintptrFromInt32(0) } return v1 } func _PSModMaskArr_Last(tls *libc.TLS, arr uintptr) (r uintptr) { var v1 uintptr _ = v1 if arr != 0 { v1 = arr + 16 + uintptr((*TPSModMaskArr)(unsafe.Pointer(arr)).Fsize)*4 } else { v1 = libc.UintptrFromInt32(0) } return v1 } func _PSModMaskArr_Front(tls *libc.TLS, arr uintptr) (r uintptr) { return arr + 16 } func _PSModMaskArr_Back(tls *libc.TLS, arr uintptr) (r uintptr) { return arr + 16 + uintptr((*TPSModMaskArr)(unsafe.Pointer(arr)).Fsize-uint64(1))*4 } func _PSModMaskArr_Resize(tls *libc.TLS, arrp uintptr, newSize Tsize_t) { var init1 int32 var memSize Tsize_t _, _ = init1, memSize if newSize == uint64(0) { libtcl9_0.XTcl_Free(tls, *(*uintptr)(unsafe.Pointer(arrp))) *(*uintptr)(unsafe.Pointer(arrp)) = libc.UintptrFromInt32(0) } else { init1 = libc.BoolInt32(*(*uintptr)(unsafe.Pointer(arrp)) == libc.UintptrFromInt32(0)) memSize = _PSModMaskArr_BufferSize(tls, newSize-uint64(1)) + uint64(24) *(*uintptr)(unsafe.Pointer(arrp)) = libtcl9_0.XTcl_Realloc(tls, *(*uintptr)(unsafe.Pointer(arrp)), memSize) if init1 != 0 { (*TPSModMaskArr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(arrp)))).Fsize = uint64(0) } else { if newSize < (*TPSModMaskArr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(arrp)))).Fsize { (*TPSModMaskArr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(arrp)))).Fsize = newSize } } (*TPSModMaskArr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(arrp)))).Fcapacity = newSize } } func _PSModMaskArr_Clear(tls *libc.TLS, arr uintptr, from Tsize_t, to Tsize_t) { libc.Xmemset(tls, arr+16+uintptr(from)*4, 0, _PSModMaskArr_BufferSize(tls, to-from)) } func _PSModMaskArr_ResizeAndClear(tls *libc.TLS, arrp uintptr, newSize Tsize_t) { var oldCapacity Tsize_t var v1 uint64 _, _ = oldCapacity, v1 if *(*uintptr)(unsafe.Pointer(arrp)) != 0 { v1 = (*TPSModMaskArr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(arrp)))).Fcapacity } else { v1 = uint64(0) } oldCapacity = v1 _PSModMaskArr_Resize(tls, arrp, newSize) if newSize > oldCapacity { _PSModMaskArr_Clear(tls, *(*uintptr)(unsafe.Pointer(arrp)), oldCapacity, newSize) } } func _PSModMaskArr_SetSize(tls *libc.TLS, arr uintptr, newSize Tsize_t) { if arr != 0 { (*TPSModMaskArr)(unsafe.Pointer(arr)).Fsize = newSize } } func _PSModMaskArr_Append(tls *libc.TLS, arrp uintptr, elem uintptr) { var v1 Tsize_t var v2 uintptr _, _ = v1, v2 if !(*(*uintptr)(unsafe.Pointer(arrp)) != 0) { _PSModMaskArr_Resize(tls, arrp, uint64(1)) } else { if (*TPSModMaskArr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(arrp)))).Fsize == (*TPSModMaskArr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(arrp)))).Fcapacity { _PSModMaskArr_Resize(tls, arrp, (*TPSModMaskArr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(arrp)))).Fcapacity+((*TPSModMaskArr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(arrp)))).Fcapacity+uint64(1))/uint64(2)) } } v2 = *(*uintptr)(unsafe.Pointer(arrp)) v1 = *(*Tsize_t)(unsafe.Pointer(v2)) *(*Tsize_t)(unsafe.Pointer(v2))++ *(*uint32)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(arrp)) + 16 + uintptr(v1)*4)) = *(*uint32)(unsafe.Pointer(elem)) } func _PSModMaskArr_PopBack(tls *libc.TLS, arr uintptr) (r Tsize_t) { var p1 uintptr _ = p1 p1 = arr *(*Tsize_t)(unsafe.Pointer(p1)) -= uint64(1) return *(*Tsize_t)(unsafe.Pointer(p1)) } func _PSModMaskArr_Get(tls *libc.TLS, arr uintptr, at Tsize_t) (r uintptr) { return arr + 16 + uintptr(at)*4 } func _PSModMaskArr_Set(tls *libc.TLS, arr uintptr, at Tsize_t, elem uintptr) { *(*uint32)(unsafe.Pointer(arr + 16 + uintptr(at)*4)) = *(*uint32)(unsafe.Pointer(elem)) } func _PSModMaskArr_Free(tls *libc.TLS, arrp uintptr) { _PSModMaskArr_Resize(tls, arrp, uint64(0)) } func _PSModMaskArr_Find(tls *libc.TLS, arr uintptr, elem uintptr) (r int32) { var buf uintptr var i Tsize_t _, _ = buf, i if arr != 0 { buf = arr + 16 i = uint64(0) for { if !(i < (*TPSModMaskArr)(unsafe.Pointer(arr)).Fsize) { break } if libc.Xmemcmp(tls, buf+uintptr(i)*4, elem, uint64(4)) == 0 { return libc.Int32FromUint64(i) } goto _1 _1: ; i++ } } return -int32(1) } func _PSModMaskArr_Contains(tls *libc.TLS, arr uintptr, elem uintptr) (r int32) { return libc.BoolInt32(_PSModMaskArr_Find(tls, arr, elem) != -int32(1)) } type TPSEntry = struct { F_dl_ struct { Fprev uintptr Fnext uintptr } Fwindow TWindow FpsPtr uintptr FlastModMaskArr uintptr Fcount uint32 F__ccgo44 uint8 } // C documentation // // /* Defining the whole PSList_* stuff (list of PSEntry items). */ // /* LT = type of head/list */ // /* ------------------------------------------------------------------------- */ type TPSList = struct { Ffirst uintptr Flast uintptr } func _PSList_Init(tls *libc.TLS, head uintptr) { (*TPSList)(unsafe.Pointer(head)).Ffirst = libc.UintptrFromInt32(0) (*TPSList)(unsafe.Pointer(head)).Flast = libc.UintptrFromInt32(0) } func _PSList_ElemInit(tls *libc.TLS, elem uintptr) { (*TPSEntry1)(unsafe.Pointer(elem)).F_dl_.Fnext = libc.UintptrFromInt32(0) (*TPSEntry1)(unsafe.Pointer(elem)).F_dl_.Fprev = libc.UintptrFromInt32(0) } func _PSList_IsEmpty(tls *libc.TLS, head uintptr) (r int32) { return libc.BoolInt32((*TPSList)(unsafe.Pointer(head)).Ffirst == libc.UintptrFromInt32(0)) } func _PSList_IsLinked(tls *libc.TLS, elem uintptr) (r int32) { return libc.BoolInt32((*TPSEntry1)(unsafe.Pointer(elem)).F_dl_.Fnext != 0 && (*TPSEntry1)(unsafe.Pointer(elem)).F_dl_.Fprev != 0) } func _PSList_IsFirst(tls *libc.TLS, elem uintptr) (r int32) { return libc.BoolInt32((*TPSEntry1)(unsafe.Pointer((*TPSEntry1)(unsafe.Pointer(elem)).F_dl_.Fprev)).F_dl_.Fprev == elem) } func _PSList_IsLast(tls *libc.TLS, elem uintptr) (r int32) { return libc.BoolInt32((*TPSEntry1)(unsafe.Pointer((*TPSEntry1)(unsafe.Pointer(elem)).F_dl_.Fnext)).F_dl_.Fnext == elem) } func _PSList_First(tls *libc.TLS, head uintptr) (r uintptr) { return (*TPSList)(unsafe.Pointer(head)).Ffirst } func _PSList_Last(tls *libc.TLS, head uintptr) (r uintptr) { return (*TPSList)(unsafe.Pointer(head)).Flast } func _PSList_Next(tls *libc.TLS, elem uintptr) (r uintptr) { var v1 uintptr _ = v1 if _PSList_IsLast(tls, elem) != 0 { v1 = libc.UintptrFromInt32(0) } else { v1 = (*TPSEntry1)(unsafe.Pointer(elem)).F_dl_.Fnext } return v1 } func _PSList_Prev(tls *libc.TLS, elem uintptr) (r uintptr) { var v1 uintptr _ = v1 if _PSList_IsFirst(tls, elem) != 0 { v1 = libc.UintptrFromInt32(0) } else { v1 = (*TPSEntry1)(unsafe.Pointer(elem)).F_dl_.Fprev } return v1 } func _PSList_Size(tls *libc.TLS, head uintptr) (r uint32) { var elem, v1 uintptr var size uint32 _, _, _ = elem, size, v1 size = uint32(0) v1 = (*TPSList)(unsafe.Pointer(head)).Ffirst elem = v1 if v1 != 0 { for { if !(elem != head) { break } size++ goto _2 _2: ; elem = (*TPSEntry1)(unsafe.Pointer(elem)).F_dl_.Fnext } } return size } func _PSList_InsertAfter(tls *libc.TLS, listElem uintptr, elem uintptr) { (*TPSEntry1)(unsafe.Pointer(elem)).F_dl_.Fnext = (*TPSEntry1)(unsafe.Pointer(listElem)).F_dl_.Fnext (*TPSEntry1)(unsafe.Pointer(elem)).F_dl_.Fprev = listElem (*TPSEntry1)(unsafe.Pointer((*TPSEntry1)(unsafe.Pointer(listElem)).F_dl_.Fnext)).F_dl_.Fprev = elem (*TPSEntry1)(unsafe.Pointer(listElem)).F_dl_.Fnext = elem } func _PSList_InsertBefore(tls *libc.TLS, listElem uintptr, elem uintptr) { (*TPSEntry1)(unsafe.Pointer(elem)).F_dl_.Fnext = listElem (*TPSEntry1)(unsafe.Pointer(elem)).F_dl_.Fprev = (*TPSEntry1)(unsafe.Pointer(listElem)).F_dl_.Fprev (*TPSEntry1)(unsafe.Pointer((*TPSEntry1)(unsafe.Pointer(listElem)).F_dl_.Fprev)).F_dl_.Fnext = elem (*TPSEntry1)(unsafe.Pointer(listElem)).F_dl_.Fprev = elem } func _PSList_Prepend(tls *libc.TLS, head uintptr, elem uintptr) { (*TPSEntry1)(unsafe.Pointer(elem)).F_dl_.Fprev = head if !((*TPSList)(unsafe.Pointer(head)).Ffirst != 0) { (*TPSEntry1)(unsafe.Pointer(elem)).F_dl_.Fnext = head (*TPSList)(unsafe.Pointer(head)).Flast = elem } else { (*TPSEntry1)(unsafe.Pointer(elem)).F_dl_.Fnext = (*TPSList)(unsafe.Pointer(head)).Ffirst (*TPSEntry1)(unsafe.Pointer((*TPSList)(unsafe.Pointer(head)).Ffirst)).F_dl_.Fprev = elem } (*TPSList)(unsafe.Pointer(head)).Ffirst = elem } func _PSList_Append(tls *libc.TLS, head uintptr, elem uintptr) { (*TPSEntry1)(unsafe.Pointer(elem)).F_dl_.Fnext = head if !((*TPSList)(unsafe.Pointer(head)).Ffirst != 0) { (*TPSEntry1)(unsafe.Pointer(elem)).F_dl_.Fprev = head (*TPSList)(unsafe.Pointer(head)).Ffirst = elem } else { (*TPSEntry1)(unsafe.Pointer(elem)).F_dl_.Fprev = (*TPSList)(unsafe.Pointer(head)).Flast (*TPSEntry1)(unsafe.Pointer((*TPSList)(unsafe.Pointer(head)).Flast)).F_dl_.Fnext = elem } (*TPSList)(unsafe.Pointer(head)).Flast = elem } func _PSList_Move(tls *libc.TLS, dst uintptr, src uintptr) { if (*TPSList)(unsafe.Pointer(src)).Ffirst != 0 { if (*TPSList)(unsafe.Pointer(dst)).Ffirst != 0 { (*TPSEntry1)(unsafe.Pointer((*TPSList)(unsafe.Pointer(dst)).Flast)).F_dl_.Fnext = (*TPSList)(unsafe.Pointer(src)).Ffirst (*TPSEntry1)(unsafe.Pointer((*TPSList)(unsafe.Pointer(src)).Ffirst)).F_dl_.Fprev = (*TPSList)(unsafe.Pointer(dst)).Flast (*TPSList)(unsafe.Pointer(dst)).Flast = (*TPSList)(unsafe.Pointer(src)).Flast } else { *(*TPSList)(unsafe.Pointer(dst)) = *(*TPSList)(unsafe.Pointer(src)) (*TPSEntry1)(unsafe.Pointer((*TPSList)(unsafe.Pointer(dst)).Ffirst)).F_dl_.Fprev = dst } (*TPSEntry1)(unsafe.Pointer((*TPSList)(unsafe.Pointer(dst)).Flast)).F_dl_.Fnext = dst _PSList_Init(tls, src) } } func _PSList_Remove(tls *libc.TLS, elem uintptr) { var isFirst, isLast int32 _, _ = isFirst, isLast isFirst = _PSList_IsFirst(tls, elem) isLast = _PSList_IsLast(tls, elem) if isFirst != 0 && isLast != 0 { (*TPSList)(unsafe.Pointer((*TPSEntry1)(unsafe.Pointer(elem)).F_dl_.Fprev)).Ffirst = libc.UintptrFromInt32(0) (*TPSList)(unsafe.Pointer((*TPSEntry1)(unsafe.Pointer(elem)).F_dl_.Fnext)).Flast = libc.UintptrFromInt32(0) } else { if isFirst != 0 { (*TPSList)(unsafe.Pointer((*TPSEntry1)(unsafe.Pointer(elem)).F_dl_.Fprev)).Ffirst = (*TPSEntry1)(unsafe.Pointer(elem)).F_dl_.Fnext } else { (*TPSEntry1)(unsafe.Pointer((*TPSEntry1)(unsafe.Pointer(elem)).F_dl_.Fprev)).F_dl_.Fnext = (*TPSEntry1)(unsafe.Pointer(elem)).F_dl_.Fnext } if isLast != 0 { (*TPSList)(unsafe.Pointer((*TPSEntry1)(unsafe.Pointer(elem)).F_dl_.Fnext)).Flast = (*TPSEntry1)(unsafe.Pointer(elem)).F_dl_.Fprev } else { (*TPSEntry1)(unsafe.Pointer((*TPSEntry1)(unsafe.Pointer(elem)).F_dl_.Fnext)).F_dl_.Fprev = (*TPSEntry1)(unsafe.Pointer(elem)).F_dl_.Fprev } } _PSList_ElemInit(tls, elem) } func _PSList_Free(tls *libc.TLS, elem uintptr) { _PSList_Remove(tls, elem) libtcl9_0.XTcl_Free(tls, elem) } func _PSList_RemoveHead(tls *libc.TLS, head uintptr) { _PSList_Remove(tls, (*TPSList)(unsafe.Pointer(head)).Ffirst) } func _PSList_RemoveTail(tls *libc.TLS, head uintptr) { _PSList_Remove(tls, (*TPSList)(unsafe.Pointer(head)).Flast) } func _PSList_FreeHead(tls *libc.TLS, head uintptr) { _PSList_Free(tls, (*TPSList)(unsafe.Pointer(head)).Ffirst) } func _PSList_FreeTail(tls *libc.TLS, head uintptr) { _PSList_Free(tls, (*TPSList)(unsafe.Pointer(head)).Flast) } func _PSList_SwapElems(tls *libc.TLS, lhs uintptr, rhs uintptr) { var tmp TPSEntry1 _ = tmp if lhs != rhs { if _PSList_IsFirst(tls, lhs) != 0 { (*TPSList)(unsafe.Pointer((*TPSEntry1)(unsafe.Pointer(lhs)).F_dl_.Fprev)).Ffirst = rhs } else { if _PSList_IsFirst(tls, rhs) != 0 { (*TPSList)(unsafe.Pointer((*TPSEntry1)(unsafe.Pointer(rhs)).F_dl_.Fprev)).Ffirst = lhs } } if _PSList_IsLast(tls, lhs) != 0 { (*TPSList)(unsafe.Pointer((*TPSEntry1)(unsafe.Pointer(lhs)).F_dl_.Fnext)).Flast = rhs } else { if _PSList_IsLast(tls, rhs) != 0 { (*TPSList)(unsafe.Pointer((*TPSEntry1)(unsafe.Pointer(rhs)).F_dl_.Fnext)).Flast = lhs } } tmp.F_dl_ = (*TPSEntry1)(unsafe.Pointer(lhs)).F_dl_ (*TPSEntry1)(unsafe.Pointer(lhs)).F_dl_ = (*TPSEntry1)(unsafe.Pointer(rhs)).F_dl_ (*TPSEntry1)(unsafe.Pointer(rhs)).F_dl_ = tmp.F_dl_ } } func _PSList_Clear(tls *libc.TLS, head uintptr) { var next, p uintptr _, _ = next, p p = (*TPSList)(unsafe.Pointer(head)).Ffirst for { if !(p != 0) { break } next = _PSList_Next(tls, p) libtcl9_0.XTcl_Free(tls, p) goto _1 _1: ; p = next } _PSList_Init(tls, head) } func _PSList_Traverse(tls *libc.TLS, head uintptr, func1 uintptr) { var next, p uintptr _, _ = next, p p = (*TPSList)(unsafe.Pointer(head)).Ffirst for { if !(p != 0) { break } next = (*(*func(*libc.TLS, uintptr, uintptr) uintptr)(unsafe.Pointer(&struct{ uintptr }{func1})))(tls, head, p) goto _1 _1: ; p = next } } /* Don't keep larger arrays of modifier masks inside PSEntry. */ /* * Maps and lookup tables from an event to a list of patterns that match that event. */ type TLookupTables = struct { FpatternTable TTcl_HashTable FlistTable TTcl_HashTable FentryPool TPSList Fnumber uint32 } /* * The structure below represents a binding table. A binding table represents * a domain in which event bindings may occur. It includes a space of objects * relative to which events occur (usually windows, but not always), a history * of recent events in the domain, and a set of mappings that associate * particular Tcl commands with sequences of events in the domain. Multiple * binding tables may exist at once, either because there are multiple * applications open, or because there are multiple domains within an * application with separate event bindings for each (for example, each canvas * widget has a separate binding table for associating events with the items * in the canvas). */ // C documentation // // /* Defining the whole PromArr_* stuff (array of PSList entries) */ // /* AT = type of array */ // /* ------------------------------------------------------------------------- */ type TPromArr = struct { Fsize Tsize_t Fcapacity Tsize_t Fbuf [1]TPSList } func _PromArr_Init(tls *libc.TLS, arr uintptr) { (*TPromArr)(unsafe.Pointer(arr)).Fsize = uint64(0) (*TPromArr)(unsafe.Pointer(arr)).Fcapacity = uint64(0) } func _PromArr_ElemSize(tls *libc.TLS) (r Tsize_t) { return uint64(16) } func _PromArr_BufferSize(tls *libc.TLS, numElems Tsize_t) (r Tsize_t) { return numElems * uint64(16) } func _PromArr_IsEmpty(tls *libc.TLS, arr uintptr) (r int32) { return libc.BoolInt32(!(arr != 0) || (*TPromArr)(unsafe.Pointer(arr)).Fsize == 0) } func _PromArr_Size(tls *libc.TLS, arr uintptr) (r Tsize_t) { var v1 uint64 _ = v1 if arr != 0 { v1 = (*TPromArr)(unsafe.Pointer(arr)).Fsize } else { v1 = 0 } return v1 } func _PromArr_Capacity(tls *libc.TLS, arr uintptr) (r Tsize_t) { var v1 uint64 _ = v1 if arr != 0 { v1 = (*TPromArr)(unsafe.Pointer(arr)).Fcapacity } else { v1 = 0 } return v1 } func _PromArr_First(tls *libc.TLS, arr uintptr) (r uintptr) { var v1 uintptr _ = v1 if arr != 0 { v1 = arr + 16 } else { v1 = libc.UintptrFromInt32(0) } return v1 } func _PromArr_Last(tls *libc.TLS, arr uintptr) (r uintptr) { var v1 uintptr _ = v1 if arr != 0 { v1 = arr + 16 + uintptr((*TPromArr)(unsafe.Pointer(arr)).Fsize)*16 } else { v1 = libc.UintptrFromInt32(0) } return v1 } func _PromArr_Front(tls *libc.TLS, arr uintptr) (r uintptr) { return arr + 16 } func _PromArr_Back(tls *libc.TLS, arr uintptr) (r uintptr) { return arr + 16 + uintptr((*TPromArr)(unsafe.Pointer(arr)).Fsize-uint64(1))*16 } func _PromArr_Resize(tls *libc.TLS, arrp uintptr, newSize Tsize_t) { var init1 int32 var memSize Tsize_t _, _ = init1, memSize if newSize == uint64(0) { libtcl9_0.XTcl_Free(tls, *(*uintptr)(unsafe.Pointer(arrp))) *(*uintptr)(unsafe.Pointer(arrp)) = libc.UintptrFromInt32(0) } else { init1 = libc.BoolInt32(*(*uintptr)(unsafe.Pointer(arrp)) == libc.UintptrFromInt32(0)) memSize = _PromArr_BufferSize(tls, newSize-uint64(1)) + uint64(32) *(*uintptr)(unsafe.Pointer(arrp)) = libtcl9_0.XTcl_Realloc(tls, *(*uintptr)(unsafe.Pointer(arrp)), memSize) if init1 != 0 { (*TPromArr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(arrp)))).Fsize = uint64(0) } else { if newSize < (*TPromArr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(arrp)))).Fsize { (*TPromArr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(arrp)))).Fsize = newSize } } (*TPromArr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(arrp)))).Fcapacity = newSize } } func _PromArr_Clear(tls *libc.TLS, arr uintptr, from Tsize_t, to Tsize_t) { libc.Xmemset(tls, arr+16+uintptr(from)*16, 0, _PromArr_BufferSize(tls, to-from)) } func _PromArr_ResizeAndClear(tls *libc.TLS, arrp uintptr, newSize Tsize_t) { var oldCapacity Tsize_t var v1 uint64 _, _ = oldCapacity, v1 if *(*uintptr)(unsafe.Pointer(arrp)) != 0 { v1 = (*TPromArr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(arrp)))).Fcapacity } else { v1 = uint64(0) } oldCapacity = v1 _PromArr_Resize(tls, arrp, newSize) if newSize > oldCapacity { _PromArr_Clear(tls, *(*uintptr)(unsafe.Pointer(arrp)), oldCapacity, newSize) } } func _PromArr_SetSize(tls *libc.TLS, arr uintptr, newSize Tsize_t) { if arr != 0 { (*TPromArr)(unsafe.Pointer(arr)).Fsize = newSize } } func _PromArr_Append(tls *libc.TLS, arrp uintptr, elem uintptr) { var v1 Tsize_t var v2 uintptr _, _ = v1, v2 if !(*(*uintptr)(unsafe.Pointer(arrp)) != 0) { _PromArr_Resize(tls, arrp, uint64(1)) } else { if (*TPromArr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(arrp)))).Fsize == (*TPromArr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(arrp)))).Fcapacity { _PromArr_Resize(tls, arrp, (*TPromArr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(arrp)))).Fcapacity+((*TPromArr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(arrp)))).Fcapacity+uint64(1))/uint64(2)) } } v2 = *(*uintptr)(unsafe.Pointer(arrp)) v1 = *(*Tsize_t)(unsafe.Pointer(v2)) *(*Tsize_t)(unsafe.Pointer(v2))++ *(*TPSList)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(arrp)) + 16 + uintptr(v1)*16)) = *(*TPSList)(unsafe.Pointer(elem)) } func _PromArr_PopBack(tls *libc.TLS, arr uintptr) (r Tsize_t) { var p1 uintptr _ = p1 p1 = arr *(*Tsize_t)(unsafe.Pointer(p1)) -= uint64(1) return *(*Tsize_t)(unsafe.Pointer(p1)) } func _PromArr_Get(tls *libc.TLS, arr uintptr, at Tsize_t) (r uintptr) { return arr + 16 + uintptr(at)*16 } func _PromArr_Set(tls *libc.TLS, arr uintptr, at Tsize_t, elem uintptr) { *(*TPSList)(unsafe.Pointer(arr + 16 + uintptr(at)*16)) = *(*TPSList)(unsafe.Pointer(elem)) } func _PromArr_Free(tls *libc.TLS, arrp uintptr) { _PromArr_Resize(tls, arrp, uint64(0)) } func _PromArr_Find(tls *libc.TLS, arr uintptr, elem uintptr) (r int32) { var buf uintptr var i Tsize_t _, _ = buf, i if arr != 0 { buf = arr + 16 i = uint64(0) for { if !(i < (*TPromArr)(unsafe.Pointer(arr)).Fsize) { break } if libc.Xmemcmp(tls, buf+uintptr(i)*16, elem, uint64(16)) == 0 { return libc.Int32FromUint64(i) } goto _1 _1: ; i++ } } return -int32(1) } func _PromArr_Contains(tls *libc.TLS, arr uintptr, elem uintptr) (r int32) { return libc.BoolInt32(_PromArr_Find(tls, arr, elem) != -int32(1)) } type TBindingTable = struct { FeventInfo [40]TEvent FpromArr uintptr FcurEvent uintptr FcurModMask uint32 FlookupTables TLookupTables FobjectTable TTcl_HashTable Finterp uintptr } /* * The following structure represents virtual event table. A virtual event * table provides a way to map from platform-specific physical events such as * button clicks or key presses to virtual events such as <>, * <>, or <>. * * A virtual event is usually never part of the event stream, but instead is * synthesized inline by matching low-level events. However, a virtual event * may be generated by platform-specific code or by Tcl commands. In that case, * no lookup of the virtual event will need to be done using this table, * because the virtual event is actually in the event stream. */ type TVirtualEventTable = struct { FlookupTables TLookupTables FnameTable TTcl_HashTable } /* * The following structure is used as a key in a patternTable for both binding * tables and a virtual event tables. * * In a binding table, the object field corresponds to the binding tag for the * widget whose bindings are being accessed. * * In a virtual event table, the object field is always NULL. Virtual events * are a global definiton and are not tied to a particular binding tag. * * The same key is used for both types of pattern tables so that the helper * functions that traverse and match patterns will work for both binding * tables and virtual event tables. */ type TPatternTableKey = struct { Fobject uintptr Ftype1 uint32 Fdetail TDetail } /* * The following structure defines a pattern, which is matched against X * events as part of the process of converting X events into Tcl commands. * * For technical reasons we do not use 'union Detail', although this would * be possible, instead 'info' and 'name' are both included. */ type TTkPattern = struct { FeventType uint32 Fcount uint32 FmodMask uint32 Finfo TInfo Fname TTk_Uid } /* * The following structure keeps track of all the virtual events that are * associated with a particular physical event. It is pointed to by the 'owners' * field in a PatSeq in the patternTable of a virtual event table. */ // C documentation // // /* AT = type of array */ // /* ------------------------------------------------------------------------- */ type TVirtOwners = struct { Fsize Tsize_t Fcapacity Tsize_t Fbuf [1]uintptr } func _VirtOwners_ElemSize(tls *libc.TLS) (r Tsize_t) { return uint64(40) } func _VirtOwners_BufferSize(tls *libc.TLS, numElems Tsize_t) (r Tsize_t) { return numElems * uint64(8) } func _VirtOwners_IsEmpty(tls *libc.TLS, arr uintptr) (r int32) { return libc.BoolInt32(!(arr != 0) || (*TVirtOwners)(unsafe.Pointer(arr)).Fsize == uint64(0)) } func _VirtOwners_First(tls *libc.TLS, arr uintptr) (r uintptr) { var v1 uintptr _ = v1 if arr != 0 { v1 = arr + 16 } else { v1 = libc.UintptrFromInt32(0) } return v1 } func _VirtOwners_Last(tls *libc.TLS, arr uintptr) (r uintptr) { var v1 uintptr _ = v1 if arr != 0 { v1 = arr + 16 + uintptr((*TVirtOwners)(unsafe.Pointer(arr)).Fsize)*8 } else { v1 = libc.UintptrFromInt32(0) } return v1 } func _VirtOwners_Front(tls *libc.TLS, arr uintptr) (r uintptr) { return *(*uintptr)(unsafe.Pointer(arr + 16)) } func _VirtOwners_Back(tls *libc.TLS, arr uintptr) (r uintptr) { return *(*uintptr)(unsafe.Pointer(arr + 16 + uintptr((*TVirtOwners)(unsafe.Pointer(arr)).Fsize-uint64(1))*8)) } func _VirtOwners_Size(tls *libc.TLS, arr uintptr) (r Tsize_t) { var v1 uint64 _ = v1 if arr != 0 { v1 = (*TVirtOwners)(unsafe.Pointer(arr)).Fsize } else { v1 = uint64(0) } return v1 } func _VirtOwners_Capacity(tls *libc.TLS, arr uintptr) (r Tsize_t) { var v1 uint64 _ = v1 if arr != 0 { v1 = (*TVirtOwners)(unsafe.Pointer(arr)).Fcapacity } else { v1 = uint64(0) } return v1 } func _VirtOwners_Resize(tls *libc.TLS, arrp uintptr, newCapacity Tsize_t) { var init1 int32 var memSize Tsize_t _, _ = init1, memSize if newCapacity == uint64(0) { libtcl9_0.XTcl_Free(tls, *(*uintptr)(unsafe.Pointer(arrp))) *(*uintptr)(unsafe.Pointer(arrp)) = libc.UintptrFromInt32(0) } else { init1 = libc.BoolInt32(*(*uintptr)(unsafe.Pointer(arrp)) == libc.UintptrFromInt32(0)) memSize = _VirtOwners_BufferSize(tls, newCapacity-uint64(1)) + uint64(24) *(*uintptr)(unsafe.Pointer(arrp)) = libtcl9_0.XTcl_Realloc(tls, *(*uintptr)(unsafe.Pointer(arrp)), memSize) if init1 != 0 { (*TVirtOwners)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(arrp)))).Fsize = uint64(0) } else { if newCapacity < (*TVirtOwners)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(arrp)))).Fsize { (*TVirtOwners)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(arrp)))).Fsize = newCapacity } } (*TVirtOwners)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(arrp)))).Fcapacity = newCapacity } } func _VirtOwners_Clear(tls *libc.TLS, arr uintptr, from Tsize_t, to Tsize_t) { libc.Xmemset(tls, arr+16+uintptr(from)*8, 0, _VirtOwners_BufferSize(tls, to-from)) } func _VirtOwners_ResizeAndClear(tls *libc.TLS, arrp uintptr, newCapacity Tsize_t) { var oldCapacity Tsize_t var v1 uint64 _, _ = oldCapacity, v1 if *(*uintptr)(unsafe.Pointer(arrp)) != 0 { v1 = (*TVirtOwners)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(arrp)))).Fcapacity } else { v1 = uint64(0) } oldCapacity = v1 _VirtOwners_Resize(tls, arrp, newCapacity) if newCapacity > oldCapacity { _VirtOwners_Clear(tls, *(*uintptr)(unsafe.Pointer(arrp)), oldCapacity, newCapacity) } } func _VirtOwners_SetSize(tls *libc.TLS, arr uintptr, newSize Tsize_t) { (*TVirtOwners)(unsafe.Pointer(arr)).Fsize = newSize } func _VirtOwners_Append(tls *libc.TLS, arrp uintptr, elem uintptr) { var v1 Tsize_t var v2 uintptr _, _ = v1, v2 if !(*(*uintptr)(unsafe.Pointer(arrp)) != 0) { _VirtOwners_Resize(tls, arrp, uint64(1)) } else { if (*TVirtOwners)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(arrp)))).Fsize == (*TVirtOwners)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(arrp)))).Fcapacity { _VirtOwners_Resize(tls, arrp, (*TVirtOwners)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(arrp)))).Fcapacity+((*TVirtOwners)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(arrp)))).Fcapacity+uint64(1))/uint64(2)) } } v2 = *(*uintptr)(unsafe.Pointer(arrp)) v1 = *(*Tsize_t)(unsafe.Pointer(v2)) *(*Tsize_t)(unsafe.Pointer(v2))++ *(*uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(arrp)) + 16 + uintptr(v1)*8)) = elem } func _VirtOwners_PopBack(tls *libc.TLS, arr uintptr) (r Tsize_t) { var p1 uintptr _ = p1 p1 = arr *(*Tsize_t)(unsafe.Pointer(p1)) -= uint64(1) return *(*Tsize_t)(unsafe.Pointer(p1)) } func _VirtOwners_Get(tls *libc.TLS, arr uintptr, at Tsize_t) (r uintptr) { return *(*uintptr)(unsafe.Pointer(arr + 16 + uintptr(at)*8)) } func _VirtOwners_Set(tls *libc.TLS, arr uintptr, at Tsize_t, elem uintptr) { *(*uintptr)(unsafe.Pointer(arr + 16 + uintptr(at)*8)) = elem } func _VirtOwners_Free(tls *libc.TLS, arrp uintptr) { _VirtOwners_Resize(tls, arrp, uint64(0)) } func _VirtOwners_Find(tls *libc.TLS, arr uintptr, elem uintptr) (r int32) { var buf uintptr var i Tsize_t _, _ = buf, i if arr != 0 { buf = arr + 16 i = uint64(0) for { if !(i < (*TVirtOwners)(unsafe.Pointer(arr)).Fsize) { break } if *(*uintptr)(unsafe.Pointer(buf + uintptr(i)*8)) == elem { return libc.Int32FromUint64(i) } goto _1 _1: ; i++ } } return -int32(1) } func _VirtOwners_Contains(tls *libc.TLS, arr uintptr, elem uintptr) (r int32) { return libc.BoolInt32(_VirtOwners_Find(tls, arr, elem) != -int32(1)) } /* define array of hash entries */ /* * The following structure defines a pattern sequence, which consists of one * or more patterns. In order to trigger, a pattern sequence must match the * most recent X events (first pattern to most recent event, next pattern to * next event, and so on). It is used as the hash value in a patternTable for * both binding tables and virtual event tables. * * In a binding table, it is the sequence of physical events that make up a * binding for an object. * * In a virtual event table, it is the sequence of physical events that define * a virtual event. * * The same structure is used for both types of pattern tables so that the * helper functions that traverse and match patterns will work for both * binding tables and virtual event tables. */ type TPatSeq = struct { FnumPats uint32 Fcount uint32 Fnumber uint32 F__ccgo12 uint8 Fscript uintptr Fobject uintptr FnextSeqPtr uintptr FhPtr uintptr Fptr struct { FnextObj [0]uintptr Fowners uintptr } Fpats [1]TTkPattern } /* * Compute memory size of struct PatSeq with given pattern size. * The caller must be sure that pattern size is greater than zero. */ /* * Constants that define how close together two events must be in milliseconds * or pixels to be considered close in space or time. */ /* * The following structure is used in the nameTable of a virtual event table * to associate a virtual event with all the physical events that can trigger * it. */ // C documentation // // /* AT = type of array */ // /* ------------------------------------------------------------------------- */ type TPhysOwned = struct { Fsize Tsize_t Fcapacity Tsize_t Fbuf [1]uintptr } func _PhysOwned_ElemSize(tls *libc.TLS) (r Tsize_t) { return uint64(88) } func _PhysOwned_BufferSize(tls *libc.TLS, numElems Tsize_t) (r Tsize_t) { return numElems * uint64(8) } func _PhysOwned_IsEmpty(tls *libc.TLS, arr uintptr) (r int32) { return libc.BoolInt32(!(arr != 0) || (*TPhysOwned)(unsafe.Pointer(arr)).Fsize == uint64(0)) } func _PhysOwned_First(tls *libc.TLS, arr uintptr) (r uintptr) { var v1 uintptr _ = v1 if arr != 0 { v1 = arr + 16 } else { v1 = libc.UintptrFromInt32(0) } return v1 } func _PhysOwned_Last(tls *libc.TLS, arr uintptr) (r uintptr) { var v1 uintptr _ = v1 if arr != 0 { v1 = arr + 16 + uintptr((*TPhysOwned)(unsafe.Pointer(arr)).Fsize)*8 } else { v1 = libc.UintptrFromInt32(0) } return v1 } func _PhysOwned_Front(tls *libc.TLS, arr uintptr) (r uintptr) { return *(*uintptr)(unsafe.Pointer(arr + 16)) } func _PhysOwned_Back(tls *libc.TLS, arr uintptr) (r uintptr) { return *(*uintptr)(unsafe.Pointer(arr + 16 + uintptr((*TPhysOwned)(unsafe.Pointer(arr)).Fsize-uint64(1))*8)) } func _PhysOwned_Size(tls *libc.TLS, arr uintptr) (r Tsize_t) { var v1 uint64 _ = v1 if arr != 0 { v1 = (*TPhysOwned)(unsafe.Pointer(arr)).Fsize } else { v1 = uint64(0) } return v1 } func _PhysOwned_Capacity(tls *libc.TLS, arr uintptr) (r Tsize_t) { var v1 uint64 _ = v1 if arr != 0 { v1 = (*TPhysOwned)(unsafe.Pointer(arr)).Fcapacity } else { v1 = uint64(0) } return v1 } func _PhysOwned_Resize(tls *libc.TLS, arrp uintptr, newCapacity Tsize_t) { var init1 int32 var memSize Tsize_t _, _ = init1, memSize if newCapacity == uint64(0) { libtcl9_0.XTcl_Free(tls, *(*uintptr)(unsafe.Pointer(arrp))) *(*uintptr)(unsafe.Pointer(arrp)) = libc.UintptrFromInt32(0) } else { init1 = libc.BoolInt32(*(*uintptr)(unsafe.Pointer(arrp)) == libc.UintptrFromInt32(0)) memSize = _PhysOwned_BufferSize(tls, newCapacity-uint64(1)) + uint64(24) *(*uintptr)(unsafe.Pointer(arrp)) = libtcl9_0.XTcl_Realloc(tls, *(*uintptr)(unsafe.Pointer(arrp)), memSize) if init1 != 0 { (*TPhysOwned)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(arrp)))).Fsize = uint64(0) } else { if newCapacity < (*TPhysOwned)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(arrp)))).Fsize { (*TPhysOwned)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(arrp)))).Fsize = newCapacity } } (*TPhysOwned)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(arrp)))).Fcapacity = newCapacity } } func _PhysOwned_Clear(tls *libc.TLS, arr uintptr, from Tsize_t, to Tsize_t) { libc.Xmemset(tls, arr+16+uintptr(from)*8, 0, _PhysOwned_BufferSize(tls, to-from)) } func _PhysOwned_ResizeAndClear(tls *libc.TLS, arrp uintptr, newCapacity Tsize_t) { var oldCapacity Tsize_t var v1 uint64 _, _ = oldCapacity, v1 if *(*uintptr)(unsafe.Pointer(arrp)) != 0 { v1 = (*TPhysOwned)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(arrp)))).Fcapacity } else { v1 = uint64(0) } oldCapacity = v1 _PhysOwned_Resize(tls, arrp, newCapacity) if newCapacity > oldCapacity { _PhysOwned_Clear(tls, *(*uintptr)(unsafe.Pointer(arrp)), oldCapacity, newCapacity) } } func _PhysOwned_SetSize(tls *libc.TLS, arr uintptr, newSize Tsize_t) { (*TPhysOwned)(unsafe.Pointer(arr)).Fsize = newSize } func _PhysOwned_Append(tls *libc.TLS, arrp uintptr, elem uintptr) { var v1 Tsize_t var v2 uintptr _, _ = v1, v2 if !(*(*uintptr)(unsafe.Pointer(arrp)) != 0) { _PhysOwned_Resize(tls, arrp, uint64(1)) } else { if (*TPhysOwned)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(arrp)))).Fsize == (*TPhysOwned)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(arrp)))).Fcapacity { _PhysOwned_Resize(tls, arrp, (*TPhysOwned)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(arrp)))).Fcapacity+((*TPhysOwned)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(arrp)))).Fcapacity+uint64(1))/uint64(2)) } } v2 = *(*uintptr)(unsafe.Pointer(arrp)) v1 = *(*Tsize_t)(unsafe.Pointer(v2)) *(*Tsize_t)(unsafe.Pointer(v2))++ *(*uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(arrp)) + 16 + uintptr(v1)*8)) = elem } func _PhysOwned_PopBack(tls *libc.TLS, arr uintptr) (r Tsize_t) { var p1 uintptr _ = p1 p1 = arr *(*Tsize_t)(unsafe.Pointer(p1)) -= uint64(1) return *(*Tsize_t)(unsafe.Pointer(p1)) } func _PhysOwned_Get(tls *libc.TLS, arr uintptr, at Tsize_t) (r uintptr) { return *(*uintptr)(unsafe.Pointer(arr + 16 + uintptr(at)*8)) } func _PhysOwned_Set(tls *libc.TLS, arr uintptr, at Tsize_t, elem uintptr) { *(*uintptr)(unsafe.Pointer(arr + 16 + uintptr(at)*8)) = elem } func _PhysOwned_Free(tls *libc.TLS, arrp uintptr) { _PhysOwned_Resize(tls, arrp, uint64(0)) } func _PhysOwned_Find(tls *libc.TLS, arr uintptr, elem uintptr) (r int32) { var buf uintptr var i Tsize_t _, _ = buf, i if arr != 0 { buf = arr + 16 i = uint64(0) for { if !(i < (*TPhysOwned)(unsafe.Pointer(arr)).Fsize) { break } if *(*uintptr)(unsafe.Pointer(buf + uintptr(i)*8)) == elem { return libc.Int32FromUint64(i) } goto _1 _1: ; i++ } } return -int32(1) } func _PhysOwned_Contains(tls *libc.TLS, arr uintptr, elem uintptr) (r int32) { return libc.BoolInt32(_PhysOwned_Find(tls, arr, elem) != -int32(1)) } /* define array of pattern seqs */ /* * One of the following structures exists for each interpreter. This structure * keeps track of the current display and screen in the interpreter, so that a * command can be invoked whenever the display/screen changes (the command does * things like point tk::Priv at a display-specific structure). */ type TScreenInfo = struct { FcurDispPtr uintptr FcurScreenIndex int32 FbindingDepth uint32 } /* * The following structure keeps track of all the information local to the * binding package on a per interpreter basis. */ type TBindInfo = struct { FvirtualEventTable TVirtualEventTable FscreenInfo TScreenInfo Fdeleted int32 FlastEventTime TTime FlastCurrentTime TTime } /* * In X11R4 and earlier versions, XStringToKeysym is ridiculously slow. The * data structure and hash table below, along with the code that uses them, * implement a fast mapping from strings to keysyms. In X11R5 and later * releases XStringToKeysym is plenty fast so this stuff isn't needed. The * #define REDO_KEYSYM_LOOKUP is normally undefined, so that XStringToKeysym * gets used. It can be set in the Makefile to enable the use of the hash * table below. */ /* * A hash table is kept to map from the string names of event modifiers to * information about those modifiers. The structure for storing this * information, and the hash table built at initialization time, are defined * below. */ type TModInfo = struct { Fname uintptr Fmask uint32 Fflags uint32 } /* * Flags for ModInfo structures: * * DOUBLE - Non-zero means duplicate this event, e.g. for double-clicks. * TRIPLE - Non-zero means triplicate this event, e.g. for triple-clicks. * QUADRUPLE - Non-zero means quadruple this event, e.g. for 4-fold-clicks. * MULT_CLICKS - Combination of all the above. */ var _modArray = [44]TModInfo{ 0: { Fname: __ccgo_ts + 1513, Fmask: libc.Uint32FromInt32(libc.Int32FromInt32(1) << libc.Int32FromInt32(2)), }, 1: { Fname: __ccgo_ts + 1521, Fmask: libc.Uint32FromInt32(libc.Int32FromInt32(1) << libc.Int32FromInt32(0)), }, 2: { Fname: __ccgo_ts + 1527, Fmask: libc.Uint32FromInt32(libc.Int32FromInt32(1) << libc.Int32FromInt32(1)), }, 3: { Fname: __ccgo_ts + 1532, Fmask: libc.Uint32FromInt32(libc.Int32FromInt32(1) << libc.Int32FromInt32(15) << libc.Int32FromInt32(1)), }, 4: { Fname: __ccgo_ts + 1537, Fmask: libc.Uint32FromInt32(libc.Int32FromInt32(1) << libc.Int32FromInt32(15) << libc.Int32FromInt32(1)), }, 5: { Fname: __ccgo_ts + 1539, Fmask: libc.Uint32FromInt32(libc.Int32FromInt32(1) << libc.Int32FromInt32(15) << libc.Int32FromInt32(2)), }, 6: { Fname: __ccgo_ts + 1543, Fmask: libc.Uint32FromInt32(libc.Int32FromInt32(1) << libc.Int32FromInt32(15) << libc.Int32FromInt32(3)), }, 7: { Fname: __ccgo_ts + 1552, Fmask: libc.Uint32FromInt32(libc.Int32FromInt32(1) << libc.Int32FromInt32(8)), }, 8: { Fname: __ccgo_ts + 1555, Fmask: libc.Uint32FromInt32(libc.Int32FromInt32(1) << libc.Int32FromInt32(8)), }, 9: { Fname: __ccgo_ts + 1563, Fmask: libc.Uint32FromInt32(libc.Int32FromInt32(1) << libc.Int32FromInt32(9)), }, 10: { Fname: __ccgo_ts + 1566, Fmask: libc.Uint32FromInt32(libc.Int32FromInt32(1) << libc.Int32FromInt32(9)), }, 11: { Fname: __ccgo_ts + 1574, Fmask: libc.Uint32FromInt32(libc.Int32FromInt32(1) << libc.Int32FromInt32(10)), }, 12: { Fname: __ccgo_ts + 1577, Fmask: libc.Uint32FromInt32(libc.Int32FromInt32(1) << libc.Int32FromInt32(10)), }, 13: { Fname: __ccgo_ts + 1585, Fmask: libc.Uint32FromInt32(libc.Int32FromInt32(1) << libc.Int32FromInt32(11)), }, 14: { Fname: __ccgo_ts + 1588, Fmask: libc.Uint32FromInt32(libc.Int32FromInt32(1) << libc.Int32FromInt32(11)), }, 15: { Fname: __ccgo_ts + 1596, Fmask: libc.Uint32FromInt32(libc.Int32FromInt32(1) << libc.Int32FromInt32(12)), }, 16: { Fname: __ccgo_ts + 1599, Fmask: libc.Uint32FromInt32(libc.Int32FromInt32(1) << libc.Int32FromInt32(12)), }, 17: { Fname: __ccgo_ts + 1607, Fmask: libc.Uint32FromInt32(libc.Int32FromInt32(1) << libc.Int32FromInt32(15) << libc.Int32FromInt32(6)), }, 18: { Fname: __ccgo_ts + 1610, Fmask: libc.Uint32FromInt32(libc.Int32FromInt32(1) << libc.Int32FromInt32(15) << libc.Int32FromInt32(6)), }, 19: { Fname: __ccgo_ts + 1618, Fmask: libc.Uint32FromInt32(libc.Int32FromInt32(1) << libc.Int32FromInt32(15) << libc.Int32FromInt32(7)), }, 20: { Fname: __ccgo_ts + 1621, Fmask: libc.Uint32FromInt32(libc.Int32FromInt32(1) << libc.Int32FromInt32(15) << libc.Int32FromInt32(7)), }, 21: { Fname: __ccgo_ts + 1629, Fmask: libc.Uint32FromInt32(libc.Int32FromInt32(1) << libc.Int32FromInt32(15) << libc.Int32FromInt32(8)), }, 22: { Fname: __ccgo_ts + 1632, Fmask: libc.Uint32FromInt32(libc.Int32FromInt32(1) << libc.Int32FromInt32(15) << libc.Int32FromInt32(8)), }, 23: { Fname: __ccgo_ts + 1640, Fmask: libc.Uint32FromInt32(libc.Int32FromInt32(1) << libc.Int32FromInt32(15) << libc.Int32FromInt32(9)), }, 24: { Fname: __ccgo_ts + 1643, Fmask: libc.Uint32FromInt32(libc.Int32FromInt32(1) << libc.Int32FromInt32(15) << libc.Int32FromInt32(9)), }, 25: { Fname: __ccgo_ts + 1651, Fmask: libc.Uint32FromInt32(libc.Int32FromInt32(1) << libc.Int32FromInt32(3)), }, 26: { Fname: __ccgo_ts + 1656, Fmask: libc.Uint32FromInt32(libc.Int32FromInt32(1) << libc.Int32FromInt32(3)), }, 27: { Fname: __ccgo_ts + 1659, Fmask: libc.Uint32FromInt32(libc.Int32FromInt32(1) << libc.Int32FromInt32(15) << libc.Int32FromInt32(1)), }, 28: { Fname: __ccgo_ts + 1667, Fmask: libc.Uint32FromInt32(libc.Int32FromInt32(1) << libc.Int32FromInt32(4)), }, 29: { Fname: __ccgo_ts + 1672, Fmask: libc.Uint32FromInt32(libc.Int32FromInt32(1) << libc.Int32FromInt32(4)), }, 30: { Fname: __ccgo_ts + 1675, Fmask: libc.Uint32FromInt32(libc.Int32FromInt32(1) << libc.Int32FromInt32(15) << libc.Int32FromInt32(2)), }, 31: { Fname: __ccgo_ts + 1682, Fmask: libc.Uint32FromInt32(libc.Int32FromInt32(1) << libc.Int32FromInt32(5)), }, 32: { Fname: __ccgo_ts + 1687, Fmask: libc.Uint32FromInt32(libc.Int32FromInt32(1) << libc.Int32FromInt32(5)), }, 33: { Fname: __ccgo_ts + 1690, Fmask: libc.Uint32FromInt32(libc.Int32FromInt32(1) << libc.Int32FromInt32(5)), }, 34: { Fname: __ccgo_ts + 1694, Fmask: libc.Uint32FromInt32(libc.Int32FromInt32(1) << libc.Int32FromInt32(6)), }, 35: { Fname: __ccgo_ts + 1699, Fmask: libc.Uint32FromInt32(libc.Int32FromInt32(1) << libc.Int32FromInt32(6)), }, 36: { Fname: __ccgo_ts + 1702, Fmask: libc.Uint32FromInt32(libc.Int32FromInt32(1) << libc.Int32FromInt32(6)), }, 37: { Fname: __ccgo_ts + 1705, Fmask: libc.Uint32FromInt32(libc.Int32FromInt32(1) << libc.Int32FromInt32(7)), }, 38: { Fname: __ccgo_ts + 1710, Fmask: libc.Uint32FromInt32(libc.Int32FromInt32(1) << libc.Int32FromInt32(7)), }, 39: { Fname: __ccgo_ts + 1713, Fflags: libc.Uint32FromInt32(libc.Int32FromInt32(1) << libc.Int32FromInt32(0)), }, 40: { Fname: __ccgo_ts + 1720, Fflags: libc.Uint32FromInt32(libc.Int32FromInt32(1) << libc.Int32FromInt32(1)), }, 41: { Fname: __ccgo_ts + 1727, Fflags: libc.Uint32FromInt32(libc.Int32FromInt32(1) << libc.Int32FromInt32(2)), }, 42: { Fname: __ccgo_ts + 1737, }, 43: {}, } var _modTable TTcl_HashTable /* * This module also keeps a hash table mapping from event names to information * about those events. The structure, an array to use to initialize the hash * table, and the hash table are all defined below. */ type TEventInfo = struct { Fname uintptr Ftype1 uint32 FeventMask uint32 } /* * Note: some of the masks below are an OR-ed combination of several masks. * This is necessary because X doesn't report up events unless you also ask * for down events. Also, X doesn't report button state in motion events * unless you've asked about button events. */ var _eventArray = [32]TEventInfo{ 0: { Fname: __ccgo_ts + 1741, Ftype1: uint32(KeyPress), FeventMask: libc.Uint32FromInt64(libc.Int64FromInt64(1) << libc.Int32FromInt32(0)), }, 1: { Fname: __ccgo_ts + 1745, Ftype1: uint32(KeyPress), FeventMask: libc.Uint32FromInt64(libc.Int64FromInt64(1) << libc.Int32FromInt32(0)), }, 2: { Fname: __ccgo_ts + 1754, Ftype1: uint32(KeyRelease), FeventMask: libc.Uint32FromInt64(libc.Int64FromInt64(1)<= int32('1') && libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(field))) <= int32('9') && libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(field + 1))) == int32('\000') { v1 = libc.Uint32FromInt32(libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(field))) - libc.Int32FromUint8('0')) } else { v1 = uint32(0) } button = v1 if button > uint32(3) { v2 = button + uint32(4) } else { v2 = button } return v2 } func _CurrentTimeInMilliSecs(tls *libc.TLS) (r TTime) { bp := tls.Alloc(16) defer tls.Free(16) var _ /* now at bp+0 */ TTcl_Time libtcl9_0.XTcl_GetTime(tls, bp) return libc.Uint64FromInt64((*(*TTcl_Time)(unsafe.Pointer(bp))).Fsec)*uint64(1000) + libc.Uint64FromInt64((*(*TTcl_Time)(unsafe.Pointer(bp))).Fusec)/uint64(1000) } func _GetInfo(tls *libc.TLS, psPtr uintptr, index uint32) (r TInfo) { return (*(*TTkPattern)(unsafe.Pointer(psPtr + 56 + uintptr(index)*32))).Finfo } func _GetCount(tls *libc.TLS, psPtr uintptr, index uint32) (r uint32) { return (*(*TTkPattern)(unsafe.Pointer(psPtr + 56 + uintptr(index)*32))).Fcount } func _CountSpecialized(tls *libc.TLS, fstMatchPtr uintptr, sndMatchPtr uintptr) (r int32) { var fstCount, sndCount int32 var i uint32 _, _, _ = fstCount, i, sndCount fstCount = 0 sndCount = 0 i = uint32(0) for { if !(i < (*TPatSeq)(unsafe.Pointer(fstMatchPtr)).FnumPats) { break } if _GetInfo(tls, fstMatchPtr, i) != 0 { fstCount = int32(uint32(fstCount) + _GetCount(tls, fstMatchPtr, i)) } goto _1 _1: ; i++ } i = uint32(0) for { if !(i < (*TPatSeq)(unsafe.Pointer(sndMatchPtr)).FnumPats) { break } if _GetInfo(tls, sndMatchPtr, i) != 0 { sndCount = int32(uint32(sndCount) + _GetCount(tls, sndMatchPtr, i)) } goto _2 _2: ; i++ } return sndCount - fstCount } func _IsKeyEventType(tls *libc.TLS, eventType int32) (r int32) { return libc.BoolInt32(eventType == int32(KeyPress) || eventType == int32(KeyRelease)) } func _IsButtonEventType(tls *libc.TLS, eventType uint32) (r int32) { return libc.BoolInt32(eventType == uint32(ButtonPress) || eventType == uint32(ButtonRelease)) } func _MatchEventNearby(tls *libc.TLS, lhs uintptr, rhs uintptr) (r int32) { /* Current button event */ /* assert: lhs->xbutton.time <= rhs->xbutton.time */ return libc.BoolInt32(_TestNearbyTime(tls, libc.Int32FromUint64((*(*TXButtonEvent)(unsafe.Pointer(rhs))).Ftime), libc.Int32FromUint64((*(*TXButtonEvent)(unsafe.Pointer(lhs))).Ftime)) != 0 && _TestNearbyCoords(tls, (*(*TXButtonEvent)(unsafe.Pointer(rhs))).Fx_root, (*(*TXButtonEvent)(unsafe.Pointer(lhs))).Fx_root) != 0 && _TestNearbyCoords(tls, (*(*TXButtonEvent)(unsafe.Pointer(rhs))).Fy_root, (*(*TXButtonEvent)(unsafe.Pointer(lhs))).Fy_root) != 0) } func _MatchEventRepeat(tls *libc.TLS, lhs uintptr, rhs uintptr) (r int32) { /* Current key event */ /* assert: lhs->time <= rhs->time */ return libc.BoolInt32((*TXKeyEvent)(unsafe.Pointer(lhs)).Fkeycode == (*TXKeyEvent)(unsafe.Pointer(rhs)).Fkeycode && _TestNearbyTime(tls, libc.Int32FromUint64((*TXKeyEvent)(unsafe.Pointer(lhs)).Ftime), libc.Int32FromUint64((*TXKeyEvent)(unsafe.Pointer(rhs)).Ftime)) != 0) } func _FreePatSeq(tls *libc.TLS, psPtr uintptr) { libtcl9_0.XTcl_Free(tls, (*TPatSeq)(unsafe.Pointer(psPtr)).Fscript) if !((*TPatSeq)(unsafe.Pointer(psPtr)).Fobject != 0) { _VirtOwners_Free(tls, psPtr+48) } libtcl9_0.XTcl_Free(tls, psPtr) } func _RemoveListEntry(tls *libc.TLS, pool uintptr, psEntry uintptr) { if _PSModMaskArr_Capacity(tls, (*TPSEntry)(unsafe.Pointer(psEntry)).FlastModMaskArr) > uint64(MAX_MOD_MASK_ARR_SIZE) { _PSModMaskArr_Free(tls, psEntry+32) } _PSList_Remove(tls, psEntry) _PSList_Append(tls, pool, psEntry) } func _ClearList(tls *libc.TLS, psList uintptr, pool uintptr, object uintptr) { var psEntry, psNext uintptr _, _ = psEntry, psNext if object != 0 { psEntry = _PSList_First(tls, psList) for { if !(psEntry != 0) { break } psNext = _PSList_Next(tls, psEntry) if (*TPatSeq1)(unsafe.Pointer((*TPSEntry)(unsafe.Pointer(psEntry)).FpsPtr)).Fobject == object { _RemoveListEntry(tls, pool, psEntry) } goto _1 _1: ; psEntry = psNext } } else { _PSList_Move(tls, pool, psList) } } func _FreePatSeqEntry(tls *libc.TLS, dummy940 uintptr, entry uintptr) (r uintptr) { var next uintptr _ = next next = _PSList_Next(tls, entry) _PSModMaskArr_Free(tls, entry+32) libtcl9_0.XTcl_Free(tls, entry) return next } func _ResolveModifiers(tls *libc.TLS, dispPtr uintptr, modMask uint32) (r uint32) { if (*TTkDisplay)(unsafe.Pointer(dispPtr)).FmetaModMask != 0 { if modMask&libc.Uint32FromInt32(libc.Int32FromInt32(1)< uint32(0) && _eventArrayIndex[type1] == -int32(1) { _eventArrayIndex[type1] = libc.Int32FromUint32(i) } goto _2 _2: ; i++ } libtcl9_0.XTcl_InitHashTable(tls, uintptr(unsafe.Pointer(&_modTable)), TCL_STRING_KEYS) modPtr = uintptr(unsafe.Pointer(&_modArray)) for { if !((*TModInfo)(unsafe.Pointer(modPtr)).Fname != 0) { break } hPtr = (*(*func(*libc.TLS, uintptr, uintptr, uintptr) uintptr)(unsafe.Pointer(&struct{ uintptr }{(*TTcl_HashTable)(unsafe.Pointer(uintptr(unsafe.Pointer(&_modTable)))).FcreateProc})))(tls, uintptr(unsafe.Pointer(&_modTable)), (*TModInfo)(unsafe.Pointer(modPtr)).Fname, bp) (*TTcl_HashEntry)(unsafe.Pointer(hPtr)).FclientData = modPtr goto _3 _3: ; modPtr += 16 } libtcl9_0.XTcl_InitHashTable(tls, uintptr(unsafe.Pointer(&_eventTable)), TCL_STRING_KEYS) eiPtr = uintptr(unsafe.Pointer(&_eventArray)) for { if !((*TEventInfo)(unsafe.Pointer(eiPtr)).Fname != 0) { break } hPtr = (*(*func(*libc.TLS, uintptr, uintptr, uintptr) uintptr)(unsafe.Pointer(&struct{ uintptr }{(*TTcl_HashTable)(unsafe.Pointer(uintptr(unsafe.Pointer(&_eventTable)))).FcreateProc})))(tls, uintptr(unsafe.Pointer(&_eventTable)), (*TEventInfo)(unsafe.Pointer(eiPtr)).Fname, bp) (*TTcl_HashEntry)(unsafe.Pointer(hPtr)).FclientData = eiPtr goto _4 _4: ; eiPtr += 16 } _initialized = int32(1) } libtcl9_0.XTcl_MutexUnlock(tls, uintptr(unsafe.Pointer(&_bindMutex))) } (*TTkMainInfo)(unsafe.Pointer(mainPtr)).FbindingTable = XTk_CreateBindingTable(tls, (*TTkMainInfo)(unsafe.Pointer(mainPtr)).Finterp) bindInfoPtr = libtcl9_0.XTcl_Alloc(tls, uint64(376)) _InitVirtualEventTable(tls, bindInfoPtr) (*TBindInfo)(unsafe.Pointer(bindInfoPtr)).FscreenInfo.FcurDispPtr = libc.UintptrFromInt32(0) (*TBindInfo)(unsafe.Pointer(bindInfoPtr)).FscreenInfo.FcurScreenIndex = -int32(1) (*TBindInfo)(unsafe.Pointer(bindInfoPtr)).FscreenInfo.FbindingDepth = uint32(0) (*TBindInfo)(unsafe.Pointer(bindInfoPtr)).Fdeleted = 0 (*TBindInfo)(unsafe.Pointer(bindInfoPtr)).FlastCurrentTime = _CurrentTimeInMilliSecs(tls) (*TBindInfo)(unsafe.Pointer(bindInfoPtr)).FlastEventTime = uint64(0) (*TTkMainInfo)(unsafe.Pointer(mainPtr)).FbindInfo = bindInfoPtr XTkpInitializeMenuBindings(tls, (*TTkMainInfo)(unsafe.Pointer(mainPtr)).Finterp, (*TTkMainInfo)(unsafe.Pointer(mainPtr)).FbindingTable) } /* *--------------------------------------------------------------------------- * * TkBindFree -- * * This function is called when an application is deleted. It deletes all * the structures used by bindings and virtual events. * * Results: * None. * * Side effects: * Memory freed. * *--------------------------------------------------------------------------- */ func XTkBindFree(tls *libc.TLS, mainPtr uintptr) { /* The newly created application. */ var bindInfoPtr uintptr _ = bindInfoPtr XTk_DeleteBindingTable(tls, (*TTkMainInfo)(unsafe.Pointer(mainPtr)).FbindingTable) (*TTkMainInfo)(unsafe.Pointer(mainPtr)).FbindingTable = libc.UintptrFromInt32(0) bindInfoPtr = (*TTkMainInfo)(unsafe.Pointer(mainPtr)).FbindInfo _DeleteVirtualEventTable(tls, bindInfoPtr) (*TBindInfo)(unsafe.Pointer(bindInfoPtr)).Fdeleted = int32(1) libtcl9_0.XTcl_EventuallyFree(tls, bindInfoPtr, libc.UintptrFromInt32(3)) (*TTkMainInfo)(unsafe.Pointer(mainPtr)).FbindInfo = libc.UintptrFromInt32(0) } /* *-------------------------------------------------------------- * * Tk_CreateBindingTable -- * * Set up a new domain in which event bindings may be created. * * Results: * The return value is a token for the new table, which must be passed to * functions like Tk_CreateBinding. * * Side effects: * Memory is allocated for the new table. * *-------------------------------------------------------------- */ func XTk_CreateBindingTable(tls *libc.TLS, interp uintptr) (r TTk_BindingTable) { /* Interpreter to associate with the binding table: commands are * executed in this interpreter. */ var bindPtr uintptr var i uint32 _, _ = bindPtr, i bindPtr = libtcl9_0.XTcl_Alloc(tls, uint64(8688)) /* * Create and initialize a new binding table. */ libc.Xmemset(tls, bindPtr, 0, uint64(8688)) i = uint32(0) for { if !(uint64(i) < libc.Uint64FromInt64(8320)/libc.Uint64FromInt64(208)) { break } *(*int32)(unsafe.Pointer(bindPtr + uintptr(i)*208)) = -int32(1) goto _1 _1: ; i++ } (*TBindingTable)(unsafe.Pointer(bindPtr)).FcurEvent = bindPtr /* do not assign NULL */ (*TBindingTable)(unsafe.Pointer(bindPtr)).FlookupTables.Fnumber = uint32(0) _PromArr_ResizeAndClear(tls, bindPtr+8320, uint64(2)) libtcl9_0.XTcl_InitHashTable(tls, bindPtr+8344+104, libc.Int32FromUint64(libc.Uint64FromInt64(24)/libc.Uint64FromInt64(4))) libtcl9_0.XTcl_InitHashTable(tls, bindPtr+8344, libc.Int32FromUint64(libc.Uint64FromInt64(24)/libc.Uint64FromInt64(4))) libtcl9_0.XTcl_InitHashTable(tls, bindPtr+8576, int32(TCL_ONE_WORD_KEYS)) (*TBindingTable)(unsafe.Pointer(bindPtr)).Finterp = interp return bindPtr } /* *-------------------------------------------------------------- * * Tk_DeleteBindingTable -- * * Destroy a binding table and free up all its memory. The caller should * not use bindingTable again after this function returns. * * Results: * None. * * Side effects: * Memory is freed. * *-------------------------------------------------------------- */ func XTk_DeleteBindingTable(tls *libc.TLS, bindPtr TTk_BindingTable) { bp := tls.Alloc(32) defer tls.Free(32) /* Token for the binding table to destroy. */ var hPtr, nextPtr, psPtr uintptr var _ /* search at bp+0 */ TTcl_HashSearch _, _, _ = hPtr, nextPtr, psPtr /* * Find and delete all of the patterns associated with the binding table. */ hPtr = libtcl9_0.XTcl_FirstHashEntry(tls, bindPtr+8344, bp) for { if !(hPtr != 0) { break } psPtr = (*TTcl_HashEntry)(unsafe.Pointer(hPtr)).FclientData for { if !(psPtr != 0) { break } nextPtr = (*TPatSeq)(unsafe.Pointer(psPtr)).FnextSeqPtr _FreePatSeq(tls, psPtr) goto _2 _2: ; psPtr = nextPtr } goto _1 _1: ; hPtr = libtcl9_0.XTcl_NextHashEntry(tls, bp) } /* * Don't forget to release lookup elements. */ _ClearLookupTable(tls, bindPtr+8344, libc.UintptrFromInt32(0)) _ClearPromotionLists(tls, bindPtr, libc.UintptrFromInt32(0)) _PromArr_Free(tls, bindPtr+8320) _PSList_Traverse(tls, bindPtr+8344+208, __ccgo_fp(_FreePatSeqEntry)) /* * Clean up the rest of the information associated with the binding table. */ libtcl9_0.XTcl_DeleteHashTable(tls, bindPtr+8344) libtcl9_0.XTcl_DeleteHashTable(tls, bindPtr+8344+104) libtcl9_0.XTcl_DeleteHashTable(tls, bindPtr+8576) libtcl9_0.XTcl_Free(tls, bindPtr) } /* *-------------------------------------------------------------- * * InsertPatSeq -- * * Insert given pattern sequence into lookup table for fast * access. * * Results: * None. * * Side effects: * Memory allocated. * *-------------------------------------------------------------- */ func _InsertPatSeq(tls *libc.TLS, lookupTables uintptr, psPtr uintptr) { bp := tls.Alloc(32) defer tls.Free(32) var hPtr, psEntry, psList uintptr var _ /* isNew at bp+24 */ int32 var _ /* key at bp+0 */ TPatternTableKey _, _, _ = hPtr, psEntry, psList if !(int32(uint32(*(*uint8)(unsafe.Pointer(psPtr + 12))&0x1>>0)) != 0) { _SetupPatternKey(tls, bp, psPtr) hPtr = (*(*func(*libc.TLS, uintptr, uintptr, uintptr) uintptr)(unsafe.Pointer(&struct{ uintptr }{(*TTcl_HashTable)(unsafe.Pointer(lookupTables + 104)).FcreateProc})))(tls, lookupTables+104, bp, bp+24) if *(*int32)(unsafe.Pointer(bp + 24)) != 0 { psList = libtcl9_0.XTcl_Alloc(tls, uint64(16)) _PSList_Init(tls, psList) (*TTcl_HashEntry)(unsafe.Pointer(hPtr)).FclientData = psList } else { psList = (*TTcl_HashEntry)(unsafe.Pointer(hPtr)).FclientData } psEntry = _MakeListEntry(tls, lookupTables+208, psPtr, 0) _PSList_Append(tls, psList, psEntry) libc.SetBitFieldPtr8Uint32(psPtr+12, libc.Uint32FromInt32(1), 0, 0x1) } } /* *-------------------------------------------------------------- * * Tk_CreateBinding -- * * Add a binding to a binding table, so that future calls to Tk_BindEvent * may execute the command in the binding. * * Results: * The return value is 0 if an error occurred while setting up the * binding. In this case, an error message will be left in the interp's * result. If all went well then the return value is a mask of the event * types that must be made available to Tk_BindEvent in order to properly * detect when this binding triggers. This value can be used to determine * what events to select for in a window, for example. * * Side effects: * An existing binding on the same event sequence may be replaced. The * new binding may cause future calls to Tk_BindEvent to behave * differently than they did previously. * *-------------------------------------------------------------- */ func XTk_CreateBinding(tls *libc.TLS, interp uintptr, bindPtr TTk_BindingTable, object uintptr, eventString uintptr, script uintptr, append1 int32) (r uint64) { bp := tls.Alloc(16) defer tls.Free(16) /* 0 means replace any existing binding for eventString; * 1 means append to that binding. If the existing binding is * for a callback function and not a Tcl command string, the * existing binding will always be replaced. */ var hPtr, newStr, oldStr, psPtr, v1 uintptr var length, length1, length2 Tsize_t var _ /* eventMask at bp+0 */ uint32 var _ /* isNew at bp+4 */ int32 _, _, _, _, _, _, _, _ = hPtr, length, length1, length2, newStr, oldStr, psPtr, v1 psPtr = _FindSequence(tls, interp, bindPtr+8344, object, eventString, libc.BoolInt32(!!(*(*uint8)(unsafe.Pointer(script)) != 0)), int32(1), bp) if !(*(*uint8)(unsafe.Pointer(script)) != 0) { /* Silently ignore empty scripts -- see SF#3006842 */ return uint64(*(*uint32)(unsafe.Pointer(bp))) } if !(psPtr != 0) { return uint64(0) } if uint64((*TPatSeq)(unsafe.Pointer(psPtr)).FnumPats) > _PromArr_Capacity(tls, (*TTk_BindingTable_)(unsafe.Pointer(bindPtr)).FpromArr) { /* * We have to increase the size of array containing the lists of promoted sequences. * Normally the maximal size is 1, only in very seldom cases a bigger size is needed. * Note that for technical reasons the capacity should be one higher than the expected * maximal size. */ _PromArr_ResizeAndClear(tls, bindPtr+8320, uint64((*TPatSeq)(unsafe.Pointer(psPtr)).FnumPats)) } if !((*TPatSeq)(unsafe.Pointer(psPtr)).Fscript != 0) { /* * This pattern sequence was just created. Link the pattern into the * list associated with the object, so that if the object goes away, * these bindings will all automatically be deleted. */ hPtr = (*(*func(*libc.TLS, uintptr, uintptr, uintptr) uintptr)(unsafe.Pointer(&struct{ uintptr }{(*TTcl_HashTable)(unsafe.Pointer(bindPtr + 8576)).FcreateProc})))(tls, bindPtr+8576, object, bp+4) if *(*int32)(unsafe.Pointer(bp + 4)) != 0 { v1 = libc.UintptrFromInt32(0) } else { v1 = (*TTcl_HashEntry)(unsafe.Pointer(hPtr)).FclientData } *(*uintptr)(unsafe.Pointer(psPtr + 48)) = v1 (*TTcl_HashEntry)(unsafe.Pointer(hPtr)).FclientData = psPtr _InsertPatSeq(tls, bindPtr+8344, psPtr) } oldStr = (*TPatSeq)(unsafe.Pointer(psPtr)).Fscript if append1 != 0 && oldStr != 0 { length1 = libc.Xstrlen(tls, oldStr) length2 = libc.Xstrlen(tls, script) newStr = libtcl9_0.XTcl_Alloc(tls, length1+length2+uint64(2)) libc.Xmemcpy(tls, newStr, oldStr, length1) *(*uint8)(unsafe.Pointer(newStr + uintptr(length1))) = uint8('\n') libc.Xmemcpy(tls, newStr+uintptr(length1)+uintptr(1), script, length2+uint64(1)) } else { length = libc.Xstrlen(tls, script) newStr = libtcl9_0.XTcl_Alloc(tls, length+uint64(1)) libc.Xmemcpy(tls, newStr, script, length+uint64(1)) } libtcl9_0.XTcl_Free(tls, oldStr) (*TPatSeq)(unsafe.Pointer(psPtr)).Fscript = newStr return uint64(*(*uint32)(unsafe.Pointer(bp))) } /* *-------------------------------------------------------------- * * Tk_DeleteBinding -- * * Remove an event binding from a binding table. * * Results: * The result is a standard Tcl return value. If an error occurs then the * interp's result will contain an error message. * * Side effects: * The binding given by object and eventString is removed from * bindingTable. * *-------------------------------------------------------------- */ func XTk_DeleteBinding(tls *libc.TLS, interp uintptr, bindPtr TTk_BindingTable, object uintptr, eventString uintptr) (r int32) { /* String describing event sequence that triggers binding. */ var hPtr, prevPtr, psPtr, v1 uintptr _, _, _, _ = hPtr, prevPtr, psPtr, v1 psPtr = _FindSequence(tls, interp, bindPtr+8344, object, eventString, 0, int32(1), libc.UintptrFromInt32(0)) if !(psPtr != 0) { libtcl9_0.XTcl_ResetResult(tls, interp) } else { /* * Unlink the binding from the list for its object. */ v1 = (*(*func(*libc.TLS, uintptr, uintptr) uintptr)(unsafe.Pointer(&struct{ uintptr }{(*TTcl_HashTable)(unsafe.Pointer(bindPtr + 8576)).FfindProc})))(tls, bindPtr+8576, object) hPtr = v1 if !(v1 != 0) { libtcl9_0.XTcl_Panic(tls, __ccgo_ts+2399, 0) } prevPtr = (*TTcl_HashEntry)(unsafe.Pointer(hPtr)).FclientData if prevPtr == psPtr { (*TTcl_HashEntry)(unsafe.Pointer(hPtr)).FclientData = *(*uintptr)(unsafe.Pointer(psPtr + 48)) } else { for { if !(prevPtr != 0) { libtcl9_0.XTcl_Panic(tls, __ccgo_ts+2449, 0) } if *(*uintptr)(unsafe.Pointer(prevPtr + 48)) == psPtr { *(*uintptr)(unsafe.Pointer(prevPtr + 48)) = *(*uintptr)(unsafe.Pointer(psPtr + 48)) break } goto _2 _2: ; prevPtr = *(*uintptr)(unsafe.Pointer(prevPtr + 48)) } } _RemovePatSeqFromLookup(tls, bindPtr+8344, psPtr) _RemovePatSeqFromPromotionLists(tls, bindPtr, psPtr) _DeletePatSeq(tls, psPtr) } return TCL_OK } /* *-------------------------------------------------------------- * * Tk_GetBinding -- * * Return the script associated with a given event string. * * Results: * The return value is a pointer to the script associated with * eventString for object in the domain given by bindingTable. If there * is no binding for eventString, or if eventString is improperly formed, * then NULL is returned and an error message is left in the interp's * result. The return value is semi-static: it will persist until the * binding is changed or deleted. * * Side effects: * None. * *-------------------------------------------------------------- */ func XTk_GetBinding(tls *libc.TLS, interp uintptr, bindPtr TTk_BindingTable, object uintptr, eventString uintptr) (r uintptr) { /* String describing event sequence that triggers binding. */ var psPtr, v1 uintptr _, _ = psPtr, v1 psPtr = _FindSequence(tls, interp, bindPtr+8344, object, eventString, 0, int32(1), libc.UintptrFromInt32(0)) if psPtr != 0 { v1 = (*TPatSeq)(unsafe.Pointer(psPtr)).Fscript } else { v1 = libc.UintptrFromInt32(0) } return v1 } /* *-------------------------------------------------------------- * * Tk_GetAllBindings -- * * Return a list of event strings for all the bindings associated with a * given object. * * Results: * There is no return value. The interp's result is modified to hold a * Tcl list with one entry for each binding associated with object in * bindingTable. Each entry in the list contains the event string * associated with one binding. * * Side effects: * None. * *-------------------------------------------------------------- */ func XTk_GetAllBindings(tls *libc.TLS, interp uintptr, bindPtr TTk_BindingTable, object uintptr) { /* Token for object. */ var hPtr, psPtr, resultObj, v1 uintptr _, _, _, _ = hPtr, psPtr, resultObj, v1 v1 = (*(*func(*libc.TLS, uintptr, uintptr) uintptr)(unsafe.Pointer(&struct{ uintptr }{(*TTcl_HashTable)(unsafe.Pointer(bindPtr + 8576)).FfindProc})))(tls, bindPtr+8576, object) hPtr = v1 if v1 != 0 { resultObj = libtcl9_0.XTcl_NewObj(tls) /* * For each binding, output information about each of the patterns in its sequence. */ psPtr = (*TTcl_HashEntry)(unsafe.Pointer(hPtr)).FclientData for { if !(psPtr != 0) { break } libtcl9_0.XTcl_ListObjAppendElement(tls, libc.UintptrFromInt32(0), resultObj, _GetPatternObj(tls, psPtr)) goto _2 _2: ; psPtr = *(*uintptr)(unsafe.Pointer(psPtr + 48)) } libtcl9_0.XTcl_SetObjResult(tls, interp, resultObj) } } /* *-------------------------------------------------------------- * * RemovePatSeqFromLookup -- * * Remove given pattern sequence from lookup tables. This * can be required before deleting the pattern sequence. * * Results: * None. * * Side effects: * None. * *-------------------------------------------------------------- */ func _RemovePatSeqFromLookup(tls *libc.TLS, lookupTables uintptr, psPtr uintptr) { bp := tls.Alloc(32) defer tls.Free(32) /* Remove this pattern sequence. */ var hPtr, psEntry, psList, v1, v3 uintptr var _ /* key at bp+0 */ TPatternTableKey _, _, _, _, _ = hPtr, psEntry, psList, v1, v3 _SetupPatternKey(tls, bp, psPtr) v1 = (*(*func(*libc.TLS, uintptr, uintptr) uintptr)(unsafe.Pointer(&struct{ uintptr }{(*TTcl_HashTable)(unsafe.Pointer(lookupTables + 104)).FfindProc})))(tls, lookupTables+104, bp) hPtr = v1 if v1 != 0 { psList = (*TTcl_HashEntry)(unsafe.Pointer(hPtr)).FclientData if (*TPSList)(unsafe.Pointer(psList)).Ffirst != 0 { v3 = (*TPSList)(unsafe.Pointer(psList)).Ffirst } else { v3 = psList } psEntry = v3 for { if !(psEntry != psList) { break } if (*TPSEntry)(unsafe.Pointer(psEntry)).FpsPtr == psPtr { libc.SetBitFieldPtr8Uint32(psPtr+12, libc.Uint32FromInt32(0), 0, 0x1) _RemoveListEntry(tls, lookupTables+208, psEntry) return } goto _2 _2: ; psEntry = (*TPSEntry)(unsafe.Pointer(psEntry)).F_dl_.Fnext } } } /* *-------------------------------------------------------------- * * RemovePatSeqFromPromotionLists -- * * Remove given pattern sequence from promotion lists. This * can be required before deleting the pattern sequence. * * Results: * None. * * Side effects: * None. * *-------------------------------------------------------------- */ func _RemovePatSeqFromPromotionLists(tls *libc.TLS, bindPtr TTk_BindingTable, psPtr uintptr) { /* Remove this pattern sequence. */ var i Tsize_t var psEntry, psList, v3 uintptr _, _, _, _ = i, psEntry, psList, v3 i = uint64(0) for { if !(i < _PromArr_Size(tls, (*TTk_BindingTable_)(unsafe.Pointer(bindPtr)).FpromArr)) { break } psList = _PromArr_Get(tls, (*TTk_BindingTable_)(unsafe.Pointer(bindPtr)).FpromArr, i) if (*TPSList)(unsafe.Pointer(psList)).Ffirst != 0 { v3 = (*TPSList)(unsafe.Pointer(psList)).Ffirst } else { v3 = psList } psEntry = v3 for { if !(psEntry != psList) { break } if (*TPSEntry)(unsafe.Pointer(psEntry)).FpsPtr == psPtr { _RemoveListEntry(tls, bindPtr+8344+208, psEntry) break } goto _2 _2: ; psEntry = (*TPSEntry)(unsafe.Pointer(psEntry)).F_dl_.Fnext } goto _1 _1: ; i++ } } /* *-------------------------------------------------------------- * * DeletePatSeq -- * * Delete given pattern sequence. Possibly it is required * to invoke RemovePatSeqFromLookup(), and RemovePatSeqFromPromotionLists() * before. * * Results: * Pointer to succeeding pattern sequence. * * Side effects: * Deallocation of memory. * *-------------------------------------------------------------- */ func _DeletePatSeq(tls *libc.TLS, psPtr uintptr) (r uintptr) { /* Delete this pattern sequence. */ var nextPtr, prevPtr uintptr _, _ = nextPtr, prevPtr prevPtr = (*TTcl_HashEntry)(unsafe.Pointer((*TPatSeq)(unsafe.Pointer(psPtr)).FhPtr)).FclientData nextPtr = *(*uintptr)(unsafe.Pointer(psPtr + 48)) /* * Be sure to remove each binding from its hash chain in the pattern * table. If this is the last pattern in the chain, then delete the * hash entry too. */ if prevPtr == psPtr { if !((*TPatSeq)(unsafe.Pointer(psPtr)).FnextSeqPtr != 0) { libtcl9_0.XTcl_DeleteHashEntry(tls, (*TPatSeq)(unsafe.Pointer(psPtr)).FhPtr) } else { (*TTcl_HashEntry)(unsafe.Pointer((*TPatSeq)(unsafe.Pointer(psPtr)).FhPtr)).FclientData = (*TPatSeq)(unsafe.Pointer(psPtr)).FnextSeqPtr } } else { for { if !(prevPtr != 0) { libtcl9_0.XTcl_Panic(tls, __ccgo_ts+2495, 0) } if (*TPatSeq)(unsafe.Pointer(prevPtr)).FnextSeqPtr == psPtr { (*TPatSeq)(unsafe.Pointer(prevPtr)).FnextSeqPtr = (*TPatSeq)(unsafe.Pointer(psPtr)).FnextSeqPtr break } goto _1 _1: ; prevPtr = (*TPatSeq)(unsafe.Pointer(prevPtr)).FnextSeqPtr } } _FreePatSeq(tls, psPtr) return nextPtr } /* *-------------------------------------------------------------- * * Tk_DeleteAllBindings -- * * Remove all bindings associated with a given object in a given binding * table. * * Results: * All bindings associated with object are removed from bindingTable. * * Side effects: * None. * *-------------------------------------------------------------- */ func XTk_DeleteAllBindings(tls *libc.TLS, bindPtr TTk_BindingTable, object uintptr) { /* Token for object. */ var hPtr, nextPtr, psPtr, v1 uintptr _, _, _, _ = hPtr, nextPtr, psPtr, v1 v1 = (*(*func(*libc.TLS, uintptr, uintptr) uintptr)(unsafe.Pointer(&struct{ uintptr }{(*TTcl_HashTable)(unsafe.Pointer(bindPtr + 8576)).FfindProc})))(tls, bindPtr+8576, object) hPtr = v1 if !(v1 != 0) { return } /* * Don't forget to clear lookup tables. */ _ClearLookupTable(tls, bindPtr+8344, object) _ClearPromotionLists(tls, bindPtr, object) psPtr = (*TTcl_HashEntry)(unsafe.Pointer(hPtr)).FclientData for { if !(psPtr != 0) { break } nextPtr = _DeletePatSeq(tls, psPtr) goto _2 _2: ; psPtr = nextPtr } libtcl9_0.XTcl_DeleteHashEntry(tls, hPtr) } /* *--------------------------------------------------------------------------- * * Tk_BindEvent -- * * This function is invoked to process an X event. The event is added to * those recorded for the binding table. Then each of the objects at * *objectPtr is checked in order to see if it has a binding that matches * the recent events. If so, the most specific binding is invoked for * each object. * * Results: * None. * * Side effects: * Depends on the script associated with the matching binding. * * All Tcl binding scripts for each object are accumulated before the * first binding is evaluated. If the action of a Tcl binding is to * change or delete a binding, or delete the window associated with the * binding, all the original Tcl binding scripts will still fire. * *--------------------------------------------------------------------------- */ // C documentation // // /* helper function */ func _ResetCounters(tls *libc.TLS, eventInfo uintptr, eventType uint32, window TWindow) { var curEvent uintptr _ = curEvent curEvent = eventInfo + uintptr(eventType)*208 if (*(*TXAnyEvent)(unsafe.Pointer(&(*TEvent)(unsafe.Pointer(curEvent)).Fxev))).Fwindow == window { (*(*TXAnyEvent)(unsafe.Pointer(&(*TEvent)(unsafe.Pointer(curEvent)).Fxev))).Fwindow = uint64(0) (*(*TEvent)(unsafe.Pointer(eventInfo + uintptr(eventType)*208))).FcountAny = uint32(0) (*(*TEvent)(unsafe.Pointer(eventInfo + uintptr(eventType)*208))).FcountDetailed = uint32(0) } } // C documentation // // /* helper function */ func _IsBetterMatch(tls *libc.TLS, fstMatchPtr uintptr, sndMatchPtr uintptr) (r int32) { /* this is a better match? */ var diff int32 var fstCount, sndCount uint64 var i uint32 _, _, _, _ = diff, fstCount, i, sndCount if !(sndMatchPtr != 0) { return 0 } if !(fstMatchPtr != 0) { return int32(1) } diff = _CountSpecialized(tls, fstMatchPtr, sndMatchPtr) if diff > 0 { return int32(1) } if diff < 0 { return 0 } fstCount = uint64(0) sndCount = uint64(0) /* * Count the most high-ordered patterns. * * (This computation assumes that a sequence does not contain more than * 1,000,000 single patterns. It can be precluded that in practice this * assumption will not be violated.) */ i = uint32(0) for { if !(i < (*TPatSeq)(unsafe.Pointer(fstMatchPtr)).FnumPats) { break } fstCount += _weight[_GetCount(tls, fstMatchPtr, i)] goto _1 _1: ; i++ } i = uint32(0) for { if !(i < (*TPatSeq)(unsafe.Pointer(sndMatchPtr)).FnumPats) { break } sndCount += _weight[_GetCount(tls, sndMatchPtr, i)] goto _2 _2: ; i++ } if sndCount > fstCount { return int32(1) } if sndCount < fstCount { return 0 } return libc.BoolInt32((*TPatSeq)(unsafe.Pointer(sndMatchPtr)).Fnumber > (*TPatSeq)(unsafe.Pointer(fstMatchPtr)).Fnumber) } /* local scope */ var _weight = [5]uint64{ 1: uint64(1), 2: uint64(1000000), 3: libc.Uint64FromUint64(1000000) * libc.Uint64FromUint64(1000000), 4: libc.Uint64FromUint64(1000000) * libc.Uint64FromUint64(1000000) * libc.Uint64FromUint64(1000000), } func XTk_BindEvent(tls *libc.TLS, bindPtr TTk_BindingTable, eventPtr uintptr, tkwin TTk_Window, numObjects TTcl_Size, objArr uintptr) { bp := tls.Alloc(496) defer tls.Free(496) /* Array of one or more objects to check for a matching binding. */ var arraySize, i, k, len1 TTcl_Size var bestPtr, bindInfoPtr, curEvent, dispPtr, end, interp, mPtr, matchPtrArr, oldDispPtr, p, patPtr, physTables, psEntry, psList, psNext, psSuccList, screenPtr, virtTables, winPtr, v8 uintptr var code, oldScreen, reset int32 var flags, newArraySize, scriptCount, v2, v3, v4, v9 uint32 var interpState TTcl_InterpState var psPtr, psl [2]uintptr var _ /* matchPtr at bp+480 */ uintptr var _ /* matchPtrBuf at bp+0 */ [32]uintptr var _ /* scripts at bp+256 */ TTcl_DString _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = arraySize, bestPtr, bindInfoPtr, code, curEvent, dispPtr, end, flags, i, interp, interpState, k, len1, mPtr, matchPtrArr, newArraySize, oldDispPtr, oldScreen, p, patPtr, physTables, psEntry, psList, psNext, psPtr, psSuccList, psl, reset, screenPtr, scriptCount, virtTables, winPtr, v2, v3, v4, v8, v9 winPtr = tkwin matchPtrArr = bp /* * Ignore events on windows that don't have names: these are windows like * wrapper windows that shouldn't be visible to the application. */ if !((*TTkWindow)(unsafe.Pointer(winPtr)).FpathName != 0) { return } flags = libc.Uint32FromInt32(_flagArray[(*TXEvent)(unsafe.Pointer(eventPtr)).Ftype1]) /* * Ignore event types which are not in flagArray and all zeroes there. */ if (*TXEvent)(unsafe.Pointer(eventPtr)).Ftype1 >= libc.Int32FromInt32(MappingNotify)+libc.Int32FromInt32(6) || !(flags != 0) { return } if flags&libc.Uint32FromInt32(libc.Int32FromInt32(1)< libc.Uint64FromInt64(256)/libc.Uint64FromInt64(8) { /* It's unrealistic that the buffer size is too small, but who knows? */ matchPtrArr = libtcl9_0.XTcl_Alloc(tls, libc.Uint64FromInt64(numObjects)*uint64(8)) } libc.Xmemset(tls, matchPtrArr, 0, libc.Uint64FromInt64(numObjects)*uint64(8)) if !(_PromArr_IsEmpty(tls, (*TTk_BindingTable_)(unsafe.Pointer(bindPtr)).FpromArr) != 0) { k = 0 for { if !(k < numObjects) { break } psl[int32(1)] = _PromArr_Last(tls, (*TTk_BindingTable_)(unsafe.Pointer(bindPtr)).FpromArr) psl[0] = psl[int32(1)] - uintptr(1)*16 /* * Loop over all promoted bindings, finding the longest matching one. * * Note that we must process all lists, because all matching patterns * have to be promoted. Normally at most one list will be processed, and * usually this list only contains one or two patterns. */ i = libc.Int64FromUint64(_PromArr_Size(tls, (*TTk_BindingTable_)(unsafe.Pointer(bindPtr)).FpromArr)) for { if !(i > 0) { break } psPtr[0] = _MatchPatterns(tls, dispPtr, bindPtr, psl[0], psl[int32(1)], libc.Uint32FromInt64(i), curEvent, *(*uintptr)(unsafe.Pointer(objArr + uintptr(k)*8)), libc.UintptrFromInt32(0)) if _IsBetterMatch(tls, *(*uintptr)(unsafe.Pointer(matchPtrArr + uintptr(k)*8)), psPtr[0]) != 0 { /* We will process it later, because we still may find a pattern with better match. */ *(*uintptr)(unsafe.Pointer(matchPtrArr + uintptr(k)*8)) = psPtr[0] } if !(_PSList_IsEmpty(tls, psl[int32(1)]) != 0) { /* We have promoted sequences, adjust array size. */ arraySize = _Max(tls, i+int64(1), arraySize) } goto _6 _6: ; i-- psl[0] -= 16 psl[int32(1)] -= 16 } goto _5 _5: ; k++ } } /* * 1. Look for bindings for the specific detail (button and key events). * 2. Look for bindings without detail. */ k = 0 for { if !(k < numObjects) { break } psSuccList = _PromArr_First(tls, (*TTk_BindingTable_)(unsafe.Pointer(bindPtr)).FpromArr) psl[0] = _GetLookupForEvent(tls, physTables, curEvent, *(*uintptr)(unsafe.Pointer(objArr + uintptr(k)*8)), int32(1)) psl[int32(1)] = _GetLookupForEvent(tls, physTables, curEvent, *(*uintptr)(unsafe.Pointer(objArr + uintptr(k)*8)), 0) psPtr[0] = _MatchPatterns(tls, dispPtr, bindPtr, psl[0], psSuccList, uint32(0), curEvent, *(*uintptr)(unsafe.Pointer(objArr + uintptr(k)*8)), libc.UintptrFromInt32(0)) psPtr[int32(1)] = _MatchPatterns(tls, dispPtr, bindPtr, psl[int32(1)], psSuccList, uint32(0), curEvent, *(*uintptr)(unsafe.Pointer(objArr + uintptr(k)*8)), libc.UintptrFromInt32(0)) if !(_PSList_IsEmpty(tls, psSuccList) != 0) { /* We have promoted sequences, adjust array size. */ arraySize = _Max(tls, int64(1), arraySize) } if psPtr[0] != 0 { v8 = psPtr[0] } else { v8 = psPtr[int32(1)] } bestPtr = v8 if *(*uintptr)(unsafe.Pointer(matchPtrArr + uintptr(k)*8)) != 0 { if _IsBetterMatch(tls, *(*uintptr)(unsafe.Pointer(matchPtrArr + uintptr(k)*8)), bestPtr) != 0 { *(*uintptr)(unsafe.Pointer(matchPtrArr + uintptr(k)*8)) = bestPtr } else { /* * We've already found a higher level match, nevertheless it was required to * process the level zero patterns because of possible promotions. */ } /* * Now we have to catch up the processing of the script. */ } else { /* * We have to look whether we can find a better match in virtual table, provided that we * don't have a higher level match. */ *(*uintptr)(unsafe.Pointer(matchPtrArr + uintptr(k)*8)) = bestPtr if (*TXEvent)(unsafe.Pointer(eventPtr)).Ftype1 != libc.Int32FromInt32(MappingNotify)+libc.Int32FromInt32(1) { virtTables = bindInfoPtr *(*uintptr)(unsafe.Pointer(bp + 480)) = *(*uintptr)(unsafe.Pointer(matchPtrArr + uintptr(k)*8)) /* * Note that virtual events cannot promote. */ psl[0] = _GetLookupForEvent(tls, virtTables, curEvent, libc.UintptrFromInt32(0), int32(1)) psl[int32(1)] = _GetLookupForEvent(tls, virtTables, curEvent, libc.UintptrFromInt32(0), 0) mPtr = _MatchPatterns(tls, dispPtr, bindPtr, psl[0], libc.UintptrFromInt32(0), uint32(0), curEvent, *(*uintptr)(unsafe.Pointer(objArr + uintptr(k)*8)), bp+480) if mPtr != 0 { *(*uintptr)(unsafe.Pointer(matchPtrArr + uintptr(k)*8)) = *(*uintptr)(unsafe.Pointer(bp + 480)) *(*uintptr)(unsafe.Pointer(bp + 480)) = mPtr } if _MatchPatterns(tls, dispPtr, bindPtr, psl[int32(1)], libc.UintptrFromInt32(0), uint32(0), curEvent, *(*uintptr)(unsafe.Pointer(objArr + uintptr(k)*8)), bp+480) != 0 { *(*uintptr)(unsafe.Pointer(matchPtrArr + uintptr(k)*8)) = *(*uintptr)(unsafe.Pointer(bp + 480)) } } } if *(*uintptr)(unsafe.Pointer(matchPtrArr + uintptr(k)*8)) != 0 { v9 = scriptCount scriptCount++ _ExpandPercents(tls, winPtr, (*TPatSeq)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(matchPtrArr + uintptr(k)*8)))).Fscript, curEvent, v9, bp+256) /* Null is added to the scripts string to separate the various scripts. */ libtcl9_0.XTcl_DStringAppend(tls, bp+256, __ccgo_ts+195, int64(1)) } goto _7 _7: ; k++ } _PromArr_SetSize(tls, (*TTk_BindingTable_)(unsafe.Pointer(bindPtr)).FpromArr, libc.Uint64FromInt64(arraySize)) /* * Remove expired pattern sequences. */ i = 0 newArraySize = libc.Uint32FromInt32(0) for { if !(i < arraySize) { break } psList = _PromArr_Get(tls, (*TTk_BindingTable_)(unsafe.Pointer(bindPtr)).FpromArr, libc.Uint64FromInt64(i)) psEntry = _PSList_First(tls, psList) for { if !(psEntry != 0) { break } psNext = _PSList_Next(tls, psEntry) patPtr = (*TPSEntry)(unsafe.Pointer(psEntry)).FpsPtr + 56 + uintptr(i+int64(1))*32 /* * We have to remove the following entries from promotion list (but * only if we don't want to keep it): * ------------------------------------------------------------------ * 1) It is marked as expired (see MatchPatterns()). * 2) If we have a Key event, and current entry is matching a Button. * 3) If we have a Button event, and current entry is matching a Key. * 4) If we have a detailed event, current entry it is also detailed, * we have matching event types, but the details are different. * 5) Current entry has been matched with a different window. */ if int32(uint32(*(*uint8)(unsafe.Pointer(psEntry + 44))&0x2>>1)) != 0 { libc.SetBitFieldPtr8Uint32(psEntry+44, libc.Uint32FromInt32(0), 1, 0x2) } else { if int32(uint32(*(*uint8)(unsafe.Pointer(psEntry + 44))&0x1>>0)) != 0 || (*TPSEntry)(unsafe.Pointer(psEntry)).Fwindow != (*(*TXAnyEvent)(unsafe.Pointer(&(*TEvent)(unsafe.Pointer(curEvent)).Fxev))).Fwindow || (*TTkPattern)(unsafe.Pointer(patPtr)).Finfo != 0 && *(*TInfo)(unsafe.Pointer(curEvent + 192)) != 0 && (*TTkPattern)(unsafe.Pointer(patPtr)).FeventType == libc.Uint32FromInt32((*TEvent)(unsafe.Pointer(curEvent)).Fxev.Ftype1) && (*TTkPattern)(unsafe.Pointer(patPtr)).Finfo != *(*TInfo)(unsafe.Pointer(curEvent + 192)) { _RemoveListEntry(tls, bindPtr+8344+208, psEntry) } else { switch (*TTkPattern)(unsafe.Pointer(patPtr)).FeventType { case uint32(ButtonPress): fallthrough case uint32(ButtonRelease): if _IsKeyEventType(tls, (*TEvent)(unsafe.Pointer(curEvent)).Fxev.Ftype1) != 0 { _RemoveListEntry(tls, bindPtr+8344+208, psEntry) } case uint32(KeyPress): fallthrough case uint32(KeyRelease): if _IsButtonEventType(tls, libc.Uint32FromInt32((*TEvent)(unsafe.Pointer(curEvent)).Fxev.Ftype1)) != 0 { _RemoveListEntry(tls, bindPtr+8344+208, psEntry) } break } } } goto _11 _11: ; psEntry = psNext } if !(_PSList_IsEmpty(tls, psList) != 0) { /* We still have promoted sequences, adjust array size. */ newArraySize = libc.Uint32FromInt64(_Max(tls, i+int64(1), libc.Int64FromUint32(newArraySize))) } goto _10 _10: ; i++ } _PromArr_SetSize(tls, (*TTk_BindingTable_)(unsafe.Pointer(bindPtr)).FpromArr, uint64(newArraySize)) if matchPtrArr != bp { libtcl9_0.XTcl_Free(tls, matchPtrArr) } if (*TTcl_DString)(unsafe.Pointer(bp+256)).Flength == 0 { return /* Nothing to do. */ } /* * Now go back through and evaluate the binding for each object, in order, * dealing with "break" and "continue" exceptions appropriately. * * There are two tricks here: * 1. Bindings can be invoked from in the middle of Tcl commands, where * the interp's result is significant (for example, a widget might be * deleted because of an error in creating it, so the result contains * an error message that is eventually going to be returned by the * creating command). To preserve the result, we save it in a dynamic * string. * 2. The binding's action can potentially delete the binding, so bindPtr * may not point to anything valid once the action completes. Thus we * have to save bindPtr->interp in a local variable in order to restore * the result. */ interp = (*TTk_BindingTable_)(unsafe.Pointer(bindPtr)).Finterp /* * Save information about the current screen, then invoke a script if the * screen has changed. */ interpState = libtcl9_0.XTcl_SaveInterpState(tls, interp, TCL_OK) screenPtr = bindInfoPtr + 336 oldDispPtr = (*TScreenInfo)(unsafe.Pointer(screenPtr)).FcurDispPtr oldScreen = (*TScreenInfo)(unsafe.Pointer(screenPtr)).FcurScreenIndex if dispPtr != (*TScreenInfo)(unsafe.Pointer(screenPtr)).FcurDispPtr || (*TTk_FakeWin)(unsafe.Pointer(tkwin)).FscreenNum != (*TScreenInfo)(unsafe.Pointer(screenPtr)).FcurScreenIndex { (*TScreenInfo)(unsafe.Pointer(screenPtr)).FcurDispPtr = dispPtr (*TScreenInfo)(unsafe.Pointer(screenPtr)).FcurScreenIndex = (*TTk_FakeWin)(unsafe.Pointer(tkwin)).FscreenNum _ChangeScreen(tls, interp, (*TTkDisplay)(unsafe.Pointer(dispPtr)).Fname, (*TScreenInfo)(unsafe.Pointer(screenPtr)).FcurScreenIndex) } /* * Be careful when dereferencing screenPtr or bindInfoPtr. If we evaluate * something that destroys ".", bindInfoPtr would have been freed, but we * can tell that by first checking to see if winPtr->mainPtr == NULL. */ libtcl9_0.XTcl_Preserve(tls, bindInfoPtr) p = (*TTcl_DString)(unsafe.Pointer(bp + 256)).Fstring1 end = p + uintptr((*TTcl_DString)(unsafe.Pointer(bp+256)).Flength) for { if !(p < end) { break } len1 = libc.Int64FromUint64(libc.Xstrlen(tls, p)) if !((*TBindInfo)(unsafe.Pointer(bindInfoPtr)).Fdeleted != 0) { (*TScreenInfo)(unsafe.Pointer(screenPtr)).FbindingDepth++ } libtcl9_0.XTcl_AllowExceptions(tls, interp) code = libtcl9_0.XTcl_EvalEx(tls, interp, p, len1, int32(TCL_EVAL_GLOBAL)) p += uintptr(len1 + int64(1)) if !((*TBindInfo)(unsafe.Pointer(bindInfoPtr)).Fdeleted != 0) { (*TScreenInfo)(unsafe.Pointer(screenPtr)).FbindingDepth-- } if code != TCL_OK && code != int32(TCL_CONTINUE) { if code != int32(TCL_BREAK) { libtcl9_0.XTcl_AppendObjToErrorInfo(tls, interp, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+2536, int64(-int32(1)))) libtcl9_0.XTcl_BackgroundException(tls, interp, code) } break } goto _12 _12: } if !((*TBindInfo)(unsafe.Pointer(bindInfoPtr)).Fdeleted != 0) && (*TScreenInfo)(unsafe.Pointer(screenPtr)).FbindingDepth > uint32(0) && (oldDispPtr != (*TScreenInfo)(unsafe.Pointer(screenPtr)).FcurDispPtr || oldScreen != (*TScreenInfo)(unsafe.Pointer(screenPtr)).FcurScreenIndex) { /* * Some other binding script is currently executing, but its screen is * no longer current. Change the current display back again. */ (*TScreenInfo)(unsafe.Pointer(screenPtr)).FcurDispPtr = oldDispPtr (*TScreenInfo)(unsafe.Pointer(screenPtr)).FcurScreenIndex = oldScreen _ChangeScreen(tls, interp, (*TTkDisplay)(unsafe.Pointer(oldDispPtr)).Fname, oldScreen) } libtcl9_0.XTcl_RestoreInterpState(tls, interp, interpState) libtcl9_0.XTcl_DStringFree(tls, bp+256) libtcl9_0.XTcl_Release(tls, bindInfoPtr) } /* *---------------------------------------------------------------------- * * MatchPatterns -- * * Given a list of pattern sequences and the recent event, return * the pattern sequence that best matches this event, if there is * one. * * Results: * * The return value is NULL if no match is found. Otherwise the * return value is the most specific pattern sequence among all * those that match the event table. * * Side effects: * None. * *---------------------------------------------------------------------- */ // C documentation // // /* helper function */ func _VirtPatIsBound(tls *libc.TLS, bindPtr TTk_BindingTable, psPtr uintptr, object uintptr, physPtrPtr uintptr) (r int32) { bp := tls.Alloc(32) defer tls.Free(32) /* Input: the best physical event. * Output: the physical event associated with matching virtual event. */ var hPtr, owners, physPatPtr, virtPatPtr, v2, v3 uintptr var i uint32 var _ /* key at bp+0 */ TPatternTableKey _, _, _, _, _, _, _ = hPtr, i, owners, physPatPtr, virtPatPtr, v2, v3 if *(*uintptr)(unsafe.Pointer(physPtrPtr)) != 0 { physPatPtr = *(*uintptr)(unsafe.Pointer(physPtrPtr)) + 56 virtPatPtr = psPtr + 56 if (*TTkPattern)(unsafe.Pointer(physPatPtr)).Finfo != 0 || !((*TTkPattern)(unsafe.Pointer(virtPatPtr)).Finfo != 0) { if _IsSubsetOf(tls, (*TTkPattern)(unsafe.Pointer(virtPatPtr)).FmodMask, (*TTkPattern)(unsafe.Pointer(physPatPtr)).FmodMask) != 0 { return 0 /* We cannot surpass this match. */ } } } /* Otherwise on some systems the key contains uninitialized bytes. */ libc.Xmemset(tls, bp, 0, uint64(24)) (*(*TPatternTableKey)(unsafe.Pointer(bp))).Fobject = object (*(*TPatternTableKey)(unsafe.Pointer(bp))).Ftype1 = libc.Uint32FromInt32(libc.Int32FromInt32(MappingNotify) + libc.Int32FromInt32(1)) owners = *(*uintptr)(unsafe.Pointer(psPtr + 48)) i = uint32(0) for { if !(uint64(i) < _VirtOwners_Size(tls, owners)) { break } hPtr = _VirtOwners_Get(tls, owners, uint64(i)) if (*TTcl_HashTable)(unsafe.Pointer((*TTcl_HashEntry)(unsafe.Pointer(hPtr)).FtablePtr)).FkeyType == int32(TCL_ONE_WORD_KEYS) || (*TTcl_HashTable)(unsafe.Pointer((*TTcl_HashEntry)(unsafe.Pointer(hPtr)).FtablePtr)).FkeyType == -int32(1) { v2 = *(*uintptr)(unsafe.Pointer(hPtr + 32)) } else { v2 = hPtr + 32 } *(*TTk_Uid)(unsafe.Pointer(bp + 16)) = v2 v3 = (*(*func(*libc.TLS, uintptr, uintptr) uintptr)(unsafe.Pointer(&struct{ uintptr }{(*TTcl_HashTable)(unsafe.Pointer(bindPtr + 8344)).FfindProc})))(tls, bindPtr+8344, bp) hPtr = v3 if v3 != 0 { /* The physical event matches this virtual event's definition. */ *(*uintptr)(unsafe.Pointer(physPtrPtr)) = (*TTcl_HashEntry)(unsafe.Pointer(hPtr)).FclientData return int32(1) } goto _1 _1: ; i++ } return 0 } // C documentation // // /* helper function */ func _Compare(tls *libc.TLS, fstMatchPtr uintptr, sndMatchPtr uintptr) (r int32) { /* Most recent match. */ var diff, v1 int32 _, _ = diff, v1 if !(fstMatchPtr != 0) { return +libc.Int32FromInt32(1) } diff = _CountSpecialized(tls, fstMatchPtr, sndMatchPtr) if diff != 0 { v1 = diff } else { v1 = libc.Int32FromUint32((*TPatSeq)(unsafe.Pointer(sndMatchPtr)).Fcount) - libc.Int32FromUint32((*TPatSeq)(unsafe.Pointer(fstMatchPtr)).Fcount) } return v1 } // C documentation // // /* helper function */ func _CompareModMasks(tls *libc.TLS, fstModMaskArr uintptr, sndModMaskArr uintptr, fstModMask uint32, sndModMask uint32) (r int32) { var fstCount, i, sndCount int32 var fstiModMask, sndiModMask uint32 _, _, _, _, _ = fstCount, fstiModMask, i, sndCount, sndiModMask fstCount = 0 sndCount = 0 if _PSModMaskArr_IsEmpty(tls, fstModMaskArr) != 0 { if !(_PSModMaskArr_IsEmpty(tls, sndModMaskArr) != 0) { i = libc.Int32FromUint64(_PSModMaskArr_Size(tls, sndModMaskArr) - uint64(1)) for { if !(i >= 0) { break } if *(*uint32)(unsafe.Pointer(_PSModMaskArr_Get(tls, sndModMaskArr, libc.Uint64FromInt32(i)))) != 0 { sndCount++ } goto _1 _1: ; i-- } } } else { if _PSModMaskArr_IsEmpty(tls, sndModMaskArr) != 0 { i = libc.Int32FromUint64(_PSModMaskArr_Size(tls, fstModMaskArr) - uint64(1)) for { if !(i >= 0) { break } if *(*uint32)(unsafe.Pointer(_PSModMaskArr_Get(tls, fstModMaskArr, libc.Uint64FromInt32(i)))) != 0 { fstCount++ } goto _2 _2: ; i-- } } else { i = libc.Int32FromUint64(_PSModMaskArr_Size(tls, fstModMaskArr) - uint64(1)) for { if !(i >= 0) { break } fstiModMask = *(*uint32)(unsafe.Pointer(_PSModMaskArr_Get(tls, fstModMaskArr, libc.Uint64FromInt32(i)))) sndiModMask = *(*uint32)(unsafe.Pointer(_PSModMaskArr_Get(tls, sndModMaskArr, libc.Uint64FromInt32(i)))) if _IsSubsetOf(tls, fstiModMask, sndiModMask) != 0 { sndCount++ } if _IsSubsetOf(tls, sndiModMask, fstiModMask) != 0 { fstCount++ } goto _3 _3: ; i-- } } } /* Finally compare modifier masks of last pattern. */ if _IsSubsetOf(tls, fstModMask, sndModMask) != 0 { sndCount++ } if _IsSubsetOf(tls, sndModMask, fstModMask) != 0 { fstCount++ } return fstCount - sndCount } // C documentation // // /* helper function */ func _IsPSInPSList(tls *libc.TLS, psPtr uintptr, psList uintptr) (r int32) { /* ...an element of this list of patterns sequence? */ var psEntry, v2 uintptr _, _ = psEntry, v2 if (*TPSList)(unsafe.Pointer(psList)).Ffirst != 0 { v2 = (*TPSList)(unsafe.Pointer(psList)).Ffirst } else { v2 = psList } psEntry = v2 for { if !(psEntry != psList) { break } if (*TPSEntry)(unsafe.Pointer(psEntry)).FpsPtr == psPtr { return int32(1) } goto _1 _1: ; psEntry = (*TPSEntry)(unsafe.Pointer(psEntry)).F_dl_.Fnext } return 0 } func _MatchPatterns(tls *libc.TLS, dispPtr uintptr, bindPtr TTk_BindingTable, psList uintptr, psSuccList uintptr, patIndex uint32, curEvent uintptr, object uintptr, physPtrPtr uintptr) (r uintptr) { bp := tls.Alloc(16) defer tls.Free(16) /* Input: the best physical event; NULL if we test physical events. * Output: the associated physical event for the best matching virtual * event; NULL when we match physical events. */ var bestModMask, count, curModMask, v4 uint32 var bestModMaskArr, bestPhysPtr, bestPtr, patPtr, psEntry, psNewEntry, psPtr uintptr var cmp, isModKeyOnly, v3 int32 var i TTcl_Size var window TWindow var _ /* modMask at bp+0 */ uint32 _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = bestModMask, bestModMaskArr, bestPhysPtr, bestPtr, cmp, count, curModMask, i, isModKeyOnly, patPtr, psEntry, psNewEntry, psPtr, window, v3, v4 bestModMaskArr = libc.UintptrFromInt32(0) isModKeyOnly = 0 if !(psList != 0) { return libc.UintptrFromInt32(0) } bestModMask = uint32(0) bestPtr = libc.UintptrFromInt32(0) bestPhysPtr = libc.UintptrFromInt32(0) window = (*(*TXAnyEvent)(unsafe.Pointer(&(*TEvent)(unsafe.Pointer(curEvent)).Fxev))).Fwindow /* * Modifier key events interlaced between patterns parts of a * sequence shall not prevent a sequence from ultimately * matching. Example: when trying to trigger * from the keyboard, the sequence of events actually seen is * then (possibly repeating if the key is hold * down), and finally . At the time is * seen, we shall keep the pattern sequence in * the promotion list, otherwise it is impossible to trigger * it from the keyboard. See bug [16ef161925]. */ if _IsKeyEventType(tls, (*TEvent)(unsafe.Pointer(curEvent)).Fxev.Ftype1) != 0 { i = 0 for { if !(i < (*TTkDisplay)(unsafe.Pointer(dispPtr)).FnumModKeyCodes) { break } if uint32(*(*TKeyCode)(unsafe.Pointer((*TTkDisplay)(unsafe.Pointer(dispPtr)).FmodKeyCodes + uintptr(i)))) == (*(*TXKeyEvent)(unsafe.Pointer(&(*TEvent)(unsafe.Pointer(curEvent)).Fxev))).Fkeycode { isModKeyOnly = int32(1) break } goto _1 _1: ; i++ } } psEntry = _PSList_First(tls, psList) for { if !(psEntry != 0) { break } if patIndex == uint32(0) || (*TPSEntry)(unsafe.Pointer(psEntry)).Fwindow == window { psPtr = (*TPSEntry)(unsafe.Pointer(psEntry)).FpsPtr if (*TPatSeq)(unsafe.Pointer(psPtr)).Fobject != 0 { v3 = libc.BoolInt32((*TPatSeq)(unsafe.Pointer(psPtr)).Fobject == object) } else { v3 = _VirtPatIsBound(tls, bindPtr, psPtr, object, physPtrPtr) } if v3 != 0 { patPtr = psPtr + 56 + uintptr(patIndex)*32 /* Ignore modifier key events, and KeyRelease events if the current event * is of a different type (e.g. a Button event) */ libc.SetBitFieldPtr8Uint32(psEntry+44, libc.BoolUint32(isModKeyOnly != 0 || (*TTkPattern)(unsafe.Pointer(patPtr)).FeventType != libc.Uint32FromInt32((*TEvent)(unsafe.Pointer(curEvent)).Fxev.Ftype1) && (*TEvent)(unsafe.Pointer(curEvent)).Fxev.Ftype1 == int32(KeyRelease)), 1, 0x2) if (*TTkPattern)(unsafe.Pointer(patPtr)).FeventType == libc.Uint32FromInt32((*TEvent)(unsafe.Pointer(curEvent)).Fxev.Ftype1) && ((*TEvent)(unsafe.Pointer(curEvent)).Fxev.Ftype1 != int32(CreateNotify) || (*(*TXCreateWindowEvent)(unsafe.Pointer(&(*TEvent)(unsafe.Pointer(curEvent)).Fxev))).Fparent == window) && (!((*TTkPattern)(unsafe.Pointer(patPtr)).Fname != 0) || (*TTkPattern)(unsafe.Pointer(patPtr)).Fname == *(*TTk_Uid)(unsafe.Pointer(curEvent + 192))) && (!((*TTkPattern)(unsafe.Pointer(patPtr)).Finfo != 0) || (*TTkPattern)(unsafe.Pointer(patPtr)).Finfo == *(*TInfo)(unsafe.Pointer(curEvent + 192))) { /* * Resolve the modifier mask for Alt and Mod keys. Unfortunately this * cannot be done in ParseEventDescription, otherwise this function would * be the better place. */ *(*uint32)(unsafe.Pointer(bp)) = _ResolveModifiers(tls, dispPtr, (*TTkPattern)(unsafe.Pointer(patPtr)).FmodMask) curModMask = _ResolveModifiers(tls, dispPtr, (*TTk_BindingTable_)(unsafe.Pointer(bindPtr)).FcurModMask) libc.SetBitFieldPtr8Uint32(psEntry+44, libc.Uint32FromInt32(1), 0, 0x1) /* Remove it from promotion list. */ libc.SetBitFieldPtr8Uint32(psEntry+44, libc.Uint32FromInt32(0), 1, 0x2) /* Don't keep matching patterns. */ if _IsSubsetOf(tls, *(*uint32)(unsafe.Pointer(bp)), curModMask) != 0 { if (*TTkPattern)(unsafe.Pointer(patPtr)).Finfo != 0 { v4 = (*TEvent)(unsafe.Pointer(curEvent)).FcountDetailed } else { v4 = (*TEvent)(unsafe.Pointer(curEvent)).FcountAny } count = v4 if uint64(patIndex) < _PSModMaskArr_Size(tls, (*TPSEntry)(unsafe.Pointer(psEntry)).FlastModMaskArr) { _PSModMaskArr_Set(tls, (*TPSEntry)(unsafe.Pointer(psEntry)).FlastModMaskArr, uint64(patIndex), bp) } /* * This pattern is finally matching. */ if (*TPatSeq)(unsafe.Pointer(psPtr)).FnumPats == patIndex+uint32(1) { if (*TTkPattern)(unsafe.Pointer(patPtr)).Fcount <= count { /* * This is also a final pattern (i.e. the pattern sequence is complete). * We always prefer the pattern with better match. * If completely equal than prefer most recently defined pattern. */ cmp = _Compare(tls, bestPtr, psPtr) if cmp == 0 { cmp = _CompareModMasks(tls, (*TPSEntry)(unsafe.Pointer(psEntry)).FlastModMaskArr, bestModMaskArr, *(*uint32)(unsafe.Pointer(bp)), bestModMask) } if cmp > 0 || cmp == 0 && (*TPatSeq)(unsafe.Pointer(bestPtr)).Fnumber < (*TPatSeq)(unsafe.Pointer(psPtr)).Fnumber { bestPtr = psPtr bestModMask = *(*uint32)(unsafe.Pointer(bp)) bestModMaskArr = (*TPSEntry)(unsafe.Pointer(psEntry)).FlastModMaskArr if physPtrPtr != 0 { bestPhysPtr = *(*uintptr)(unsafe.Pointer(physPtrPtr)) } } } else { libc.SetBitFieldPtr8Uint32(psEntry+44, libc.Uint32FromInt32(1), 1, 0x2) /* Don't remove it from promotion list. */ } } else { if psSuccList != 0 { /* * Not a final pattern, but matching (i.e. successive patterns match the pattern sequence so far), * so promote the pattern sequence to next level if not already promoted in the success list. * But do not promote if count of current pattern is not yet reached. */ if !(_IsPSInPSList(tls, psPtr, psSuccList) != 0) { if (*TTkPattern)(unsafe.Pointer(patPtr)).Fcount == (*TPSEntry)(unsafe.Pointer(psEntry)).Fcount { psNewEntry = _MakeListEntry(tls, bindPtr+8344+208, psPtr, int32(uint32(*(*uint8)(unsafe.Pointer(psPtr + 12))&0x2>>1))) if !(_PSModMaskArr_IsEmpty(tls, (*TPSEntry)(unsafe.Pointer(psNewEntry)).FlastModMaskArr) != 0) { _PSModMaskArr_Set(tls, (*TPSEntry)(unsafe.Pointer(psNewEntry)).FlastModMaskArr, uint64(patIndex), bp) } _PSList_Append(tls, psSuccList, psNewEntry) (*TPSEntry)(unsafe.Pointer(psNewEntry)).Fwindow = window /* Bind to current window. */ } else { *(*uint32)(unsafe.Pointer(psEntry + 40)) += uint32(1) libc.SetBitFieldPtr8Uint32(psEntry+44, libc.Uint32FromInt32(1), 1, 0x2) /* Don't remove it from promotion list. */ } } else { /* * Pattern sequence is already present in the success list. */ libc.SetBitFieldPtr8Uint32(psEntry+44, libc.Uint32FromInt32(1), 1, 0x2) /* Don't remove it from promotion list. */ } } } } } } } goto _2 _2: ; psEntry = _PSList_Next(tls, psEntry) } if bestPhysPtr != 0 { *(*uintptr)(unsafe.Pointer(physPtrPtr)) = bestPhysPtr } return bestPtr } /* *-------------------------------------------------------------- * * ExpandPercents -- * * Given a command and an event, produce a new command by replacing % * constructs in the original command with information from the X event. * * Results: * The new expanded command is appended to the dynamic string given by * dsPtr. * * Side effects: * None. * *-------------------------------------------------------------- */ func _ExpandPercents(tls *libc.TLS, winPtr uintptr, before uintptr, eventPtr uintptr, scriptCount uint32, dsPtr uintptr) { bp := tls.Alloc(272) defer tls.Free(272) /* Dynamic string in which to append new command. */ var detail, v1, v3 int32 var evPtr, name, string1, vePtr, v4 uintptr var flags uint32 var length, spaceNeeded TTcl_Size var number int64 var tkwin TTk_Window var unumber uint64 var _ /* buf at bp+0 */ TTcl_DString var _ /* cvtFlags at bp+248 */ int32 var _ /* numStorage at bp+224 */ [24]uint8 _, _, _, _, _, _, _, _, _, _, _, _, _, _ = detail, evPtr, flags, length, name, number, spaceNeeded, string1, tkwin, unumber, vePtr, v1, v3, v4 libtcl9_0.XTcl_DStringInit(tls, bp) evPtr = eventPtr if (*TXEvent)(unsafe.Pointer(evPtr)).Ftype1 < libc.Int32FromInt32(MappingNotify)+libc.Int32FromInt32(6) { v1 = _flagArray[(*TXEvent)(unsafe.Pointer(evPtr)).Ftype1] } else { v1 = 0 } flags = libc.Uint32FromInt32(v1) for int32(1) != 0 { /* unsigned */ /* * Find everything up to the next % character and append it to the * result string. */ string1 = before for { if !(*(*uint8)(unsafe.Pointer(string1)) != 0 && libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(string1))) != int32('%')) { break } goto _2 _2: ; string1++ } if string1 != before { libtcl9_0.XTcl_DStringAppend(tls, dsPtr, before, int64(string1)-int64(before)) before = string1 } if !(*(*uint8)(unsafe.Pointer(before)) != 0) { break } /* * There's a percent sequence here. Process it. */ string1 = __ccgo_ts + 2566 switch libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(before + 1))) { case int32('#'): unumber = (*(*TXAnyEvent)(unsafe.Pointer(evPtr))).Fserial libc.X__builtin_snprintf(tls, bp+224, uint64(24), __ccgo_ts+2569, libc.VaList(bp+264, unumber)) string1 = bp + 224 case int32('a'): if flags&libc.Uint32FromInt32(libc.Int32FromInt32(1)<= 0) { break } psPtr = _PhysOwned_Get(tls, *(*uintptr)(unsafe.Pointer(bp)), libc.Uint64FromInt32(iPhys)) if !(eventPSPtr != 0) || psPtr == eventPSPtr { owners = *(*uintptr)(unsafe.Pointer(psPtr + 48)) iVirt = _VirtOwners_Find(tls, owners, vhPtr) /* Otherwise we couldn't find owner, and this should not happen. */ /* * Remove association between this physical event and the given * virtual event that it triggers. */ if _VirtOwners_Size(tls, owners) > uint64(1) { /* * This physical event still triggers some other virtual * event(s). Consolidate the list of virtual owners for this * physical event so it no longer triggers the given virtual * event. */ _VirtOwners_Set(tls, owners, libc.Uint64FromInt32(iVirt), _VirtOwners_Back(tls, owners)) _VirtOwners_PopBack(tls, owners) } else { /* * Removed last reference to this physical event, so remove it * from lookup table. */ _RemovePatSeqFromLookup(tls, vetPtr, psPtr) _DeletePatSeq(tls, psPtr) } /* * Now delete the virtual event's reference to the physical event. */ lastElemPtr = _PhysOwned_Back(tls, *(*uintptr)(unsafe.Pointer(bp))) if _PhysOwned_PopBack(tls, *(*uintptr)(unsafe.Pointer(bp))) > uint64(0) && eventPSPtr != 0 { /* * Just deleting this one physical event. Consolidate list of * owned physical events and return. */ if libc.Uint64FromInt32(iPhys) < _PhysOwned_Size(tls, *(*uintptr)(unsafe.Pointer(bp))) { _PhysOwned_Set(tls, *(*uintptr)(unsafe.Pointer(bp)), libc.Uint64FromInt32(iPhys), lastElemPtr) } return TCL_OK } } goto _4 _4: } if _PhysOwned_IsEmpty(tls, *(*uintptr)(unsafe.Pointer(bp))) != 0 { /* * All the physical events for this virtual event were deleted, either * because there was only one associated physical event or because the * caller was deleting the entire virtual event. Now the virtual event * itself should be deleted. */ _PhysOwned_Free(tls, bp) libtcl9_0.XTcl_DeleteHashEntry(tls, vhPtr) } return TCL_OK } /* *--------------------------------------------------------------------------- * * GetVirtualEvent -- * * Return the list of physical events that can invoke the given virtual * event. * * Results: * The return value is TCL_OK and the interp's result is filled with the * string representation of the physical events associated with the * virtual event; if there are no physical events for the given virtual * event, the interp's result is filled with and empty string. If the * virtual event string is improperly formed, then TCL_ERROR is returned * and an error message is left in the interp's result. * * Side effects: * None. * *--------------------------------------------------------------------------- */ func _GetVirtualEvent(tls *libc.TLS, interp uintptr, vetPtr uintptr, virtName uintptr) (r int32) { /* String describing virtual event. */ var iPhys uint32 var owned, resultObj, vhPtr, v2 uintptr var virtUid, v1 TTk_Uid _, _, _, _, _, _, _ = iPhys, owned, resultObj, vhPtr, virtUid, v1, v2 v1 = _GetVirtualEventUid(tls, interp, libtcl9_0.XTcl_GetStringFromObj(tls, virtName, libc.UintptrFromInt32(0))) virtUid = v1 if !(v1 != 0) { return int32(TCL_ERROR) } v2 = (*(*func(*libc.TLS, uintptr, uintptr) uintptr)(unsafe.Pointer(&struct{ uintptr }{(*TTcl_HashTable)(unsafe.Pointer(vetPtr + 232)).FfindProc})))(tls, vetPtr+232, virtUid) vhPtr = v2 if !(v2 != 0) { return TCL_OK } resultObj = libtcl9_0.XTcl_NewObj(tls) owned = (*TTcl_HashEntry)(unsafe.Pointer(vhPtr)).FclientData iPhys = uint32(0) for { if !(uint64(iPhys) < _PhysOwned_Size(tls, owned)) { break } libtcl9_0.XTcl_ListObjAppendElement(tls, libc.UintptrFromInt32(0), resultObj, _GetPatternObj(tls, _PhysOwned_Get(tls, owned, uint64(iPhys)))) goto _3 _3: ; iPhys++ } libtcl9_0.XTcl_SetObjResult(tls, interp, resultObj) return TCL_OK } /* *-------------------------------------------------------------- * * GetAllVirtualEvents -- * * Return a list that contains the names of all the virtual event * defined. * * Results: * There is no return value. The interp's result is modified to hold a * Tcl list with one entry for each virtual event in nameTable. * * Side effects: * None. * *-------------------------------------------------------------- */ func _GetAllVirtualEvents(tls *libc.TLS, interp uintptr, vetPtr uintptr) { bp := tls.Alloc(48) defer tls.Free(48) /* Table containing events. */ var hPtr, msg, resultObj, v2 uintptr var _ /* search at bp+0 */ TTcl_HashSearch _, _, _, _ = hPtr, msg, resultObj, v2 resultObj = libtcl9_0.XTcl_NewObj(tls) hPtr = libtcl9_0.XTcl_FirstHashEntry(tls, vetPtr+232, bp) for { if !(hPtr != 0) { break } if (*TTcl_HashTable)(unsafe.Pointer((*TTcl_HashEntry)(unsafe.Pointer(hPtr)).FtablePtr)).FkeyType == int32(TCL_ONE_WORD_KEYS) || (*TTcl_HashTable)(unsafe.Pointer((*TTcl_HashEntry)(unsafe.Pointer(hPtr)).FtablePtr)).FkeyType == -int32(1) { v2 = *(*uintptr)(unsafe.Pointer(hPtr + 32)) } else { v2 = hPtr + 32 } msg = libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+2794, libc.VaList(bp+32, v2)) libtcl9_0.XTcl_ListObjAppendElement(tls, libc.UintptrFromInt32(0), resultObj, msg) goto _1 _1: ; hPtr = libtcl9_0.XTcl_NextHashEntry(tls, bp) } libtcl9_0.XTcl_SetObjResult(tls, interp, resultObj) } /* *--------------------------------------------------------------------------- * * HandleEventGenerate -- * * Helper function for the "event generate" command. Generate and process * an XEvent, constructed from information parsed from the event * description string and its optional arguments. * * argv[0] contains name of the target window. * argv[1] contains pattern string for one event (e.g, ). * argv[2..argc-1] contains -field/option pairs for specifying additional * detail in the generated event. * * Either virtual or physical events can be generated this way. The event * description string must contain the specification for only one event. * * Results: * None. * * Side effects: * When constructing the event, * event.xany.serial is filled with the current X serial number. * event.xany.window is filled with the target window. * event.xany.display is filled with the target window's display. * Any other fields in eventPtr which are not specified by the pattern * string or the optional arguments, are set to 0. * * The event may be handled synchronously or asynchronously, depending on * the value specified by the optional "-when" option. The default * setting is synchronous. * *--------------------------------------------------------------------------- */ func _HandleEventGenerate(tls *libc.TLS, interp uintptr, mainWin TTk_Window, objc TTcl_Size, objv uintptr) (r int32) { bp := tls.Alloc(336) defer tls.Free(336) /* Argument objects. */ var badOpt, synch, v3, v4, v5 int32 var biPtr, dispPtr, dispPtr1, mainPtr, name, optionPtr, userDataObj, value, value1, valuePtr, windowName uintptr var count, flags, v1 uint32 var i TTcl_Size var keysym TKeySym var pos TTcl_QueuePosition var warpWindow TTk_Window var _ /* event at bp+0 */ struct { Fvirt [0]TXVirtualEvent Fgeneral TXEvent } var _ /* eventMask at bp+248 */ uint32 var _ /* index at bp+260 */ int32 var _ /* number at bp+256 */ int32 var _ /* p at bp+192 */ uintptr var _ /* pat at bp+200 */ TTkPattern var _ /* rootX at bp+264 */ int32 var _ /* rootX at bp+272 */ int32 var _ /* rootY at bp+268 */ int32 var _ /* rootY at bp+276 */ int32 var _ /* tkwin at bp+232 */ TTk_Window var _ /* tkwin2 at bp+240 */ TTk_Window var _ /* warp at bp+252 */ int32 _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = badOpt, biPtr, count, dispPtr, dispPtr1, flags, i, keysym, mainPtr, name, optionPtr, pos, synch, userDataObj, value, value1, valuePtr, warpWindow, windowName, v1, v3, v4, v5 windowName = libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv)), libc.UintptrFromInt32(0)) if !(*(*uint8)(unsafe.Pointer(windowName)) != 0) { *(*TTk_Window)(unsafe.Pointer(bp + 232)) = mainWin } else { if !(_NameToWindow(tls, interp, mainWin, *(*uintptr)(unsafe.Pointer(objv)), bp+232) != 0) { return int32(TCL_ERROR) } } mainPtr = mainWin if !(*(*TTk_Window)(unsafe.Pointer(bp + 232)) != 0) || (*TTkWindow)(unsafe.Pointer(mainPtr)).FmainPtr != (*TTkWindow)(unsafe.Pointer(*(*TTk_Window)(unsafe.Pointer(bp + 232)))).FmainPtr { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+3008, libc.VaList(bp+288, libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv)), libc.UintptrFromInt32(0))))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+288, __ccgo_ts+179, __ccgo_ts+3058, __ccgo_ts+1064, libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv)), libc.UintptrFromInt32(0)), libc.UintptrFromInt32(0))) return int32(TCL_ERROR) } name = libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8)), libc.UintptrFromInt32(0)) *(*uintptr)(unsafe.Pointer(bp + 192)) = name *(*uint32)(unsafe.Pointer(bp + 248)) = uint32(0) userDataObj = libc.UintptrFromInt32(0) v1 = _ParseEventDescription(tls, interp, bp+192, bp+200, bp+248) count = v1 if v1 == uint32(0) { return int32(TCL_ERROR) } if count != uint32(1) { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+3065, int64(-libc.Int32FromInt32(1)))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+288, __ccgo_ts+179, __ccgo_ts+3115, __ccgo_ts+3121, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) } if *(*uint8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 192)))) != 0 { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+3134, int64(-libc.Int32FromInt32(1)))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+288, __ccgo_ts+179, __ccgo_ts+3115, __ccgo_ts+3171, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) } libc.Xmemset(tls, bp, 0, uint64(192)) (*(*TXAnyEvent)(unsafe.Pointer(&*(*TXEvent)(unsafe.Pointer(bp))))).Ftype1 = libc.Int32FromUint32((*(*TTkPattern)(unsafe.Pointer(bp + 200))).FeventType) (*(*TXAnyEvent)(unsafe.Pointer(&*(*TXEvent)(unsafe.Pointer(bp))))).Fserial = (*struct { Fext_data uintptr Fprivate1 uintptr Ffd int32 Fprivate2 int32 Fproto_major_version int32 Fproto_minor_version int32 Fvendor uintptr Fprivate3 TXID Fprivate4 TXID Fprivate5 TXID Fprivate6 int32 Fresource_alloc uintptr Fbyte_order int32 Fbitmap_unit int32 Fbitmap_pad int32 Fbitmap_bit_order int32 Fnformats int32 Fpixmap_format uintptr Fprivate8 int32 Frelease int32 Fprivate9 uintptr Fprivate10 uintptr Fqlen int32 Flast_request_read uint64 Frequest uint64 Fprivate11 TXPointer Fprivate12 TXPointer Fprivate13 TXPointer Fprivate14 TXPointer Fmax_request_size uint32 Fdb uintptr Fprivate15 uintptr Fdisplay_name uintptr Fdefault_screen int32 Fnscreens int32 Fscreens uintptr Fmotion_buffer uint64 Fprivate16 uint64 Fmin_keycode int32 Fmax_keycode int32 Fprivate17 TXPointer Fprivate18 TXPointer Fprivate19 int32 Fxdefaults uintptr })(unsafe.Pointer((*TTk_FakeWin)(unsafe.Pointer(*(*TTk_Window)(unsafe.Pointer(bp + 232)))).Fdisplay)).Frequest + uint64(1) (*(*TXAnyEvent)(unsafe.Pointer(&*(*TXEvent)(unsafe.Pointer(bp))))).Fsend_event = 0 if *(*uint8)(unsafe.Pointer(windowName)) != 0 { (*(*TXAnyEvent)(unsafe.Pointer(&*(*TXEvent)(unsafe.Pointer(bp))))).Fwindow = (*TTk_FakeWin)(unsafe.Pointer(*(*TTk_Window)(unsafe.Pointer(bp + 232)))).Fwindow } else { (*(*TXAnyEvent)(unsafe.Pointer(&*(*TXEvent)(unsafe.Pointer(bp))))).Fwindow = (*TScreen)(unsafe.Pointer((*struct { Fext_data uintptr Fprivate1 uintptr Ffd int32 Fprivate2 int32 Fproto_major_version int32 Fproto_minor_version int32 Fvendor uintptr Fprivate3 TXID Fprivate4 TXID Fprivate5 TXID Fprivate6 int32 Fresource_alloc uintptr Fbyte_order int32 Fbitmap_unit int32 Fbitmap_pad int32 Fbitmap_bit_order int32 Fnformats int32 Fpixmap_format uintptr Fprivate8 int32 Frelease int32 Fprivate9 uintptr Fprivate10 uintptr Fqlen int32 Flast_request_read uint64 Frequest uint64 Fprivate11 TXPointer Fprivate12 TXPointer Fprivate13 TXPointer Fprivate14 TXPointer Fmax_request_size uint32 Fdb uintptr Fprivate15 uintptr Fdisplay_name uintptr Fdefault_screen int32 Fnscreens int32 Fscreens uintptr Fmotion_buffer uint64 Fprivate16 uint64 Fmin_keycode int32 Fmax_keycode int32 Fprivate17 TXPointer Fprivate18 TXPointer Fprivate19 int32 Fxdefaults uintptr })(unsafe.Pointer((*TTk_FakeWin)(unsafe.Pointer(*(*TTk_Window)(unsafe.Pointer(bp + 232)))).Fdisplay)).Fscreens + uintptr((*TTk_FakeWin)(unsafe.Pointer(*(*TTk_Window)(unsafe.Pointer(bp + 232)))).FscreenNum)*128)).Froot } (*(*TXAnyEvent)(unsafe.Pointer(&*(*TXEvent)(unsafe.Pointer(bp))))).Fdisplay = (*TTk_FakeWin)(unsafe.Pointer(*(*TTk_Window)(unsafe.Pointer(bp + 232)))).Fdisplay flags = libc.Uint32FromInt32(_flagArray[(*(*TXAnyEvent)(unsafe.Pointer(&*(*TXEvent)(unsafe.Pointer(bp))))).Ftype1]) if flags&libc.Uint32FromInt32(libc.Int32FromInt32(1)< -xyz" will return the error message that * "-xyz" is a bad option, rather than that the value for "-xyz" * is missing. */ libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+3180, libc.VaList(bp+288, libtcl9_0.XTcl_GetStringFromObj(tls, optionPtr, libc.UintptrFromInt32(0))))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+288, __ccgo_ts+179, __ccgo_ts+3115, __ccgo_ts+3203, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) } switch *(*int32)(unsafe.Pointer(bp + 260)) { case 23: if libtcl9_0.XTcl_GetBoolFromObj(tls, interp, valuePtr, (libc.Int32FromInt32(TCL_NULL_OK)-libc.Int32FromInt32(2))&libc.Int32FromInt64(4), bp+252) != TCL_OK { return int32(TCL_ERROR) } if !(flags&libc.Uint32FromInt32(libc.Int32FromInt32(1)<= int32(Button4) { *(*int32)(unsafe.Pointer(bp + 256)) += libc.Int32FromInt32(Button8) - libc.Int32FromInt32(Button4) } (*(*TXButtonEvent)(unsafe.Pointer(&*(*TXEvent)(unsafe.Pointer(bp))))).Fbutton = libc.Uint32FromInt32(*(*int32)(unsafe.Pointer(bp + 256))) } else { badOpt = int32(1) } case 4: if libtcl9_0.XTcl_GetIntFromObj(tls, interp, valuePtr, bp+256) != TCL_OK { return int32(TCL_ERROR) } if flags&libc.Uint32FromInt32(libc.Int32FromInt32(1)<warpWindow * is NULL) is run directly here. */ if !((*TTkDisplay)(unsafe.Pointer(dispPtr1)).FwarpWindow != 0) { XTkpWarpPointer(tls, dispPtr1) libx11.XXForceScreenSaver(tls, (*TTkDisplay)(unsafe.Pointer(dispPtr1)).Fdisplay, ScreenSaverReset) } } /* * Now we have constructed the event, inject it into the event handling * code. */ if synch != 0 { XTk_HandleEvent(tls, bp) } else { XTk_QueueWindowEvent(tls, bp, pos) } } libtcl9_0.XTcl_ResetResult(tls, interp) return TCL_OK } var _fieldStrings = [29]uintptr{ 0: __ccgo_ts + 2801, 1: __ccgo_ts + 2807, 2: __ccgo_ts + 2814, 3: __ccgo_ts + 2827, 4: __ccgo_ts + 2835, 5: __ccgo_ts + 2842, 6: __ccgo_ts + 2848, 7: __ccgo_ts + 2855, 8: __ccgo_ts + 2863, 9: __ccgo_ts + 2870, 10: __ccgo_ts + 2878, 11: __ccgo_ts + 2887, 12: __ccgo_ts + 2895, 13: __ccgo_ts + 2901, 14: __ccgo_ts + 2911, 15: __ccgo_ts + 2918, 16: __ccgo_ts + 2924, 17: __ccgo_ts + 2931, 18: __ccgo_ts + 2938, 19: __ccgo_ts + 2949, 20: __ccgo_ts + 2957, 21: __ccgo_ts + 2964, 22: __ccgo_ts + 2975, 23: __ccgo_ts + 2981, 24: __ccgo_ts + 2987, 25: __ccgo_ts + 2994, 26: __ccgo_ts + 3002, 27: __ccgo_ts + 3005, 28: libc.UintptrFromInt32(0), } /* *--------------------------------------------------------------------------- * * NameToWindow -- * * Helper function for lookup of a window given its path name. Our * version is able to handle window id's. * * Results: * None. * * Side effects: * None. * *--------------------------------------------------------------------------- */ func _NameToWindow(tls *libc.TLS, interp uintptr, mainWin TTk_Window, objPtr uintptr, tkwinPtr uintptr) (r int32) { bp := tls.Alloc(64) defer tls.Free(64) /* Filled with token for window. */ var name uintptr var tkwin, v1 TTk_Window var _ /* id at bp+0 */ TWindow _, _, _ = name, tkwin, v1 name = libtcl9_0.XTcl_GetStringFromObj(tls, objPtr, libc.UintptrFromInt32(0)) if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(name))) == int32('.') { v1 = XTk_NameToWindow(tls, interp, name, mainWin) tkwin = v1 if !(v1 != 0) { return 0 } } else { tkwin = libc.UintptrFromInt32(0) /* * Check for the winPtr being valid, even if it looks okay to * TkpScanWindowId. [Bug #411307] */ if XTkpScanWindowId(tls, libc.UintptrFromInt32(0), name, bp) == TCL_OK { tkwin = XTk_IdToWindow(tls, (*TTk_FakeWin)(unsafe.Pointer(mainWin)).Fdisplay, *(*TWindow)(unsafe.Pointer(bp))) } if !(tkwin != 0) { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+3334, libc.VaList(bp+16, name))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+16, __ccgo_ts+179, __ccgo_ts+3058, __ccgo_ts+3366, name, libc.UintptrFromInt32(0))) return 0 } } *(*TTk_Window)(unsafe.Pointer(tkwinPtr)) = tkwin return int32(1) } /* *------------------------------------------------------------------------- * * TkDoWarpWrtWin -- * * Perform warping of mouse pointer with respect to a window. * * Results: * None * * Side effects: * Mouse pointer moves to a new location. * *------------------------------------------------------------------------- */ func XTkDoWarpWrtWin(tls *libc.TLS, dispPtr uintptr) { /* * A NULL warpWindow means warping with respect to the whole screen. * We want to warp here only if we're warping with respect to a window. */ if (*TTkDisplay)(unsafe.Pointer(dispPtr)).FwarpWindow != 0 { /* * Warping with respect to a window can only be done if the window is * mapped. This was checked in HandleEvent. The window needs to be * still mapped at the time the present code is executed. Also * one needs to guard against window destruction in the meantime, * which could have happened as a side effect of an event handler. */ if (*TTk_FakeWin)(unsafe.Pointer((*TTkDisplay)(unsafe.Pointer(dispPtr)).FwarpWindow)).Fflags&uint32(TK_MAPPED) != 0 && (*TTk_FakeWin)(unsafe.Pointer((*TTkDisplay)(unsafe.Pointer(dispPtr)).FwarpWindow)).Fwindow != uint64(0) { XTkpWarpPointer(tls, dispPtr) libx11.XXForceScreenSaver(tls, (*TTkDisplay)(unsafe.Pointer(dispPtr)).Fdisplay, ScreenSaverReset) } libtcl9_0.XTcl_Release(tls, (*TTkDisplay)(unsafe.Pointer(dispPtr)).FwarpWindow) (*TTkDisplay)(unsafe.Pointer(dispPtr)).FwarpWindow = libc.UintptrFromInt32(0) } } /* *------------------------------------------------------------------------- * * GetVirtualEventUid -- * * Determine if the given string is in the proper format for a virtual * event. * * Results: * The return value is NULL if the virtual event string was not in the * proper format. In this case, an error message will be left in the * interp's result. Otherwise the return value is a Tk_Uid that * represents the virtual event. * * Side effects: * None. * *------------------------------------------------------------------------- */ func _GetVirtualEventUid(tls *libc.TLS, interp uintptr, virtString uintptr) (r TTk_Uid) { bp := tls.Alloc(48) defer tls.Free(48) var length Tsize_t var uid TTk_Uid _, _ = length, uid length = libc.Xstrlen(tls, virtString) if length < uint64(5) || libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(virtString))) != int32('<') || libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(virtString + 1))) != int32('<') || libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(virtString + uintptr(length-uint64(2))))) != int32('>') || libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(virtString + uintptr(length-uint64(1))))) != int32('>') { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+3376, libc.VaList(bp+8, virtString))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+8, __ccgo_ts+179, __ccgo_ts+3115, __ccgo_ts+3411, __ccgo_ts+3419, libc.UintptrFromInt32(0))) return libc.UintptrFromInt32(0) } *(*uint8)(unsafe.Pointer(virtString + uintptr(length-uint64(2)))) = uint8('\000') uid = XTk_GetUid(tls, virtString+uintptr(2)) *(*uint8)(unsafe.Pointer(virtString + uintptr(length-uint64(2)))) = uint8('>') return uid } /* *---------------------------------------------------------------------- * * FindSequence -- * * Find the entry in the pattern table that corresponds to a particular * pattern string, and return a pointer to that entry. * * Results: * The return value is normally a pointer to the PatSeq in patternTable * that corresponds to eventString. If an error was found while parsing * eventString, or if "create" is 0 and no pattern sequence previously * existed, then NULL is returned and the interp's result contains a * message describing the problem. If no pattern sequence previously * existed for eventString, then a new one is created with a NULL command * field. In a successful return, *maskPtr is filled in with a mask of * the event types on which the pattern sequence depends. * * Side effects: * A new pattern sequence may be allocated. * *---------------------------------------------------------------------- */ func _FindSequence(tls *libc.TLS, interp uintptr, lookupTables uintptr, object uintptr, eventString uintptr, create int32, allowVirtual int32, maskPtr uintptr) (r uintptr) { bp := tls.Alloc(96) defer tls.Free(96) /* *maskPtr is filled in with the event types on which this * pattern sequence depends. */ var count, maxCount, modMask, numPats, patsBufSize, pos, sequenceSize, totalCount, v3, v5 uint32 var hPtr, patPtr, psPtr, psPtr2, v2, v6 uintptr var virtualFound int32 var _ /* eventMask at bp+12 */ uint32 var _ /* isNew at bp+8 */ int32 var _ /* key at bp+16 */ TPatternTableKey var _ /* p at bp+0 */ uintptr _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = count, hPtr, maxCount, modMask, numPats, patPtr, patsBufSize, pos, psPtr, psPtr2, sequenceSize, totalCount, virtualFound, v2, v3, v5, v6 patsBufSize = uint32(1) totalCount = uint32(0) virtualFound = 0 *(*uintptr)(unsafe.Pointer(bp)) = eventString maxCount = uint32(0) *(*uint32)(unsafe.Pointer(bp + 12)) = uint32(0) modMask = uint32(0) psPtr = libtcl9_0.XTcl_Alloc(tls, libc.Uint64FromInt64(88)+uint64(patsBufSize-libc.Uint32FromInt32(1))*libc.Uint64FromInt64(32)) /* *------------------------------------------------------------------ * Step 1: parse the pattern string to produce an array of Patterns. *------------------------------------------------------------------ */ patPtr = psPtr + 56 numPats = libc.Uint32FromInt32(0) for { v2 = _SkipSpaces(tls, *(*uintptr)(unsafe.Pointer(bp))) *(*uintptr)(unsafe.Pointer(bp)) = v2 if !(*(*uint8)(unsafe.Pointer(v2)) != 0) { break } if numPats >= patsBufSize { pos = libc.Uint32FromInt64((int64(patPtr) - T__predefined_ptrdiff_t(psPtr+56)) / 32) patsBufSize += patsBufSize psPtr = libtcl9_0.XTcl_Realloc(tls, psPtr, libc.Uint64FromInt64(88)+uint64(patsBufSize-libc.Uint32FromInt32(1))*libc.Uint64FromInt64(32)) patPtr = psPtr + 56 + uintptr(pos)*32 } v3 = _ParseEventDescription(tls, interp, bp, patPtr, bp+12) count = v3 if v3 == uint32(0) { /* error encountered */ libtcl9_0.XTcl_Free(tls, psPtr) return libc.UintptrFromInt32(0) } if libc.Int64FromUint32(*(*uint32)(unsafe.Pointer(bp + 12)))&(libc.Int64FromInt64(1)< uint32(1) { maxCount = libc.Uint32FromInt64(_Max(tls, libc.Int64FromUint32(count), libc.Int64FromUint32(maxCount))) } totalCount += count modMask |= (*TTkPattern)(unsafe.Pointer(patPtr)).FmodMask goto _1 _1: ; patPtr += 32 numPats++ } /* *------------------------------------------------------------------ * Step 2: find the sequence in the binding table if it exists, and * add a new sequence to the table if it doesn't. *------------------------------------------------------------------ */ if numPats == uint32(0) { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+3500, int64(-libc.Int32FromInt32(1)))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+48, __ccgo_ts+179, __ccgo_ts+3115, __ccgo_ts+3531, libc.UintptrFromInt32(0))) libtcl9_0.XTcl_Free(tls, psPtr) return libc.UintptrFromInt32(0) } if numPats > uint32(1) && virtualFound != 0 { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+3541, int64(-libc.Int32FromInt32(1)))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+48, __ccgo_ts+179, __ccgo_ts+3115, __ccgo_ts+3411, __ccgo_ts+3576, libc.UintptrFromInt32(0))) libtcl9_0.XTcl_Free(tls, psPtr) return libc.UintptrFromInt32(0) } if patsBufSize > numPats { psPtr = libtcl9_0.XTcl_Realloc(tls, psPtr, libc.Uint64FromInt64(88)+uint64(numPats-libc.Uint32FromInt32(1))*libc.Uint64FromInt64(32)) } patPtr = psPtr + 56 (*TPatSeq)(unsafe.Pointer(psPtr)).Fobject = object _SetupPatternKey(tls, bp+16, psPtr) hPtr = (*(*func(*libc.TLS, uintptr, uintptr, uintptr) uintptr)(unsafe.Pointer(&struct{ uintptr }{(*TTcl_HashTable)(unsafe.Pointer(lookupTables)).FcreateProc})))(tls, lookupTables, bp+16, bp+8) if !(*(*int32)(unsafe.Pointer(bp + 8)) != 0) { sequenceSize = uint32(uint64(numPats) * uint64(32)) psPtr2 = (*TTcl_HashEntry)(unsafe.Pointer(hPtr)).FclientData for { if !(psPtr2 != 0) { break } if numPats == (*TPatSeq)(unsafe.Pointer(psPtr2)).FnumPats && libc.Xmemcmp(tls, patPtr, psPtr2+56, uint64(sequenceSize)) == 0 { libtcl9_0.XTcl_Free(tls, psPtr) if maskPtr != 0 { *(*uint32)(unsafe.Pointer(maskPtr)) = *(*uint32)(unsafe.Pointer(bp + 12)) } return psPtr2 } goto _4 _4: ; psPtr2 = (*TPatSeq)(unsafe.Pointer(psPtr2)).FnextSeqPtr } } if !(create != 0) { if *(*int32)(unsafe.Pointer(bp + 8)) != 0 { libtcl9_0.XTcl_DeleteHashEntry(tls, hPtr) } /* * No binding exists for the sequence, so return an empty error. This * is a special error that the caller will check for in order to * silently ignore this case. This is a hack that maintains backward * compatibility for Tk_GetBinding but the various "bind" commands * silently ignore missing bindings. */ libtcl9_0.XTcl_Free(tls, psPtr) return libc.UintptrFromInt32(0) } (*TPatSeq)(unsafe.Pointer(psPtr)).FnumPats = numPats (*TPatSeq)(unsafe.Pointer(psPtr)).Fcount = totalCount v6 = lookupTables + 224 v5 = *(*uint32)(unsafe.Pointer(v6)) *(*uint32)(unsafe.Pointer(v6))++ (*TPatSeq)(unsafe.Pointer(psPtr)).Fnumber = v5 libc.SetBitFieldPtr8Uint32(psPtr+12, libc.Uint32FromInt32(0), 0, 0x1) libc.SetBitFieldPtr8Uint32(psPtr+12, libc.BoolUint32(modMask != libc.Uint32FromInt32(0)), 1, 0x2) (*TPatSeq)(unsafe.Pointer(psPtr)).Fscript = libc.UintptrFromInt32(0) (*TPatSeq)(unsafe.Pointer(psPtr)).FnextSeqPtr = (*TTcl_HashEntry)(unsafe.Pointer(hPtr)).FclientData (*TPatSeq)(unsafe.Pointer(psPtr)).FhPtr = hPtr *(*uintptr)(unsafe.Pointer(psPtr + 48)) = libc.UintptrFromInt32(0) (*TTcl_HashEntry)(unsafe.Pointer(hPtr)).FclientData = psPtr if maskPtr != 0 { *(*uint32)(unsafe.Pointer(maskPtr)) = *(*uint32)(unsafe.Pointer(bp + 12)) } return psPtr } /* *--------------------------------------------------------------------------- * * ParseEventDescription -- * * Fill Pattern buffer with information about event from event string. * * Results: * Leaves error message in interp and returns 0 if there was an error due * to a badly formed event string. Returns 1 if proper event was * specified, 2 if Double modifier was used in event string, or 3 if * Triple was used. * * Side effects: * On exit, eventStringPtr points to rest of event string (after the * closing '>', so that this function can be called repeatedly to parse * all the events in the entire sequence. * *--------------------------------------------------------------------------- */ // C documentation // // /* helper function */ func _FinalizeParseEventDescription(tls *libc.TLS, interp uintptr, patPtr uintptr, count uint32, errorObj uintptr, errCode uintptr) (r uint32) { bp := tls.Alloc(48) defer tls.Free(48) if errorObj != 0 { libtcl9_0.XTcl_SetObjResult(tls, interp, errorObj) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+8, __ccgo_ts+179, __ccgo_ts+3115, errCode, libc.UintptrFromInt32(0))) } (*TTkPattern)(unsafe.Pointer(patPtr)).Fcount = count return count } func _ParseEventDescription(tls *libc.TLS, interp uintptr, eventStringPtr uintptr, patPtr uintptr, eventMaskPtr uintptr) (r uint32) { bp := tls.Alloc(800) defer tls.Free(800) /* Filled with event mask of matched event. */ var bufPtr, eiPtr, field, hPtr, modPtr, p, v1, v2 uintptr var button, count, eventFlags, eventMask, i, size, v3 uint32 var _ /* buf at bp+2 */ [256]uint8 var _ /* field at bp+258 */ [512]uint8 var _ /* string at bp+0 */ [2]uint8 _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = bufPtr, button, count, eiPtr, eventFlags, eventMask, field, hPtr, i, modPtr, p, size, v1, v2, v3 eventMask = uint32(0) count = uint32(1) p = *(*uintptr)(unsafe.Pointer(eventStringPtr)) libc.Xmemset(tls, patPtr, 0, uint64(32)) /* Otherwise memcmp doesn't work. */ /* * Handle simple ASCII characters. */ if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(p))) != int32('<') { (*TTkPattern)(unsafe.Pointer(patPtr)).FeventType = uint32(KeyPress) eventMask = libc.Uint32FromInt64(libc.Int64FromInt64(1) << libc.Int32FromInt32(0)) (*(*[2]uint8)(unsafe.Pointer(bp)))[0] = *(*uint8)(unsafe.Pointer(p)) (*(*[2]uint8)(unsafe.Pointer(bp)))[int32(1)] = uint8('\000') (*TTkPattern)(unsafe.Pointer(patPtr)).Finfo = XTkStringToKeysym(tls, bp) if (*TTkPattern)(unsafe.Pointer(patPtr)).Finfo == uint64(0) { if !(libc.BoolInt32(uint32(*(*uint8)(unsafe.Pointer(p)))-libc.Uint32FromInt32(0x20) < libc.Uint32FromInt32(0x5f)) != 0) { return _FinalizeParseEventDescription(tls, interp, patPtr, uint32(0), libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+3588, libc.VaList(bp+784, libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(p))))), __ccgo_ts+3613) } (*TTkPattern)(unsafe.Pointer(patPtr)).Finfo = uint64(*(*uint8)(unsafe.Pointer(p))) } p++ } else { /* * A fancier event description. This can be either a virtual event or a physical event. * * A virtual event description consists of: * * 1. double open angle brackets. * 2. virtual event name. * 3. double close angle brackets. * * A physical event description consists of: * * 1. open angle bracket. * 2. any number of modifiers, each followed by spaces or dashes. * 3. an optional event name. * 4. an option button or keysym name. Either this or item 3 *must* be present; if both * are present then they are separated by spaces or dashes. * 5. a close angle bracket. */ p++ if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(p))) == int32('<') { /* * This is a virtual event: soak up all the characters up to the next '>'. */ field = p + uintptr(1) bufPtr = bp + 2 p = libc.Xstrchr(tls, field, int32('>')) if p == field { return _FinalizeParseEventDescription(tls, interp, patPtr, uint32(0), libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+3622, int64(-libc.Int32FromInt32(1))), __ccgo_ts+3419) } if !(p != 0) || libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(p + 1))) != int32('>') { return _FinalizeParseEventDescription(tls, interp, patPtr, uint32(0), libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+3659, int64(-libc.Int32FromInt32(1))), __ccgo_ts+3419) } size = libc.Uint32FromInt64(int64(p) - int64(field)) if uint64(size) >= uint64(256) { bufPtr = libtcl9_0.XTcl_Alloc(tls, uint64(size+uint32(1))) } libc.Xstrncpy(tls, bufPtr, field, uint64(size)) *(*uint8)(unsafe.Pointer(bufPtr + uintptr(size))) = uint8('\000') eventMask = libc.Uint32FromInt64(libc.Int64FromInt64(1) << libc.Int32FromInt32(30)) (*TTkPattern)(unsafe.Pointer(patPtr)).FeventType = libc.Uint32FromInt32(libc.Int32FromInt32(MappingNotify) + libc.Int32FromInt32(1)) (*TTkPattern)(unsafe.Pointer(patPtr)).Fname = XTk_GetUid(tls, bufPtr) if bufPtr != bp+2 { libtcl9_0.XTcl_Free(tls, bufPtr) } p += uintptr(2) } else { for int32(1) != 0 { p = _GetField(tls, p, bp+258, uint32(512)) if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(p))) == int32('>') { /* * This solves the problem of, e.g., being * misinterpreted as Control + Meta + missing keysym instead of * Control + KeyPress + M. */ break } v1 = (*(*func(*libc.TLS, uintptr, uintptr) uintptr)(unsafe.Pointer(&struct{ uintptr }{(*TTcl_HashTable)(unsafe.Pointer(uintptr(unsafe.Pointer(&_modTable)))).FfindProc})))(tls, uintptr(unsafe.Pointer(&_modTable)), bp+258) hPtr = v1 if !(v1 != 0) { break } modPtr = (*TTcl_HashEntry)(unsafe.Pointer(hPtr)).FclientData *(*uint32)(unsafe.Pointer(patPtr + 8)) |= (*TModInfo)(unsafe.Pointer(modPtr)).Fmask if (*TModInfo)(unsafe.Pointer(modPtr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(1)<>= uint32(1) if !(i != 0) { break } count++ } } p = _SkipFieldDelims(tls, p) } eventFlags = uint32(0) v2 = (*(*func(*libc.TLS, uintptr, uintptr) uintptr)(unsafe.Pointer(&struct{ uintptr }{(*TTcl_HashTable)(unsafe.Pointer(uintptr(unsafe.Pointer(&_eventTable)))).FfindProc})))(tls, uintptr(unsafe.Pointer(&_eventTable)), bp+258) hPtr = v2 if v2 != 0 { eiPtr = (*TTcl_HashEntry)(unsafe.Pointer(hPtr)).FclientData (*TTkPattern)(unsafe.Pointer(patPtr)).FeventType = (*TEventInfo)(unsafe.Pointer(eiPtr)).Ftype1 eventFlags = libc.Uint32FromInt32(_flagArray[(*TEventInfo)(unsafe.Pointer(eiPtr)).Ftype1]) eventMask = (*TEventInfo)(unsafe.Pointer(eiPtr)).FeventMask p = _GetField(tls, _SkipFieldDelims(tls, p), bp+258, uint32(512)) } if *(*uint8)(unsafe.Pointer(bp + 258)) != 0 { button = _GetButtonNumber(tls, bp+258) if eventFlags&libc.Uint32FromInt32(libc.Int32FromInt32(1)<') { p = _SkipFieldDelims(tls, _GetField(tls, p, bp+258, uint32(512))) v3 = _GetButtonNumber(tls, bp+258) button = v3 if v3 == uint32(0) { return _FinalizeParseEventDescription(tls, interp, patPtr, uint32(0), libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+3690, libc.VaList(bp+784, bp+258)), __ccgo_ts+3713) } *(*uint32)(unsafe.Pointer(patPtr + 8)) |= XTk_GetButtonMask(tls, button) } (*TTkPattern)(unsafe.Pointer(patPtr)).Finfo = libc.Uint64FromInt32(_ButtonNumberFromState(tls, (*TTkPattern)(unsafe.Pointer(patPtr)).FmodMask)) } else { return _FinalizeParseEventDescription(tls, interp, patPtr, uint32(0), libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+3804, libc.VaList(bp+784, bp+258)), __ccgo_ts+3844) } } } } else { if eventFlags == uint32(0) { return _FinalizeParseEventDescription(tls, interp, patPtr, uint32(0), libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+3852, int64(-libc.Int32FromInt32(1))), __ccgo_ts+3888) } else { if (*TTkPattern)(unsafe.Pointer(patPtr)).FeventType == uint32(MotionNotify) { (*TTkPattern)(unsafe.Pointer(patPtr)).Finfo = libc.Uint64FromInt32(_ButtonNumberFromState(tls, (*TTkPattern)(unsafe.Pointer(patPtr)).FmodMask)) } } } p = _SkipFieldDelims(tls, p) if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(p))) != int32('>') { for *(*uint8)(unsafe.Pointer(p)) != 0 { p++ if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(p))) == int32('>') { return _FinalizeParseEventDescription(tls, interp, patPtr, uint32(0), libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+3901, int64(-libc.Int32FromInt32(1))), __ccgo_ts+3942) } } return _FinalizeParseEventDescription(tls, interp, patPtr, uint32(0), libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+3954, int64(-libc.Int32FromInt32(1))), __ccgo_ts+3419) } p++ } } *(*uintptr)(unsafe.Pointer(eventStringPtr)) = p *(*uint32)(unsafe.Pointer(eventMaskPtr)) |= eventMask return _FinalizeParseEventDescription(tls, interp, patPtr, count, libc.UintptrFromInt32(0), libc.UintptrFromInt32(0)) } /* *---------------------------------------------------------------------- * * GetField -- * * Used to parse pattern descriptions. Copies up to size characters from * p to copy, stopping at end of string, space, "-", ">", or whenever * size is exceeded. * * Results: * The return value is a pointer to the character just after the last one * copied (usually "-" or space or ">", but could be anything if size was * exceeded). Also places NULL-terminated string (up to size character, * including NULL), at copy. * * Side effects: * None. * *---------------------------------------------------------------------- */ func _GetField(tls *libc.TLS, p uintptr, copy1 uintptr, size uint32) (r uintptr) { /* Maximum number of characters to copy. */ var v2, v3 int32 var v5 bool var v6, v7 uintptr _, _, _, _, _ = v2, v3, v5, v6, v7 for { if v5 = *(*uint8)(unsafe.Pointer(p)) != 0; v5 { v2 = libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(p))) v3 = libc.BoolInt32(v2 == int32(' ') || libc.Uint32FromInt32(v2)-uint32('\t') < uint32(5)) goto _4 _4: } if !(v5 && !(v3 != 0) && libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(p))) != int32('>') && libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(p))) != int32('-') && size > uint32(1)) { break } v6 = copy1 copy1++ v7 = p p++ *(*uint8)(unsafe.Pointer(v6)) = *(*uint8)(unsafe.Pointer(v7)) goto _1 _1: ; size-- } *(*uint8)(unsafe.Pointer(copy1)) = uint8('\000') return p } /* *--------------------------------------------------------------------------- * * GetPatternObj -- * * Produce a string version of the given event, for displaying to the * user. * * Results: * The string is returned as a Tcl_Obj. * * Side effects: * It is the caller's responsibility to arrange for the object to be * released; it starts with a refCount of zero. * *--------------------------------------------------------------------------- */ func _GetPatternObj(tls *libc.TLS, psPtr uintptr) (r uintptr) { bp := tls.Alloc(32) defer tls.Free(32) var i, modMask uint32 var modPtr, patPtr, patternObj, string1 uintptr var v3 uint64 var _ /* c at bp+0 */ uint8 _, _, _, _, _, _, _ = i, modMask, modPtr, patPtr, patternObj, string1, v3 patternObj = libtcl9_0.XTcl_NewObj(tls) i = uint32(0) for { if !(i < (*TPatSeq)(unsafe.Pointer(psPtr)).FnumPats) { break } patPtr = psPtr + 56 + uintptr(i)*32 /* * Check for simple case of an ASCII character. */ if (*TTkPattern)(unsafe.Pointer(patPtr)).FeventType == uint32(KeyPress) && (*TTkPattern)(unsafe.Pointer(patPtr)).Fcount == uint32(1) && (*TTkPattern)(unsafe.Pointer(patPtr)).FmodMask == uint32(0) && (*TTkPattern)(unsafe.Pointer(patPtr)).Finfo < uint64(128) && libc.BoolInt32(uint32(uint8((*TTkPattern)(unsafe.Pointer(patPtr)).Finfo))-uint32(0x20) < uint32(0x5f)) != 0 && (*TTkPattern)(unsafe.Pointer(patPtr)).Finfo != uint64('<') && (*TTkPattern)(unsafe.Pointer(patPtr)).Finfo != uint64(' ') { *(*uint8)(unsafe.Pointer(bp)) = uint8((*TTkPattern)(unsafe.Pointer(patPtr)).Finfo) libtcl9_0.XTcl_AppendToObj(tls, patternObj, bp, int64(1)) } else { if (*TTkPattern)(unsafe.Pointer(patPtr)).FeventType == libc.Uint32FromInt32(libc.Int32FromInt32(MappingNotify)+libc.Int32FromInt32(1)) { libtcl9_0.XTcl_AppendPrintfToObj(tls, patternObj, __ccgo_ts+2794, libc.VaList(bp+16, (*TTkPattern)(unsafe.Pointer(patPtr)).Fname)) } else { /* * It's a more general event specification. First check for "Double", * "Triple", "Quadruple", then modifiers, then event type, then keysym * or button detail. */ libtcl9_0.XTcl_AppendToObj(tls, patternObj, __ccgo_ts+3977, int64(1)) switch (*TTkPattern)(unsafe.Pointer(patPtr)).Fcount { case uint32(2): libtcl9_0.XTcl_AppendToObj(tls, patternObj, __ccgo_ts+3979, int64(7)) case uint32(3): libtcl9_0.XTcl_AppendToObj(tls, patternObj, __ccgo_ts+3987, int64(7)) case uint32(4): libtcl9_0.XTcl_AppendToObj(tls, patternObj, __ccgo_ts+3995, int64(10)) break } modMask = (*TTkPattern)(unsafe.Pointer(patPtr)).FmodMask modPtr = uintptr(unsafe.Pointer(&_modArray)) for { if !(modMask != 0) { break } if (*TModInfo)(unsafe.Pointer(modPtr)).Fmask&modMask != 0 { modMask &= ^(*TModInfo)(unsafe.Pointer(modPtr)).Fmask libtcl9_0.XTcl_AppendPrintfToObj(tls, patternObj, __ccgo_ts+4006, libc.VaList(bp+16, (*TModInfo)(unsafe.Pointer(modPtr)).Fname)) } goto _2 _2: ; modPtr += 16 } libtcl9_0.XTcl_AppendToObj(tls, patternObj, _eventArray[_eventArrayIndex[(*TTkPattern)(unsafe.Pointer(patPtr)).FeventType]].Fname, int64(-libc.Int32FromInt32(1))) if (*TTkPattern)(unsafe.Pointer(patPtr)).Finfo != 0 { switch (*TTkPattern)(unsafe.Pointer(patPtr)).FeventType { case uint32(KeyPress): fallthrough case uint32(KeyRelease): string1 = XTkKeysymToString(tls, (*TTkPattern)(unsafe.Pointer(patPtr)).Finfo) if string1 != 0 { libtcl9_0.XTcl_AppendToObj(tls, patternObj, __ccgo_ts+4010, int64(1)) libtcl9_0.XTcl_AppendToObj(tls, patternObj, string1, int64(-libc.Int32FromInt32(1))) } case uint32(ButtonPress): fallthrough case uint32(ButtonRelease): if (*TTkPattern)(unsafe.Pointer(patPtr)).Finfo > uint64(7) { v3 = (*TTkPattern)(unsafe.Pointer(patPtr)).Finfo - uint64(4) } else { v3 = (*TTkPattern)(unsafe.Pointer(patPtr)).Finfo } libtcl9_0.XTcl_AppendPrintfToObj(tls, patternObj, __ccgo_ts+4012, libc.VaList(bp+16, uint32(v3))) break } } libtcl9_0.XTcl_AppendToObj(tls, patternObj, __ccgo_ts+4016, int64(1)) } } goto _1 _1: ; i++ } return patternObj } /* *---------------------------------------------------------------------- * * TkStringToKeysym -- * * This function finds the keysym associated with a given keysym name. * * Results: * The return value is the keysym that corresponds to name, or NoSymbol * if there is no such keysym. * * Side effects: * None. * *---------------------------------------------------------------------- */ func XTkStringToKeysym(tls *libc.TLS, name uintptr) (r TKeySym) { bp := tls.Alloc(16) defer tls.Free(16) /* Name of a keysym. */ var len1 Tsize_t var _ /* keysym at bp+0 */ int32 _ = len1 len1 = libc.Uint64FromInt64(libtcl9_0.XTcl_UtfToUniChar(tls, name, bp)) if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(name + uintptr(len1)))) == int32('\000') { if !(libtcl9_0.XTcl_UniCharIsPrint(tls, *(*int32)(unsafe.Pointer(bp))) != 0) { /* This form not supported */ } else { if libc.Uint32FromInt32(*(*int32)(unsafe.Pointer(bp))-libc.Int32FromInt32(0x21)) <= uint32(0x5D) { return libc.Uint64FromInt32(*(*int32)(unsafe.Pointer(bp))) } else { if libc.Uint32FromInt32(*(*int32)(unsafe.Pointer(bp))-libc.Int32FromInt32(0xA1)) <= uint32(0x5E) { return libc.Uint64FromInt32(*(*int32)(unsafe.Pointer(bp))) } else { if *(*int32)(unsafe.Pointer(bp)) == int32(0x20AC) { return uint64(0x20AC) } else { return libc.Uint64FromInt32(*(*int32)(unsafe.Pointer(bp))) + uint64(0x1000000) } } } } } return libx11.XXStringToKeysym(tls, name) } /* *---------------------------------------------------------------------- * * TkKeysymToString -- * * This function finds the keysym name associated with a given keysym. * * Results: * The return value is a pointer to a static string containing the name * of the given keysym, or NULL if there is no known name. * * Side effects: * None. * *---------------------------------------------------------------------- */ func XTkKeysymToString(tls *libc.TLS, keysym TKeySym) (r uintptr) { bp := tls.Alloc(32) defer tls.Free(32) var _ /* buf at bp+0 */ [10]uint8 if uint32(keysym-libc.Uint64FromInt32(0x21)) <= uint32(0x5D) { keysym += uint64(0x1000000) } else { if uint32(keysym-libc.Uint64FromInt32(0xA1)) <= uint32(0x5E) { keysym += uint64(0x1000000) } else { if keysym == uint64(0x20AC) { keysym += uint64(0x1000000) } } } if keysym >= uint64(0x1000020) && keysym <= uint64(0x110FFFF) && uint32(keysym-libc.Uint64FromInt32(0x100007F)) > uint32(0x20) { if libtcl9_0.XTcl_UniCharIsPrint(tls, libc.Int32FromUint64(keysym-uint64(0x1000000))) != 0 { (*(*[10]uint8)(unsafe.Pointer(bp)))[libtcl9_0.XTcl_UniCharToUtf(tls, libc.Int32FromUint64(keysym-uint64(0x1000000)), bp)] = uint8('\000') } else { if keysym >= uint64(0x1010000) { libc.X__builtin_snprintf(tls, bp, uint64(10), __ccgo_ts+4018, libc.VaList(bp+24, libc.Int32FromUint64(keysym-libc.Uint64FromInt32(0x1000000)))) } else { libc.X__builtin_snprintf(tls, bp, uint64(10), __ccgo_ts+4024, libc.VaList(bp+24, libc.Int32FromUint64(keysym-libc.Uint64FromInt32(0x1000000)))) } } return XTk_GetUid(tls, bp) } return libx11.XXKeysymToString(tls, keysym) } /* *---------------------------------------------------------------------- * * TkpGetBindingXEvent -- * * This function returns the XEvent associated with the currently * executing binding. This function can only be invoked while a binding * is executing. * * Results: * Returns a pointer to the XEvent that caused the current binding code * to be run. * * Side effects: * None. * *---------------------------------------------------------------------- */ func XTkpGetBindingXEvent(tls *libc.TLS, interp uintptr) (r uintptr) { /* Interpreter. */ var bindPtr, winPtr uintptr _, _ = bindPtr, winPtr winPtr = XTk_MainWindow(tls, interp) bindPtr = (*TTkMainInfo)(unsafe.Pointer((*TTkWindow)(unsafe.Pointer(winPtr)).FmainPtr)).FbindingTable return (*TBindingTable)(unsafe.Pointer(bindPtr)).FcurEvent } type TPSEntry1 = struct { F_dl_ struct { Fprev uintptr Fnext uintptr } Fwindow TWindow FpsPtr uintptr FlastModMaskArr uintptr Fcount uint32 F__ccgo44 uint8 } const error_height = 17 const error_width = 17 const gray12_height = 16 const gray12_width = 16 const gray25_height = 16 const gray25_width = 16 const gray50_height = 16 const gray50_width = 16 const gray75_height = 16 const gray75_width = 16 const hourglass_height = 21 const hourglass_width = 19 const info_height = 21 const info_width = 8 const questhead_height = 22 const questhead_width = 20 const question_height = 27 const question_width = 17 const warning_height = 19 const warning_width = 6 /* * Local Variables: * mode: c * c-basic-offset: 4 * fill-column: 78 * End: */ /* * The includes below are for pre-defined bitmaps. * * Platform-specific issue: Windows complains when the bitmaps are included, * because an array of characters is being initialized with integers as * elements. For lint purposes, the following pragmas temporarily turn off * that warning message. */ var _error_bits = [51]uint8{ 0: uint8(0xf0), 1: uint8(0x0f), 3: uint8(0x58), 4: uint8(0x15), 6: uint8(0xac), 7: uint8(0x2a), 9: uint8(0x16), 10: uint8(0x50), 12: uint8(0x2b), 13: uint8(0xa0), 15: uint8(0x55), 16: uint8(0x40), 17: uint8(0x01), 18: uint8(0xa3), 19: uint8(0xc0), 21: uint8(0x45), 22: uint8(0x41), 23: uint8(0x01), 24: uint8(0x83), 25: uint8(0xc2), 27: uint8(0x05), 28: uint8(0x45), 29: uint8(0x01), 30: uint8(0x03), 31: uint8(0xca), 33: uint8(0x05), 34: uint8(0x74), 35: uint8(0x01), 36: uint8(0x0a), 37: uint8(0xa8), 39: uint8(0x14), 40: uint8(0x58), 42: uint8(0xe8), 43: uint8(0x2f), 45: uint8(0x50), 46: uint8(0x15), 48: uint8(0xa0), 49: uint8(0x0a), } var _gray12_bits = [32]uint8{ 2: uint8(0x22), 3: uint8(0x22), 6: uint8(0x88), 7: uint8(0x88), 10: uint8(0x22), 11: uint8(0x22), 14: uint8(0x88), 15: uint8(0x88), 18: uint8(0x22), 19: uint8(0x22), 22: uint8(0x88), 23: uint8(0x88), 26: uint8(0x22), 27: uint8(0x22), 30: uint8(0x88), 31: uint8(0x88), } var _gray25_bits = [32]uint8{ 0: uint8(0x88), 1: uint8(0x88), 2: uint8(0x22), 3: uint8(0x22), 4: uint8(0x88), 5: uint8(0x88), 6: uint8(0x22), 7: uint8(0x22), 8: uint8(0x88), 9: uint8(0x88), 10: uint8(0x22), 11: uint8(0x22), 12: uint8(0x88), 13: uint8(0x88), 14: uint8(0x22), 15: uint8(0x22), 16: uint8(0x88), 17: uint8(0x88), 18: uint8(0x22), 19: uint8(0x22), 20: uint8(0x88), 21: uint8(0x88), 22: uint8(0x22), 23: uint8(0x22), 24: uint8(0x88), 25: uint8(0x88), 26: uint8(0x22), 27: uint8(0x22), 28: uint8(0x88), 29: uint8(0x88), 30: uint8(0x22), 31: uint8(0x22), } var _gray50_bits = [32]uint8{ 0: uint8(0x55), 1: uint8(0x55), 2: uint8(0xaa), 3: uint8(0xaa), 4: uint8(0x55), 5: uint8(0x55), 6: uint8(0xaa), 7: uint8(0xaa), 8: uint8(0x55), 9: uint8(0x55), 10: uint8(0xaa), 11: uint8(0xaa), 12: uint8(0x55), 13: uint8(0x55), 14: uint8(0xaa), 15: uint8(0xaa), 16: uint8(0x55), 17: uint8(0x55), 18: uint8(0xaa), 19: uint8(0xaa), 20: uint8(0x55), 21: uint8(0x55), 22: uint8(0xaa), 23: uint8(0xaa), 24: uint8(0x55), 25: uint8(0x55), 26: uint8(0xaa), 27: uint8(0xaa), 28: uint8(0x55), 29: uint8(0x55), 30: uint8(0xaa), 31: uint8(0xaa), } var _gray75_bits = [32]uint8{ 0: uint8(0x77), 1: uint8(0x77), 2: uint8(0xdd), 3: uint8(0xdd), 4: uint8(0x77), 5: uint8(0x77), 6: uint8(0xdd), 7: uint8(0xdd), 8: uint8(0x77), 9: uint8(0x77), 10: uint8(0xdd), 11: uint8(0xdd), 12: uint8(0x77), 13: uint8(0x77), 14: uint8(0xdd), 15: uint8(0xdd), 16: uint8(0x77), 17: uint8(0x77), 18: uint8(0xdd), 19: uint8(0xdd), 20: uint8(0x77), 21: uint8(0x77), 22: uint8(0xdd), 23: uint8(0xdd), 24: uint8(0x77), 25: uint8(0x77), 26: uint8(0xdd), 27: uint8(0xdd), 28: uint8(0x77), 29: uint8(0x77), 30: uint8(0xdd), 31: uint8(0xdd), } var _hourglass_bits = [63]uint8{ 0: uint8(0xff), 1: uint8(0xff), 2: uint8(0x07), 3: uint8(0x55), 4: uint8(0x55), 5: uint8(0x05), 6: uint8(0xa2), 7: uint8(0x2a), 8: uint8(0x03), 9: uint8(0x66), 10: uint8(0x15), 11: uint8(0x01), 12: uint8(0xa2), 13: uint8(0x2a), 14: uint8(0x03), 15: uint8(0x66), 16: uint8(0x15), 17: uint8(0x01), 18: uint8(0xc2), 19: uint8(0x0a), 20: uint8(0x03), 21: uint8(0x46), 22: uint8(0x05), 23: uint8(0x01), 24: uint8(0x82), 25: uint8(0x0a), 26: uint8(0x03), 27: uint8(0x06), 28: uint8(0x05), 29: uint8(0x01), 30: uint8(0x02), 31: uint8(0x03), 32: uint8(0x03), 33: uint8(0x86), 34: uint8(0x05), 35: uint8(0x01), 36: uint8(0xc2), 37: uint8(0x0a), 38: uint8(0x03), 39: uint8(0x66), 40: uint8(0x15), 41: uint8(0x01), 42: uint8(0xa2), 43: uint8(0x2a), 44: uint8(0x03), 45: uint8(0x66), 46: uint8(0x15), 47: uint8(0x01), 48: uint8(0xa2), 49: uint8(0x2a), 50: uint8(0x03), 51: uint8(0x66), 52: uint8(0x15), 53: uint8(0x01), 54: uint8(0xa2), 55: uint8(0x2a), 56: uint8(0x03), 57: uint8(0xff), 58: uint8(0xff), 59: uint8(0x07), 60: uint8(0xab), 61: uint8(0xaa), 62: uint8(0x02), } var _info_bits = [21]uint8{ 0: uint8(0x3c), 1: uint8(0x2a), 2: uint8(0x16), 3: uint8(0x2a), 4: uint8(0x14), 7: uint8(0x3f), 8: uint8(0x15), 9: uint8(0x2e), 10: uint8(0x14), 11: uint8(0x2c), 12: uint8(0x14), 13: uint8(0x2c), 14: uint8(0x14), 15: uint8(0x2c), 16: uint8(0x14), 17: uint8(0x2c), 18: uint8(0xd7), 19: uint8(0xab), 20: uint8(0x55), } var _questhead_bits = [66]uint8{ 0: uint8(0xf8), 1: uint8(0x1f), 3: uint8(0xac), 4: uint8(0x2a), 6: uint8(0x56), 7: uint8(0x55), 9: uint8(0xeb), 10: uint8(0xaf), 12: uint8(0xf5), 13: uint8(0x5f), 14: uint8(0x01), 15: uint8(0xfb), 16: uint8(0xbf), 18: uint8(0x75), 19: uint8(0x5d), 20: uint8(0x01), 21: uint8(0xfb), 22: uint8(0xbe), 23: uint8(0x02), 24: uint8(0x75), 25: uint8(0x5d), 26: uint8(0x05), 27: uint8(0xab), 28: uint8(0xbe), 29: uint8(0x0a), 30: uint8(0x55), 31: uint8(0x5f), 32: uint8(0x07), 33: uint8(0xab), 34: uint8(0xaf), 36: uint8(0xd6), 37: uint8(0x57), 38: uint8(0x01), 39: uint8(0xac), 40: uint8(0xab), 42: uint8(0xd8), 43: uint8(0x57), 45: uint8(0xb0), 46: uint8(0xaa), 48: uint8(0x50), 49: uint8(0x55), 51: uint8(0xb0), 52: uint8(0x0b), 54: uint8(0xd0), 55: uint8(0x17), 57: uint8(0xb0), 58: uint8(0x0b), 60: uint8(0x58), 61: uint8(0x15), 63: uint8(0xa8), 64: uint8(0x2a), } var _question_bits = [81]uint8{ 0: uint8(0xf0), 1: uint8(0x0f), 3: uint8(0x58), 4: uint8(0x15), 6: uint8(0xac), 7: uint8(0x2a), 9: uint8(0x56), 10: uint8(0x55), 12: uint8(0x2b), 13: uint8(0xa8), 15: uint8(0x15), 16: uint8(0x50), 17: uint8(0x01), 18: uint8(0x0b), 19: uint8(0xa0), 21: uint8(0x05), 22: uint8(0x60), 23: uint8(0x01), 24: uint8(0x0b), 25: uint8(0xa0), 27: uint8(0x05), 28: uint8(0x60), 29: uint8(0x01), 30: uint8(0x0b), 31: uint8(0xb0), 34: uint8(0x58), 35: uint8(0x01), 37: uint8(0xaf), 39: uint8(0x80), 40: uint8(0x55), 42: uint8(0xc0), 43: uint8(0x2a), 45: uint8(0x40), 46: uint8(0x15), 48: uint8(0xc0), 49: uint8(0x02), 51: uint8(0x40), 52: uint8(0x01), 54: uint8(0xc0), 55: uint8(0x02), 57: uint8(0x40), 58: uint8(0x01), 60: uint8(0xc0), 61: uint8(0x02), 66: uint8(0x80), 67: uint8(0x01), 69: uint8(0xc0), 70: uint8(0x02), 72: uint8(0x40), 73: uint8(0x01), 75: uint8(0xc0), 76: uint8(0x02), 79: uint8(0x01), } var _warning_bits = [19]uint8{ 0: uint8(0x0c), 1: uint8(0x16), 2: uint8(0x2b), 3: uint8(0x15), 4: uint8(0x2b), 5: uint8(0x15), 6: uint8(0x2b), 7: uint8(0x16), 8: uint8(0x0a), 9: uint8(0x16), 10: uint8(0x0a), 11: uint8(0x16), 12: uint8(0x0a), 15: uint8(0x1e), 16: uint8(0x0a), 17: uint8(0x16), 18: uint8(0x0a), } /* * One of the following data structures exists for each bitmap that is * currently in use. Each structure is indexed with both "idTable" and * "nameTable". */ type TTkBitmap = struct { Fbitmap TPixmap Fwidth int32 Fheight int32 Fdisplay uintptr FscreenNum int32 FresourceRefCount int32 FobjRefCount int32 FnameHashPtr uintptr FidHashPtr uintptr FnextPtr uintptr } /* * Used in bitmapDataTable, stored in the TkDisplay structure, to map between * in-core data about a bitmap to its TkBitmap structure. */ type TDataKey = struct { Fsource uintptr Fwidth int32 Fheight int32 } type TThreadSpecificData = struct { Finitialized int32 FpredefBitmapTable TTcl_HashTable } var _dataKey TTcl_ThreadDataKey func init() { p := unsafe.Pointer(&XtkBitmapObjType) *(*uintptr)(unsafe.Add(p, 8)) = __ccgo_fp(_FreeBitmapObjProc) *(*uintptr)(unsafe.Add(p, 16)) = __ccgo_fp(_DupBitmapObjProc) } /* *---------------------------------------------------------------------- * * Tk_AllocBitmapFromObj -- * * Given a Tcl_Obj *, map the value to a corresponding Pixmap structure * based on the tkwin given. * * Results: * The return value is the X identifer for the desired bitmap (i.e. a * Pixmap with a single plane), unless string couldn't be parsed * correctly. In this case, None is returned and an error message is left * in the interp's result. The caller should never modify the bitmap that * is returned, and should eventually call Tk_FreeBitmapFromObj when the * bitmap is no longer needed. * * Side effects: * The bitmap is added to an internal database with a reference count. * For each call to this function, there should eventually be a call to * Tk_FreeBitmapFromObj, so that the database can be cleaned up when * bitmaps aren't needed anymore. * *---------------------------------------------------------------------- */ func XTk_AllocBitmapFromObj(tls *libc.TLS, interp uintptr, tkwin TTk_Window, objPtr uintptr) (r TPixmap) { /* Object describing bitmap; see manual entry * for legal syntax of string value. */ var bitmapPtr, firstBitmapPtr uintptr _, _ = bitmapPtr, firstBitmapPtr if (*TTcl_Obj)(unsafe.Pointer(objPtr)).FtypePtr != uintptr(unsafe.Pointer(&XtkBitmapObjType)) { _InitBitmapObj(tls, objPtr) } bitmapPtr = (*(*struct { Fptr1 uintptr Fptr2 uintptr })(unsafe.Pointer(objPtr + 32))).Fptr1 /* * If the object currently points to a TkBitmap, see if it's the one we * want. If so, increment its reference count and return. */ if bitmapPtr != libc.UintptrFromInt32(0) { if (*TTkBitmap)(unsafe.Pointer(bitmapPtr)).FresourceRefCount == 0 { /* * This is a stale reference: it refers to a TkBitmap that's no * longer in use. Clear the reference. */ _FreeBitmapObj(tls, objPtr) bitmapPtr = libc.UintptrFromInt32(0) } else { if (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fdisplay == (*TTkBitmap)(unsafe.Pointer(bitmapPtr)).Fdisplay && (*TTk_FakeWin)(unsafe.Pointer(tkwin)).FscreenNum == (*TTkBitmap)(unsafe.Pointer(bitmapPtr)).FscreenNum { (*TTkBitmap)(unsafe.Pointer(bitmapPtr)).FresourceRefCount++ return (*TTkBitmap)(unsafe.Pointer(bitmapPtr)).Fbitmap } } } /* * The object didn't point to the TkBitmap that we wanted. Search the list * of TkBitmaps with the same name to see if one of the others is the * right one. */ if bitmapPtr != libc.UintptrFromInt32(0) { firstBitmapPtr = (*TTcl_HashEntry)(unsafe.Pointer((*TTkBitmap)(unsafe.Pointer(bitmapPtr)).FnameHashPtr)).FclientData _FreeBitmapObj(tls, objPtr) bitmapPtr = firstBitmapPtr for { if !(bitmapPtr != libc.UintptrFromInt32(0)) { break } if (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fdisplay == (*TTkBitmap)(unsafe.Pointer(bitmapPtr)).Fdisplay && (*TTk_FakeWin)(unsafe.Pointer(tkwin)).FscreenNum == (*TTkBitmap)(unsafe.Pointer(bitmapPtr)).FscreenNum { (*TTkBitmap)(unsafe.Pointer(bitmapPtr)).FresourceRefCount++ (*TTkBitmap)(unsafe.Pointer(bitmapPtr)).FobjRefCount++ (*(*struct { Fptr1 uintptr Fptr2 uintptr })(unsafe.Pointer(objPtr + 32))).Fptr1 = bitmapPtr return (*TTkBitmap)(unsafe.Pointer(bitmapPtr)).Fbitmap } goto _1 _1: ; bitmapPtr = (*TTkBitmap)(unsafe.Pointer(bitmapPtr)).FnextPtr } } /* * Still no luck. Call GetBitmap to allocate a new TkBitmap object. */ bitmapPtr = _GetBitmap(tls, interp, tkwin, libtcl9_0.XTcl_GetStringFromObj(tls, objPtr, libc.UintptrFromInt32(0))) (*(*struct { Fptr1 uintptr Fptr2 uintptr })(unsafe.Pointer(objPtr + 32))).Fptr1 = bitmapPtr if bitmapPtr == libc.UintptrFromInt32(0) { return uint64(0) } (*TTkBitmap)(unsafe.Pointer(bitmapPtr)).FobjRefCount++ return (*TTkBitmap)(unsafe.Pointer(bitmapPtr)).Fbitmap } /* *---------------------------------------------------------------------- * * Tk_GetBitmap -- * * Given a string describing a bitmap, locate (or create if necessary) a * bitmap that fits the description. * * Results: * The return value is the X identifer for the desired bitmap (i.e. a * Pixmap with a single plane), unless string couldn't be parsed * correctly. In this case, None is returned and an error message is left * in the interp's result. The caller should never modify the bitmap that * is returned, and should eventually call Tk_FreeBitmap when the bitmap * is no longer needed. * * Side effects: * The bitmap is added to an internal database with a reference count. * For each call to this function, there should eventually be a call to * Tk_FreeBitmap, so that the database can be cleaned up when bitmaps * aren't needed anymore. * *---------------------------------------------------------------------- */ func XTk_GetBitmap(tls *libc.TLS, interp uintptr, tkwin TTk_Window, string1 uintptr) (r TPixmap) { /* Description of bitmap. See manual entry for * details on legal syntax. */ var bitmapPtr uintptr _ = bitmapPtr bitmapPtr = _GetBitmap(tls, interp, tkwin, string1) if bitmapPtr == libc.UintptrFromInt32(0) { return uint64(0) } return (*TTkBitmap)(unsafe.Pointer(bitmapPtr)).Fbitmap } /* *---------------------------------------------------------------------- * * GetBitmap -- * * Given a string describing a bitmap, locate (or create if necessary) a * bitmap that fits the description. This routine returns the internal * data structure for the bitmap. This avoids extra hash table lookups in * Tk_AllocBitmapFromObj. * * Results: * The return value is the X identifer for the desired bitmap (i.e. a * Pixmap with a single plane), unless string couldn't be parsed * correctly. In this case, None is returned and an error message is left * in the interp's result. The caller should never modify the bitmap that * is returned, and should eventually call Tk_FreeBitmap when the bitmap * is no longer needed. * * Side effects: * The bitmap is added to an internal database with a reference count. * For each call to this function, there should eventually be a call to * Tk_FreeBitmap or Tk_FreeBitmapFromObj, so that the database can be * cleaned up when bitmaps aren't needed anymore. * *---------------------------------------------------------------------- */ func _GetBitmap(tls *libc.TLS, interp uintptr, tkwin TTk_Window, string1 uintptr) (r uintptr) { bp := tls.Alloc(304) defer tls.Free(304) /* Description of bitmap. See manual entry for * details on legal syntax. */ var bitmapPtr, dispPtr, existingBitmapPtr, nameHashPtr, predefHashPtr, predefPtr, tsdPtr uintptr var result int32 var _ /* bitmap at bp+0 */ TPixmap var _ /* buffer at bp+24 */ TTcl_DString var _ /* dummy2 at bp+20 */ int32 var _ /* height at bp+16 */ int32 var _ /* isNew at bp+8 */ int32 var _ /* width at bp+12 */ int32 _, _, _, _, _, _, _, _ = bitmapPtr, dispPtr, existingBitmapPtr, nameHashPtr, predefHashPtr, predefPtr, result, tsdPtr *(*int32)(unsafe.Pointer(bp + 12)) = 0 *(*int32)(unsafe.Pointer(bp + 16)) = 0 dispPtr = (*TTkWindow)(unsafe.Pointer(tkwin)).FdispPtr tsdPtr = libtcl9_0.XTcl_GetThreadData(tls, uintptr(unsafe.Pointer(&_dataKey)), int64(112)) if !((*TTkDisplay)(unsafe.Pointer(dispPtr)).FbitmapInit != 0) { _BitmapInit(tls, dispPtr) } nameHashPtr = (*(*func(*libc.TLS, uintptr, uintptr, uintptr) uintptr)(unsafe.Pointer(&struct{ uintptr }{(*TTcl_HashTable)(unsafe.Pointer(dispPtr + 408)).FcreateProc})))(tls, dispPtr+408, string1, bp+8) if !(*(*int32)(unsafe.Pointer(bp + 8)) != 0) { existingBitmapPtr = (*TTcl_HashEntry)(unsafe.Pointer(nameHashPtr)).FclientData bitmapPtr = existingBitmapPtr for { if !(bitmapPtr != libc.UintptrFromInt32(0)) { break } if (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fdisplay == (*TTkBitmap)(unsafe.Pointer(bitmapPtr)).Fdisplay && (*TTk_FakeWin)(unsafe.Pointer(tkwin)).FscreenNum == (*TTkBitmap)(unsafe.Pointer(bitmapPtr)).FscreenNum { (*TTkBitmap)(unsafe.Pointer(bitmapPtr)).FresourceRefCount++ return bitmapPtr } goto _1 _1: ; bitmapPtr = (*TTkBitmap)(unsafe.Pointer(bitmapPtr)).FnextPtr } } else { existingBitmapPtr = libc.UintptrFromInt32(0) } /* * No suitable bitmap exists. Create a new bitmap from the information * contained in the string. If the string starts with "@" then the rest of * the string is a file name containing the bitmap. Otherwise the string * must refer to a bitmap defined by a call to Tk_DefineBitmap. */ if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(string1))) == int32('@') { if libtcl9_0.XTcl_IsSafe(tls, interp) != 0 { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+4037, int64(-libc.Int32FromInt32(1)))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+256, __ccgo_ts+179, __ccgo_ts+4089, __ccgo_ts+4094, libc.UintptrFromInt32(0))) goto error } /* * Note that we need to cast away the const from the string because * Tcl_TranslateFileName is non-const, even though it doesn't modify * the string. */ string1 = libtcl9_0.XTcl_TranslateFileName(tls, interp, string1+uintptr(1), bp+24) if string1 == libc.UintptrFromInt32(0) { goto error } result = XTkReadBitmapFile(tls, (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fdisplay, (*TScreen)(unsafe.Pointer((*struct { Fext_data uintptr Fprivate1 uintptr Ffd int32 Fprivate2 int32 Fproto_major_version int32 Fproto_minor_version int32 Fvendor uintptr Fprivate3 TXID Fprivate4 TXID Fprivate5 TXID Fprivate6 int32 Fresource_alloc uintptr Fbyte_order int32 Fbitmap_unit int32 Fbitmap_pad int32 Fbitmap_bit_order int32 Fnformats int32 Fpixmap_format uintptr Fprivate8 int32 Frelease int32 Fprivate9 uintptr Fprivate10 uintptr Fqlen int32 Flast_request_read uint64 Frequest uint64 Fprivate11 TXPointer Fprivate12 TXPointer Fprivate13 TXPointer Fprivate14 TXPointer Fmax_request_size uint32 Fdb uintptr Fprivate15 uintptr Fdisplay_name uintptr Fdefault_screen int32 Fnscreens int32 Fscreens uintptr Fmotion_buffer uint64 Fprivate16 uint64 Fmin_keycode int32 Fmax_keycode int32 Fprivate17 TXPointer Fprivate18 TXPointer Fprivate19 int32 Fxdefaults uintptr })(unsafe.Pointer((*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fdisplay)).Fscreens+uintptr((*TTk_FakeWin)(unsafe.Pointer(tkwin)).FscreenNum)*128)).Froot, string1, bp+12, bp+16, bp, bp+20, bp+20) if result != BitmapSuccess { if interp != libc.UintptrFromInt32(0) { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+4106, libc.VaList(bp+256, string1))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+256, __ccgo_ts+179, __ccgo_ts+763, __ccgo_ts+4137, libc.UintptrFromInt32(0))) } libtcl9_0.XTcl_DStringFree(tls, bp+24) goto error } libtcl9_0.XTcl_DStringFree(tls, bp+24) } else { predefHashPtr = (*(*func(*libc.TLS, uintptr, uintptr) uintptr)(unsafe.Pointer(&struct{ uintptr }{(*TTcl_HashTable)(unsafe.Pointer(tsdPtr + 8)).FfindProc})))(tls, tsdPtr+8, string1) if predefHashPtr == libc.UintptrFromInt32(0) { /* * The following platform specific call allows the user to define * bitmaps that may only exist during run time. If it returns None * nothing was found and we return the error. */ *(*TPixmap)(unsafe.Pointer(bp)) = uint64(0) if *(*TPixmap)(unsafe.Pointer(bp)) == uint64(0) { if interp != libc.UintptrFromInt32(0) { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+4148, libc.VaList(bp+256, string1))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+256, __ccgo_ts+179, __ccgo_ts+3058, __ccgo_ts+763, string1, libc.UintptrFromInt32(0))) } goto error } } else { predefPtr = (*TTcl_HashEntry)(unsafe.Pointer(predefHashPtr)).FclientData *(*int32)(unsafe.Pointer(bp + 12)) = (*TTkPredefBitmap)(unsafe.Pointer(predefPtr)).Fwidth *(*int32)(unsafe.Pointer(bp + 16)) = (*TTkPredefBitmap)(unsafe.Pointer(predefPtr)).Fheight if (*TTkPredefBitmap)(unsafe.Pointer(predefPtr)).Fnative != 0 { *(*TPixmap)(unsafe.Pointer(bp)) = uint64(0) if *(*TPixmap)(unsafe.Pointer(bp)) == uint64(0) { libtcl9_0.XTcl_Panic(tls, __ccgo_ts+4172, 0) } } else { *(*TPixmap)(unsafe.Pointer(bp)) = libx11.XXCreateBitmapFromData(tls, (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fdisplay, (*TScreen)(unsafe.Pointer((*struct { Fext_data uintptr Fprivate1 uintptr Ffd int32 Fprivate2 int32 Fproto_major_version int32 Fproto_minor_version int32 Fvendor uintptr Fprivate3 TXID Fprivate4 TXID Fprivate5 TXID Fprivate6 int32 Fresource_alloc uintptr Fbyte_order int32 Fbitmap_unit int32 Fbitmap_pad int32 Fbitmap_bit_order int32 Fnformats int32 Fpixmap_format uintptr Fprivate8 int32 Frelease int32 Fprivate9 uintptr Fprivate10 uintptr Fqlen int32 Flast_request_read uint64 Frequest uint64 Fprivate11 TXPointer Fprivate12 TXPointer Fprivate13 TXPointer Fprivate14 TXPointer Fmax_request_size uint32 Fdb uintptr Fprivate15 uintptr Fdisplay_name uintptr Fdefault_screen int32 Fnscreens int32 Fscreens uintptr Fmotion_buffer uint64 Fprivate16 uint64 Fmin_keycode int32 Fmax_keycode int32 Fprivate17 TXPointer Fprivate18 TXPointer Fprivate19 int32 Fxdefaults uintptr })(unsafe.Pointer((*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fdisplay)).Fscreens+uintptr((*TTk_FakeWin)(unsafe.Pointer(tkwin)).FscreenNum)*128)).Froot, (*TTkPredefBitmap)(unsafe.Pointer(predefPtr)).Fsource, libc.Uint32FromInt32(*(*int32)(unsafe.Pointer(bp + 12))), libc.Uint32FromInt32(*(*int32)(unsafe.Pointer(bp + 16)))) } } } /* * Add information about this bitmap to our database. */ bitmapPtr = libtcl9_0.XTcl_Alloc(tls, uint64(64)) (*TTkBitmap)(unsafe.Pointer(bitmapPtr)).Fbitmap = *(*TPixmap)(unsafe.Pointer(bp)) (*TTkBitmap)(unsafe.Pointer(bitmapPtr)).Fwidth = *(*int32)(unsafe.Pointer(bp + 12)) (*TTkBitmap)(unsafe.Pointer(bitmapPtr)).Fheight = *(*int32)(unsafe.Pointer(bp + 16)) (*TTkBitmap)(unsafe.Pointer(bitmapPtr)).Fdisplay = (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fdisplay (*TTkBitmap)(unsafe.Pointer(bitmapPtr)).FscreenNum = (*TTk_FakeWin)(unsafe.Pointer(tkwin)).FscreenNum (*TTkBitmap)(unsafe.Pointer(bitmapPtr)).FresourceRefCount = int32(1) (*TTkBitmap)(unsafe.Pointer(bitmapPtr)).FobjRefCount = 0 (*TTkBitmap)(unsafe.Pointer(bitmapPtr)).FnameHashPtr = nameHashPtr (*TTkBitmap)(unsafe.Pointer(bitmapPtr)).FidHashPtr = (*(*func(*libc.TLS, uintptr, uintptr, uintptr) uintptr)(unsafe.Pointer(&struct{ uintptr }{(*TTcl_HashTable)(unsafe.Pointer(dispPtr + 512)).FcreateProc})))(tls, dispPtr+512, uintptr(*(*TPixmap)(unsafe.Pointer(bp))), bp+8) if !(*(*int32)(unsafe.Pointer(bp + 8)) != 0) { libtcl9_0.XTcl_Panic(tls, __ccgo_ts+4202, 0) } (*TTkBitmap)(unsafe.Pointer(bitmapPtr)).FnextPtr = existingBitmapPtr (*TTcl_HashEntry)(unsafe.Pointer(nameHashPtr)).FclientData = bitmapPtr (*TTcl_HashEntry)(unsafe.Pointer((*TTkBitmap)(unsafe.Pointer(bitmapPtr)).FidHashPtr)).FclientData = bitmapPtr return bitmapPtr goto error error: ; if *(*int32)(unsafe.Pointer(bp + 8)) != 0 { libtcl9_0.XTcl_DeleteHashEntry(tls, nameHashPtr) } return libc.UintptrFromInt32(0) } /* *---------------------------------------------------------------------- * * Tk_DefineBitmap -- * * This function associates a textual name with a binary bitmap * description, so that the name may be used to refer to the bitmap in * future calls to Tk_GetBitmap. * * Results: * A standard Tcl result. If an error occurs then TCL_ERROR is returned * and a message is left in the interp's result. * * Side effects: * "Name" is entered into the bitmap table and may be used from here on * to refer to the given bitmap. * *---------------------------------------------------------------------- */ func XTk_DefineBitmap(tls *libc.TLS, interp uintptr, name uintptr, source uintptr, width int32, height int32) (r int32) { bp := tls.Alloc(48) defer tls.Free(48) /* Height of bitmap. */ var predefHashPtr, predefPtr, tsdPtr uintptr var _ /* isNew at bp+0 */ int32 _, _, _ = predefHashPtr, predefPtr, tsdPtr tsdPtr = libtcl9_0.XTcl_GetThreadData(tls, uintptr(unsafe.Pointer(&_dataKey)), int64(112)) /* * Initialize the Bitmap module if not initialized already for this * thread. Since the current TkDisplay structure cannot be introspected * from here, pass a NULL pointer to BitmapInit, which will know to * initialize only the data in the ThreadSpecificData structure for the * current thread. */ if !((*TThreadSpecificData)(unsafe.Pointer(tsdPtr)).Finitialized != 0) { _BitmapInit(tls, libc.UintptrFromInt32(0)) } predefHashPtr = (*(*func(*libc.TLS, uintptr, uintptr, uintptr) uintptr)(unsafe.Pointer(&struct{ uintptr }{(*TTcl_HashTable)(unsafe.Pointer(tsdPtr + 8)).FcreateProc})))(tls, tsdPtr+8, name, bp) if !(*(*int32)(unsafe.Pointer(bp)) != 0) { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+4244, libc.VaList(bp+16, name))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+16, __ccgo_ts+179, __ccgo_ts+763, __ccgo_ts+4275, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) } predefPtr = libtcl9_0.XTcl_Alloc(tls, uint64(24)) (*TTkPredefBitmap)(unsafe.Pointer(predefPtr)).Fsource = source (*TTkPredefBitmap)(unsafe.Pointer(predefPtr)).Fwidth = width (*TTkPredefBitmap)(unsafe.Pointer(predefPtr)).Fheight = height (*TTkPredefBitmap)(unsafe.Pointer(predefPtr)).Fnative = 0 (*TTcl_HashEntry)(unsafe.Pointer(predefHashPtr)).FclientData = predefPtr return TCL_OK } /* *-------------------------------------------------------------- * * Tk_NameOfBitmap -- * * Given a bitmap, return a textual string identifying the bitmap. * * Results: * The return value is the string name associated with bitmap. * * Side effects: * None. * *-------------------------------------------------------------- */ func XTk_NameOfBitmap(tls *libc.TLS, display uintptr, bitmap TPixmap) (r uintptr) { /* Bitmap whose name is wanted. */ var bitmapPtr, dispPtr, idHashPtr uintptr _, _, _ = bitmapPtr, dispPtr, idHashPtr dispPtr = XTkGetDisplay(tls, display) if !(dispPtr == libc.UintptrFromInt32(0) || !((*TTkDisplay)(unsafe.Pointer(dispPtr)).FbitmapInit != 0)) { goto _1 } goto unknown unknown: ; libtcl9_0.XTcl_Panic(tls, __ccgo_ts+4282, 0) _1: ; idHashPtr = (*(*func(*libc.TLS, uintptr, uintptr) uintptr)(unsafe.Pointer(&struct{ uintptr }{(*TTcl_HashTable)(unsafe.Pointer(dispPtr + 512)).FfindProc})))(tls, dispPtr+512, uintptr(bitmap)) if idHashPtr == libc.UintptrFromInt32(0) { goto unknown } bitmapPtr = (*TTcl_HashEntry)(unsafe.Pointer(idHashPtr)).FclientData return (*TTkBitmap)(unsafe.Pointer(bitmapPtr)).FnameHashPtr + 32 } /* *-------------------------------------------------------------- * * Tk_SizeOfBitmap -- * * Given a bitmap managed by this module, returns the width and height of * the bitmap. * * Results: * The words at *widthPtr and *heightPtr are filled in with the * dimenstions of bitmap. * * Side effects: * If bitmap isn't managed by this module then the function panics.. * *-------------------------------------------------------------- */ func XTk_SizeOfBitmap(tls *libc.TLS, display uintptr, bitmap TPixmap, widthPtr uintptr, heightPtr uintptr) { /* Store bitmap height here. */ var bitmapPtr, dispPtr, idHashPtr uintptr _, _, _ = bitmapPtr, dispPtr, idHashPtr dispPtr = XTkGetDisplay(tls, display) if !!((*TTkDisplay)(unsafe.Pointer(dispPtr)).FbitmapInit != 0) { goto _1 } goto unknownBitmap unknownBitmap: ; libtcl9_0.XTcl_Panic(tls, __ccgo_ts+4331, 0) _1: ; idHashPtr = (*(*func(*libc.TLS, uintptr, uintptr) uintptr)(unsafe.Pointer(&struct{ uintptr }{(*TTcl_HashTable)(unsafe.Pointer(dispPtr + 512)).FfindProc})))(tls, dispPtr+512, uintptr(bitmap)) if idHashPtr == libc.UintptrFromInt32(0) { goto unknownBitmap } bitmapPtr = (*TTcl_HashEntry)(unsafe.Pointer(idHashPtr)).FclientData *(*int32)(unsafe.Pointer(widthPtr)) = (*TTkBitmap)(unsafe.Pointer(bitmapPtr)).Fwidth *(*int32)(unsafe.Pointer(heightPtr)) = (*TTkBitmap)(unsafe.Pointer(bitmapPtr)).Fheight } /* *---------------------------------------------------------------------- * * FreeBitmap -- * * This function does all the work of releasing a bitmap allocated by * Tk_GetBitmap or TkGetBitmapFromData. It is invoked by both * Tk_FreeBitmap and Tk_FreeBitmapFromObj * * Results: * None. * * Side effects: * The reference count associated with bitmap is decremented, and it is * officially deallocated if no-one is using it anymore. * *---------------------------------------------------------------------- */ func _FreeBitmap(tls *libc.TLS, bitmapPtr uintptr) { /* Bitmap to be released. */ var prevPtr, v2 uintptr var v1 int32 _, _, _ = prevPtr, v1, v2 v2 = bitmapPtr + 28 v1 = *(*int32)(unsafe.Pointer(v2)) *(*int32)(unsafe.Pointer(v2))-- if v1 > int32(1) { return } XTk_FreePixmap(tls, (*TTkBitmap)(unsafe.Pointer(bitmapPtr)).Fdisplay, (*TTkBitmap)(unsafe.Pointer(bitmapPtr)).Fbitmap) libtcl9_0.XTcl_DeleteHashEntry(tls, (*TTkBitmap)(unsafe.Pointer(bitmapPtr)).FidHashPtr) prevPtr = (*TTcl_HashEntry)(unsafe.Pointer((*TTkBitmap)(unsafe.Pointer(bitmapPtr)).FnameHashPtr)).FclientData if prevPtr == bitmapPtr { if (*TTkBitmap)(unsafe.Pointer(bitmapPtr)).FnextPtr == libc.UintptrFromInt32(0) { libtcl9_0.XTcl_DeleteHashEntry(tls, (*TTkBitmap)(unsafe.Pointer(bitmapPtr)).FnameHashPtr) } else { (*TTcl_HashEntry)(unsafe.Pointer((*TTkBitmap)(unsafe.Pointer(bitmapPtr)).FnameHashPtr)).FclientData = (*TTkBitmap)(unsafe.Pointer(bitmapPtr)).FnextPtr } } else { for (*TTkBitmap)(unsafe.Pointer(prevPtr)).FnextPtr != bitmapPtr { prevPtr = (*TTkBitmap)(unsafe.Pointer(prevPtr)).FnextPtr } (*TTkBitmap)(unsafe.Pointer(prevPtr)).FnextPtr = (*TTkBitmap)(unsafe.Pointer(bitmapPtr)).FnextPtr } if (*TTkBitmap)(unsafe.Pointer(bitmapPtr)).FobjRefCount == 0 { libtcl9_0.XTcl_Free(tls, bitmapPtr) } } /* *---------------------------------------------------------------------- * * Tk_FreeBitmap -- * * This function is called to release a bitmap allocated by Tk_GetBitmap * or TkGetBitmapFromData. * * Results: * None. * * Side effects: * The reference count associated with bitmap is decremented, and it is * officially deallocated if no-one is using it anymore. * *---------------------------------------------------------------------- */ func XTk_FreeBitmap(tls *libc.TLS, display uintptr, bitmap TPixmap) { /* Bitmap to be released. */ var dispPtr, idHashPtr uintptr _, _ = dispPtr, idHashPtr dispPtr = XTkGetDisplay(tls, display) if !((*TTkDisplay)(unsafe.Pointer(dispPtr)).FbitmapInit != 0) { libtcl9_0.XTcl_Panic(tls, __ccgo_ts+4380, 0) } idHashPtr = (*(*func(*libc.TLS, uintptr, uintptr) uintptr)(unsafe.Pointer(&struct{ uintptr }{(*TTcl_HashTable)(unsafe.Pointer(dispPtr + 512)).FfindProc})))(tls, dispPtr+512, uintptr(bitmap)) if idHashPtr == libc.UintptrFromInt32(0) { libtcl9_0.XTcl_Panic(tls, __ccgo_ts+4421, 0) } _FreeBitmap(tls, (*TTcl_HashEntry)(unsafe.Pointer(idHashPtr)).FclientData) } /* *---------------------------------------------------------------------- * * Tk_FreeBitmapFromObj -- * * This function is called to release a bitmap allocated by * Tk_AllocBitmapFromObj. It does not throw away the Tcl_Obj *; it only * gets rid of the hash table entry for this bitmap and clears the cached * value that is normally stored in the object. * * Results: * None. * * Side effects: * The reference count associated with the bitmap represented by objPtr * is decremented, and the bitmap is released to X if there are no * remaining uses for it. * *---------------------------------------------------------------------- */ func XTk_FreeBitmapFromObj(tls *libc.TLS, tkwin TTk_Window, objPtr uintptr) { /* The Tcl_Obj * to be freed. */ _FreeBitmap(tls, _GetBitmapFromObj(tls, tkwin, objPtr)) } /* *--------------------------------------------------------------------------- * * FreeBitmapObjProc, FreeBitmapObj -- * * This proc is called to release an object reference to a bitmap. * Called when the object's internal rep is released or when the cached * bitmapPtr needs to be changed. * * Results: * None. * * Side effects: * The object reference count is decremented. When both it and the hash * ref count go to zero, the color's resources are released. * *--------------------------------------------------------------------------- */ func _FreeBitmapObjProc(tls *libc.TLS, objPtr uintptr) { /* The object we are releasing. */ _FreeBitmapObj(tls, objPtr) (*TTcl_Obj)(unsafe.Pointer(objPtr)).FtypePtr = libc.UintptrFromInt32(0) } func _FreeBitmapObj(tls *libc.TLS, objPtr uintptr) { /* The object we are releasing. */ var bitmapPtr uintptr _ = bitmapPtr bitmapPtr = (*(*struct { Fptr1 uintptr Fptr2 uintptr })(unsafe.Pointer(objPtr + 32))).Fptr1 if bitmapPtr != libc.UintptrFromInt32(0) { (*TTkBitmap)(unsafe.Pointer(bitmapPtr)).FobjRefCount-- if (*TTkBitmap)(unsafe.Pointer(bitmapPtr)).FobjRefCount == 0 && (*TTkBitmap)(unsafe.Pointer(bitmapPtr)).FresourceRefCount == 0 { libtcl9_0.XTcl_Free(tls, bitmapPtr) } (*(*struct { Fptr1 uintptr Fptr2 uintptr })(unsafe.Pointer(objPtr + 32))).Fptr1 = libc.UintptrFromInt32(0) } } /* *--------------------------------------------------------------------------- * * DupBitmapObjProc -- * * When a cached bitmap object is duplicated, this is called to update * the internal reps. * * Results: * None. * * Side effects: * The color's objRefCount is incremented and the internal rep of the * copy is set to point to it. * *--------------------------------------------------------------------------- */ func _DupBitmapObjProc(tls *libc.TLS, srcObjPtr uintptr, dupObjPtr uintptr) { /* The object we are copying to. */ var bitmapPtr uintptr _ = bitmapPtr bitmapPtr = (*(*struct { Fptr1 uintptr Fptr2 uintptr })(unsafe.Pointer(srcObjPtr + 32))).Fptr1 (*TTcl_Obj)(unsafe.Pointer(dupObjPtr)).FtypePtr = (*TTcl_Obj)(unsafe.Pointer(srcObjPtr)).FtypePtr (*(*struct { Fptr1 uintptr Fptr2 uintptr })(unsafe.Pointer(dupObjPtr + 32))).Fptr1 = bitmapPtr if bitmapPtr != libc.UintptrFromInt32(0) { (*TTkBitmap)(unsafe.Pointer(bitmapPtr)).FobjRefCount++ } } /* *---------------------------------------------------------------------- * * Tk_GetBitmapFromData -- * * Given a description of the bits for a bitmap, make a bitmap that has * the given properties. *** NOTE: this function is obsolete and really * shouldn't be used anymore. *** * * Results: * The return value is the X identifer for the desired bitmap (a * one-plane Pixmap), unless it couldn't be created properly. In this * case, None is returned and an error message is left in the interp's * result. The caller should never modify the bitmap that is returned, * and should eventually call Tk_FreeBitmap when the bitmap is no longer * needed. * * Side effects: * The bitmap is added to an internal database with a reference count. * For each call to this function, there should eventually be a call to * Tk_FreeBitmap, so that the database can be cleaned up when bitmaps * aren't needed anymore. * *---------------------------------------------------------------------- */ func XTk_GetBitmapFromData(tls *libc.TLS, interp uintptr, tkwin TTk_Window, source uintptr, width int32, height int32) (r TPixmap) { bp := tls.Alloc(80) defer tls.Free(80) /* Dimensions of bitmap. */ var dataHashPtr, dispPtr, name, tsdPtr uintptr var _ /* isNew at bp+16 */ int32 var _ /* nameKey at bp+0 */ TDataKey var _ /* string at bp+20 */ [40]uint8 _, _, _, _ = dataHashPtr, dispPtr, name, tsdPtr dispPtr = (*TTkWindow)(unsafe.Pointer(tkwin)).FdispPtr tsdPtr = libtcl9_0.XTcl_GetThreadData(tls, uintptr(unsafe.Pointer(&_dataKey)), int64(112)) if !((*TThreadSpecificData)(unsafe.Pointer(tsdPtr)).Finitialized != 0) { _BitmapInit(tls, dispPtr) } (*(*TDataKey)(unsafe.Pointer(bp))).Fsource = source (*(*TDataKey)(unsafe.Pointer(bp))).Fwidth = width (*(*TDataKey)(unsafe.Pointer(bp))).Fheight = height dataHashPtr = (*(*func(*libc.TLS, uintptr, uintptr, uintptr) uintptr)(unsafe.Pointer(&struct{ uintptr }{(*TTcl_HashTable)(unsafe.Pointer(dispPtr + 616)).FcreateProc})))(tls, dispPtr+616, bp, bp+16) if !(*(*int32)(unsafe.Pointer(bp + 16)) != 0) { name = (*TTcl_HashEntry)(unsafe.Pointer(dataHashPtr)).FclientData } else { (*TTkDisplay)(unsafe.Pointer(dispPtr)).FbitmapAutoNumber++ libc.X__builtin_snprintf(tls, bp+20, uint64(40), __ccgo_ts+4468, libc.VaList(bp+72, (*TTkDisplay)(unsafe.Pointer(dispPtr)).FbitmapAutoNumber)) name = bp + 20 (*TTcl_HashEntry)(unsafe.Pointer(dataHashPtr)).FclientData = name if XTk_DefineBitmap(tls, interp, name, source, width, height) != TCL_OK { libtcl9_0.XTcl_DeleteHashEntry(tls, dataHashPtr) return uint64(TCL_ERROR) } } return XTk_GetBitmap(tls, interp, tkwin, name) } /* *---------------------------------------------------------------------- * * Tk_GetBitmapFromObj -- * * Returns the bitmap referred to by a Tcl object. The bitmap must * already have been allocated via a call to Tk_AllocBitmapFromObj or * Tk_GetBitmap. * * Results: * Returns the Pixmap that matches the tkwin and the string rep of * objPtr. * * Side effects: * If the object is not already a bitmap, the conversion will free any * old internal representation. * *---------------------------------------------------------------------- */ func XTk_GetBitmapFromObj(tls *libc.TLS, tkwin TTk_Window, objPtr uintptr) (r TPixmap) { /* The object from which to get pixels. */ var bitmapPtr uintptr _ = bitmapPtr bitmapPtr = _GetBitmapFromObj(tls, tkwin, objPtr) return (*TTkBitmap)(unsafe.Pointer(bitmapPtr)).Fbitmap } /* *---------------------------------------------------------------------- * * GetBitmapFromObj -- * * Returns the bitmap referred to by a Tcl object. The bitmap must * already have been allocated via a call to Tk_AllocBitmapFromObj or * Tk_GetBitmap. * * Results: * Returns the TkBitmap * that matches the tkwin and the string rep of * objPtr. * * Side effects: * If the object is not already a bitmap, the conversion will free any * old internal representation. * *---------------------------------------------------------------------- */ func _GetBitmapFromObj(tls *libc.TLS, tkwin TTk_Window, objPtr uintptr) (r uintptr) { /* The object that describes the desired * bitmap. */ var bitmapPtr, dispPtr, hashPtr uintptr _, _, _ = bitmapPtr, dispPtr, hashPtr dispPtr = (*TTkWindow)(unsafe.Pointer(tkwin)).FdispPtr if (*TTcl_Obj)(unsafe.Pointer(objPtr)).FtypePtr != uintptr(unsafe.Pointer(&XtkBitmapObjType)) { _InitBitmapObj(tls, objPtr) } bitmapPtr = (*(*struct { Fptr1 uintptr Fptr2 uintptr })(unsafe.Pointer(objPtr + 32))).Fptr1 if bitmapPtr != libc.UintptrFromInt32(0) { if (*TTkBitmap)(unsafe.Pointer(bitmapPtr)).FresourceRefCount > 0 && (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fdisplay == (*TTkBitmap)(unsafe.Pointer(bitmapPtr)).Fdisplay { return bitmapPtr } hashPtr = (*TTkBitmap)(unsafe.Pointer(bitmapPtr)).FnameHashPtr _FreeBitmapObj(tls, objPtr) } else { hashPtr = (*(*func(*libc.TLS, uintptr, uintptr) uintptr)(unsafe.Pointer(&struct{ uintptr }{(*TTcl_HashTable)(unsafe.Pointer(dispPtr + 408)).FfindProc})))(tls, dispPtr+408, libtcl9_0.XTcl_GetStringFromObj(tls, objPtr, libc.UintptrFromInt32(0))) if hashPtr == libc.UintptrFromInt32(0) { goto error } } /* * At this point we've got a hash table entry, off of which hang one or * more TkBitmap structures. See if any of them will work. */ bitmapPtr = (*TTcl_HashEntry)(unsafe.Pointer(hashPtr)).FclientData for { if !(bitmapPtr != libc.UintptrFromInt32(0)) { break } if (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fdisplay == (*TTkBitmap)(unsafe.Pointer(bitmapPtr)).Fdisplay { (*(*struct { Fptr1 uintptr Fptr2 uintptr })(unsafe.Pointer(objPtr + 32))).Fptr1 = bitmapPtr (*TTkBitmap)(unsafe.Pointer(bitmapPtr)).FobjRefCount++ return bitmapPtr } goto _1 _1: ; bitmapPtr = (*TTkBitmap)(unsafe.Pointer(bitmapPtr)).FnextPtr } goto error error: ; libtcl9_0.XTcl_Panic(tls, __ccgo_ts+4474, 0) /* * The following code isn't reached; it's just there to please compilers. */ return libc.UintptrFromInt32(0) } /* *---------------------------------------------------------------------- * * InitBitmapObj -- * * Bookeeping function to change an objPtr to a bitmap type. * * Results: * None. * * Side effects: * The old internal rep of the object is freed. The internal rep is * cleared. The final form of the object is set by either * Tk_AllocBitmapFromObj or GetBitmapFromObj. * *---------------------------------------------------------------------- */ func _InitBitmapObj(tls *libc.TLS, objPtr uintptr) { /* The object to convert. */ var typePtr uintptr _ = typePtr /* * Free the old internalRep before setting the new one. */ libtcl9_0.XTcl_GetStringFromObj(tls, objPtr, libc.UintptrFromInt32(0)) typePtr = (*TTcl_Obj)(unsafe.Pointer(objPtr)).FtypePtr if typePtr != libc.UintptrFromInt32(0) && (*TTcl_ObjType)(unsafe.Pointer(typePtr)).FfreeIntRepProc != libc.UintptrFromInt32(0) { (*(*func(*libc.TLS, uintptr))(unsafe.Pointer(&struct{ uintptr }{(*TTcl_ObjType)(unsafe.Pointer(typePtr)).FfreeIntRepProc})))(tls, objPtr) } (*TTcl_Obj)(unsafe.Pointer(objPtr)).FtypePtr = uintptr(unsafe.Pointer(&XtkBitmapObjType)) (*(*struct { Fptr1 uintptr Fptr2 uintptr })(unsafe.Pointer(objPtr + 32))).Fptr1 = libc.UintptrFromInt32(0) } /* *---------------------------------------------------------------------- * * BitmapInit -- * * Initializes hash tables used by this module. Initializes tables stored * in TkDisplay structure if a TkDisplay pointer is passed in. Also * initializes the thread-local data in the current thread's * ThreadSpecificData structure. * * Results: * None. * * Side effects: * Read the code. * *---------------------------------------------------------------------- */ func _BitmapInit(tls *libc.TLS, dispPtr uintptr) { /* TkDisplay structure encapsulating * thread-specific data used by this module, * or NULL if unavailable. */ var dummy, tsdPtr uintptr _, _ = dummy, tsdPtr tsdPtr = libtcl9_0.XTcl_GetThreadData(tls, uintptr(unsafe.Pointer(&_dataKey)), int64(112)) /* * First initialize the data in the ThreadSpecificData structure, if * needed. */ if !((*TThreadSpecificData)(unsafe.Pointer(tsdPtr)).Finitialized != 0) { (*TThreadSpecificData)(unsafe.Pointer(tsdPtr)).Finitialized = int32(1) dummy = libtcl9_0.XTcl_CreateInterp(tls) libtcl9_0.XTcl_InitHashTable(tls, tsdPtr+8, TCL_STRING_KEYS) XTk_DefineBitmap(tls, dummy, __ccgo_ts+4524, uintptr(unsafe.Pointer(&_error_bits)), int32(error_width), int32(error_height)) XTk_DefineBitmap(tls, dummy, __ccgo_ts+4530, uintptr(unsafe.Pointer(&_gray75_bits)), int32(gray75_width), int32(gray75_height)) XTk_DefineBitmap(tls, dummy, __ccgo_ts+4537, uintptr(unsafe.Pointer(&_gray50_bits)), int32(gray50_width), int32(gray50_height)) XTk_DefineBitmap(tls, dummy, __ccgo_ts+4544, uintptr(unsafe.Pointer(&_gray25_bits)), int32(gray25_width), int32(gray25_height)) XTk_DefineBitmap(tls, dummy, __ccgo_ts+4551, uintptr(unsafe.Pointer(&_gray12_bits)), int32(gray12_width), int32(gray12_height)) XTk_DefineBitmap(tls, dummy, __ccgo_ts+4558, uintptr(unsafe.Pointer(&_hourglass_bits)), int32(hourglass_width), int32(hourglass_height)) XTk_DefineBitmap(tls, dummy, __ccgo_ts+2671, uintptr(unsafe.Pointer(&_info_bits)), int32(info_width), int32(info_height)) XTk_DefineBitmap(tls, dummy, __ccgo_ts+4568, uintptr(unsafe.Pointer(&_questhead_bits)), int32(questhead_width), int32(questhead_height)) XTk_DefineBitmap(tls, dummy, __ccgo_ts+4578, uintptr(unsafe.Pointer(&_question_bits)), int32(question_width), int32(question_height)) XTk_DefineBitmap(tls, dummy, __ccgo_ts+4587, uintptr(unsafe.Pointer(&_warning_bits)), int32(warning_width), int32(warning_height)) libtcl9_0.XTcl_DeleteInterp(tls, dummy) } /* * Was a valid TkDisplay pointer passed? If so, initialize the Bitmap * module tables in that structure. */ if dispPtr != libc.UintptrFromInt32(0) { (*TTkDisplay)(unsafe.Pointer(dispPtr)).FbitmapInit = int32(1) libtcl9_0.XTcl_InitHashTable(tls, dispPtr+408, TCL_STRING_KEYS) libtcl9_0.XTcl_InitHashTable(tls, dispPtr+616, libc.Int32FromUint64(libc.Uint64FromInt64(16)/libc.Uint64FromInt64(4))) /* * The call below is tricky: can't use sizeof(IdKey) because it gets * padded with extra unpredictable bytes on some 64-bit machines. */ /* * The comment above doesn't make sense... */ libtcl9_0.XTcl_InitHashTable(tls, dispPtr+512, int32(TCL_ONE_WORD_KEYS)) } } /* *---------------------------------------------------------------------- * * TkReadBitmapFile -- * * Loads a bitmap image in X bitmap format into the specified drawable. * This is equivalent to the XReadBitmapFile in X. * * Results: * Sets the size, hotspot, and bitmap on success. * * Side effects: * Creates a new bitmap from the file data. * *---------------------------------------------------------------------- */ func XTkReadBitmapFile(tls *libc.TLS, display uintptr, d TDrawable, filename uintptr, width_return uintptr, height_return uintptr, bitmap_return uintptr, x_hot_return uintptr, y_hot_return uintptr) (r int32) { var data uintptr _ = data data = XTkGetBitmapData(tls, libc.UintptrFromInt32(0), libc.UintptrFromInt32(0), filename, width_return, height_return, x_hot_return, y_hot_return) if data == libc.UintptrFromInt32(0) { return int32(BitmapFileInvalid) } *(*TPixmap)(unsafe.Pointer(bitmap_return)) = libx11.XXCreateBitmapFromData(tls, display, d, data, *(*uint32)(unsafe.Pointer(width_return)), *(*uint32)(unsafe.Pointer(height_return))) libtcl9_0.XTcl_Free(tls, data) return BitmapSuccess } /* *---------------------------------------------------------------------- * * TkDebugBitmap -- * * This function returns debugging information about a bitmap. * * Results: * The return value is a list with one sublist for each TkBitmap * corresponding to "name". Each sublist has two elements that contain * the resourceRefCount and objRefCount fields from the TkBitmap * structure. * * Side effects: * None. * *---------------------------------------------------------------------- */ func XTkDebugBitmap(tls *libc.TLS, tkwin TTk_Window, name uintptr) (r uintptr) { /* Name of the desired color. */ var bitmapPtr, dispPtr, hashPtr, objPtr, resultPtr uintptr _, _, _, _, _ = bitmapPtr, dispPtr, hashPtr, objPtr, resultPtr dispPtr = (*TTkWindow)(unsafe.Pointer(tkwin)).FdispPtr resultPtr = libtcl9_0.XTcl_NewObj(tls) hashPtr = (*(*func(*libc.TLS, uintptr, uintptr) uintptr)(unsafe.Pointer(&struct{ uintptr }{(*TTcl_HashTable)(unsafe.Pointer(dispPtr + 408)).FfindProc})))(tls, dispPtr+408, name) if hashPtr != libc.UintptrFromInt32(0) { bitmapPtr = (*TTcl_HashEntry)(unsafe.Pointer(hashPtr)).FclientData if bitmapPtr == libc.UintptrFromInt32(0) { libtcl9_0.XTcl_Panic(tls, __ccgo_ts+4595, 0) } for { if !(bitmapPtr != libc.UintptrFromInt32(0)) { break } objPtr = libtcl9_0.XTcl_NewObj(tls) libtcl9_0.XTcl_ListObjAppendElement(tls, libc.UintptrFromInt32(0), objPtr, libtcl9_0.XTcl_NewWideIntObj(tls, int64((*TTkBitmap)(unsafe.Pointer(bitmapPtr)).FresourceRefCount))) libtcl9_0.XTcl_ListObjAppendElement(tls, libc.UintptrFromInt32(0), objPtr, libtcl9_0.XTcl_NewWideIntObj(tls, int64((*TTkBitmap)(unsafe.Pointer(bitmapPtr)).FobjRefCount))) libtcl9_0.XTcl_ListObjAppendElement(tls, libc.UintptrFromInt32(0), resultPtr, objPtr) goto _1 _1: ; bitmapPtr = (*TTkBitmap)(unsafe.Pointer(bitmapPtr)).FnextPtr } } return resultPtr } /* *---------------------------------------------------------------------- * * TkGetBitmapPredefTable -- * * This function is used by tkMacOSXBitmap.c to access the thread-specific * predefBitmap table that maps from the names of the predefined bitmaps * to data associated with those bitmaps. It is required because the * table is allocated in thread-local storage and is not visible outside * this file. * Results: * Returns a pointer to the predefined bitmap hash table for the current * thread. * * Side effects: * None. * *---------------------------------------------------------------------- */ func XTkGetBitmapPredefTable(tls *libc.TLS) (r uintptr) { var tsdPtr uintptr _ = tsdPtr tsdPtr = libtcl9_0.XTcl_GetThreadData(tls, uintptr(unsafe.Pointer(&_dataKey)), int64(112)) return tsdPtr + 8 } const ACTIVE_BG = "#ececec" const BLACK = "#000000" const DEF_BUSY_CURSOR = "watch" const DEF_BUTTON_ACTIVE_BG_COLOR = "ACTIVE_BG" const DEF_BUTTON_ACTIVE_BG_MONO = "BLACK" const DEF_BUTTON_ACTIVE_FG_COLOR = "BLACK" const DEF_BUTTON_ACTIVE_FG_MONO = "WHITE" const DEF_BUTTON_ANCHOR = "center" const DEF_BUTTON_BG_COLOR = "NORMAL_BG" const DEF_BUTTON_BG_MONO = "WHITE" const DEF_BUTTON_BITMAP = "" const DEF_BUTTON_BORDER_WIDTH = "1" const DEF_BUTTON_COMMAND = "" const DEF_BUTTON_COMPOUND = "none" const DEF_BUTTON_CURSOR = "" const DEF_BUTTON_DEFAULT = "disabled" const DEF_BUTTON_DISABLED_FG_COLOR = "DISABLED" const DEF_BUTTON_DISABLED_FG_MONO = "" const DEF_BUTTON_FG = "BLACK" const DEF_BUTTON_FONT = "TkDefaultFont" const DEF_BUTTON_HEIGHT = "0" const DEF_BUTTON_HIGHLIGHT = "BLACK" const DEF_BUTTON_HIGHLIGHT_BG_COLOR = "DEF_BUTTON_BG_COLOR" const DEF_BUTTON_HIGHLIGHT_BG_MONO = "DEF_BUTTON_BG_MONO" const DEF_BUTTON_HIGHLIGHT_WIDTH = "1" const DEF_BUTTON_IMAGE = "NULL" const DEF_BUTTON_INDICATOR = "1" const DEF_BUTTON_JUSTIFY = "center" const DEF_BUTTON_OFF_VALUE = "0" const DEF_BUTTON_ON_VALUE = "1" const DEF_BUTTON_OVER_RELIEF = "" const DEF_BUTTON_PADX = "3m" const DEF_BUTTON_PADY = "1m" const DEF_BUTTON_RELIEF = "raised" const DEF_BUTTON_REPEAT_DELAY = "0" const DEF_BUTTON_REPEAT_INTERVAL = "0" const DEF_BUTTON_SELECT_COLOR = "INDICATOR" const DEF_BUTTON_SELECT_IMAGE = "NULL" const DEF_BUTTON_SELECT_MONO = "BLACK" const DEF_BUTTON_STATE = "normal" const DEF_BUTTON_TAKE_FOCUS = "NULL" const DEF_BUTTON_TEXT = "" const DEF_BUTTON_TEXT_VARIABLE = "" const DEF_BUTTON_TRISTATE_VALUE = "" const DEF_BUTTON_VALUE = "" const DEF_BUTTON_WIDTH = "0" const DEF_BUTTON_WRAP_LENGTH = "0" const DEF_CANVAS_BG_COLOR = "NORMAL_BG" const DEF_CANVAS_BG_MONO = "WHITE" const DEF_CANVAS_BORDER_WIDTH = "0" const DEF_CANVAS_CLOSE_ENOUGH = "1" const DEF_CANVAS_CONFINE = "1" const DEF_CANVAS_CURSOR = "" const DEF_CANVAS_HEIGHT = "7c" const DEF_CANVAS_HIGHLIGHT = "BLACK" const DEF_CANVAS_HIGHLIGHT_BG = "NORMAL_BG" const DEF_CANVAS_HIGHLIGHT_WIDTH = "1" const DEF_CANVAS_INSERT_BD_COLOR = "0" const DEF_CANVAS_INSERT_BD_MONO = "0" const DEF_CANVAS_INSERT_BG = "BLACK" const DEF_CANVAS_INSERT_OFF_TIME = "300" const DEF_CANVAS_INSERT_ON_TIME = "600" const DEF_CANVAS_INSERT_WIDTH = "2" const DEF_CANVAS_RELIEF = "flat" const DEF_CANVAS_SCROLL_REGION = "" const DEF_CANVAS_SELECT_BD_COLOR = "1" const DEF_CANVAS_SELECT_BD_MONO = "0" const DEF_CANVAS_SELECT_COLOR = "SELECT_BG" const DEF_CANVAS_SELECT_FG_COLOR = "BLACK" const DEF_CANVAS_SELECT_FG_MONO = "WHITE" const DEF_CANVAS_SELECT_MONO = "BLACK" const DEF_CANVAS_TAKE_FOCUS = "NULL" const DEF_CANVAS_WIDTH = "10c" const DEF_CANVAS_X_SCROLL_CMD = "" const DEF_CANVAS_X_SCROLL_INCREMENT = "0" const DEF_CANVAS_Y_SCROLL_CMD = "" const DEF_CANVAS_Y_SCROLL_INCREMENT = "0" const DEF_CANVBMAP_FG = "BLACK" const DEF_CANVITEM_OUTLINE = "BLACK" const DEF_CANVTEXT_FONT = "TkDefaultFont" const DEF_CHECKBUTTON_VARIABLE = "" const DEF_CHKRAD_ACTIVE_FG_COLOR = "DEF_BUTTON_ACTIVE_FG_COLOR" const DEF_CHKRAD_FG = "DEF_BUTTON_FG" const DEF_ENTRY_BG_COLOR = "WHITE" const DEF_ENTRY_BG_MONO = "WHITE" const DEF_ENTRY_BORDER_WIDTH = "1" const DEF_ENTRY_CURSOR = "xterm" const DEF_ENTRY_DISABLED_BG_COLOR = "NORMAL_BG" const DEF_ENTRY_DISABLED_BG_MONO = "WHITE" const DEF_ENTRY_DISABLED_FG = "DISABLED" const DEF_ENTRY_EXPORT_SELECTION = "1" const DEF_ENTRY_FG = "BLACK" const DEF_ENTRY_FONT = "TkTextFont" const DEF_ENTRY_HIGHLIGHT = "BLACK" const DEF_ENTRY_HIGHLIGHT_BG = "NORMAL_BG" const DEF_ENTRY_HIGHLIGHT_WIDTH = "1" const DEF_ENTRY_INSERT_BD_COLOR = "0" const DEF_ENTRY_INSERT_BD_MONO = "0" const DEF_ENTRY_INSERT_BG = "BLACK" const DEF_ENTRY_INSERT_OFF_TIME = "300" const DEF_ENTRY_INSERT_ON_TIME = "600" const DEF_ENTRY_INSERT_WIDTH = "2" const DEF_ENTRY_JUSTIFY = "left" const DEF_ENTRY_PLACEHOLDER = "" const DEF_ENTRY_PLACEHOLDERFG = "PLACEHOLDER_FG" const DEF_ENTRY_READONLY_BG_COLOR = "NORMAL_BG" const DEF_ENTRY_READONLY_BG_MONO = "WHITE" const DEF_ENTRY_RELIEF = "sunken" const DEF_ENTRY_SCROLL_COMMAND = "" const DEF_ENTRY_SELECT_BD_COLOR = "0" const DEF_ENTRY_SELECT_BD_MONO = "0" const DEF_ENTRY_SELECT_COLOR = "SELECT_BG" const DEF_ENTRY_SELECT_FG_COLOR = "BLACK" const DEF_ENTRY_SELECT_FG_MONO = "WHITE" const DEF_ENTRY_SELECT_MONO = "BLACK" const DEF_ENTRY_SHOW = "NULL" const DEF_ENTRY_STATE = "normal" const DEF_ENTRY_TAKE_FOCUS = "NULL" const DEF_ENTRY_TEXT_VARIABLE = "" const DEF_ENTRY_WIDTH = "20" const DEF_FRAME_BG_COLOR = "NORMAL_BG" const DEF_FRAME_BG_IMAGE = "NULL" const DEF_FRAME_BG_MONO = "WHITE" const DEF_FRAME_BG_TILE = "0" const DEF_FRAME_BORDER_WIDTH = "0" const DEF_FRAME_CLASS = "Frame" const DEF_FRAME_COLORMAP = "" const DEF_FRAME_CONTAINER = "0" const DEF_FRAME_CURSOR = "" const DEF_FRAME_HEIGHT = "0" const DEF_FRAME_HIGHLIGHT = "BLACK" const DEF_FRAME_HIGHLIGHT_BG = "NORMAL_BG" const DEF_FRAME_HIGHLIGHT_WIDTH = "0" const DEF_FRAME_LABEL = "" const DEF_FRAME_PADX = "0" const DEF_FRAME_PADY = "0" const DEF_FRAME_RELIEF = "flat" const DEF_FRAME_TAKE_FOCUS = "0" const DEF_FRAME_VISUAL = "" const DEF_FRAME_WIDTH = "0" const DEF_LABCHKRAD_PADX = "1" const DEF_LABCHKRAD_PADY = "1" const DEF_LABCHKRAD_RELIEF = "flat" const DEF_LABELFRAME_BORDER_WIDTH = "2" const DEF_LABELFRAME_CLASS = "Labelframe" const DEF_LABELFRAME_FG = "BLACK" const DEF_LABELFRAME_FONT = "TkDefaultFont" const DEF_LABELFRAME_LABELANCHOR = "nw" const DEF_LABELFRAME_RELIEF = "groove" const DEF_LABELFRAME_TEXT = "" const DEF_LABEL_FG = "BLACK" const DEF_LABEL_HIGHLIGHT_WIDTH = "0" const DEF_LABEL_TAKE_FOCUS = "0" const DEF_LISTBOX_ACTIVE_STYLE = "dotbox" const DEF_LISTBOX_BG_COLOR = "WHITE" const DEF_LISTBOX_BG_MONO = "WHITE" const DEF_LISTBOX_BORDER_WIDTH = "1" const DEF_LISTBOX_CURSOR = "" const DEF_LISTBOX_DISABLED_FG = "DISABLED" const DEF_LISTBOX_EXPORT_SELECTION = "1" const DEF_LISTBOX_FG = "BLACK" const DEF_LISTBOX_FONT = "TkDefaultFont" const DEF_LISTBOX_HEIGHT = "10" const DEF_LISTBOX_HIGHLIGHT = "BLACK" const DEF_LISTBOX_HIGHLIGHT_BG = "NORMAL_BG" const DEF_LISTBOX_HIGHLIGHT_WIDTH = "1" const DEF_LISTBOX_JUSTIFY = "left" const DEF_LISTBOX_LIST_VARIABLE = "" const DEF_LISTBOX_RELIEF = "sunken" const DEF_LISTBOX_SCROLL_COMMAND = "" const DEF_LISTBOX_SELECT_BD = "0" const DEF_LISTBOX_SELECT_COLOR = "SELECT_BG" const DEF_LISTBOX_SELECT_FG_COLOR = "BLACK" const DEF_LISTBOX_SELECT_FG_MONO = "WHITE" const DEF_LISTBOX_SELECT_MODE = "browse" const DEF_LISTBOX_SELECT_MONO = "BLACK" const DEF_LISTBOX_SET_GRID = "0" const DEF_LISTBOX_STATE = "normal" const DEF_LISTBOX_TAKE_FOCUS = "NULL" const DEF_LISTBOX_WIDTH = "20" const DEF_MENUBUTTON_ACTIVE_BG_COLOR = "ACTIVE_BG" const DEF_MENUBUTTON_ACTIVE_BG_MONO = "BLACK" const DEF_MENUBUTTON_ACTIVE_FG_COLOR = "BLACK" const DEF_MENUBUTTON_ACTIVE_FG_MONO = "WHITE" const DEF_MENUBUTTON_ANCHOR = "center" const DEF_MENUBUTTON_BG_COLOR = "NORMAL_BG" const DEF_MENUBUTTON_BG_MONO = "WHITE" const DEF_MENUBUTTON_BITMAP = "" const DEF_MENUBUTTON_BORDER_WIDTH = "1" const DEF_MENUBUTTON_CURSOR = "" const DEF_MENUBUTTON_DIRECTION = "below" const DEF_MENUBUTTON_DISABLED_FG_COLOR = "DISABLED" const DEF_MENUBUTTON_DISABLED_FG_MONO = "" const DEF_MENUBUTTON_FG = "BLACK" const DEF_MENUBUTTON_FONT = "TkDefaultFont" const DEF_MENUBUTTON_HEIGHT = "0" const DEF_MENUBUTTON_HIGHLIGHT = "BLACK" const DEF_MENUBUTTON_HIGHLIGHT_BG_COLOR = "DEF_MENUBUTTON_BG_COLOR" const DEF_MENUBUTTON_HIGHLIGHT_BG_MONO = "DEF_MENUBUTTON_BG_MONO" const DEF_MENUBUTTON_HIGHLIGHT_WIDTH = "0" const DEF_MENUBUTTON_IMAGE = "NULL" const DEF_MENUBUTTON_INDICATOR = "0" const DEF_MENUBUTTON_JUSTIFY = "center" const DEF_MENUBUTTON_MENU = "" const DEF_MENUBUTTON_PADX = "4p" const DEF_MENUBUTTON_PADY = "3p" const DEF_MENUBUTTON_RELIEF = "flat" const DEF_MENUBUTTON_STATE = "normal" const DEF_MENUBUTTON_TAKE_FOCUS = "0" const DEF_MENUBUTTON_TEXT = "" const DEF_MENUBUTTON_TEXT_VARIABLE = "" const DEF_MENUBUTTON_WIDTH = "0" const DEF_MENUBUTTON_WRAP_LENGTH = "0" const DEF_MENU_ACTIVE_BG_COLOR = "ACTIVE_BG" const DEF_MENU_ACTIVE_BG_MONO = "BLACK" const DEF_MENU_ACTIVE_BORDER_WIDTH = "1" const DEF_MENU_ACTIVE_FG_COLOR = "BLACK" const DEF_MENU_ACTIVE_FG_MONO = "WHITE" const DEF_MENU_ACTIVE_RELIEF = "raised" const DEF_MENU_BG_COLOR = "NORMAL_BG" const DEF_MENU_BG_MONO = "WHITE" const DEF_MENU_BORDER_WIDTH = "1" const DEF_MENU_CURSOR = "arrow" const DEF_MENU_DISABLED_FG_COLOR = "DISABLED" const DEF_MENU_DISABLED_FG_MONO = "" const DEF_MENU_ENTRY_ACCELERATOR = "NULL" const DEF_MENU_ENTRY_ACTIVE_BG = "NULL" const DEF_MENU_ENTRY_ACTIVE_FG = "NULL" const DEF_MENU_ENTRY_BG = "NULL" const DEF_MENU_ENTRY_BITMAP = "NULL" const DEF_MENU_ENTRY_CHECK_VARIABLE = "NULL" const DEF_MENU_ENTRY_COLUMN_BREAK = "0" const DEF_MENU_ENTRY_COMMAND = "NULL" const DEF_MENU_ENTRY_COMPOUND = "none" const DEF_MENU_ENTRY_FG = "NULL" const DEF_MENU_ENTRY_FONT = "NULL" const DEF_MENU_ENTRY_HIDE_MARGIN = "0" const DEF_MENU_ENTRY_IMAGE = "NULL" const DEF_MENU_ENTRY_INDICATOR = "1" const DEF_MENU_ENTRY_LABEL = "NULL" const DEF_MENU_ENTRY_MENU = "NULL" const DEF_MENU_ENTRY_OFF_VALUE = "0" const DEF_MENU_ENTRY_ON_VALUE = "1" const DEF_MENU_ENTRY_RADIO_VARIABLE = "selectedButton" const DEF_MENU_ENTRY_SELECT = "NULL" const DEF_MENU_ENTRY_SELECT_IMAGE = "NULL" const DEF_MENU_ENTRY_STATE = "normal" const DEF_MENU_ENTRY_VALUE = "NULL" const DEF_MENU_FG = "BLACK" const DEF_MENU_FONT = "TkMenuFont" const DEF_MENU_POST_COMMAND = "" const DEF_MENU_RELIEF = "raised" const DEF_MENU_SELECT_COLOR = "BLACK" const DEF_MENU_SELECT_MONO = "BLACK" const DEF_MENU_TAKE_FOCUS = "0" const DEF_MENU_TEAROFF = "0" const DEF_MENU_TEAROFF_CMD = "NULL" const DEF_MENU_TITLE = "" const DEF_MENU_TYPE = "normal" const DEF_MESSAGE_ANCHOR = "center" const DEF_MESSAGE_ASPECT = "150" const DEF_MESSAGE_BG_COLOR = "NORMAL_BG" const DEF_MESSAGE_BG_MONO = "WHITE" const DEF_MESSAGE_BORDER_WIDTH = "1" const DEF_MESSAGE_CURSOR = "" const DEF_MESSAGE_FG = "BLACK" const DEF_MESSAGE_FONT = "TkDefaultFont" const DEF_MESSAGE_HIGHLIGHT = "BLACK" const DEF_MESSAGE_HIGHLIGHT_BG = "NORMAL_BG" const DEF_MESSAGE_HIGHLIGHT_WIDTH = "0" const DEF_MESSAGE_JUSTIFY = "left" const DEF_MESSAGE_PADX = "NULL" const DEF_MESSAGE_PADY = "NULL" const DEF_MESSAGE_RELIEF = "flat" const DEF_MESSAGE_TAKE_FOCUS = "0" const DEF_MESSAGE_TEXT = "" const DEF_MESSAGE_TEXT_VARIABLE = "" const DEF_MESSAGE_WIDTH = "0" const DEF_PANEDWINDOW_BG_COLOR = "NORMAL_BG" const DEF_PANEDWINDOW_BG_MONO = "WHITE" const DEF_PANEDWINDOW_BORDERWIDTH = "1" const DEF_PANEDWINDOW_CURSOR = "" const DEF_PANEDWINDOW_HANDLEPAD = "8" const DEF_PANEDWINDOW_HANDLESIZE = "8" const DEF_PANEDWINDOW_HEIGHT = "" const DEF_PANEDWINDOW_OPAQUERESIZE = "1" const DEF_PANEDWINDOW_ORIENT = "horizontal" const DEF_PANEDWINDOW_PANE_AFTER = "" const DEF_PANEDWINDOW_PANE_BEFORE = "" const DEF_PANEDWINDOW_PANE_HEIGHT = "" const DEF_PANEDWINDOW_PANE_HIDE = "0" const DEF_PANEDWINDOW_PANE_MINSIZE = "0" const DEF_PANEDWINDOW_PANE_PADX = "0" const DEF_PANEDWINDOW_PANE_PADY = "0" const DEF_PANEDWINDOW_PANE_STICKY = "nsew" const DEF_PANEDWINDOW_PANE_STRETCH = "last" const DEF_PANEDWINDOW_PANE_WIDTH = "" const DEF_PANEDWINDOW_PROXYBORDER = "2" const DEF_PANEDWINDOW_RELIEF = "flat" const DEF_PANEDWINDOW_SASHCURSOR = "" const DEF_PANEDWINDOW_SASHPAD = "0" const DEF_PANEDWINDOW_SASHRELIEF = "flat" const DEF_PANEDWINDOW_SASHWIDTH = "3" const DEF_PANEDWINDOW_SHOWHANDLE = "0" const DEF_PANEDWINDOW_WIDTH = "" const DEF_RADIOBUTTON_VARIABLE = "selectedButton" const DEF_SCALE_ACTIVE_BG_COLOR = "ACTIVE_BG" const DEF_SCALE_ACTIVE_BG_MONO = "BLACK" const DEF_SCALE_BG_COLOR = "NORMAL_BG" const DEF_SCALE_BG_MONO = "WHITE" const DEF_SCALE_BIG_INCREMENT = "0.0" const DEF_SCALE_BORDER_WIDTH = "1" const DEF_SCALE_COMMAND = "" const DEF_SCALE_CURSOR = "" const DEF_SCALE_DIGITS = "0" const DEF_SCALE_FG_COLOR = "BLACK" const DEF_SCALE_FG_MONO = "BLACK" const DEF_SCALE_FONT = "TkDefaultFont" const DEF_SCALE_FROM = "0.0" const DEF_SCALE_HIGHLIGHT = "BLACK" const DEF_SCALE_HIGHLIGHT_BG_COLOR = "DEF_SCALE_BG_COLOR" const DEF_SCALE_HIGHLIGHT_BG_MONO = "DEF_SCALE_BG_MONO" const DEF_SCALE_HIGHLIGHT_WIDTH = "1" const DEF_SCALE_LABEL = "" const DEF_SCALE_LENGTH = "100" const DEF_SCALE_ORIENT = "vertical" const DEF_SCALE_RELIEF = "flat" const DEF_SCALE_REPEAT_DELAY = "300" const DEF_SCALE_REPEAT_INTERVAL = "100" const DEF_SCALE_RESOLUTION = "1.0" const DEF_SCALE_SHOW_VALUE = "1" const DEF_SCALE_SLIDER_LENGTH = "30" const DEF_SCALE_SLIDER_RELIEF = "raised" const DEF_SCALE_STATE = "normal" const DEF_SCALE_TAKE_FOCUS = "NULL" const DEF_SCALE_TICK_INTERVAL = "0.0" const DEF_SCALE_TO = "100.0" const DEF_SCALE_TROUGH_COLOR = "TROUGH" const DEF_SCALE_TROUGH_MONO = "WHITE" const DEF_SCALE_VARIABLE = "" const DEF_SCALE_WIDTH = "15" const DEF_SCROLLBAR_ACTIVE_BG_COLOR = "ACTIVE_BG" const DEF_SCROLLBAR_ACTIVE_BG_MONO = "BLACK" const DEF_SCROLLBAR_ACTIVE_RELIEF = "raised" const DEF_SCROLLBAR_BG_COLOR = "NORMAL_BG" const DEF_SCROLLBAR_BG_MONO = "WHITE" const DEF_SCROLLBAR_BORDER_WIDTH = "1" const DEF_SCROLLBAR_COMMAND = "" const DEF_SCROLLBAR_CURSOR = "" const DEF_SCROLLBAR_EL_BORDER_WIDTH = "NULL" const DEF_SCROLLBAR_HIGHLIGHT = "BLACK" const DEF_SCROLLBAR_HIGHLIGHT_BG = "NORMAL_BG" const DEF_SCROLLBAR_HIGHLIGHT_WIDTH = "0" const DEF_SCROLLBAR_JUMP = "0" const DEF_SCROLLBAR_ORIENT = "vertical" const DEF_SCROLLBAR_RELIEF = "sunken" const DEF_SCROLLBAR_REPEAT_DELAY = "300" const DEF_SCROLLBAR_REPEAT_INTERVAL = "100" const DEF_SCROLLBAR_TAKE_FOCUS = "NULL" const DEF_SCROLLBAR_TROUGH_COLOR = "TROUGH" const DEF_SCROLLBAR_TROUGH_MONO = "WHITE" const DEF_SCROLLBAR_WIDTH = "11" const DEF_TEXT_AUTO_SEPARATORS = "1" const DEF_TEXT_BG_COLOR = "WHITE" const DEF_TEXT_BG_MONO = "WHITE" const DEF_TEXT_BLOCK_CURSOR = "0" const DEF_TEXT_BORDER_WIDTH = "1" const DEF_TEXT_CURSOR = "xterm" const DEF_TEXT_EXPORT_SELECTION = "1" const DEF_TEXT_FG = "BLACK" const DEF_TEXT_FONT = "TkFixedFont" const DEF_TEXT_HEIGHT = "24" const DEF_TEXT_HIGHLIGHT = "BLACK" const DEF_TEXT_HIGHLIGHT_BG = "NORMAL_BG" const DEF_TEXT_HIGHLIGHT_WIDTH = "1" const DEF_TEXT_INACTIVE_SELECT_BG_COLOR = "SELECT_BG" const DEF_TEXT_INSERT_BD_COLOR = "0" const DEF_TEXT_INSERT_BD_MONO = "0" const DEF_TEXT_INSERT_BG = "BLACK" const DEF_TEXT_INSERT_OFF_TIME = "300" const DEF_TEXT_INSERT_ON_TIME = "600" const DEF_TEXT_INSERT_UNFOCUSSED = "none" const DEF_TEXT_INSERT_WIDTH = "2" const DEF_TEXT_MAX_UNDO = "0" const DEF_TEXT_PADX = "1" const DEF_TEXT_PADY = "1" const DEF_TEXT_RELIEF = "sunken" const DEF_TEXT_SELECT_BD_COLOR = "0" const DEF_TEXT_SELECT_BD_MONO = "0" const DEF_TEXT_SELECT_COLOR = "SELECT_BG" const DEF_TEXT_SELECT_FG_COLOR = "BLACK" const DEF_TEXT_SELECT_FG_MONO = "WHITE" const DEF_TEXT_SELECT_MONO = "BLACK" const DEF_TEXT_SELECT_RELIEF = "raised" const DEF_TEXT_SET_GRID = "0" const DEF_TEXT_SPACING1 = "0" const DEF_TEXT_SPACING2 = "0" const DEF_TEXT_SPACING3 = "0" const DEF_TEXT_STATE = "normal" const DEF_TEXT_TABS = "" const DEF_TEXT_TABSTYLE = "tabular" const DEF_TEXT_TAKE_FOCUS = "NULL" const DEF_TEXT_UNDO = "0" const DEF_TEXT_WIDTH = "80" const DEF_TEXT_WRAP = "char" const DEF_TEXT_XSCROLL_COMMAND = "" const DEF_TEXT_YSCROLL_COMMAND = "" const DEF_TOPLEVEL_CLASS = "Toplevel" const DEF_TOPLEVEL_MENU = "" const DEF_TOPLEVEL_SCREEN = "" const DEF_TOPLEVEL_USE = "" const DISABLED = "#a3a3a3" const INDICATOR = "WHITE" const NORMAL_BG = "#d9d9d9" const PLACEHOLDER_FG = "#b3b3b3" const SELECT_BG = "#c3c3c3" const TROUGH = "#b3b3b3" const WHITE = "#ffffff" type TBusy1 = struct { Fdisplay uintptr Finterp uintptr FtkBusy TTk_Window FtkParent TTk_Window FtkRef TTk_Window Fx int32 Fy int32 Fwidth int32 Fheight int32 FmenuBar int32 Fcursor TTk_Cursor FhashPtr uintptr FtablePtr uintptr FoptionTable TTk_OptionTable } type TBusy = struct { Fdisplay uintptr Finterp uintptr FtkBusy TTk_Window FtkParent TTk_Window FtkRef TTk_Window Fx int32 Fy int32 Fwidth int32 Fheight int32 FmenuBar int32 Fcursor TTk_Cursor FhashPtr uintptr FtablePtr uintptr FoptionTable TTk_OptionTable } /* * default.h -- * * This file defines the defaults for all options for all of * the Tk widgets. * * Copyright © 1991-1994 The Regents of the University of California. * Copyright © 1994 Sun Microsystems, Inc. * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. */ /* * tkUnixDefault.h -- * * This file defines the defaults for all options for all of * the Tk widgets. * * Copyright © 1991-1994 The Regents of the University of California. * Copyright © 1994-1997 Sun Microsystems, Inc. * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. */ /* * The definitions below provide symbolic names for the default colors. * NORMAL_BG - Normal background color. * ACTIVE_BG - Background color when widget is active. * SELECT_BG - Background color for selected text. * TROUGH - Background color for troughs in scales and scrollbars. * INDICATOR - Color for indicator when button is selected. * DISABLED - Foreground color when widget is disabled. * PLACEHOLDER_FG - Foreground color for placeholder text. */ /* * Defaults for labels, buttons, checkbuttons, and radiobuttons: */ /* * Defaults for canvases: */ /* * Defaults for entries: */ /* * Defaults for frames: */ /* * Defaults for labelframes: */ /* * Defaults for listboxes: */ /* * Defaults for individual entries of menus: */ /* * Defaults for menus overall: */ /* * Defaults for menubuttons: */ /* * Defaults for messages: */ /* * Defaults for panedwindows */ /* * Defaults for panedwindow panes */ /* * Defaults for scales: */ /* * Defaults for scrollbars: */ /* * Defaults for texts: */ /* * Defaults for canvas text: */ /* * Defaults for canvas items * (arcs, bitmaps, lines, polygons, rectangles, and ovals): */ /* * Defaults for toplevels (most of the defaults for frames also apply * to toplevels): */ /* * Defaults for busy windows: */ /* * Things about the busy system that may be configured. Note that on some * platforms this may or may not have an effect. */ var _busyOptionSpecs = [2]TTk_OptionSpec{ 0: { Ftype1: int32(TK_OPTION_CURSOR), FoptionName: __ccgo_ts + 4638, FdbName: __ccgo_ts + 4646, FdbClass: __ccgo_ts + 4653, FdefValue: __ccgo_ts + 4660, FobjOffset: int64(-libc.Int32FromInt32(1)), FinternalOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 64)), Fflags: int32(TCL_NULL_OK), }, 1: { Ftype1: int32(TK_OPTION_END), }, } /* * The "busy" geometry manager definition. */ var _busyMgrInfo = TTk_GeomMgr{ Fname: __ccgo_ts + 4666, } func init() { p := unsafe.Pointer(&_busyMgrInfo) *(*uintptr)(unsafe.Add(p, 8)) = __ccgo_fp(_BusyGeometryProc) *(*uintptr)(unsafe.Add(p, 16)) = __ccgo_fp(_BusyCustodyProc) } /* * Helper functions, need to check if a Tcl/Tk alternative already exists. */ func _FirstChild(tls *libc.TLS, parent TTk_Window) (r TTk_Window) { var parentPtr uintptr _ = parentPtr parentPtr = parent return (*TTkWindow1)(unsafe.Pointer(parentPtr)).FchildList } func _NextChild(tls *libc.TLS, tkwin TTk_Window) (r TTk_Window) { var winPtr uintptr _ = winPtr winPtr = tkwin if winPtr == libc.UintptrFromInt32(0) { return libc.UintptrFromInt32(0) } return (*TTkWindow1)(unsafe.Pointer(winPtr)).FnextPtr } func _SetWindowInstanceData(tls *libc.TLS, tkwin TTk_Window, instanceData uintptr) { var winPtr uintptr _ = winPtr winPtr = tkwin (*TTkWindow1)(unsafe.Pointer(winPtr)).FinstanceData = instanceData } /* *---------------------------------------------------------------------- * * BusyCustodyProc -- * * This procedure is invoked when the busy window has been stolen by * another geometry manager. The information and memory associated with * the busy window is released. I don't know why anyone would try to pack * a busy window, but this should keep everything sane, if it is. * * Results: * None. * * Side effects: * The Busy structure is freed at the next idle point. * *---------------------------------------------------------------------- */ func _BusyCustodyProc(tls *libc.TLS, clientData uintptr, dummy132 TTk_Window) { /* Not used. */ var busyPtr uintptr _ = busyPtr busyPtr = clientData XTk_DeleteEventHandler(tls, (*TBusy)(unsafe.Pointer(busyPtr)).FtkBusy, libc.Uint64FromInt64(libc.Int64FromInt64(1)<result. * * Side effects: * None. * *---------------------------------------------------------------------- */ func _GetBusy(tls *libc.TLS, interp uintptr, busyTablePtr uintptr, windowObj uintptr) (r uintptr) { bp := tls.Alloc(64) defer tls.Free(64) /* Path name of parent window */ var hPtr uintptr var _ /* tkwin at bp+0 */ TTk_Window _ = hPtr *(*TTk_Window)(unsafe.Pointer(bp)) = XTk_MainWindow(tls, interp) if !(*(*TTk_Window)(unsafe.Pointer(bp)) != 0) || XTkGetWindowFromObj(tls, interp, *(*TTk_Window)(unsafe.Pointer(bp)), windowObj, bp) != TCL_OK { return libc.UintptrFromInt32(0) } hPtr = (*(*func(*libc.TLS, uintptr, uintptr) uintptr)(unsafe.Pointer(&struct{ uintptr }{(*TTcl_HashTable)(unsafe.Pointer(busyTablePtr)).FfindProc})))(tls, busyTablePtr, *(*TTk_Window)(unsafe.Pointer(bp))) if hPtr == libc.UintptrFromInt32(0) { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+4690, libc.VaList(bp+16, libtcl9_0.XTcl_GetStringFromObj(tls, windowObj, libc.UintptrFromInt32(0))))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+16, __ccgo_ts+179, __ccgo_ts+3058, __ccgo_ts+4719, libtcl9_0.XTcl_GetStringFromObj(tls, windowObj, libc.UintptrFromInt32(0)), libc.UintptrFromInt32(0))) return libc.UintptrFromInt32(0) } return (*TTcl_HashEntry)(unsafe.Pointer(hPtr)).FclientData } /* *---------------------------------------------------------------------- * * HoldBusy -- * * Creates (if necessary) and maps a busy window, thereby preventing * device events from being be received by the parent window and its * children. * * Results: * Returns a standard TCL result. If path name represents a busy window, * it is unmapped and TCL_OK is returned. Otherwise, TCL_ERROR is * returned and an error message is left in interp->result. * * Side effects: * The busy window is created and displayed, blocking events from the * parent window and its children. * *---------------------------------------------------------------------- */ func _HoldBusy(tls *libc.TLS, busyTablePtr uintptr, interp uintptr, windowObj uintptr, configObjc TTcl_Size, configObjv uintptr) (r int32) { bp := tls.Alloc(16) defer tls.Free(16) var busyPtr, hPtr uintptr var result int32 var _ /* isNew at bp+8 */ int32 var _ /* tkwin at bp+0 */ TTk_Window _, _, _ = busyPtr, hPtr, result if XTkGetWindowFromObj(tls, interp, XTk_MainWindow(tls, interp), windowObj, bp) != TCL_OK { return int32(TCL_ERROR) } hPtr = (*(*func(*libc.TLS, uintptr, uintptr, uintptr) uintptr)(unsafe.Pointer(&struct{ uintptr }{(*TTcl_HashTable)(unsafe.Pointer(busyTablePtr)).FcreateProc})))(tls, busyTablePtr, *(*TTk_Window)(unsafe.Pointer(bp)), bp+8) if *(*int32)(unsafe.Pointer(bp + 8)) != 0 { busyPtr = _CreateBusy(tls, interp, *(*TTk_Window)(unsafe.Pointer(bp))) if busyPtr == libc.UintptrFromInt32(0) { libtcl9_0.XTcl_DeleteHashEntry(tls, hPtr) return int32(TCL_ERROR) } (*TTcl_HashEntry)(unsafe.Pointer(hPtr)).FclientData = busyPtr (*TBusy)(unsafe.Pointer(busyPtr)).FhashPtr = hPtr } else { busyPtr = (*TTcl_HashEntry)(unsafe.Pointer(hPtr)).FclientData } (*TBusy)(unsafe.Pointer(busyPtr)).FtablePtr = busyTablePtr result = _ConfigureBusy(tls, interp, busyPtr, configObjc, configObjv) /* * Don't map the busy window unless the reference window is also currently * displayed. */ if (*TTk_FakeWin)(unsafe.Pointer((*TBusy)(unsafe.Pointer(busyPtr)).FtkRef)).Fflags&uint32(TK_MAPPED) != 0 { XTkpShowBusyWindow(tls, busyPtr) } else { XTkpHideBusyWindow(tls, busyPtr) } if result == TCL_OK { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewStringObj(tls, (*TTk_FakeWin)(unsafe.Pointer((*TBusy)(unsafe.Pointer(busyPtr)).FtkBusy)).FpathName, int64(-libc.Int32FromInt32(1)))) } return result } /* *---------------------------------------------------------------------- * * Tk_BusyObjCmd -- * * This function is invoked to process the "tk busy" Tcl command. See the * user documentation for details on what it does. * * Results: * A standard Tcl result. * * Side effects: * See the user documentation. * *---------------------------------------------------------------------- */ func XTk_BusyObjCmd(tls *libc.TLS, clientData uintptr, interp uintptr, objc TTcl_Size, objv uintptr) (r int32) { bp := tls.Alloc(48) defer tls.Free(48) /* Argument objects. */ var busyPtr, busyTablePtr, hPtr, objPtr, pattern, v1, v2 uintptr var result int32 var tkwin TTk_Window var _ /* cursor at bp+8 */ TTcl_HashSearch var _ /* index at bp+0 */ int32 _, _, _, _, _, _, _, _, _ = busyPtr, busyTablePtr, hPtr, objPtr, pattern, result, tkwin, v1, v2 tkwin = clientData busyTablePtr = (*TTkWindow)(unsafe.Pointer(tkwin)).FmainPtr + 304 result = TCL_OK if objc < int64(2) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(1), objv, __ccgo_ts+4769) return int32(TCL_ERROR) } /* * [tk busy ] command shortcut. */ if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8)), libc.UintptrFromInt32(0))))) == int32('.') { if objc%int64(2) == int64(1) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(1), objv, __ccgo_ts+4787) return int32(TCL_ERROR) } return _HoldBusy(tls, busyTablePtr, interp, *(*uintptr)(unsafe.Pointer(objv + 1*8)), objc-int64(2), objv+uintptr(2)*8) } if libtcl9_0.XTcl_GetIndexFromObjStruct(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 1*8)), uintptr(unsafe.Pointer(&_optionStrings1)), libc.Int64FromUint64(libc.Uint64FromInt64(8)), __ccgo_ts+2689, libc.Int32FromInt32(0)|libc.Int32FromUint64(libc.Uint64FromInt64(4)< offset { break } scanned += (*TTkClipboardBuffer)(unsafe.Pointer(cbPtr)).Flength goto _1 _1: ; cbPtr = (*TTkClipboardBuffer)(unsafe.Pointer(cbPtr)).FnextPtr } /* * Copy up to maxBytes or end of list, switching buffers as needed. */ freeCount = maxBytes srcPtr = (*TTkClipboardBuffer)(unsafe.Pointer(cbPtr)).Fbuffer + uintptr(offset-scanned) destPtr = buffer length = (*TTkClipboardBuffer)(unsafe.Pointer(cbPtr)).Flength - (offset - scanned) for int32(1) != 0 { if length > freeCount { libc.Xstrncpy(tls, destPtr, srcPtr, libc.Uint64FromInt64(freeCount)) return maxBytes } else { libc.Xstrncpy(tls, destPtr, srcPtr, libc.Uint64FromInt64(length)) destPtr += uintptr(length) count += length freeCount -= length } cbPtr = (*TTkClipboardBuffer)(unsafe.Pointer(cbPtr)).FnextPtr if cbPtr == libc.UintptrFromInt32(0) { break } srcPtr = (*TTkClipboardBuffer)(unsafe.Pointer(cbPtr)).Fbuffer length = (*TTkClipboardBuffer)(unsafe.Pointer(cbPtr)).Flength } return count } /* *---------------------------------------------------------------------- * * ClipboardAppHandler -- * * This function acts as selection handler for retrievals of type * TK_APPLICATION. It returns the name of the application that owns the * clipboard. Note: we can't use the default Tk selection handler for * this selection type, because the clipboard window isn't a "real" * window and doesn't have the necessary information. * * Results: * The return value is a count of the number of bytes actually stored at * buffer. * * Side effects: * None. * *---------------------------------------------------------------------- */ func _ClipboardAppHandler(tls *libc.TLS, clientData uintptr, offset TTcl_Size, buffer uintptr, maxBytes TTcl_Size) (r TTcl_Size) { /* Maximum # of bytes to store at buffer. */ var dispPtr, p uintptr var length TTcl_Size _, _, _ = dispPtr, length, p dispPtr = clientData p = (*TTkWindow1)(unsafe.Pointer((*TTkMainInfo1)(unsafe.Pointer((*TTkDisplay)(unsafe.Pointer(dispPtr)).FclipboardAppPtr)).FwinPtr)).FnameUid length = libc.Int64FromUint64(libc.Xstrlen(tls, p)) if length <= offset { return 0 } length -= offset if length > maxBytes { length = maxBytes } libc.Xmemcpy(tls, buffer, p, libc.Uint64FromInt64(length)) *(*uint8)(unsafe.Pointer(buffer + uintptr(length))) = uint8(0) return length } /* *---------------------------------------------------------------------- * * ClipboardWindowHandler -- * * This function acts as selection handler for retrievals of type * TK_WINDOW. Since the clipboard doesn't correspond to any particular * window, we just return ".". We can't use Tk's default handler for this * selection type, because the clipboard window isn't a valid window. * * Results: * The return value is 1, the number of non-null bytes stored at buffer. * * Side effects: * None. * *---------------------------------------------------------------------- */ func _ClipboardWindowHandler(tls *libc.TLS, dummy176 uintptr, dummy177 TTcl_Size, buffer uintptr, dummy180 TTcl_Size) (r TTcl_Size) { /* Maximum # of bytes to store at buffer. */ *(*uint8)(unsafe.Pointer(buffer)) = uint8('.') *(*uint8)(unsafe.Pointer(buffer + 1)) = uint8(0) return int64(1) } /* *---------------------------------------------------------------------- * * ClipboardLostSel -- * * This function is invoked whenever clipboard ownership is claimed by * another window. It just sets a flag so that we know the clipboard was * taken away. * * Results: * None. * * Side effects: * The clipboard is marked as inactive. * *---------------------------------------------------------------------- */ func _ClipboardLostSel(tls *libc.TLS, clientData uintptr) { /* Pointer to TkDisplay structure. */ var dispPtr uintptr _ = dispPtr dispPtr = clientData (*TTkDisplay)(unsafe.Pointer(dispPtr)).FclipboardActive = 0 } /* *---------------------------------------------------------------------- * * Tk_ClipboardClear -- * * Take control of the clipboard and clear out the previous contents. * This function must be invoked before any calls to Tk_ClipboardAppend. * * Results: * A standard Tcl result. If an error occurs, an error message is left in * the interp's result. * * Side effects: * From now on, requests for the CLIPBOARD selection will be directed to * the clipboard manager routines associated with clipWindow for the * display of tkwin. In order to guarantee atomicity, no event handling * should occur between Tk_ClipboardClear and the following * Tk_ClipboardAppend calls. This function may cause a user-defined * LostSel command to be invoked when the CLIPBOARD is claimed, so any * calling function should be reentrant at the point Tk_ClipboardClear is * invoked. * *---------------------------------------------------------------------- */ func XTk_ClipboardClear(tls *libc.TLS, interp uintptr, tkwin TTk_Window) (r int32) { /* Window in application that is clearing * clipboard; identifies application and * display. */ var cbPtr, dispPtr, nextCbPtr, nextTargetPtr, targetPtr, winPtr uintptr var result int32 _, _, _, _, _, _, _ = cbPtr, dispPtr, nextCbPtr, nextTargetPtr, result, targetPtr, winPtr winPtr = tkwin dispPtr = (*TTkWindow)(unsafe.Pointer(winPtr)).FdispPtr if (*TTkDisplay)(unsafe.Pointer(dispPtr)).FclipWindow == libc.UintptrFromInt32(0) { result = XTkClipInit(tls, interp, dispPtr) if result != TCL_OK { return result } } /* * Discard any existing clipboard data and delete the selection handler(s) * associated with that data. */ targetPtr = (*TTkDisplay)(unsafe.Pointer(dispPtr)).FclipTargetPtr for { if !(targetPtr != libc.UintptrFromInt32(0)) { break } cbPtr = (*TTkClipboardTarget)(unsafe.Pointer(targetPtr)).FfirstBufferPtr for { if !(cbPtr != libc.UintptrFromInt32(0)) { break } libtcl9_0.XTcl_Free(tls, (*TTkClipboardBuffer)(unsafe.Pointer(cbPtr)).Fbuffer) nextCbPtr = (*TTkClipboardBuffer)(unsafe.Pointer(cbPtr)).FnextPtr libtcl9_0.XTcl_Free(tls, cbPtr) goto _2 _2: ; cbPtr = nextCbPtr } nextTargetPtr = (*TTkClipboardTarget)(unsafe.Pointer(targetPtr)).FnextPtr XTk_DeleteSelHandler(tls, (*TTkDisplay)(unsafe.Pointer(dispPtr)).FclipWindow, (*TTkDisplay)(unsafe.Pointer(dispPtr)).FclipboardAtom, (*TTkClipboardTarget)(unsafe.Pointer(targetPtr)).Ftype1) libtcl9_0.XTcl_Free(tls, targetPtr) goto _1 _1: ; targetPtr = nextTargetPtr } (*TTkDisplay)(unsafe.Pointer(dispPtr)).FclipTargetPtr = libc.UintptrFromInt32(0) /* * Reclaim the clipboard selection if we lost it. */ if !((*TTkDisplay)(unsafe.Pointer(dispPtr)).FclipboardActive != 0) { XTk_OwnSelection(tls, (*TTkDisplay)(unsafe.Pointer(dispPtr)).FclipWindow, (*TTkDisplay)(unsafe.Pointer(dispPtr)).FclipboardAtom, __ccgo_fp(_ClipboardLostSel), dispPtr) (*TTkDisplay)(unsafe.Pointer(dispPtr)).FclipboardActive = int32(1) } (*TTkDisplay)(unsafe.Pointer(dispPtr)).FclipboardAppPtr = (*TTkWindow)(unsafe.Pointer(winPtr)).FmainPtr return TCL_OK } /* *---------------------------------------------------------------------- * * Tk_ClipboardAppend -- * * Append a buffer of data to the clipboard. The first buffer of a given * type determines the format for that type. Any successive appends to * that type must have the same format or an error will be returned. * Tk_ClipboardClear must be called before a sequence of * Tk_ClipboardAppend calls can be issued. In order to guarantee * atomicity, no event handling should occur between Tk_ClipboardClear * and the following Tk_ClipboardAppend calls. * * Results: * A standard Tcl result. If an error is returned, an error message is * left in the interp's result. * * Side effects: * The specified buffer will be copied onto the end of the clipboard. * The clipboard maintains a list of buffers which will be used to supply * the data for a selection get request. The first time a given type is * appended, Tk_ClipboardAppend will register a selection handler of the * appropriate type. * *---------------------------------------------------------------------- */ func XTk_ClipboardAppend(tls *libc.TLS, interp uintptr, tkwin TTk_Window, type1 TAtom, format TAtom, buffer uintptr) (r int32) { bp := tls.Alloc(48) defer tls.Free(48) /* NULL terminated string containing the data * to be added to the clipboard. */ var cbPtr, dispPtr, targetPtr, winPtr, v2 uintptr _, _, _, _, _ = cbPtr, dispPtr, targetPtr, winPtr, v2 winPtr = tkwin dispPtr = (*TTkWindow)(unsafe.Pointer(winPtr)).FdispPtr /* * If this application doesn't already own the clipboard, clear the * clipboard. If we don't own the clipboard selection, claim it. */ if (*TTkDisplay)(unsafe.Pointer(dispPtr)).FclipboardAppPtr != (*TTkWindow)(unsafe.Pointer(winPtr)).FmainPtr { XTk_ClipboardClear(tls, interp, tkwin) } else { if !((*TTkDisplay)(unsafe.Pointer(dispPtr)).FclipboardActive != 0) { XTk_OwnSelection(tls, (*TTkDisplay)(unsafe.Pointer(dispPtr)).FclipWindow, (*TTkDisplay)(unsafe.Pointer(dispPtr)).FclipboardAtom, __ccgo_fp(_ClipboardLostSel), dispPtr) (*TTkDisplay)(unsafe.Pointer(dispPtr)).FclipboardActive = int32(1) } } /* * Check to see if the specified target is already present on the * clipboard. If it isn't, we need to create a new target; otherwise, we * just append the new buffer to the clipboard list. */ targetPtr = (*TTkDisplay)(unsafe.Pointer(dispPtr)).FclipTargetPtr for { if !(targetPtr != libc.UintptrFromInt32(0)) { break } if (*TTkClipboardTarget)(unsafe.Pointer(targetPtr)).Ftype1 == type1 { break } goto _1 _1: ; targetPtr = (*TTkClipboardTarget)(unsafe.Pointer(targetPtr)).FnextPtr } if targetPtr == libc.UintptrFromInt32(0) { targetPtr = libtcl9_0.XTcl_Alloc(tls, uint64(40)) (*TTkClipboardTarget)(unsafe.Pointer(targetPtr)).Ftype1 = type1 (*TTkClipboardTarget)(unsafe.Pointer(targetPtr)).Fformat = format v2 = libc.UintptrFromInt32(0) (*TTkClipboardTarget)(unsafe.Pointer(targetPtr)).FlastBufferPtr = v2 (*TTkClipboardTarget)(unsafe.Pointer(targetPtr)).FfirstBufferPtr = v2 (*TTkClipboardTarget)(unsafe.Pointer(targetPtr)).FnextPtr = (*TTkDisplay)(unsafe.Pointer(dispPtr)).FclipTargetPtr (*TTkDisplay)(unsafe.Pointer(dispPtr)).FclipTargetPtr = targetPtr XTk_CreateSelHandler(tls, (*TTkDisplay)(unsafe.Pointer(dispPtr)).FclipWindow, (*TTkDisplay)(unsafe.Pointer(dispPtr)).FclipboardAtom, type1, __ccgo_fp(_ClipboardHandler), targetPtr, format) } else { if (*TTkClipboardTarget)(unsafe.Pointer(targetPtr)).Fformat != format { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+4856, libc.VaList(bp+8, XTk_GetAtomName(tls, tkwin, format), XTk_GetAtomName(tls, tkwin, (*TTkClipboardTarget)(unsafe.Pointer(targetPtr)).Fformat), XTk_GetAtomName(tls, tkwin, type1)))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+8, __ccgo_ts+179, __ccgo_ts+4910, __ccgo_ts+4920, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) } } /* * Append a new buffer to the buffer chain. */ cbPtr = libtcl9_0.XTcl_Alloc(tls, uint64(24)) (*TTkClipboardBuffer)(unsafe.Pointer(cbPtr)).FnextPtr = libc.UintptrFromInt32(0) if (*TTkClipboardTarget)(unsafe.Pointer(targetPtr)).FlastBufferPtr != libc.UintptrFromInt32(0) { (*TTkClipboardBuffer)(unsafe.Pointer((*TTkClipboardTarget)(unsafe.Pointer(targetPtr)).FlastBufferPtr)).FnextPtr = cbPtr } else { (*TTkClipboardTarget)(unsafe.Pointer(targetPtr)).FfirstBufferPtr = cbPtr } (*TTkClipboardTarget)(unsafe.Pointer(targetPtr)).FlastBufferPtr = cbPtr (*TTkClipboardBuffer)(unsafe.Pointer(cbPtr)).Flength = libc.Int64FromUint64(libc.Xstrlen(tls, buffer)) (*TTkClipboardBuffer)(unsafe.Pointer(cbPtr)).Fbuffer = libtcl9_0.XTcl_Alloc(tls, libc.Uint64FromInt64((*TTkClipboardBuffer)(unsafe.Pointer(cbPtr)).Flength+int64(1))) libc.Xstrcpy(tls, (*TTkClipboardBuffer)(unsafe.Pointer(cbPtr)).Fbuffer, buffer) return TCL_OK } /* *---------------------------------------------------------------------- * * Tk_ClipboardObjCmd -- * * This function is invoked to process the "clipboard" Tcl command. See * the user documentation for details on what it does. * * Results: * A standard Tcl result. * * Side effects: * See the user documentation. * *---------------------------------------------------------------------- */ func XTk_ClipboardObjCmd(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) (r int32) { bp := tls.Alloc(304) defer tls.Free(304) /* Argument strings. */ var format, selection, target, target1 TAtom var formatName, path, string1, string11, targetName, targetName1 uintptr var i, result int32 var tkwin TTk_Window var _ /* index at bp+0 */ int32 var _ /* length at bp+8 */ TTcl_Size var _ /* selBytes at bp+24 */ TTcl_DString var _ /* subIndex at bp+16 */ int32 var _ /* subIndex at bp+248 */ int32 var _ /* subIndex at bp+4 */ int32 _, _, _, _, _, _, _, _, _, _, _, _, _ = format, formatName, i, path, result, selection, string1, string11, target, target1, targetName, targetName1, tkwin tkwin = clientData path = libc.UintptrFromInt32(0) if objc < int32(2) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(1), objv, __ccgo_ts+4953) return int32(TCL_ERROR) } if libtcl9_0.XTcl_GetIndexFromObjStruct(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 1*8)), uintptr(unsafe.Pointer(&_optionStrings2)), libc.Int64FromUint64(libc.Uint64FromInt64(8)), __ccgo_ts+2689, libc.Int32FromInt32(0)|libc.Int32FromUint64(libc.Uint64FromInt64(4)<= objc { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+3180, libc.VaList(bp+264, string1))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+264, __ccgo_ts+179, __ccgo_ts+4910, __ccgo_ts+182, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) } switch *(*int32)(unsafe.Pointer(bp + 4)) { case 0: path = libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(i)*8)), libc.UintptrFromInt32(0)) case 1: formatName = libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(i)*8)), libc.UintptrFromInt32(0)) case 2: targetName = libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(i)*8)), libc.UintptrFromInt32(0)) break } goto _1 _1: ; i++ } if objc-i != int32(1) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(2), objv, __ccgo_ts+4995) return int32(TCL_ERROR) } if path != libc.UintptrFromInt32(0) { tkwin = XTk_NameToWindow(tls, interp, path, tkwin) } if tkwin == libc.UintptrFromInt32(0) { return int32(TCL_ERROR) } if targetName != libc.UintptrFromInt32(0) { target = XTk_InternAtom(tls, tkwin, targetName) } else { target = libc.Uint64FromInt32(31) } if formatName != libc.UintptrFromInt32(0) { format = XTk_InternAtom(tls, tkwin, formatName) } else { format = libc.Uint64FromInt32(31) } return XTk_ClipboardAppend(tls, interp, tkwin, target, format, libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(i)*8)), libc.UintptrFromInt32(0))) case 1: if objc != int32(2) && objc != int32(4) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(2), objv, __ccgo_ts+5020) return int32(TCL_ERROR) } if objc == int32(4) { if libtcl9_0.XTcl_GetIndexFromObjStruct(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), uintptr(unsafe.Pointer(&_clearOptionStrings)), libc.Int64FromUint64(libc.Uint64FromInt64(8)), __ccgo_ts+2689, libc.Int32FromInt32(0)|libc.Int32FromUint64(libc.Uint64FromInt64(4)<= objc { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+3180, libc.VaList(bp+264, string11))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+264, __ccgo_ts+179, __ccgo_ts+4910, __ccgo_ts+182, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) } switch *(*int32)(unsafe.Pointer(bp + 248)) { case 0: path = libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(i)*8)), libc.UintptrFromInt32(0)) case 1: targetName1 = libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(i)*8)), libc.UintptrFromInt32(0)) break } goto _2 _2: ; i++ } if path != libc.UintptrFromInt32(0) { tkwin = XTk_NameToWindow(tls, interp, path, tkwin) } if tkwin == libc.UintptrFromInt32(0) { return int32(TCL_ERROR) } selection = XTk_InternAtom(tls, tkwin, __ccgo_ts+4910) if objc-i > int32(1) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(2), objv, __ccgo_ts+5040) return int32(TCL_ERROR) } else { if objc-i == int32(1) { target1 = XTk_InternAtom(tls, tkwin, libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(i)*8)), libc.UintptrFromInt32(0))) } else { if targetName1 != libc.UintptrFromInt32(0) { target1 = XTk_InternAtom(tls, tkwin, targetName1) } else { target1 = libc.Uint64FromInt32(31) } } } libtcl9_0.XTcl_DStringInit(tls, bp+24) result = XTk_GetSelection(tls, interp, tkwin, selection, target1, __ccgo_fp(_ClipboardGetProc), bp+24) if result == TCL_OK { libtcl9_0.XTcl_DStringResult(tls, interp, bp+24) } else { libtcl9_0.XTcl_DStringFree(tls, bp+24) } return result } return TCL_OK } var _optionStrings2 = [4]uintptr{ 0: __ccgo_ts + 4936, 1: __ccgo_ts + 4943, 2: __ccgo_ts + 4949, 3: libc.UintptrFromInt32(0), } var _appendOptionStrings = [4]uintptr{ 0: __ccgo_ts + 4970, 1: __ccgo_ts + 4981, 2: __ccgo_ts + 4989, 3: libc.UintptrFromInt32(0), } var _clearOptionStrings = [2]uintptr{ 0: __ccgo_ts + 4970, 1: libc.UintptrFromInt32(0), } var _getOptionStrings = [3]uintptr{ 0: __ccgo_ts + 4970, 1: __ccgo_ts + 4989, 2: libc.UintptrFromInt32(0), } /* *---------------------------------------------------------------------- * * TkClipInit -- * * This function is called to initialize the window for claiming * clipboard ownership and for receiving selection get results. This * function is called from tkSelect.c as well as tkClipboard.c. * * Results: * The result is a standard Tcl return value, which is normally TCL_OK. * If an error occurs then an error message is left in the interp's * result and TCL_ERROR is returned. * * Side effects: * Sets up the clipWindow and related data structures. * *---------------------------------------------------------------------- */ func XTkClipInit(tls *libc.TLS, dummy640 uintptr, dispPtr uintptr) (r int32) { bp := tls.Alloc(112) defer tls.Free(112) /* Display to initialize. */ var _ /* atts at bp+0 */ TXSetWindowAttributes (*TTkDisplay)(unsafe.Pointer(dispPtr)).FclipTargetPtr = libc.UintptrFromInt32(0) (*TTkDisplay)(unsafe.Pointer(dispPtr)).FclipboardActive = 0 (*TTkDisplay)(unsafe.Pointer(dispPtr)).FclipboardAppPtr = libc.UintptrFromInt32(0) /* * Create the window used for clipboard ownership and selection retrieval, * and set up an event handler for it. */ (*TTkDisplay)(unsafe.Pointer(dispPtr)).FclipWindow = XTkAllocWindow(tls, dispPtr, (*struct { Fext_data uintptr Fprivate1 uintptr Ffd int32 Fprivate2 int32 Fproto_major_version int32 Fproto_minor_version int32 Fvendor uintptr Fprivate3 TXID Fprivate4 TXID Fprivate5 TXID Fprivate6 int32 Fresource_alloc uintptr Fbyte_order int32 Fbitmap_unit int32 Fbitmap_pad int32 Fbitmap_bit_order int32 Fnformats int32 Fpixmap_format uintptr Fprivate8 int32 Frelease int32 Fprivate9 uintptr Fprivate10 uintptr Fqlen int32 Flast_request_read uint64 Frequest uint64 Fprivate11 TXPointer Fprivate12 TXPointer Fprivate13 TXPointer Fprivate14 TXPointer Fmax_request_size uint32 Fdb uintptr Fprivate15 uintptr Fdisplay_name uintptr Fdefault_screen int32 Fnscreens int32 Fscreens uintptr Fmotion_buffer uint64 Fprivate16 uint64 Fmin_keycode int32 Fmax_keycode int32 Fprivate17 TXPointer Fprivate18 TXPointer Fprivate19 int32 Fxdefaults uintptr })(unsafe.Pointer((*TTkDisplay)(unsafe.Pointer(dispPtr)).Fdisplay)).Fdefault_screen, libc.UintptrFromInt32(0)) libtcl9_0.XTcl_Preserve(tls, (*TTkDisplay)(unsafe.Pointer(dispPtr)).FclipWindow) *(*uint32)(unsafe.Pointer((*TTkDisplay)(unsafe.Pointer(dispPtr)).FclipWindow + 280)) |= libc.Uint32FromInt32(libc.Int32FromInt32(TK_TOP_HIERARCHY) | libc.Int32FromInt32(TK_TOP_LEVEL) | libc.Int32FromInt32(TK_HAS_WRAPPER) | libc.Int32FromInt32(TK_WIN_MANAGED)) XTkWmNewWindow(tls, (*TTkDisplay)(unsafe.Pointer(dispPtr)).FclipWindow) (*(*TXSetWindowAttributes)(unsafe.Pointer(bp))).Foverride_redirect = int32(True) XTk_ChangeWindowAttributes(tls, (*TTkDisplay)(unsafe.Pointer(dispPtr)).FclipWindow, libc.Uint64FromInt64(libc.Int64FromInt64(1)< int32(4)) { goto _1 } goto wrongArgs wrongArgs: ; libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(1), objv, __ccgo_ts+5147) return int32(TCL_ERROR) _1: ; i = int64(1) for { if !(i < int64(objc)) { break } if libtcl9_0.XTcl_GetIndexFromObjStruct(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(i)*8)), uintptr(unsafe.Pointer(&_bellOptions)), libc.Int64FromUint64(libc.Uint64FromInt64(8)), __ccgo_ts+2689, libc.Int32FromInt32(0)|libc.Int32FromUint64(libc.Uint64FromInt64(4)<= int64(objc) { goto wrongArgs } tkwin = XTk_NameToWindow(tls, interp, libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(i)*8)), libc.UintptrFromInt32(0)), tkwin) if tkwin == libc.UintptrFromInt32(0) { return int32(TCL_ERROR) } case 1: nice = int32(1) break } goto _2 _2: ; i++ } handler = XTk_CreateErrorHandler(tls, (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fdisplay, -int32(1), -int32(1), -int32(1), libc.UintptrFromInt32(0), libc.UintptrFromInt32(0)) libx11.XXBell(tls, (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fdisplay, 0) if !(nice != 0) { libx11.XXForceScreenSaver(tls, (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fdisplay, ScreenSaverReset) } libx11.XXFlush(tls, (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fdisplay) XTk_DeleteErrorHandler(tls, handler) return TCL_OK } var _bellOptions = [3]uintptr{ 0: __ccgo_ts + 4970, 1: __ccgo_ts + 5141, 2: libc.UintptrFromInt32(0), } /* *---------------------------------------------------------------------- * * Tk_BindObjCmd -- * * This function is invoked to process the "bind" Tcl command. See the * user documentation for details on what it does. * * Results: * A standard Tcl result. * * Side effects: * See the user documentation. * *---------------------------------------------------------------------- */ func XTk_BindObjCmd(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) (r int32) { /* Argument objects. */ var append1 int32 var command, object, script, sequence, string1, winPtr uintptr var mask uint64 var tkwin TTk_Window _, _, _, _, _, _, _, _, _ = append1, command, mask, object, script, sequence, string1, tkwin, winPtr tkwin = clientData if objc < int32(2) || objc > int32(4) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(1), objv, __ccgo_ts+5175) return int32(TCL_ERROR) } string1 = libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8)), libc.UintptrFromInt32(0)) /* * Bind tags either a window name or a tag name for the first argument. * If the argument starts with ".", assume it is a window; otherwise, it * is a tag. */ if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(string1))) == int32('.') { winPtr = XTk_NameToWindow(tls, interp, string1, tkwin) if winPtr == libc.UintptrFromInt32(0) { return int32(TCL_ERROR) } object = (*TTkWindow)(unsafe.Pointer(winPtr)).FpathName } else { winPtr = clientData object = XTk_GetUid(tls, string1) } /* * If there are four arguments, the command is modifying a binding. If * there are three arguments, the command is querying a binding. If there * are only two arguments, the command is querying all the bindings for * the given tag/window. */ if objc == int32(4) { append1 = 0 sequence = libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8)), libc.UintptrFromInt32(0)) script = libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 3*8)), libc.UintptrFromInt32(0)) /* * If the script is null, just delete the binding. */ if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(script))) == 0 { return XTk_DeleteBinding(tls, interp, (*TTkMainInfo)(unsafe.Pointer((*TTkWindow)(unsafe.Pointer(winPtr)).FmainPtr)).FbindingTable, object, sequence) } /* * If the script begins with "+", append this script to the existing * binding. */ if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(script))) == int32('+') { script++ append1 = int32(1) } mask = XTk_CreateBinding(tls, interp, (*TTkMainInfo)(unsafe.Pointer((*TTkWindow)(unsafe.Pointer(winPtr)).FmainPtr)).FbindingTable, object, sequence, script, append1) if mask == uint64(0) { return int32(TCL_ERROR) } } else { if objc == int32(3) { command = XTk_GetBinding(tls, interp, (*TTkMainInfo)(unsafe.Pointer((*TTkWindow)(unsafe.Pointer(winPtr)).FmainPtr)).FbindingTable, object, libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8)), libc.UintptrFromInt32(0))) if command == libc.UintptrFromInt32(0) { libtcl9_0.XTcl_ResetResult(tls, interp) return TCL_OK } libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewStringObj(tls, command, int64(-libc.Int32FromInt32(1)))) } else { XTk_GetAllBindings(tls, interp, (*TTkMainInfo)(unsafe.Pointer((*TTkWindow)(unsafe.Pointer(winPtr)).FmainPtr)).FbindingTable, object) } } return TCL_OK } /* *---------------------------------------------------------------------- * * TkBindEventProc -- * * This function is invoked by Tk_HandleEvent for each event; it causes * any appropriate bindings for that event to be invoked. * * Results: * None. * * Side effects: * Depends on what bindings have been established with the "bind" * command. * *---------------------------------------------------------------------- */ func XTkBindEventProc(tls *libc.TLS, winPtr uintptr, eventPtr uintptr) { bp := tls.Alloc(160) defer tls.Free(160) /* Information about event. */ var count, i TTcl_Size var hPtr, objPtr, p, topLevPtr uintptr var _ /* objects at bp+0 */ [20]uintptr _, _, _, _, _, _ = count, hPtr, i, objPtr, p, topLevPtr if (*TTkWindow)(unsafe.Pointer(winPtr)).FmainPtr == libc.UintptrFromInt32(0) || (*TTkMainInfo)(unsafe.Pointer((*TTkWindow)(unsafe.Pointer(winPtr)).FmainPtr)).FbindingTable == libc.UintptrFromInt32(0) { return } objPtr = bp if (*TTkWindow)(unsafe.Pointer(winPtr)).FnumTags != 0 { /* * Make a copy of the tags for the window, replacing window names with * pointers to the pathName from the appropriate window. */ if (*TTkWindow)(unsafe.Pointer(winPtr)).FnumTags > int64(MAX_OBJS) { objPtr = libtcl9_0.XTcl_Alloc(tls, libc.Uint64FromInt64((*TTkWindow)(unsafe.Pointer(winPtr)).FnumTags)*uint64(8)) } i = 0 for { if !(i < (*TTkWindow)(unsafe.Pointer(winPtr)).FnumTags) { break } p = *(*uintptr)(unsafe.Pointer((*TTkWindow)(unsafe.Pointer(winPtr)).FtagPtr + uintptr(i)*8)) if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(p))) == int32('.') { hPtr = (*(*func(*libc.TLS, uintptr, uintptr) uintptr)(unsafe.Pointer(&struct{ uintptr }{(*TTcl_HashTable)(unsafe.Pointer((*TTkWindow)(unsafe.Pointer(winPtr)).FmainPtr + 24)).FfindProc})))(tls, (*TTkWindow)(unsafe.Pointer(winPtr)).FmainPtr+24, p) if hPtr != libc.UintptrFromInt32(0) { p = (*TTkWindow)(unsafe.Pointer((*TTcl_HashEntry)(unsafe.Pointer(hPtr)).FclientData)).FpathName } else { p = libc.UintptrFromInt32(0) } } *(*uintptr)(unsafe.Pointer(objPtr + uintptr(i)*8)) = p goto _1 _1: ; i++ } count = (*TTkWindow)(unsafe.Pointer(winPtr)).FnumTags } else { *(*uintptr)(unsafe.Pointer(objPtr)) = (*TTkWindow)(unsafe.Pointer(winPtr)).FpathName *(*uintptr)(unsafe.Pointer(objPtr + 1*8)) = (*TTkWindow)(unsafe.Pointer(winPtr)).FclassUid topLevPtr = winPtr for { if !(topLevPtr != libc.UintptrFromInt32(0) && !((*TTkWindow)(unsafe.Pointer(topLevPtr)).Fflags&libc.Uint32FromInt32(TK_TOP_HIERARCHY) != 0)) { break } /* Empty loop body. */ goto _2 _2: ; topLevPtr = (*TTkWindow)(unsafe.Pointer(topLevPtr)).FparentPtr } if winPtr != topLevPtr && topLevPtr != libc.UintptrFromInt32(0) { count = int64(4) *(*uintptr)(unsafe.Pointer(objPtr + 2*8)) = (*TTkWindow)(unsafe.Pointer(topLevPtr)).FpathName } else { count = int64(3) } *(*uintptr)(unsafe.Pointer(objPtr + uintptr(count-int64(1))*8)) = XTk_GetUid(tls, __ccgo_ts+5202) } XTk_BindEvent(tls, (*TTkMainInfo)(unsafe.Pointer((*TTkWindow)(unsafe.Pointer(winPtr)).FmainPtr)).FbindingTable, eventPtr, winPtr, count, objPtr) if objPtr != bp { libtcl9_0.XTcl_Free(tls, objPtr) } } /* *---------------------------------------------------------------------- * * Tk_BindtagsObjCmd -- * * This function is invoked to process the "bindtags" Tcl command. See * the user documentation for details on what it does. * * Results: * A standard Tcl result. * * Side effects: * See the user documentation. * *---------------------------------------------------------------------- */ func XTk_BindtagsObjCmd(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) (r int32) { bp := tls.Alloc(16) defer tls.Free(16) /* Argument objects. */ var copy1, listPtr, p, winPtr, winPtr2 uintptr var i TTcl_Size var tkwin TTk_Window var _ /* length at bp+0 */ TTcl_Size var _ /* tags at bp+8 */ uintptr _, _, _, _, _, _, _ = copy1, i, listPtr, p, tkwin, winPtr, winPtr2 tkwin = clientData if objc < int32(2) || objc > int32(3) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(1), objv, __ccgo_ts+5206) return int32(TCL_ERROR) } winPtr = XTk_NameToWindow(tls, interp, libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8)), libc.UintptrFromInt32(0)), tkwin) if winPtr == libc.UintptrFromInt32(0) { return int32(TCL_ERROR) } if objc == int32(2) { listPtr = libtcl9_0.XTcl_NewObj(tls) if (*TTkWindow)(unsafe.Pointer(winPtr)).FnumTags == 0 { libtcl9_0.XTcl_ListObjAppendElement(tls, libc.UintptrFromInt32(0), listPtr, libtcl9_0.XTcl_NewStringObj(tls, (*TTkWindow)(unsafe.Pointer(winPtr)).FpathName, int64(-libc.Int32FromInt32(1)))) libtcl9_0.XTcl_ListObjAppendElement(tls, libc.UintptrFromInt32(0), listPtr, libtcl9_0.XTcl_NewStringObj(tls, (*TTkWindow)(unsafe.Pointer(winPtr)).FclassUid, int64(-libc.Int32FromInt32(1)))) winPtr2 = winPtr for winPtr2 != libc.UintptrFromInt32(0) && !((*TTk_FakeWin)(unsafe.Pointer(winPtr2)).Fflags&libc.Uint32FromInt32(TK_TOP_HIERARCHY) != 0) { winPtr2 = (*TTkWindow)(unsafe.Pointer(winPtr2)).FparentPtr } if winPtr != winPtr2 && winPtr2 != libc.UintptrFromInt32(0) { libtcl9_0.XTcl_ListObjAppendElement(tls, libc.UintptrFromInt32(0), listPtr, libtcl9_0.XTcl_NewStringObj(tls, (*TTkWindow)(unsafe.Pointer(winPtr2)).FpathName, int64(-libc.Int32FromInt32(1)))) } libtcl9_0.XTcl_ListObjAppendElement(tls, libc.UintptrFromInt32(0), listPtr, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+5202, int64(-libc.Int32FromInt32(1)))) } else { i = 0 for { if !(i < (*TTkWindow)(unsafe.Pointer(winPtr)).FnumTags) { break } libtcl9_0.XTcl_ListObjAppendElement(tls, libc.UintptrFromInt32(0), listPtr, libtcl9_0.XTcl_NewStringObj(tls, *(*uintptr)(unsafe.Pointer((*TTkWindow)(unsafe.Pointer(winPtr)).FtagPtr + uintptr(i)*8)), int64(-libc.Int32FromInt32(1)))) goto _1 _1: ; i++ } } libtcl9_0.XTcl_SetObjResult(tls, interp, listPtr) return TCL_OK } if (*TTkWindow)(unsafe.Pointer(winPtr)).FtagPtr != libc.UintptrFromInt32(0) { XTkFreeBindingTags(tls, winPtr) } if libtcl9_0.XTcl_ListObjGetElements(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp, bp+8) != TCL_OK { return int32(TCL_ERROR) } if *(*TTcl_Size)(unsafe.Pointer(bp)) == 0 { return TCL_OK } (*TTkWindow)(unsafe.Pointer(winPtr)).FnumTags = *(*TTcl_Size)(unsafe.Pointer(bp)) (*TTkWindow)(unsafe.Pointer(winPtr)).FtagPtr = libtcl9_0.XTcl_Alloc(tls, libc.Uint64FromInt64(*(*TTcl_Size)(unsafe.Pointer(bp)))*uint64(8)) i = 0 for { if !(i < *(*TTcl_Size)(unsafe.Pointer(bp))) { break } p = libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 8)) + uintptr(i)*8)), libc.UintptrFromInt32(0)) if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(p))) == int32('.') { /* * Handle names starting with "." specially: store a malloc'ed * string, rather than a Uid; at event time we'll look up the name * in the window table and use the corresponding window, if there * is one. */ copy1 = libtcl9_0.XTcl_Alloc(tls, libc.Xstrlen(tls, p)+uint64(1)) libc.Xstrcpy(tls, copy1, p) *(*uintptr)(unsafe.Pointer((*TTkWindow)(unsafe.Pointer(winPtr)).FtagPtr + uintptr(i)*8)) = copy1 } else { *(*uintptr)(unsafe.Pointer((*TTkWindow)(unsafe.Pointer(winPtr)).FtagPtr + uintptr(i)*8)) = XTk_GetUid(tls, p) } goto _2 _2: ; i++ } return TCL_OK } /* *---------------------------------------------------------------------- * * TkFreeBindingTags -- * * This function is called to free all of the binding tags associated * with a window; typically it is only invoked where there are * window-specific tags. * * Results: * None. * * Side effects: * Any binding tags for winPtr are freed. * *---------------------------------------------------------------------- */ func XTkFreeBindingTags(tls *libc.TLS, winPtr uintptr) { /* Window whose tags are to be released. */ var i TTcl_Size var p uintptr _, _ = i, p i = 0 for { if !(i < (*TTkWindow)(unsafe.Pointer(winPtr)).FnumTags) { break } p = *(*uintptr)(unsafe.Pointer((*TTkWindow)(unsafe.Pointer(winPtr)).FtagPtr + uintptr(i)*8)) if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(p))) == int32('.') { /* * Names starting with "." are malloced rather than Uids, so they * have to be freed. */ libtcl9_0.XTcl_Free(tls, p) } goto _1 _1: ; i++ } libtcl9_0.XTcl_Free(tls, (*TTkWindow)(unsafe.Pointer(winPtr)).FtagPtr) (*TTkWindow)(unsafe.Pointer(winPtr)).FnumTags = 0 (*TTkWindow)(unsafe.Pointer(winPtr)).FtagPtr = libc.UintptrFromInt32(0) } /* *---------------------------------------------------------------------- * * Tk_DestroyObjCmd -- * * This function is invoked to process the "destroy" Tcl command. See the * user documentation for details on what it does. * * Results: * A standard Tcl result. * * Side effects: * See the user documentation. * *---------------------------------------------------------------------- */ func XTk_DestroyObjCmd(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) (r int32) { /* Argument objects. */ var i TTcl_Size var tkwin, window TTk_Window _, _, _ = i, tkwin, window tkwin = clientData i = int64(1) for { if !(i < int64(objc)) { break } window = XTk_NameToWindow(tls, interp, libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(i)*8)), libc.UintptrFromInt32(0)), tkwin) if window == libc.UintptrFromInt32(0) { libtcl9_0.XTcl_ResetResult(tls, interp) goto _1 } XTk_DestroyWindow(tls, window) if window == tkwin { /* * We just deleted the main window for the application! This makes * it impossible to do anything more (tkwin isn't valid anymore). */ break } goto _1 _1: ; i++ } return TCL_OK } /* *---------------------------------------------------------------------- * * Tk_LowerObjCmd -- * * This function is invoked to process the "lower" Tcl command. See the * user documentation for details on what it does. * * Results: * A standard Tcl result. * * Side effects: * See the user documentation. * *---------------------------------------------------------------------- */ func XTk_LowerObjCmd(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) (r int32) { bp := tls.Alloc(48) defer tls.Free(48) /* Argument objects. */ var mainwin, other, tkwin TTk_Window _, _, _ = mainwin, other, tkwin mainwin = clientData if objc != int32(2) && objc != int32(3) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(1), objv, __ccgo_ts+5223) return int32(TCL_ERROR) } tkwin = XTk_NameToWindow(tls, interp, libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8)), libc.UintptrFromInt32(0)), mainwin) if tkwin == libc.UintptrFromInt32(0) { return int32(TCL_ERROR) } if objc == int32(2) { other = libc.UintptrFromInt32(0) } else { other = XTk_NameToWindow(tls, interp, libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8)), libc.UintptrFromInt32(0)), mainwin) if other == libc.UintptrFromInt32(0) { return int32(TCL_ERROR) } } if XTk_RestackWindow(tls, tkwin, int32(Below), other) != TCL_OK { if other != 0 { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+5242, libc.VaList(bp+8, libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8)), libc.UintptrFromInt32(0)), libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8)), libc.UintptrFromInt32(0))))) } else { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+5270, libc.VaList(bp+8, libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8)), libc.UintptrFromInt32(0))))) } libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+8, __ccgo_ts+179, __ccgo_ts+5297, __ccgo_ts+5305, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) } return TCL_OK } /* *---------------------------------------------------------------------- * * Tk_RaiseObjCmd -- * * This function is invoked to process the "raise" Tcl command. See the * user documentation for details on what it does. * * Results: * A standard Tcl result. * * Side effects: * See the user documentation. * *---------------------------------------------------------------------- */ func XTk_RaiseObjCmd(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) (r int32) { bp := tls.Alloc(48) defer tls.Free(48) /* Argument objects. */ var mainwin, other, tkwin TTk_Window _, _, _ = mainwin, other, tkwin mainwin = clientData if objc != int32(2) && objc != int32(3) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(1), objv, __ccgo_ts+5311) return int32(TCL_ERROR) } tkwin = XTk_NameToWindow(tls, interp, libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8)), libc.UintptrFromInt32(0)), mainwin) if tkwin == libc.UintptrFromInt32(0) { return int32(TCL_ERROR) } if objc == int32(2) { other = libc.UintptrFromInt32(0) } else { other = XTk_NameToWindow(tls, interp, libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8)), libc.UintptrFromInt32(0)), mainwin) if other == libc.UintptrFromInt32(0) { return int32(TCL_ERROR) } } if XTk_RestackWindow(tls, tkwin, Above, other) != TCL_OK { if other != 0 { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+5330, libc.VaList(bp+8, libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8)), libc.UintptrFromInt32(0)), libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8)), libc.UintptrFromInt32(0))))) } else { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+5358, libc.VaList(bp+8, libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8)), libc.UintptrFromInt32(0))))) } libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+8, __ccgo_ts+179, __ccgo_ts+5297, __ccgo_ts+5382, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) } return TCL_OK } /* * ---------------------------------------------------------------------- * * TkInitTkCmd -- * * Set up the tk ensemble. * * Results: * A standard Tcl result. * * Side effects: * None. * * ---------------------------------------------------------------------- */ func XTkInitTkCmd(tls *libc.TLS, interp uintptr, clientData uintptr) (r int32) { var isSafe int32 _ = isSafe /* If the interp is safe, leave out "fontchooser" */ isSafe = libtcl9_0.XTcl_IsSafe(tls, interp) XTkMakeEnsemble(tls, interp, __ccgo_ts+5388, __ccgo_ts+5391, clientData, uintptr(unsafe.Pointer(&_tkCmdMap))+uintptr(isSafe)*24) return TCL_OK } /* *---------------------------------------------------------------------- * * AppnameCmd, CaretCmd, ScalingCmd, UseinputmethodsCmd, * WindowingsystemCmd, InactiveCmd -- * * These functions are invoked to process the "tk" ensemble subcommands. * See the user documentation for details on what they do. * * Results: * A standard Tcl result. * * Side effects: * See the user documentation. * *---------------------------------------------------------------------- */ func _AppnameCmd(tls *libc.TLS, clientData uintptr, interp uintptr, objc TTcl_Size, objv uintptr) (r int32) { bp := tls.Alloc(48) defer tls.Free(48) /* Argument objects. */ var string1, winPtr uintptr var tkwin TTk_Window _, _, _ = string1, tkwin, winPtr tkwin = clientData if libtcl9_0.XTcl_IsSafe(tls, interp) != 0 { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+5394, int64(-libc.Int32FromInt32(1)))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+8, __ccgo_ts+179, __ccgo_ts+4089, __ccgo_ts+5439, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) } winPtr = tkwin if objc == int64(2) { string1 = libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8)), libc.UintptrFromInt32(0)) (*TTkWindow)(unsafe.Pointer(winPtr)).FnameUid = XTk_GetUid(tls, XTk_SetAppName(tls, tkwin, string1)) } else { if objc != int64(1) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(1), objv, __ccgo_ts+5451) return int32(TCL_ERROR) } } libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewStringObj(tls, (*TTkWindow)(unsafe.Pointer(winPtr)).FnameUid, int64(-libc.Int32FromInt32(1)))) return TCL_OK } func _CaretCmd(tls *libc.TLS, clientData uintptr, interp uintptr, objc TTcl_Size, objv uintptr) (r int32) { bp := tls.Alloc(16) defer tls.Free(16) /* Argument objects. */ var caretPtr, objPtr uintptr var height, value, x, y int32 var i TTcl_Size var tkwin, window TTk_Window var _ /* index at bp+0 */ int32 var _ /* value at bp+4 */ int32 _, _, _, _, _, _, _, _, _ = caretPtr, height, i, objPtr, tkwin, value, window, x, y tkwin = clientData if objc < int64(2) || objc > int64(3) && !!(objc&libc.Int64FromInt32(1) != 0) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(1), objv, __ccgo_ts+5461) return int32(TCL_ERROR) } window = XTk_NameToWindow(tls, interp, libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8)), libc.UintptrFromInt32(0)), tkwin) if window == libc.UintptrFromInt32(0) { return int32(TCL_ERROR) } caretPtr = (*TTkWindow)(unsafe.Pointer(window)).FdispPtr + 2640 if objc == int64(2) { /* * Return all the current values */ objPtr = libtcl9_0.XTcl_NewObj(tls) libtcl9_0.XTcl_ListObjAppendElement(tls, interp, objPtr, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+2870, int64(7))) libtcl9_0.XTcl_ListObjAppendElement(tls, interp, objPtr, libtcl9_0.XTcl_NewWideIntObj(tls, int64((*TTkCaret)(unsafe.Pointer(caretPtr)).Fheight))) libtcl9_0.XTcl_ListObjAppendElement(tls, interp, objPtr, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+3002, int64(2))) libtcl9_0.XTcl_ListObjAppendElement(tls, interp, objPtr, libtcl9_0.XTcl_NewWideIntObj(tls, int64((*TTkCaret)(unsafe.Pointer(caretPtr)).Fx))) libtcl9_0.XTcl_ListObjAppendElement(tls, interp, objPtr, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+3005, int64(2))) libtcl9_0.XTcl_ListObjAppendElement(tls, interp, objPtr, libtcl9_0.XTcl_NewWideIntObj(tls, int64((*TTkCaret)(unsafe.Pointer(caretPtr)).Fy))) libtcl9_0.XTcl_SetObjResult(tls, interp, objPtr) } else { if objc == int64(3) { /* * Return the current value of the selected option */ if libtcl9_0.XTcl_GetIndexFromObjStruct(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), uintptr(unsafe.Pointer(&_caretStrings)), libc.Int64FromUint64(libc.Uint64FromInt64(8)), __ccgo_ts+5499, libc.Int32FromInt32(0)|libc.Int32FromUint64(libc.Uint64FromInt64(4)<= int64(2) && libc.Xstrncmp(tls, string1, __ccgo_ts+4970, libc.Uint64FromInt64(*(*TTcl_Size)(unsafe.Pointer(bp)))) == 0 { if objc < int64(2) { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+6810, int64(-libc.Int32FromInt32(1)))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+16, __ccgo_ts+179, __ccgo_ts+6841, __ccgo_ts+6850, libc.UintptrFromInt32(0))) return int64(-libc.Int32FromInt32(1)) } *(*TTk_Window)(unsafe.Pointer(tkwinPtr)) = XTk_NameToWindow(tls, interp, libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8)), libc.UintptrFromInt32(0)), *(*TTk_Window)(unsafe.Pointer(tkwinPtr))) if *(*TTk_Window)(unsafe.Pointer(tkwinPtr)) == libc.UintptrFromInt32(0) { return int64(-libc.Int32FromInt32(1)) } return int64(2) } return 0 } /* *---------------------------------------------------------------------- * * TkDeadAppObjCmd -- * * If an application has been deleted then all Tk commands will be * re-bound to this function. * * Results: * A standard Tcl error is reported to let the user know that the * application is dead. * * Side effects: * See the user documentation. * *---------------------------------------------------------------------- */ func XTkDeadAppObjCmd(tls *libc.TLS, dummy1933 uintptr, interp uintptr, dummy1935 int32, objv uintptr) (r int32) { bp := tls.Alloc(16) defer tls.Free(16) /* Argument strings. */ libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+6860, libc.VaList(bp+8, libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv)), libc.UintptrFromInt32(0))))) return int32(TCL_ERROR) } /* *---------------------------------------------------------------------- * * GetTopHierarchy -- * * Retrieves the top-of-hierarchy window which is the nearest ancestor of * the specified window. * * Results: * Returns the top-of-hierarchy window, or NULL if the window has no * ancestor which is at the top of a physical window hierarchy. * * Side effects: * None. * *---------------------------------------------------------------------- */ func _GetTopHierarchy(tls *libc.TLS, tkwin TTk_Window) (r uintptr) { /* Window for which the top-of-hierarchy * ancestor should be determined. */ var winPtr uintptr _ = winPtr winPtr = tkwin for winPtr != libc.UintptrFromInt32(0) && !((*TTkWindow)(unsafe.Pointer(winPtr)).Fflags&libc.Uint32FromInt32(TK_TOP_HIERARCHY) != 0) { winPtr = (*TTkWindow)(unsafe.Pointer(winPtr)).FparentPtr } return winPtr } const TK_COLOR_BY_NAME = 1 const TK_COLOR_BY_VALUE = 2 type TTkColor = struct { Fcolor TXColor Fmagic uint32 Fgc TGC Fscreen uintptr Fcolormap TColormap Fvisual uintptr FresourceRefCount TTcl_Size FobjRefCount TTcl_Size Ftype1 int32 FhashPtr uintptr FnextPtr uintptr } /* * Structures of the following following type are used as keys for * colorValueTable (in TkDisplay). */ type TValueKey = struct { Fred int32 Fgreen int32 Fblue int32 Fcolormap TColormap Fdisplay uintptr } /* * The structure below is used to allocate thread-local data. */ type TThreadSpecificData1 = struct { FrgbString [20]uint8 } var _dataKey1 TTcl_ThreadDataKey func init() { p := unsafe.Pointer(&XtkColorObjType) *(*uintptr)(unsafe.Add(p, 8)) = __ccgo_fp(_FreeColorObjProc) *(*uintptr)(unsafe.Add(p, 16)) = __ccgo_fp(_DupColorObjProc) *(*uintptr)(unsafe.Add(p, 48)) = __ccgo_fp(XTkLengthOne) } /* *---------------------------------------------------------------------- * * Tk_AllocColorFromObj -- * * Given a Tcl_Obj *, map the value to a corresponding XColor structure * based on the tkwin given. * * Results: * The return value is a pointer to an XColor structure that indicates * the red, blue, and green intensities for the color given by the string * in objPtr, and also specifies a pixel value to use to draw in that * color. If an error occurs, NULL is returned and an error message will * be left in interp's result (unless interp is NULL). * * Side effects: * The color is added to an internal database with a reference count. For * each call to this function, there should eventually be a call to * Tk_FreeColorFromObj so that the database is cleaned up when colors * aren't in use anymore. * *---------------------------------------------------------------------- */ func XTk_AllocColorFromObj(tls *libc.TLS, interp uintptr, tkwin TTk_Window, objPtr uintptr) (r uintptr) { /* Object that describes the color; string * value is a color name such as "red" or * "#ff0000".*/ var firstColorPtr, tkColPtr uintptr _, _ = firstColorPtr, tkColPtr if (*TTcl_Obj)(unsafe.Pointer(objPtr)).FtypePtr != uintptr(unsafe.Pointer(&XtkColorObjType)) { _InitColorObj(tls, objPtr) } tkColPtr = (*(*struct { Fptr1 uintptr Fptr2 uintptr })(unsafe.Pointer(objPtr + 32))).Fptr1 /* * If the object currently points to a TkColor, see if it's the one we * want. If so, increment its reference count and return. */ if tkColPtr != libc.UintptrFromInt32(0) { if (*TTkColor)(unsafe.Pointer(tkColPtr)).FresourceRefCount == 0 { /* * This is a stale reference: it refers to a TkColor that's no * longer in use. Clear the reference. */ _FreeColorObj(tls, objPtr) tkColPtr = libc.UintptrFromInt32(0) } else { if (*struct { Fext_data uintptr Fprivate1 uintptr Ffd int32 Fprivate2 int32 Fproto_major_version int32 Fproto_minor_version int32 Fvendor uintptr Fprivate3 TXID Fprivate4 TXID Fprivate5 TXID Fprivate6 int32 Fresource_alloc uintptr Fbyte_order int32 Fbitmap_unit int32 Fbitmap_pad int32 Fbitmap_bit_order int32 Fnformats int32 Fpixmap_format uintptr Fprivate8 int32 Frelease int32 Fprivate9 uintptr Fprivate10 uintptr Fqlen int32 Flast_request_read uint64 Frequest uint64 Fprivate11 TXPointer Fprivate12 TXPointer Fprivate13 TXPointer Fprivate14 TXPointer Fmax_request_size uint32 Fdb uintptr Fprivate15 uintptr Fdisplay_name uintptr Fdefault_screen int32 Fnscreens int32 Fscreens uintptr Fmotion_buffer uint64 Fprivate16 uint64 Fmin_keycode int32 Fmax_keycode int32 Fprivate17 TXPointer Fprivate18 TXPointer Fprivate19 int32 Fxdefaults uintptr })(unsafe.Pointer((*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fdisplay)).Fscreens+uintptr((*TTk_FakeWin)(unsafe.Pointer(tkwin)).FscreenNum)*128 == (*TTkColor)(unsafe.Pointer(tkColPtr)).Fscreen && (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fatts.Fcolormap == (*TTkColor)(unsafe.Pointer(tkColPtr)).Fcolormap { (*TTkColor)(unsafe.Pointer(tkColPtr)).FresourceRefCount++ return tkColPtr } } } /* * The object didn't point to the TkColor that we wanted. Search the list * of TkColors with the same name to see if one of the saved TkColors is * the right one. */ if tkColPtr != libc.UintptrFromInt32(0) { firstColorPtr = (*TTcl_HashEntry)(unsafe.Pointer((*TTkColor)(unsafe.Pointer(tkColPtr)).FhashPtr)).FclientData _FreeColorObj(tls, objPtr) tkColPtr = firstColorPtr for { if !(tkColPtr != libc.UintptrFromInt32(0)) { break } if (*struct { Fext_data uintptr Fprivate1 uintptr Ffd int32 Fprivate2 int32 Fproto_major_version int32 Fproto_minor_version int32 Fvendor uintptr Fprivate3 TXID Fprivate4 TXID Fprivate5 TXID Fprivate6 int32 Fresource_alloc uintptr Fbyte_order int32 Fbitmap_unit int32 Fbitmap_pad int32 Fbitmap_bit_order int32 Fnformats int32 Fpixmap_format uintptr Fprivate8 int32 Frelease int32 Fprivate9 uintptr Fprivate10 uintptr Fqlen int32 Flast_request_read uint64 Frequest uint64 Fprivate11 TXPointer Fprivate12 TXPointer Fprivate13 TXPointer Fprivate14 TXPointer Fmax_request_size uint32 Fdb uintptr Fprivate15 uintptr Fdisplay_name uintptr Fdefault_screen int32 Fnscreens int32 Fscreens uintptr Fmotion_buffer uint64 Fprivate16 uint64 Fmin_keycode int32 Fmax_keycode int32 Fprivate17 TXPointer Fprivate18 TXPointer Fprivate19 int32 Fxdefaults uintptr })(unsafe.Pointer((*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fdisplay)).Fscreens+uintptr((*TTk_FakeWin)(unsafe.Pointer(tkwin)).FscreenNum)*128 == (*TTkColor)(unsafe.Pointer(tkColPtr)).Fscreen && (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fatts.Fcolormap == (*TTkColor)(unsafe.Pointer(tkColPtr)).Fcolormap { (*TTkColor)(unsafe.Pointer(tkColPtr)).FresourceRefCount++ (*TTkColor)(unsafe.Pointer(tkColPtr)).FobjRefCount++ (*(*struct { Fptr1 uintptr Fptr2 uintptr })(unsafe.Pointer(objPtr + 32))).Fptr1 = tkColPtr return tkColPtr } goto _1 _1: ; tkColPtr = (*TTkColor)(unsafe.Pointer(tkColPtr)).FnextPtr } } /* * Still no luck. Call Tk_GetColor to allocate a new TkColor object. */ tkColPtr = XTk_GetColor(tls, interp, tkwin, libtcl9_0.XTcl_GetStringFromObj(tls, objPtr, libc.UintptrFromInt32(0))) (*(*struct { Fptr1 uintptr Fptr2 uintptr })(unsafe.Pointer(objPtr + 32))).Fptr1 = tkColPtr if tkColPtr != libc.UintptrFromInt32(0) { /* The resourceRefCount is incremented by Tk_GetColor. */ (*TTkColor)(unsafe.Pointer(tkColPtr)).FobjRefCount++ } return tkColPtr } /* *---------------------------------------------------------------------- * * Tk_GetColor -- * * Given a string name for a color, map the name to a corresponding * XColor structure. * * Results: * The return value is a pointer to an XColor structure that indicates * the red, blue, and green intensities for the color given by "name", * and also specifies a pixel value to use to draw in that color. If an * error occurs, NULL is returned and an error message will be left in * the interp's result. * * Side effects: * The color is added to an internal database with a reference count. For * each call to this function, there should eventually be a call to * Tk_FreeColor so that the database is cleaned up when colors aren't in * use anymore. * *---------------------------------------------------------------------- */ func XTk_GetColor(tls *libc.TLS, interp uintptr, tkwin TTk_Window, name uintptr) (r uintptr) { bp := tls.Alloc(64) defer tls.Free(64) /* Name of color to be allocated (in form * suitable for passing to XParseColor). */ var dispPtr, existingColPtr, nameHashPtr, tkColPtr uintptr var _ /* isNew at bp+0 */ int32 _, _, _, _ = dispPtr, existingColPtr, nameHashPtr, tkColPtr dispPtr = (*TTkWindow)(unsafe.Pointer(tkwin)).FdispPtr if !((*TTkDisplay)(unsafe.Pointer(dispPtr)).FcolorInit != 0) { _ColorInit(tls, dispPtr) } /* * First, check to see if there's already a mapping for this color name. */ nameHashPtr = (*(*func(*libc.TLS, uintptr, uintptr, uintptr) uintptr)(unsafe.Pointer(&struct{ uintptr }{(*TTcl_HashTable)(unsafe.Pointer(dispPtr + 744)).FcreateProc})))(tls, dispPtr+744, name, bp) if !(*(*int32)(unsafe.Pointer(bp)) != 0) { existingColPtr = (*TTcl_HashEntry)(unsafe.Pointer(nameHashPtr)).FclientData tkColPtr = existingColPtr for { if !(tkColPtr != libc.UintptrFromInt32(0)) { break } if (*TTkColor)(unsafe.Pointer(tkColPtr)).Fscreen == (*struct { Fext_data uintptr Fprivate1 uintptr Ffd int32 Fprivate2 int32 Fproto_major_version int32 Fproto_minor_version int32 Fvendor uintptr Fprivate3 TXID Fprivate4 TXID Fprivate5 TXID Fprivate6 int32 Fresource_alloc uintptr Fbyte_order int32 Fbitmap_unit int32 Fbitmap_pad int32 Fbitmap_bit_order int32 Fnformats int32 Fpixmap_format uintptr Fprivate8 int32 Frelease int32 Fprivate9 uintptr Fprivate10 uintptr Fqlen int32 Flast_request_read uint64 Frequest uint64 Fprivate11 TXPointer Fprivate12 TXPointer Fprivate13 TXPointer Fprivate14 TXPointer Fmax_request_size uint32 Fdb uintptr Fprivate15 uintptr Fdisplay_name uintptr Fdefault_screen int32 Fnscreens int32 Fscreens uintptr Fmotion_buffer uint64 Fprivate16 uint64 Fmin_keycode int32 Fmax_keycode int32 Fprivate17 TXPointer Fprivate18 TXPointer Fprivate19 int32 Fxdefaults uintptr })(unsafe.Pointer((*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fdisplay)).Fscreens+uintptr((*TTk_FakeWin)(unsafe.Pointer(tkwin)).FscreenNum)*128 && (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fatts.Fcolormap == (*TTkColor)(unsafe.Pointer(tkColPtr)).Fcolormap { (*TTkColor)(unsafe.Pointer(tkColPtr)).FresourceRefCount++ return tkColPtr } goto _1 _1: ; tkColPtr = (*TTkColor)(unsafe.Pointer(tkColPtr)).FnextPtr } } else { existingColPtr = libc.UintptrFromInt32(0) } /* * The name isn't currently known. Map from the name to a pixel value. */ tkColPtr = XTkpGetColor(tls, tkwin, name) if tkColPtr == libc.UintptrFromInt32(0) { if interp != libc.UintptrFromInt32(0) { if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(name))) == int32('#') { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+7139, libc.VaList(bp+16, name))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+16, __ccgo_ts+179, __ccgo_ts+182, __ccgo_ts+7163, libc.UintptrFromInt32(0))) } else { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+7169, libc.VaList(bp+16, name))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+16, __ccgo_ts+179, __ccgo_ts+3058, __ccgo_ts+7163, name, libc.UintptrFromInt32(0))) } } if *(*int32)(unsafe.Pointer(bp)) != 0 { libtcl9_0.XTcl_DeleteHashEntry(tls, nameHashPtr) } return libc.UintptrFromInt32(0) } /* * Now create a new TkColor structure and add it to colorNameTable (in * TkDisplay). */ (*TTkColor)(unsafe.Pointer(tkColPtr)).Fmagic = libc.Uint32FromInt32(0x46140277) (*TTkColor)(unsafe.Pointer(tkColPtr)).Fgc = libc.UintptrFromInt32(0) (*TTkColor)(unsafe.Pointer(tkColPtr)).Fscreen = (*struct { Fext_data uintptr Fprivate1 uintptr Ffd int32 Fprivate2 int32 Fproto_major_version int32 Fproto_minor_version int32 Fvendor uintptr Fprivate3 TXID Fprivate4 TXID Fprivate5 TXID Fprivate6 int32 Fresource_alloc uintptr Fbyte_order int32 Fbitmap_unit int32 Fbitmap_pad int32 Fbitmap_bit_order int32 Fnformats int32 Fpixmap_format uintptr Fprivate8 int32 Frelease int32 Fprivate9 uintptr Fprivate10 uintptr Fqlen int32 Flast_request_read uint64 Frequest uint64 Fprivate11 TXPointer Fprivate12 TXPointer Fprivate13 TXPointer Fprivate14 TXPointer Fmax_request_size uint32 Fdb uintptr Fprivate15 uintptr Fdisplay_name uintptr Fdefault_screen int32 Fnscreens int32 Fscreens uintptr Fmotion_buffer uint64 Fprivate16 uint64 Fmin_keycode int32 Fmax_keycode int32 Fprivate17 TXPointer Fprivate18 TXPointer Fprivate19 int32 Fxdefaults uintptr })(unsafe.Pointer((*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fdisplay)).Fscreens + uintptr((*TTk_FakeWin)(unsafe.Pointer(tkwin)).FscreenNum)*128 (*TTkColor)(unsafe.Pointer(tkColPtr)).Fcolormap = (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fatts.Fcolormap (*TTkColor)(unsafe.Pointer(tkColPtr)).Fvisual = (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fvisual (*TTkColor)(unsafe.Pointer(tkColPtr)).FresourceRefCount = int64(1) (*TTkColor)(unsafe.Pointer(tkColPtr)).FobjRefCount = 0 (*TTkColor)(unsafe.Pointer(tkColPtr)).Ftype1 = int32(TK_COLOR_BY_NAME) (*TTkColor)(unsafe.Pointer(tkColPtr)).FhashPtr = nameHashPtr (*TTkColor)(unsafe.Pointer(tkColPtr)).FnextPtr = existingColPtr (*TTcl_HashEntry)(unsafe.Pointer(nameHashPtr)).FclientData = tkColPtr return tkColPtr } /* *---------------------------------------------------------------------- * * Tk_GetColorByValue -- * * Given a desired set of red-green-blue intensities for a color, locate * a pixel value to use to draw that color in a given window. * * Results: * The return value is a pointer to an XColor structure that indicates * the closest red, blue, and green intensities available to those * specified in colorPtr, and also specifies a pixel value to use to draw * in that color. * * Side effects: * The color is added to an internal database with a reference count. For * each call to this function, there should eventually be a call to * Tk_FreeColor, so that the database is cleaned up when colors aren't in * use anymore. * *---------------------------------------------------------------------- */ func XTk_GetColorByValue(tls *libc.TLS, tkwin TTk_Window, colorPtr uintptr) (r uintptr) { bp := tls.Alloc(48) defer tls.Free(48) /* Red, green, and blue fields indicate * desired color. */ var dispPtr, display, tkColPtr, valueHashPtr uintptr var _ /* isNew at bp+32 */ int32 var _ /* valueKey at bp+0 */ TValueKey _, _, _, _ = dispPtr, display, tkColPtr, valueHashPtr display = (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fdisplay dispPtr = XTkGetDisplay(tls, display) if !((*TTkDisplay)(unsafe.Pointer(dispPtr)).FcolorInit != 0) { _ColorInit(tls, dispPtr) } /* * First, check to see if there's already a mapping for this color name. * Must clear the structure first; it's not tightly packed on 64-bit * systems. [Bug 2911570] */ libc.Xmemset(tls, bp, 0, uint64(32)) (*(*TValueKey)(unsafe.Pointer(bp))).Fred = libc.Int32FromUint16((*TXColor)(unsafe.Pointer(colorPtr)).Fred) (*(*TValueKey)(unsafe.Pointer(bp))).Fgreen = libc.Int32FromUint16((*TXColor)(unsafe.Pointer(colorPtr)).Fgreen) (*(*TValueKey)(unsafe.Pointer(bp))).Fblue = libc.Int32FromUint16((*TXColor)(unsafe.Pointer(colorPtr)).Fblue) (*(*TValueKey)(unsafe.Pointer(bp))).Fcolormap = (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fatts.Fcolormap (*(*TValueKey)(unsafe.Pointer(bp))).Fdisplay = display valueHashPtr = (*(*func(*libc.TLS, uintptr, uintptr, uintptr) uintptr)(unsafe.Pointer(&struct{ uintptr }{(*TTcl_HashTable)(unsafe.Pointer(dispPtr + 848)).FcreateProc})))(tls, dispPtr+848, bp, bp+32) if !(*(*int32)(unsafe.Pointer(bp + 32)) != 0) { tkColPtr = (*TTcl_HashEntry)(unsafe.Pointer(valueHashPtr)).FclientData (*TTkColor)(unsafe.Pointer(tkColPtr)).FresourceRefCount++ return tkColPtr } /* * The name isn't currently known. Find a pixel value for this color and * add a new structure to colorValueTable (in TkDisplay). */ tkColPtr = XTkpGetColorByValue(tls, tkwin, colorPtr) (*TTkColor)(unsafe.Pointer(tkColPtr)).Fmagic = libc.Uint32FromInt32(0x46140277) (*TTkColor)(unsafe.Pointer(tkColPtr)).Fgc = libc.UintptrFromInt32(0) (*TTkColor)(unsafe.Pointer(tkColPtr)).Fscreen = (*struct { Fext_data uintptr Fprivate1 uintptr Ffd int32 Fprivate2 int32 Fproto_major_version int32 Fproto_minor_version int32 Fvendor uintptr Fprivate3 TXID Fprivate4 TXID Fprivate5 TXID Fprivate6 int32 Fresource_alloc uintptr Fbyte_order int32 Fbitmap_unit int32 Fbitmap_pad int32 Fbitmap_bit_order int32 Fnformats int32 Fpixmap_format uintptr Fprivate8 int32 Frelease int32 Fprivate9 uintptr Fprivate10 uintptr Fqlen int32 Flast_request_read uint64 Frequest uint64 Fprivate11 TXPointer Fprivate12 TXPointer Fprivate13 TXPointer Fprivate14 TXPointer Fmax_request_size uint32 Fdb uintptr Fprivate15 uintptr Fdisplay_name uintptr Fdefault_screen int32 Fnscreens int32 Fscreens uintptr Fmotion_buffer uint64 Fprivate16 uint64 Fmin_keycode int32 Fmax_keycode int32 Fprivate17 TXPointer Fprivate18 TXPointer Fprivate19 int32 Fxdefaults uintptr })(unsafe.Pointer((*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fdisplay)).Fscreens + uintptr((*TTk_FakeWin)(unsafe.Pointer(tkwin)).FscreenNum)*128 (*TTkColor)(unsafe.Pointer(tkColPtr)).Fcolormap = (*(*TValueKey)(unsafe.Pointer(bp))).Fcolormap (*TTkColor)(unsafe.Pointer(tkColPtr)).Fvisual = (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fvisual (*TTkColor)(unsafe.Pointer(tkColPtr)).FresourceRefCount = int64(1) (*TTkColor)(unsafe.Pointer(tkColPtr)).FobjRefCount = 0 (*TTkColor)(unsafe.Pointer(tkColPtr)).Ftype1 = int32(TK_COLOR_BY_VALUE) (*TTkColor)(unsafe.Pointer(tkColPtr)).FhashPtr = valueHashPtr (*TTkColor)(unsafe.Pointer(tkColPtr)).FnextPtr = libc.UintptrFromInt32(0) (*TTcl_HashEntry)(unsafe.Pointer(valueHashPtr)).FclientData = tkColPtr return tkColPtr } /* *-------------------------------------------------------------- * * Tk_NameOfColor -- * * Given a color, return a textual string identifying the color. * * Results: * If colorPtr was created by Tk_GetColor, then the return value is the * "string" that was used to create it. Otherwise the return value is a * string that could have been passed to Tk_GetColor to allocate that * color. The storage for the returned string is only guaranteed to * persist up until the next call to this function. * * Side effects: * None. * *-------------------------------------------------------------- */ func XTk_NameOfColor(tls *libc.TLS, colorPtr uintptr) (r uintptr) { bp := tls.Alloc(32) defer tls.Free(32) /* Color whose name is desired. */ var tkColPtr, tsdPtr uintptr _, _ = tkColPtr, tsdPtr tkColPtr = colorPtr if (*TTkColor)(unsafe.Pointer(tkColPtr)).Fmagic == libc.Uint32FromInt32(0x46140277) && (*TTkColor)(unsafe.Pointer(tkColPtr)).Ftype1 == int32(TK_COLOR_BY_NAME) { return (*TTkColor)(unsafe.Pointer(tkColPtr)).FhashPtr + 32 } else { tsdPtr = libtcl9_0.XTcl_GetThreadData(tls, uintptr(unsafe.Pointer(&_dataKey1)), int64(20)) libc.X__builtin_snprintf(tls, tsdPtr, uint64(20), __ccgo_ts+7193, libc.VaList(bp+8, libc.Int32FromUint16((*TXColor)(unsafe.Pointer(colorPtr)).Fred), libc.Int32FromUint16((*TXColor)(unsafe.Pointer(colorPtr)).Fgreen), libc.Int32FromUint16((*TXColor)(unsafe.Pointer(colorPtr)).Fblue))) /* * If the string has the form #RSRSTUTUVWVW (where equal letters * denote equal hexdigits) then this is equivalent to #RSTUVW. Then * output the shorter form. */ if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(tsdPtr + 1))) == libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(tsdPtr + 3))) && libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(tsdPtr + 2))) == libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(tsdPtr + 4))) && libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(tsdPtr + 5))) == libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(tsdPtr + 7))) && libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(tsdPtr + 6))) == libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(tsdPtr + 8))) && libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(tsdPtr + 9))) == libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(tsdPtr + 11))) && libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(tsdPtr + 10))) == libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(tsdPtr + 12))) { *(*uint8)(unsafe.Pointer(tsdPtr + 3)) = *(*uint8)(unsafe.Pointer(tsdPtr + 5)) *(*uint8)(unsafe.Pointer(tsdPtr + 4)) = *(*uint8)(unsafe.Pointer(tsdPtr + 6)) *(*uint8)(unsafe.Pointer(tsdPtr + 5)) = *(*uint8)(unsafe.Pointer(tsdPtr + 9)) *(*uint8)(unsafe.Pointer(tsdPtr + 6)) = *(*uint8)(unsafe.Pointer(tsdPtr + 10)) *(*uint8)(unsafe.Pointer(tsdPtr + 7)) = uint8('\000') } return tsdPtr } return r } /* *---------------------------------------------------------------------- * * Tk_GCForColor -- * * Given a color allocated from this module, this function returns a GC * that can be used for simple drawing with that color. * * Results: * The return value is a GC with color set as its foreground color and * all other fields defaulted. This GC is only valid as long as the color * exists; it is freed automatically when the last reference to the color * is freed. * * Side effects: * None. * *---------------------------------------------------------------------- */ func XTk_GCForColor(tls *libc.TLS, colorPtr uintptr, drawable TDrawable) (r TGC) { bp := tls.Alloc(128) defer tls.Free(128) /* Drawable in which the color will be used * (must have same screen and depth as the one * for which the color was allocated). */ var tkColPtr uintptr var _ /* gcValues at bp+0 */ TXGCValues _ = tkColPtr tkColPtr = colorPtr /* * Do a quick sanity check to make sure this color was really allocated by * Tk_GetColor. */ if (*TTkColor)(unsafe.Pointer(tkColPtr)).Fmagic != libc.Uint32FromInt32(0x46140277) { libtcl9_0.XTcl_Panic(tls, __ccgo_ts+7207, 0) } if (*TTkColor)(unsafe.Pointer(tkColPtr)).Fgc == libc.UintptrFromInt32(0) { (*(*TXGCValues)(unsafe.Pointer(bp))).Fforeground = (*TTkColor)(unsafe.Pointer(tkColPtr)).Fcolor.Fpixel (*TTkColor)(unsafe.Pointer(tkColPtr)).Fgc = libx11.XXCreateGC(tls, (*TScreen)(unsafe.Pointer((*TTkColor)(unsafe.Pointer(tkColPtr)).Fscreen)).Fdisplay, drawable, libc.Uint64FromInt64(libc.Int64FromInt64(1)< int64(1) { return } /* * This color is no longer being actively used, so free the color * resources associated with it and remove it from the hash table. No * longer any objects referencing it. */ if (*TTkColor)(unsafe.Pointer(tkColPtr)).Fgc != libc.UintptrFromInt32(0) { libx11.XXFreeGC(tls, (*TScreen)(unsafe.Pointer(screen)).Fdisplay, (*TTkColor)(unsafe.Pointer(tkColPtr)).Fgc) (*TTkColor)(unsafe.Pointer(tkColPtr)).Fgc = libc.UintptrFromInt32(0) } XTkpFreeColor(tls, tkColPtr) prevPtr = (*TTcl_HashEntry)(unsafe.Pointer((*TTkColor)(unsafe.Pointer(tkColPtr)).FhashPtr)).FclientData if prevPtr == tkColPtr { if (*TTkColor)(unsafe.Pointer(tkColPtr)).FnextPtr == libc.UintptrFromInt32(0) { libtcl9_0.XTcl_DeleteHashEntry(tls, (*TTkColor)(unsafe.Pointer(tkColPtr)).FhashPtr) } else { (*TTcl_HashEntry)(unsafe.Pointer((*TTkColor)(unsafe.Pointer(tkColPtr)).FhashPtr)).FclientData = (*TTkColor)(unsafe.Pointer(tkColPtr)).FnextPtr } } else { for (*TTkColor)(unsafe.Pointer(prevPtr)).FnextPtr != tkColPtr { prevPtr = (*TTkColor)(unsafe.Pointer(prevPtr)).FnextPtr } (*TTkColor)(unsafe.Pointer(prevPtr)).FnextPtr = (*TTkColor)(unsafe.Pointer(tkColPtr)).FnextPtr } /* * Free the TkColor structure if there are no objects referencing it. * However, if there are objects referencing it then keep the structure * around; it will get freed when the last reference is cleared */ if (*TTkColor)(unsafe.Pointer(tkColPtr)).FobjRefCount == 0 { libtcl9_0.XTcl_Free(tls, tkColPtr) } } /* *---------------------------------------------------------------------- * * Tk_FreeColorFromObj -- * * This function is called to release a color allocated by * Tk_AllocColorFromObj. It does not throw away the Tcl_Obj *; it only * gets rid of the hash table entry for this color and clears the cached * value that is normally stored in the object. * * Results: * None. * * Side effects: * The reference count associated with the color represented by objPtr is * decremented, and the color is released to X if there are no remaining * uses for it. * *---------------------------------------------------------------------- */ func XTk_FreeColorFromObj(tls *libc.TLS, tkwin TTk_Window, objPtr uintptr) { /* The Tcl_Obj * to be freed. */ XTk_FreeColor(tls, XTk_GetColorFromObj(tls, tkwin, objPtr)) _FreeColorObj(tls, objPtr) } /* *--------------------------------------------------------------------------- * * FreeColorObjProc, FreeColorObj -- * * This proc is called to release an object reference to a color. Called * when the object's internal rep is released or when the cached tkColPtr * needs to be changed. * * Results: * None. * * Side effects: * The object reference count is decremented. When both it and the hash * ref count go to zero, the color's resources are released. * *--------------------------------------------------------------------------- */ func _FreeColorObjProc(tls *libc.TLS, objPtr uintptr) { /* The object we are releasing. */ _FreeColorObj(tls, objPtr) (*TTcl_Obj)(unsafe.Pointer(objPtr)).FtypePtr = libc.UintptrFromInt32(0) } func _FreeColorObj(tls *libc.TLS, objPtr uintptr) { /* The object we are releasing. */ var tkColPtr, v2 uintptr var v1 TTcl_Size _, _, _ = tkColPtr, v1, v2 tkColPtr = (*(*struct { Fptr1 uintptr Fptr2 uintptr })(unsafe.Pointer(objPtr + 32))).Fptr1 if tkColPtr != libc.UintptrFromInt32(0) { v2 = tkColPtr + 64 v1 = *(*TTcl_Size)(unsafe.Pointer(v2)) *(*TTcl_Size)(unsafe.Pointer(v2))-- if v1 <= int64(1) && (*TTkColor)(unsafe.Pointer(tkColPtr)).FresourceRefCount == 0 { libtcl9_0.XTcl_Free(tls, tkColPtr) } (*(*struct { Fptr1 uintptr Fptr2 uintptr })(unsafe.Pointer(objPtr + 32))).Fptr1 = libc.UintptrFromInt32(0) } } /* *--------------------------------------------------------------------------- * * DupColorObjProc -- * * When a cached color object is duplicated, this is called to update the * internal reps. * * Results: * None. * * Side effects: * The color's objRefCount is incremented and the internal rep of the * copy is set to point to it. * *--------------------------------------------------------------------------- */ func _DupColorObjProc(tls *libc.TLS, srcObjPtr uintptr, dupObjPtr uintptr) { /* The object we are copying to. */ var tkColPtr uintptr _ = tkColPtr tkColPtr = (*(*struct { Fptr1 uintptr Fptr2 uintptr })(unsafe.Pointer(srcObjPtr + 32))).Fptr1 (*TTcl_Obj)(unsafe.Pointer(dupObjPtr)).FtypePtr = (*TTcl_Obj)(unsafe.Pointer(srcObjPtr)).FtypePtr (*(*struct { Fptr1 uintptr Fptr2 uintptr })(unsafe.Pointer(dupObjPtr + 32))).Fptr1 = tkColPtr if tkColPtr != libc.UintptrFromInt32(0) { (*TTkColor)(unsafe.Pointer(tkColPtr)).FobjRefCount++ } } /* *---------------------------------------------------------------------- * * Tk_GetColorFromObj -- * * Returns the color referred to by a Tcl object. The color must already * have been allocated via a call to Tk_AllocColorFromObj or Tk_GetColor. * * Results: * Returns the XColor * that matches the tkwin and the string rep of * objPtr. * * Side effects: * If the object is not already a color, the conversion will free any old * internal representation. * *---------------------------------------------------------------------- */ func XTk_GetColorFromObj(tls *libc.TLS, tkwin TTk_Window, objPtr uintptr) (r uintptr) { /* String value contains the name of the * desired color. */ var dispPtr, hashPtr, tkColPtr uintptr _, _, _ = dispPtr, hashPtr, tkColPtr dispPtr = (*TTkWindow)(unsafe.Pointer(tkwin)).FdispPtr if (*TTcl_Obj)(unsafe.Pointer(objPtr)).FtypePtr != uintptr(unsafe.Pointer(&XtkColorObjType)) { _InitColorObj(tls, objPtr) } /* * First check to see if the internal representation of the object is * defined and is a color that is valid for the current screen and color * map. If it is, we are done. */ tkColPtr = (*(*struct { Fptr1 uintptr Fptr2 uintptr })(unsafe.Pointer(objPtr + 32))).Fptr1 if tkColPtr != libc.UintptrFromInt32(0) && (*TTkColor)(unsafe.Pointer(tkColPtr)).FresourceRefCount > 0 && (*struct { Fext_data uintptr Fprivate1 uintptr Ffd int32 Fprivate2 int32 Fproto_major_version int32 Fproto_minor_version int32 Fvendor uintptr Fprivate3 TXID Fprivate4 TXID Fprivate5 TXID Fprivate6 int32 Fresource_alloc uintptr Fbyte_order int32 Fbitmap_unit int32 Fbitmap_pad int32 Fbitmap_bit_order int32 Fnformats int32 Fpixmap_format uintptr Fprivate8 int32 Frelease int32 Fprivate9 uintptr Fprivate10 uintptr Fqlen int32 Flast_request_read uint64 Frequest uint64 Fprivate11 TXPointer Fprivate12 TXPointer Fprivate13 TXPointer Fprivate14 TXPointer Fmax_request_size uint32 Fdb uintptr Fprivate15 uintptr Fdisplay_name uintptr Fdefault_screen int32 Fnscreens int32 Fscreens uintptr Fmotion_buffer uint64 Fprivate16 uint64 Fmin_keycode int32 Fmax_keycode int32 Fprivate17 TXPointer Fprivate18 TXPointer Fprivate19 int32 Fxdefaults uintptr })(unsafe.Pointer((*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fdisplay)).Fscreens+uintptr((*TTk_FakeWin)(unsafe.Pointer(tkwin)).FscreenNum)*128 == (*TTkColor)(unsafe.Pointer(tkColPtr)).Fscreen && (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fatts.Fcolormap == (*TTkColor)(unsafe.Pointer(tkColPtr)).Fcolormap { /* * The object already points to the right TkColor structure. Just * return it. */ return tkColPtr } /* * If we reach this point, it means that the TkColor structure that we * have cached in the internal representation is not valid for the current * screen and colormap. But there is a list of other TkColor structures * attached to the TkDisplay. Walk this list looking for the right TkColor * structure. */ hashPtr = (*(*func(*libc.TLS, uintptr, uintptr) uintptr)(unsafe.Pointer(&struct{ uintptr }{(*TTcl_HashTable)(unsafe.Pointer(dispPtr + 744)).FfindProc})))(tls, dispPtr+744, libtcl9_0.XTcl_GetStringFromObj(tls, objPtr, libc.UintptrFromInt32(0))) if hashPtr == libc.UintptrFromInt32(0) { goto error } tkColPtr = (*TTcl_HashEntry)(unsafe.Pointer(hashPtr)).FclientData for { if !(tkColPtr != libc.UintptrFromInt32(0)) { break } if (*struct { Fext_data uintptr Fprivate1 uintptr Ffd int32 Fprivate2 int32 Fproto_major_version int32 Fproto_minor_version int32 Fvendor uintptr Fprivate3 TXID Fprivate4 TXID Fprivate5 TXID Fprivate6 int32 Fresource_alloc uintptr Fbyte_order int32 Fbitmap_unit int32 Fbitmap_pad int32 Fbitmap_bit_order int32 Fnformats int32 Fpixmap_format uintptr Fprivate8 int32 Frelease int32 Fprivate9 uintptr Fprivate10 uintptr Fqlen int32 Flast_request_read uint64 Frequest uint64 Fprivate11 TXPointer Fprivate12 TXPointer Fprivate13 TXPointer Fprivate14 TXPointer Fmax_request_size uint32 Fdb uintptr Fprivate15 uintptr Fdisplay_name uintptr Fdefault_screen int32 Fnscreens int32 Fscreens uintptr Fmotion_buffer uint64 Fprivate16 uint64 Fmin_keycode int32 Fmax_keycode int32 Fprivate17 TXPointer Fprivate18 TXPointer Fprivate19 int32 Fxdefaults uintptr })(unsafe.Pointer((*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fdisplay)).Fscreens+uintptr((*TTk_FakeWin)(unsafe.Pointer(tkwin)).FscreenNum)*128 == (*TTkColor)(unsafe.Pointer(tkColPtr)).Fscreen && (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fatts.Fcolormap == (*TTkColor)(unsafe.Pointer(tkColPtr)).Fcolormap { _FreeColorObj(tls, objPtr) (*(*struct { Fptr1 uintptr Fptr2 uintptr })(unsafe.Pointer(objPtr + 32))).Fptr1 = tkColPtr (*TTkColor)(unsafe.Pointer(tkColPtr)).FobjRefCount++ return tkColPtr } goto _1 _1: ; tkColPtr = (*TTkColor)(unsafe.Pointer(tkColPtr)).FnextPtr } goto error error: ; libtcl9_0.XTcl_Panic(tls, __ccgo_ts+7282, 0) /* * The following code isn't reached; it's just there to please compilers. */ return libc.UintptrFromInt32(0) } /* *---------------------------------------------------------------------- * * InitColorObj -- * * Bookeeping function to change an objPtr to a color type. * * Results: * None. * * Side effects: * The old internal rep of the object is freed. The object's type is set * to color with a NULL TkColor pointer (the pointer will be set later by * either Tk_AllocColorFromObj or Tk_GetColorFromObj). * *---------------------------------------------------------------------- */ func _InitColorObj(tls *libc.TLS, objPtr uintptr) { /* The object to convert. */ var typePtr uintptr _ = typePtr /* * Free the old internalRep before setting the new one. */ libtcl9_0.XTcl_GetStringFromObj(tls, objPtr, libc.UintptrFromInt32(0)) typePtr = (*TTcl_Obj)(unsafe.Pointer(objPtr)).FtypePtr if typePtr != libc.UintptrFromInt32(0) && (*TTcl_ObjType)(unsafe.Pointer(typePtr)).FfreeIntRepProc != libc.UintptrFromInt32(0) { (*(*func(*libc.TLS, uintptr))(unsafe.Pointer(&struct{ uintptr }{(*TTcl_ObjType)(unsafe.Pointer(typePtr)).FfreeIntRepProc})))(tls, objPtr) } (*TTcl_Obj)(unsafe.Pointer(objPtr)).FtypePtr = uintptr(unsafe.Pointer(&XtkColorObjType)) (*(*struct { Fptr1 uintptr Fptr2 uintptr })(unsafe.Pointer(objPtr + 32))).Fptr1 = libc.UintptrFromInt32(0) } /* *---------------------------------------------------------------------- * * ColorInit -- * * Initialize the structure used for color management. * * Results: * None. * * Side effects: * Read the code. * *---------------------------------------------------------------------- */ func _ColorInit(tls *libc.TLS, dispPtr uintptr) { if !((*TTkDisplay)(unsafe.Pointer(dispPtr)).FcolorInit != 0) { (*TTkDisplay)(unsafe.Pointer(dispPtr)).FcolorInit = int32(1) libtcl9_0.XTcl_InitHashTable(tls, dispPtr+744, TCL_STRING_KEYS) libtcl9_0.XTcl_InitHashTable(tls, dispPtr+848, libc.Int32FromUint64(libc.Uint64FromInt64(32)/libc.Uint64FromInt64(4))) } } /* *---------------------------------------------------------------------- * * TkDebugColor -- * * This function returns debugging information about a color. * * Results: * The return value is a list with one sublist for each TkColor * corresponding to "name". Each sublist has two elements that contain * the resourceRefCount and objRefCount fields from the TkColor * structure. * * Side effects: * None. * *---------------------------------------------------------------------- */ func XTkDebugColor(tls *libc.TLS, tkwin TTk_Window, name uintptr) (r uintptr) { /* Name of the desired color. */ var dispPtr, hashPtr, objPtr, resultPtr, tkColPtr uintptr _, _, _, _, _ = dispPtr, hashPtr, objPtr, resultPtr, tkColPtr dispPtr = (*TTkWindow)(unsafe.Pointer(tkwin)).FdispPtr resultPtr = libtcl9_0.XTcl_NewObj(tls) hashPtr = (*(*func(*libc.TLS, uintptr, uintptr) uintptr)(unsafe.Pointer(&struct{ uintptr }{(*TTcl_HashTable)(unsafe.Pointer(dispPtr + 744)).FfindProc})))(tls, dispPtr+744, name) if hashPtr != libc.UintptrFromInt32(0) { tkColPtr = (*TTcl_HashEntry)(unsafe.Pointer(hashPtr)).FclientData if tkColPtr == libc.UintptrFromInt32(0) { libtcl9_0.XTcl_Panic(tls, __ccgo_ts+7333, 0) } for { if !(tkColPtr != libc.UintptrFromInt32(0)) { break } objPtr = libtcl9_0.XTcl_NewObj(tls) libtcl9_0.XTcl_ListObjAppendElement(tls, libc.UintptrFromInt32(0), objPtr, libtcl9_0.XTcl_NewWideIntObj(tls, (*TTkColor)(unsafe.Pointer(tkColPtr)).FresourceRefCount)) libtcl9_0.XTcl_ListObjAppendElement(tls, libc.UintptrFromInt32(0), objPtr, libtcl9_0.XTcl_NewWideIntObj(tls, (*TTkColor)(unsafe.Pointer(tkColPtr)).FobjRefCount)) libtcl9_0.XTcl_ListObjAppendElement(tls, libc.UintptrFromInt32(0), resultPtr, objPtr) goto _1 _1: ; tkColPtr = (*TTkColor)(unsafe.Pointer(tkColPtr)).FnextPtr } } return resultPtr } func XTkParseColor(tls *libc.TLS, display uintptr, map1 TColormap, name uintptr, color uintptr) (r int32) { bp := tls.Alloc(16) defer tls.Free(16) var p, q, v1, v10, v14, v18, v19, v2, v20, v22, v24, v26, v28, v30, v32, v34, v35, v36, v38, v39, v4, v40, v42, v43, v44, v46, v47, v48, v50, v51, v52, v54, v56, v57, v6 uintptr var v11, v12, v13, v15, v16, v17, v23, v25, v27, v29, v31, v33, v41, v45, v49, v7, v8, v9 uint8 var v21, v3, v37, v5, v53, v55 bool var _ /* buf at bp+0 */ [14]uint8 _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = p, q, v1, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v2, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v3, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v4, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v5, v50, v51, v52, v53, v54, v55, v56, v57, v6, v7, v8, v9 if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(name))) == int32('#') { (*(*[14]uint8)(unsafe.Pointer(bp)))[0] = uint8('#') (*(*[14]uint8)(unsafe.Pointer(bp)))[int32(13)] = uint8('\000') name++ v1 = name if v3 = !(*(*uint8)(unsafe.Pointer(v1)) != 0); !v3 { name++ v2 = name } if v5 = v3 || !(*(*uint8)(unsafe.Pointer(v2)) != 0); !v5 { name++ v4 = name } if v5 || !(*(*uint8)(unsafe.Pointer(v4)) != 0) { /* Not at least 3 hex digits, so invalid */ return 0 } else { name++ v6 = name if !(*(*uint8)(unsafe.Pointer(v6)) != 0) { /* Exactly 3 hex digits */ name-- v10 = name v9 = *(*uint8)(unsafe.Pointer(v10)) (*(*[14]uint8)(unsafe.Pointer(bp)))[int32(12)] = v9 v8 = v9 (*(*[14]uint8)(unsafe.Pointer(bp)))[int32(11)] = v8 v7 = v8 (*(*[14]uint8)(unsafe.Pointer(bp)))[int32(10)] = v7 (*(*[14]uint8)(unsafe.Pointer(bp)))[int32(9)] = v7 name-- v14 = name v13 = *(*uint8)(unsafe.Pointer(v14)) (*(*[14]uint8)(unsafe.Pointer(bp)))[int32(8)] = v13 v12 = v13 (*(*[14]uint8)(unsafe.Pointer(bp)))[int32(7)] = v12 v11 = v12 (*(*[14]uint8)(unsafe.Pointer(bp)))[int32(6)] = v11 (*(*[14]uint8)(unsafe.Pointer(bp)))[int32(5)] = v11 name-- v18 = name v17 = *(*uint8)(unsafe.Pointer(v18)) (*(*[14]uint8)(unsafe.Pointer(bp)))[int32(4)] = v17 v16 = v17 (*(*[14]uint8)(unsafe.Pointer(bp)))[int32(3)] = v16 v15 = v16 (*(*[14]uint8)(unsafe.Pointer(bp)))[int32(2)] = v15 (*(*[14]uint8)(unsafe.Pointer(bp)))[int32(1)] = v15 name = bp } else { name++ v19 = name if v21 = !(*(*uint8)(unsafe.Pointer(v19)) != 0); !v21 { name++ v20 = name } if v21 || !(*(*uint8)(unsafe.Pointer(v20)) != 0) { /* Not at least 6 hex digits, so invalid */ return 0 } else { name++ v22 = name if !(*(*uint8)(unsafe.Pointer(v22)) != 0) { /* Exactly 6 hex digits */ name-- v24 = name v23 = *(*uint8)(unsafe.Pointer(v24)) (*(*[14]uint8)(unsafe.Pointer(bp)))[int32(12)] = v23 (*(*[14]uint8)(unsafe.Pointer(bp)))[int32(10)] = v23 name-- v26 = name v25 = *(*uint8)(unsafe.Pointer(v26)) (*(*[14]uint8)(unsafe.Pointer(bp)))[int32(11)] = v25 (*(*[14]uint8)(unsafe.Pointer(bp)))[int32(9)] = v25 name-- v28 = name v27 = *(*uint8)(unsafe.Pointer(v28)) (*(*[14]uint8)(unsafe.Pointer(bp)))[int32(8)] = v27 (*(*[14]uint8)(unsafe.Pointer(bp)))[int32(6)] = v27 name-- v30 = name v29 = *(*uint8)(unsafe.Pointer(v30)) (*(*[14]uint8)(unsafe.Pointer(bp)))[int32(7)] = v29 (*(*[14]uint8)(unsafe.Pointer(bp)))[int32(5)] = v29 name-- v32 = name v31 = *(*uint8)(unsafe.Pointer(v32)) (*(*[14]uint8)(unsafe.Pointer(bp)))[int32(4)] = v31 (*(*[14]uint8)(unsafe.Pointer(bp)))[int32(2)] = v31 name-- v34 = name v33 = *(*uint8)(unsafe.Pointer(v34)) (*(*[14]uint8)(unsafe.Pointer(bp)))[int32(3)] = v33 (*(*[14]uint8)(unsafe.Pointer(bp)))[int32(1)] = v33 name = bp } else { name++ v35 = name if v37 = !(*(*uint8)(unsafe.Pointer(v35)) != 0); !v37 { name++ v36 = name } if v37 || !(*(*uint8)(unsafe.Pointer(v36)) != 0) { /* Not at least 9 hex digits, so invalid */ return 0 } else { name++ v38 = name if !(*(*uint8)(unsafe.Pointer(v38)) != 0) { /* Exactly 9 hex digits */ name-- v39 = name (*(*[14]uint8)(unsafe.Pointer(bp)))[int32(11)] = *(*uint8)(unsafe.Pointer(v39)) name-- v40 = name (*(*[14]uint8)(unsafe.Pointer(bp)))[int32(10)] = *(*uint8)(unsafe.Pointer(v40)) name-- v42 = name v41 = *(*uint8)(unsafe.Pointer(v42)) (*(*[14]uint8)(unsafe.Pointer(bp)))[int32(12)] = v41 (*(*[14]uint8)(unsafe.Pointer(bp)))[int32(9)] = v41 name-- v43 = name (*(*[14]uint8)(unsafe.Pointer(bp)))[int32(7)] = *(*uint8)(unsafe.Pointer(v43)) name-- v44 = name (*(*[14]uint8)(unsafe.Pointer(bp)))[int32(6)] = *(*uint8)(unsafe.Pointer(v44)) name-- v46 = name v45 = *(*uint8)(unsafe.Pointer(v46)) (*(*[14]uint8)(unsafe.Pointer(bp)))[int32(8)] = v45 (*(*[14]uint8)(unsafe.Pointer(bp)))[int32(5)] = v45 name-- v47 = name (*(*[14]uint8)(unsafe.Pointer(bp)))[int32(3)] = *(*uint8)(unsafe.Pointer(v47)) name-- v48 = name (*(*[14]uint8)(unsafe.Pointer(bp)))[int32(2)] = *(*uint8)(unsafe.Pointer(v48)) name-- v50 = name v49 = *(*uint8)(unsafe.Pointer(v50)) (*(*[14]uint8)(unsafe.Pointer(bp)))[int32(4)] = v49 (*(*[14]uint8)(unsafe.Pointer(bp)))[int32(1)] = v49 name = bp } else { name++ v51 = name if v53 = !(*(*uint8)(unsafe.Pointer(v51)) != 0); !v53 { name++ v52 = name } if v55 = v53 || !(*(*uint8)(unsafe.Pointer(v52)) != 0); !v55 { name++ v54 = name } if v55 || *(*uint8)(unsafe.Pointer(v54)) != 0 { /* Not exactly 12 hex digits, so invalid */ return 0 } else { name -= uintptr(13) } } } } } } } goto done } else { if libc.Uint64FromInt32((libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(name)))-libc.Int32FromUint8('A'))&libc.Int32FromInt32(0xdf)) < libc.Uint64FromInt64(160)/libc.Uint64FromInt64(8) { if !((libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(name)))-libc.Int32FromUint8('G'))&libc.Int32FromInt32(0xdf) != 0) && !((libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(name + 1)))-libc.Int32FromUint8('R'))&libc.Int32FromInt32(0xdf) != 0) && !((libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(name + 2)))-libc.Int32FromUint8('A'))&libc.Int32FromInt32(0xdb) != 0) && !((libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(name + 3)))-libc.Int32FromUint8('Y'))&libc.Int32FromInt32(0xdf) != 0) && !(*(*uint8)(unsafe.Pointer(name + 4)) != 0) { name = __ccgo_ts + 7375 goto done } else { p = XtkWebColors[(libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(name)))-int32('A'))&int32(0x1f)] if p != 0 { q = name for { q++ v56 = q if !!((libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(p)))-libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(v56))))&libc.Int32FromInt32(0xdf) != 0) { break } v57 = p p++ if !(*(*uint8)(unsafe.Pointer(v57)) != 0) { name = p goto done } } } } } } if libc.Xstrlen(tls, name) > uint64(99) { return 0 } goto done done: ; return libx11.XXParseColor(tls, display, map1, name, color) return r } const OPTION_NEEDS_FREEING = 1 const TK_FS_ITALIC = 1 const TK_FS_OBLIQUE = 2 const TK_FS_ROMAN = 0 const TK_FS_UNKNOWN = -1 const TK_FW_BOLD = 1 const TK_FW_NORMAL = 0 const TK_FW_UNKNOWN = -1 const TK_SW_CONDENSE = 1 const TK_SW_EXPAND = 2 const TK_SW_NORMAL = 0 const TK_SW_UNKNOWN = 3 const XLFD_ADD_STYLE = 5 const XLFD_AVERAGE_WIDTH = 11 const XLFD_CHARSET = 12 const XLFD_FAMILY = 1 const XLFD_FOUNDRY = 0 const XLFD_NUMFIELDS = 13 const XLFD_PIXEL_SIZE = 6 const XLFD_POINT_SIZE = 7 const XLFD_RESOLUTION_X = 8 const XLFD_RESOLUTION_Y = 9 const XLFD_SETWIDTH = 4 const XLFD_SLANT = 3 const XLFD_SPACING = 10 const XLFD_WEIGHT = 2 type TTkFontAttributes = struct { Ffamily TTk_Uid Fsize float64 Fweight int32 Fslant int32 Funderline int32 Foverstrike int32 } type TTkFontAttributes1 = struct { Ffamily TTk_Uid Fsize float64 Fweight int32 Fslant int32 Funderline int32 Foverstrike int32 } type TTkFontMetrics = struct { Fascent int32 Fdescent int32 FmaxWidth int32 Ffixed int32 } type TTkFont = struct { FresourceRefCount TTcl_Size FobjRefCount TTcl_Size FcacheHashPtr uintptr FnamedHashPtr uintptr Fscreen uintptr FtabWidth int32 FunderlinePos int32 FunderlineHeight int32 Ffid TFont Ffa TTkFontAttributes Ffm TTkFontMetrics FnextPtr uintptr } type TTkXLFDAttributes = struct { Ffoundry TTk_Uid Fslant int32 Fsetwidth int32 Fcharset TTk_Uid } /* * The following encoding is used in TK_OPTION_VAR: * * if sizeof(type) == sizeof(int) => TK_OPTION_VAR(type) = 0 * if sizeof(type) == 1 => TK_OPTION_VAR(type) = 64 * if sizeof(type) == 2 => TK_OPTION_VAR(type) = 128 * if sizeof(type) == sizeof(long long) => TK_OPTION_VAR(type) = 192 */ /* * The following definition keeps track of all of * the option tables that have been created for a thread. */ type TThreadSpecificData2 = struct { Finitialized int32 FhashTable TTcl_HashTable } var _dataKey2 TTcl_ThreadDataKey /* * The following two structures are used along with Tk_OptionSpec structures * to manage configuration options. Tk_OptionSpec is static templates that are * compiled into the code of a widget or other object manager. However, to * look up options efficiently we need to supplement the static information * with additional dynamic information, and this dynamic information may be * different for each application. Thus we create structures of the following * two types to hold all of the dynamic information; this is done by * Tk_CreateOptionTable. * * One of the following structures corresponds to each Tk_OptionSpec. These * structures exist as arrays inside TkOptionTable structures. */ type TOption = struct { FspecPtr uintptr FdbNameUID TTk_Uid FdbClassUID TTk_Uid FdefaultPtr uintptr Fextra struct { FsynonymPtr [0]uintptr Fcustom [0]uintptr FmonoColorPtr uintptr } Fflags int32 } /* * The following two structures are used along with Tk_OptionSpec structures * to manage configuration options. Tk_OptionSpec is static templates that are * compiled into the code of a widget or other object manager. However, to * look up options efficiently we need to supplement the static information * with additional dynamic information, and this dynamic information may be * different for each application. Thus we create structures of the following * two types to hold all of the dynamic information; this is done by * Tk_CreateOptionTable. * * One of the following structures corresponds to each Tk_OptionSpec. These * structures exist as arrays inside TkOptionTable structures. */ type TTkOption = TOption /* * Flag bits defined for Option structures: * * OPTION_NEEDS_FREEING - 1 means that FreeResources must be invoked to * free resources associated with the option when * it is no longer needed. */ /* * One of the following exists for each Tk_OptionSpec array that has been * passed to Tk_CreateOptionTable. */ type TOptionTable = struct { FrefCount Tsize_t FhashEntryPtr uintptr FnextPtr uintptr FnumOptions Tsize_t Foptions [1]TOption } /* * The structure below defines an object type that is used to cache the result * of looking up an option name. If an object has this type, then its * internalPtr1 field points to the OptionTable in which it was looked up, and * the internalPtr2 field points to the entry that matched. */ var _optionObjType = TTkObjType{ FobjType: TTcl_ObjType{ Fname: __ccgo_ts + 2689, }, } func init() { p := unsafe.Pointer(&_optionObjType) *(*uintptr)(unsafe.Add(p, 8)) = __ccgo_fp(_FreeOptionInternalRep) *(*uintptr)(unsafe.Add(p, 16)) = __ccgo_fp(_DupOptionInternalRep) } /* *-------------------------------------------------------------- * * Tk_CreateOptionTable -- * * Given a template for configuration options, this function creates a * table that may be used to look up options efficiently. * * Results: * Returns a token to a structure that can be passed to functions such as * Tk_InitOptions, Tk_SetOptions, and Tk_FreeConfigOptions. * * Side effects: * Storage is allocated. * *-------------------------------------------------------------- */ func XTk_CreateOptionTable(tls *libc.TLS, interp uintptr, templatePtr uintptr) (r TTk_OptionTable) { bp := tls.Alloc(16) defer tls.Free(16) /* Static information about the configuration * options. */ var hashEntryPtr, optionPtr, specPtr, specPtr2, tablePtr, tsdPtr uintptr var i, numOptions Tsize_t var _ /* newEntry at bp+0 */ int32 _, _, _, _, _, _, _, _ = hashEntryPtr, i, numOptions, optionPtr, specPtr, specPtr2, tablePtr, tsdPtr tsdPtr = libtcl9_0.XTcl_GetThreadData(tls, uintptr(unsafe.Pointer(&_dataKey2)), int64(112)) /* * We use an TSD in the thread to keep a hash table of * all the option tables we've created for this application. This is * used for allowing us to share the tables (e.g. in several chains). * The code below finds the hash table or creates a new one if it * doesn't already exist. */ if !((*TThreadSpecificData2)(unsafe.Pointer(tsdPtr)).Finitialized != 0) { libtcl9_0.XTcl_InitHashTable(tls, tsdPtr+8, int32(TCL_ONE_WORD_KEYS)) (*TThreadSpecificData2)(unsafe.Pointer(tsdPtr)).Finitialized = int32(1) } /* * See if a table has already been created for this template. If so, just * reuse the existing table. */ hashEntryPtr = (*(*func(*libc.TLS, uintptr, uintptr, uintptr) uintptr)(unsafe.Pointer(&struct{ uintptr }{(*TTcl_HashTable)(unsafe.Pointer(tsdPtr + 8)).FcreateProc})))(tls, tsdPtr+8, templatePtr, bp) if !(*(*int32)(unsafe.Pointer(bp)) != 0) { tablePtr = (*TTcl_HashEntry)(unsafe.Pointer(hashEntryPtr)).FclientData (*TOptionTable)(unsafe.Pointer(tablePtr)).FrefCount++ return tablePtr } /* * Count the number of options in the template, then create the table * structure. */ numOptions = uint64(0) specPtr = templatePtr for { if !((*TTk_OptionSpec)(unsafe.Pointer(specPtr)).Ftype1 != int32(TK_OPTION_END)) { break } numOptions++ goto _1 _1: ; specPtr += 80 } tablePtr = libtcl9_0.XTcl_Alloc(tls, uint64(80)+numOptions*uint64(48)) (*TOptionTable)(unsafe.Pointer(tablePtr)).FrefCount = uint64(1) (*TOptionTable)(unsafe.Pointer(tablePtr)).FhashEntryPtr = hashEntryPtr (*TOptionTable)(unsafe.Pointer(tablePtr)).FnextPtr = libc.UintptrFromInt32(0) (*TOptionTable)(unsafe.Pointer(tablePtr)).FnumOptions = numOptions /* * Initialize all of the Option structures in the table. */ specPtr = templatePtr optionPtr = tablePtr + 32 for { if !((*TTk_OptionSpec)(unsafe.Pointer(specPtr)).Ftype1 != int32(TK_OPTION_END)) { break } (*TOption)(unsafe.Pointer(optionPtr)).FspecPtr = specPtr (*TOption)(unsafe.Pointer(optionPtr)).FdbNameUID = libc.UintptrFromInt32(0) (*TOption)(unsafe.Pointer(optionPtr)).FdbClassUID = libc.UintptrFromInt32(0) (*TOption)(unsafe.Pointer(optionPtr)).FdefaultPtr = libc.UintptrFromInt32(0) *(*uintptr)(unsafe.Pointer(optionPtr + 32)) = libc.UintptrFromInt32(0) (*TOption)(unsafe.Pointer(optionPtr)).Fflags = 0 if (*TTk_OptionSpec)(unsafe.Pointer(specPtr)).Ftype1 == int32(TK_OPTION_SYNONYM) { /* * This is a synonym option; find the original option that it refers * to and create a pointer from the synonym to the origin. */ specPtr2 = templatePtr i = libc.Uint64FromInt32(0) for { if (*TTk_OptionSpec)(unsafe.Pointer(specPtr2)).Ftype1 == int32(TK_OPTION_END) { libtcl9_0.XTcl_Panic(tls, __ccgo_ts+7389, 0) } if libc.Xstrcmp(tls, (*TTk_OptionSpec)(unsafe.Pointer(specPtr2)).FoptionName, (*TTk_OptionSpec)(unsafe.Pointer(specPtr)).FclientData) == 0 { *(*uintptr)(unsafe.Pointer(optionPtr + 32)) = tablePtr + 32 + uintptr(i)*48 break } goto _3 _3: ; specPtr2 += 80 i++ } } else { if (*TTk_OptionSpec)(unsafe.Pointer(specPtr)).FdbName != libc.UintptrFromInt32(0) { (*TOption)(unsafe.Pointer(optionPtr)).FdbNameUID = XTk_GetUid(tls, (*TTk_OptionSpec)(unsafe.Pointer(specPtr)).FdbName) } if (*TTk_OptionSpec)(unsafe.Pointer(specPtr)).FdbClass != libc.UintptrFromInt32(0) { (*TOption)(unsafe.Pointer(optionPtr)).FdbClassUID = XTk_GetUid(tls, (*TTk_OptionSpec)(unsafe.Pointer(specPtr)).FdbClass) } if (*TTk_OptionSpec)(unsafe.Pointer(specPtr)).FdefValue != libc.UintptrFromInt32(0) { (*TOption)(unsafe.Pointer(optionPtr)).FdefaultPtr = libtcl9_0.XTcl_NewStringObj(tls, (*TTk_OptionSpec)(unsafe.Pointer(specPtr)).FdefValue, int64(-libc.Int32FromInt32(1))) (*TTcl_Obj)(unsafe.Pointer((*TOption)(unsafe.Pointer(optionPtr)).FdefaultPtr)).FrefCount++ } if ((*TTk_OptionSpec)(unsafe.Pointer(specPtr)).Ftype1 == int32(TK_OPTION_COLOR) || (*TTk_OptionSpec)(unsafe.Pointer(specPtr)).Ftype1 == int32(TK_OPTION_BORDER)) && (*TTk_OptionSpec)(unsafe.Pointer(specPtr)).FclientData != libc.UintptrFromInt32(0) { *(*uintptr)(unsafe.Pointer(optionPtr + 32)) = libtcl9_0.XTcl_NewStringObj(tls, (*TTk_OptionSpec)(unsafe.Pointer(specPtr)).FclientData, int64(-libc.Int32FromInt32(1))) (*TTcl_Obj)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(optionPtr + 32)))).FrefCount++ } if (*TTk_OptionSpec)(unsafe.Pointer(specPtr)).Ftype1 == int32(TK_OPTION_CUSTOM) { /* * Get the custom parsing, etc., functions. */ *(*uintptr)(unsafe.Pointer(optionPtr + 32)) = (*TTk_OptionSpec)(unsafe.Pointer(specPtr)).FclientData } } if (*TTk_OptionSpec)(unsafe.Pointer(specPtr)).Ftype1 == int32(TK_OPTION_STRING) && (*TTk_OptionSpec)(unsafe.Pointer(specPtr)).FinternalOffset != int64(-libc.Int32FromInt32(1)) || (*TTk_OptionSpec)(unsafe.Pointer(specPtr)).Ftype1 == int32(TK_OPTION_COLOR) || (*TTk_OptionSpec)(unsafe.Pointer(specPtr)).Ftype1 == int32(TK_OPTION_FONT) || (*TTk_OptionSpec)(unsafe.Pointer(specPtr)).Ftype1 == int32(TK_OPTION_BITMAP) || (*TTk_OptionSpec)(unsafe.Pointer(specPtr)).Ftype1 == int32(TK_OPTION_BORDER) || (*TTk_OptionSpec)(unsafe.Pointer(specPtr)).Ftype1 == int32(TK_OPTION_CURSOR) || (*TTk_OptionSpec)(unsafe.Pointer(specPtr)).Ftype1 == int32(TK_OPTION_CUSTOM) { *(*int32)(unsafe.Pointer(optionPtr + 40)) |= int32(OPTION_NEEDS_FREEING) } goto _2 _2: ; specPtr += 80 optionPtr += 48 } (*TOptionTable)(unsafe.Pointer(tablePtr)).FhashEntryPtr = hashEntryPtr (*TTcl_HashEntry)(unsafe.Pointer(hashEntryPtr)).FclientData = tablePtr /* * Finally, check to see if this template chains to another template with * additional options. If so, call ourselves recursively to create the * next table(s). */ if (*TTk_OptionSpec)(unsafe.Pointer(specPtr)).FclientData != libc.UintptrFromInt32(0) { (*TOptionTable)(unsafe.Pointer(tablePtr)).FnextPtr = XTk_CreateOptionTable(tls, interp, (*TTk_OptionSpec)(unsafe.Pointer(specPtr)).FclientData) } return tablePtr } /* *---------------------------------------------------------------------- * * Tk_DeleteOptionTable -- * * Called to release resources used by an option table when the table is * no longer needed. * * Results: * None. * * Side effects: * The option table and associated resources (such as additional option * tables chained off it) are destroyed. * *---------------------------------------------------------------------- */ func XTk_DeleteOptionTable(tls *libc.TLS, optionTable TTk_OptionTable) { /* The option table to delete. */ var _objPtr, _objPtr1, optionPtr, tablePtr, v2, v5, v7 uintptr var count, v1 Tsize_t var v4, v6 TTcl_Size _, _, _, _, _, _, _, _, _, _, _ = _objPtr, _objPtr1, count, optionPtr, tablePtr, v1, v2, v4, v5, v6, v7 tablePtr = optionTable v2 = tablePtr v1 = *(*Tsize_t)(unsafe.Pointer(v2)) *(*Tsize_t)(unsafe.Pointer(v2))-- if v1 > uint64(1) { return } if (*TOptionTable)(unsafe.Pointer(tablePtr)).FnextPtr != libc.UintptrFromInt32(0) { XTk_DeleteOptionTable(tls, (*TOptionTable)(unsafe.Pointer(tablePtr)).FnextPtr) } count = (*TOptionTable)(unsafe.Pointer(tablePtr)).FnumOptions optionPtr = tablePtr + 32 for { if !(count > uint64(0)) { break } if (*TOption)(unsafe.Pointer(optionPtr)).FdefaultPtr != libc.UintptrFromInt32(0) { _objPtr = (*TOption)(unsafe.Pointer(optionPtr)).FdefaultPtr v5 = _objPtr v4 = *(*TTcl_Size)(unsafe.Pointer(v5)) *(*TTcl_Size)(unsafe.Pointer(v5))-- if v4 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr) } } if ((*TTk_OptionSpec)(unsafe.Pointer((*TOption)(unsafe.Pointer(optionPtr)).FspecPtr)).Ftype1 == int32(TK_OPTION_COLOR) || (*TTk_OptionSpec)(unsafe.Pointer((*TOption)(unsafe.Pointer(optionPtr)).FspecPtr)).Ftype1 == int32(TK_OPTION_BORDER)) && *(*uintptr)(unsafe.Pointer(optionPtr + 32)) != libc.UintptrFromInt32(0) { _objPtr1 = *(*uintptr)(unsafe.Pointer(optionPtr + 32)) v7 = _objPtr1 v6 = *(*TTcl_Size)(unsafe.Pointer(v7)) *(*TTcl_Size)(unsafe.Pointer(v7))-- if v6 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr1) } } goto _3 _3: ; count-- optionPtr += 48 } libtcl9_0.XTcl_DeleteHashEntry(tls, (*TOptionTable)(unsafe.Pointer(tablePtr)).FhashEntryPtr) libtcl9_0.XTcl_Free(tls, tablePtr) } /* *-------------------------------------------------------------- * * Tk_InitOptions -- * * This function is invoked when an object such as a widget is created. * It supplies an initial value for each configuration option (the value * may come from the option database, a system default, or the default in * the option table). * * Results: * The return value is TCL_OK if the function completed successfully, and * TCL_ERROR if one of the initial values was bogus. If an error occurs * and interp isn't NULL, then an error message will be left in its * result. * * Side effects: * Fields of recordPtr are filled in with initial values. * *-------------------------------------------------------------- */ func XTk_InitOptions(tls *libc.TLS, interp uintptr, recordPtr uintptr, optionTable TTk_OptionTable, tkwin TTk_Window) (r int32) { bp := tls.Alloc(224) defer tls.Free(224) /* Certain options types (such as * TK_OPTION_COLOR) need fields out of the * window they are used in to be able to * calculate their values. Not needed unless * one of these options is in the configSpecs * record. */ var _objPtr, _objPtr1, optionPtr, tablePtr, valuePtr, v3, v5 uintptr var count Tsize_t var source int32 var value TTk_Uid var v2, v4 TTcl_Size var _ /* msg at bp+0 */ [200]uint8 _, _, _, _, _, _, _, _, _, _, _, _ = _objPtr, _objPtr1, count, optionPtr, source, tablePtr, value, valuePtr, v2, v3, v4, v5 tablePtr = optionTable /* * If this table chains to other tables, handle their initialization * first. That way, if both tables refer to the same field of the record, * the value in the first table will win. */ if (*TOptionTable)(unsafe.Pointer(tablePtr)).FnextPtr != libc.UintptrFromInt32(0) { if XTk_InitOptions(tls, interp, recordPtr, (*TOptionTable)(unsafe.Pointer(tablePtr)).FnextPtr, tkwin) != TCL_OK { return int32(TCL_ERROR) } } /* * Iterate over all of the options in the table, initializing each in * turn. */ optionPtr = tablePtr + 32 count = (*TOptionTable)(unsafe.Pointer(tablePtr)).FnumOptions for { if !(count > uint64(0)) { break } /* * If we specify TK_OPTION_DONT_SET_DEFAULT, then the user has * processed and set a default for this already. */ if (*TTk_OptionSpec)(unsafe.Pointer((*TOption)(unsafe.Pointer(optionPtr)).FspecPtr)).Ftype1 == int32(TK_OPTION_SYNONYM) || (*TTk_OptionSpec)(unsafe.Pointer((*TOption)(unsafe.Pointer(optionPtr)).FspecPtr)).Fflags&(libc.Int32FromInt32(1)< uint64(4) { *(*int64)(unsafe.Pointer(oldInternalPtr)) = *(*int64)(unsafe.Pointer(internalPtr)) *(*int64)(unsafe.Pointer(internalPtr)) = *(*TTcl_WideInt)(unsafe.Pointer(bp + 40)) } else { *(*int64)(unsafe.Pointer(oldInternalPtr)) = *(*int64)(unsafe.Pointer(internalPtr)) *(*int64)(unsafe.Pointer(internalPtr)) = *(*TTcl_WideInt)(unsafe.Pointer(bp + 40)) } } } else { libtcl9_0.XTcl_Panic(tls, __ccgo_ts+7594, libc.VaList(bp+112, __ccgo_ts+7679)) } _23: ; goto _20 _3: ; if XTkGetIntForIndex(tls, *(*uintptr)(unsafe.Pointer(bp)), int64(-libc.Int32FromInt32(1)), 0, bp+48) != TCL_OK { if interp != 0 { libtcl9_0.XTcl_AppendResult(tls, interp, libc.VaList(bp+112, __ccgo_ts+7693, libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(bp)), libc.UintptrFromInt32(0)), __ccgo_ts+7705, libc.UintptrFromInt32(0))) } return int32(TCL_ERROR) } if *(*TTcl_Size)(unsafe.Pointer(bp + 48)) < int64(-libc.Int32FromInt32(1)-libc.Int32FromInt32(0x7fffffff)) { *(*TTcl_Size)(unsafe.Pointer(bp + 48)) = int64(-libc.Int32FromInt32(1) - libc.Int32FromInt32(0x7fffffff)) } else { if *(*TTcl_Size)(unsafe.Pointer(bp + 48)) > int64(INT_MAX) { *(*TTcl_Size)(unsafe.Pointer(bp + 48)) = int64(INT_MAX) } } if internalPtr != libc.UintptrFromInt32(0) { *(*int32)(unsafe.Pointer(oldInternalPtr)) = *(*int32)(unsafe.Pointer(internalPtr)) *(*int32)(unsafe.Pointer(internalPtr)) = int32(*(*TTcl_Size)(unsafe.Pointer(bp + 48))) } goto _20 _4: ; if nullOK != 0 && _ObjectIsEmpty(tls, *(*uintptr)(unsafe.Pointer(bp))) != 0 { *(*uintptr)(unsafe.Pointer(bp)) = libc.UintptrFromInt32(0) *(*float64)(unsafe.Pointer(bp + 56)) = float64(libc.X__builtin_nanf(tls, __ccgo_ts+195)) } else { if nullOK != 0 { v29 = libc.UintptrFromInt32(0) } else { v29 = interp } if libtcl9_0.XTcl_GetDoubleFromObj(tls, v29, *(*uintptr)(unsafe.Pointer(bp)), bp+56) != TCL_OK { if nullOK != 0 && interp != 0 { msg = libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+7762, int64(-libc.Int32FromInt32(1))) libtcl9_0.XTcl_AppendLimitedToObj(tls, msg, libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(bp)), libc.UintptrFromInt32(0)), int64(-libc.Int32FromInt32(1)), int64(50), __ccgo_ts+195) libtcl9_0.XTcl_AppendToObj(tls, msg, __ccgo_ts+7592, int64(-libc.Int32FromInt32(1))) libtcl9_0.XTcl_SetObjResult(tls, interp, msg) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+112, __ccgo_ts+5785, __ccgo_ts+182, __ccgo_ts+7672, libc.UintptrFromInt32(0))) } return int32(TCL_ERROR) } } if internalPtr != libc.UintptrFromInt32(0) { *(*float64)(unsafe.Pointer(oldInternalPtr)) = *(*float64)(unsafe.Pointer(internalPtr)) *(*float64)(unsafe.Pointer(internalPtr)) = *(*float64)(unsafe.Pointer(bp + 56)) } goto _20 _5: ; if nullOK != 0 && _ObjectIsEmpty(tls, *(*uintptr)(unsafe.Pointer(bp))) != 0 { *(*uintptr)(unsafe.Pointer(bp)) = libc.UintptrFromInt32(0) } if internalPtr != libc.UintptrFromInt32(0) { if *(*uintptr)(unsafe.Pointer(bp)) != libc.UintptrFromInt32(0) { value = libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(bp)), bp+64) newStr = libtcl9_0.XTcl_Alloc(tls, libc.Uint64FromInt64(*(*TTcl_Size)(unsafe.Pointer(bp + 64))+int64(1))) libc.Xstrcpy(tls, newStr, value) } else { newStr = libc.UintptrFromInt32(0) } *(*uintptr)(unsafe.Pointer(oldInternalPtr)) = *(*uintptr)(unsafe.Pointer(internalPtr)) *(*uintptr)(unsafe.Pointer(internalPtr)) = newStr } goto _20 _6: ; if nullOK != 0 && _ObjectIsEmpty(tls, *(*uintptr)(unsafe.Pointer(bp))) != 0 { *(*uintptr)(unsafe.Pointer(bp)) = libc.UintptrFromInt32(0) *(*int32)(unsafe.Pointer(bp + 72)) = -int32(1) } else { if nullOK != 0 { v30 = int32(TCL_NULL_OK) } else { v30 = 0 } if libtcl9_0.XTcl_GetIndexFromObjStruct(tls, interp, *(*uintptr)(unsafe.Pointer(bp)), (*TTk_OptionSpec)(unsafe.Pointer((*TOption)(unsafe.Pointer(optionPtr)).FspecPtr)).FclientData, libc.Int64FromUint64(libc.Uint64FromInt64(8)), (*TTk_OptionSpec)(unsafe.Pointer((*TOption)(unsafe.Pointer(optionPtr)).FspecPtr)).FoptionName+libc.UintptrFromInt32(1), v30|libc.Int32FromUint64(libc.Uint64FromInt64(4)< uint64(0)) { break } p1 = name p2 = (*TTk_OptionSpec)(unsafe.Pointer((*TOption)(unsafe.Pointer(optionPtr)).FspecPtr)).FoptionName for { if !(libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(p1))) == libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(p2)))) { break } if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(p1))) == 0 { /* * This is an exact match. We're done. */ return optionPtr } goto _3 _3: ; p1++ p2++ } if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(p1))) == 0 { /* * The name is an abbreviation for this option. Keep to make * sure that the abbreviation only matches one option name. * If we've already found a match in the past, then it is an * error unless the full names for the two options are * identical; in this case, the first option overrides the * second. */ if bestPtr == libc.UintptrFromInt32(0) { bestPtr = optionPtr } else { if libc.Xstrcmp(tls, (*TTk_OptionSpec)(unsafe.Pointer((*TOption)(unsafe.Pointer(bestPtr)).FspecPtr)).FoptionName, (*TTk_OptionSpec)(unsafe.Pointer((*TOption)(unsafe.Pointer(optionPtr)).FspecPtr)).FoptionName) != 0 { return libc.UintptrFromInt32(0) } } } goto _2 _2: ; optionPtr += 48 count-- } goto _1 _1: ; tablePtr2 = (*TOptionTable)(unsafe.Pointer(tablePtr2)).FnextPtr } /* * Return whatever we have found, which could be NULL if nothing * matched. The multiple-matching case is handled above. */ return bestPtr } /* *---------------------------------------------------------------------- * * GetOptionFromObj -- * * This function searches through a chained option table to find the * entry for a particular option name. * * Results: * The return value is a pointer to the matching entry, or NULL if no * matching entry could be found. If NULL is returned and interp is not * NULL than an error message is left in its result. Note: if the * matching entry is a synonym then this function returns a pointer to * the synonym entry, *not* the "real" entry that the synonym refers to. * * Side effects: * Information about the matching entry is cached in the object * containing the name, so that future lookups can proceed more quickly. * *---------------------------------------------------------------------- */ func _GetOptionFromObj(tls *libc.TLS, interp uintptr, objPtr uintptr, tablePtr uintptr) (r uintptr) { bp := tls.Alloc(48) defer tls.Free(48) /* Table in which to look up objPtr. */ var bestPtr, name uintptr _, _ = bestPtr, name /* * First, check to see if the object already has the answer cached. */ if (*TTcl_Obj)(unsafe.Pointer(objPtr)).FtypePtr == uintptr(unsafe.Pointer(&_optionObjType)) { if (*(*struct { Fptr1 uintptr Fptr2 uintptr })(unsafe.Pointer(objPtr + 32))).Fptr1 == tablePtr { return (*(*struct { Fptr1 uintptr Fptr2 uintptr })(unsafe.Pointer(objPtr + 32))).Fptr2 } } /* * The answer isn't cached. */ name = libtcl9_0.XTcl_GetStringFromObj(tls, objPtr, libc.UintptrFromInt32(0)) bestPtr = _GetOption(tls, name, tablePtr) if bestPtr == libc.UintptrFromInt32(0) { goto error } if (*TTcl_Obj)(unsafe.Pointer(objPtr)).FtypePtr != libc.UintptrFromInt32(0) && (*TTcl_ObjType)(unsafe.Pointer((*TTcl_Obj)(unsafe.Pointer(objPtr)).FtypePtr)).FfreeIntRepProc != libc.UintptrFromInt32(0) { (*(*func(*libc.TLS, uintptr))(unsafe.Pointer(&struct{ uintptr }{(*TTcl_ObjType)(unsafe.Pointer((*TTcl_Obj)(unsafe.Pointer(objPtr)).FtypePtr)).FfreeIntRepProc})))(tls, objPtr) } (*(*struct { Fptr1 uintptr Fptr2 uintptr })(unsafe.Pointer(objPtr + 32))).Fptr1 = tablePtr (*(*struct { Fptr1 uintptr Fptr2 uintptr })(unsafe.Pointer(objPtr + 32))).Fptr2 = bestPtr (*TTcl_Obj)(unsafe.Pointer(objPtr)).FtypePtr = uintptr(unsafe.Pointer(&_optionObjType)) (*TOptionTable)(unsafe.Pointer(tablePtr)).FrefCount++ return bestPtr goto error error: ; if interp != libc.UintptrFromInt32(0) { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+7987, libc.VaList(bp+8, name))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+8, __ccgo_ts+179, __ccgo_ts+3058, __ccgo_ts+8007, name, libc.UintptrFromInt32(0))) } return libc.UintptrFromInt32(0) } /* *---------------------------------------------------------------------- * * TkGetOptionSpec -- * * This function searches through a chained option table to find the * option spec for a particular option name. * * Results: * The return value is a pointer to the option spec of the matching * entry, or NULL if no matching entry could be found. Note: if the * matching entry is a synonym then this function returns a pointer to * the option spec of the synonym entry, *not* the "real" entry that the * synonym refers to. Note: this call is primarily used by the style * management code (tkStyle.c) to look up an element's option spec into a * widget's option table. * * Side effects: * None. * *---------------------------------------------------------------------- */ func XTkGetOptionSpec(tls *libc.TLS, name uintptr, optionTable TTk_OptionTable) (r uintptr) { /* Table in which to look up name. */ var optionPtr uintptr _ = optionPtr optionPtr = _GetOption(tls, name, optionTable) if optionPtr == libc.UintptrFromInt32(0) { return libc.UintptrFromInt32(0) } return (*TOption)(unsafe.Pointer(optionPtr)).FspecPtr } /* *---------------------------------------------------------------------- * * FreeOptionInternalRep -- * * Part of the option Tcl object type implementation. Frees the storage * associated with a option object's internal representation unless it * is still in use. * * Results: * None. * * Side effects: * The option object's internal rep is marked invalid and its memory * gets freed unless it is still in use somewhere. In that case the * cleanup is delayed until the last reference goes away. * *---------------------------------------------------------------------- */ func _FreeOptionInternalRep(tls *libc.TLS, objPtr uintptr) { /* Object whose internal rep to free. */ var tablePtr TTk_OptionTable _ = tablePtr tablePtr = (*(*struct { Fptr1 uintptr Fptr2 uintptr })(unsafe.Pointer(objPtr + 32))).Fptr1 XTk_DeleteOptionTable(tls, tablePtr) (*TTcl_Obj)(unsafe.Pointer(objPtr)).FtypePtr = libc.UintptrFromInt32(0) (*(*struct { Fptr1 uintptr Fptr2 uintptr })(unsafe.Pointer(objPtr + 32))).Fptr1 = libc.UintptrFromInt32(0) (*(*struct { Fptr1 uintptr Fptr2 uintptr })(unsafe.Pointer(objPtr + 32))).Fptr2 = libc.UintptrFromInt32(0) } /* *--------------------------------------------------------------------------- * * DupOptionInternalRep -- * * When a cached option object is duplicated, this is called to update the * internal reps. * *--------------------------------------------------------------------------- */ func _DupOptionInternalRep(tls *libc.TLS, srcObjPtr uintptr, dupObjPtr uintptr) { /* The object we are copying to. */ var tablePtr uintptr _ = tablePtr tablePtr = (*(*struct { Fptr1 uintptr Fptr2 uintptr })(unsafe.Pointer(srcObjPtr + 32))).Fptr1 (*TOptionTable)(unsafe.Pointer(tablePtr)).FrefCount++ (*TTcl_Obj)(unsafe.Pointer(dupObjPtr)).FtypePtr = (*TTcl_Obj)(unsafe.Pointer(srcObjPtr)).FtypePtr (*TTcl_Obj)(unsafe.Pointer(dupObjPtr)).FinternalRep = (*TTcl_Obj)(unsafe.Pointer(srcObjPtr)).FinternalRep } /* *-------------------------------------------------------------- * * Tk_SetOptions -- * * Process one or more name-value pairs for configuration options and * fill in fields of a record with new values. * * Results: * If all goes well then TCL_OK is returned and the old values of any * modified objects are saved in *savePtr, if it isn't NULL (the caller * must eventually call Tk_RestoreSavedOptions or Tk_FreeSavedOptions to * free the contents of *savePtr). In addition, if maskPtr isn't NULL * then *maskPtr is filled in with the OR of the typeMask bits from all * modified options. If an error occurs then TCL_ERROR is returned and a * message is left in interp's result unless interp is NULL; nothing is * saved in *savePtr or *maskPtr in this case. * * Side effects: * The fields of recordPtr get filled in with object pointers from * objc/objv. Old information in widgRec's fields gets recycled. * Information may be left at *savePtr. * *-------------------------------------------------------------- */ func XTk_SetOptions(tls *libc.TLS, interp uintptr, recordPtr uintptr, optionTable TTk_OptionTable, objc TTcl_Size, objv uintptr, tkwin TTk_Window, savePtr uintptr, maskPtr uintptr) (r int32) { bp := tls.Alloc(32) defer tls.Free(32) /* It non-NULL, this word is modified on a * successful return to hold the bit-wise OR * of the typeMask fields of all options that * were modified by this call. Used by the * caller to figure out which options actually * changed. */ var lastSavePtr, newSavePtr, optionPtr, tablePtr, v2 uintptr var mask int32 _, _, _, _, _, _ = lastSavePtr, mask, newSavePtr, optionPtr, tablePtr, v2 tablePtr = optionTable if savePtr != libc.UintptrFromInt32(0) { (*TTk_SavedOptions)(unsafe.Pointer(savePtr)).FrecordPtr = recordPtr (*TTk_SavedOptions)(unsafe.Pointer(savePtr)).Ftkwin = tkwin (*TTk_SavedOptions)(unsafe.Pointer(savePtr)).FnumItems = 0 (*TTk_SavedOptions)(unsafe.Pointer(savePtr)).FnextPtr = libc.UintptrFromInt32(0) } lastSavePtr = savePtr /* * Scan through all of the arguments, processing those that match entries * in the option table. */ mask = 0 for { if !(objc > 0) { break } optionPtr = _GetOptionFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv)), tablePtr) if optionPtr == libc.UintptrFromInt32(0) { goto error } if (*TTk_OptionSpec)(unsafe.Pointer((*TOption)(unsafe.Pointer(optionPtr)).FspecPtr)).Ftype1 == int32(TK_OPTION_SYNONYM) { optionPtr = *(*uintptr)(unsafe.Pointer(optionPtr + 32)) } if objc < int64(2) { if interp != libc.UintptrFromInt32(0) { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+3180, libc.VaList(bp+8, libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv)), libc.UintptrFromInt32(0))))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+8, __ccgo_ts+179, __ccgo_ts+8014, libc.UintptrFromInt32(0))) goto error } } if savePtr != libc.UintptrFromInt32(0) && (*TTk_SavedOptions)(unsafe.Pointer(lastSavePtr)).FnumItems >= int64(TK_NUM_SAVED_OPTIONS) { /* * We've run out of space for saving old option values. Allocate * more space. */ newSavePtr = libtcl9_0.XTcl_Alloc(tls, uint64(512)) (*TTk_SavedOptions)(unsafe.Pointer(newSavePtr)).FrecordPtr = recordPtr (*TTk_SavedOptions)(unsafe.Pointer(newSavePtr)).Ftkwin = tkwin (*TTk_SavedOptions)(unsafe.Pointer(newSavePtr)).FnumItems = 0 (*TTk_SavedOptions)(unsafe.Pointer(newSavePtr)).FnextPtr = libc.UintptrFromInt32(0) (*TTk_SavedOptions)(unsafe.Pointer(lastSavePtr)).FnextPtr = newSavePtr lastSavePtr = newSavePtr } if savePtr != libc.UintptrFromInt32(0) { v2 = lastSavePtr + 24 + uintptr((*TTk_SavedOptions)(unsafe.Pointer(lastSavePtr)).FnumItems)*24 } else { v2 = libc.UintptrFromInt32(0) } if _DoObjConfig(tls, interp, recordPtr, optionPtr, *(*uintptr)(unsafe.Pointer(objv + 1*8)), tkwin, v2) != TCL_OK { libtcl9_0.XTcl_AppendObjToErrorInfo(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+8028, libc.VaList(bp+8, libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv)), libc.UintptrFromInt32(0))))) goto error } if savePtr != libc.UintptrFromInt32(0) { (*TTk_SavedOptions)(unsafe.Pointer(lastSavePtr)).FnumItems++ } mask |= (*TTk_OptionSpec)(unsafe.Pointer((*TOption)(unsafe.Pointer(optionPtr)).FspecPtr)).FtypeMask goto _1 _1: ; objc -= int64(2) objv += uintptr(2) * 8 } if maskPtr != libc.UintptrFromInt32(0) { *(*int32)(unsafe.Pointer(maskPtr)) = mask } return TCL_OK goto error error: ; if savePtr != libc.UintptrFromInt32(0) { XTk_RestoreSavedOptions(tls, savePtr) } return int32(TCL_ERROR) } /* *---------------------------------------------------------------------- * * Tk_RestoreSavedOptions -- * * This function undoes the effect of a previous call to Tk_SetOptions by * restoring all of the options to their value before the call to * Tk_SetOptions. * * Results: * None. * * Side effects: * The configutation record is restored and all the information stored in * savePtr is freed. * *---------------------------------------------------------------------- */ func XTk_RestoreSavedOptions(tls *libc.TLS, savePtr uintptr) { bp := tls.Alloc(16) defer tls.Free(16) /* Holds saved option information; must have * been passed to Tk_SetOptions. */ var _objPtr, custom, internalPtr, newPtr, optionPtr, ptr, specPtr, v3 uintptr var i, v2 TTcl_Size _, _, _, _, _, _, _, _, _, _ = _objPtr, custom, i, internalPtr, newPtr, optionPtr, ptr, specPtr, v2, v3 /* * Be sure to restore the options in the opposite order they were set. * This is important because it's possible that the same option name was * used twice in a single call to Tk_SetOptions. */ if (*TTk_SavedOptions)(unsafe.Pointer(savePtr)).FnextPtr != libc.UintptrFromInt32(0) { XTk_RestoreSavedOptions(tls, (*TTk_SavedOptions)(unsafe.Pointer(savePtr)).FnextPtr) libtcl9_0.XTcl_Free(tls, (*TTk_SavedOptions)(unsafe.Pointer(savePtr)).FnextPtr) (*TTk_SavedOptions)(unsafe.Pointer(savePtr)).FnextPtr = libc.UintptrFromInt32(0) } i = (*TTk_SavedOptions)(unsafe.Pointer(savePtr)).FnumItems - int64(1) for { if !(i >= 0) { break } optionPtr = (*(*TTk_SavedOption)(unsafe.Pointer(savePtr + 24 + uintptr(i)*24))).FoptionPtr specPtr = (*TOption)(unsafe.Pointer(optionPtr)).FspecPtr /* * First free the new value of the option, which is currently in the * record. */ if (*TTk_OptionSpec)(unsafe.Pointer(specPtr)).FobjOffset >= 0 { newPtr = *(*uintptr)(unsafe.Pointer((*TTk_SavedOptions)(unsafe.Pointer(savePtr)).FrecordPtr + uintptr((*TTk_OptionSpec)(unsafe.Pointer(specPtr)).FobjOffset))) } else { newPtr = libc.UintptrFromInt32(0) } if (*TTk_OptionSpec)(unsafe.Pointer(specPtr)).FinternalOffset >= 0 { internalPtr = (*TTk_SavedOptions)(unsafe.Pointer(savePtr)).FrecordPtr + uintptr((*TTk_OptionSpec)(unsafe.Pointer(specPtr)).FinternalOffset) } else { internalPtr = libc.UintptrFromInt32(0) } if (*TOption)(unsafe.Pointer(optionPtr)).Fflags&int32(OPTION_NEEDS_FREEING) != 0 { _FreeResources(tls, optionPtr, newPtr, internalPtr, (*TTk_SavedOptions)(unsafe.Pointer(savePtr)).Ftkwin) } if newPtr != libc.UintptrFromInt32(0) { _objPtr = newPtr v3 = _objPtr v2 = *(*TTcl_Size)(unsafe.Pointer(v3)) *(*TTcl_Size)(unsafe.Pointer(v3))-- if v2 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr) } } /* * Now restore the old value of the option. */ if (*TTk_OptionSpec)(unsafe.Pointer(specPtr)).FobjOffset != int64(-libc.Int32FromInt32(1)) { *(*uintptr)(unsafe.Pointer((*TTk_SavedOptions)(unsafe.Pointer(savePtr)).FrecordPtr + uintptr((*TTk_OptionSpec)(unsafe.Pointer(specPtr)).FobjOffset))) = (*(*TTk_SavedOption)(unsafe.Pointer(savePtr + 24 + uintptr(i)*24))).FvaluePtr } if (*TTk_OptionSpec)(unsafe.Pointer(specPtr)).FinternalOffset != int64(-libc.Int32FromInt32(1)) { ptr = savePtr + 24 + uintptr(i)*24 + 16 switch (*TTk_OptionSpec)(unsafe.Pointer(specPtr)).Ftype1 { case int32(TK_OPTION_BOOLEAN): if (*TTk_OptionSpec)(unsafe.Pointer((*TOption)(unsafe.Pointer(optionPtr)).FspecPtr)).Fflags&((libc.Int32FromInt64(4)-libc.Int32FromInt32(1)|libc.Int32FromInt32(3))< uint64(4) { *(*int64)(unsafe.Pointer(internalPtr)) = *(*int64)(unsafe.Pointer(ptr)) } else { *(*int64)(unsafe.Pointer(internalPtr)) = *(*int64)(unsafe.Pointer(ptr)) } } else { libtcl9_0.XTcl_Panic(tls, __ccgo_ts+7594, libc.VaList(bp+8, __ccgo_ts+7679)) } } else { *(*int32)(unsafe.Pointer(internalPtr)) = *(*int32)(unsafe.Pointer(ptr)) } case int32(TK_OPTION_INDEX): *(*int32)(unsafe.Pointer(internalPtr)) = *(*int32)(unsafe.Pointer(ptr)) case int32(TK_OPTION_DOUBLE): *(*float64)(unsafe.Pointer(internalPtr)) = *(*float64)(unsafe.Pointer(ptr)) case int32(TK_OPTION_STRING): *(*uintptr)(unsafe.Pointer(internalPtr)) = *(*uintptr)(unsafe.Pointer(ptr)) case int32(TK_OPTION_STRING_TABLE): if (*TTk_OptionSpec)(unsafe.Pointer((*TOption)(unsafe.Pointer(optionPtr)).FspecPtr)).Fflags&((libc.Int32FromInt64(4)-libc.Int32FromInt32(1)|libc.Int32FromInt32(3))< uint64(0)) { break } savedOptionPtr = savePtr + 24 + uintptr(count-uint64(1))*24 if (*TTkOption)(unsafe.Pointer((*TTk_SavedOption)(unsafe.Pointer(savedOptionPtr)).FoptionPtr)).Fflags&int32(OPTION_NEEDS_FREEING) != 0 { _FreeResources(tls, (*TTk_SavedOption)(unsafe.Pointer(savedOptionPtr)).FoptionPtr, (*TTk_SavedOption)(unsafe.Pointer(savedOptionPtr)).FvaluePtr, savedOptionPtr+16, (*TTk_SavedOptions)(unsafe.Pointer(savePtr)).Ftkwin) } if (*TTk_SavedOption)(unsafe.Pointer(savedOptionPtr)).FvaluePtr != libc.UintptrFromInt32(0) { _objPtr = (*TTk_SavedOption)(unsafe.Pointer(savedOptionPtr)).FvaluePtr v3 = _objPtr v2 = *(*TTcl_Size)(unsafe.Pointer(v3)) *(*TTcl_Size)(unsafe.Pointer(v3))-- if v2 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr) } } goto _1 _1: ; count-- } } /* *---------------------------------------------------------------------- * * Tk_FreeConfigOptions -- * * Free all resources associated with configuration options. * * Results: * None. * * Side effects: * All of the Tcl_Obj's in recordPtr that are controlled by configuration * options in optionTable are freed. * *---------------------------------------------------------------------- */ func XTk_FreeConfigOptions(tls *libc.TLS, recordPtr uintptr, optionTable TTk_OptionTable, tkwin TTk_Window) { /* Window associated with recordPtr; needed * for freeing some options. */ var _objPtr, oldInternalPtr, oldPtr, oldPtrPtr, optionPtr, specPtr, tablePtr, v4 uintptr var count Tsize_t var v3 TTcl_Size _, _, _, _, _, _, _, _, _, _ = _objPtr, count, oldInternalPtr, oldPtr, oldPtrPtr, optionPtr, specPtr, tablePtr, v3, v4 tablePtr = optionTable for { if !(tablePtr != libc.UintptrFromInt32(0)) { break } optionPtr = tablePtr + 32 count = (*TOptionTable)(unsafe.Pointer(tablePtr)).FnumOptions for { if !(count > uint64(0)) { break } specPtr = (*TOption)(unsafe.Pointer(optionPtr)).FspecPtr if (*TTk_OptionSpec)(unsafe.Pointer(specPtr)).Ftype1 == int32(TK_OPTION_SYNONYM) { goto _2 } if (*TTk_OptionSpec)(unsafe.Pointer(specPtr)).FobjOffset != int64(-libc.Int32FromInt32(1)) { oldPtrPtr = recordPtr + uintptr((*TTk_OptionSpec)(unsafe.Pointer(specPtr)).FobjOffset) oldPtr = *(*uintptr)(unsafe.Pointer(oldPtrPtr)) *(*uintptr)(unsafe.Pointer(oldPtrPtr)) = libc.UintptrFromInt32(0) } else { oldPtr = libc.UintptrFromInt32(0) } if (*TTk_OptionSpec)(unsafe.Pointer(specPtr)).FinternalOffset != int64(-libc.Int32FromInt32(1)) { oldInternalPtr = recordPtr + uintptr((*TTk_OptionSpec)(unsafe.Pointer(specPtr)).FinternalOffset) } else { oldInternalPtr = libc.UintptrFromInt32(0) } if (*TOption)(unsafe.Pointer(optionPtr)).Fflags&int32(OPTION_NEEDS_FREEING) != 0 { _FreeResources(tls, optionPtr, oldPtr, oldInternalPtr, tkwin) } if oldPtr != libc.UintptrFromInt32(0) { _objPtr = oldPtr v4 = _objPtr v3 = *(*TTcl_Size)(unsafe.Pointer(v4)) *(*TTcl_Size)(unsafe.Pointer(v4))-- if v3 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr) } } goto _2 _2: ; optionPtr += 48 count-- } goto _1 _1: ; tablePtr = (*TOptionTable)(unsafe.Pointer(tablePtr)).FnextPtr } } /* *---------------------------------------------------------------------- * * FreeResources -- * * Free system resources associated with a configuration option, such as * colors or fonts. * * Results: * None. * * Side effects: * Any system resources associated with objPtr are released. However, * objPtr itself is not freed. * *---------------------------------------------------------------------- */ func _FreeResources(tls *libc.TLS, optionPtr uintptr, objPtr uintptr, internalPtr uintptr, tkwin TTk_Window) { /* The window in which this option is used. */ var custom uintptr var internalFormExists int32 _, _ = custom, internalFormExists /* * If there exists an internal form for the value, use it to free * resources (also zero out the internal form). If there is no internal * form, then use the object form. */ internalFormExists = libc.BoolInt32((*TTk_OptionSpec)(unsafe.Pointer((*TOption)(unsafe.Pointer(optionPtr)).FspecPtr)).FinternalOffset != int64(-libc.Int32FromInt32(1))) switch (*TTk_OptionSpec)(unsafe.Pointer((*TOption)(unsafe.Pointer(optionPtr)).FspecPtr)).Ftype1 { case int32(TK_OPTION_STRING): if internalFormExists != 0 { if *(*uintptr)(unsafe.Pointer(internalPtr)) != libc.UintptrFromInt32(0) { libtcl9_0.XTcl_Free(tls, *(*uintptr)(unsafe.Pointer(internalPtr))) *(*uintptr)(unsafe.Pointer(internalPtr)) = libc.UintptrFromInt32(0) } } case int32(TK_OPTION_COLOR): if internalFormExists != 0 { if *(*uintptr)(unsafe.Pointer(internalPtr)) != libc.UintptrFromInt32(0) { XTk_FreeColor(tls, *(*uintptr)(unsafe.Pointer(internalPtr))) *(*uintptr)(unsafe.Pointer(internalPtr)) = libc.UintptrFromInt32(0) } } else { if objPtr != libc.UintptrFromInt32(0) { XTk_FreeColorFromObj(tls, tkwin, objPtr) } } case int32(TK_OPTION_FONT): if internalFormExists != 0 { XTk_FreeFont(tls, *(*TTk_Font)(unsafe.Pointer(internalPtr))) *(*TTk_Font)(unsafe.Pointer(internalPtr)) = libc.UintptrFromInt32(0) } else { if objPtr != libc.UintptrFromInt32(0) { XTk_FreeFontFromObj(tls, tkwin, objPtr) } } case int32(TK_OPTION_STYLE): if internalFormExists != 0 { XTk_FreeStyle(tls, *(*TTk_Style)(unsafe.Pointer(internalPtr))) *(*TTk_Style)(unsafe.Pointer(internalPtr)) = libc.UintptrFromInt32(0) } case int32(TK_OPTION_BITMAP): if internalFormExists != 0 { if *(*TPixmap)(unsafe.Pointer(internalPtr)) != uint64(0) { XTk_FreeBitmap(tls, (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fdisplay, *(*TPixmap)(unsafe.Pointer(internalPtr))) *(*TPixmap)(unsafe.Pointer(internalPtr)) = uint64(0) } } else { if objPtr != libc.UintptrFromInt32(0) { XTk_FreeBitmapFromObj(tls, tkwin, objPtr) } } case int32(TK_OPTION_BORDER): if internalFormExists != 0 { if *(*TTk_3DBorder)(unsafe.Pointer(internalPtr)) != libc.UintptrFromInt32(0) { XTk_Free3DBorder(tls, *(*TTk_3DBorder)(unsafe.Pointer(internalPtr))) *(*TTk_3DBorder)(unsafe.Pointer(internalPtr)) = libc.UintptrFromInt32(0) } } else { if objPtr != libc.UintptrFromInt32(0) { XTk_Free3DBorderFromObj(tls, tkwin, objPtr) } } case int32(TK_OPTION_CURSOR): if internalFormExists != 0 { if *(*TTk_Cursor)(unsafe.Pointer(internalPtr)) != libc.UintptrFromInt32(0) { XTk_FreeCursor(tls, (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fdisplay, *(*TTk_Cursor)(unsafe.Pointer(internalPtr))) *(*TTk_Cursor)(unsafe.Pointer(internalPtr)) = libc.UintptrFromInt32(0) } } else { if objPtr != libc.UintptrFromInt32(0) { XTk_FreeCursorFromObj(tls, tkwin, objPtr) } } case int32(TK_OPTION_CUSTOM): custom = *(*uintptr)(unsafe.Pointer(optionPtr + 32)) if internalFormExists != 0 && (*TTk_ObjCustomOption)(unsafe.Pointer(custom)).FfreeProc != libc.UintptrFromInt32(0) { (*(*func(*libc.TLS, uintptr, TTk_Window, uintptr))(unsafe.Pointer(&struct{ uintptr }{(*TTk_ObjCustomOption)(unsafe.Pointer(custom)).FfreeProc})))(tls, (*TTk_ObjCustomOption)(unsafe.Pointer(custom)).FclientData, tkwin, internalPtr) } default: break } } /* *-------------------------------------------------------------- * * Tk_GetOptionInfo -- * * Returns a list object containing complete information about either a * single option or all the configuration options in a table. * * Results: * This function normally returns a pointer to an object. If namePtr * isn't NULL, then the result object is a list with five elements: the * option's name, its database name, database class, default value, and * current value. If the option is a synonym then the list will contain * only two values: the option name and the name of the option it refers * to. If namePtr is NULL, then information is returned for every option * in the option table: the result will have one sub-list (in the form * described above) for each option in the table. If an error occurs * (e.g. because namePtr isn't valid) then NULL is returned and an error * message will be left in interp's result unless interp is NULL. * * Side effects: * None. * *-------------------------------------------------------------- */ func XTk_GetOptionInfo(tls *libc.TLS, interp uintptr, recordPtr uintptr, optionTable TTk_OptionTable, namePtr uintptr, tkwin TTk_Window) (r uintptr) { /* Window associated with recordPtr; needed to * compute correct default value for some * options. */ var count Tsize_t var optionPtr, resultPtr, tablePtr uintptr _, _, _, _ = count, optionPtr, resultPtr, tablePtr tablePtr = optionTable /* * If information is only wanted for a single configuration spec, then * handle that one spec specially. */ if namePtr != libc.UintptrFromInt32(0) { optionPtr = _GetOptionFromObj(tls, interp, namePtr, tablePtr) if optionPtr == libc.UintptrFromInt32(0) { return libc.UintptrFromInt32(0) } if (*TTk_OptionSpec)(unsafe.Pointer((*TOption)(unsafe.Pointer(optionPtr)).FspecPtr)).Ftype1 == int32(TK_OPTION_SYNONYM) { optionPtr = *(*uintptr)(unsafe.Pointer(optionPtr + 32)) } return _GetConfigList(tls, recordPtr, optionPtr, tkwin) } /* * Loop through all the specs, creating a big list with all their * information. */ resultPtr = libtcl9_0.XTcl_NewListObj(tls, 0, libc.UintptrFromInt32(0)) for { if !(tablePtr != libc.UintptrFromInt32(0)) { break } optionPtr = tablePtr + 32 count = (*TOptionTable)(unsafe.Pointer(tablePtr)).FnumOptions for { if !(count > uint64(0)) { break } libtcl9_0.XTcl_ListObjAppendElement(tls, interp, resultPtr, _GetConfigList(tls, recordPtr, optionPtr, tkwin)) goto _2 _2: ; optionPtr += 48 count-- } goto _1 _1: ; tablePtr = (*TOptionTable)(unsafe.Pointer(tablePtr)).FnextPtr } return resultPtr } /* *-------------------------------------------------------------- * * GetConfigList -- * * Create a valid Tcl list holding the configuration information for a * single configuration option. * * Results: * A Tcl list, dynamically allocated. The caller is expected to arrange * for this list to be freed eventually. * * Side effects: * Memory is allocated. * *-------------------------------------------------------------- */ func _GetConfigList(tls *libc.TLS, recordPtr uintptr, optionPtr uintptr, tkwin TTk_Window) (r uintptr) { /* Window corresponding to recordPtr. */ var elementPtr, listPtr uintptr _, _ = elementPtr, listPtr listPtr = libtcl9_0.XTcl_NewListObj(tls, 0, libc.UintptrFromInt32(0)) libtcl9_0.XTcl_ListObjAppendElement(tls, libc.UintptrFromInt32(0), listPtr, libtcl9_0.XTcl_NewStringObj(tls, (*TTk_OptionSpec)(unsafe.Pointer((*TOption)(unsafe.Pointer(optionPtr)).FspecPtr)).FoptionName, int64(-libc.Int32FromInt32(1)))) if (*TTk_OptionSpec)(unsafe.Pointer((*TOption)(unsafe.Pointer(optionPtr)).FspecPtr)).Ftype1 == int32(TK_OPTION_SYNONYM) { elementPtr = libtcl9_0.XTcl_NewStringObj(tls, (*TTk_OptionSpec)(unsafe.Pointer((*TTkOption)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(optionPtr + 32)))).FspecPtr)).FoptionName, int64(-libc.Int32FromInt32(1))) libtcl9_0.XTcl_ListObjAppendElement(tls, libc.UintptrFromInt32(0), listPtr, elementPtr) } else { if (*TOption)(unsafe.Pointer(optionPtr)).FdbNameUID == libc.UintptrFromInt32(0) { elementPtr = libtcl9_0.XTcl_NewObj(tls) } else { elementPtr = libtcl9_0.XTcl_NewStringObj(tls, (*TOption)(unsafe.Pointer(optionPtr)).FdbNameUID, int64(-libc.Int32FromInt32(1))) } libtcl9_0.XTcl_ListObjAppendElement(tls, libc.UintptrFromInt32(0), listPtr, elementPtr) if (*TOption)(unsafe.Pointer(optionPtr)).FdbClassUID == libc.UintptrFromInt32(0) { elementPtr = libtcl9_0.XTcl_NewObj(tls) } else { elementPtr = libtcl9_0.XTcl_NewStringObj(tls, (*TOption)(unsafe.Pointer(optionPtr)).FdbClassUID, int64(-libc.Int32FromInt32(1))) } libtcl9_0.XTcl_ListObjAppendElement(tls, libc.UintptrFromInt32(0), listPtr, elementPtr) if tkwin != libc.UintptrFromInt32(0) && ((*TTk_OptionSpec)(unsafe.Pointer((*TOption)(unsafe.Pointer(optionPtr)).FspecPtr)).Ftype1 == int32(TK_OPTION_COLOR) || (*TTk_OptionSpec)(unsafe.Pointer((*TOption)(unsafe.Pointer(optionPtr)).FspecPtr)).Ftype1 == int32(TK_OPTION_BORDER)) && (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fdepth <= int32(1) && *(*uintptr)(unsafe.Pointer(optionPtr + 32)) != libc.UintptrFromInt32(0) { elementPtr = *(*uintptr)(unsafe.Pointer(optionPtr + 32)) } else { if (*TOption)(unsafe.Pointer(optionPtr)).FdefaultPtr != libc.UintptrFromInt32(0) { elementPtr = (*TOption)(unsafe.Pointer(optionPtr)).FdefaultPtr } else { elementPtr = libtcl9_0.XTcl_NewObj(tls) } } libtcl9_0.XTcl_ListObjAppendElement(tls, libc.UintptrFromInt32(0), listPtr, elementPtr) if (*TTk_OptionSpec)(unsafe.Pointer((*TOption)(unsafe.Pointer(optionPtr)).FspecPtr)).FobjOffset != int64(-libc.Int32FromInt32(1)) { elementPtr = *(*uintptr)(unsafe.Pointer(recordPtr + uintptr((*TTk_OptionSpec)(unsafe.Pointer((*TOption)(unsafe.Pointer(optionPtr)).FspecPtr)).FobjOffset))) if elementPtr == libc.UintptrFromInt32(0) { elementPtr = libtcl9_0.XTcl_NewObj(tls) } } else { elementPtr = _GetObjectForOption(tls, recordPtr, optionPtr, tkwin) } libtcl9_0.XTcl_ListObjAppendElement(tls, libc.UintptrFromInt32(0), listPtr, elementPtr) } return listPtr } /* *---------------------------------------------------------------------- * * GetObjectForOption -- * * This function is called to create an object that contains the value * for an option. It is invoked by GetConfigList and Tk_GetOptionValue * when only the internal form of an option is stored in the record. * * Results: * The return value is a pointer to a Tcl object. The caller must call * Tcl_IncrRefCount on this object to preserve it. * * Side effects: * None. * *---------------------------------------------------------------------- */ func _GetObjectForOption(tls *libc.TLS, recordPtr uintptr, optionPtr uintptr, tkwin TTk_Window) (r uintptr) { bp := tls.Alloc(64) defer tls.Free(64) /* Window corresponding to recordPtr. */ var border TTk_3DBorder var colorPtr, custom, internalPtr, objPtr uintptr var cursor TTk_Cursor var nullOK, value, value2, value3 int32 var pixmap TPixmap var style TTk_Style var tkfont TTk_Font var value1 TTcl_WideInt var value4 TTk_Justify var value5 TTk_Anchor var v1 uint64 var v3 bool var _ /* __u at bp+0 */ struct { F__i [0]uint64 F__f float64 } var _ /* buf at bp+8 */ [32]uint8 _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = border, colorPtr, cursor, custom, internalPtr, nullOK, objPtr, pixmap, style, tkfont, value, value1, value2, value3, value4, value5, v1, v3 objPtr = libc.UintptrFromInt32(0) /* Points to internal value of option in record. */ if (*TTk_OptionSpec)(unsafe.Pointer((*TOption)(unsafe.Pointer(optionPtr)).FspecPtr)).FinternalOffset != int64(-libc.Int32FromInt32(1)) { internalPtr = recordPtr + uintptr((*TTk_OptionSpec)(unsafe.Pointer((*TOption)(unsafe.Pointer(optionPtr)).FspecPtr)).FinternalOffset) switch (*TTk_OptionSpec)(unsafe.Pointer((*TOption)(unsafe.Pointer(optionPtr)).FspecPtr)).Ftype1 { case int32(TK_OPTION_BOOLEAN): value = -int32(1) if (*TTk_OptionSpec)(unsafe.Pointer((*TOption)(unsafe.Pointer(optionPtr)).FspecPtr)).Fflags&((libc.Int32FromInt64(4)-libc.Int32FromInt32(1)|libc.Int32FromInt32(3))< uint64(4) { value1 = *(*int64)(unsafe.Pointer(internalPtr)) if nullOK != 0 && value1 == int64(-libc.Int64FromInt64(0x7fffffffffffffff)-libc.Int64FromInt32(1)) { break } } else { value1 = *(*int64)(unsafe.Pointer(internalPtr)) if nullOK != 0 && value1 == -libc.Int64FromInt64(0x7fffffffffffffff)-libc.Int64FromInt32(1) { break } } } else { libtcl9_0.XTcl_Panic(tls, __ccgo_ts+7594, libc.VaList(bp+48, __ccgo_ts+7679)) } } else { value1 = int64(*(*int32)(unsafe.Pointer(internalPtr))) if nullOK != 0 && value1 == int64(-libc.Int32FromInt32(1)-libc.Int32FromInt32(0x7fffffff)) { break } } objPtr = libtcl9_0.XTcl_NewWideIntObj(tls, value1) case int32(TK_OPTION_INDEX): if !((*TTk_OptionSpec)(unsafe.Pointer((*TOption)(unsafe.Pointer(optionPtr)).FspecPtr)).Fflags&(libc.Int32FromInt32(TCL_NULL_OK)|libc.Int32FromInt32(TCL_NULL_OK)|libc.Int32FromInt32(1)) != 0) || *(*int32)(unsafe.Pointer(internalPtr)) != -libc.Int32FromInt32(1)-libc.Int32FromInt32(0x7fffffff) { if *(*int32)(unsafe.Pointer(internalPtr)) == -libc.Int32FromInt32(1)-libc.Int32FromInt32(0x7fffffff) { objPtr = libtcl9_0.XTcl_NewObj(tls) } else { if *(*int32)(unsafe.Pointer(internalPtr)) == int32(INT_MAX) { objPtr = libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+8120, int64(-libc.Int32FromInt32(1))) } else { if *(*int32)(unsafe.Pointer(internalPtr)) == -int32(1) { objPtr = libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+8126, int64(-libc.Int32FromInt32(1))) } else { if *(*int32)(unsafe.Pointer(internalPtr)) < 0 { libc.X__builtin_snprintf(tls, bp+8, uint64(32), __ccgo_ts+8130, libc.VaList(bp+48, int32(1)+*(*int32)(unsafe.Pointer(internalPtr)))) objPtr = libtcl9_0.XTcl_NewStringObj(tls, bp+8, int64(-libc.Int32FromInt32(1))) } else { objPtr = libtcl9_0.XTcl_NewWideIntObj(tls, int64(*(*int32)(unsafe.Pointer(internalPtr)))) } } } } } case int32(TK_OPTION_DOUBLE): if v3 = !((*TTk_OptionSpec)(unsafe.Pointer((*TOption)(unsafe.Pointer(optionPtr)).FspecPtr)).Fflags&(libc.Int32FromInt32(TCL_NULL_OK)|libc.Int32FromInt32(TCL_NULL_OK)|libc.Int32FromInt32(1)) != 0); !v3 { *(*float64)(unsafe.Pointer(bp)) = *(*float64)(unsafe.Pointer(internalPtr)) v1 = *(*uint64)(unsafe.Pointer(bp)) goto _2 _2: } if v3 || !(libc.BoolInt32(v1&(-libc.Uint64FromUint64(1)>>libc.Int32FromInt32(1)) > libc.Uint64FromUint64(0x7ff)<= 0 { objPtr = libtcl9_0.XTcl_NewStringObj(tls, *(*uintptr)(unsafe.Pointer((*TTk_OptionSpec)(unsafe.Pointer((*TOption)(unsafe.Pointer(optionPtr)).FspecPtr)).FclientData + uintptr(value2)*8)), int64(-libc.Int32FromInt32(1))) } case int32(TK_OPTION_COLOR): colorPtr = *(*uintptr)(unsafe.Pointer(internalPtr)) if colorPtr != libc.UintptrFromInt32(0) { objPtr = libtcl9_0.XTcl_NewStringObj(tls, XTk_NameOfColor(tls, colorPtr), int64(-libc.Int32FromInt32(1))) } case int32(TK_OPTION_FONT): tkfont = *(*TTk_Font)(unsafe.Pointer(internalPtr)) if tkfont != libc.UintptrFromInt32(0) { objPtr = libtcl9_0.XTcl_NewStringObj(tls, XTk_NameOfFont(tls, tkfont), int64(-libc.Int32FromInt32(1))) } case int32(TK_OPTION_STYLE): style = *(*TTk_Style)(unsafe.Pointer(internalPtr)) if style != libc.UintptrFromInt32(0) { objPtr = libtcl9_0.XTcl_NewStringObj(tls, XTk_NameOfStyle(tls, style), int64(-libc.Int32FromInt32(1))) } case int32(TK_OPTION_BITMAP): pixmap = *(*TPixmap)(unsafe.Pointer(internalPtr)) if pixmap != uint64(0) { objPtr = libtcl9_0.XTcl_NewStringObj(tls, XTk_NameOfBitmap(tls, (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fdisplay, pixmap), int64(-libc.Int32FromInt32(1))) } case int32(TK_OPTION_BORDER): border = *(*TTk_3DBorder)(unsafe.Pointer(internalPtr)) if border != libc.UintptrFromInt32(0) { objPtr = libtcl9_0.XTcl_NewStringObj(tls, XTk_NameOf3DBorder(tls, border), int64(-libc.Int32FromInt32(1))) } case int32(TK_OPTION_RELIEF): value3 = -int32(1) if (*TTk_OptionSpec)(unsafe.Pointer((*TOption)(unsafe.Pointer(optionPtr)).FspecPtr)).Fflags&((libc.Int32FromInt64(4)-libc.Int32FromInt32(1)|libc.Int32FromInt32(3))< int32(3) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(2), objv, __ccgo_ts+8421) return int32(TCL_ERROR) } cmd = libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+8429, int64(-libc.Int32FromInt32(1))) if objc == int32(3) { libtcl9_0.XTcl_ListObjAppendElement(tls, libc.UintptrFromInt32(0), cmd, *(*uintptr)(unsafe.Pointer(objv + 2*8))) } default: } (*TTcl_Obj)(unsafe.Pointer(cmd)).FrefCount++ if consoleInterp != 0 && !(libtcl9_0.XTcl_InterpDeleted(tls, consoleInterp) != 0) { libtcl9_0.XTcl_Preserve(tls, consoleInterp) result = libtcl9_0.XTcl_EvalObjEx(tls, consoleInterp, cmd, int32(TCL_EVAL_GLOBAL)) libtcl9_0.XTcl_SetReturnOptions(tls, interp, libtcl9_0.XTcl_GetReturnOptions(tls, consoleInterp, result)) libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_GetObjResult(tls, consoleInterp)) libtcl9_0.XTcl_Release(tls, consoleInterp) } else { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+8440, int64(-libc.Int32FromInt32(1)))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+16, __ccgo_ts+179, __ccgo_ts+8465, __ccgo_ts+6792, libc.UintptrFromInt32(0))) result = int32(TCL_ERROR) } _objPtr = cmd v2 = _objPtr v1 = *(*TTcl_Size)(unsafe.Pointer(v2)) *(*TTcl_Size)(unsafe.Pointer(v2))-- if v1 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr) } return result } var _options = [5]uintptr{ 0: __ccgo_ts + 8364, 1: __ccgo_ts + 8369, 2: __ccgo_ts + 8374, 3: __ccgo_ts + 8379, 4: libc.UintptrFromInt32(0), } /* *---------------------------------------------------------------------- * * InterpreterObjCmd -- * * This command allows the console interp to communicate with the main * interpreter. * * Results: * A standard Tcl result. * *---------------------------------------------------------------------- */ func _InterpreterObjCmd(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) (r int32) { bp := tls.Alloc(48) defer tls.Free(48) /* Argument objects */ var info, otherInterp uintptr var result int32 var _ /* index at bp+0 */ int32 _, _, _ = info, otherInterp, result result = TCL_OK info = clientData otherInterp = (*TConsoleInfo)(unsafe.Pointer(info)).Finterp if objc < int32(2) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(1), objv, __ccgo_ts+8480) return int32(TCL_ERROR) } if libtcl9_0.XTcl_GetIndexFromObjStruct(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 1*8)), uintptr(unsafe.Pointer(&_options1)), libc.Int64FromUint64(libc.Uint64FromInt64(8)), __ccgo_ts+2689, libc.Int32FromInt32(0)|libc.Int32FromUint64(libc.Uint64FromInt64(4)< int64(1) { return } libtcl9_0.XTcl_DeleteHashEntry(tls, (*TTkCursor)(unsafe.Pointer(cursorPtr)).FidHashPtr) prevPtr = (*TTcl_HashEntry)(unsafe.Pointer((*TTkCursor)(unsafe.Pointer(cursorPtr)).FhashPtr)).FclientData if prevPtr == cursorPtr { if (*TTkCursor)(unsafe.Pointer(cursorPtr)).FnextPtr == libc.UintptrFromInt32(0) { libtcl9_0.XTcl_DeleteHashEntry(tls, (*TTkCursor)(unsafe.Pointer(cursorPtr)).FhashPtr) } else { (*TTcl_HashEntry)(unsafe.Pointer((*TTkCursor)(unsafe.Pointer(cursorPtr)).FhashPtr)).FclientData = (*TTkCursor)(unsafe.Pointer(cursorPtr)).FnextPtr } } else { for (*TTkCursor)(unsafe.Pointer(prevPtr)).FnextPtr != cursorPtr { prevPtr = (*TTkCursor)(unsafe.Pointer(prevPtr)).FnextPtr } (*TTkCursor)(unsafe.Pointer(prevPtr)).FnextPtr = (*TTkCursor)(unsafe.Pointer(cursorPtr)).FnextPtr } XTkpFreeCursor(tls, cursorPtr) if (*TTkCursor)(unsafe.Pointer(cursorPtr)).FobjRefCount == 0 { libtcl9_0.XTcl_Free(tls, cursorPtr) } } /* *---------------------------------------------------------------------- * * Tk_FreeCursor -- * * This function is called to release a cursor allocated by Tk_GetCursor * or TkGetCursorFromData. * * Results: * None. * * Side effects: * The reference count associated with cursor is decremented, and it is * officially deallocated if no-one is using it anymore. * *---------------------------------------------------------------------- */ func XTk_FreeCursor(tls *libc.TLS, display uintptr, cursor TTk_Cursor) { /* Identifier for cursor to be released. */ var dispPtr, idHashPtr uintptr _, _ = dispPtr, idHashPtr dispPtr = XTkGetDisplay(tls, display) if !((*TTkDisplay)(unsafe.Pointer(dispPtr)).FcursorInit != 0) { libtcl9_0.XTcl_Panic(tls, __ccgo_ts+8649, 0) } idHashPtr = (*(*func(*libc.TLS, uintptr, uintptr) uintptr)(unsafe.Pointer(&struct{ uintptr }{(*TTcl_HashTable)(unsafe.Pointer(dispPtr + 1168)).FfindProc})))(tls, dispPtr+1168, cursor) if idHashPtr == libc.UintptrFromInt32(0) { libtcl9_0.XTcl_Panic(tls, __ccgo_ts+8690, 0) } _FreeCursor(tls, (*TTcl_HashEntry)(unsafe.Pointer(idHashPtr)).FclientData) } /* *---------------------------------------------------------------------- * * Tk_FreeCursorFromObj -- * * This function is called to release a cursor allocated by * Tk_AllocCursorFromObj. It does not throw away the Tcl_Obj *; it only * gets rid of the hash table entry for this cursor and clears the cached * value that is normally stored in the object. * * Results: * None. * * Side effects: * The reference count associated with the cursor represented by objPtr * is decremented, and the cursor is released to X if there are no * remaining uses for it. * *---------------------------------------------------------------------- */ func XTk_FreeCursorFromObj(tls *libc.TLS, tkwin TTk_Window, objPtr uintptr) { /* The Tcl_Obj * to be freed. */ _FreeCursor(tls, _GetCursorFromObj(tls, tkwin, objPtr)) _FreeCursorObj(tls, objPtr) } /* *--------------------------------------------------------------------------- * * FreeCursorObjProc, FreeCursorObj -- * * This proc is called to release an object reference to a cursor. * Called when the object's internal rep is released or when the cached * tkColPtr needs to be changed. * * Results: * None. * * Side effects: * The object reference count is decremented. When both it and the hash * ref count go to zero, the color's resources are released. * *--------------------------------------------------------------------------- */ func _FreeCursorObjProc(tls *libc.TLS, objPtr uintptr) { /* The object we are releasing. */ _FreeCursorObj(tls, objPtr) (*TTcl_Obj)(unsafe.Pointer(objPtr)).FtypePtr = libc.UintptrFromInt32(0) } func _FreeCursorObj(tls *libc.TLS, objPtr uintptr) { /* The object we are releasing. */ var cursorPtr, v2 uintptr var v1 TTcl_Size _, _, _ = cursorPtr, v1, v2 cursorPtr = (*(*struct { Fptr1 uintptr Fptr2 uintptr })(unsafe.Pointer(objPtr + 32))).Fptr1 if cursorPtr != libc.UintptrFromInt32(0) { v2 = cursorPtr + 24 v1 = *(*TTcl_Size)(unsafe.Pointer(v2)) *(*TTcl_Size)(unsafe.Pointer(v2))-- if v1 <= int64(1) && (*TTkCursor)(unsafe.Pointer(cursorPtr)).FresourceRefCount == 0 { libtcl9_0.XTcl_Free(tls, cursorPtr) } (*(*struct { Fptr1 uintptr Fptr2 uintptr })(unsafe.Pointer(objPtr + 32))).Fptr1 = libc.UintptrFromInt32(0) } } /* *--------------------------------------------------------------------------- * * DupCursorObjProc -- * * When a cached cursor object is duplicated, this is called to update * the internal reps. * * Results: * None. * * Side effects: * The color's objRefCount is incremented and the internal rep of the * copy is set to point to it. * *--------------------------------------------------------------------------- */ func _DupCursorObjProc(tls *libc.TLS, srcObjPtr uintptr, dupObjPtr uintptr) { /* The object we are copying to. */ var cursorPtr uintptr _ = cursorPtr cursorPtr = (*(*struct { Fptr1 uintptr Fptr2 uintptr })(unsafe.Pointer(srcObjPtr + 32))).Fptr1 (*TTcl_Obj)(unsafe.Pointer(dupObjPtr)).FtypePtr = (*TTcl_Obj)(unsafe.Pointer(srcObjPtr)).FtypePtr (*(*struct { Fptr1 uintptr Fptr2 uintptr })(unsafe.Pointer(dupObjPtr + 32))).Fptr1 = cursorPtr if cursorPtr != libc.UintptrFromInt32(0) { (*TTkCursor)(unsafe.Pointer(cursorPtr)).FobjRefCount++ } } /* *---------------------------------------------------------------------- * * Tk_GetCursorFromObj -- * * Returns the cursor referred to buy a Tcl object. The cursor must * already have been allocated via a call to Tk_AllocCursorFromObj or * Tk_GetCursor. * * Results: * Returns the Tk_Cursor that matches the tkwin and the string rep of the * name of the cursor given in objPtr. * * Side effects: * If the object is not already a cursor, the conversion will free any * old internal representation. * *---------------------------------------------------------------------- */ func XTk_GetCursorFromObj(tls *libc.TLS, tkwin TTk_Window, objPtr uintptr) (r TTk_Cursor) { /* The object from which to get pixels. */ var cursorPtr uintptr _ = cursorPtr cursorPtr = _GetCursorFromObj(tls, tkwin, objPtr) /* * GetCursorFromObj should never return NULL */ return (*TTkCursor)(unsafe.Pointer(cursorPtr)).Fcursor } /* *---------------------------------------------------------------------- * * GetCursorFromObj -- * * Returns the cursor referred to by a Tcl object. The cursor must * already have been allocated via a call to Tk_AllocCursorFromObj or * Tk_GetCursor. * * Results: * Returns the TkCursor * that matches the tkwin and the string rep of * the name of the cursor given in objPtr. * * Side effects: * If the object is not already a cursor, the conversion will free any * old internal representation. * *---------------------------------------------------------------------- */ func _GetCursorFromObj(tls *libc.TLS, tkwin TTk_Window, objPtr uintptr) (r uintptr) { /* The object that describes the desired * cursor. */ var cursorPtr, dispPtr, hashPtr uintptr _, _, _ = cursorPtr, dispPtr, hashPtr dispPtr = (*TTkWindow)(unsafe.Pointer(tkwin)).FdispPtr if (*TTcl_Obj)(unsafe.Pointer(objPtr)).FtypePtr != uintptr(unsafe.Pointer(&XtkCursorObjType)) { _InitCursorObj(tls, objPtr) } /* * The internal representation is a cache of the last cursor used with the * given name. But there can be lots different cursors for each cursor * name; one cursor for each display. Check to see if the cursor we have * cached is the one that is needed. */ cursorPtr = (*(*struct { Fptr1 uintptr Fptr2 uintptr })(unsafe.Pointer(objPtr + 32))).Fptr1 if cursorPtr != libc.UintptrFromInt32(0) && (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fdisplay == (*TTkCursor)(unsafe.Pointer(cursorPtr)).Fdisplay { return cursorPtr } /* * If we get to here, it means the cursor we need is not in the cache. * Try to look up the cursor in the TkDisplay structure of the window. */ hashPtr = (*(*func(*libc.TLS, uintptr, uintptr) uintptr)(unsafe.Pointer(&struct{ uintptr }{(*TTcl_HashTable)(unsafe.Pointer(dispPtr + 960)).FfindProc})))(tls, dispPtr+960, libtcl9_0.XTcl_GetStringFromObj(tls, objPtr, libc.UintptrFromInt32(0))) if hashPtr == libc.UintptrFromInt32(0) { goto error } cursorPtr = (*TTcl_HashEntry)(unsafe.Pointer(hashPtr)).FclientData for { if !(cursorPtr != libc.UintptrFromInt32(0)) { break } if (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fdisplay == (*TTkCursor)(unsafe.Pointer(cursorPtr)).Fdisplay { _FreeCursorObj(tls, objPtr) (*(*struct { Fptr1 uintptr Fptr2 uintptr })(unsafe.Pointer(objPtr + 32))).Fptr1 = cursorPtr (*TTkCursor)(unsafe.Pointer(cursorPtr)).FobjRefCount++ return cursorPtr } goto _1 _1: ; cursorPtr = (*TTkCursor)(unsafe.Pointer(cursorPtr)).FnextPtr } goto error error: ; libtcl9_0.XTcl_Panic(tls, __ccgo_ts+8737, 0) /* * The following code isn't reached; it's just there to please compilers. */ return libc.UintptrFromInt32(0) } /* *---------------------------------------------------------------------- * * InitCursorObj -- * * Bookeeping function to change an objPtr to a cursor type. * * Results: * None. * * Side effects: * The old internal rep of the object is freed. The internal rep is * cleared. The final form of the object is set by either * Tk_AllocCursorFromObj or GetCursorFromObj. * *---------------------------------------------------------------------- */ func _InitCursorObj(tls *libc.TLS, objPtr uintptr) { /* The object to convert. */ var typePtr uintptr _ = typePtr /* * Free the old internalRep before setting the new one. */ libtcl9_0.XTcl_GetStringFromObj(tls, objPtr, libc.UintptrFromInt32(0)) typePtr = (*TTcl_Obj)(unsafe.Pointer(objPtr)).FtypePtr if typePtr != libc.UintptrFromInt32(0) && (*TTcl_ObjType)(unsafe.Pointer(typePtr)).FfreeIntRepProc != libc.UintptrFromInt32(0) { (*(*func(*libc.TLS, uintptr))(unsafe.Pointer(&struct{ uintptr }{(*TTcl_ObjType)(unsafe.Pointer(typePtr)).FfreeIntRepProc})))(tls, objPtr) } (*TTcl_Obj)(unsafe.Pointer(objPtr)).FtypePtr = uintptr(unsafe.Pointer(&XtkCursorObjType)) (*(*struct { Fptr1 uintptr Fptr2 uintptr })(unsafe.Pointer(objPtr + 32))).Fptr1 = libc.UintptrFromInt32(0) } /* *---------------------------------------------------------------------- * * CursorInit -- * * Initialize the structures used for cursor management. * * Results: * None. * * Side effects: * Read the code. * *---------------------------------------------------------------------- */ func _CursorInit(tls *libc.TLS, dispPtr uintptr) { /* Display used to store thread-specific * data. */ libtcl9_0.XTcl_InitHashTable(tls, dispPtr+960, TCL_STRING_KEYS) libtcl9_0.XTcl_InitHashTable(tls, dispPtr+1064, libc.Int32FromUint64(libc.Uint64FromInt64(56)/libc.Uint64FromInt64(4))) /* * The call below is tricky: can't use sizeof(IdKey) because it gets * padded with extra unpredictable bytes on some 64-bit machines. */ /* * Old code.... * Tcl_InitHashTable(&dispPtr->cursorIdTable, sizeof(Display *) * /sizeof(int)); * * The comment above doesn't make sense. However, XIDs should only be 32 * bits, by the definition of X, so the code above causes Tk to crash. * Here is the real code: */ libtcl9_0.XTcl_InitHashTable(tls, dispPtr+1168, int32(TCL_ONE_WORD_KEYS)) (*TTkDisplay)(unsafe.Pointer(dispPtr)).FcursorInit = int32(1) } /* *---------------------------------------------------------------------- * * TkDebugCursor -- * * This function returns debugging information about a cursor. * * Results: * The return value is a list with one sublist for each TkCursor * corresponding to "name". Each sublist has two elements that contain * the resourceRefCount and objRefCount fields from the TkCursor * structure. * * Side effects: * None. * *---------------------------------------------------------------------- */ func XTkDebugCursor(tls *libc.TLS, tkwin TTk_Window, name uintptr) (r uintptr) { /* Name of the desired color. */ var cursorPtr, dispPtr, hashPtr, objPtr, resultPtr uintptr _, _, _, _, _ = cursorPtr, dispPtr, hashPtr, objPtr, resultPtr dispPtr = (*TTkWindow)(unsafe.Pointer(tkwin)).FdispPtr if !((*TTkDisplay)(unsafe.Pointer(dispPtr)).FcursorInit != 0) { _CursorInit(tls, dispPtr) } resultPtr = libtcl9_0.XTcl_NewObj(tls) hashPtr = (*(*func(*libc.TLS, uintptr, uintptr) uintptr)(unsafe.Pointer(&struct{ uintptr }{(*TTcl_HashTable)(unsafe.Pointer(dispPtr + 960)).FfindProc})))(tls, dispPtr+960, name) if hashPtr != libc.UintptrFromInt32(0) { cursorPtr = (*TTcl_HashEntry)(unsafe.Pointer(hashPtr)).FclientData if cursorPtr == libc.UintptrFromInt32(0) { libtcl9_0.XTcl_Panic(tls, __ccgo_ts+8787, 0) } for { if !(cursorPtr != libc.UintptrFromInt32(0)) { break } objPtr = libtcl9_0.XTcl_NewObj(tls) libtcl9_0.XTcl_ListObjAppendElement(tls, libc.UintptrFromInt32(0), objPtr, libtcl9_0.XTcl_NewWideIntObj(tls, (*TTkCursor)(unsafe.Pointer(cursorPtr)).FresourceRefCount)) libtcl9_0.XTcl_ListObjAppendElement(tls, libc.UintptrFromInt32(0), objPtr, libtcl9_0.XTcl_NewWideIntObj(tls, (*TTkCursor)(unsafe.Pointer(cursorPtr)).FobjRefCount)) libtcl9_0.XTcl_ListObjAppendElement(tls, libc.UintptrFromInt32(0), resultPtr, objPtr) goto _1 _1: ; cursorPtr = (*TTkCursor)(unsafe.Pointer(cursorPtr)).FnextPtr } } return resultPtr } /* * Local Variables: * mode: c * c-basic-offset: 4 * fill-column: 78 * End: */ /* * The default X error handler gets saved here, so that it can be invoked if * an error occurs that we can't handle. */ type TTkXErrorHandler = uintptr var _defaultHandler = uintptr(0) func init() { p := unsafe.Pointer(&_defaultHandler) *(*uintptr)(unsafe.Add(p, 0)) = libc.UintptrFromInt32(0) } /* *-------------------------------------------------------------- * * Tk_CreateErrorHandler -- * * Arrange for all a given procedure to be invoked whenever certain * errors occur. * * Results: * The return value is a token identifying the handler; it must be passed * to Tk_DeleteErrorHandler to delete the handler. * * Side effects: * If an X error occurs that matches the error, request, and minor * arguments, then errorProc will be invoked. ErrorProc should have the * following structure: * * int * errorProc(caddr_t clientData, XErrorEvent *errorEventPtr) { * } * * The clientData argument will be the same as the clientData argument to * this procedure, and errorEvent will describe the error. If errorProc * returns 0, it means that it completely "handled" the error: no further * processing should be done. If errorProc returns 1, it means that it * didn't know how to deal with the error, so we should look for other * error handlers, or invoke the default error handler if no other * handler returns zero. Handlers are invoked in order of age: youngest * handler first. * * Note: errorProc will only be called for errors associated with X * requests made AFTER this call, but BEFORE the handler is deleted by * calling Tk_DeleteErrorHandler. * *-------------------------------------------------------------- */ func XTk_CreateErrorHandler(tls *libc.TLS, display uintptr, error1 int32, request int32, minorCode int32, errorProc uintptr, clientData uintptr) (r TTk_ErrorHandler) { /* Arbitrary value to pass to errorProc. */ var dispPtr, errorPtr uintptr _, _ = dispPtr, errorPtr /* * Find the display. If Tk doesn't know about this display then it's an * error: panic. */ dispPtr = XTkGetDisplay(tls, display) if dispPtr == libc.UintptrFromInt32(0) { libtcl9_0.XTcl_Panic(tls, __ccgo_ts+8830, 0) } /* * Make sure that X calls us whenever errors occur. */ if _defaultHandler == libc.UintptrFromInt32(0) { _defaultHandler = libx11.XXSetErrorHandler(tls, __ccgo_fp(_ErrorProc)) } /* * Create the handler record. */ errorPtr = libtcl9_0.XTcl_Alloc(tls, uint64(64)) (*TTkErrorHandler)(unsafe.Pointer(errorPtr)).FdispPtr = dispPtr (*TTkErrorHandler)(unsafe.Pointer(errorPtr)).FfirstRequest = (*struct { Fext_data uintptr Fprivate1 uintptr Ffd int32 Fprivate2 int32 Fproto_major_version int32 Fproto_minor_version int32 Fvendor uintptr Fprivate3 TXID Fprivate4 TXID Fprivate5 TXID Fprivate6 int32 Fresource_alloc uintptr Fbyte_order int32 Fbitmap_unit int32 Fbitmap_pad int32 Fbitmap_bit_order int32 Fnformats int32 Fpixmap_format uintptr Fprivate8 int32 Frelease int32 Fprivate9 uintptr Fprivate10 uintptr Fqlen int32 Flast_request_read uint64 Frequest uint64 Fprivate11 TXPointer Fprivate12 TXPointer Fprivate13 TXPointer Fprivate14 TXPointer Fmax_request_size uint32 Fdb uintptr Fprivate15 uintptr Fdisplay_name uintptr Fdefault_screen int32 Fnscreens int32 Fscreens uintptr Fmotion_buffer uint64 Fprivate16 uint64 Fmin_keycode int32 Fmax_keycode int32 Fprivate17 TXPointer Fprivate18 TXPointer Fprivate19 int32 Fxdefaults uintptr })(unsafe.Pointer(display)).Frequest + uint64(1) (*TTkErrorHandler)(unsafe.Pointer(errorPtr)).FlastRequest = libc.Uint64FromInt32(-libc.Int32FromInt32(1)) (*TTkErrorHandler)(unsafe.Pointer(errorPtr)).Ferror1 = error1 (*TTkErrorHandler)(unsafe.Pointer(errorPtr)).Frequest = request (*TTkErrorHandler)(unsafe.Pointer(errorPtr)).FminorCode = minorCode (*TTkErrorHandler)(unsafe.Pointer(errorPtr)).FerrorProc = errorProc (*TTkErrorHandler)(unsafe.Pointer(errorPtr)).FclientData = clientData (*TTkErrorHandler)(unsafe.Pointer(errorPtr)).FnextPtr = (*TTkDisplay)(unsafe.Pointer(dispPtr)).FerrorPtr (*TTkDisplay)(unsafe.Pointer(dispPtr)).FerrorPtr = errorPtr return errorPtr } /* *-------------------------------------------------------------- * * Tk_DeleteErrorHandler -- * * Do not use an error handler anymore. * * Results: * None. * * Side effects: * The handler denoted by the "handler" argument will not be invoked for * any X errors associated with requests made after this call. However, * if errors arrive later for requests made BEFORE this call, then the * handler will still be invoked. Call XSync if you want to be sure that * all outstanding errors have been received and processed. * *-------------------------------------------------------------- */ func XTk_DeleteErrorHandler(tls *libc.TLS, handler TTk_ErrorHandler) { /* Token for handler to delete; was previous * return value from Tk_CreateErrorHandler. */ var dispPtr, errorPtr, nextPtr, prevPtr, v2 uintptr var lastSerial uint64 var v1 TTcl_Size _, _, _, _, _, _, _ = dispPtr, errorPtr, lastSerial, nextPtr, prevPtr, v1, v2 errorPtr = handler dispPtr = (*TTkErrorHandler)(unsafe.Pointer(errorPtr)).FdispPtr (*TTkErrorHandler)(unsafe.Pointer(errorPtr)).FlastRequest = (*struct { Fext_data uintptr Fprivate1 uintptr Ffd int32 Fprivate2 int32 Fproto_major_version int32 Fproto_minor_version int32 Fvendor uintptr Fprivate3 TXID Fprivate4 TXID Fprivate5 TXID Fprivate6 int32 Fresource_alloc uintptr Fbyte_order int32 Fbitmap_unit int32 Fbitmap_pad int32 Fbitmap_bit_order int32 Fnformats int32 Fpixmap_format uintptr Fprivate8 int32 Frelease int32 Fprivate9 uintptr Fprivate10 uintptr Fqlen int32 Flast_request_read uint64 Frequest uint64 Fprivate11 TXPointer Fprivate12 TXPointer Fprivate13 TXPointer Fprivate14 TXPointer Fmax_request_size uint32 Fdb uintptr Fprivate15 uintptr Fdisplay_name uintptr Fdefault_screen int32 Fnscreens int32 Fscreens uintptr Fmotion_buffer uint64 Fprivate16 uint64 Fmin_keycode int32 Fmax_keycode int32 Fprivate17 TXPointer Fprivate18 TXPointer Fprivate19 int32 Fxdefaults uintptr })(unsafe.Pointer((*TTkDisplay)(unsafe.Pointer(dispPtr)).Fdisplay)).Frequest + uint64(1) - uint64(1) /* * Ensure that no user callback for this handler is invoked any further. */ (*TTkErrorHandler)(unsafe.Pointer(errorPtr)).FerrorProc = libc.UintptrFromInt32(0) /* * Every once-in-a-while, cleanup handlers that are no longer active. We * probably won't be able to free the handler that was just deleted (need * to wait for any outstanding requests to be processed by server), but * there may be previously-deleted handlers that are now ready for garbage * collection. To reduce the cost of the cleanup, let a few dead handlers * pile up, then clean them all at once. This adds a bit of overhead to * errors that might occur while the dead handlers are hanging around, but * reduces the overhead of scanning the list to clean up (particularly if * there are many handlers that stay around forever). */ v2 = dispPtr + 1312 v1 = *(*TTcl_Size)(unsafe.Pointer(v2)) *(*TTcl_Size)(unsafe.Pointer(v2))++ if v1 >= int64(9) { lastSerial = (*struct { Fext_data uintptr Fprivate1 uintptr Ffd int32 Fprivate2 int32 Fproto_major_version int32 Fproto_minor_version int32 Fvendor uintptr Fprivate3 TXID Fprivate4 TXID Fprivate5 TXID Fprivate6 int32 Fresource_alloc uintptr Fbyte_order int32 Fbitmap_unit int32 Fbitmap_pad int32 Fbitmap_bit_order int32 Fnformats int32 Fpixmap_format uintptr Fprivate8 int32 Frelease int32 Fprivate9 uintptr Fprivate10 uintptr Fqlen int32 Flast_request_read uint64 Frequest uint64 Fprivate11 TXPointer Fprivate12 TXPointer Fprivate13 TXPointer Fprivate14 TXPointer Fmax_request_size uint32 Fdb uintptr Fprivate15 uintptr Fdisplay_name uintptr Fdefault_screen int32 Fnscreens int32 Fscreens uintptr Fmotion_buffer uint64 Fprivate16 uint64 Fmin_keycode int32 Fmax_keycode int32 Fprivate17 TXPointer Fprivate18 TXPointer Fprivate19 int32 Fxdefaults uintptr })(unsafe.Pointer((*TTkDisplay)(unsafe.Pointer(dispPtr)).Fdisplay)).Flast_request_read /* * Last chance to catch errors for this handler: if no event/error * processing took place to follow up the end of this error handler * we need a round trip with the X server now. */ if (*TTkErrorHandler)(unsafe.Pointer(errorPtr)).FlastRequest > lastSerial { libx11.XXSync(tls, (*TTkDisplay)(unsafe.Pointer(dispPtr)).Fdisplay, False) } (*TTkDisplay)(unsafe.Pointer(dispPtr)).FdeleteCount = 0 errorPtr = (*TTkDisplay)(unsafe.Pointer(dispPtr)).FerrorPtr prevPtr = libc.UintptrFromInt32(0) for { if !(errorPtr != libc.UintptrFromInt32(0)) { break } nextPtr = (*TTkErrorHandler)(unsafe.Pointer(errorPtr)).FnextPtr if (*TTkErrorHandler)(unsafe.Pointer(errorPtr)).FlastRequest != libc.Uint64FromInt32(-libc.Int32FromInt32(1)) && (*TTkErrorHandler)(unsafe.Pointer(errorPtr)).FlastRequest <= lastSerial { if prevPtr == libc.UintptrFromInt32(0) { (*TTkDisplay)(unsafe.Pointer(dispPtr)).FerrorPtr = nextPtr } else { (*TTkErrorHandler)(unsafe.Pointer(prevPtr)).FnextPtr = nextPtr } libtcl9_0.XTcl_Free(tls, errorPtr) goto _3 } prevPtr = errorPtr goto _3 _3: ; errorPtr = nextPtr } } } /* *-------------------------------------------------------------- * * ErrorProc -- * * This procedure is invoked by the X system when error events arrive. * * Results: * If it returns, the return value is zero. However, it is possible that * one of the error handlers may just exit. * * Side effects: * This procedure does two things. First, it uses the serial # in the * error event to eliminate handlers whose expiration serials are now in * the past. Second, it invokes any handlers that want to deal with the * error. * *-------------------------------------------------------------- */ func _ErrorProc(tls *libc.TLS, display uintptr, errEventPtr uintptr) (r int32) { /* Information about error. */ var dispPtr, errorPtr uintptr var w TWindow _, _, _ = dispPtr, errorPtr, w /* * See if we know anything about the display. If not, then invoke the * default error handler. */ dispPtr = XTkGetDisplay(tls, display) if dispPtr == libc.UintptrFromInt32(0) { goto couldntHandle } /* * Otherwise invoke any relevant handlers for the error, in order. */ errorPtr = (*TTkDisplay)(unsafe.Pointer(dispPtr)).FerrorPtr for { if !(errorPtr != libc.UintptrFromInt32(0)) { break } if (*TTkErrorHandler)(unsafe.Pointer(errorPtr)).FfirstRequest > (*TXErrorEvent)(unsafe.Pointer(errEventPtr)).Fserial || (*TTkErrorHandler)(unsafe.Pointer(errorPtr)).Ferror1 != -int32(1) && (*TTkErrorHandler)(unsafe.Pointer(errorPtr)).Ferror1 != libc.Int32FromUint8((*TXErrorEvent)(unsafe.Pointer(errEventPtr)).Ferror_code) || (*TTkErrorHandler)(unsafe.Pointer(errorPtr)).Frequest != -int32(1) && (*TTkErrorHandler)(unsafe.Pointer(errorPtr)).Frequest != libc.Int32FromUint8((*TXErrorEvent)(unsafe.Pointer(errEventPtr)).Frequest_code) || (*TTkErrorHandler)(unsafe.Pointer(errorPtr)).FminorCode != -int32(1) && (*TTkErrorHandler)(unsafe.Pointer(errorPtr)).FminorCode != libc.Int32FromUint8((*TXErrorEvent)(unsafe.Pointer(errEventPtr)).Fminor_code) || (*TTkErrorHandler)(unsafe.Pointer(errorPtr)).FlastRequest != libc.Uint64FromInt32(-libc.Int32FromInt32(1)) && (*TTkErrorHandler)(unsafe.Pointer(errorPtr)).FlastRequest < (*TXErrorEvent)(unsafe.Pointer(errEventPtr)).Fserial { goto _1 } if (*TTkErrorHandler)(unsafe.Pointer(errorPtr)).FerrorProc == libc.UintptrFromInt32(0) || (*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*TTkErrorHandler)(unsafe.Pointer(errorPtr)).FerrorProc})))(tls, (*TTkErrorHandler)(unsafe.Pointer(errorPtr)).FclientData, errEventPtr) == 0 { return 0 } goto _1 _1: ; errorPtr = (*TTkErrorHandler)(unsafe.Pointer(errorPtr)).FnextPtr } /* * See if the error is a BadWindow error. If so, and it refers to a window * that still exists in our window table, then ignore the error. Errors * like this can occur if a window owned by us is deleted by someone * externally, like a window manager. We'll ignore the errors at least * long enough to clean up internally and remove the entry from the window * table. * * NOTE: For embedding, we must also check whether the window was recently * deleted. If so, it may be that Tk generated operations on windows that * were deleted by the container. Now we are getting the errors * (BadWindow) after Tk already deleted the window itself. */ if libc.Int32FromUint8((*TXErrorEvent)(unsafe.Pointer(errEventPtr)).Ferror_code) == int32(BadWindow) { w = (*TXErrorEvent)(unsafe.Pointer(errEventPtr)).Fresourceid if XTk_IdToWindow(tls, display, w) != libc.UintptrFromInt32(0) { return 0 } } /* * We couldn't handle the error. Use the default handler. */ goto couldntHandle couldntHandle: ; return (*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{_defaultHandler})))(tls, display, errEventPtr) return r } /* * Local Variables: * mode: c * c-basic-offset: 4 * fill-column: 78 * End: */ /* * There's a potential problem if a handler is deleted while it's current * (i.e. its function is executing), since Tk_HandleEvent will need to read * the handler's "nextPtr" field when the function returns. To handle this * problem, structures of the type below indicate the next handler to be * processed for any (recursively nested) dispatches in progress. The * nextHandler fields get updated if the handlers pointed to are deleted. * Tk_HandleEvent also needs to know if the entire window gets deleted; the * winPtr field is set to zero if that particular window gets deleted. */ type TInProgress = struct { FeventPtr uintptr FwinPtr uintptr FnextHandler uintptr FnextPtr uintptr } /* * For each call to Tk_CreateGenericHandler or Tk_CreateClientMessageHandler, * an instance of the following structure will be created. All of the active * handlers are linked into a list. */ type TGenericHandler = struct { Fproc uintptr FclientData uintptr FdeleteFlag int32 FnextPtr uintptr } /* * There's a potential problem if Tk_HandleEvent is entered recursively. A * handler cannot be deleted physically until we have returned from calling * it. Otherwise, we're looking at unallocated memory in advancing to its * `next' entry. We deal with the problem by using the `delete flag' and * deleting handlers only when it's known that there's no handler active. */ /* * The following structure is used for queueing X-style events on the Tcl * event queue. */ type TTkWindowEvent = struct { Fheader TTcl_Event Fevent TXEvent } /* * Array of event masks corresponding to each X event: */ var _eventMasks = [40]uint64{ 2: libc.Uint64FromInt64(libc.Int64FromInt64(1) << libc.Int32FromInt32(0)), 3: libc.Uint64FromInt64(libc.Int64FromInt64(1) << libc.Int32FromInt32(1)), 4: libc.Uint64FromInt64(libc.Int64FromInt64(1) << libc.Int32FromInt32(2)), 5: libc.Uint64FromInt64(libc.Int64FromInt64(1) << libc.Int32FromInt32(3)), 6: libc.Uint64FromInt64(libc.Int64FromInt64(1)< uint32(Button9) { v1 = uint32(0) } else { v1 = _buttonMasks[button] } return v1 } /* *---------------------------------------------------------------------- * * InvokeClientMessageHandlers -- * * Iterate the list of handlers and invoke the function pointer for each. * * Results: * None. * * Side effects: * Handlers may be deleted and events may be sent to handlers. * *---------------------------------------------------------------------- */ func _InvokeClientMessageHandlers(tls *libc.TLS, tsdPtr uintptr, tkwin TTk_Window, eventPtr uintptr) { var curPtr, prevPtr, tmpPtr uintptr var done int32 _, _, _, _ = curPtr, done, prevPtr, tmpPtr curPtr = (*TThreadSpecificData3)(unsafe.Pointer(tsdPtr)).FcmList prevPtr = libc.UintptrFromInt32(0) for { if !(curPtr != libc.UintptrFromInt32(0)) { break } if (*TGenericHandler)(unsafe.Pointer(curPtr)).FdeleteFlag != 0 { if !((*TThreadSpecificData3)(unsafe.Pointer(tsdPtr)).FhandlersActive != 0) { /* * This handler needs to be deleted and there are no calls * pending through any handlers, so now is a safe time to * delete it. */ tmpPtr = (*TGenericHandler)(unsafe.Pointer(curPtr)).FnextPtr if prevPtr == libc.UintptrFromInt32(0) { (*TThreadSpecificData3)(unsafe.Pointer(tsdPtr)).FcmList = tmpPtr } else { (*TGenericHandler)(unsafe.Pointer(prevPtr)).FnextPtr = tmpPtr } if tmpPtr == libc.UintptrFromInt32(0) { (*TThreadSpecificData3)(unsafe.Pointer(tsdPtr)).FlastCmPtr = prevPtr } libtcl9_0.XTcl_Free(tls, curPtr) curPtr = tmpPtr goto _1 } } else { (*TThreadSpecificData3)(unsafe.Pointer(tsdPtr)).FhandlersActive++ done = (*(*func(*libc.TLS, TTk_Window, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*TGenericHandler)(unsafe.Pointer(curPtr)).Fproc})))(tls, tkwin, eventPtr) (*TThreadSpecificData3)(unsafe.Pointer(tsdPtr)).FhandlersActive-- if done != 0 { break } } prevPtr = curPtr curPtr = (*TGenericHandler)(unsafe.Pointer(curPtr)).FnextPtr goto _1 _1: } } /* *---------------------------------------------------------------------- * * InvokeGenericHandlers -- * * Iterate the list of handlers and invoke the function pointer for each. * If the handler invoked returns a non-zero value then we are done. * * Results: * 0 when the event wasn't handled by a handler. Non-zero when it was * processed and handled by a handler. * * Side effects: * Handlers may be deleted and events may be sent to handlers. * *---------------------------------------------------------------------- */ func _InvokeGenericHandlers(tls *libc.TLS, tsdPtr uintptr, eventPtr uintptr) (r int32) { var curPtr, prevPtr, tmpPtr uintptr var done int32 _, _, _, _ = curPtr, done, prevPtr, tmpPtr curPtr = (*TThreadSpecificData3)(unsafe.Pointer(tsdPtr)).FgenericList prevPtr = libc.UintptrFromInt32(0) for { if !(curPtr != libc.UintptrFromInt32(0)) { break } if (*TGenericHandler)(unsafe.Pointer(curPtr)).FdeleteFlag != 0 { if !((*TThreadSpecificData3)(unsafe.Pointer(tsdPtr)).FhandlersActive != 0) { /* * This handler needs to be deleted and there are no calls * pending through the handler, so now is a safe time to * delete it. */ tmpPtr = (*TGenericHandler)(unsafe.Pointer(curPtr)).FnextPtr if prevPtr == libc.UintptrFromInt32(0) { (*TThreadSpecificData3)(unsafe.Pointer(tsdPtr)).FgenericList = tmpPtr } else { (*TGenericHandler)(unsafe.Pointer(prevPtr)).FnextPtr = tmpPtr } if tmpPtr == libc.UintptrFromInt32(0) { (*TThreadSpecificData3)(unsafe.Pointer(tsdPtr)).FlastGenericPtr = prevPtr } libtcl9_0.XTcl_Free(tls, curPtr) curPtr = tmpPtr goto _1 } } else { (*TThreadSpecificData3)(unsafe.Pointer(tsdPtr)).FhandlersActive++ done = (*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*TGenericHandler)(unsafe.Pointer(curPtr)).Fproc})))(tls, (*TGenericHandler)(unsafe.Pointer(curPtr)).FclientData, eventPtr) (*TThreadSpecificData3)(unsafe.Pointer(tsdPtr)).FhandlersActive-- if done != 0 { return done } } prevPtr = curPtr curPtr = (*TGenericHandler)(unsafe.Pointer(curPtr)).FnextPtr goto _1 _1: } return 0 } /* *---------------------------------------------------------------------- * * Tk_CreateEventHandler -- * * Arrange for a given function to be invoked whenever events from a * given class occur in a given window. * * Results: * None. * * Side effects: * From now on, whenever an event of the type given by mask occurs for * token and is processed by Tk_HandleEvent, proc will be called. See the * manual entry for details of the calling sequence and return value for * proc. * *---------------------------------------------------------------------- */ func XTk_CreateEventHandler(tls *libc.TLS, token TTk_Window, mask uint64, proc uintptr, clientData uintptr) { /* Arbitrary data to pass to proc. */ var found int32 var handlerPtr, winPtr uintptr _, _, _ = found, handlerPtr, winPtr winPtr = token /* * Skim through the list of existing handlers to (a) compute the overall * event mask for the window (so we can pass this new value to the X * system) and (b) see if there's already a handler declared with the same * callback and clientData (if so, just change the mask). If no existing * handler matches, then create a new handler. */ if (*TTkWindow)(unsafe.Pointer(winPtr)).FhandlerList == libc.UintptrFromInt32(0) { /* * No event handlers defined at all, so must create. */ handlerPtr = libtcl9_0.XTcl_Alloc(tls, uint64(32)) (*TTkWindow)(unsafe.Pointer(winPtr)).FhandlerList = handlerPtr } else { found = 0 handlerPtr = (*TTkWindow)(unsafe.Pointer(winPtr)).FhandlerList for { if (*TTkEventHandler)(unsafe.Pointer(handlerPtr)).Fproc == proc && (*TTkEventHandler)(unsafe.Pointer(handlerPtr)).FclientData == clientData { (*TTkEventHandler)(unsafe.Pointer(handlerPtr)).Fmask = mask found = int32(1) } if (*TTkEventHandler)(unsafe.Pointer(handlerPtr)).FnextPtr == libc.UintptrFromInt32(0) { break } goto _1 _1: ; handlerPtr = (*TTkEventHandler)(unsafe.Pointer(handlerPtr)).FnextPtr } /* * If we found anything, we're done because we do not need to use * XSelectInput; Tk always selects on all events anyway in order to * support binding on classes, 'all' and other bind-tags. */ if found != 0 { return } /* * No event handler matched, so create a new one. */ (*TTkEventHandler)(unsafe.Pointer(handlerPtr)).FnextPtr = libtcl9_0.XTcl_Alloc(tls, uint64(32)) handlerPtr = (*TTkEventHandler)(unsafe.Pointer(handlerPtr)).FnextPtr } /* * Initialize the new event handler. */ (*TTkEventHandler)(unsafe.Pointer(handlerPtr)).Fmask = mask (*TTkEventHandler)(unsafe.Pointer(handlerPtr)).Fproc = proc (*TTkEventHandler)(unsafe.Pointer(handlerPtr)).FclientData = clientData (*TTkEventHandler)(unsafe.Pointer(handlerPtr)).FnextPtr = libc.UintptrFromInt32(0) /* * No need to call XSelectInput: Tk always selects on all events for all * windows (needed to support bindings on classes and "all"). */ } /* *---------------------------------------------------------------------- * * Tk_DeleteEventHandler -- * * Delete a previously-created handler. * * Results: * None. * * Side effects: * If there existed a handler as described by the parameters, the handler * is deleted so that proc will not be invoked again. * *---------------------------------------------------------------------- */ func XTk_DeleteEventHandler(tls *libc.TLS, token TTk_Window, mask uint64, proc uintptr, clientData uintptr) { var handlerPtr, ipPtr, prevPtr, tsdPtr, winPtr uintptr _, _, _, _, _ = handlerPtr, ipPtr, prevPtr, tsdPtr, winPtr winPtr = token tsdPtr = libtcl9_0.XTcl_GetThreadData(tls, uintptr(unsafe.Pointer(&_dataKey3)), int64(80)) /* * Find the event handler to be deleted, or return immediately if it * doesn't exist. */ handlerPtr = (*TTkWindow)(unsafe.Pointer(winPtr)).FhandlerList prevPtr = libc.UintptrFromInt32(0) for { if handlerPtr == libc.UintptrFromInt32(0) { return } if (*TTkEventHandler)(unsafe.Pointer(handlerPtr)).Fmask == mask && (*TTkEventHandler)(unsafe.Pointer(handlerPtr)).Fproc == proc && (*TTkEventHandler)(unsafe.Pointer(handlerPtr)).FclientData == clientData { break } goto _1 _1: ; prevPtr = handlerPtr handlerPtr = (*TTkEventHandler)(unsafe.Pointer(handlerPtr)).FnextPtr } /* * If Tk_HandleEvent is about to process this handler, tell it to process * the next one instead. */ ipPtr = (*TThreadSpecificData3)(unsafe.Pointer(tsdPtr)).FpendingPtr for { if !(ipPtr != libc.UintptrFromInt32(0)) { break } if (*TInProgress)(unsafe.Pointer(ipPtr)).FnextHandler == handlerPtr { (*TInProgress)(unsafe.Pointer(ipPtr)).FnextHandler = (*TTkEventHandler)(unsafe.Pointer(handlerPtr)).FnextPtr } goto _2 _2: ; ipPtr = (*TInProgress)(unsafe.Pointer(ipPtr)).FnextPtr } /* * Free resources associated with the handler. */ if prevPtr == libc.UintptrFromInt32(0) { (*TTkWindow)(unsafe.Pointer(winPtr)).FhandlerList = (*TTkEventHandler)(unsafe.Pointer(handlerPtr)).FnextPtr } else { (*TTkEventHandler)(unsafe.Pointer(prevPtr)).FnextPtr = (*TTkEventHandler)(unsafe.Pointer(handlerPtr)).FnextPtr } libtcl9_0.XTcl_Free(tls, handlerPtr) /* * No need to call XSelectInput: Tk always selects on all events for all * windows (needed to support bindings on classes and "all"). */ } /*---------------------------------------------------------------------- * * Tk_CreateGenericHandler -- * * Register a function to be called on each X event, regardless of * display or window. Generic handlers are useful for capturing events * that aren't associated with windows, or events for windows not managed * by Tk. * * Results: * None. * * Side Effects: * From now on, whenever an X event is given to Tk_HandleEvent, invoke * proc, giving it clientData and the event as arguments. * *---------------------------------------------------------------------- */ func XTk_CreateGenericHandler(tls *libc.TLS, proc uintptr, clientData uintptr) { /* One-word value to pass to proc. */ var handlerPtr, tsdPtr uintptr _, _ = handlerPtr, tsdPtr tsdPtr = libtcl9_0.XTcl_GetThreadData(tls, uintptr(unsafe.Pointer(&_dataKey3)), int64(80)) handlerPtr = libtcl9_0.XTcl_Alloc(tls, uint64(32)) (*TGenericHandler)(unsafe.Pointer(handlerPtr)).Fproc = proc (*TGenericHandler)(unsafe.Pointer(handlerPtr)).FclientData = clientData (*TGenericHandler)(unsafe.Pointer(handlerPtr)).FdeleteFlag = 0 (*TGenericHandler)(unsafe.Pointer(handlerPtr)).FnextPtr = libc.UintptrFromInt32(0) if (*TThreadSpecificData3)(unsafe.Pointer(tsdPtr)).FgenericList == libc.UintptrFromInt32(0) { (*TThreadSpecificData3)(unsafe.Pointer(tsdPtr)).FgenericList = handlerPtr } else { (*TGenericHandler)(unsafe.Pointer((*TThreadSpecificData3)(unsafe.Pointer(tsdPtr)).FlastGenericPtr)).FnextPtr = handlerPtr } (*TThreadSpecificData3)(unsafe.Pointer(tsdPtr)).FlastGenericPtr = handlerPtr } /* *---------------------------------------------------------------------- * * Tk_DeleteGenericHandler -- * * Delete a previously-created generic handler. * * Results: * None. * * Side Effects: * If there existed a handler as described by the parameters, that * handler is logically deleted so that proc will not be invoked again. * The physical deletion happens in the event loop in Tk_HandleEvent. * *---------------------------------------------------------------------- */ func XTk_DeleteGenericHandler(tls *libc.TLS, proc uintptr, clientData uintptr) { var handler, tsdPtr uintptr _, _ = handler, tsdPtr tsdPtr = libtcl9_0.XTcl_GetThreadData(tls, uintptr(unsafe.Pointer(&_dataKey3)), int64(80)) handler = (*TThreadSpecificData3)(unsafe.Pointer(tsdPtr)).FgenericList for { if !(handler != 0) { break } if (*TGenericHandler)(unsafe.Pointer(handler)).Fproc == proc && (*TGenericHandler)(unsafe.Pointer(handler)).FclientData == clientData { (*TGenericHandler)(unsafe.Pointer(handler)).FdeleteFlag = int32(1) } goto _1 _1: ; handler = (*TGenericHandler)(unsafe.Pointer(handler)).FnextPtr } } /*---------------------------------------------------------------------- * * Tk_CreateClientMessageHandler -- * * Register a function to be called on each ClientMessage event. * ClientMessage handlers are useful for Drag&Drop extensions. * * Results: * None. * * Side Effects: * From now on, whenever a ClientMessage event is received that isn't a * WM_PROTOCOL event or SelectionEvent, invoke proc, giving it tkwin and * the event as arguments. * *---------------------------------------------------------------------- */ func XTk_CreateClientMessageHandler(tls *libc.TLS, proc uintptr) { /* Function to call on event. */ var handlerPtr, tsdPtr uintptr _, _ = handlerPtr, tsdPtr tsdPtr = libtcl9_0.XTcl_GetThreadData(tls, uintptr(unsafe.Pointer(&_dataKey3)), int64(80)) /* * We use a GenericHandler struct, because it's basically the same, except * with an extra clientData field we'll never use. */ handlerPtr = libtcl9_0.XTcl_Alloc(tls, uint64(32)) (*TGenericHandler)(unsafe.Pointer(handlerPtr)).Fproc = proc (*TGenericHandler)(unsafe.Pointer(handlerPtr)).FclientData = libc.UintptrFromInt32(0) /* never used */ (*TGenericHandler)(unsafe.Pointer(handlerPtr)).FdeleteFlag = 0 (*TGenericHandler)(unsafe.Pointer(handlerPtr)).FnextPtr = libc.UintptrFromInt32(0) if (*TThreadSpecificData3)(unsafe.Pointer(tsdPtr)).FcmList == libc.UintptrFromInt32(0) { (*TThreadSpecificData3)(unsafe.Pointer(tsdPtr)).FcmList = handlerPtr } else { (*TGenericHandler)(unsafe.Pointer((*TThreadSpecificData3)(unsafe.Pointer(tsdPtr)).FlastCmPtr)).FnextPtr = handlerPtr } (*TThreadSpecificData3)(unsafe.Pointer(tsdPtr)).FlastCmPtr = handlerPtr } /* *---------------------------------------------------------------------- * * Tk_DeleteClientMessageHandler -- * * Delete a previously-created ClientMessage handler. * * Results: * None. * * Side Effects: * If there existed a handler as described by the parameters, that * handler is logically deleted so that proc will not be invoked again. * The physical deletion happens in the event loop in * TkClientMessageEventProc. * *---------------------------------------------------------------------- */ func XTk_DeleteClientMessageHandler(tls *libc.TLS, proc uintptr) { var handler, tsdPtr uintptr _, _ = handler, tsdPtr tsdPtr = libtcl9_0.XTcl_GetThreadData(tls, uintptr(unsafe.Pointer(&_dataKey3)), int64(80)) handler = (*TThreadSpecificData3)(unsafe.Pointer(tsdPtr)).FcmList for { if !(handler != libc.UintptrFromInt32(0)) { break } if (*TGenericHandler)(unsafe.Pointer(handler)).Fproc == proc { (*TGenericHandler)(unsafe.Pointer(handler)).FdeleteFlag = int32(1) } goto _1 _1: ; handler = (*TGenericHandler)(unsafe.Pointer(handler)).FnextPtr } } /* *---------------------------------------------------------------------- * * TkXErrorHandler -- * * TkXErrorHandler is an error handler, to be installed via * Tk_CreateErrorHandler, that will set a flag if an X error occurred. * * Results: * Always returns 0, indicating that the X error was handled. * * Side effects: * None. * *---------------------------------------------------------------------- */ func _TkXErrorHandler(tls *libc.TLS, clientData uintptr, dummy1013 uintptr) (r int32) { /* X error info. */ var error1 uintptr _ = error1 error1 = clientData *(*int32)(unsafe.Pointer(error1)) = int32(1) return 0 } /* *---------------------------------------------------------------------- * * ParentXId -- * * Returns the parent of the given window, or "None" if the window * doesn't exist. * * Results: * Returns an X window ID. * * Side effects: * None. * *---------------------------------------------------------------------- */ func _ParentXId(tls *libc.TLS, display uintptr, w TWindow) (r TWindow) { bp := tls.Alloc(48) defer tls.Free(48) var handler TTk_ErrorHandler var status int32 var _ /* childList at bp+24 */ uintptr var _ /* gotXError at bp+0 */ int32 var _ /* nChildren at bp+32 */ uint32 var _ /* parent at bp+8 */ TWindow var _ /* root at bp+16 */ TWindow _, _ = handler, status /* * Handle errors ourselves. */ *(*int32)(unsafe.Pointer(bp)) = 0 handler = XTk_CreateErrorHandler(tls, display, -int32(1), -int32(1), -int32(1), __ccgo_fp(_TkXErrorHandler), bp) /* * Get the parent window. */ status = libx11.XXQueryTree(tls, display, w, bp+16, bp+8, bp+24, bp+32) /* * Do some cleanup; gotta return "None" if we got an error. */ XTk_DeleteErrorHandler(tls, handler) libx11.XXSync(tls, display, False) if status != 0 && *(*uintptr)(unsafe.Pointer(bp + 24)) != libc.UintptrFromInt32(0) { libx11.XXFree(tls, *(*uintptr)(unsafe.Pointer(bp + 24))) } if status == 0 { *(*TWindow)(unsafe.Pointer(bp + 8)) = uint64(0) } return *(*TWindow)(unsafe.Pointer(bp + 8)) } /* *---------------------------------------------------------------------- * * Tk_HandleEvent -- * * Given an event, invoke all the handlers that have been registered for * the event. * * Results: * None. * * Side effects: * Depends on the handlers. * *---------------------------------------------------------------------- */ func XTk_HandleEvent(tls *libc.TLS, eventPtr uintptr) { bp := tls.Alloc(48) defer tls.Free(48) /* Event to dispatch. */ var but, result, v1 int32 var handlerPtr, interp, tsdPtr uintptr var mask uint64 var _ /* ip at bp+8 */ TInProgress var _ /* winPtr at bp+0 */ uintptr _, _, _, _, _, _, _ = but, handlerPtr, interp, mask, result, tsdPtr, v1 interp = libc.UintptrFromInt32(0) tsdPtr = libtcl9_0.XTcl_GetThreadData(tls, uintptr(unsafe.Pointer(&_dataKey3)), int64(80)) if (*TXEvent)(unsafe.Pointer(eventPtr)).Ftype1 == int32(ButtonRelease) || (*TXEvent)(unsafe.Pointer(eventPtr)).Ftype1 == int32(ButtonPress) { if (*(*TXButtonEvent)(unsafe.Pointer(eventPtr))).Fbutton >= uint32(Button4) && (*(*TXButtonEvent)(unsafe.Pointer(eventPtr))).Fbutton < uint32(Button8) { if (*TXEvent)(unsafe.Pointer(eventPtr)).Ftype1 == int32(ButtonRelease) { return } else { /* eventPtr->type == ButtonPress */ but = libc.Int32FromUint32((*(*TXButtonEvent)(unsafe.Pointer(eventPtr))).Fbutton) (*TXEvent)(unsafe.Pointer(eventPtr)).Ftype1 = libc.Int32FromInt32(MappingNotify) + libc.Int32FromInt32(4) (*(*TXAnyEvent)(unsafe.Pointer(eventPtr))).Fsend_event = -int32(1) if but&int32(1) != 0 { v1 = -int32(120) } else { v1 = int32(120) } (*(*TXKeyEvent)(unsafe.Pointer(eventPtr))).Fkeycode = libc.Uint32FromInt32(v1) if but > int32(Button5) { (*(*TXKeyEvent)(unsafe.Pointer(eventPtr))).Fstate |= libc.Uint32FromInt32(libc.Int32FromInt32(1) << libc.Int32FromInt32(0)) } } } } /* * If the generic handler processed this event we are done and can return. */ if _InvokeGenericHandlers(tls, tsdPtr, eventPtr) != 0 { goto releaseEventResources } if _RefreshKeyboardMappingIfNeeded(tls, eventPtr) != 0 { /* * We are done with a MappingNotify event. */ goto releaseEventResources } mask = _GetEventMaskFromXEvent(tls, eventPtr) *(*uintptr)(unsafe.Pointer(bp)) = _GetTkWindowFromXEvent(tls, eventPtr) if *(*uintptr)(unsafe.Pointer(bp)) == libc.UintptrFromInt32(0) { goto releaseEventResources } /* * Once a window has started getting deleted, don't process any more * events for it except for the DestroyNotify event. This check is needed * because a DestroyNotify handler could re-invoke the event loop, causing * other pending events to be handled for the window (the window doesn't * get totally expunged from our tables until after the DestroyNotify * event has been completely handled). */ if (*TTkWindow)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp)))).Fflags&uint32(TK_ALREADY_DEAD) != 0 && (*TXEvent)(unsafe.Pointer(eventPtr)).Ftype1 != int32(DestroyNotify) { goto releaseEventResources } if (*TTkWindow)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp)))).FmainPtr != libc.UintptrFromInt32(0) { interp = (*TTkMainInfo)(unsafe.Pointer((*TTkWindow)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp)))).FmainPtr)).Finterp /* * Protect interpreter for this window from possible deletion while we * are dealing with the event for this window. Thus, widget writers do * not have to worry about protecting the interpreter in their own * code. */ libtcl9_0.XTcl_Preserve(tls, interp) result = libc.BoolInt32(_InvokeFocusHandlers(tls, bp, mask, eventPtr) != 0 || _InvokeMouseHandlers(tls, *(*uintptr)(unsafe.Pointer(bp)), mask, eventPtr) != 0) if result != 0 { goto releaseInterpreter } } /* * Create the input context for the window if it hasn't already been done * (XFilterEvent needs this context). When the event is a FocusIn event, * set the input context focus to the receiving window. This code is only * ever active for X11. */ /* * If the XIC has been invalidated, it must be recreated. */ if (*TTkDisplay)(unsafe.Pointer((*TTkWindow)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp)))).FdispPtr)).FximGeneration != (*TTkWindow)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp)))).FximGeneration { *(*uint32)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp)) + 280)) &= libc.Uint32FromInt32(^libc.Int32FromInt32(TK_CHECKED_IC)) (*TTkWindow)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp)))).FinputContext = libc.UintptrFromInt32(0) } if (*TTkDisplay)(unsafe.Pointer((*TTkWindow)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp)))).FdispPtr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(1)< 0 { libtcl9_0.XTcl_DoOneEvent(tls, 0) } } type TTkWindowEvent1 = struct { Fheader TTcl_Event Fevent TXEvent } /* * Local Variables: * mode: c * c-basic-offset: 4 * fill-column: 78 * End: */ /* * For each top-level window that has ever received the focus, there is a * record of the following type: */ type TToplevelFocusInfo = struct { FtopLevelPtr uintptr FfocusWinPtr uintptr FnextPtr uintptr } /* * Local Variables: * mode: c * c-basic-offset: 4 * fill-column: 78 * End: */ /* * For each top-level window that has ever received the focus, there is a * record of the following type: */ type TTkToplevelFocusInfo = TToplevelFocusInfo /* * One of the following structures exists for each display used by each * application. These are linked together from the TkMainInfo structure. * These structures are needed because it isn't sufficient to store a single * piece of focus information in each display or in each application: we need * the cross-product. There needs to be separate information for each display, * because it's possible to have multiple focus windows active simultaneously * on different displays. There also needs to be separate information for each * application, because of embedding: if an embedded application has the * focus, its container application also has the focus. Thus we keep a list of * structures for each application: the same display can appear in structures * for several applications at once. */ type TDisplayFocusInfo = struct { FdispPtr uintptr FfocusWinPtr uintptr FfocusOnMapPtr uintptr FforceFocus int32 FfocusSerial uint64 FnextPtr uintptr } /* * One of the following structures exists for each display used by each * application. These are linked together from the TkMainInfo structure. * These structures are needed because it isn't sufficient to store a single * piece of focus information in each display or in each application: we need * the cross-product. There needs to be separate information for each display, * because it's possible to have multiple focus windows active simultaneously * on different displays. There also needs to be separate information for each * application, because of embedding: if an embedded application has the * focus, its container application also has the focus. Thus we keep a list of * structures for each application: the same display can appear in structures * for several applications at once. */ type TTkDisplayFocusInfo = TDisplayFocusInfo /* *-------------------------------------------------------------- * * Tk_FocusObjCmd -- * * This function is invoked to process the "focus" Tcl command. See the * user documentation for details on what it does. * * Results: * A standard Tcl result. * * Side effects: * See the user documentation. * *-------------------------------------------------------------- */ func XTk_FocusObjCmd(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) (r int32) { bp := tls.Alloc(16) defer tls.Free(16) /* Argument objects. */ var focusWin, tkwin TTk_Window var newPtr, tlFocusPtr, topLevelPtr, winPtr, windowName uintptr var _ /* index at bp+0 */ int32 _, _, _, _, _, _, _ = focusWin, newPtr, tkwin, tlFocusPtr, topLevelPtr, winPtr, windowName tkwin = clientData winPtr = clientData /* * If invoked with no arguments, just return the current focus window. */ if objc == int32(1) { focusWin = XTkGetFocusWin(tls, winPtr) if focusWin != libc.UintptrFromInt32(0) { libtcl9_0.XTcl_SetObjResult(tls, interp, XTk_NewWindowObj(tls, focusWin)) } return TCL_OK } /* * If invoked with a single argument beginning with "." then focus on that * window. */ if objc == int32(2) { windowName = libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8)), libc.UintptrFromInt32(0)) /* * The empty string case exists for backwards compatibility. */ if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(windowName))) == int32('\000') { return TCL_OK } if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(windowName))) == int32('.') { newPtr = XTk_NameToWindow(tls, interp, windowName, tkwin) if newPtr == libc.UintptrFromInt32(0) { return int32(TCL_ERROR) } XTkSetFocusWin(tls, newPtr, 0) return TCL_OK } } /* * We have a subcommand to parse and act upon. */ if libtcl9_0.XTcl_GetIndexFromObjStruct(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 1*8)), uintptr(unsafe.Pointer(&_focusOptions)), libc.Int64FromUint64(libc.Uint64FromInt64(8)), __ccgo_ts+2689, libc.Int32FromInt32(0)|libc.Int32FromUint64(libc.Uint64FromInt64(4)<focusPtr, but only if it currently is the same as * this application's focusWinPtr: this check is needed to handle * embedded applications in the same process. */ if (*TTkDisplay)(unsafe.Pointer(dispPtr)).FfocusPtr == (*TDisplayFocusInfo)(unsafe.Pointer(displayFocusPtr)).FfocusWinPtr { (*TTkDisplay)(unsafe.Pointer(dispPtr)).FfocusPtr = libc.UintptrFromInt32(0) } (*TDisplayFocusInfo)(unsafe.Pointer(displayFocusPtr)).FfocusWinPtr = libc.UintptrFromInt32(0) } else { if (*TXEvent)(unsafe.Pointer(eventPtr)).Ftype1 == int32(EnterNotify) { /* * If there is no window manager, or if the window manager isn't * moving the focus around (e.g. the disgusting "NoTitleFocus" option * has been selected in twm), then we won't get FocusIn or FocusOut * events. Instead, the "focus" field will be set in an Enter event to * indicate that we've already got the focus when the mouse enters the * window (even though we didn't get a FocusIn event). Watch for this * and grab the focus when it happens. Note: if this is an embedded * application then don't accept the focus implicitly like this; the * container application will give us the focus explicitly if it wants * us to have it. */ if (*(*TXCrossingEvent)(unsafe.Pointer(eventPtr))).Ffocus != 0 && (*TDisplayFocusInfo)(unsafe.Pointer(displayFocusPtr)).FfocusWinPtr == libc.UintptrFromInt32(0) && !((*TTkWindow)(unsafe.Pointer(winPtr)).Fflags&libc.Uint32FromInt32(TK_EMBEDDED) != 0) { if (*TTkDisplay)(unsafe.Pointer(dispPtr)).FfocusDebug != 0 { libc.Xprintf(tls, __ccgo_ts+9158, libc.VaList(bp+8, (*TTkWindow)(unsafe.Pointer(newFocusPtr)).FpathName)) libc.Xfflush(tls, libc.Xstdout) } _GenerateFocusEvents(tls, (*TDisplayFocusInfo)(unsafe.Pointer(displayFocusPtr)).FfocusWinPtr, newFocusPtr) (*TDisplayFocusInfo)(unsafe.Pointer(displayFocusPtr)).FfocusWinPtr = newFocusPtr (*TTkDisplay)(unsafe.Pointer(dispPtr)).FimplicitWinPtr = winPtr (*TTkDisplay)(unsafe.Pointer(dispPtr)).FfocusPtr = newFocusPtr } } else { if (*TXEvent)(unsafe.Pointer(eventPtr)).Ftype1 == int32(LeaveNotify) { /* * If the pointer just left a window for which we automatically * claimed the focus on enter, move the focus back to the root window, * where it was before we claimed it above. Note: * dispPtr->implicitWinPtr may not be the same as * displayFocusPtr->focusWinPtr (e.g. because the "focus" command was * used to redirect the focus after it arrived at * dispPtr->implicitWinPtr)!! In addition, we generate events because * the window manager won't give us a FocusOut event when we focus on * the root. */ if (*TTkDisplay)(unsafe.Pointer(dispPtr)).FimplicitWinPtr != libc.UintptrFromInt32(0) && !((*TTkWindow)(unsafe.Pointer(winPtr)).Fflags&libc.Uint32FromInt32(TK_EMBEDDED) != 0) { if (*TTkDisplay)(unsafe.Pointer(dispPtr)).FfocusDebug != 0 { libc.Xprintf(tls, __ccgo_ts+9185, libc.VaList(bp+8, (*TTkWindow1)(unsafe.Pointer((*TDisplayFocusInfo)(unsafe.Pointer(displayFocusPtr)).FfocusWinPtr)).FpathName)) libc.Xfflush(tls, libc.Xstdout) } _GenerateFocusEvents(tls, (*TDisplayFocusInfo)(unsafe.Pointer(displayFocusPtr)).FfocusWinPtr, libc.UintptrFromInt32(0)) libx11.XXSetInputFocus(tls, (*TTkDisplay)(unsafe.Pointer(dispPtr)).Fdisplay, uint64(1), libc.Int32FromInt64(1), uint64(0)) (*TDisplayFocusInfo)(unsafe.Pointer(displayFocusPtr)).FfocusWinPtr = libc.UintptrFromInt32(0) (*TTkDisplay)(unsafe.Pointer(dispPtr)).FimplicitWinPtr = libc.UintptrFromInt32(0) (*TTkDisplay)(unsafe.Pointer(dispPtr)).FfocusPtr = libc.UintptrFromInt32(0) } } } } } return retValue } /* *---------------------------------------------------------------------- * * TkSetFocusWin -- * * This function is invoked to change the focus window for a given * display in a given application. * * Results: * None. * * Side effects: * Event handlers may be invoked to process the change of * focus. * *---------------------------------------------------------------------- */ func XTkSetFocusWin(tls *libc.TLS, winPtr uintptr, force int32) { /* If non-zero, set the X focus to this window * even if the application doesn't currently * have the X focus. */ var allMapped, serial int32 var displayFocusPtr, displayFocusPtr2, focusPtr, tlFocusPtr, topLevelPtr uintptr _, _, _, _, _, _, _ = allMapped, displayFocusPtr, displayFocusPtr2, focusPtr, serial, tlFocusPtr, topLevelPtr /* * Don't set focus if window is already dead. [Bug 3574708] */ if (*TTkWindow)(unsafe.Pointer(winPtr)).Fflags&uint32(TK_ALREADY_DEAD) != 0 { return } /* * Get the current focus window with the same display and application * as winPtr. */ displayFocusPtr = _FindDisplayFocusInfo(tls, (*TTkWindow)(unsafe.Pointer(winPtr)).FmainPtr, (*TTkWindow)(unsafe.Pointer(winPtr)).FdispPtr) /* * Do nothing if the window already has focus and force is not set. If * force is set, we need to grab the focus, since under Windows or macOS * this may involve taking control away from another application. */ if winPtr == (*TDisplayFocusInfo)(unsafe.Pointer(displayFocusPtr)).FfocusWinPtr && !(force != 0) { return } /* * Find the toplevel window for winPtr, then find (or create) a record * for the toplevel. Also see whether winPtr and all its ancestors are * mapped. */ allMapped = int32(1) topLevelPtr = winPtr for { if topLevelPtr == libc.UintptrFromInt32(0) { /* * The window is being deleted. No point in worrying about giving * it the focus. */ return } if !((*TTkWindow)(unsafe.Pointer(topLevelPtr)).Fflags&libc.Uint32FromInt32(TK_MAPPED) != 0) { allMapped = 0 } if (*TTkWindow)(unsafe.Pointer(topLevelPtr)).Fflags&uint32(TK_TOP_HIERARCHY) != 0 { break } goto _1 _1: ; topLevelPtr = (*TTkWindow)(unsafe.Pointer(topLevelPtr)).FparentPtr } /* * If any ancestor of the new focus window isn't mapped, then we can't set * focus for it (X will generate an error, for example). Instead, create * an event handler that will set the focus to this window once it gets * mapped. At the same time, delete any old handler that might be around; * it's no longer relevant. */ if (*TDisplayFocusInfo)(unsafe.Pointer(displayFocusPtr)).FfocusOnMapPtr != libc.UintptrFromInt32(0) { XTk_DeleteEventHandler(tls, (*TDisplayFocusInfo)(unsafe.Pointer(displayFocusPtr)).FfocusOnMapPtr, libc.Uint64FromInt64(libc.Int64FromInt64(1)<focusPtr * is kept properly in sync with the "truth", which is the value in * displayFocusPtr->focusWinPtr. */ if focusWinPtr != libc.UintptrFromInt32(0) && (*TTkWindow)(unsafe.Pointer(focusWinPtr)).FmainPtr == (*TTkWindow)(unsafe.Pointer(winPtr)).FmainPtr { /* * Map the x and y coordinates to make sense in the context of the * focus window, if possible (make both -1 if the map-from and map-to * windows don't share the same screen). */ if (*TTkWindow)(unsafe.Pointer(focusWinPtr)).Fdisplay != (*TTkWindow)(unsafe.Pointer(winPtr)).Fdisplay || (*TTkWindow)(unsafe.Pointer(focusWinPtr)).FscreenNum != (*TTkWindow)(unsafe.Pointer(winPtr)).FscreenNum { (*(*TXKeyEvent)(unsafe.Pointer(eventPtr))).Fx = -int32(1) (*(*TXKeyEvent)(unsafe.Pointer(eventPtr))).Fy = -int32(1) } else { XTk_GetRootCoords(tls, focusWinPtr, bp, bp+4) (*(*TXKeyEvent)(unsafe.Pointer(eventPtr))).Fx = (*(*TXKeyEvent)(unsafe.Pointer(eventPtr))).Fx_root - *(*int32)(unsafe.Pointer(bp)) (*(*TXKeyEvent)(unsafe.Pointer(eventPtr))).Fy = (*(*TXKeyEvent)(unsafe.Pointer(eventPtr))).Fy_root - *(*int32)(unsafe.Pointer(bp + 4)) } (*(*TXKeyEvent)(unsafe.Pointer(eventPtr))).Fwindow = (*TTkWindow)(unsafe.Pointer(focusWinPtr)).Fwindow return focusWinPtr } /* * The event doesn't belong to us. Perhaps, due to embedding, it really * belongs to someone else. Give the embedding code a chance to redirect * the event. */ XTkpRedirectKeyEvent(tls, winPtr, eventPtr) return libc.UintptrFromInt32(0) } /* *---------------------------------------------------------------------- * * TkFocusDeadWindow -- * * This function is invoked when it is determined that a window is dead. * It cleans up focus-related information about the window. * * Results: * None. * * Side effects: * Various things get cleaned up and recycled. * *---------------------------------------------------------------------- */ func XTkFocusDeadWindow(tls *libc.TLS, winPtr uintptr) { bp := tls.Alloc(32) defer tls.Free(32) /* Information about the window that is being * deleted. */ var dispPtr, displayFocusPtr, prevPtr, tlFocusPtr uintptr var noMatch int32 _, _, _, _, _ = dispPtr, displayFocusPtr, noMatch, prevPtr, tlFocusPtr dispPtr = (*TTkWindow)(unsafe.Pointer(winPtr)).FdispPtr noMatch = int32(1) /* * Certain special windows like those used for send and clipboard have no * mainPtr. */ if (*TTkWindow)(unsafe.Pointer(winPtr)).FmainPtr == libc.UintptrFromInt32(0) { return } /* * Search for focus records that refer to this window either as the * top-level window or the current focus window. */ displayFocusPtr = _FindDisplayFocusInfo(tls, (*TTkWindow)(unsafe.Pointer(winPtr)).FmainPtr, (*TTkWindow)(unsafe.Pointer(winPtr)).FdispPtr) prevPtr = libc.UintptrFromInt32(0) tlFocusPtr = (*TTkMainInfo)(unsafe.Pointer((*TTkWindow)(unsafe.Pointer(winPtr)).FmainPtr)).FtlFocusPtr for { if !(tlFocusPtr != libc.UintptrFromInt32(0)) { break } if winPtr == (*TToplevelFocusInfo)(unsafe.Pointer(tlFocusPtr)).FtopLevelPtr { /* * The top-level window is the one being deleted: free the focus * record and release the focus back to PointerRoot if we acquired * it implicitly. */ if (*TTkDisplay)(unsafe.Pointer(dispPtr)).FimplicitWinPtr == winPtr { if (*TTkDisplay)(unsafe.Pointer(dispPtr)).FfocusDebug != 0 { libc.Xprintf(tls, __ccgo_ts+9220, libc.VaList(bp+8, (*TTkWindow)(unsafe.Pointer((*TToplevelFocusInfo)(unsafe.Pointer(tlFocusPtr)).FtopLevelPtr)).FpathName)) libc.Xfflush(tls, libc.Xstdout) } (*TTkDisplay)(unsafe.Pointer(dispPtr)).FimplicitWinPtr = libc.UintptrFromInt32(0) (*TDisplayFocusInfo)(unsafe.Pointer(displayFocusPtr)).FfocusWinPtr = libc.UintptrFromInt32(0) (*TTkDisplay)(unsafe.Pointer(dispPtr)).FfocusPtr = libc.UintptrFromInt32(0) } if (*TDisplayFocusInfo)(unsafe.Pointer(displayFocusPtr)).FfocusWinPtr == (*TToplevelFocusInfo)(unsafe.Pointer(tlFocusPtr)).FfocusWinPtr { (*TDisplayFocusInfo)(unsafe.Pointer(displayFocusPtr)).FfocusWinPtr = libc.UintptrFromInt32(0) (*TTkDisplay)(unsafe.Pointer(dispPtr)).FfocusPtr = libc.UintptrFromInt32(0) } if prevPtr == libc.UintptrFromInt32(0) { (*TTkMainInfo)(unsafe.Pointer((*TTkWindow)(unsafe.Pointer(winPtr)).FmainPtr)).FtlFocusPtr = (*TToplevelFocusInfo)(unsafe.Pointer(tlFocusPtr)).FnextPtr } else { (*TToplevelFocusInfo)(unsafe.Pointer(prevPtr)).FnextPtr = (*TToplevelFocusInfo)(unsafe.Pointer(tlFocusPtr)).FnextPtr } libtcl9_0.XTcl_Free(tls, tlFocusPtr) noMatch = 0 break } else { if winPtr == (*TToplevelFocusInfo)(unsafe.Pointer(tlFocusPtr)).FfocusWinPtr { /* * The deleted window had the focus for its top-level: move the * focus to the top-level itself. */ (*TToplevelFocusInfo)(unsafe.Pointer(tlFocusPtr)).FfocusWinPtr = (*TToplevelFocusInfo)(unsafe.Pointer(tlFocusPtr)).FtopLevelPtr if (*TDisplayFocusInfo)(unsafe.Pointer(displayFocusPtr)).FfocusWinPtr == winPtr && !((*TTkWindow)(unsafe.Pointer((*TToplevelFocusInfo)(unsafe.Pointer(tlFocusPtr)).FtopLevelPtr)).Fflags&libc.Uint32FromInt32(TK_ALREADY_DEAD) != 0) { if (*TTkDisplay)(unsafe.Pointer(dispPtr)).FfocusDebug != 0 { libc.Xprintf(tls, __ccgo_ts+9259, libc.VaList(bp+8, (*TTkWindow)(unsafe.Pointer((*TToplevelFocusInfo)(unsafe.Pointer(tlFocusPtr)).FtopLevelPtr)).FpathName, (*TTkWindow)(unsafe.Pointer(winPtr)).FpathName)) libc.Xfflush(tls, libc.Xstdout) } _GenerateFocusEvents(tls, (*TDisplayFocusInfo)(unsafe.Pointer(displayFocusPtr)).FfocusWinPtr, (*TToplevelFocusInfo)(unsafe.Pointer(tlFocusPtr)).FtopLevelPtr) (*TDisplayFocusInfo)(unsafe.Pointer(displayFocusPtr)).FfocusWinPtr = (*TToplevelFocusInfo)(unsafe.Pointer(tlFocusPtr)).FtopLevelPtr (*TTkDisplay)(unsafe.Pointer(dispPtr)).FfocusPtr = (*TToplevelFocusInfo)(unsafe.Pointer(tlFocusPtr)).FtopLevelPtr } noMatch = 0 break } } goto _1 _1: ; prevPtr = tlFocusPtr tlFocusPtr = (*TToplevelFocusInfo)(unsafe.Pointer(tlFocusPtr)).FnextPtr } /* * Occasionally, things can become unsynchronized. Move them back into * synch now. [Bug 2496114] */ if (*TDisplayFocusInfo)(unsafe.Pointer(displayFocusPtr)).FfocusWinPtr == winPtr { if (*TTkDisplay)(unsafe.Pointer(dispPtr)).FfocusDebug != 0 { libc.Xprintf(tls, __ccgo_ts+9297, libc.VaList(bp+8, (*TTkWindow)(unsafe.Pointer(winPtr)).FpathName)) libc.Xfflush(tls, libc.Xstdout) } (*TDisplayFocusInfo)(unsafe.Pointer(displayFocusPtr)).FfocusWinPtr = libc.UintptrFromInt32(0) } if (*TDisplayFocusInfo)(unsafe.Pointer(displayFocusPtr)).FfocusOnMapPtr == winPtr { (*TDisplayFocusInfo)(unsafe.Pointer(displayFocusPtr)).FfocusOnMapPtr = libc.UintptrFromInt32(0) } /* * It may happen that the search above for focus records that refer * to this window did not find any match. In such a case, when the * dead window had the focus, release it. */ if noMatch != 0 && (*TTkDisplay)(unsafe.Pointer(dispPtr)).FfocusPtr == winPtr { (*TTkDisplay)(unsafe.Pointer(dispPtr)).FfocusPtr = libc.UintptrFromInt32(0) } } /* *---------------------------------------------------------------------- * * GenerateFocusEvents -- * * This function is called to create FocusIn and FocusOut events to move * the input focus from one window to another. * * Results: * None. * * Side effects: * FocusIn and FocusOut events are generated. * *---------------------------------------------------------------------- */ func _GenerateFocusEvents(tls *libc.TLS, sourcePtr uintptr, destPtr uintptr) { bp := tls.Alloc(192) defer tls.Free(192) /* New window to have the focus (may be * NULL). */ var winPtr uintptr var _ /* event at bp+0 */ TXEvent _ = winPtr winPtr = sourcePtr if winPtr == libc.UintptrFromInt32(0) { winPtr = destPtr if winPtr == libc.UintptrFromInt32(0) { return } } (*(*TXFocusChangeEvent)(unsafe.Pointer(&*(*TXEvent)(unsafe.Pointer(bp))))).Fserial = (*struct { Fext_data uintptr Fprivate1 uintptr Ffd int32 Fprivate2 int32 Fproto_major_version int32 Fproto_minor_version int32 Fvendor uintptr Fprivate3 TXID Fprivate4 TXID Fprivate5 TXID Fprivate6 int32 Fresource_alloc uintptr Fbyte_order int32 Fbitmap_unit int32 Fbitmap_pad int32 Fbitmap_bit_order int32 Fnformats int32 Fpixmap_format uintptr Fprivate8 int32 Frelease int32 Fprivate9 uintptr Fprivate10 uintptr Fqlen int32 Flast_request_read uint64 Frequest uint64 Fprivate11 TXPointer Fprivate12 TXPointer Fprivate13 TXPointer Fprivate14 TXPointer Fmax_request_size uint32 Fdb uintptr Fprivate15 uintptr Fdisplay_name uintptr Fdefault_screen int32 Fnscreens int32 Fscreens uintptr Fmotion_buffer uint64 Fprivate16 uint64 Fmin_keycode int32 Fmax_keycode int32 Fprivate17 TXPointer Fprivate18 TXPointer Fprivate19 int32 Fxdefaults uintptr })(unsafe.Pointer((*TTkWindow)(unsafe.Pointer(winPtr)).Fdisplay)).Flast_request_read (*(*TXFocusChangeEvent)(unsafe.Pointer(&*(*TXEvent)(unsafe.Pointer(bp))))).Fsend_event = libc.Int32FromInt32(0x547321ac) (*(*TXFocusChangeEvent)(unsafe.Pointer(&*(*TXEvent)(unsafe.Pointer(bp))))).Fdisplay = (*TTkWindow)(unsafe.Pointer(winPtr)).Fdisplay (*(*TXFocusChangeEvent)(unsafe.Pointer(&*(*TXEvent)(unsafe.Pointer(bp))))).Fmode = NotifyNormal XTkInOutEvents(tls, bp, sourcePtr, destPtr, int32(FocusOut), int32(FocusIn), int32(TCL_QUEUE_MARK)) } /* *---------------------------------------------------------------------- * * FocusMapProc -- * * This function is called as an event handler for VisibilityNotify * events, if a window receives the focus at a time when its toplevel * isn't mapped. The function is needed because X won't allow the focus * to be set to an unmapped window; we detect when the toplevel is mapped * and set the focus to it then. * * Results: * None. * * Side effects: * If this is a map event, the focus gets set to the toplevel given by * clientData. * *---------------------------------------------------------------------- */ func _FocusMapProc(tls *libc.TLS, clientData uintptr, eventPtr uintptr) { bp := tls.Alloc(32) defer tls.Free(32) /* Information about event. */ var displayFocusPtr, winPtr uintptr _, _ = displayFocusPtr, winPtr winPtr = clientData if (*TXEvent)(unsafe.Pointer(eventPtr)).Ftype1 == int32(VisibilityNotify) { displayFocusPtr = _FindDisplayFocusInfo(tls, (*TTkWindow)(unsafe.Pointer(winPtr)).FmainPtr, (*TTkWindow)(unsafe.Pointer(winPtr)).FdispPtr) if (*TTkDisplay)(unsafe.Pointer((*TTkWindow)(unsafe.Pointer(winPtr)).FdispPtr)).FfocusDebug != 0 { libc.Xprintf(tls, __ccgo_ts+9326, libc.VaList(bp+8, (*TTkWindow)(unsafe.Pointer(winPtr)).FpathName, (*TDisplayFocusInfo)(unsafe.Pointer(displayFocusPtr)).FforceFocus)) libc.Xfflush(tls, libc.Xstdout) } XTk_DeleteEventHandler(tls, winPtr, libc.Uint64FromInt64(libc.Int64FromInt64(1)< int32(4) { skip3 = int32(XTkGetDisplayOf(tls, interp, int64(objc-int32(3)), objv+uintptr(3)*8, bp+8)) if skip3 < 0 { return int32(TCL_ERROR) } } if objc != int32(4)+skip3 { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(2), objv, __ccgo_ts+10237) return int32(TCL_ERROR) } tkfont1 = XTk_AllocFontFromObj(tls, interp, *(*TTk_Window)(unsafe.Pointer(bp + 8)), *(*uintptr)(unsafe.Pointer(objv + 2*8))) if tkfont1 == libc.UintptrFromInt32(0) { return int32(TCL_ERROR) } string3 = libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(int32(3)+skip3)*8)), bp+128) libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewWideIntObj(tls, int64(XTk_TextWidth(tls, tkfont1, string3, *(*TTcl_Size)(unsafe.Pointer(bp + 128)))))) XTk_FreeFont(tls, tkfont1) case 6: skip4 = int32(XTkGetDisplayOf(tls, interp, int64(objc-int32(3)), objv+uintptr(3)*8, bp+8)) if skip4 < 0 { return int32(TCL_ERROR) } if objc < int32(3) || objc > int32(4)+skip4 { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(2), objv, __ccgo_ts+10302) return int32(TCL_ERROR) } tkfont2 = XTk_AllocFontFromObj(tls, interp, *(*TTk_Window)(unsafe.Pointer(bp + 8)), *(*uintptr)(unsafe.Pointer(objv + 2*8))) if tkfont2 == libc.UintptrFromInt32(0) { return int32(TCL_ERROR) } objc -= skip4 objv += uintptr(skip4) * 8 fmPtr = tkfont2 + 96 if objc == int32(3) { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+10337, libc.VaList(bp+168, (*TTkFontMetrics)(unsafe.Pointer(fmPtr)).Fascent, (*TTkFontMetrics)(unsafe.Pointer(fmPtr)).Fdescent, (*TTkFontMetrics)(unsafe.Pointer(fmPtr)).Fascent+(*TTkFontMetrics)(unsafe.Pointer(fmPtr)).Fdescent, (*TTkFontMetrics)(unsafe.Pointer(fmPtr)).Ffixed))) } else { if libtcl9_0.XTcl_GetIndexFromObjStruct(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 3*8)), uintptr(unsafe.Pointer(&_switches)), libc.Int64FromUint64(libc.Uint64FromInt64(8)), __ccgo_ts+10384, libc.Int32FromInt32(0)|libc.Int32FromUint64(libc.Uint64FromInt64(4)< descent { /* * If this set of values would cause the bottom of the underline bar * to stick below the descent of the font, jack the underline up a bit * higher. */ (*TTkFont)(unsafe.Pointer(fontPtr)).FunderlineHeight = descent - (*TTkFont)(unsafe.Pointer(fontPtr)).FunderlinePos if (*TTkFont)(unsafe.Pointer(fontPtr)).FunderlineHeight == 0 { (*TTkFont)(unsafe.Pointer(fontPtr)).FunderlinePos-- (*TTkFont)(unsafe.Pointer(fontPtr)).FunderlineHeight = int32(1) } } (*(*struct { Fptr1 uintptr Fptr2 uintptr })(unsafe.Pointer(objPtr + 32))).Fptr1 = fontPtr (*(*struct { Fptr1 uintptr Fptr2 uintptr })(unsafe.Pointer(objPtr + 32))).Fptr2 = fiPtr return fontPtr } /* *---------------------------------------------------------------------- * * Tk_GetFontFromObj -- * * Find the font that corresponds to a given object. The font must have * already been created by Tk_GetFont or Tk_AllocFontFromObj. * * Results: * The return value is a token for the font that matches objPtr and is * suitable for use in tkwin. * * Side effects: * If the object is not already a font ref, the conversion will free any * old internal representation. * *---------------------------------------------------------------------- */ func XTk_GetFontFromObj(tls *libc.TLS, tkwin TTk_Window, objPtr uintptr) (r TTk_Font) { /* The object from which to get the font. */ var fiPtr, fontPtr, hashPtr uintptr _, _, _ = fiPtr, fontPtr, hashPtr fiPtr = (*TTkMainInfo)(unsafe.Pointer((*TTkWindow)(unsafe.Pointer(tkwin)).FmainPtr)).FfontInfoPtr if (*TTcl_Obj)(unsafe.Pointer(objPtr)).FtypePtr != uintptr(unsafe.Pointer(&XtkFontObjType)) || (*(*struct { Fptr1 uintptr Fptr2 uintptr })(unsafe.Pointer(objPtr + 32))).Fptr2 != fiPtr { _SetFontFromAny(tls, libc.UintptrFromInt32(0), objPtr) } fontPtr = (*(*struct { Fptr1 uintptr Fptr2 uintptr })(unsafe.Pointer(objPtr + 32))).Fptr1 if fontPtr != libc.UintptrFromInt32(0) { if (*TTkFont)(unsafe.Pointer(fontPtr)).FresourceRefCount == 0 { /* * This is a stale reference: it refers to a TkFont that's no * longer in use. Clear the reference. */ _FreeFontObj(tls, objPtr) fontPtr = libc.UintptrFromInt32(0) } else { if (*struct { Fext_data uintptr Fprivate1 uintptr Ffd int32 Fprivate2 int32 Fproto_major_version int32 Fproto_minor_version int32 Fvendor uintptr Fprivate3 TXID Fprivate4 TXID Fprivate5 TXID Fprivate6 int32 Fresource_alloc uintptr Fbyte_order int32 Fbitmap_unit int32 Fbitmap_pad int32 Fbitmap_bit_order int32 Fnformats int32 Fpixmap_format uintptr Fprivate8 int32 Frelease int32 Fprivate9 uintptr Fprivate10 uintptr Fqlen int32 Flast_request_read uint64 Frequest uint64 Fprivate11 TXPointer Fprivate12 TXPointer Fprivate13 TXPointer Fprivate14 TXPointer Fmax_request_size uint32 Fdb uintptr Fprivate15 uintptr Fdisplay_name uintptr Fdefault_screen int32 Fnscreens int32 Fscreens uintptr Fmotion_buffer uint64 Fprivate16 uint64 Fmin_keycode int32 Fmax_keycode int32 Fprivate17 TXPointer Fprivate18 TXPointer Fprivate19 int32 Fxdefaults uintptr })(unsafe.Pointer((*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fdisplay)).Fscreens+uintptr((*TTk_FakeWin)(unsafe.Pointer(tkwin)).FscreenNum)*128 == (*TTkFont)(unsafe.Pointer(fontPtr)).Fscreen { return fontPtr } } } /* * Next, search the list of fonts that have the name we want, to see if * one of them is for the right screen. */ if fontPtr != libc.UintptrFromInt32(0) { hashPtr = (*TTkFont)(unsafe.Pointer(fontPtr)).FcacheHashPtr _FreeFontObj(tls, objPtr) } else { hashPtr = (*(*func(*libc.TLS, uintptr, uintptr) uintptr)(unsafe.Pointer(&struct{ uintptr }{(*TTcl_HashTable)(unsafe.Pointer(fiPtr)).FfindProc})))(tls, fiPtr, libtcl9_0.XTcl_GetStringFromObj(tls, objPtr, libc.UintptrFromInt32(0))) } if hashPtr != libc.UintptrFromInt32(0) { fontPtr = (*TTcl_HashEntry)(unsafe.Pointer(hashPtr)).FclientData for { if !(fontPtr != libc.UintptrFromInt32(0)) { break } if (*struct { Fext_data uintptr Fprivate1 uintptr Ffd int32 Fprivate2 int32 Fproto_major_version int32 Fproto_minor_version int32 Fvendor uintptr Fprivate3 TXID Fprivate4 TXID Fprivate5 TXID Fprivate6 int32 Fresource_alloc uintptr Fbyte_order int32 Fbitmap_unit int32 Fbitmap_pad int32 Fbitmap_bit_order int32 Fnformats int32 Fpixmap_format uintptr Fprivate8 int32 Frelease int32 Fprivate9 uintptr Fprivate10 uintptr Fqlen int32 Flast_request_read uint64 Frequest uint64 Fprivate11 TXPointer Fprivate12 TXPointer Fprivate13 TXPointer Fprivate14 TXPointer Fmax_request_size uint32 Fdb uintptr Fprivate15 uintptr Fdisplay_name uintptr Fdefault_screen int32 Fnscreens int32 Fscreens uintptr Fmotion_buffer uint64 Fprivate16 uint64 Fmin_keycode int32 Fmax_keycode int32 Fprivate17 TXPointer Fprivate18 TXPointer Fprivate19 int32 Fxdefaults uintptr })(unsafe.Pointer((*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fdisplay)).Fscreens+uintptr((*TTk_FakeWin)(unsafe.Pointer(tkwin)).FscreenNum)*128 == (*TTkFont)(unsafe.Pointer(fontPtr)).Fscreen { (*TTkFont)(unsafe.Pointer(fontPtr)).FobjRefCount++ (*(*struct { Fptr1 uintptr Fptr2 uintptr })(unsafe.Pointer(objPtr + 32))).Fptr1 = fontPtr (*(*struct { Fptr1 uintptr Fptr2 uintptr })(unsafe.Pointer(objPtr + 32))).Fptr2 = fiPtr return fontPtr } goto _1 _1: ; fontPtr = (*TTkFont)(unsafe.Pointer(fontPtr)).FnextPtr } } libtcl9_0.XTcl_Panic(tls, __ccgo_ts+10535, 0) return libc.UintptrFromInt32(0) } /* *---------------------------------------------------------------------- * * SetFontFromAny -- * * Convert the internal representation of a Tcl object to the font * internal form. * * Results: * Always returns TCL_OK. * * Side effects: * The object is left with its typePtr pointing to tkFontObjType. The * TkFont pointer is NULL. * *---------------------------------------------------------------------- */ func _SetFontFromAny(tls *libc.TLS, dummy1372 uintptr, objPtr uintptr) (r int32) { /* The object to convert. */ var typePtr uintptr _ = typePtr /* * Free the old internalRep before setting the new one. */ libtcl9_0.XTcl_GetStringFromObj(tls, objPtr, libc.UintptrFromInt32(0)) typePtr = (*TTcl_Obj)(unsafe.Pointer(objPtr)).FtypePtr if typePtr != libc.UintptrFromInt32(0) && (*TTcl_ObjType)(unsafe.Pointer(typePtr)).FfreeIntRepProc != libc.UintptrFromInt32(0) { (*(*func(*libc.TLS, uintptr))(unsafe.Pointer(&struct{ uintptr }{(*TTcl_ObjType)(unsafe.Pointer(typePtr)).FfreeIntRepProc})))(tls, objPtr) } (*TTcl_Obj)(unsafe.Pointer(objPtr)).FtypePtr = uintptr(unsafe.Pointer(&XtkFontObjType)) (*(*struct { Fptr1 uintptr Fptr2 uintptr })(unsafe.Pointer(objPtr + 32))).Fptr1 = libc.UintptrFromInt32(0) (*(*struct { Fptr1 uintptr Fptr2 uintptr })(unsafe.Pointer(objPtr + 32))).Fptr2 = libc.UintptrFromInt32(0) return TCL_OK } /* *--------------------------------------------------------------------------- * * Tk_NameOfFont -- * * Given a font, return a textual string identifying it. * * Results: * The return value is the description that was passed to Tk_GetFont() to * create the font. The storage for the returned string is only * guaranteed to persist until the font is deleted. The caller should not * modify this string. * * Side effects: * None. * *--------------------------------------------------------------------------- */ func XTk_NameOfFont(tls *libc.TLS, tkfont TTk_Font) (r uintptr) { /* Font whose name is desired. */ var fontPtr uintptr _ = fontPtr fontPtr = tkfont return (*TTkFont)(unsafe.Pointer(fontPtr)).FcacheHashPtr + 32 } /* *--------------------------------------------------------------------------- * * Tk_FreeFont -- * * Called to release a font allocated by Tk_GetFont(). * * Results: * None. * * Side effects: * The reference count associated with font is decremented, and only * deallocated when no one is using it. * *--------------------------------------------------------------------------- */ func XTk_FreeFont(tls *libc.TLS, tkfont TTk_Font) { /* Font to be released. */ var fontPtr, nfPtr, prevPtr, v2, v4 uintptr var v1 TTcl_Size var v3 Tsize_t _, _, _, _, _, _, _ = fontPtr, nfPtr, prevPtr, v1, v2, v3, v4 fontPtr = tkfont if fontPtr == libc.UintptrFromInt32(0) { return } v2 = fontPtr v1 = *(*TTcl_Size)(unsafe.Pointer(v2)) *(*TTcl_Size)(unsafe.Pointer(v2))-- if v1 > int64(1) { return } if (*TTkFont)(unsafe.Pointer(fontPtr)).FnamedHashPtr != libc.UintptrFromInt32(0) { /* * This font derived from a named font. Reduce the reference count on * the named font and free it if no-one else is using it. */ nfPtr = (*TTcl_HashEntry)(unsafe.Pointer((*TTkFont)(unsafe.Pointer(fontPtr)).FnamedHashPtr)).FclientData v4 = nfPtr v3 = *(*Tsize_t)(unsafe.Pointer(v4)) *(*Tsize_t)(unsafe.Pointer(v4))-- if v3 <= uint64(1) && (*TNamedFont)(unsafe.Pointer(nfPtr)).FdeletePending != 0 { libtcl9_0.XTcl_DeleteHashEntry(tls, (*TTkFont)(unsafe.Pointer(fontPtr)).FnamedHashPtr) libtcl9_0.XTcl_Free(tls, nfPtr) } } prevPtr = (*TTcl_HashEntry)(unsafe.Pointer((*TTkFont)(unsafe.Pointer(fontPtr)).FcacheHashPtr)).FclientData if prevPtr == fontPtr { if (*TTkFont)(unsafe.Pointer(fontPtr)).FnextPtr == libc.UintptrFromInt32(0) { libtcl9_0.XTcl_DeleteHashEntry(tls, (*TTkFont)(unsafe.Pointer(fontPtr)).FcacheHashPtr) } else { (*TTcl_HashEntry)(unsafe.Pointer((*TTkFont)(unsafe.Pointer(fontPtr)).FcacheHashPtr)).FclientData = (*TTkFont)(unsafe.Pointer(fontPtr)).FnextPtr } } else { for (*TTkFont)(unsafe.Pointer(prevPtr)).FnextPtr != fontPtr { prevPtr = (*TTkFont)(unsafe.Pointer(prevPtr)).FnextPtr } (*TTkFont)(unsafe.Pointer(prevPtr)).FnextPtr = (*TTkFont)(unsafe.Pointer(fontPtr)).FnextPtr } XTkpDeleteFont(tls, fontPtr) if (*TTkFont)(unsafe.Pointer(fontPtr)).FobjRefCount == 0 { libtcl9_0.XTcl_Free(tls, fontPtr) } } /* *--------------------------------------------------------------------------- * * Tk_FreeFontFromObj -- * * Called to release a font inside a Tcl_Obj *. Decrements the refCount * of the font and removes it from the hash tables if necessary. * * Results: * None. * * Side effects: * The reference count associated with font is decremented, and only * deallocated when no one is using it. * *--------------------------------------------------------------------------- */ func XTk_FreeFontFromObj(tls *libc.TLS, tkwin TTk_Window, objPtr uintptr) { /* The Tcl_Obj * to be freed. */ XTk_FreeFont(tls, XTk_GetFontFromObj(tls, tkwin, objPtr)) } /* *--------------------------------------------------------------------------- * * FreeFontObjProc, FreeFontObj -- * * This proc is called to release an object reference to a font. Called * when the object's internal rep is released or when the cached fontPtr * needs to be changed. * * Results: * None. * * Side effects: * The object reference count is decremented. When both it and the hash * ref count go to zero, the font's resources are released. * *--------------------------------------------------------------------------- */ func _FreeFontObjProc(tls *libc.TLS, objPtr uintptr) { /* The object we are releasing. */ _FreeFontObj(tls, objPtr) (*TTcl_Obj)(unsafe.Pointer(objPtr)).FtypePtr = libc.UintptrFromInt32(0) } func _FreeFontObj(tls *libc.TLS, objPtr uintptr) { /* The object we are releasing. */ var fontPtr, v2 uintptr var v1 TTcl_Size _, _, _ = fontPtr, v1, v2 fontPtr = (*(*struct { Fptr1 uintptr Fptr2 uintptr })(unsafe.Pointer(objPtr + 32))).Fptr1 if fontPtr != libc.UintptrFromInt32(0) { v2 = fontPtr + 8 v1 = *(*TTcl_Size)(unsafe.Pointer(v2)) *(*TTcl_Size)(unsafe.Pointer(v2))-- if v1 <= int64(1) && (*TTkFont)(unsafe.Pointer(fontPtr)).FresourceRefCount == 0 { libtcl9_0.XTcl_Free(tls, fontPtr) } (*(*struct { Fptr1 uintptr Fptr2 uintptr })(unsafe.Pointer(objPtr + 32))).Fptr1 = libc.UintptrFromInt32(0) (*(*struct { Fptr1 uintptr Fptr2 uintptr })(unsafe.Pointer(objPtr + 32))).Fptr2 = libc.UintptrFromInt32(0) } } /* *--------------------------------------------------------------------------- * * DupFontObjProc -- * * When a cached font object is duplicated, this is called to update the * internal reps. * * Results: * None. * * Side effects: * The font's objRefCount is incremented and the internal rep of the copy * is set to point to it. * *--------------------------------------------------------------------------- */ func _DupFontObjProc(tls *libc.TLS, srcObjPtr uintptr, dupObjPtr uintptr) { /* The object we are copying to. */ var fontPtr uintptr _ = fontPtr fontPtr = (*(*struct { Fptr1 uintptr Fptr2 uintptr })(unsafe.Pointer(srcObjPtr + 32))).Fptr1 (*TTcl_Obj)(unsafe.Pointer(dupObjPtr)).FtypePtr = (*TTcl_Obj)(unsafe.Pointer(srcObjPtr)).FtypePtr (*(*struct { Fptr1 uintptr Fptr2 uintptr })(unsafe.Pointer(dupObjPtr + 32))).Fptr1 = fontPtr (*(*struct { Fptr1 uintptr Fptr2 uintptr })(unsafe.Pointer(dupObjPtr + 32))).Fptr2 = (*(*struct { Fptr1 uintptr Fptr2 uintptr })(unsafe.Pointer(srcObjPtr + 32))).Fptr2 if fontPtr != libc.UintptrFromInt32(0) { (*TTkFont)(unsafe.Pointer(fontPtr)).FobjRefCount++ } } /* *--------------------------------------------------------------------------- * * Tk_FontId -- * * Given a font, return an opaque handle that should be selected into the * XGCValues structure in order to get the constructed gc to use this * font. This function would go away if the XGCValues structure were * replaced with a TkGCValues structure. * * Results: * As above. * * Side effects: * None. * *--------------------------------------------------------------------------- */ func XTk_FontId(tls *libc.TLS, tkfont TTk_Font) (r TFont) { /* Font that is going to be selected into * GC. */ var fontPtr uintptr _ = fontPtr fontPtr = tkfont return (*TTkFont)(unsafe.Pointer(fontPtr)).Ffid } /* *--------------------------------------------------------------------------- * * Tk_GetFontMetrics -- * * Returns overall ascent and descent metrics for the given font. These * values can be used to space multiple lines of text and to align the * baselines of text in different fonts. * * Results: * If *heightPtr is non-NULL, it is filled with the overall height of the * font, which is the sum of the ascent and descent. If *ascentPtr or * *descentPtr is non-NULL, they are filled with the ascent and/or * descent information for the font. * * Side effects: * None. * *--------------------------------------------------------------------------- */ func XTk_GetFontMetrics(tls *libc.TLS, tkfont TTk_Font, fmPtr uintptr) { /* Pointer to structure in which font metrics * for tkfont will be stored. */ var fontPtr uintptr _ = fontPtr fontPtr = tkfont (*TTk_FontMetrics)(unsafe.Pointer(fmPtr)).Fascent = (*TTkFont)(unsafe.Pointer(fontPtr)).Ffm.Fascent (*TTk_FontMetrics)(unsafe.Pointer(fmPtr)).Fdescent = (*TTkFont)(unsafe.Pointer(fontPtr)).Ffm.Fdescent (*TTk_FontMetrics)(unsafe.Pointer(fmPtr)).Flinespace = (*TTkFont)(unsafe.Pointer(fontPtr)).Ffm.Fascent + (*TTkFont)(unsafe.Pointer(fontPtr)).Ffm.Fdescent } /* *--------------------------------------------------------------------------- * * Tk_PostscriptFontName -- * * Given a Tk_Font, return the name of the corresponding Postscript font. * * Results: * The return value is the pointsize of the given Tk_Font. The name of * the Postscript font is appended to dsPtr. * * Side effects: * If the font does not exist on the printer, the print job will fail at * print time. Given a "reasonable" Postscript printer, the following * Tk_Font font families should print correctly: * * Avant Garde, Arial, Bookman, Courier, Courier New, Geneva, * Helvetica, Monaco, New Century Schoolbook, New York, * Palatino, Symbol, Times, Times New Roman, Zapf Chancery, * and Zapf Dingbats. * * Any other Tk_Font font families may not print correctly because the * computed Postscript font name may be incorrect. * *--------------------------------------------------------------------------- */ func XTk_PostscriptFontName(tls *libc.TLS, tkfont TTk_Font, dsPtr uintptr) (r int32) { bp := tls.Alloc(16) defer tls.Free(16) /* Pointer to an initialized Tcl_DString to * which the name of the Postscript font that * corresponds to tkfont will be appended. */ var dest, fontPtr, src, v1 uintptr var family, slantString, weightString TTk_Uid var len1, upper, v3, v4 int32 var _ /* ch at bp+0 */ int32 _, _, _, _, _, _, _, _, _, _, _ = dest, family, fontPtr, len1, slantString, src, upper, weightString, v1, v3, v4 fontPtr = tkfont len1 = int32((*TTcl_DString)(unsafe.Pointer(dsPtr)).Flength) /* * Convert the case-insensitive Tk_Font family name to the case-sensitive * Postscript family name. Take out any spaces and capitalize the first * letter of each word. */ family = (*TTkFont)(unsafe.Pointer(fontPtr)).Ffa.Ffamily if libc.Xstrncasecmp(tls, family, __ccgo_ts+10584, uint64(4)) == 0 { family = family + uintptr(4) } if libc.Xstrcasecmp(tls, family, __ccgo_ts+9571) == 0 || libc.Xstrcasecmp(tls, family, __ccgo_ts+9577) == 0 { family = __ccgo_ts + 9561 } else { if libc.Xstrcasecmp(tls, family, __ccgo_ts+9536) == 0 || libc.Xstrcasecmp(tls, family, __ccgo_ts+9552) == 0 { family = __ccgo_ts + 9530 } else { if libc.Xstrcasecmp(tls, family, __ccgo_ts+9592) == 0 || libc.Xstrcasecmp(tls, family, __ccgo_ts+10589) == 0 { family = __ccgo_ts + 9584 } else { if libc.Xstrcasecmp(tls, family, __ccgo_ts+10596) == 0 { family = __ccgo_ts + 10596 } else { if libc.Xstrcasecmp(tls, family, __ccgo_ts+10607) == 0 { family = __ccgo_ts + 10607 } else { if libc.Xstrcasecmp(tls, family, __ccgo_ts+10620) == 0 { family = __ccgo_ts + 10620 } else { /* * Inline, capitalize the first letter of each word, lowercase the * rest of the letters in each word, and then take out the spaces * between the words. This may make the DString shorter, which is safe * to do. */ libtcl9_0.XTcl_DStringAppend(tls, dsPtr, family, int64(-libc.Int32FromInt32(1))) v1 = (*TTcl_DString)(unsafe.Pointer(dsPtr)).Fstring1 + uintptr(len1) dest = v1 src = v1 upper = int32(1) for { if !(libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(src))) != int32('\000')) { break } for { v3 = libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(src))) v4 = libc.BoolInt32(v3 == int32(' ') || libc.Uint32FromInt32(v3)-uint32('\t') < uint32(5)) goto _5 _5: if !(v4 != 0) { break } /* INTL: ISO space */ src++ upper = int32(1) } src += uintptr(libtcl9_0.XTcl_UtfToUniChar(tls, src, bp)) if upper != 0 { *(*int32)(unsafe.Pointer(bp)) = libtcl9_0.XTcl_UniCharToUpper(tls, *(*int32)(unsafe.Pointer(bp))) upper = 0 } else { *(*int32)(unsafe.Pointer(bp)) = libtcl9_0.XTcl_UniCharToLower(tls, *(*int32)(unsafe.Pointer(bp))) } dest += uintptr(libtcl9_0.XTcl_UniCharToUtf(tls, *(*int32)(unsafe.Pointer(bp)), dest)) goto _2 _2: } *(*uint8)(unsafe.Pointer(dest)) = uint8('\000') libtcl9_0.XTcl_DStringSetLength(tls, dsPtr, int64(dest)-int64((*TTcl_DString)(unsafe.Pointer(dsPtr)).Fstring1)) family = (*TTcl_DString)(unsafe.Pointer(dsPtr)).Fstring1 + uintptr(len1) } } } } } } if family != (*TTcl_DString)(unsafe.Pointer(dsPtr)).Fstring1+uintptr(len1) { libtcl9_0.XTcl_DStringAppend(tls, dsPtr, family, int64(-libc.Int32FromInt32(1))) family = (*TTcl_DString)(unsafe.Pointer(dsPtr)).Fstring1 + uintptr(len1) } if libc.Xstrcasecmp(tls, family, __ccgo_ts+10633) == 0 { libtcl9_0.XTcl_DStringSetLength(tls, dsPtr, int64(len1)) libtcl9_0.XTcl_DStringAppend(tls, dsPtr, __ccgo_ts+10654, int64(-libc.Int32FromInt32(1))) family = (*TTcl_DString)(unsafe.Pointer(dsPtr)).Fstring1 + uintptr(len1) } /* * Get the string to use for the weight. */ weightString = libc.UintptrFromInt32(0) if (*TTkFont)(unsafe.Pointer(fontPtr)).Ffa.Fweight == TK_FW_NORMAL { if libc.Xstrcmp(tls, family, __ccgo_ts+10671) == 0 { weightString = __ccgo_ts + 10679 } else { if libc.Xstrcmp(tls, family, __ccgo_ts+10596) == 0 { weightString = __ccgo_ts + 10685 } else { if libc.Xstrcmp(tls, family, __ccgo_ts+10607) == 0 { weightString = __ccgo_ts + 10690 } } } } else { if libc.Xstrcmp(tls, family, __ccgo_ts+10671) == 0 || libc.Xstrcmp(tls, family, __ccgo_ts+10596) == 0 { weightString = __ccgo_ts + 10697 } else { weightString = __ccgo_ts + 10702 } } /* * Get the string to use for the slant. */ slantString = libc.UintptrFromInt32(0) if (*TTkFont)(unsafe.Pointer(fontPtr)).Ffa.Fslant == TK_FS_ROMAN { /* Do nothing */ } else { if libc.Xstrcmp(tls, family, __ccgo_ts+9561) == 0 || libc.Xstrcmp(tls, family, __ccgo_ts+9584) == 0 || libc.Xstrcmp(tls, family, __ccgo_ts+10596) == 0 { slantString = __ccgo_ts + 10707 } else { slantString = __ccgo_ts + 10715 } } /* * The string "Roman" needs to be added to some fonts that are not bold * and not italic. */ if slantString == libc.UintptrFromInt32(0) && weightString == libc.UintptrFromInt32(0) { if libc.Xstrcmp(tls, family, __ccgo_ts+9530) == 0 || libc.Xstrcmp(tls, family, __ccgo_ts+10654) == 0 || libc.Xstrcmp(tls, family, __ccgo_ts+10722) == 0 { libtcl9_0.XTcl_DStringAppend(tls, dsPtr, __ccgo_ts+10731, int64(-libc.Int32FromInt32(1))) } } else { libtcl9_0.XTcl_DStringAppend(tls, dsPtr, __ccgo_ts+4010, int64(-libc.Int32FromInt32(1))) if weightString != libc.UintptrFromInt32(0) { libtcl9_0.XTcl_DStringAppend(tls, dsPtr, weightString, int64(-libc.Int32FromInt32(1))) } if slantString != libc.UintptrFromInt32(0) { libtcl9_0.XTcl_DStringAppend(tls, dsPtr, slantString, int64(-libc.Int32FromInt32(1))) } } return int32((*TTkFont)(unsafe.Pointer(fontPtr)).Ffa.Fsize + libc.Float64FromFloat64(0.5)) } /* *--------------------------------------------------------------------------- * * Tk_TextWidth -- * * A wrapper function for the more complicated interface of * Tk_MeasureChars. Computes how much space the given simple string * needs. * * Results: * The return value is the width (in pixels) of the given string. * * Side effects: * None. * *--------------------------------------------------------------------------- */ func XTk_TextWidth(tls *libc.TLS, tkfont TTk_Font, string1 uintptr, numBytes TTcl_Size) (r int32) { bp := tls.Alloc(16) defer tls.Free(16) /* Number of bytes to consider from string, or * TCL_INDEX_NONE for strlen(). */ var _ /* width at bp+0 */ int32 if numBytes < 0 { numBytes = libc.Int64FromUint64(libc.Xstrlen(tls, string1)) } XTk_MeasureChars(tls, tkfont, string1, numBytes, -int32(1), 0, bp) return *(*int32)(unsafe.Pointer(bp)) } /* *--------------------------------------------------------------------------- * * Tk_UnderlineChars, Tk_UnderlineCharsInContext -- * * These procedures draw an underline for a given range of characters in * a given string. They don't draw the characters (which are assumed to * have been displayed previously); they just draw the underline. These * procedures would mainly be used to quickly underline a few characters * without having to construct an underlined font. To produce properly * underlined text, the appropriate underlined font should be constructed * and used. * * Results: * None. * * Side effects: * Information gets displayed in "drawable". * *---------------------------------------------------------------------- */ func XTk_UnderlineChars(tls *libc.TLS, display uintptr, drawable TDrawable, gc TGC, tkfont TTk_Font, string1 uintptr, x int32, y int32, firstByte TTcl_Size, lastByte TTcl_Size) { /* Index of first byte after the last * character. */ XTk_UnderlineCharsInContext(tls, display, drawable, gc, tkfont, string1, lastByte, x, y, firstByte, lastByte) } func XTk_UnderlineCharsInContext(tls *libc.TLS, display uintptr, drawable TDrawable, gc TGC, tkfont TTk_Font, string1 uintptr, numBytes TTcl_Size, x int32, y int32, firstByte TTcl_Size, lastByte TTcl_Size) { bp := tls.Alloc(16) defer tls.Free(16) /* Index of first byte after the last * character. */ var fontPtr uintptr var _ /* endX at bp+4 */ int32 var _ /* startX at bp+0 */ int32 _ = fontPtr fontPtr = tkfont XTk_MeasureCharsInContext(tls, tkfont, string1, numBytes, 0, firstByte, -int32(1), 0, bp) XTk_MeasureCharsInContext(tls, tkfont, string1, numBytes, 0, lastByte, -int32(1), 0, bp+4) libx11.XXFillRectangle(tls, display, drawable, gc, x+*(*int32)(unsafe.Pointer(bp)), y+(*TTkFont)(unsafe.Pointer(fontPtr)).FunderlinePos, libc.Uint32FromInt32(*(*int32)(unsafe.Pointer(bp + 4))-*(*int32)(unsafe.Pointer(bp))), libc.Uint32FromInt32((*TTkFont)(unsafe.Pointer(fontPtr)).FunderlineHeight)) } /* *--------------------------------------------------------------------------- * * Tk_ComputeTextLayout -- * * Computes the amount of screen space needed to display a multi-line, * justified string of text. Records all the measurements that were done * to determine to size and positioning of the individual lines of text; * this information can be used by the Tk_DrawTextLayout() function to * display the text quickly (without remeasuring it). * * This function is useful for simple widgets that want to display * single-font, multi-line text and want Tk to handle the details. * * Results: * The return value is a Tk_TextLayout token that holds the measurement * information for the given string. The token is only valid for the * given string. If the string is freed, the token is no longer valid and * must also be freed. To free the token, call Tk_FreeTextLayout(). * * The dimensions of the screen area needed to display the text are * stored in *widthPtr and *heightPtr. * * Side effects: * Memory is allocated to hold the measurement information. * *--------------------------------------------------------------------------- */ func XTk_ComputeTextLayout(tls *libc.TLS, tkfont TTk_Font, string1 uintptr, numChars TTcl_Size, wrapLength int32, justify TTk_Justify, flags int32, widthPtr uintptr, heightPtr uintptr) (r TTk_TextLayout) { bp := tls.Alloc(256) defer tls.Free(256) /* Filled with height of string. */ var baseline, bytesThisChunk, curLine, extra, height, layoutHeight, maxWidth, y, v3, v4 int32 var chunkPtr, end, endp, fmPtr, fontPtr, lineLengths, special, start uintptr var n TTcl_Size var v6 bool var _ /* curX at bp+4 */ int32 var _ /* layoutPtr at bp+16 */ uintptr var _ /* lineBuffer at bp+24 */ TTcl_DString var _ /* maxChunks at bp+0 */ int32 var _ /* newX at bp+8 */ int32 _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = baseline, bytesThisChunk, chunkPtr, curLine, end, endp, extra, fmPtr, fontPtr, height, layoutHeight, lineLengths, maxWidth, n, special, start, y, v3, v4, v6 fontPtr = tkfont libtcl9_0.XTcl_DStringInit(tls, bp+24) if fontPtr == libc.UintptrFromInt32(0) || string1 == libc.UintptrFromInt32(0) { if widthPtr != libc.UintptrFromInt32(0) { *(*int32)(unsafe.Pointer(widthPtr)) = 0 } if heightPtr != libc.UintptrFromInt32(0) { *(*int32)(unsafe.Pointer(heightPtr)) = 0 } return libc.UintptrFromInt32(0) } fmPtr = fontPtr + 96 height = (*TTkFontMetrics)(unsafe.Pointer(fmPtr)).Fascent + (*TTkFontMetrics)(unsafe.Pointer(fmPtr)).Fdescent if numChars < 0 { numChars = libtcl9_0.XTcl_NumUtfChars(tls, string1, int64(-libc.Int32FromInt32(1))) } if wrapLength == 0 { wrapLength = -int32(1) } *(*int32)(unsafe.Pointer(bp)) = int32(1) *(*uintptr)(unsafe.Pointer(bp + 16)) = libtcl9_0.XTcl_Alloc(tls, uint64(libc.UintptrFromInt32(0)+32)+libc.Uint64FromInt32(*(*int32)(unsafe.Pointer(bp)))*uint64(48)) (*TTextLayout)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 16)))).Ftkfont = tkfont (*TTextLayout)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 16)))).Fstring1 = string1 (*TTextLayout)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 16)))).FnumChunks = 0 baseline = (*TTkFontMetrics)(unsafe.Pointer(fmPtr)).Fascent maxWidth = 0 /* * Divide the string up into simple strings and measure each string. */ *(*int32)(unsafe.Pointer(bp + 4)) = 0 endp = libtcl9_0.XTcl_UtfAtIndex(tls, string1, numChars) special = string1 flags &= libc.Int32FromInt32(TK_IGNORE_TABS) | libc.Int32FromInt32(TK_IGNORE_NEWLINES) flags |= libc.Int32FromInt32(TK_WHOLE_WORDS) | libc.Int32FromInt32(TK_AT_LEAST_ONE) start = string1 for { if !(start < endp) { break } if start >= special { /* * Find the next special character in the string. * * INTL: Note that it is safe to increment by byte, because we are * looking for 7-bit characters that will appear unchanged in * UTF-8. At some point we may need to support the full Unicode * whitespace set. */ special = start for { if !(special < endp) { break } if !(flags&libc.Int32FromInt32(TK_IGNORE_NEWLINES) != 0) { if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(special))) == int32('\n') || libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(special))) == int32('\r') { break } } if !(flags&libc.Int32FromInt32(TK_IGNORE_TABS) != 0) { if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(special))) == int32('\t') { break } } goto _2 _2: ; special++ } } /* * Special points at the next special character (or the end of the * string). Process characters between start and special. */ chunkPtr = libc.UintptrFromInt32(0) if start < special { bytesThisChunk = XTk_MeasureChars(tls, tkfont, start, int64(special)-int64(start), wrapLength-*(*int32)(unsafe.Pointer(bp + 4)), flags, bp+8) *(*int32)(unsafe.Pointer(bp + 8)) += *(*int32)(unsafe.Pointer(bp + 4)) flags &= ^libc.Int32FromInt32(TK_AT_LEAST_ONE) if bytesThisChunk > 0 { chunkPtr = _NewChunk(tls, bp+16, bp, start, int64(bytesThisChunk), *(*int32)(unsafe.Pointer(bp + 4)), *(*int32)(unsafe.Pointer(bp + 8)), baseline) start += uintptr(bytesThisChunk) *(*int32)(unsafe.Pointer(bp + 4)) = *(*int32)(unsafe.Pointer(bp + 8)) } } if start == special && special < endp { /* * Handle the special character. * * INTL: Special will be pointing at a 7-bit character so we can * safely treat it as a single byte. */ chunkPtr = libc.UintptrFromInt32(0) if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(special))) == int32('\t') { *(*int32)(unsafe.Pointer(bp + 8)) = *(*int32)(unsafe.Pointer(bp + 4)) + (*TTkFont)(unsafe.Pointer(fontPtr)).FtabWidth *(*int32)(unsafe.Pointer(bp + 8)) -= *(*int32)(unsafe.Pointer(bp + 8)) % (*TTkFont)(unsafe.Pointer(fontPtr)).FtabWidth (*TLayoutChunk)(unsafe.Pointer(_NewChunk(tls, bp+16, bp, start, int64(1), *(*int32)(unsafe.Pointer(bp + 4)), *(*int32)(unsafe.Pointer(bp + 8)), baseline))).FnumDisplayChars = int64(-int32(1)) start++ *(*int32)(unsafe.Pointer(bp + 4)) = *(*int32)(unsafe.Pointer(bp + 8)) flags &= ^libc.Int32FromInt32(TK_AT_LEAST_ONE) if start < endp && (wrapLength <= 0 || *(*int32)(unsafe.Pointer(bp + 8)) <= wrapLength) { /* * More chars can still fit on this line. */ goto _1 } } else { (*TLayoutChunk)(unsafe.Pointer(_NewChunk(tls, bp+16, bp, start, int64(1), *(*int32)(unsafe.Pointer(bp + 4)), *(*int32)(unsafe.Pointer(bp + 4)), baseline))).FnumDisplayChars = int64(-int32(1)) start++ goto wrapLine } } /* * No more characters are going to go on this line, either because no * more characters can fit or there are no more characters left. * Consume all extra spaces at end of line. */ for { if v6 = start < endp; v6 { v3 = libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(start))) v4 = libc.BoolInt32(v3 == int32(' ') || libc.Uint32FromInt32(v3)-uint32('\t') < uint32(5)) goto _5 _5: } if !(v6 && v4 != 0) { break } /* INTL: ISO space */ if !(flags&libc.Int32FromInt32(TK_IGNORE_NEWLINES) != 0) { if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(start))) == int32('\n') || libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(start))) == int32('\r') { break } } if !(flags&libc.Int32FromInt32(TK_IGNORE_TABS) != 0) { if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(start))) == int32('\t') { break } } start++ } if chunkPtr != libc.UintptrFromInt32(0) { /* * Append all the extra spaces on this line to the end of the last * text chunk. This is a little tricky because we are switching * back and forth between characters and bytes. */ end = (*TLayoutChunk)(unsafe.Pointer(chunkPtr)).Fstart + uintptr((*TLayoutChunk)(unsafe.Pointer(chunkPtr)).FnumBytes) bytesThisChunk = int32(int64(start) - int64(end)) if bytesThisChunk > 0 { bytesThisChunk = XTk_MeasureChars(tls, tkfont, end, int64(bytesThisChunk), -int32(1), 0, chunkPtr+40) *(*TTcl_Size)(unsafe.Pointer(chunkPtr + 8)) += int64(bytesThisChunk) *(*TTcl_Size)(unsafe.Pointer(chunkPtr + 16)) += libtcl9_0.XTcl_NumUtfChars(tls, end, int64(bytesThisChunk)) *(*int32)(unsafe.Pointer(chunkPtr + 40)) += *(*int32)(unsafe.Pointer(bp + 4)) } } goto wrapLine wrapLine: ; flags |= int32(TK_AT_LEAST_ONE) /* * Save current line length, then move current position to start of * next line. */ if *(*int32)(unsafe.Pointer(bp + 4)) > maxWidth { maxWidth = *(*int32)(unsafe.Pointer(bp + 4)) } /* * Remember width of this line, so that all chunks on this line can be * centered or right justified, if necessary. */ libtcl9_0.XTcl_DStringAppend(tls, bp+24, bp+4, int64(4)) *(*int32)(unsafe.Pointer(bp + 4)) = 0 baseline += height goto _1 _1: } /* * If last line ends with a newline, then we need to make a 0 width chunk * on the next line. Otherwise "Hello" and "Hello\n" are the same height. */ if (*TTextLayout)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 16)))).FnumChunks > 0 && !(flags&libc.Int32FromInt32(TK_IGNORE_NEWLINES) != 0) { if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer((*(*TLayoutChunk)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 16)) + 32 + uintptr((*TTextLayout)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 16)))).FnumChunks-int64(1))*48))).Fstart))) == int32('\n') { chunkPtr = _NewChunk(tls, bp+16, bp, start, 0, *(*int32)(unsafe.Pointer(bp + 4)), *(*int32)(unsafe.Pointer(bp + 4)), baseline) (*TLayoutChunk)(unsafe.Pointer(chunkPtr)).FnumDisplayChars = int64(-int32(1)) libtcl9_0.XTcl_DStringAppend(tls, bp+24, bp+4, int64(4)) baseline += height } } (*TTextLayout)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 16)))).Fwidth = maxWidth layoutHeight = baseline - (*TTkFontMetrics)(unsafe.Pointer(fmPtr)).Fascent if (*TTextLayout)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 16)))).FnumChunks == 0 { layoutHeight = height /* * This fake chunk is used by the other functions so that they can * pretend that there is a chunk with no chars in it, which makes the * coding simpler. */ (*TTextLayout)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 16)))).FnumChunks = int64(1) (*(*TLayoutChunk)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 16)) + 32))).Fstart = string1 (*(*TLayoutChunk)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 16)) + 32))).FnumBytes = 0 (*(*TLayoutChunk)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 16)) + 32))).FnumChars = 0 (*(*TLayoutChunk)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 16)) + 32))).FnumDisplayChars = int64(-int32(1)) (*(*TLayoutChunk)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 16)) + 32))).Fx = 0 (*(*TLayoutChunk)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 16)) + 32))).Fy = (*TTkFontMetrics)(unsafe.Pointer(fmPtr)).Fascent (*(*TLayoutChunk)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 16)) + 32))).FtotalWidth = 0 (*(*TLayoutChunk)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 16)) + 32))).FdisplayWidth = 0 } else { /* * Using maximum line length, shift all the chunks so that the lines * are all justified correctly. */ curLine = 0 chunkPtr = *(*uintptr)(unsafe.Pointer(bp + 16)) + 32 y = (*TLayoutChunk)(unsafe.Pointer(chunkPtr)).Fy lineLengths = (*TTcl_DString)(unsafe.Pointer(bp + 24)).Fstring1 n = 0 for { if !(n < (*TTextLayout)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 16)))).FnumChunks) { break } if (*TLayoutChunk)(unsafe.Pointer(chunkPtr)).Fy != y { curLine++ y = (*TLayoutChunk)(unsafe.Pointer(chunkPtr)).Fy } extra = maxWidth - *(*int32)(unsafe.Pointer(lineLengths + uintptr(curLine)*4)) if justify == int32(TK_JUSTIFY_CENTER) { *(*int32)(unsafe.Pointer(chunkPtr + 32)) += extra / int32(2) } else { if justify == int32(TK_JUSTIFY_RIGHT) { *(*int32)(unsafe.Pointer(chunkPtr + 32)) += extra } } chunkPtr += 48 goto _7 _7: ; n++ } } if widthPtr != libc.UintptrFromInt32(0) { *(*int32)(unsafe.Pointer(widthPtr)) = (*TTextLayout)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 16)))).Fwidth } if heightPtr != libc.UintptrFromInt32(0) { *(*int32)(unsafe.Pointer(heightPtr)) = layoutHeight } libtcl9_0.XTcl_DStringFree(tls, bp+24) return *(*uintptr)(unsafe.Pointer(bp + 16)) } /* *--------------------------------------------------------------------------- * * Tk_FreeTextLayout -- * * This function is called to release the storage associated with a * Tk_TextLayout when it is no longer needed. * * Results: * None. * * Side effects: * Memory is freed. * *--------------------------------------------------------------------------- */ func XTk_FreeTextLayout(tls *libc.TLS, textLayout TTk_TextLayout) { /* The text layout to be released. */ var layoutPtr uintptr _ = layoutPtr layoutPtr = textLayout if layoutPtr != libc.UintptrFromInt32(0) { libtcl9_0.XTcl_Free(tls, layoutPtr) } } /* *--------------------------------------------------------------------------- * * Tk_DrawTextLayout -- * * Use the information in the Tk_TextLayout token to display a * multi-line, justified string of text. * * This function is useful for simple widgets that need to display * single-font, multi-line text and want Tk to handle the details. * * Results: * None. * * Side effects: * Text drawn on the screen. * *--------------------------------------------------------------------------- */ func XTk_DrawTextLayout(tls *libc.TLS, display uintptr, drawable TDrawable, gc TGC, layout TTk_TextLayout, x int32, y int32, firstChar TTcl_Size, lastChar TTcl_Size) { bp := tls.Alloc(16) defer tls.Free(16) /* The index just after the last character to * draw from the given text item. A number < 0 * means to draw all characters. */ var chunkPtr, firstByte, lastByte, layoutPtr uintptr var i int32 var numDisplayChars TTcl_Size var _ /* drawX at bp+0 */ int32 _, _, _, _, _, _ = chunkPtr, firstByte, i, lastByte, layoutPtr, numDisplayChars layoutPtr = layout if layoutPtr == libc.UintptrFromInt32(0) { return } if lastChar < 0 { lastChar = int64(100000000) } chunkPtr = layoutPtr + 32 i = 0 for { if !(int64(i) < (*TTextLayout)(unsafe.Pointer(layoutPtr)).FnumChunks) { break } numDisplayChars = (*TLayoutChunk)(unsafe.Pointer(chunkPtr)).FnumDisplayChars if numDisplayChars > 0 && firstChar < numDisplayChars { if firstChar <= 0 { *(*int32)(unsafe.Pointer(bp)) = 0 firstChar = 0 firstByte = (*TLayoutChunk)(unsafe.Pointer(chunkPtr)).Fstart } else { firstByte = libtcl9_0.XTcl_UtfAtIndex(tls, (*TLayoutChunk)(unsafe.Pointer(chunkPtr)).Fstart, firstChar) XTk_MeasureChars(tls, (*TTextLayout)(unsafe.Pointer(layoutPtr)).Ftkfont, (*TLayoutChunk)(unsafe.Pointer(chunkPtr)).Fstart, int64(firstByte)-int64((*TLayoutChunk)(unsafe.Pointer(chunkPtr)).Fstart), -int32(1), 0, bp) } if lastChar < numDisplayChars { numDisplayChars = lastChar } lastByte = libtcl9_0.XTcl_UtfAtIndex(tls, (*TLayoutChunk)(unsafe.Pointer(chunkPtr)).Fstart, numDisplayChars) XTk_DrawChars(tls, display, drawable, gc, (*TTextLayout)(unsafe.Pointer(layoutPtr)).Ftkfont, firstByte, int64(lastByte)-int64(firstByte), x+(*TLayoutChunk)(unsafe.Pointer(chunkPtr)).Fx+*(*int32)(unsafe.Pointer(bp)), y+(*TLayoutChunk)(unsafe.Pointer(chunkPtr)).Fy) } firstChar -= (*TLayoutChunk)(unsafe.Pointer(chunkPtr)).FnumChars lastChar -= (*TLayoutChunk)(unsafe.Pointer(chunkPtr)).FnumChars if lastChar <= 0 { break } chunkPtr += 48 goto _1 _1: ; i++ } } func XTkDrawAngledTextLayout(tls *libc.TLS, display uintptr, drawable TDrawable, gc TGC, layout TTk_TextLayout, x int32, y int32, angle float64, firstChar TTcl_Size, lastChar TTcl_Size) { bp := tls.Alloc(16) defer tls.Free(16) /* The index just after the last character to * draw from the given text item. A number < 0 * means to draw all characters. */ var chunkPtr, firstByte, lastByte, layoutPtr uintptr var cosA, dx, dy, sinA float64 var i, numDisplayChars int32 var _ /* drawX at bp+0 */ int32 _, _, _, _, _, _, _, _, _, _ = chunkPtr, cosA, dx, dy, firstByte, i, lastByte, layoutPtr, numDisplayChars, sinA layoutPtr = layout sinA = libc.Xsin(tls, float64(angle*float64(3.141592653589793))/float64(180)) cosA = libc.Xcos(tls, float64(angle*float64(3.141592653589793))/float64(180)) if layoutPtr == libc.UintptrFromInt32(0) { return } if lastChar < 0 { lastChar = int64(100000000) } chunkPtr = layoutPtr + 32 i = 0 for { if !(int64(i) < (*TTextLayout)(unsafe.Pointer(layoutPtr)).FnumChunks) { break } numDisplayChars = int32((*TLayoutChunk)(unsafe.Pointer(chunkPtr)).FnumDisplayChars) if numDisplayChars > 0 && firstChar < int64(numDisplayChars) { if firstChar <= 0 { *(*int32)(unsafe.Pointer(bp)) = 0 firstChar = 0 firstByte = (*TLayoutChunk)(unsafe.Pointer(chunkPtr)).Fstart } else { firstByte = libtcl9_0.XTcl_UtfAtIndex(tls, (*TLayoutChunk)(unsafe.Pointer(chunkPtr)).Fstart, firstChar) XTk_MeasureChars(tls, (*TTextLayout)(unsafe.Pointer(layoutPtr)).Ftkfont, (*TLayoutChunk)(unsafe.Pointer(chunkPtr)).Fstart, int64(firstByte)-int64((*TLayoutChunk)(unsafe.Pointer(chunkPtr)).Fstart), -int32(1), 0, bp) } if lastChar < int64(numDisplayChars) { numDisplayChars = int32(lastChar) } lastByte = libtcl9_0.XTcl_UtfAtIndex(tls, (*TLayoutChunk)(unsafe.Pointer(chunkPtr)).Fstart, int64(numDisplayChars)) dx = float64(cosA*float64((*TLayoutChunk)(unsafe.Pointer(chunkPtr)).Fx+*(*int32)(unsafe.Pointer(bp)))) + float64(sinA*float64((*TLayoutChunk)(unsafe.Pointer(chunkPtr)).Fy)) dy = float64(-sinA*float64((*TLayoutChunk)(unsafe.Pointer(chunkPtr)).Fx+*(*int32)(unsafe.Pointer(bp)))) + float64(cosA*float64((*TLayoutChunk)(unsafe.Pointer(chunkPtr)).Fy)) if angle == float64(0) { XTk_DrawChars(tls, display, drawable, gc, (*TTextLayout)(unsafe.Pointer(layoutPtr)).Ftkfont, firstByte, int64(lastByte)-int64(firstByte), int32(float64(x)+dx), int32(float64(y)+dy)) } else { XTkDrawAngledChars(tls, display, drawable, gc, (*TTextLayout)(unsafe.Pointer(layoutPtr)).Ftkfont, firstByte, int64(lastByte)-int64(firstByte), float64(x)+dx, float64(y)+dy, angle) } } firstChar -= (*TLayoutChunk)(unsafe.Pointer(chunkPtr)).FnumChars lastChar -= (*TLayoutChunk)(unsafe.Pointer(chunkPtr)).FnumChars if lastChar <= 0 { break } chunkPtr += 48 goto _1 _1: ; i++ } } /* *--------------------------------------------------------------------------- * * Tk_UnderlineTextLayout -- * * Use the information in the Tk_TextLayout token to display an underline * below an individual character. This function does not draw the text, * just the underline. * * This function is useful for simple widgets that need to display * single-font, multi-line text with an individual character underlined * and want Tk to handle the details. To display larger amounts of * underlined text, construct and use an underlined font. * * Results: * None. * * Side effects: * Underline drawn on the screen. * *--------------------------------------------------------------------------- */ func XTk_UnderlineTextLayout(tls *libc.TLS, display uintptr, drawable TDrawable, gc TGC, layout TTk_TextLayout, x int32, y int32, underline int32) { bp := tls.Alloc(16) defer tls.Free(16) /* Index of the single character to underline, * or INT_MIN for no underline. */ var fontPtr, layoutPtr uintptr var _ /* height at bp+12 */ int32 var _ /* width at bp+8 */ int32 var _ /* xx at bp+0 */ int32 var _ /* yy at bp+4 */ int32 _, _ = fontPtr, layoutPtr if XTk_CharBbox(tls, layout, int64(underline), bp, bp+4, bp+8, bp+12) != 0 && *(*int32)(unsafe.Pointer(bp + 8)) != 0 { layoutPtr = layout fontPtr = (*TTextLayout)(unsafe.Pointer(layoutPtr)).Ftkfont libx11.XXFillRectangle(tls, display, drawable, gc, x+*(*int32)(unsafe.Pointer(bp)), y+*(*int32)(unsafe.Pointer(bp + 4))+(*TTkFont)(unsafe.Pointer(fontPtr)).Ffm.Fascent+(*TTkFont)(unsafe.Pointer(fontPtr)).FunderlinePos, libc.Uint32FromInt32(*(*int32)(unsafe.Pointer(bp + 8))), libc.Uint32FromInt32((*TTkFont)(unsafe.Pointer(fontPtr)).FunderlineHeight)) } } func XTkUnderlineAngledTextLayout(tls *libc.TLS, display uintptr, drawable TDrawable, gc TGC, layout TTk_TextLayout, x int32, y int32, angle float64, underline int32) { bp := tls.Alloc(48) defer tls.Free(48) /* Index of the single character to underline, * or INT_MIN for no underline. */ var cosA, dy, sinA float64 var fontPtr, layoutPtr uintptr var _ /* height at bp+12 */ int32 var _ /* points at bp+16 */ [5]TXPoint var _ /* width at bp+8 */ int32 var _ /* xx at bp+0 */ int32 var _ /* yy at bp+4 */ int32 _, _, _, _, _ = cosA, dy, fontPtr, layoutPtr, sinA if angle == float64(0) { XTk_UnderlineTextLayout(tls, display, drawable, gc, layout, x, y, underline) return } if XTk_CharBbox(tls, layout, int64(underline), bp, bp+4, bp+8, bp+12) != 0 && *(*int32)(unsafe.Pointer(bp + 8)) != 0 { layoutPtr = layout fontPtr = (*TTextLayout)(unsafe.Pointer(layoutPtr)).Ftkfont sinA = libc.Xsin(tls, float64(angle*float64(3.141592653589793))/libc.Float64FromInt32(180)) cosA = libc.Xcos(tls, float64(angle*float64(3.141592653589793))/libc.Float64FromInt32(180)) dy = float64(*(*int32)(unsafe.Pointer(bp + 4)) + (*TTkFont)(unsafe.Pointer(fontPtr)).Ffm.Fascent + (*TTkFont)(unsafe.Pointer(fontPtr)).FunderlinePos) /* * Note that we're careful to only round a double value once, which * minimizes roundoff errors. */ (*(*[5]TXPoint)(unsafe.Pointer(bp + 16)))[0].Fx = int16(x + int32(int16(libc.Xfloor(tls, float64(float64(*(*int32)(unsafe.Pointer(bp)))*cosA)+float64(dy*sinA)+float64(0.5))))) (*(*[5]TXPoint)(unsafe.Pointer(bp + 16)))[0].Fy = int16(y + int32(int16(libc.Xfloor(tls, float64(dy*cosA)-float64(float64(*(*int32)(unsafe.Pointer(bp)))*sinA)+float64(0.5))))) (*(*[5]TXPoint)(unsafe.Pointer(bp + 16)))[int32(1)].Fx = int16(x + int32(int16(libc.Xfloor(tls, float64(float64(*(*int32)(unsafe.Pointer(bp)))*cosA)+float64(dy*sinA)+float64(float64(*(*int32)(unsafe.Pointer(bp + 8)))*cosA)+float64(0.5))))) (*(*[5]TXPoint)(unsafe.Pointer(bp + 16)))[int32(1)].Fy = int16(y + int32(int16(libc.Xfloor(tls, float64(dy*cosA)-float64(float64(*(*int32)(unsafe.Pointer(bp)))*sinA)-float64(float64(*(*int32)(unsafe.Pointer(bp + 8)))*sinA)+float64(0.5))))) if (*TTkFont)(unsafe.Pointer(fontPtr)).FunderlineHeight == int32(1) { /* * Thin underlines look better when rotated when drawn as a line * rather than a rectangle; the rasterizer copes better. */ libx11.XXDrawLines(tls, display, drawable, gc, bp+16, int32(2), CoordModeOrigin) } else { (*(*[5]TXPoint)(unsafe.Pointer(bp + 16)))[int32(2)].Fx = int16(x + int32(int16(libc.Xfloor(tls, float64(float64(*(*int32)(unsafe.Pointer(bp)))*cosA)+float64(dy*sinA)+float64(float64(*(*int32)(unsafe.Pointer(bp + 8)))*cosA)+float64(float64((*TTkFont)(unsafe.Pointer(fontPtr)).FunderlineHeight)*sinA)+float64(0.5))))) (*(*[5]TXPoint)(unsafe.Pointer(bp + 16)))[int32(2)].Fy = int16(y + int32(int16(libc.Xfloor(tls, float64(dy*cosA)-float64(float64(*(*int32)(unsafe.Pointer(bp)))*sinA)-float64(float64(*(*int32)(unsafe.Pointer(bp + 8)))*sinA)+float64(float64((*TTkFont)(unsafe.Pointer(fontPtr)).FunderlineHeight)*cosA)+float64(0.5))))) (*(*[5]TXPoint)(unsafe.Pointer(bp + 16)))[int32(3)].Fx = int16(x + int32(int16(libc.Xfloor(tls, float64(float64(*(*int32)(unsafe.Pointer(bp)))*cosA)+float64(dy*sinA)+float64(float64((*TTkFont)(unsafe.Pointer(fontPtr)).FunderlineHeight)*sinA)+float64(0.5))))) (*(*[5]TXPoint)(unsafe.Pointer(bp + 16)))[int32(3)].Fy = int16(y + int32(int16(libc.Xfloor(tls, float64(dy*cosA)-float64(float64(*(*int32)(unsafe.Pointer(bp)))*sinA)+float64(float64((*TTkFont)(unsafe.Pointer(fontPtr)).FunderlineHeight)*cosA)+float64(0.5))))) (*(*[5]TXPoint)(unsafe.Pointer(bp + 16)))[int32(4)].Fx = (*(*[5]TXPoint)(unsafe.Pointer(bp + 16)))[0].Fx (*(*[5]TXPoint)(unsafe.Pointer(bp + 16)))[int32(4)].Fy = (*(*[5]TXPoint)(unsafe.Pointer(bp + 16)))[0].Fy libx11.XXFillPolygon(tls, display, drawable, gc, bp+16, int32(5), Complex, CoordModeOrigin) libx11.XXDrawLines(tls, display, drawable, gc, bp+16, int32(5), CoordModeOrigin) } } } /* *--------------------------------------------------------------------------- * * Tk_PointToChar -- * * Use the information in the Tk_TextLayout token to determine the * character closest to the given point. The point must be specified with * respect to the upper-left hand corner of the text layout, which is * considered to be located at (0, 0). * * Any point whose y-value is less that 0 will be considered closest to * the first character in the text layout; any point whose y-value is * greater than the height of the text layout will be considered closest * to the last character in the text layout. * * Any point whose x-value is less than 0 will be considered closest to * the first character on that line; any point whose x-value is greater * than the width of the text layout will be considered closest to the * last character on that line. * * Results: * The return value is the index of the character that was closest to the * point. Given a text layout with no characters, the value 0 will always * be returned, referring to a hypothetical zero-width placeholder * character. * * Side effects: * None. * *--------------------------------------------------------------------------- */ func XTk_PointToChar(tls *libc.TLS, layout TTk_TextLayout, x int32, y int32) (r int32) { bp := tls.Alloc(16) defer tls.Free(16) /* Coordinates of point to check, with respect * to the upper-left corner of the text * layout. */ var baseline, i, n, numChars, pos int32 var chunkPtr, fontPtr, lastPtr, layoutPtr, v1 uintptr var _ /* dummy at bp+0 */ int32 _, _, _, _, _, _, _, _, _, _ = baseline, chunkPtr, fontPtr, i, lastPtr, layoutPtr, n, numChars, pos, v1 layoutPtr = layout if y < 0 { /* * Point lies above any line in this layout. Return the index of the * first char. */ return 0 } /* * Find which line contains the point. */ fontPtr = (*TTextLayout)(unsafe.Pointer(layoutPtr)).Ftkfont v1 = layoutPtr + 32 chunkPtr = v1 lastPtr = v1 numChars = 0 i = 0 for { if !(int64(i) < (*TTextLayout)(unsafe.Pointer(layoutPtr)).FnumChunks) { break } baseline = (*TLayoutChunk)(unsafe.Pointer(chunkPtr)).Fy if y < baseline+(*TTkFont)(unsafe.Pointer(fontPtr)).Ffm.Fdescent { if x < (*TLayoutChunk)(unsafe.Pointer(chunkPtr)).Fx { /* * Point is to the left of all chunks on this line. Return the * index of the first character on this line. */ return numChars } if x >= (*TTextLayout)(unsafe.Pointer(layoutPtr)).Fwidth { /* * If point lies off right side of the text layout, return the * last char in the last chunk on this line. Without this, it * might return the index of the first char that was located * outside of the text layout. */ x = int32(INT_MAX) } /* * Examine all chunks on this line to see which one contains the * specified point. */ lastPtr = chunkPtr for int64(i) < (*TTextLayout)(unsafe.Pointer(layoutPtr)).FnumChunks && (*TLayoutChunk)(unsafe.Pointer(chunkPtr)).Fy == baseline { if x < (*TLayoutChunk)(unsafe.Pointer(chunkPtr)).Fx+(*TLayoutChunk)(unsafe.Pointer(chunkPtr)).FtotalWidth { /* * Point falls on one of the characters in this chunk. */ if (*TLayoutChunk)(unsafe.Pointer(chunkPtr)).FnumDisplayChars < 0 { /* * This is a special chunk that encapsulates a single * tab or newline char. */ return numChars } n = XTk_MeasureChars(tls, fontPtr, (*TLayoutChunk)(unsafe.Pointer(chunkPtr)).Fstart, (*TLayoutChunk)(unsafe.Pointer(chunkPtr)).FnumBytes, x-(*TLayoutChunk)(unsafe.Pointer(chunkPtr)).Fx, 0, bp) return int32(int64(numChars) + libtcl9_0.XTcl_NumUtfChars(tls, (*TLayoutChunk)(unsafe.Pointer(chunkPtr)).Fstart, int64(n))) } numChars = int32(int64(numChars) + (*TLayoutChunk)(unsafe.Pointer(chunkPtr)).FnumChars) lastPtr = chunkPtr chunkPtr += 48 i++ } /* * Point is to the right of all chars in all the chunks on this * line. Return the index just past the last char in the last * chunk on this line. */ pos = numChars if int64(i) < (*TTextLayout)(unsafe.Pointer(layoutPtr)).FnumChunks { pos-- } return pos } numChars = int32(int64(numChars) + (*TLayoutChunk)(unsafe.Pointer(chunkPtr)).FnumChars) lastPtr = chunkPtr chunkPtr += 48 goto _2 _2: ; i++ } /* * Point lies below any line in this text layout. Return the index just * past the last char. */ return int32(int64((*TLayoutChunk)(unsafe.Pointer(lastPtr)).Fstart+uintptr((*TLayoutChunk)(unsafe.Pointer(lastPtr)).FnumChars)) - int64((*TTextLayout)(unsafe.Pointer(layoutPtr)).Fstring1)) } /* *--------------------------------------------------------------------------- * * Tk_CharBbox -- * * Use the information in the Tk_TextLayout token to return the bounding * box for the character specified by index. * * The width of the bounding box is the advance width of the character, * and does not include and left- or right-bearing. Any character that * extends partially outside of the text layout is considered to be * truncated at the edge. Any character which is located completely * outside of the text layout is considered to be zero-width and pegged * against the edge. * * The height of the bounding box is the line height for this font, * extending from the top of the ascent to the bottom of the descent. * Information about the actual height of the individual letter is not * available. * * A text layout that contains no characters is considered to contain a * single zero-width placeholder character. * * Results: * The return value is 0 if the index did not specify a character in the * text layout, or non-zero otherwise. In that case, *bbox is filled with * the bounding box of the character. * * Side effects: * None. * *--------------------------------------------------------------------------- */ func XTk_CharBbox(tls *libc.TLS, layout TTk_TextLayout, index TTcl_Size, xPtr uintptr, yPtr uintptr, widthPtr uintptr, heightPtr uintptr) (r int32) { bp := tls.Alloc(16) defer tls.Free(16) /* Filled with the width and height of the * bounding box for the character specified by * index, if non-NULL. */ var chunkPtr, end, fontPtr, layoutPtr uintptr var i int32 var tkfont TTk_Font var _ /* ch at bp+8 */ int32 var _ /* w at bp+4 */ int32 var _ /* x at bp+0 */ int32 _, _, _, _, _, _ = chunkPtr, end, fontPtr, i, layoutPtr, tkfont layoutPtr = layout chunkPtr = layoutPtr + 32 *(*int32)(unsafe.Pointer(bp)) = 0 if index < 0 { i = 0 for { if !(int64(i) < (*TTextLayout)(unsafe.Pointer(layoutPtr)).FnumChunks) { break } index += (*TLayoutChunk)(unsafe.Pointer(chunkPtr + uintptr(i)*48)).FnumChars goto _1 _1: ; i++ } if index < 0 { return 0 } } tkfont = (*TTextLayout)(unsafe.Pointer(layoutPtr)).Ftkfont fontPtr = tkfont i = 0 for { if !(int64(i) < (*TTextLayout)(unsafe.Pointer(layoutPtr)).FnumChunks) { break } if (*TLayoutChunk)(unsafe.Pointer(chunkPtr)).FnumDisplayChars < 0 { if index == 0 { *(*int32)(unsafe.Pointer(bp)) = (*TLayoutChunk)(unsafe.Pointer(chunkPtr)).Fx *(*int32)(unsafe.Pointer(bp + 4)) = (*TLayoutChunk)(unsafe.Pointer(chunkPtr)).FtotalWidth goto check } } else { if index < (*TLayoutChunk)(unsafe.Pointer(chunkPtr)).FnumChars { end = libtcl9_0.XTcl_UtfAtIndex(tls, (*TLayoutChunk)(unsafe.Pointer(chunkPtr)).Fstart, index) if xPtr != libc.UintptrFromInt32(0) { XTk_MeasureChars(tls, tkfont, (*TLayoutChunk)(unsafe.Pointer(chunkPtr)).Fstart, int64(end)-int64((*TLayoutChunk)(unsafe.Pointer(chunkPtr)).Fstart), -int32(1), 0, bp) *(*int32)(unsafe.Pointer(bp)) += (*TLayoutChunk)(unsafe.Pointer(chunkPtr)).Fx } if widthPtr != libc.UintptrFromInt32(0) { XTk_MeasureChars(tls, tkfont, end, libtcl9_0.XTcl_UtfToUniChar(tls, end, bp+8), -int32(1), 0, bp+4) } goto check } } index -= (*TLayoutChunk)(unsafe.Pointer(chunkPtr)).FnumChars chunkPtr += 48 goto _2 _2: ; i++ } if index != 0 { return 0 } /* * Special case to get location just past last char in layout. */ chunkPtr -= 48 *(*int32)(unsafe.Pointer(bp)) = (*TLayoutChunk)(unsafe.Pointer(chunkPtr)).Fx + (*TLayoutChunk)(unsafe.Pointer(chunkPtr)).FtotalWidth *(*int32)(unsafe.Pointer(bp + 4)) = 0 /* * Ensure that the bbox lies within the text layout. This forces all chars * that extend off the right edge of the text layout to have truncated * widths, and all chars that are completely off the right edge of the * text layout to peg to the edge and have 0 width. */ goto check check: ; if yPtr != libc.UintptrFromInt32(0) { *(*int32)(unsafe.Pointer(yPtr)) = (*TLayoutChunk)(unsafe.Pointer(chunkPtr)).Fy - (*TTkFont)(unsafe.Pointer(fontPtr)).Ffm.Fascent } if heightPtr != libc.UintptrFromInt32(0) { *(*int32)(unsafe.Pointer(heightPtr)) = (*TTkFont)(unsafe.Pointer(fontPtr)).Ffm.Fascent + (*TTkFont)(unsafe.Pointer(fontPtr)).Ffm.Fdescent } if *(*int32)(unsafe.Pointer(bp)) > (*TTextLayout)(unsafe.Pointer(layoutPtr)).Fwidth { *(*int32)(unsafe.Pointer(bp)) = (*TTextLayout)(unsafe.Pointer(layoutPtr)).Fwidth } if xPtr != libc.UintptrFromInt32(0) { *(*int32)(unsafe.Pointer(xPtr)) = *(*int32)(unsafe.Pointer(bp)) } if widthPtr != libc.UintptrFromInt32(0) { if *(*int32)(unsafe.Pointer(bp))+*(*int32)(unsafe.Pointer(bp + 4)) > (*TTextLayout)(unsafe.Pointer(layoutPtr)).Fwidth { *(*int32)(unsafe.Pointer(bp + 4)) = (*TTextLayout)(unsafe.Pointer(layoutPtr)).Fwidth - *(*int32)(unsafe.Pointer(bp)) } *(*int32)(unsafe.Pointer(widthPtr)) = *(*int32)(unsafe.Pointer(bp + 4)) } return int32(1) } /* *--------------------------------------------------------------------------- * * Tk_DistanceToTextLayout -- * * Computes the distance in pixels from the given point to the given text * layout. Non-displaying space characters that occur at the end of * individual lines in the text layout are ignored for hit detection * purposes. * * Results: * The return value is 0 if the point (x, y) is inside the text layout. * If the point isn't inside the text layout then the return value is the * distance in pixels from the point to the text item. * * Side effects: * None. * *--------------------------------------------------------------------------- */ func XTk_DistanceToTextLayout(tls *libc.TLS, layout TTk_TextLayout, x int32, y int32) (r int32) { /* Coordinates of point to check, with respect * to the upper-left corner of the text layout * (in pixels). */ var ascent, descent, dist, i, minDist, x1, x2, xDiff, y1, y2, yDiff int32 var chunkPtr, fontPtr, layoutPtr uintptr _, _, _, _, _, _, _, _, _, _, _, _, _, _ = ascent, chunkPtr, descent, dist, fontPtr, i, layoutPtr, minDist, x1, x2, xDiff, y1, y2, yDiff layoutPtr = layout fontPtr = (*TTextLayout)(unsafe.Pointer(layoutPtr)).Ftkfont ascent = (*TTkFont)(unsafe.Pointer(fontPtr)).Ffm.Fascent descent = (*TTkFont)(unsafe.Pointer(fontPtr)).Ffm.Fdescent minDist = 0 chunkPtr = layoutPtr + 32 i = 0 for { if !(int64(i) < (*TTextLayout)(unsafe.Pointer(layoutPtr)).FnumChunks) { break } if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer((*TLayoutChunk)(unsafe.Pointer(chunkPtr)).Fstart))) == int32('\n') { /* * Newline characters are not counted when computing distance (but * tab characters would still be considered). */ chunkPtr += 48 goto _1 } x1 = (*TLayoutChunk)(unsafe.Pointer(chunkPtr)).Fx y1 = (*TLayoutChunk)(unsafe.Pointer(chunkPtr)).Fy - ascent x2 = (*TLayoutChunk)(unsafe.Pointer(chunkPtr)).Fx + (*TLayoutChunk)(unsafe.Pointer(chunkPtr)).FdisplayWidth y2 = (*TLayoutChunk)(unsafe.Pointer(chunkPtr)).Fy + descent if x < x1 { xDiff = x1 - x } else { if x >= x2 { xDiff = x - x2 + int32(1) } else { xDiff = 0 } } if y < y1 { yDiff = y1 - y } else { if y >= y2 { yDiff = y - y2 + int32(1) } else { yDiff = 0 } } if xDiff == 0 && yDiff == 0 { return 0 } dist = int32(libc.X__builtin_hypot(tls, float64(xDiff), float64(yDiff))) if dist < minDist || minDist == 0 { minDist = dist } chunkPtr += 48 goto _1 _1: ; i++ } return minDist } /* *--------------------------------------------------------------------------- * * Tk_IntersectTextLayout -- * * Determines whether a text layout lies entirely inside, entirely * outside, or overlaps a given rectangle. Non-displaying space * characters that occur at the end of individual lines in the text * layout are ignored for intersection calculations. * * Results: * The return value is -1 if the text layout is entirely outside of the * rectangle, 0 if it overlaps, and 1 if it is entirely inside of the * rectangle. * * Side effects: * None. * *--------------------------------------------------------------------------- */ func XTk_IntersectTextLayout(tls *libc.TLS, layout TTk_TextLayout, x int32, y int32, width int32, height int32) (r int32) { /* The width and height of the above * rectangular area, in pixels. */ var bottom, i, left, result, right, top, x1, x2, y1, y2 int32 var chunkPtr, fontPtr, layoutPtr uintptr _, _, _, _, _, _, _, _, _, _, _, _, _ = bottom, chunkPtr, fontPtr, i, layoutPtr, left, result, right, top, x1, x2, y1, y2 layoutPtr = layout /* * Scan the chunks one at a time, seeing whether each is entirely in, * entirely out, or overlapping the rectangle. If an overlap is detected, * return immediately; otherwise wait until all chunks have been processed * and see if they were all inside or all outside. */ chunkPtr = layoutPtr + 32 fontPtr = (*TTextLayout)(unsafe.Pointer(layoutPtr)).Ftkfont left = x top = y right = x + width bottom = y + height result = 0 i = 0 for { if !(int64(i) < (*TTextLayout)(unsafe.Pointer(layoutPtr)).FnumChunks) { break } if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer((*TLayoutChunk)(unsafe.Pointer(chunkPtr)).Fstart))) == int32('\n') || (*TLayoutChunk)(unsafe.Pointer(chunkPtr)).FnumBytes == 0 { /* * Newline characters and empty chunks are not counted when * computing area intersection (but tab characters would still be * considered). */ chunkPtr += 48 goto _1 } x1 = (*TLayoutChunk)(unsafe.Pointer(chunkPtr)).Fx y1 = (*TLayoutChunk)(unsafe.Pointer(chunkPtr)).Fy - (*TTkFont)(unsafe.Pointer(fontPtr)).Ffm.Fascent x2 = (*TLayoutChunk)(unsafe.Pointer(chunkPtr)).Fx + (*TLayoutChunk)(unsafe.Pointer(chunkPtr)).FdisplayWidth y2 = (*TLayoutChunk)(unsafe.Pointer(chunkPtr)).Fy + (*TTkFont)(unsafe.Pointer(fontPtr)).Ffm.Fdescent if right < x1 || left >= x2 || bottom < y1 || top >= y2 { if result == int32(1) { return 0 } result = -int32(1) } else { if x1 < left || x2 >= right || y1 < top || y2 >= bottom { return 0 } else { if result == -int32(1) { return 0 } else { result = int32(1) } } } chunkPtr += 48 goto _1 _1: ; i++ } return result } /* *--------------------------------------------------------------------------- * * TkIntersectAngledTextLayout -- * * Determines whether a text layout that has been turned by an angle * about its top-left coordinae lies entirely inside, entirely outside, * or overlaps a given rectangle. Non-displaying space characters that * occur at the end of individual lines in the text layout are ignored * for intersection calculations. * * Results: * The return value is -1 if the text layout is entirely outside of the * rectangle, 0 if it overlaps, and 1 if it is entirely inside of the * rectangle. * * Side effects: * None. * *--------------------------------------------------------------------------- */ func _PointInQuadrilateral(tls *libc.TLS, qx uintptr, qy uintptr, x float64, y float64) (r int32) { var dx, dy, sideDX, sideDY float64 var i int32 _, _, _, _, _ = dx, dy, i, sideDX, sideDY i = 0 for { if !(i < int32(4)) { break } sideDX = *(*float64)(unsafe.Pointer(qx + uintptr((i+int32(1))%int32(4))*8)) - *(*float64)(unsafe.Pointer(qx + uintptr(i)*8)) sideDY = *(*float64)(unsafe.Pointer(qy + uintptr((i+int32(1))%int32(4))*8)) - *(*float64)(unsafe.Pointer(qy + uintptr(i)*8)) dx = x - *(*float64)(unsafe.Pointer(qx + uintptr(i)*8)) dy = y - *(*float64)(unsafe.Pointer(qy + uintptr(i)*8)) if float64(sideDX*dy) < float64(sideDY*dx) { return 0 } goto _1 _1: ; i++ } return int32(1) } func _SidesIntersect(tls *libc.TLS, ax1 float64, ay1 float64, ax2 float64, ay2 float64, bx1 float64, by1 float64, bx2 float64, by2 float64) (r int32) { var dx, dx1, dy, dy1 float64 _, _, _, _ = dx, dx1, dy, dy1 dx = ax2 - ax1 dy = ay2 - ay1 dx1 = bx1 - ax1 dy1 = by1 - ay1 if libc.BoolInt32(float64(dx*dy1)-float64(dy*dx1) > float64(0)) == libc.BoolInt32(float64(dx*(by2-ay1))-float64(dy*(bx2-ax1)) > float64(0)) { return 0 } dx = bx2 - bx1 dy = by2 - by1 if libc.BoolInt32(float64(dy*dx1)-float64(dx*dy1) > float64(0)) == libc.BoolInt32(float64(dx*(ay2-by1))-float64(dy*(ax2-bx1)) > float64(0)) { return 0 } return int32(1) } func XTkIntersectAngledTextLayout(tls *libc.TLS, layout TTk_TextLayout, x int32, y int32, width int32, height int32, angle float64) (r int32) { bp := tls.Alloc(128) defer tls.Free(128) var c, s, v3, v4, v5, v6 float64 var chunkPtr, fontPtr, layoutPtr uintptr var i, j, k, x1, x2, y1, y2 int32 var _ /* cx at bp+64 */ [4]float64 var _ /* cy at bp+96 */ [4]float64 var _ /* rx at bp+0 */ [4]float64 var _ /* ry at bp+32 */ [4]float64 _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = c, chunkPtr, fontPtr, i, j, k, layoutPtr, s, x1, x2, y1, y2, v3, v4, v5, v6 c = libc.Xcos(tls, float64(angle*float64(3.141592653589793))/float64(180)) s = libc.Xsin(tls, float64(angle*float64(3.141592653589793))/float64(180)) if angle == float64(0) { return XTk_IntersectTextLayout(tls, layout, x, y, width, height) } /* * Compute the coordinates of the rectangle, rotated into text layout * space. */ (*(*[4]float64)(unsafe.Pointer(bp)))[0] = float64(float64(x)*c) - float64(float64(y)*s) (*(*[4]float64)(unsafe.Pointer(bp + 32)))[0] = float64(float64(y)*c) + float64(float64(x)*s) (*(*[4]float64)(unsafe.Pointer(bp)))[int32(1)] = float64(float64(x+width)*c) - float64(float64(y)*s) (*(*[4]float64)(unsafe.Pointer(bp + 32)))[int32(1)] = float64(float64(y)*c) + float64(float64(x+width)*s) (*(*[4]float64)(unsafe.Pointer(bp)))[int32(2)] = float64(float64(x+width)*c) - float64(float64(y+height)*s) (*(*[4]float64)(unsafe.Pointer(bp + 32)))[int32(2)] = float64(float64(y+height)*c) + float64(float64(x+width)*s) (*(*[4]float64)(unsafe.Pointer(bp)))[int32(3)] = float64(float64(x)*c) - float64(float64(y+height)*s) (*(*[4]float64)(unsafe.Pointer(bp + 32)))[int32(3)] = float64(float64(y+height)*c) + float64(float64(x)*s) /* * Want to know if all chunks are inside the rectangle, or if there is any * overlap. First, we check to see if all chunks are inside; if and only * if they are, we're in the "inside" case. */ layoutPtr = layout chunkPtr = layoutPtr + 32 fontPtr = (*TTextLayout)(unsafe.Pointer(layoutPtr)).Ftkfont i = 0 for { if !(int64(i) < (*TTextLayout)(unsafe.Pointer(layoutPtr)).FnumChunks) { break } if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer((*TLayoutChunk)(unsafe.Pointer(chunkPtr)).Fstart))) == int32('\n') { /* * Newline characters are not counted when computing area * intersection (but tab characters would still be considered). */ goto _1 } x1 = (*TLayoutChunk)(unsafe.Pointer(chunkPtr)).Fx y1 = (*TLayoutChunk)(unsafe.Pointer(chunkPtr)).Fy - (*TTkFont)(unsafe.Pointer(fontPtr)).Ffm.Fascent x2 = (*TLayoutChunk)(unsafe.Pointer(chunkPtr)).Fx + (*TLayoutChunk)(unsafe.Pointer(chunkPtr)).FdisplayWidth y2 = (*TLayoutChunk)(unsafe.Pointer(chunkPtr)).Fy + (*TTkFont)(unsafe.Pointer(fontPtr)).Ffm.Fdescent if !(_PointInQuadrilateral(tls, bp, bp+32, float64(x1), float64(y1)) != 0) || !(_PointInQuadrilateral(tls, bp, bp+32, float64(x2), float64(y1)) != 0) || !(_PointInQuadrilateral(tls, bp, bp+32, float64(x2), float64(y2)) != 0) || !(_PointInQuadrilateral(tls, bp, bp+32, float64(x1), float64(y2)) != 0) { goto notInside } goto _1 _1: ; i++ chunkPtr += 48 } return int32(1) /* * Next, check to see if all the points of the rectangle are inside a * single chunk; if they are, we're in an "overlap" case. */ goto notInside notInside: ; chunkPtr = layoutPtr + 32 i = 0 for { if !(int64(i) < (*TTextLayout)(unsafe.Pointer(layoutPtr)).FnumChunks) { break } if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer((*TLayoutChunk)(unsafe.Pointer(chunkPtr)).Fstart))) == int32('\n') { /* * Newline characters are not counted when computing area * intersection (but tab characters would still be considered). */ goto _2 } v3 = float64((*TLayoutChunk)(unsafe.Pointer(chunkPtr)).Fx) (*(*[4]float64)(unsafe.Pointer(bp + 64)))[int32(3)] = v3 (*(*[4]float64)(unsafe.Pointer(bp + 64)))[0] = v3 v4 = float64((*TLayoutChunk)(unsafe.Pointer(chunkPtr)).Fy - (*TTkFont)(unsafe.Pointer(fontPtr)).Ffm.Fascent) (*(*[4]float64)(unsafe.Pointer(bp + 96)))[int32(1)] = v4 (*(*[4]float64)(unsafe.Pointer(bp + 96)))[0] = v4 v5 = float64((*TLayoutChunk)(unsafe.Pointer(chunkPtr)).Fx + (*TLayoutChunk)(unsafe.Pointer(chunkPtr)).FdisplayWidth) (*(*[4]float64)(unsafe.Pointer(bp + 64)))[int32(2)] = v5 (*(*[4]float64)(unsafe.Pointer(bp + 64)))[int32(1)] = v5 v6 = float64((*TLayoutChunk)(unsafe.Pointer(chunkPtr)).Fy + (*TTkFont)(unsafe.Pointer(fontPtr)).Ffm.Fdescent) (*(*[4]float64)(unsafe.Pointer(bp + 96)))[int32(3)] = v6 (*(*[4]float64)(unsafe.Pointer(bp + 96)))[int32(2)] = v6 if _PointInQuadrilateral(tls, bp+64, bp+96, (*(*[4]float64)(unsafe.Pointer(bp)))[0], (*(*[4]float64)(unsafe.Pointer(bp + 32)))[0]) != 0 && _PointInQuadrilateral(tls, bp+64, bp+96, (*(*[4]float64)(unsafe.Pointer(bp)))[int32(1)], (*(*[4]float64)(unsafe.Pointer(bp + 32)))[int32(1)]) != 0 && _PointInQuadrilateral(tls, bp+64, bp+96, (*(*[4]float64)(unsafe.Pointer(bp)))[int32(2)], (*(*[4]float64)(unsafe.Pointer(bp + 32)))[int32(2)]) != 0 && _PointInQuadrilateral(tls, bp+64, bp+96, (*(*[4]float64)(unsafe.Pointer(bp)))[int32(3)], (*(*[4]float64)(unsafe.Pointer(bp + 32)))[int32(3)]) != 0 { return 0 } goto _2 _2: ; i++ chunkPtr += 48 } /* * If we're overlapping now, we must be partially in and out of at least * one chunk. If that is the case, there must be one line segment of the * rectangle that is touching or crossing a line segment of a chunk. */ chunkPtr = layoutPtr + 32 i = 0 for { if !(int64(i) < (*TTextLayout)(unsafe.Pointer(layoutPtr)).FnumChunks) { break } if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer((*TLayoutChunk)(unsafe.Pointer(chunkPtr)).Fstart))) == int32('\n') { /* * Newline characters are not counted when computing area * intersection (but tab characters would still be considered). */ goto _7 } x1 = (*TLayoutChunk)(unsafe.Pointer(chunkPtr)).Fx y1 = (*TLayoutChunk)(unsafe.Pointer(chunkPtr)).Fy - (*TTkFont)(unsafe.Pointer(fontPtr)).Ffm.Fascent x2 = (*TLayoutChunk)(unsafe.Pointer(chunkPtr)).Fx + (*TLayoutChunk)(unsafe.Pointer(chunkPtr)).FdisplayWidth y2 = (*TLayoutChunk)(unsafe.Pointer(chunkPtr)).Fy + (*TTkFont)(unsafe.Pointer(fontPtr)).Ffm.Fdescent j = 0 for { if !(j < int32(4)) { break } k = (j + int32(1)) % int32(4) if _SidesIntersect(tls, (*(*[4]float64)(unsafe.Pointer(bp)))[j], (*(*[4]float64)(unsafe.Pointer(bp + 32)))[j], (*(*[4]float64)(unsafe.Pointer(bp)))[k], (*(*[4]float64)(unsafe.Pointer(bp + 32)))[k], float64(x1), float64(y1), float64(x2), float64(y1)) != 0 || _SidesIntersect(tls, (*(*[4]float64)(unsafe.Pointer(bp)))[j], (*(*[4]float64)(unsafe.Pointer(bp + 32)))[j], (*(*[4]float64)(unsafe.Pointer(bp)))[k], (*(*[4]float64)(unsafe.Pointer(bp + 32)))[k], float64(x2), float64(y1), float64(x2), float64(y2)) != 0 || _SidesIntersect(tls, (*(*[4]float64)(unsafe.Pointer(bp)))[j], (*(*[4]float64)(unsafe.Pointer(bp + 32)))[j], (*(*[4]float64)(unsafe.Pointer(bp)))[k], (*(*[4]float64)(unsafe.Pointer(bp + 32)))[k], float64(x2), float64(y2), float64(x1), float64(y2)) != 0 || _SidesIntersect(tls, (*(*[4]float64)(unsafe.Pointer(bp)))[j], (*(*[4]float64)(unsafe.Pointer(bp + 32)))[j], (*(*[4]float64)(unsafe.Pointer(bp)))[k], (*(*[4]float64)(unsafe.Pointer(bp + 32)))[k], float64(x1), float64(y2), float64(x1), float64(y1)) != 0 { return 0 } goto _8 _8: ; j++ } goto _7 _7: ; i++ chunkPtr += 48 } /* * They must be wholly non-overlapping. */ return -int32(1) } /* *--------------------------------------------------------------------------- * * Tk_TextLayoutToPostscript -- * * Outputs the contents of a text layout in Postscript format. The set of * lines in the text layout will be rendered by the user supplied * Postscript function. The function should be of the form: * * justify x y string function -- * * Justify is -1, 0, or 1, depending on whether the following string * should be left, center, or right justified, x and y is the location * for the origin of the string, string is the sequence of characters to * be printed, and function is the name of the caller-provided function; * the function should leave nothing on the stack. * * The meaning of the origin of the string (x and y) depends on the * justification. For left justification, x is where the left edge of the * string should appear. For center justification, x is where the center * of the string should appear. And for right justification, x is where * the right edge of the string should appear. This behavior is necessary * because, for example, right justified text on the screen is justified * with screen metrics. The same string needs to be justified with * printer metrics on the printer to appear in the correct place with * respect to other similarly justified strings. In all circumstances, y * is the location of the baseline for the string. * * Results: * The interp's result is modified to hold the Postscript code that will * render the text layout. * * Side effects: * None. * *--------------------------------------------------------------------------- */ func XTk_TextLayoutToPostscript(tls *libc.TLS, interp uintptr, layout TTk_TextLayout) { bp := tls.Alloc(48) defer tls.Free(48) /* The layout to be rendered. */ var _objPtr, chunkPtr, glyphname, layoutPtr, p, ps, psObj, v8 uintptr var baseline, i, j int32 var v7 TTcl_Size var _ /* c at bp+15 */ uint8 var _ /* ch at bp+16 */ int32 var _ /* len at bp+0 */ TTcl_Size var _ /* uindex at bp+10 */ [5]uint8 _, _, _, _, _, _, _, _, _, _, _, _ = _objPtr, baseline, chunkPtr, glyphname, i, j, layoutPtr, p, ps, psObj, v7, v8 layoutPtr = layout chunkPtr = layoutPtr + 32 baseline = (*TLayoutChunk)(unsafe.Pointer(chunkPtr)).Fy psObj = libtcl9_0.XTcl_NewObj(tls) libtcl9_0.XTcl_AppendToObj(tls, psObj, __ccgo_ts+10738, int64(-libc.Int32FromInt32(1))) i = 0 for { if !(int64(i) < (*TTextLayout)(unsafe.Pointer(layoutPtr)).FnumChunks) { break } if baseline != (*TLayoutChunk)(unsafe.Pointer(chunkPtr)).Fy { libtcl9_0.XTcl_AppendToObj(tls, psObj, __ccgo_ts+10741, int64(-libc.Int32FromInt32(1))) baseline = (*TLayoutChunk)(unsafe.Pointer(chunkPtr)).Fy } if (*TLayoutChunk)(unsafe.Pointer(chunkPtr)).FnumDisplayChars <= 0 { if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer((*TLayoutChunk)(unsafe.Pointer(chunkPtr)).Fstart))) == int32('\t') { libtcl9_0.XTcl_AppendToObj(tls, psObj, __ccgo_ts+10747, int64(-libc.Int32FromInt32(1))) } goto _1 } p = (*TLayoutChunk)(unsafe.Pointer(chunkPtr)).Fstart j = libc.Int32FromInt32(0) _4: ; if !(int64(j) < (*TLayoutChunk)(unsafe.Pointer(chunkPtr)).FnumDisplayChars) { goto _2 } /* * INTL: We only handle symbols that have an encoding as a glyph * from the standard set defined by Adobe. The rest get punted. * Eventually this should be revised to handle more sophsticiated * international postscript fonts. */ p += uintptr(libtcl9_0.XTcl_UtfToUniChar(tls, p, bp+16)) if *(*int32)(unsafe.Pointer(bp + 16)) == int32('(') || *(*int32)(unsafe.Pointer(bp + 16)) == int32(')') || *(*int32)(unsafe.Pointer(bp + 16)) == int32('\\') || *(*int32)(unsafe.Pointer(bp + 16)) < int32(0x20) { /* * Tricky point: the "03" is necessary in the snprintf below, * so that a full three digits of octal are always generated. * Without the "03", a number following this sequence could be * interpreted by Postscript as part of this sequence. */ libtcl9_0.XTcl_AppendPrintfToObj(tls, psObj, __ccgo_ts+10750, libc.VaList(bp+32, *(*int32)(unsafe.Pointer(bp + 16)))) goto _3 } else { if *(*int32)(unsafe.Pointer(bp + 16)) <= int32(0x7f) { /* * Normal ASCII character. */ *(*uint8)(unsafe.Pointer(bp + 15)) = libc.Uint8FromInt32(*(*int32)(unsafe.Pointer(bp + 16))) libtcl9_0.XTcl_AppendToObj(tls, psObj, bp+15, int64(1)) goto _3 } } /* * This character doesn't belong to the ASCII character set, so we * use the full glyph name. */ if *(*int32)(unsafe.Pointer(bp + 16)) > int32(0xffff) { goto noMapping } libc.X__builtin_snprintf(tls, bp+10, uint64(5), __ccgo_ts+10756, libc.VaList(bp+32, *(*int32)(unsafe.Pointer(bp + 16)))) /* endianness? */ glyphname = libtcl9_0.XTcl_GetVar2(tls, interp, __ccgo_ts+10761, bp+10, 0) if !(glyphname != 0) { goto _5 } ps = libtcl9_0.XTcl_GetStringFromObj(tls, psObj, bp) if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(ps + uintptr(*(*TTcl_Size)(unsafe.Pointer(bp))-int64(1))))) == int32('(') { /* * In-place edit. Ewww! */ *(*uint8)(unsafe.Pointer(ps + uintptr(*(*TTcl_Size)(unsafe.Pointer(bp))-int64(1)))) = uint8('/') } else { libtcl9_0.XTcl_AppendToObj(tls, psObj, __ccgo_ts+10776, int64(-libc.Int32FromInt32(1))) } libtcl9_0.XTcl_AppendToObj(tls, psObj, glyphname, int64(-libc.Int32FromInt32(1))) libtcl9_0.XTcl_AppendToObj(tls, psObj, __ccgo_ts+10779, int64(-libc.Int32FromInt32(1))) goto _6 _5: ; /* * No known mapping for the character into the space of * PostScript glyphs. Ignore it. :-( */ goto noMapping noMapping: ; _6: ; goto _3 _3: ; j++ goto _4 goto _2 _2: ; goto _1 _1: ; i++ chunkPtr += 48 } libtcl9_0.XTcl_AppendToObj(tls, psObj, __ccgo_ts+10781, int64(-libc.Int32FromInt32(1))) libtcl9_0.XTcl_AppendObjToObj(tls, libtcl9_0.XTcl_GetObjResult(tls, interp), psObj) _objPtr = psObj v8 = _objPtr v7 = *(*TTcl_Size)(unsafe.Pointer(v8)) *(*TTcl_Size)(unsafe.Pointer(v8))-- if v7 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr) } } /* *--------------------------------------------------------------------------- * * ConfigAttributesObj -- * * Process command line options to fill in fields of a properly * initialized font attributes structure. * * Results: * A standard Tcl return value. If TCL_ERROR is returned, an error * message will be left in interp's result object. * * Side effects: * The fields of the font attributes structure get filled in with * information from argc/argv. If an error occurs while parsing, the font * attributes structure will contain all modifications specified in the * command line options up to the point of the error. * *--------------------------------------------------------------------------- */ func _ConfigAttributesObj(tls *libc.TLS, interp uintptr, dummy3416 TTk_Window, objc TTcl_Size, objv uintptr, faPtr uintptr) (r int32) { bp := tls.Alloc(48) defer tls.Free(48) /* Font attributes structure whose fields are * to be modified. Structure must already be * properly initialized. */ var i TTcl_Size var optionPtr, value, valuePtr uintptr var _ /* index at bp+4 */ int32 var _ /* n at bp+0 */ int32 _, _, _, _ = i, optionPtr, value, valuePtr i = 0 for { if !(i < objc) { break } optionPtr = *(*uintptr)(unsafe.Pointer(objv + uintptr(i)*8)) if libtcl9_0.XTcl_GetIndexFromObjStruct(tls, interp, optionPtr, uintptr(unsafe.Pointer(&_fontOpt)), libc.Int64FromUint64(libc.Uint64FromInt64(8)), __ccgo_ts+2689, libc.Int32FromInt32(1)|libc.Int32FromUint64(libc.Uint64FromInt64(4)<= objc && objc&int64(1) != 0 { /* * This test occurs after Tcl_GetIndexFromObj() so that "font * create xyz -xyz" will return the error message that "-xyz" is a * bad option, rather than that the value for "-xyz" is missing. */ if interp != libc.UintptrFromInt32(0) { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+10785, libc.VaList(bp+16, libtcl9_0.XTcl_GetStringFromObj(tls, optionPtr, libc.UintptrFromInt32(0))))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+16, __ccgo_ts+179, __ccgo_ts+900, __ccgo_ts+10815, libc.UintptrFromInt32(0))) } return int32(TCL_ERROR) } valuePtr = *(*uintptr)(unsafe.Pointer(objv + uintptr(i+int64(1))*8)) switch *(*int32)(unsafe.Pointer(bp + 4)) { case FONT_FAMILY: value = libtcl9_0.XTcl_GetStringFromObj(tls, valuePtr, libc.UintptrFromInt32(0)) (*TTkFontAttributes)(unsafe.Pointer(faPtr)).Ffamily = XTk_GetUid(tls, value) case int32(FONT_SIZE): if libtcl9_0.XTcl_GetIntFromObj(tls, interp, valuePtr, bp) != TCL_OK { return int32(TCL_ERROR) } (*TTkFontAttributes)(unsafe.Pointer(faPtr)).Fsize = float64(*(*int32)(unsafe.Pointer(bp))) case int32(FONT_WEIGHT): *(*int32)(unsafe.Pointer(bp)) = XTkFindStateNumObj(tls, interp, optionPtr, uintptr(unsafe.Pointer(&_weightMap)), valuePtr) if *(*int32)(unsafe.Pointer(bp)) == -int32(1) { return int32(TCL_ERROR) } (*TTkFontAttributes)(unsafe.Pointer(faPtr)).Fweight = *(*int32)(unsafe.Pointer(bp)) case int32(FONT_SLANT): *(*int32)(unsafe.Pointer(bp)) = XTkFindStateNumObj(tls, interp, optionPtr, uintptr(unsafe.Pointer(&_slantMap)), valuePtr) if *(*int32)(unsafe.Pointer(bp)) == -int32(1) { return int32(TCL_ERROR) } (*TTkFontAttributes)(unsafe.Pointer(faPtr)).Fslant = *(*int32)(unsafe.Pointer(bp)) case int32(FONT_UNDERLINE): if libtcl9_0.XTcl_GetBoolFromObj(tls, interp, valuePtr, (libc.Int32FromInt32(TCL_NULL_OK)-libc.Int32FromInt32(2))&libc.Int32FromInt64(4), bp) != TCL_OK { return int32(TCL_ERROR) } (*TTkFontAttributes)(unsafe.Pointer(faPtr)).Funderline = *(*int32)(unsafe.Pointer(bp)) case int32(FONT_OVERSTRIKE): if libtcl9_0.XTcl_GetBoolFromObj(tls, interp, valuePtr, (libc.Int32FromInt32(TCL_NULL_OK)-libc.Int32FromInt32(2))&libc.Int32FromInt64(4), bp) != TCL_OK { return int32(TCL_ERROR) } (*TTkFontAttributes)(unsafe.Pointer(faPtr)).Foverstrike = *(*int32)(unsafe.Pointer(bp)) break } goto _1 _1: ; i += int64(2) } return TCL_OK } /* *--------------------------------------------------------------------------- * * GetAttributeInfoObj -- * * Return information about the font attributes as a Tcl list. * * Results: * The return value is TCL_OK if the objPtr was non-NULL and specified a * valid font attribute, TCL_ERROR otherwise. If TCL_OK is returned, the * interp's result object is modified to hold a description of either the * current value of a single option, or a list of all options and their * current values for the given font attributes. If TCL_ERROR is * returned, the interp's result is set to an error message describing * that the objPtr did not refer to a valid option. * * Side effects: * None. * *--------------------------------------------------------------------------- */ func _GetAttributeInfoObj(tls *libc.TLS, interp uintptr, faPtr uintptr, objPtr uintptr) (r int32) { bp := tls.Alloc(16) defer tls.Free(16) /* If non-NULL, indicates the single option * whose value is to be returned. Otherwise * information is returned for all options. */ var end, i, start, v2 int32 var resultPtr, str, valuePtr uintptr var _ /* index at bp+0 */ int32 _, _, _, _, _, _, _ = end, i, resultPtr, start, str, valuePtr, v2 resultPtr = libc.UintptrFromInt32(0) start = 0 end = int32(FONT_NUMFIELDS) if objPtr != libc.UintptrFromInt32(0) { if libtcl9_0.XTcl_GetIndexFromObjStruct(tls, interp, objPtr, uintptr(unsafe.Pointer(&_fontOpt)), libc.Int64FromUint64(libc.Uint64FromInt64(8)), __ccgo_ts+2689, libc.Int32FromInt32(TCL_EXACT)|libc.Int32FromUint64(libc.Uint64FromInt64(4)<= float64(0) { valuePtr = libtcl9_0.XTcl_NewWideIntObj(tls, int64((*TTkFontAttributes)(unsafe.Pointer(faPtr)).Fsize+libc.Float64FromFloat64(0.5))) } else { valuePtr = libtcl9_0.XTcl_NewWideIntObj(tls, -int64(-(*TTkFontAttributes)(unsafe.Pointer(faPtr)).Fsize+libc.Float64FromFloat64(0.5))) } case int32(FONT_WEIGHT): str = XTkFindStateString(tls, uintptr(unsafe.Pointer(&_weightMap)), (*TTkFontAttributes)(unsafe.Pointer(faPtr)).Fweight) valuePtr = libtcl9_0.XTcl_NewStringObj(tls, str, int64(-libc.Int32FromInt32(1))) case int32(FONT_SLANT): str = XTkFindStateString(tls, uintptr(unsafe.Pointer(&_slantMap)), (*TTkFontAttributes)(unsafe.Pointer(faPtr)).Fslant) valuePtr = libtcl9_0.XTcl_NewStringObj(tls, str, int64(-libc.Int32FromInt32(1))) case int32(FONT_UNDERLINE): valuePtr = libtcl9_0.XTcl_NewWideIntObj(tls, libc.BoolInt64((*TTkFontAttributes)(unsafe.Pointer(faPtr)).Funderline != 0)) case int32(FONT_OVERSTRIKE): valuePtr = libtcl9_0.XTcl_NewWideIntObj(tls, libc.BoolInt64((*TTkFontAttributes)(unsafe.Pointer(faPtr)).Foverstrike != 0)) break } if objPtr != libc.UintptrFromInt32(0) { libtcl9_0.XTcl_SetObjResult(tls, interp, valuePtr) return TCL_OK } libtcl9_0.XTcl_ListObjAppendElement(tls, libc.UintptrFromInt32(0), resultPtr, libtcl9_0.XTcl_NewStringObj(tls, _fontOpt[i], int64(-libc.Int32FromInt32(1)))) libtcl9_0.XTcl_ListObjAppendElement(tls, libc.UintptrFromInt32(0), resultPtr, valuePtr) goto _1 _1: ; i++ } libtcl9_0.XTcl_SetObjResult(tls, interp, resultPtr) return TCL_OK } /* *--------------------------------------------------------------------------- * * Tk_FontGetDescription -- * * Return information about the font description as a Tcl list. One * possible result is "{{DejaVu Sans} -16 bold underline}". * * Results: * The list of descriptions. * * Side effects: * None. * *--------------------------------------------------------------------------- */ func XTk_FontGetDescription(tls *libc.TLS, tkfont TTk_Font) (r uintptr) { /* Font whose description is desired. */ var faPtr, resultPtr, str uintptr var v1 int32 _, _, _, _ = faPtr, resultPtr, str, v1 faPtr = tkfont + 64 resultPtr = libtcl9_0.XTcl_NewObj(tls) str = (*TTkFontAttributes)(unsafe.Pointer(faPtr)).Ffamily if str != 0 { v1 = -int32(1) } else { v1 = 0 } libtcl9_0.XTcl_ListObjAppendElement(tls, libc.UintptrFromInt32(0), resultPtr, libtcl9_0.XTcl_NewStringObj(tls, str, int64(v1))) if (*TTkFontAttributes)(unsafe.Pointer(faPtr)).Fsize >= float64(0) { libtcl9_0.XTcl_ListObjAppendElement(tls, libc.UintptrFromInt32(0), resultPtr, libtcl9_0.XTcl_NewWideIntObj(tls, int64(int32((*TTkFontAttributes)(unsafe.Pointer(faPtr)).Fsize+libc.Float64FromFloat64(0.5))))) } else { libtcl9_0.XTcl_ListObjAppendElement(tls, libc.UintptrFromInt32(0), resultPtr, libtcl9_0.XTcl_NewWideIntObj(tls, int64(-int32(-(*TTkFontAttributes)(unsafe.Pointer(faPtr)).Fsize+libc.Float64FromFloat64(0.5))))) } if (*TTkFontAttributes)(unsafe.Pointer(faPtr)).Fweight != TK_FW_NORMAL { str = XTkFindStateString(tls, uintptr(unsafe.Pointer(&_weightMap)), (*TTkFontAttributes)(unsafe.Pointer(faPtr)).Fweight) libtcl9_0.XTcl_ListObjAppendElement(tls, libc.UintptrFromInt32(0), resultPtr, libtcl9_0.XTcl_NewStringObj(tls, str, int64(-libc.Int32FromInt32(1)))) } if (*TTkFontAttributes)(unsafe.Pointer(faPtr)).Fslant != TK_FS_ROMAN { str = XTkFindStateString(tls, uintptr(unsafe.Pointer(&_slantMap)), (*TTkFontAttributes)(unsafe.Pointer(faPtr)).Fslant) libtcl9_0.XTcl_ListObjAppendElement(tls, libc.UintptrFromInt32(0), resultPtr, libtcl9_0.XTcl_NewStringObj(tls, str, int64(-libc.Int32FromInt32(1)))) } if (*TTkFontAttributes)(unsafe.Pointer(faPtr)).Funderline != 0 { str = XTkFindStateString(tls, uintptr(unsafe.Pointer(&_underlineMap)), (*TTkFontAttributes)(unsafe.Pointer(faPtr)).Funderline) libtcl9_0.XTcl_ListObjAppendElement(tls, libc.UintptrFromInt32(0), resultPtr, libtcl9_0.XTcl_NewStringObj(tls, str, int64(-libc.Int32FromInt32(1)))) } if (*TTkFontAttributes)(unsafe.Pointer(faPtr)).Foverstrike != 0 { str = XTkFindStateString(tls, uintptr(unsafe.Pointer(&_overstrikeMap)), (*TTkFontAttributes)(unsafe.Pointer(faPtr)).Foverstrike) libtcl9_0.XTcl_ListObjAppendElement(tls, libc.UintptrFromInt32(0), resultPtr, libtcl9_0.XTcl_NewStringObj(tls, str, int64(-libc.Int32FromInt32(1)))) } return resultPtr } /* *--------------------------------------------------------------------------- * * ParseFontNameObj -- * * Converts a object into a set of font attributes that can be used to * construct a font. * * The string rep of the object can be one of the following forms: * XLFD (see X documentation) * "family [size] [style1 [style2 ...]" * "-option value [-option value ...]" * * Results: * The return value is TCL_ERROR if the object was syntactically invalid. * In that case an error message is left in interp's result object. * Otherwise, fills the font attribute buffer with the values parsed from * the string and returns TCL_OK; * * Side effects: * None. * *--------------------------------------------------------------------------- */ func _ParseFontNameObj(tls *libc.TLS, interp uintptr, tkwin TTk_Window, objPtr uintptr, faPtr uintptr) (r int32) { bp := tls.Alloc(80) defer tls.Free(80) /* Filled with attributes parsed from font * name. Any attributes that were not * specified in font name are filled with * default values. */ var dash, string1 uintptr var i TTcl_Size var result, v1, v2 int32 var v4 bool var _ /* n at bp+0 */ int32 var _ /* objc at bp+8 */ TTcl_Size var _ /* objv at bp+16 */ uintptr _, _, _, _, _, _, _ = dash, i, result, string1, v1, v2, v4 libc.Xmemset(tls, faPtr, 0, uint64(32)) string1 = libtcl9_0.XTcl_GetStringFromObj(tls, objPtr, libc.UintptrFromInt32(0)) if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(string1))) == int32('-') { /* * This may be an XLFD or an "-option value" string. * * If the string begins with "-*" or a "-foundry-family-*" pattern, * then consider it an XLFD. */ if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(string1 + 1))) == int32('*') { goto xlfd } dash = libc.Xstrchr(tls, string1+uintptr(1), int32('-')) if v4 = dash != libc.UintptrFromInt32(0); v4 { v1 = libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(dash + uintptr(-libc.Int32FromInt32(1))))) v2 = libc.BoolInt32(v1 == int32(' ') || libc.Uint32FromInt32(v1)-uint32('\t') < uint32(5)) goto _3 _3: } if v4 && !(v2 != 0) { /* INTL: ISO space */ goto xlfd } if libtcl9_0.XTcl_ListObjGetElements(tls, interp, objPtr, bp+8, bp+16) != TCL_OK { return int32(TCL_ERROR) } return _ConfigAttributesObj(tls, interp, tkwin, *(*TTcl_Size)(unsafe.Pointer(bp + 8)), *(*uintptr)(unsafe.Pointer(bp + 16)), faPtr) } if !(libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(string1))) == int32('*')) { goto _5 } /* * This is appears to be an XLFD. Under Unix, all valid XLFDs were * already handled by TkpGetNativeFont. If we are here, either we have * something that initially looks like an XLFD but isn't or we have * encountered an XLFD on Windows or Mac. */ goto xlfd xlfd: ; result = XTkFontParseXLFD(tls, string1, faPtr, libc.UintptrFromInt32(0)) if result == TCL_OK { return TCL_OK } /* * If the string failed to parse but was considered to be a XLFD * then it may be a "-option value" string with a hyphenated family * name as per bug 2791352 */ if libtcl9_0.XTcl_ListObjGetElements(tls, interp, objPtr, bp+8, bp+16) != TCL_OK { return int32(TCL_ERROR) } if _ConfigAttributesObj(tls, interp, tkwin, *(*TTcl_Size)(unsafe.Pointer(bp + 8)), *(*uintptr)(unsafe.Pointer(bp + 16)), faPtr) == TCL_OK { return TCL_OK } _5: ; /* * Wasn't an XLFD or "-option value" string. Try it as a "font size style" * list. */ if libtcl9_0.XTcl_ListObjGetElements(tls, libc.UintptrFromInt32(0), objPtr, bp+8, bp+16) != TCL_OK || *(*TTcl_Size)(unsafe.Pointer(bp + 8)) < int64(1) { if interp != libc.UintptrFromInt32(0) { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+10828, libc.VaList(bp+32, string1))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+32, __ccgo_ts+179, __ccgo_ts+3058, __ccgo_ts+900, string1, libc.UintptrFromInt32(0))) } return int32(TCL_ERROR) } (*TTkFontAttributes)(unsafe.Pointer(faPtr)).Ffamily = XTk_GetUid(tls, libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 16)))), libc.UintptrFromInt32(0))) if *(*TTcl_Size)(unsafe.Pointer(bp + 8)) > int64(1) { if libtcl9_0.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 16)) + 1*8)), bp) != TCL_OK { return int32(TCL_ERROR) } (*TTkFontAttributes)(unsafe.Pointer(faPtr)).Fsize = float64(*(*int32)(unsafe.Pointer(bp))) } i = int64(2) if *(*TTcl_Size)(unsafe.Pointer(bp + 8)) == int64(3) { if libtcl9_0.XTcl_ListObjGetElements(tls, interp, *(*uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 16)) + 2*8)), bp+8, bp+16) != TCL_OK { return int32(TCL_ERROR) } i = 0 } for { if !(i < *(*TTcl_Size)(unsafe.Pointer(bp + 8))) { break } *(*int32)(unsafe.Pointer(bp)) = XTkFindStateNumObj(tls, libc.UintptrFromInt32(0), libc.UintptrFromInt32(0), uintptr(unsafe.Pointer(&_weightMap)), *(*uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 16)) + uintptr(i)*8))) if *(*int32)(unsafe.Pointer(bp)) != -int32(1) { (*TTkFontAttributes)(unsafe.Pointer(faPtr)).Fweight = *(*int32)(unsafe.Pointer(bp)) goto _6 } *(*int32)(unsafe.Pointer(bp)) = XTkFindStateNumObj(tls, libc.UintptrFromInt32(0), libc.UintptrFromInt32(0), uintptr(unsafe.Pointer(&_slantMap)), *(*uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 16)) + uintptr(i)*8))) if *(*int32)(unsafe.Pointer(bp)) != -int32(1) { (*TTkFontAttributes)(unsafe.Pointer(faPtr)).Fslant = *(*int32)(unsafe.Pointer(bp)) goto _6 } *(*int32)(unsafe.Pointer(bp)) = XTkFindStateNumObj(tls, libc.UintptrFromInt32(0), libc.UintptrFromInt32(0), uintptr(unsafe.Pointer(&_underlineMap)), *(*uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 16)) + uintptr(i)*8))) if *(*int32)(unsafe.Pointer(bp)) != 0 { (*TTkFontAttributes)(unsafe.Pointer(faPtr)).Funderline = *(*int32)(unsafe.Pointer(bp)) goto _6 } *(*int32)(unsafe.Pointer(bp)) = XTkFindStateNumObj(tls, libc.UintptrFromInt32(0), libc.UintptrFromInt32(0), uintptr(unsafe.Pointer(&_overstrikeMap)), *(*uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 16)) + uintptr(i)*8))) if *(*int32)(unsafe.Pointer(bp)) != 0 { (*TTkFontAttributes)(unsafe.Pointer(faPtr)).Foverstrike = *(*int32)(unsafe.Pointer(bp)) goto _6 } /* * Unknown style. */ if interp != libc.UintptrFromInt32(0) { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+10853, libc.VaList(bp+32, libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 16)) + uintptr(i)*8)), libc.UintptrFromInt32(0))))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+32, __ccgo_ts+179, __ccgo_ts+3058, __ccgo_ts+10877, libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 16)) + uintptr(i)*8)), libc.UintptrFromInt32(0)), libc.UintptrFromInt32(0))) } return int32(TCL_ERROR) goto _6 _6: ; i++ } return TCL_OK } /* *--------------------------------------------------------------------------- * * NewChunk -- * * Helper function for Tk_ComputeTextLayout(). Encapsulates a measured * set of characters in a chunk that can be quickly drawn. * * Results: * A pointer to the new chunk in the text layout. * * Side effects: * The text layout is reallocated to hold more chunks as necessary. * * Currently, Tk_ComputeTextLayout() stores contiguous ranges of "normal" * characters in a chunk, along with individual tab and newline chars in * their own chunks. All characters in the text layout are accounted for. * *--------------------------------------------------------------------------- */ func _NewChunk(tls *libc.TLS, layoutPtrPtr uintptr, maxPtr uintptr, start uintptr, numBytes TTcl_Size, curX int32, newX int32, y int32) (r uintptr) { var chunkPtr, layoutPtr uintptr var maxChunks, numChars int32 var s Tsize_t _, _, _, _, _ = chunkPtr, layoutPtr, maxChunks, numChars, s layoutPtr = *(*uintptr)(unsafe.Pointer(layoutPtrPtr)) maxChunks = *(*int32)(unsafe.Pointer(maxPtr)) if (*TTextLayout)(unsafe.Pointer(layoutPtr)).FnumChunks == int64(maxChunks) { maxChunks *= int32(2) s = uint64(libc.UintptrFromInt32(0)+32) + libc.Uint64FromInt32(maxChunks)*uint64(48) layoutPtr = libtcl9_0.XTcl_Realloc(tls, layoutPtr, s) *(*uintptr)(unsafe.Pointer(layoutPtrPtr)) = layoutPtr *(*int32)(unsafe.Pointer(maxPtr)) = maxChunks } numChars = int32(libtcl9_0.XTcl_NumUtfChars(tls, start, numBytes)) chunkPtr = layoutPtr + 32 + uintptr((*TTextLayout)(unsafe.Pointer(layoutPtr)).FnumChunks)*48 (*TLayoutChunk)(unsafe.Pointer(chunkPtr)).Fstart = start (*TLayoutChunk)(unsafe.Pointer(chunkPtr)).FnumBytes = numBytes (*TLayoutChunk)(unsafe.Pointer(chunkPtr)).FnumChars = int64(numChars) (*TLayoutChunk)(unsafe.Pointer(chunkPtr)).FnumDisplayChars = int64(numChars) (*TLayoutChunk)(unsafe.Pointer(chunkPtr)).Fx = curX (*TLayoutChunk)(unsafe.Pointer(chunkPtr)).Fy = y (*TLayoutChunk)(unsafe.Pointer(chunkPtr)).FtotalWidth = newX - curX (*TLayoutChunk)(unsafe.Pointer(chunkPtr)).FdisplayWidth = newX - curX (*TTextLayout)(unsafe.Pointer(layoutPtr)).FnumChunks++ return chunkPtr } /* *--------------------------------------------------------------------------- * * TkFontParseXLFD -- * * Break up a fully specified XLFD into a set of font attributes. * * Results: * Return value is TCL_ERROR if string was not a fully specified XLFD. * Otherwise, fills font attribute buffer with the values parsed from the * XLFD and returns TCL_OK. * * Side effects: * None. * *--------------------------------------------------------------------------- */ func XTkFontParseXLFD(tls *libc.TLS, string1 uintptr, faPtr uintptr, xaPtr uintptr) (r int32) { bp := tls.Alloc(384) defer tls.Free(384) /* Filled with X-specific attributes parsed * from font name. Any attributes that were * not specified in font name are filled with * default values. May be NULL if such * information is not desired. */ var j int32 var src, str uintptr var _ /* ds at bp+128 */ TTcl_DString var _ /* field at bp+8 */ [15]uintptr var _ /* i at bp+0 */ int32 var _ /* xa at bp+352 */ TTkXLFDAttributes _, _, _ = j, src, str if xaPtr == libc.UintptrFromInt32(0) { xaPtr = bp + 352 } libc.Xmemset(tls, faPtr, 0, uint64(32)) libc.Xmemset(tls, xaPtr, 0, uint64(24)) libc.Xmemset(tls, bp+8, int32('\000'), uint64(120)) str = string1 if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(str))) == int32('-') { str++ } libtcl9_0.XTcl_DStringInit(tls, bp+128) libtcl9_0.XTcl_DStringAppend(tls, bp+128, str, int64(-libc.Int32FromInt32(1))) src = (*TTcl_DString)(unsafe.Pointer(bp + 128)).Fstring1 (*(*[15]uintptr)(unsafe.Pointer(bp + 8)))[0] = src *(*int32)(unsafe.Pointer(bp)) = 0 for { if !(libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(src))) != int32('\000')) { break } if !(libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(src)))&libc.Int32FromInt32(0x80) != 0) && libtcl9_0.XTcl_UniCharIsUpper(tls, libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(src)))) != 0 { *(*uint8)(unsafe.Pointer(src)) = libc.Uint8FromInt32(libtcl9_0.XTcl_UniCharToLower(tls, libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(src))))) } if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(src))) == int32('-') { *(*int32)(unsafe.Pointer(bp))++ if *(*int32)(unsafe.Pointer(bp)) == int32(XLFD_NUMFIELDS) { goto _1 } *(*uint8)(unsafe.Pointer(src)) = uint8('\000') (*(*[15]uintptr)(unsafe.Pointer(bp + 8)))[*(*int32)(unsafe.Pointer(bp))] = src + uintptr(1) if *(*int32)(unsafe.Pointer(bp)) > int32(XLFD_NUMFIELDS) { break } } goto _1 _1: ; src++ } /* * An XLFD of the form -adobe-times-medium-r-*-12-*-* is pretty common, * but it is (strictly) malformed, because the first * is eliding both the * Setwidth and the Addstyle fields. If the Addstyle field is a number, * then assume the above incorrect form was used and shift all the rest of * the fields right by one, so the number gets interpreted as a pixelsize. * This fix is so that we don't get a million reports that "it works under * X (as a native font name), but gives a syntax error under Windows (as a * parsed set of attributes)". */ if *(*int32)(unsafe.Pointer(bp)) > int32(XLFD_ADD_STYLE) && _FieldSpecified(tls, (*(*[15]uintptr)(unsafe.Pointer(bp + 8)))[int32(XLFD_ADD_STYLE)]) != 0 { if libc.Xatoi(tls, (*(*[15]uintptr)(unsafe.Pointer(bp + 8)))[int32(XLFD_ADD_STYLE)]) != 0 { j = libc.Int32FromInt32(XLFD_NUMFIELDS) - libc.Int32FromInt32(1) for { if !(j >= int32(XLFD_ADD_STYLE)) { break } (*(*[15]uintptr)(unsafe.Pointer(bp + 8)))[j+int32(1)] = (*(*[15]uintptr)(unsafe.Pointer(bp + 8)))[j] goto _2 _2: ; j-- } (*(*[15]uintptr)(unsafe.Pointer(bp + 8)))[int32(XLFD_ADD_STYLE)] = libc.UintptrFromInt32(0) *(*int32)(unsafe.Pointer(bp))++ } } /* * Bail if we don't have enough of the fields (up to pointsize). */ if *(*int32)(unsafe.Pointer(bp)) < int32(XLFD_FAMILY) { libtcl9_0.XTcl_DStringFree(tls, bp+128) return int32(TCL_ERROR) } if _FieldSpecified(tls, (*(*[15]uintptr)(unsafe.Pointer(bp + 8)))[XLFD_FOUNDRY]) != 0 { (*TTkXLFDAttributes)(unsafe.Pointer(xaPtr)).Ffoundry = XTk_GetUid(tls, (*(*[15]uintptr)(unsafe.Pointer(bp + 8)))[XLFD_FOUNDRY]) } if _FieldSpecified(tls, (*(*[15]uintptr)(unsafe.Pointer(bp + 8)))[int32(XLFD_FAMILY)]) != 0 { (*TTkFontAttributes)(unsafe.Pointer(faPtr)).Ffamily = XTk_GetUid(tls, (*(*[15]uintptr)(unsafe.Pointer(bp + 8)))[int32(XLFD_FAMILY)]) } if _FieldSpecified(tls, (*(*[15]uintptr)(unsafe.Pointer(bp + 8)))[int32(XLFD_WEIGHT)]) != 0 { (*TTkFontAttributes)(unsafe.Pointer(faPtr)).Fweight = XTkFindStateNum(tls, libc.UintptrFromInt32(0), libc.UintptrFromInt32(0), uintptr(unsafe.Pointer(&_xlfdWeightMap)), (*(*[15]uintptr)(unsafe.Pointer(bp + 8)))[int32(XLFD_WEIGHT)]) } if _FieldSpecified(tls, (*(*[15]uintptr)(unsafe.Pointer(bp + 8)))[int32(XLFD_SLANT)]) != 0 { (*TTkXLFDAttributes)(unsafe.Pointer(xaPtr)).Fslant = XTkFindStateNum(tls, libc.UintptrFromInt32(0), libc.UintptrFromInt32(0), uintptr(unsafe.Pointer(&_xlfdSlantMap)), (*(*[15]uintptr)(unsafe.Pointer(bp + 8)))[int32(XLFD_SLANT)]) if (*TTkXLFDAttributes)(unsafe.Pointer(xaPtr)).Fslant == TK_FS_ROMAN { (*TTkFontAttributes)(unsafe.Pointer(faPtr)).Fslant = TK_FS_ROMAN } else { (*TTkFontAttributes)(unsafe.Pointer(faPtr)).Fslant = int32(TK_FS_ITALIC) } } if _FieldSpecified(tls, (*(*[15]uintptr)(unsafe.Pointer(bp + 8)))[int32(XLFD_SETWIDTH)]) != 0 { (*TTkXLFDAttributes)(unsafe.Pointer(xaPtr)).Fsetwidth = XTkFindStateNum(tls, libc.UintptrFromInt32(0), libc.UintptrFromInt32(0), uintptr(unsafe.Pointer(&_xlfdSetwidthMap)), (*(*[15]uintptr)(unsafe.Pointer(bp + 8)))[int32(XLFD_SETWIDTH)]) } /* XLFD_ADD_STYLE ignored. */ /* * Pointsize in tenths of a point, but treat it as tenths of a pixel for * historical compatibility. */ (*TTkFontAttributes)(unsafe.Pointer(faPtr)).Fsize = float64(12) if _FieldSpecified(tls, (*(*[15]uintptr)(unsafe.Pointer(bp + 8)))[int32(XLFD_POINT_SIZE)]) != 0 { if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer((*(*[15]uintptr)(unsafe.Pointer(bp + 8)))[int32(XLFD_POINT_SIZE)]))) == int32('[') { /* * Some X fonts have the point size specified as follows: * * [ N1 N2 N3 N4 ] * * where N1 is the point size (in points, not decipoints!), and * N2, N3, and N4 are some additional numbers that I don't know * the purpose of, so I ignore them. */ (*TTkFontAttributes)(unsafe.Pointer(faPtr)).Fsize = libc.Xatof(tls, (*(*[15]uintptr)(unsafe.Pointer(bp + 8)))[int32(XLFD_POINT_SIZE)]+uintptr(1)) } else { if libtcl9_0.XTcl_GetInt(tls, libc.UintptrFromInt32(0), (*(*[15]uintptr)(unsafe.Pointer(bp + 8)))[int32(XLFD_POINT_SIZE)], bp) == TCL_OK { (*TTkFontAttributes)(unsafe.Pointer(faPtr)).Fsize = float64(*(*int32)(unsafe.Pointer(bp))) / float64(10) } else { return int32(TCL_ERROR) } } } /* * Pixel height of font. If specified, overrides pointsize. */ if _FieldSpecified(tls, (*(*[15]uintptr)(unsafe.Pointer(bp + 8)))[int32(XLFD_PIXEL_SIZE)]) != 0 { if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer((*(*[15]uintptr)(unsafe.Pointer(bp + 8)))[int32(XLFD_PIXEL_SIZE)]))) == int32('[') { /* * Some X fonts have the pixel size specified as follows: * * [ N1 N2 N3 N4 ] * * where N1 is the pixel size, and where N2, N3, and N4 are some * additional numbers that I don't know the purpose of, so I * ignore them. */ (*TTkFontAttributes)(unsafe.Pointer(faPtr)).Fsize = libc.Xatof(tls, (*(*[15]uintptr)(unsafe.Pointer(bp + 8)))[int32(XLFD_PIXEL_SIZE)]+uintptr(1)) } else { if libtcl9_0.XTcl_GetInt(tls, libc.UintptrFromInt32(0), (*(*[15]uintptr)(unsafe.Pointer(bp + 8)))[int32(XLFD_PIXEL_SIZE)], bp) == TCL_OK { (*TTkFontAttributes)(unsafe.Pointer(faPtr)).Fsize = float64(*(*int32)(unsafe.Pointer(bp))) } else { return int32(TCL_ERROR) } } } (*TTkFontAttributes)(unsafe.Pointer(faPtr)).Fsize = -(*TTkFontAttributes)(unsafe.Pointer(faPtr)).Fsize /* XLFD_RESOLUTION_X ignored. */ /* XLFD_RESOLUTION_Y ignored. */ /* XLFD_SPACING ignored. */ /* XLFD_AVERAGE_WIDTH ignored. */ if _FieldSpecified(tls, (*(*[15]uintptr)(unsafe.Pointer(bp + 8)))[int32(XLFD_CHARSET)]) != 0 { (*TTkXLFDAttributes)(unsafe.Pointer(xaPtr)).Fcharset = XTk_GetUid(tls, (*(*[15]uintptr)(unsafe.Pointer(bp + 8)))[int32(XLFD_CHARSET)]) } else { (*TTkXLFDAttributes)(unsafe.Pointer(xaPtr)).Fcharset = XTk_GetUid(tls, __ccgo_ts+10888) } libtcl9_0.XTcl_DStringFree(tls, bp+128) return TCL_OK } /* *--------------------------------------------------------------------------- * * FieldSpecified -- * * Helper function for TkParseXLFD(). Determines if a field in the XLFD * was set to a non-null, non-don't-care value. * * Results: * The return value is 0 if the field in the XLFD was not set and should * be ignored, non-zero otherwise. * * Side effects: * None. * *--------------------------------------------------------------------------- */ func _FieldSpecified(tls *libc.TLS, field uintptr) (r int32) { /* The field of the XLFD to check. Strictly * speaking, only when the string is "*" does * it mean don't-care. However, an unspecified * or question mark is also interpreted as * don't-care. */ var ch uint8 _ = ch if field == libc.UintptrFromInt32(0) { return 0 } ch = *(*uint8)(unsafe.Pointer(field)) return libc.BoolInt32(libc.Int32FromUint8(ch) != int32('*') && libc.Int32FromUint8(ch) != int32('?')) } /* *--------------------------------------------------------------------------- * * TkFontGetPixels -- * * Given a font size specification (as described in the TkFontAttributes * structure) return the number of pixels it represents. * * Results: * As above. * * Side effects: * None. * *--------------------------------------------------------------------------- */ func XTkFontGetPixels(tls *libc.TLS, tkwin TTk_Window, size float64) (r float64) { /* Font size. */ var d float64 _ = d if size <= float64(0) { return -size } d = float64(size*float64(25.4)) / float64(72) d *= float64((*TScreen)(unsafe.Pointer((*struct { Fext_data uintptr Fprivate1 uintptr Ffd int32 Fprivate2 int32 Fproto_major_version int32 Fproto_minor_version int32 Fvendor uintptr Fprivate3 TXID Fprivate4 TXID Fprivate5 TXID Fprivate6 int32 Fresource_alloc uintptr Fbyte_order int32 Fbitmap_unit int32 Fbitmap_pad int32 Fbitmap_bit_order int32 Fnformats int32 Fpixmap_format uintptr Fprivate8 int32 Frelease int32 Fprivate9 uintptr Fprivate10 uintptr Fqlen int32 Flast_request_read uint64 Frequest uint64 Fprivate11 TXPointer Fprivate12 TXPointer Fprivate13 TXPointer Fprivate14 TXPointer Fmax_request_size uint32 Fdb uintptr Fprivate15 uintptr Fdisplay_name uintptr Fdefault_screen int32 Fnscreens int32 Fscreens uintptr Fmotion_buffer uint64 Fprivate16 uint64 Fmin_keycode int32 Fmax_keycode int32 Fprivate17 TXPointer Fprivate18 TXPointer Fprivate19 int32 Fxdefaults uintptr })(unsafe.Pointer((*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fdisplay)).Fscreens + uintptr((*TTk_FakeWin)(unsafe.Pointer(tkwin)).FscreenNum)*128)).Fwidth) d /= float64((*TScreen)(unsafe.Pointer((*struct { Fext_data uintptr Fprivate1 uintptr Ffd int32 Fprivate2 int32 Fproto_major_version int32 Fproto_minor_version int32 Fvendor uintptr Fprivate3 TXID Fprivate4 TXID Fprivate5 TXID Fprivate6 int32 Fresource_alloc uintptr Fbyte_order int32 Fbitmap_unit int32 Fbitmap_pad int32 Fbitmap_bit_order int32 Fnformats int32 Fpixmap_format uintptr Fprivate8 int32 Frelease int32 Fprivate9 uintptr Fprivate10 uintptr Fqlen int32 Flast_request_read uint64 Frequest uint64 Fprivate11 TXPointer Fprivate12 TXPointer Fprivate13 TXPointer Fprivate14 TXPointer Fmax_request_size uint32 Fdb uintptr Fprivate15 uintptr Fdisplay_name uintptr Fdefault_screen int32 Fnscreens int32 Fscreens uintptr Fmotion_buffer uint64 Fprivate16 uint64 Fmin_keycode int32 Fmax_keycode int32 Fprivate17 TXPointer Fprivate18 TXPointer Fprivate19 int32 Fxdefaults uintptr })(unsafe.Pointer((*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fdisplay)).Fscreens + uintptr((*TTk_FakeWin)(unsafe.Pointer(tkwin)).FscreenNum)*128)).Fmwidth) return d } /* *--------------------------------------------------------------------------- * * TkFontGetPoints -- * * Given a font size specification (as described in the TkFontAttributes * structure) return the number of points it represents. * * Results: * As above. * * Side effects: * None. * *--------------------------------------------------------------------------- */ func XTkFontGetPoints(tls *libc.TLS, tkwin TTk_Window, size float64) (r float64) { /* Font size. */ var d float64 _ = d if size >= float64(0) { return size } d = float64(-size*float64(72)) / float64(25.4) d *= float64((*TScreen)(unsafe.Pointer((*struct { Fext_data uintptr Fprivate1 uintptr Ffd int32 Fprivate2 int32 Fproto_major_version int32 Fproto_minor_version int32 Fvendor uintptr Fprivate3 TXID Fprivate4 TXID Fprivate5 TXID Fprivate6 int32 Fresource_alloc uintptr Fbyte_order int32 Fbitmap_unit int32 Fbitmap_pad int32 Fbitmap_bit_order int32 Fnformats int32 Fpixmap_format uintptr Fprivate8 int32 Frelease int32 Fprivate9 uintptr Fprivate10 uintptr Fqlen int32 Flast_request_read uint64 Frequest uint64 Fprivate11 TXPointer Fprivate12 TXPointer Fprivate13 TXPointer Fprivate14 TXPointer Fmax_request_size uint32 Fdb uintptr Fprivate15 uintptr Fdisplay_name uintptr Fdefault_screen int32 Fnscreens int32 Fscreens uintptr Fmotion_buffer uint64 Fprivate16 uint64 Fmin_keycode int32 Fmax_keycode int32 Fprivate17 TXPointer Fprivate18 TXPointer Fprivate19 int32 Fxdefaults uintptr })(unsafe.Pointer((*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fdisplay)).Fscreens + uintptr((*TTk_FakeWin)(unsafe.Pointer(tkwin)).FscreenNum)*128)).Fmwidth) d /= float64((*TScreen)(unsafe.Pointer((*struct { Fext_data uintptr Fprivate1 uintptr Ffd int32 Fprivate2 int32 Fproto_major_version int32 Fproto_minor_version int32 Fvendor uintptr Fprivate3 TXID Fprivate4 TXID Fprivate5 TXID Fprivate6 int32 Fresource_alloc uintptr Fbyte_order int32 Fbitmap_unit int32 Fbitmap_pad int32 Fbitmap_bit_order int32 Fnformats int32 Fpixmap_format uintptr Fprivate8 int32 Frelease int32 Fprivate9 uintptr Fprivate10 uintptr Fqlen int32 Flast_request_read uint64 Frequest uint64 Fprivate11 TXPointer Fprivate12 TXPointer Fprivate13 TXPointer Fprivate14 TXPointer Fmax_request_size uint32 Fdb uintptr Fprivate15 uintptr Fdisplay_name uintptr Fdefault_screen int32 Fnscreens int32 Fscreens uintptr Fmotion_buffer uint64 Fprivate16 uint64 Fmin_keycode int32 Fmax_keycode int32 Fprivate17 TXPointer Fprivate18 TXPointer Fprivate19 int32 Fxdefaults uintptr })(unsafe.Pointer((*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fdisplay)).Fscreens + uintptr((*TTk_FakeWin)(unsafe.Pointer(tkwin)).FscreenNum)*128)).Fwidth) return d } /* *------------------------------------------------------------------------- * * TkFontGetAliasList -- * * Given a font name, find the list of all aliases for that font name. * One of the names in this list will probably be the name that this * platform expects when asking for the font. * * Results: * As above. The return value is NULL if the font name has no aliases. * * Side effects: * None. * *------------------------------------------------------------------------- */ func XTkFontGetAliasList(tls *libc.TLS, faceName uintptr) (r uintptr) { /* Font name to test for aliases. */ var i, j int32 _, _ = i, j i = 0 for { if !(_fontAliases[i] != libc.UintptrFromInt32(0)) { break } j = 0 for { if !(*(*uintptr)(unsafe.Pointer(_fontAliases[i] + uintptr(j)*8)) != libc.UintptrFromInt32(0)) { break } if libc.Xstrcasecmp(tls, faceName, *(*uintptr)(unsafe.Pointer(_fontAliases[i] + uintptr(j)*8))) == 0 { return _fontAliases[i] } goto _2 _2: ; j++ } goto _1 _1: ; i++ } return libc.UintptrFromInt32(0) } /* *------------------------------------------------------------------------- * * TkFontGetFallbacks -- * * Get the list of font fallbacks that the platform-specific code can use * to try to find the closest matching font the name requested. * * Results: * As above. * * Side effects: * None. * *------------------------------------------------------------------------- */ func XTkFontGetFallbacks(tls *libc.TLS) (r uintptr) { return uintptr(unsafe.Pointer(&_fontFallbacks)) } /* *------------------------------------------------------------------------- * * TkFontGetGlobalClass -- * * Get the list of fonts to try if the requested font name does not * exist and no fallbacks for that font name could be used either. * The names in this list are considered preferred over all the other * font names in the system when looking for a last-ditch fallback. * * Results: * As above. * * Side effects: * None. * *------------------------------------------------------------------------- */ func XTkFontGetGlobalClass(tls *libc.TLS) (r uintptr) { return uintptr(unsafe.Pointer(&_globalFontClass)) } /* *------------------------------------------------------------------------- * * TkFontGetSymbolClass -- * * Get the list of fonts that are symbolic; used if the operating system * cannot apriori identify symbolic fonts on its own. * * Results: * As above. * * Side effects: * None. * *------------------------------------------------------------------------- */ func XTkFontGetSymbolClass(tls *libc.TLS) (r uintptr) { return uintptr(unsafe.Pointer(&_symbolClass)) } /* *---------------------------------------------------------------------- * * TkDebugFont -- * * This function returns debugging information about a font. * * Results: * The return value is a list with one sublist for each TkFont * corresponding to "name". Each sublist has two elements that contain * the resourceRefCount and objRefCount fields from the TkFont structure. * * Side effects: * None. * *---------------------------------------------------------------------- */ func XTkDebugFont(tls *libc.TLS, tkwin TTk_Window, name uintptr) (r uintptr) { /* Name of the desired font. */ var fontPtr, hashPtr, objPtr, resultPtr uintptr _, _, _, _ = fontPtr, hashPtr, objPtr, resultPtr resultPtr = libtcl9_0.XTcl_NewObj(tls) hashPtr = (*(*func(*libc.TLS, uintptr, uintptr) uintptr)(unsafe.Pointer(&struct{ uintptr }{(*TTcl_HashTable)(unsafe.Pointer((*TTkMainInfo)(unsafe.Pointer((*TTkWindow)(unsafe.Pointer(tkwin)).FmainPtr)).FfontInfoPtr)).FfindProc})))(tls, (*TTkMainInfo)(unsafe.Pointer((*TTkWindow)(unsafe.Pointer(tkwin)).FmainPtr)).FfontInfoPtr, name) if hashPtr != libc.UintptrFromInt32(0) { fontPtr = (*TTcl_HashEntry)(unsafe.Pointer(hashPtr)).FclientData if fontPtr == libc.UintptrFromInt32(0) { libtcl9_0.XTcl_Panic(tls, __ccgo_ts+10898, 0) } for { if !(fontPtr != libc.UintptrFromInt32(0)) { break } objPtr = libtcl9_0.XTcl_NewObj(tls) libtcl9_0.XTcl_ListObjAppendElement(tls, libc.UintptrFromInt32(0), objPtr, libtcl9_0.XTcl_NewWideIntObj(tls, (*TTkFont)(unsafe.Pointer(fontPtr)).FresourceRefCount)) libtcl9_0.XTcl_ListObjAppendElement(tls, libc.UintptrFromInt32(0), objPtr, libtcl9_0.XTcl_NewWideIntObj(tls, (*TTkFont)(unsafe.Pointer(fontPtr)).FobjRefCount)) libtcl9_0.XTcl_ListObjAppendElement(tls, libc.UintptrFromInt32(0), resultPtr, objPtr) goto _1 _1: ; fontPtr = (*TTkFont)(unsafe.Pointer(fontPtr)).FnextPtr } } return resultPtr } /* *---------------------------------------------------------------------- * * TkFontGetFirstTextLayout -- * * This function returns the first chunk of a Tk_TextLayout, i.e. until * the first font change on the first line (or the whole first line if * there is no such font change). * * Results: * The return value is the byte length of the chunk, the chunk itself is * copied into dst and its Tk_Font into font. * * Side effects: * None. * *---------------------------------------------------------------------- */ func XTkFontGetFirstTextLayout(tls *libc.TLS, layout TTk_TextLayout, font uintptr, dst uintptr) (r int32) { var chunkPtr, layoutPtr uintptr var numBytesInChunk TTcl_Size _, _, _ = chunkPtr, layoutPtr, numBytesInChunk layoutPtr = layout if layoutPtr == libc.UintptrFromInt32(0) || (*TTextLayout)(unsafe.Pointer(layoutPtr)).FnumChunks == 0 || (*TLayoutChunk)(unsafe.Pointer(layoutPtr+32)).FnumDisplayChars <= 0 { *(*uint8)(unsafe.Pointer(dst)) = uint8('\000') return 0 } chunkPtr = layoutPtr + 32 numBytesInChunk = (*TLayoutChunk)(unsafe.Pointer(chunkPtr)).FnumBytes libc.Xstrncpy(tls, dst, (*TLayoutChunk)(unsafe.Pointer(chunkPtr)).Fstart, libc.Uint64FromInt64(numBytesInChunk)) *(*TTk_Font)(unsafe.Pointer(font)) = (*TTextLayout)(unsafe.Pointer(layoutPtr)).Ftkfont return int32(numBytesInChunk) } const M_PI2 = 0 /* * Local Variables: * mode: c * c-basic-offset: 4 * fill-column: 78 * End: */ /* * One of these structures is created per thread to store thread-specific * data. In this case, it is used to house the Tk_Uid structs used by each * thread. The "dataKey" below is used to locate the ThreadSpecificData for * the current thread. */ type TThreadSpecificData4 = struct { Finitialized int32 FuidTable TTcl_HashTable } var _dataKey4 TTcl_ThreadDataKey /* *---------------------------------------------------------------------- * * Tk_GetAnchorFromObj -- * * Return a Tk_Anchor value based on the value of the objPtr. * * Results: * The return value is a standard Tcl result. If an error occurs during * conversion, an error message is left in the interpreter's result * unless "interp" is NULL. * * Side effects: * The object gets converted by Tcl_GetIndexFromObj. * *---------------------------------------------------------------------- */ func XTk_GetAnchorFromObj(tls *libc.TLS, interp uintptr, objPtr uintptr, anchorPtr uintptr) (r int32) { bp := tls.Alloc(16) defer tls.Free(16) /* Where to place the Tk_Anchor that * corresponds to the string value of * objPtr. */ var code int32 var _ /* index at bp+0 */ int32 _ = code code = libtcl9_0.XTcl_GetIndexFromObjStruct(tls, interp, objPtr, uintptr(unsafe.Pointer(&XtkAnchorStrings)), libc.Int64FromUint64(libc.Uint64FromInt64(8)), __ccgo_ts+7881, libc.Int32FromInt32(0)|libc.Int32FromUint64(libc.Uint64FromInt64(4)< string1; v4 { v1 = libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(rest + uintptr(-libc.Int32FromInt32(1))))) v2 = libc.BoolInt32(v1 == int32(' ') || libc.Uint32FromInt32(v1)-uint32('\t') < uint32(5)) goto _3 _3: } if !(v4 && v2 != 0) { break } rest-- /* skip all spaces at the end */ } if rest > string1 { rest-- /* point to the character just before the last space */ } if !(rest == string1) { goto _5 } goto error error: ; if interp != libc.UintptrFromInt32(0) { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+7888, libc.VaList(bp+240, string1))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+240, __ccgo_ts+179, __ccgo_ts+182, __ccgo_ts+7935, libc.UintptrFromInt32(0))) } return int32(TCL_ERROR) _5: ; libtcl9_0.XTcl_DStringInit(tls, bp+8) libtcl9_0.XTcl_DStringAppend(tls, bp+8, string1, int64(rest)-int64(string1)) if libtcl9_0.XTcl_GetDouble(tls, libc.UintptrFromInt32(0), (*TTcl_DString)(unsafe.Pointer(bp+8)).Fstring1, bp) != TCL_OK { libtcl9_0.XTcl_DStringFree(tls, bp+8) goto error } libtcl9_0.XTcl_DStringFree(tls, bp+8) switch libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(rest))) { case int32('c'): *(*float64)(unsafe.Pointer(bp)) *= libc.Float64FromInt32(10) case int32('i'): *(*float64)(unsafe.Pointer(bp)) *= float64(25.4) case int32('m'): case int32('p'): *(*float64)(unsafe.Pointer(bp)) *= libc.Float64FromFloat64(25.4) / libc.Float64FromFloat64(72) default: goto error } *(*float64)(unsafe.Pointer(doublePtr)) = *(*float64)(unsafe.Pointer(bp)) return TCL_OK } /* *-------------------------------------------------------------- * * Tk_GetPixels -- * * Given a string, returns the number of pixels corresponding to that * string. * * Results: * The return value is a standard Tcl return result. If TCL_OK is * returned, then everything went well and the rounded pixel distance is * stored at *intPtr; otherwise TCL_ERROR is returned and an error * message is left in the interp's result. * * Side effects: * None. * *-------------------------------------------------------------- */ func XTk_GetPixels(tls *libc.TLS, interp uintptr, tkwin TTk_Window, string1 uintptr, intPtr uintptr) (r int32) { bp := tls.Alloc(16) defer tls.Free(16) /* Place to store converted result. */ var _ /* d at bp+0 */ float64 if XTkGetDoublePixels(tls, interp, tkwin, string1, bp) != TCL_OK { return int32(TCL_ERROR) } if *(*float64)(unsafe.Pointer(bp)) < libc.Float64FromInt32(0) { *(*int32)(unsafe.Pointer(intPtr)) = int32(*(*float64)(unsafe.Pointer(bp)) - libc.Float64FromFloat64(0.5)) } else { *(*int32)(unsafe.Pointer(intPtr)) = int32(*(*float64)(unsafe.Pointer(bp)) + libc.Float64FromFloat64(0.5)) } return TCL_OK } /* *-------------------------------------------------------------- * * TkGetDoublePixels -- * * Given a string, returns the number of pixels corresponding to that * string. * * Results: * The return value is a standard Tcl return result. If TCL_OK is * returned, then everything went well and the pixel distance is stored * at *doublePtr; otherwise TCL_ERROR is returned and an error message is * left in interp->result. * * Side effects: * None. * *-------------------------------------------------------------- */ func XTkGetDoublePixels(tls *libc.TLS, interp uintptr, tkwin TTk_Window, string1 uintptr, doublePtr uintptr) (r int32) { bp := tls.Alloc(272) defer tls.Free(272) /* Place to store converted result. */ var rest uintptr var v1, v2 int32 var v4 bool var _ /* d at bp+0 */ float64 var _ /* ds at bp+8 */ TTcl_DString _, _, _, _ = rest, v1, v2, v4 if libtcl9_0.XTcl_GetDouble(tls, libc.UintptrFromInt32(0), string1, bp) == TCL_OK { *(*float64)(unsafe.Pointer(doublePtr)) = *(*float64)(unsafe.Pointer(bp)) return TCL_OK } if !(tkwin != 0) { if interp != libc.UintptrFromInt32(0) { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+11349, int64(-int32(1)))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+240, __ccgo_ts+179, __ccgo_ts+182, __ccgo_ts+11376, libc.UintptrFromInt32(0))) } return int32(TCL_ERROR) } rest = string1 + uintptr(libc.Xstrlen(tls, string1)) for { if v4 = rest > string1; v4 { v1 = libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(rest + uintptr(-libc.Int32FromInt32(1))))) v2 = libc.BoolInt32(v1 == int32(' ') || libc.Uint32FromInt32(v1)-uint32('\t') < uint32(5)) goto _3 _3: } if !(v4 && v2 != 0) { break } rest-- /* skip all spaces at the end */ } if rest > string1 { rest-- /* point to the character just before the last space */ } if !(rest == string1) { goto _5 } goto error error: ; if interp != libc.UintptrFromInt32(0) { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+11394, libc.VaList(bp+240, string1))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+240, __ccgo_ts+179, __ccgo_ts+182, __ccgo_ts+7935, libc.UintptrFromInt32(0))) } return int32(TCL_ERROR) _5: ; libtcl9_0.XTcl_DStringInit(tls, bp+8) libtcl9_0.XTcl_DStringAppend(tls, bp+8, string1, int64(rest)-int64(string1)) if libtcl9_0.XTcl_GetDouble(tls, libc.UintptrFromInt32(0), (*TTcl_DString)(unsafe.Pointer(bp+8)).Fstring1, bp) != TCL_OK { libtcl9_0.XTcl_DStringFree(tls, bp+8) goto error } libtcl9_0.XTcl_DStringFree(tls, bp+8) switch libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(rest))) { case int32('c'): *(*float64)(unsafe.Pointer(bp)) *= float64(int32(10) * (*TScreen)(unsafe.Pointer((*struct { Fext_data uintptr Fprivate1 uintptr Ffd int32 Fprivate2 int32 Fproto_major_version int32 Fproto_minor_version int32 Fvendor uintptr Fprivate3 TXID Fprivate4 TXID Fprivate5 TXID Fprivate6 int32 Fresource_alloc uintptr Fbyte_order int32 Fbitmap_unit int32 Fbitmap_pad int32 Fbitmap_bit_order int32 Fnformats int32 Fpixmap_format uintptr Fprivate8 int32 Frelease int32 Fprivate9 uintptr Fprivate10 uintptr Fqlen int32 Flast_request_read uint64 Frequest uint64 Fprivate11 TXPointer Fprivate12 TXPointer Fprivate13 TXPointer Fprivate14 TXPointer Fmax_request_size uint32 Fdb uintptr Fprivate15 uintptr Fdisplay_name uintptr Fdefault_screen int32 Fnscreens int32 Fscreens uintptr Fmotion_buffer uint64 Fprivate16 uint64 Fmin_keycode int32 Fmax_keycode int32 Fprivate17 TXPointer Fprivate18 TXPointer Fprivate19 int32 Fxdefaults uintptr })(unsafe.Pointer((*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fdisplay)).Fscreens+uintptr((*TTk_FakeWin)(unsafe.Pointer(tkwin)).FscreenNum)*128)).Fwidth) *(*float64)(unsafe.Pointer(bp)) /= float64((*TScreen)(unsafe.Pointer((*struct { Fext_data uintptr Fprivate1 uintptr Ffd int32 Fprivate2 int32 Fproto_major_version int32 Fproto_minor_version int32 Fvendor uintptr Fprivate3 TXID Fprivate4 TXID Fprivate5 TXID Fprivate6 int32 Fresource_alloc uintptr Fbyte_order int32 Fbitmap_unit int32 Fbitmap_pad int32 Fbitmap_bit_order int32 Fnformats int32 Fpixmap_format uintptr Fprivate8 int32 Frelease int32 Fprivate9 uintptr Fprivate10 uintptr Fqlen int32 Flast_request_read uint64 Frequest uint64 Fprivate11 TXPointer Fprivate12 TXPointer Fprivate13 TXPointer Fprivate14 TXPointer Fmax_request_size uint32 Fdb uintptr Fprivate15 uintptr Fdisplay_name uintptr Fdefault_screen int32 Fnscreens int32 Fscreens uintptr Fmotion_buffer uint64 Fprivate16 uint64 Fmin_keycode int32 Fmax_keycode int32 Fprivate17 TXPointer Fprivate18 TXPointer Fprivate19 int32 Fxdefaults uintptr })(unsafe.Pointer((*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fdisplay)).Fscreens + uintptr((*TTk_FakeWin)(unsafe.Pointer(tkwin)).FscreenNum)*128)).Fmwidth) case int32('i'): *(*float64)(unsafe.Pointer(bp)) *= float64(float64(25.4) * float64((*TScreen)(unsafe.Pointer((*struct { Fext_data uintptr Fprivate1 uintptr Ffd int32 Fprivate2 int32 Fproto_major_version int32 Fproto_minor_version int32 Fvendor uintptr Fprivate3 TXID Fprivate4 TXID Fprivate5 TXID Fprivate6 int32 Fresource_alloc uintptr Fbyte_order int32 Fbitmap_unit int32 Fbitmap_pad int32 Fbitmap_bit_order int32 Fnformats int32 Fpixmap_format uintptr Fprivate8 int32 Frelease int32 Fprivate9 uintptr Fprivate10 uintptr Fqlen int32 Flast_request_read uint64 Frequest uint64 Fprivate11 TXPointer Fprivate12 TXPointer Fprivate13 TXPointer Fprivate14 TXPointer Fmax_request_size uint32 Fdb uintptr Fprivate15 uintptr Fdisplay_name uintptr Fdefault_screen int32 Fnscreens int32 Fscreens uintptr Fmotion_buffer uint64 Fprivate16 uint64 Fmin_keycode int32 Fmax_keycode int32 Fprivate17 TXPointer Fprivate18 TXPointer Fprivate19 int32 Fxdefaults uintptr })(unsafe.Pointer((*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fdisplay)).Fscreens+uintptr((*TTk_FakeWin)(unsafe.Pointer(tkwin)).FscreenNum)*128)).Fwidth)) *(*float64)(unsafe.Pointer(bp)) /= float64((*TScreen)(unsafe.Pointer((*struct { Fext_data uintptr Fprivate1 uintptr Ffd int32 Fprivate2 int32 Fproto_major_version int32 Fproto_minor_version int32 Fvendor uintptr Fprivate3 TXID Fprivate4 TXID Fprivate5 TXID Fprivate6 int32 Fresource_alloc uintptr Fbyte_order int32 Fbitmap_unit int32 Fbitmap_pad int32 Fbitmap_bit_order int32 Fnformats int32 Fpixmap_format uintptr Fprivate8 int32 Frelease int32 Fprivate9 uintptr Fprivate10 uintptr Fqlen int32 Flast_request_read uint64 Frequest uint64 Fprivate11 TXPointer Fprivate12 TXPointer Fprivate13 TXPointer Fprivate14 TXPointer Fmax_request_size uint32 Fdb uintptr Fprivate15 uintptr Fdisplay_name uintptr Fdefault_screen int32 Fnscreens int32 Fscreens uintptr Fmotion_buffer uint64 Fprivate16 uint64 Fmin_keycode int32 Fmax_keycode int32 Fprivate17 TXPointer Fprivate18 TXPointer Fprivate19 int32 Fxdefaults uintptr })(unsafe.Pointer((*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fdisplay)).Fscreens + uintptr((*TTk_FakeWin)(unsafe.Pointer(tkwin)).FscreenNum)*128)).Fmwidth) case int32('m'): *(*float64)(unsafe.Pointer(bp)) *= float64((*TScreen)(unsafe.Pointer((*struct { Fext_data uintptr Fprivate1 uintptr Ffd int32 Fprivate2 int32 Fproto_major_version int32 Fproto_minor_version int32 Fvendor uintptr Fprivate3 TXID Fprivate4 TXID Fprivate5 TXID Fprivate6 int32 Fresource_alloc uintptr Fbyte_order int32 Fbitmap_unit int32 Fbitmap_pad int32 Fbitmap_bit_order int32 Fnformats int32 Fpixmap_format uintptr Fprivate8 int32 Frelease int32 Fprivate9 uintptr Fprivate10 uintptr Fqlen int32 Flast_request_read uint64 Frequest uint64 Fprivate11 TXPointer Fprivate12 TXPointer Fprivate13 TXPointer Fprivate14 TXPointer Fmax_request_size uint32 Fdb uintptr Fprivate15 uintptr Fdisplay_name uintptr Fdefault_screen int32 Fnscreens int32 Fscreens uintptr Fmotion_buffer uint64 Fprivate16 uint64 Fmin_keycode int32 Fmax_keycode int32 Fprivate17 TXPointer Fprivate18 TXPointer Fprivate19 int32 Fxdefaults uintptr })(unsafe.Pointer((*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fdisplay)).Fscreens + uintptr((*TTk_FakeWin)(unsafe.Pointer(tkwin)).FscreenNum)*128)).Fwidth) *(*float64)(unsafe.Pointer(bp)) /= float64((*TScreen)(unsafe.Pointer((*struct { Fext_data uintptr Fprivate1 uintptr Ffd int32 Fprivate2 int32 Fproto_major_version int32 Fproto_minor_version int32 Fvendor uintptr Fprivate3 TXID Fprivate4 TXID Fprivate5 TXID Fprivate6 int32 Fresource_alloc uintptr Fbyte_order int32 Fbitmap_unit int32 Fbitmap_pad int32 Fbitmap_bit_order int32 Fnformats int32 Fpixmap_format uintptr Fprivate8 int32 Frelease int32 Fprivate9 uintptr Fprivate10 uintptr Fqlen int32 Flast_request_read uint64 Frequest uint64 Fprivate11 TXPointer Fprivate12 TXPointer Fprivate13 TXPointer Fprivate14 TXPointer Fmax_request_size uint32 Fdb uintptr Fprivate15 uintptr Fdisplay_name uintptr Fdefault_screen int32 Fnscreens int32 Fscreens uintptr Fmotion_buffer uint64 Fprivate16 uint64 Fmin_keycode int32 Fmax_keycode int32 Fprivate17 TXPointer Fprivate18 TXPointer Fprivate19 int32 Fxdefaults uintptr })(unsafe.Pointer((*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fdisplay)).Fscreens + uintptr((*TTk_FakeWin)(unsafe.Pointer(tkwin)).FscreenNum)*128)).Fmwidth) case int32('p'): *(*float64)(unsafe.Pointer(bp)) *= float64(libc.Float64FromFloat64(25.4) / libc.Float64FromFloat64(72) * float64((*TScreen)(unsafe.Pointer((*struct { Fext_data uintptr Fprivate1 uintptr Ffd int32 Fprivate2 int32 Fproto_major_version int32 Fproto_minor_version int32 Fvendor uintptr Fprivate3 TXID Fprivate4 TXID Fprivate5 TXID Fprivate6 int32 Fresource_alloc uintptr Fbyte_order int32 Fbitmap_unit int32 Fbitmap_pad int32 Fbitmap_bit_order int32 Fnformats int32 Fpixmap_format uintptr Fprivate8 int32 Frelease int32 Fprivate9 uintptr Fprivate10 uintptr Fqlen int32 Flast_request_read uint64 Frequest uint64 Fprivate11 TXPointer Fprivate12 TXPointer Fprivate13 TXPointer Fprivate14 TXPointer Fmax_request_size uint32 Fdb uintptr Fprivate15 uintptr Fdisplay_name uintptr Fdefault_screen int32 Fnscreens int32 Fscreens uintptr Fmotion_buffer uint64 Fprivate16 uint64 Fmin_keycode int32 Fmax_keycode int32 Fprivate17 TXPointer Fprivate18 TXPointer Fprivate19 int32 Fxdefaults uintptr })(unsafe.Pointer((*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fdisplay)).Fscreens+uintptr((*TTk_FakeWin)(unsafe.Pointer(tkwin)).FscreenNum)*128)).Fwidth)) *(*float64)(unsafe.Pointer(bp)) /= float64((*TScreen)(unsafe.Pointer((*struct { Fext_data uintptr Fprivate1 uintptr Ffd int32 Fprivate2 int32 Fproto_major_version int32 Fproto_minor_version int32 Fvendor uintptr Fprivate3 TXID Fprivate4 TXID Fprivate5 TXID Fprivate6 int32 Fresource_alloc uintptr Fbyte_order int32 Fbitmap_unit int32 Fbitmap_pad int32 Fbitmap_bit_order int32 Fnformats int32 Fpixmap_format uintptr Fprivate8 int32 Frelease int32 Fprivate9 uintptr Fprivate10 uintptr Fqlen int32 Flast_request_read uint64 Frequest uint64 Fprivate11 TXPointer Fprivate12 TXPointer Fprivate13 TXPointer Fprivate14 TXPointer Fmax_request_size uint32 Fdb uintptr Fprivate15 uintptr Fdisplay_name uintptr Fdefault_screen int32 Fnscreens int32 Fscreens uintptr Fmotion_buffer uint64 Fprivate16 uint64 Fmin_keycode int32 Fmax_keycode int32 Fprivate17 TXPointer Fprivate18 TXPointer Fprivate19 int32 Fxdefaults uintptr })(unsafe.Pointer((*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fdisplay)).Fscreens + uintptr((*TTk_FakeWin)(unsafe.Pointer(tkwin)).FscreenNum)*128)).Fmwidth) default: goto error } *(*float64)(unsafe.Pointer(doublePtr)) = *(*float64)(unsafe.Pointer(bp)) return TCL_OK } /* * Local Variables: * mode: c * c-basic-offset: 4 * fill-column: 78 * End: */ /* * One of the following data structures exists for each GC that is currently * active. The structure is indexed with two hash tables, one based on the * values in the graphics context and the other based on the display and GC * identifier. */ type TTkGC = struct { Fgc TGC Fdisplay uintptr FrefCount Tsize_t FvalueHashPtr uintptr } type TValueKey1 = struct { Fvalues TXGCValues Fdisplay uintptr FscreenNum int32 Fdepth int32 } /* *---------------------------------------------------------------------- * * Tk_GetGC -- * * Given a desired set of values for a graphics context, find a read-only * graphics context with the desired values. * * Results: * The return value is the X identifer for the desired graphics context. * The caller should never modify this GC, and should call Tk_FreeGC when * the GC is no longer needed. * * Side effects: * The GC is added to an internal database with a reference count. For * each call to this function, there should eventually be a call to * Tk_FreeGC, so that the database can be cleaned up when GC's aren't * needed anymore. * *---------------------------------------------------------------------- */ func XTk_GetGC(tls *libc.TLS, tkwin TTk_Window, valueMask uint64, valuePtr uintptr) (r TGC) { bp := tls.Alloc(160) defer tls.Free(160) /* Values are specified here for bits set in * valueMask. */ var d, freeDrawable TDrawable var dispPtr, gcPtr, idHashPtr, valueHashPtr uintptr var _ /* isNew at bp+144 */ int32 var _ /* valueKey at bp+0 */ TValueKey1 _, _, _, _, _, _ = d, dispPtr, freeDrawable, gcPtr, idHashPtr, valueHashPtr dispPtr = (*TTkWindow)(unsafe.Pointer(tkwin)).FdispPtr if (*TTkDisplay)(unsafe.Pointer(dispPtr)).FgcInit <= 0 { _GCInit(tls, dispPtr) } /* * Must zero valueKey at start to clear out pad bytes that may be part of * structure on some systems. */ libc.Xmemset(tls, bp, 0, uint64(144)) /* * First, check to see if there's already a GC that will work for this * request (exact matches only, sorry). */ if valueMask&libc.Uint64FromInt64(libc.Int64FromInt64(1)<ancestor tells how many). */ ancestor = container for { if !(ancestor != parent) { break } if ancestor == (*TMaintainContainer)(unsafe.Pointer(containerPtr)).Fancestor { XTk_CreateEventHandler(tls, ancestor, libc.Uint64FromInt64(libc.Int64FromInt64(1)< To * ------------ ---------------------- * LastRelease(B | GB): restrict window -> anc(grab window, event window) * Grab(U | B): event window -> anc(grab window, event window) * Grab(G): anc(old grab window, event window) -> * anc(new grab window, event window) * Grab(GB): restrict window -> anc(new grab window, event window) * Ungrab(G): anc(grab window, event window) -> event window * Ungrab(GB): restrict window -> event window * * Note: anc(x,y) returns the least ancestor of y that is in the tree of x, * terminating at toplevels. */ /* * The following structure is used to pass information to GrabRestrictProc * from EatGrabEvents. */ type TGrabInfo = struct { Fdisplay uintptr Fserial uint32 } /* * Bit definitions for grabFlags field of TkDisplay structures: * * GRAB_GLOBAL 1 means this is a global grab (we grabbed via * the server so all applications are locked out). * 0 means this is a local grab that affects only * this application. * GRAB_TEMP_GLOBAL 1 means we've temporarily grabbed via the * server because a button is down and we want to * make sure that we get the button-up event. The * grab will be released when the last mouse * button goes up. */ /* * The following structure is a Tcl_Event that triggers a change in the * grabWinPtr field of a display. This event guarantees that the change occurs * in the proper order relative to enter and leave events. */ type TNewGrabWinEvent = struct { Fheader TTcl_Event FdispPtr uintptr FgrabWindow TWindow } /* *---------------------------------------------------------------------- * * Tk_GrabObjCmd -- * * This function is invoked to process the "grab" Tcl command. See the * user documentation for details on what it does. * * Results: * A standard Tcl result. * * Side effects: * See the user documentation. * *---------------------------------------------------------------------- */ func XTk_GrabObjCmd(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) (r int32) { bp := tls.Alloc(64) defer tls.Free(64) /* Argument objects. */ var arg, dispPtr, resultObj, statusString, winPtr uintptr var globalGrab int32 var tkwin TTk_Window var _ /* index at bp+0 */ int32 var _ /* len at bp+8 */ TTcl_Size _, _, _, _, _, _, _ = arg, dispPtr, globalGrab, resultObj, statusString, tkwin, winPtr if objc < int32(2) { /* * Can't use Tcl_WrongNumArgs here because we want the message to * read: * wrong # args: should be "cmd ?-global? window" or "cmd option * ?arg ...?" * We can fake it with Tcl_WrongNumArgs if we assume the command name * is "grab", but if it has been aliased, the message will be * incorrect. */ libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(1), objv, __ccgo_ts+11738) libtcl9_0.XTcl_AppendResult(tls, interp, libc.VaList(bp+24, __ccgo_ts+11755, libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv)), libc.UintptrFromInt32(0)), __ccgo_ts+11761, libc.UintptrFromInt32(0))) /* This API not exposed: * ((Interp *) interp)->flags |= INTERP_ALTERNATE_WRONG_ARGS; Tcl_WrongNumArgs(interp, 1, objv, "option ?arg ...?"); */ return int32(TCL_ERROR) } /* * First check for a window name or "-global" as the first argument. */ arg = libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8)), bp+8) if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(arg))) == int32('.') { /* [grab window] */ if objc != int32(2) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(1), objv, __ccgo_ts+11738) return int32(TCL_ERROR) } tkwin = XTk_NameToWindow(tls, interp, arg, clientData) if tkwin == libc.UintptrFromInt32(0) { return int32(TCL_ERROR) } return XTk_Grab(tls, interp, tkwin, 0) } else { if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(arg))) == int32('-') && *(*TTcl_Size)(unsafe.Pointer(bp + 8)) > int64(1) { if libtcl9_0.XTcl_GetIndexFromObjStruct(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 1*8)), uintptr(unsafe.Pointer(&_flagStrings)), libc.Int64FromUint64(libc.Uint64FromInt64(8)), __ccgo_ts+2689, libc.Int32FromInt32(0)|libc.Int32FromUint64(libc.Uint64FromInt64(4)< int32(3) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(1), objv, __ccgo_ts+11780) return int32(TCL_ERROR) } if objc == int32(3) { tkwin = XTk_NameToWindow(tls, interp, libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8)), libc.UintptrFromInt32(0)), clientData) if tkwin == libc.UintptrFromInt32(0) { return int32(TCL_ERROR) } dispPtr = (*TTkWindow)(unsafe.Pointer(tkwin)).FdispPtr if (*TTkDisplay)(unsafe.Pointer(dispPtr)).FeventualGrabWinPtr != libc.UintptrFromInt32(0) { libtcl9_0.XTcl_SetObjResult(tls, interp, XTk_NewWindowObj(tls, (*TTkDisplay)(unsafe.Pointer(dispPtr)).FeventualGrabWinPtr)) } } else { resultObj = libtcl9_0.XTcl_NewObj(tls) dispPtr = XTkGetDisplayList(tls) for { if !(dispPtr != libc.UintptrFromInt32(0)) { break } if (*TTkDisplay)(unsafe.Pointer(dispPtr)).FeventualGrabWinPtr != libc.UintptrFromInt32(0) { libtcl9_0.XTcl_ListObjAppendElement(tls, libc.UintptrFromInt32(0), resultObj, XTk_NewWindowObj(tls, (*TTkDisplay)(unsafe.Pointer(dispPtr)).FeventualGrabWinPtr)) } goto _1 _1: ; dispPtr = (*TTkDisplay)(unsafe.Pointer(dispPtr)).FnextPtr } libtcl9_0.XTcl_SetObjResult(tls, interp, resultObj) } return TCL_OK case 1: /* [grab release window] */ if objc != int32(3) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(1), objv, __ccgo_ts+11797) return int32(TCL_ERROR) } tkwin = XTk_NameToWindow(tls, interp, libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8)), libc.UintptrFromInt32(0)), clientData) if tkwin == libc.UintptrFromInt32(0) { libtcl9_0.XTcl_ResetResult(tls, interp) } else { XTk_Ungrab(tls, tkwin) } case 2: /* [grab set ?-global? window] */ if objc != int32(3) && objc != int32(4) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(1), objv, __ccgo_ts+11812) return int32(TCL_ERROR) } if objc == int32(3) { globalGrab = 0 tkwin = XTk_NameToWindow(tls, interp, libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8)), libc.UintptrFromInt32(0)), clientData) } else { globalGrab = int32(1) /* * We could just test the argument by hand instead of using * Tcl_GetIndexFromObj; the benefit of using the function is that * it sets up the error message for us, so we are certain to be * consistant with the rest of Tcl. */ if libtcl9_0.XTcl_GetIndexFromObjStruct(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), uintptr(unsafe.Pointer(&_flagStrings)), libc.Int64FromUint64(libc.Uint64FromInt64(8)), __ccgo_ts+2689, libc.Int32FromInt32(0)|libc.Int32FromUint64(libc.Uint64FromInt64(4)<buttonWinPtr is non-NULL or when the GRAB_TEMP_GLOBAL flag is * set. * * Results: * None. * * Side effects: * DispPtr->buttonWinPtr is reset to NULL, and enter and leave events are * generated if necessary to move the pointer from the button grab window * to its current window. * *---------------------------------------------------------------------- */ func _ReleaseButtonGrab(tls *libc.TLS, dispPtr uintptr) { /* Display whose button grab is to be * released. */ var serial uint32 _ = serial if (*TTkDisplay)(unsafe.Pointer(dispPtr)).FbuttonWinPtr != libc.UintptrFromInt32(0) { if (*TTkDisplay)(unsafe.Pointer(dispPtr)).FbuttonWinPtr != (*TTkDisplay)(unsafe.Pointer(dispPtr)).FserverWinPtr { _MovePointer2(tls, (*TTkDisplay)(unsafe.Pointer(dispPtr)).FbuttonWinPtr, (*TTkDisplay)(unsafe.Pointer(dispPtr)).FserverWinPtr, int32(NotifyUngrab), int32(1), int32(1)) } (*TTkDisplay)(unsafe.Pointer(dispPtr)).FbuttonWinPtr = libc.UintptrFromInt32(0) } if (*TTkDisplay)(unsafe.Pointer(dispPtr)).FgrabFlags&int32(GRAB_TEMP_GLOBAL) != 0 { *(*int32)(unsafe.Pointer(dispPtr + 1840)) &= ^libc.Int32FromInt32(GRAB_TEMP_GLOBAL) serial = uint32((*struct { Fext_data uintptr Fprivate1 uintptr Ffd int32 Fprivate2 int32 Fproto_major_version int32 Fproto_minor_version int32 Fvendor uintptr Fprivate3 TXID Fprivate4 TXID Fprivate5 TXID Fprivate6 int32 Fresource_alloc uintptr Fbyte_order int32 Fbitmap_unit int32 Fbitmap_pad int32 Fbitmap_bit_order int32 Fnformats int32 Fpixmap_format uintptr Fprivate8 int32 Frelease int32 Fprivate9 uintptr Fprivate10 uintptr Fqlen int32 Flast_request_read uint64 Frequest uint64 Fprivate11 TXPointer Fprivate12 TXPointer Fprivate13 TXPointer Fprivate14 TXPointer Fmax_request_size uint32 Fdb uintptr Fprivate15 uintptr Fdisplay_name uintptr Fdefault_screen int32 Fnscreens int32 Fscreens uintptr Fmotion_buffer uint64 Fprivate16 uint64 Fmin_keycode int32 Fmax_keycode int32 Fprivate17 TXPointer Fprivate18 TXPointer Fprivate19 int32 Fxdefaults uintptr })(unsafe.Pointer((*TTkDisplay)(unsafe.Pointer(dispPtr)).Fdisplay)).Frequest + libc.Uint64FromInt32(1)) libx11.XXUngrabPointer(tls, (*TTkDisplay)(unsafe.Pointer(dispPtr)).Fdisplay, uint64(0)) libx11.XXUngrabKeyboard(tls, (*TTkDisplay)(unsafe.Pointer(dispPtr)).Fdisplay, uint64(0)) _EatGrabEvents(tls, dispPtr, serial) } } /* *---------------------------------------------------------------------- * * TkPointerEvent -- * * This function is called for each pointer-related event, before the * event has been processed. It does various things to make grabs work * correctly. * Also, this function takes care of warping the mouse pointer with * respect to a given window, both when there is a grab in effect and * when there is none. * * Results: * If the return value is 1 it means the event should be processed (event * handlers should be invoked). If the return value is 0 it means the * event should be ignored in order to make grabs work correctly. In some * cases this function modifies the event. * * Side effects: * Grab state information may be updated. New events may also be pushed * back onto the event queue to replace or augment the one passed in * here. * The mouse pointer may be moved. * *---------------------------------------------------------------------- */ func XTkPointerEvent(tls *libc.TLS, eventPtr uintptr, winPtr uintptr) (r int32) { /* Tk's information for window where event was * reported. */ var ancestorOfGrab, appGrabbed, outsideGrabTree int32 var dispPtr, winPtr2 uintptr var serial uint32 _, _, _, _, _, _ = ancestorOfGrab, appGrabbed, dispPtr, outsideGrabTree, serial, winPtr2 dispPtr = (*TTkWindow)(unsafe.Pointer(winPtr)).FdispPtr outsideGrabTree = 0 ancestorOfGrab = 0 appGrabbed = 0 /* Non-zero means event is being reported to * an application that is affected by the * grab. */ /* * Collect information about the grab (if any). */ switch XTkGrabState(tls, winPtr) { case int32(TK_GRAB_IN_TREE): appGrabbed = int32(1) case int32(TK_GRAB_ANCESTOR): appGrabbed = int32(1) outsideGrabTree = int32(1) ancestorOfGrab = int32(1) case int32(TK_GRAB_EXCLUDED): appGrabbed = int32(1) outsideGrabTree = int32(1) break } if (*TXEvent)(unsafe.Pointer(eventPtr)).Ftype1 == int32(EnterNotify) || (*TXEvent)(unsafe.Pointer(eventPtr)).Ftype1 == int32(LeaveNotify) { /* * Keep track of what window the mouse is *really* over. Any events * that we generate have a special send_event value, which is detected * below and used to ignore the event for purposes of setting * serverWinPtr. */ if (*(*TXCrossingEvent)(unsafe.Pointer(eventPtr))).Fsend_event != libc.Int32FromInt32(0x147321ac) { if (*TXEvent)(unsafe.Pointer(eventPtr)).Ftype1 == int32(LeaveNotify) && (*TTkWindow)(unsafe.Pointer(winPtr)).Fflags&uint32(TK_TOP_HIERARCHY) != 0 { (*TTkDisplay)(unsafe.Pointer(dispPtr)).FserverWinPtr = libc.UintptrFromInt32(0) } else { (*TTkDisplay)(unsafe.Pointer(dispPtr)).FserverWinPtr = winPtr } } /* * When a grab is active, X continues to report enter and leave events * for windows outside the tree of the grab window: * 1. Detect these events and ignore them except for windows above the * grab window. * 2. Allow Enter and Leave events to pass through the windows above * the grab window, but never let them end up with the pointer *in* * one of those windows. */ if (*TTkDisplay)(unsafe.Pointer(dispPtr)).FgrabWinPtr != libc.UintptrFromInt32(0) { if outsideGrabTree != 0 && appGrabbed != 0 { if !(ancestorOfGrab != 0) { return 0 } switch (*(*TXCrossingEvent)(unsafe.Pointer(eventPtr))).Fdetail { case int32(NotifyInferior): return 0 case NotifyAncestor: (*(*TXCrossingEvent)(unsafe.Pointer(eventPtr))).Fdetail = int32(NotifyVirtual) case int32(NotifyNonlinear): (*(*TXCrossingEvent)(unsafe.Pointer(eventPtr))).Fdetail = int32(NotifyNonlinearVirtual) break } } /* * Make buttons have the same grab-like behavior inside a grab as * they do outside a grab: do this by ignoring enter and leave * events except for the window in which the button was pressed. */ if (*TTkDisplay)(unsafe.Pointer(dispPtr)).FbuttonWinPtr != libc.UintptrFromInt32(0) && winPtr != (*TTkDisplay)(unsafe.Pointer(dispPtr)).FbuttonWinPtr { return 0 } } return int32(1) } if (*TXEvent)(unsafe.Pointer(eventPtr)).Ftype1 == int32(MotionNotify) && !(appGrabbed != 0) { /* * Warp the mouse pointer with respect to window dispPtr->warpWindow * if such a window was set in HandleEventGenerate. */ XTkDoWarpWrtWin(tls, dispPtr) } if !(appGrabbed != 0) { return int32(1) } /* * From this point on, there is a grab in effect. */ if (*TXEvent)(unsafe.Pointer(eventPtr)).Ftype1 == int32(MotionNotify) { /* * When grabs are active, X reports motion events relative to the * window under the pointer. Instead, it should report the events * relative to the window the button went down in, if there is a * button down. Otherwise, if the pointer window is outside the * subtree of the grab window, the events should be reported relative * to the grab window. Otherwise, the event should be reported to the * pointer window. */ winPtr2 = winPtr if (*TTkDisplay)(unsafe.Pointer(dispPtr)).FbuttonWinPtr != libc.UintptrFromInt32(0) { winPtr2 = (*TTkDisplay)(unsafe.Pointer(dispPtr)).FbuttonWinPtr } else { if outsideGrabTree != 0 || (*TTkDisplay)(unsafe.Pointer(dispPtr)).FserverWinPtr == libc.UintptrFromInt32(0) { winPtr2 = (*TTkDisplay)(unsafe.Pointer(dispPtr)).FgrabWinPtr } } if winPtr2 != winPtr { XTkChangeEventWindow(tls, eventPtr, winPtr2) XTk_QueueWindowEvent(tls, eventPtr, int32(TCL_QUEUE_HEAD)) return 0 } /* * Warp the mouse pointer with respect to window dispPtr->warpWindow * if such a window was set in HandleEventGenerate. */ XTkDoWarpWrtWin(tls, dispPtr) return int32(1) } /* * Process ButtonPress and ButtonRelease events: * 1. Keep track of whether a button is down and what window it went down * in. * 2. If the first button goes down outside the grab tree, pretend it went * down in the grab window. Note: it's important to redirect events to * the grab window like this in order to make things like menus work, * where button presses outside the grabbed menu need to be seen. An * application can always ignore the events if they occur outside its * window. * 3. If a button press or release occurs outside the window where the * first button was pressed, retarget the event so it's reported to the * window where the first button was pressed. * 4. If the last button is released in a window different than where the * first button was pressed, generate Enter/Leave events to move the * mouse from the button window to its current window. * 5. If the grab is set at a time when a button is already down, or if * the window where the button was pressed was deleted, then * dispPtr->buttonWinPtr will stay NULL. Just forget about the * auto-grab for the button press; events will go to whatever window * contains the pointer. If this window isn't in the grab tree then * redirect events to the grab window. * 6. When a button is pressed during a local grab, the X server sets a * grab of its own, since it doesn't even know about our local grab. * This causes enter and leave events no longer to be generated in the * same way as for global grabs. To eliminate this problem, set a * temporary global grab when the first button goes down and release it * when the last button comes up. */ if (*TXEvent)(unsafe.Pointer(eventPtr)).Ftype1 == int32(ButtonPress) || (*TXEvent)(unsafe.Pointer(eventPtr)).Ftype1 == int32(ButtonRelease) { winPtr2 = (*TTkDisplay)(unsafe.Pointer(dispPtr)).FbuttonWinPtr if winPtr2 == libc.UintptrFromInt32(0) { if outsideGrabTree != 0 { winPtr2 = (*TTkDisplay)(unsafe.Pointer(dispPtr)).FgrabWinPtr /* Note 5. */ } else { winPtr2 = winPtr /* Note 5. */ } } if (*TXEvent)(unsafe.Pointer(eventPtr)).Ftype1 == int32(ButtonPress) { if !((*(*TXButtonEvent)(unsafe.Pointer(eventPtr))).Fstate&libc.Uint32FromInt32(libc.Int32FromInt32(1)<= -bd && *(*int32)(unsafe.Pointer(bp + 4)) >= -bd && *(*int32)(unsafe.Pointer(bp)) < (*TTkWindow)(unsafe.Pointer(childPtr)).Fchanges.Fwidth+bd && *(*int32)(unsafe.Pointer(bp + 4)) < (*TTkWindow)(unsafe.Pointer(childPtr)).Fchanges.Fheight+bd { (*(*TXMotionEvent)(unsafe.Pointer(eventPtr))).Fsubwindow = (*TTkWindow)(unsafe.Pointer(childPtr)).Fwindow } goto _1 _1: ; childPtr = (*TTkWindow)(unsafe.Pointer(childPtr)).FnextPtr } sameScreen = int32(1) } else { (*(*TXMotionEvent)(unsafe.Pointer(eventPtr))).Fx = 0 (*(*TXMotionEvent)(unsafe.Pointer(eventPtr))).Fy = 0 (*(*TXMotionEvent)(unsafe.Pointer(eventPtr))).Fsubwindow = uint64(0) sameScreen = 0 } if (*TXEvent)(unsafe.Pointer(eventPtr)).Ftype1 == int32(MotionNotify) { (*(*TXMotionEvent)(unsafe.Pointer(eventPtr))).Fsame_screen = sameScreen } else { (*(*TXButtonEvent)(unsafe.Pointer(eventPtr))).Fsame_screen = sameScreen } } /* *---------------------------------------------------------------------- * * TkInOutEvents -- * * This function synthesizes EnterNotify and LeaveNotify events to * correctly transfer the pointer from one window to another. It can also * be used to generate FocusIn and FocusOut events to move the input * focus. * * Results: * None. * * Side effects: * Synthesized events may be pushed back onto the event queue. The event * pointed to by eventPtr is modified. * *---------------------------------------------------------------------- */ func XTkInOutEvents(tls *libc.TLS, eventPtr uintptr, sourcePtr uintptr, destPtr uintptr, leaveType int32, enterType int32, position TTcl_QueuePosition) { bp := tls.Alloc(16) defer tls.Free(16) /* Position at which events are added to the * system event queue. */ var focus, i, j int32 var winPtr uintptr var _ /* downLevels at bp+4 */ int32 var _ /* upLevels at bp+0 */ int32 _, _, _, _ = focus, i, j, winPtr /* * There are four possible cases to deal with: * * 1. SourcePtr and destPtr are the same. There's nothing to do in this * case. * 2. SourcePtr is an ancestor of destPtr in the same top-level window. * Must generate events down the window tree from source to dest. * 3. DestPtr is an ancestor of sourcePtr in the same top-level window. * Must generate events up the window tree from sourcePtr to destPtr. * 4. All other cases. Must first generate events up the window tree from * sourcePtr to its top-level, then down from destPtr's top-level to * destPtr. This form is called "non-linear." * * The call to FindCommonAncestor separates these four cases and decides * how many levels up and down events have to be generated for. */ if sourcePtr == destPtr { return } if leaveType == int32(FocusOut) || enterType == int32(FocusIn) { focus = int32(1) } else { focus = 0 } _FindCommonAncestor(tls, sourcePtr, destPtr, bp, bp+4) /* * Generate enter/leave events and add them to the grab event queue. */ if *(*int32)(unsafe.Pointer(bp + 4)) == 0 { /* * SourcePtr is an inferior of destPtr. */ if leaveType != 0 { if (*TTkWindow)(unsafe.Pointer(sourcePtr)).Fwindow != uint64(0) { (*TXEvent)(unsafe.Pointer(eventPtr)).Ftype1 = leaveType if focus != 0 { (*(*TXFocusChangeEvent)(unsafe.Pointer(eventPtr))).Fwindow = (*TTkWindow)(unsafe.Pointer(sourcePtr)).Fwindow (*(*TXFocusChangeEvent)(unsafe.Pointer(eventPtr))).Fdetail = NotifyAncestor } else { (*(*TXCrossingEvent)(unsafe.Pointer(eventPtr))).Fdetail = NotifyAncestor XTkChangeEventWindow(tls, eventPtr, sourcePtr) } XTk_QueueWindowEvent(tls, eventPtr, position) } winPtr = (*TTkWindow)(unsafe.Pointer(sourcePtr)).FparentPtr i = *(*int32)(unsafe.Pointer(bp)) - libc.Int32FromInt32(1) for { if !(i > 0) { break } if (*TTkWindow)(unsafe.Pointer(winPtr)).Fwindow != uint64(0) { (*TXEvent)(unsafe.Pointer(eventPtr)).Ftype1 = leaveType if focus != 0 { (*(*TXFocusChangeEvent)(unsafe.Pointer(eventPtr))).Fwindow = (*TTkWindow)(unsafe.Pointer(winPtr)).Fwindow (*(*TXFocusChangeEvent)(unsafe.Pointer(eventPtr))).Fdetail = int32(NotifyVirtual) } else { (*(*TXCrossingEvent)(unsafe.Pointer(eventPtr))).Fdetail = int32(NotifyVirtual) XTkChangeEventWindow(tls, eventPtr, winPtr) } XTk_QueueWindowEvent(tls, eventPtr, position) } goto _1 _1: ; winPtr = (*TTkWindow)(unsafe.Pointer(winPtr)).FparentPtr i-- } } if enterType != 0 && destPtr != libc.UintptrFromInt32(0) { if (*TTkWindow)(unsafe.Pointer(destPtr)).Fwindow != uint64(0) { (*TXEvent)(unsafe.Pointer(eventPtr)).Ftype1 = enterType if focus != 0 { (*(*TXFocusChangeEvent)(unsafe.Pointer(eventPtr))).Fwindow = (*TTkWindow)(unsafe.Pointer(destPtr)).Fwindow (*(*TXFocusChangeEvent)(unsafe.Pointer(eventPtr))).Fdetail = int32(NotifyInferior) } else { (*(*TXCrossingEvent)(unsafe.Pointer(eventPtr))).Fdetail = int32(NotifyInferior) XTkChangeEventWindow(tls, eventPtr, destPtr) } XTk_QueueWindowEvent(tls, eventPtr, position) } } } else { if *(*int32)(unsafe.Pointer(bp)) == 0 { /* * DestPtr is an inferior of sourcePtr. */ if leaveType != 0 && sourcePtr != libc.UintptrFromInt32(0) { if (*TTkWindow)(unsafe.Pointer(sourcePtr)).Fwindow != uint64(0) { (*TXEvent)(unsafe.Pointer(eventPtr)).Ftype1 = leaveType if focus != 0 { (*(*TXFocusChangeEvent)(unsafe.Pointer(eventPtr))).Fwindow = (*TTkWindow)(unsafe.Pointer(sourcePtr)).Fwindow (*(*TXFocusChangeEvent)(unsafe.Pointer(eventPtr))).Fdetail = int32(NotifyInferior) } else { (*(*TXCrossingEvent)(unsafe.Pointer(eventPtr))).Fdetail = int32(NotifyInferior) XTkChangeEventWindow(tls, eventPtr, sourcePtr) } XTk_QueueWindowEvent(tls, eventPtr, position) } } if enterType != 0 { i = *(*int32)(unsafe.Pointer(bp + 4)) - int32(1) for { if !(i > 0) { break } winPtr = (*TTkWindow)(unsafe.Pointer(destPtr)).FparentPtr j = libc.Int32FromInt32(1) for { if !(j < i) { break } /* empty */ goto _3 _3: ; winPtr = (*TTkWindow)(unsafe.Pointer(winPtr)).FparentPtr j++ } if (*TTkWindow)(unsafe.Pointer(winPtr)).Fwindow != uint64(0) { (*TXEvent)(unsafe.Pointer(eventPtr)).Ftype1 = enterType if focus != 0 { (*(*TXFocusChangeEvent)(unsafe.Pointer(eventPtr))).Fwindow = (*TTkWindow)(unsafe.Pointer(winPtr)).Fwindow (*(*TXFocusChangeEvent)(unsafe.Pointer(eventPtr))).Fdetail = int32(NotifyVirtual) } else { (*(*TXCrossingEvent)(unsafe.Pointer(eventPtr))).Fdetail = int32(NotifyVirtual) XTkChangeEventWindow(tls, eventPtr, winPtr) } XTk_QueueWindowEvent(tls, eventPtr, position) } goto _2 _2: ; i-- } if destPtr != libc.UintptrFromInt32(0) { if (*TTkWindow)(unsafe.Pointer(destPtr)).Fwindow != uint64(0) { (*TXEvent)(unsafe.Pointer(eventPtr)).Ftype1 = enterType if focus != 0 { (*(*TXFocusChangeEvent)(unsafe.Pointer(eventPtr))).Fwindow = (*TTkWindow)(unsafe.Pointer(destPtr)).Fwindow (*(*TXFocusChangeEvent)(unsafe.Pointer(eventPtr))).Fdetail = NotifyAncestor } else { (*(*TXCrossingEvent)(unsafe.Pointer(eventPtr))).Fdetail = NotifyAncestor XTkChangeEventWindow(tls, eventPtr, destPtr) } XTk_QueueWindowEvent(tls, eventPtr, position) } } } } else { /* * Non-linear: neither window is an inferior of the other. */ if leaveType != 0 { if (*TTkWindow)(unsafe.Pointer(sourcePtr)).Fwindow != uint64(0) { (*TXEvent)(unsafe.Pointer(eventPtr)).Ftype1 = leaveType if focus != 0 { (*(*TXFocusChangeEvent)(unsafe.Pointer(eventPtr))).Fwindow = (*TTkWindow)(unsafe.Pointer(sourcePtr)).Fwindow (*(*TXFocusChangeEvent)(unsafe.Pointer(eventPtr))).Fdetail = int32(NotifyNonlinear) } else { (*(*TXCrossingEvent)(unsafe.Pointer(eventPtr))).Fdetail = int32(NotifyNonlinear) XTkChangeEventWindow(tls, eventPtr, sourcePtr) } XTk_QueueWindowEvent(tls, eventPtr, position) } winPtr = (*TTkWindow)(unsafe.Pointer(sourcePtr)).FparentPtr i = *(*int32)(unsafe.Pointer(bp)) - libc.Int32FromInt32(1) for { if !(i > 0) { break } if (*TTkWindow)(unsafe.Pointer(winPtr)).Fwindow != uint64(0) { (*TXEvent)(unsafe.Pointer(eventPtr)).Ftype1 = leaveType if focus != 0 { (*(*TXFocusChangeEvent)(unsafe.Pointer(eventPtr))).Fwindow = (*TTkWindow)(unsafe.Pointer(winPtr)).Fwindow (*(*TXFocusChangeEvent)(unsafe.Pointer(eventPtr))).Fdetail = int32(NotifyNonlinearVirtual) } else { (*(*TXCrossingEvent)(unsafe.Pointer(eventPtr))).Fdetail = int32(NotifyNonlinearVirtual) XTkChangeEventWindow(tls, eventPtr, winPtr) } XTk_QueueWindowEvent(tls, eventPtr, position) } goto _4 _4: ; winPtr = (*TTkWindow)(unsafe.Pointer(winPtr)).FparentPtr i-- } } if enterType != 0 { i = *(*int32)(unsafe.Pointer(bp + 4)) - int32(1) for { if !(i > 0) { break } winPtr = (*TTkWindow)(unsafe.Pointer(destPtr)).FparentPtr j = libc.Int32FromInt32(1) for { if !(j < i) { break } goto _6 _6: ; winPtr = (*TTkWindow)(unsafe.Pointer(winPtr)).FparentPtr j++ } if (*TTkWindow)(unsafe.Pointer(winPtr)).Fwindow != uint64(0) { (*TXEvent)(unsafe.Pointer(eventPtr)).Ftype1 = enterType if focus != 0 { (*(*TXFocusChangeEvent)(unsafe.Pointer(eventPtr))).Fwindow = (*TTkWindow)(unsafe.Pointer(winPtr)).Fwindow (*(*TXFocusChangeEvent)(unsafe.Pointer(eventPtr))).Fdetail = int32(NotifyNonlinearVirtual) } else { (*(*TXCrossingEvent)(unsafe.Pointer(eventPtr))).Fdetail = int32(NotifyNonlinearVirtual) XTkChangeEventWindow(tls, eventPtr, winPtr) } XTk_QueueWindowEvent(tls, eventPtr, position) } goto _5 _5: ; i-- } if destPtr != libc.UintptrFromInt32(0) { if (*TTkWindow)(unsafe.Pointer(destPtr)).Fwindow != uint64(0) { (*TXEvent)(unsafe.Pointer(eventPtr)).Ftype1 = enterType if focus != 0 { (*(*TXFocusChangeEvent)(unsafe.Pointer(eventPtr))).Fwindow = (*TTkWindow)(unsafe.Pointer(destPtr)).Fwindow (*(*TXFocusChangeEvent)(unsafe.Pointer(eventPtr))).Fdetail = int32(NotifyNonlinear) } else { (*(*TXCrossingEvent)(unsafe.Pointer(eventPtr))).Fdetail = int32(NotifyNonlinear) XTkChangeEventWindow(tls, eventPtr, destPtr) } XTk_QueueWindowEvent(tls, eventPtr, position) } } } } } } /* *---------------------------------------------------------------------- * * MovePointer2 -- * * This function synthesizes EnterNotify and LeaveNotify events to * correctly transfer the pointer from one window to another. It is * different from TkInOutEvents in that no template X event needs to be * supplied; this function generates the template event and calls * TkInOutEvents. * * Results: * None. * * Side effects: * Synthesized events may be pushed back onto the event queue. * *---------------------------------------------------------------------- */ func _MovePointer2(tls *libc.TLS, sourcePtr uintptr, destPtr uintptr, mode int32, leaveEvents int32, enterEvents int32) { bp := tls.Alloc(224) defer tls.Free(224) /* Non-zero means generate enter events for * the windows being entered. Zero means don't * generate enter events. */ var winPtr uintptr var v1, v2 int32 var _ /* dummy1 at bp+192 */ TWindow var _ /* dummy2 at bp+200 */ TWindow var _ /* dummy3 at bp+208 */ int32 var _ /* dummy4 at bp+212 */ int32 var _ /* event at bp+0 */ TXEvent _, _, _ = winPtr, v1, v2 winPtr = sourcePtr if winPtr == libc.UintptrFromInt32(0) || (*TTkWindow)(unsafe.Pointer(winPtr)).Fwindow == uint64(0) { winPtr = destPtr if winPtr == libc.UintptrFromInt32(0) || (*TTkWindow)(unsafe.Pointer(winPtr)).Fwindow == uint64(0) { return } } (*(*TXCrossingEvent)(unsafe.Pointer(&*(*TXEvent)(unsafe.Pointer(bp))))).Fserial = (*struct { Fext_data uintptr Fprivate1 uintptr Ffd int32 Fprivate2 int32 Fproto_major_version int32 Fproto_minor_version int32 Fvendor uintptr Fprivate3 TXID Fprivate4 TXID Fprivate5 TXID Fprivate6 int32 Fresource_alloc uintptr Fbyte_order int32 Fbitmap_unit int32 Fbitmap_pad int32 Fbitmap_bit_order int32 Fnformats int32 Fpixmap_format uintptr Fprivate8 int32 Frelease int32 Fprivate9 uintptr Fprivate10 uintptr Fqlen int32 Flast_request_read uint64 Frequest uint64 Fprivate11 TXPointer Fprivate12 TXPointer Fprivate13 TXPointer Fprivate14 TXPointer Fmax_request_size uint32 Fdb uintptr Fprivate15 uintptr Fdisplay_name uintptr Fdefault_screen int32 Fnscreens int32 Fscreens uintptr Fmotion_buffer uint64 Fprivate16 uint64 Fmin_keycode int32 Fmax_keycode int32 Fprivate17 TXPointer Fprivate18 TXPointer Fprivate19 int32 Fxdefaults uintptr })(unsafe.Pointer((*TTkWindow)(unsafe.Pointer(winPtr)).Fdisplay)).Flast_request_read (*(*TXCrossingEvent)(unsafe.Pointer(&*(*TXEvent)(unsafe.Pointer(bp))))).Fsend_event = libc.Int32FromInt32(0x147321ac) (*(*TXCrossingEvent)(unsafe.Pointer(&*(*TXEvent)(unsafe.Pointer(bp))))).Fdisplay = (*TTkWindow)(unsafe.Pointer(winPtr)).Fdisplay (*(*TXCrossingEvent)(unsafe.Pointer(&*(*TXEvent)(unsafe.Pointer(bp))))).Froot = (*TScreen)(unsafe.Pointer((*struct { Fext_data uintptr Fprivate1 uintptr Ffd int32 Fprivate2 int32 Fproto_major_version int32 Fproto_minor_version int32 Fvendor uintptr Fprivate3 TXID Fprivate4 TXID Fprivate5 TXID Fprivate6 int32 Fresource_alloc uintptr Fbyte_order int32 Fbitmap_unit int32 Fbitmap_pad int32 Fbitmap_bit_order int32 Fnformats int32 Fpixmap_format uintptr Fprivate8 int32 Frelease int32 Fprivate9 uintptr Fprivate10 uintptr Fqlen int32 Flast_request_read uint64 Frequest uint64 Fprivate11 TXPointer Fprivate12 TXPointer Fprivate13 TXPointer Fprivate14 TXPointer Fmax_request_size uint32 Fdb uintptr Fprivate15 uintptr Fdisplay_name uintptr Fdefault_screen int32 Fnscreens int32 Fscreens uintptr Fmotion_buffer uint64 Fprivate16 uint64 Fmin_keycode int32 Fmax_keycode int32 Fprivate17 TXPointer Fprivate18 TXPointer Fprivate19 int32 Fxdefaults uintptr })(unsafe.Pointer((*TTkWindow)(unsafe.Pointer(winPtr)).Fdisplay)).Fscreens + uintptr((*TTkWindow)(unsafe.Pointer(winPtr)).FscreenNum)*128)).Froot (*(*TXCrossingEvent)(unsafe.Pointer(&*(*TXEvent)(unsafe.Pointer(bp))))).Ftime = XTkCurrentTime(tls, (*TTkWindow)(unsafe.Pointer(winPtr)).FdispPtr) libx11.XXQueryPointer(tls, (*TTkWindow)(unsafe.Pointer(winPtr)).Fdisplay, (*TTkWindow)(unsafe.Pointer(winPtr)).Fwindow, bp+192, bp+200, bp+72, bp+76, bp+208, bp+212, bp+96) (*(*TXCrossingEvent)(unsafe.Pointer(&*(*TXEvent)(unsafe.Pointer(bp))))).Fmode = mode (*(*TXCrossingEvent)(unsafe.Pointer(&*(*TXEvent)(unsafe.Pointer(bp))))).Ffocus = False if leaveEvents != 0 { v1 = int32(LeaveNotify) } else { v1 = 0 } if enterEvents != 0 { v2 = int32(EnterNotify) } else { v2 = 0 } XTkInOutEvents(tls, bp, sourcePtr, destPtr, v1, v2, int32(TCL_QUEUE_MARK)) } /* *---------------------------------------------------------------------- * * TkGrabDeadWindow -- * * This function is invoked whenever a window is deleted, so that * grab-related cleanup can be performed. * * Results: * None. * * Side effects: * Various cleanups happen, such as generating events to move the pointer * back to its "natural" window as if an ungrab had been done. See the * code. * *---------------------------------------------------------------------- */ func XTkGrabDeadWindow(tls *libc.TLS, winPtr uintptr) { /* Window that is in the process of being * deleted. */ var dispPtr uintptr _ = dispPtr dispPtr = (*TTkWindow)(unsafe.Pointer(winPtr)).FdispPtr if (*TTkDisplay)(unsafe.Pointer(dispPtr)).FeventualGrabWinPtr == winPtr { /* * Grab window was deleted. Release the grab. */ XTk_Ungrab(tls, (*TTkDisplay)(unsafe.Pointer(dispPtr)).FeventualGrabWinPtr) } else { if (*TTkDisplay)(unsafe.Pointer(dispPtr)).FbuttonWinPtr == winPtr { _ReleaseButtonGrab(tls, dispPtr) } } if (*TTkDisplay)(unsafe.Pointer(dispPtr)).FserverWinPtr == winPtr { if (*TTkWindow)(unsafe.Pointer(winPtr)).Fflags&uint32(TK_TOP_HIERARCHY) != 0 { (*TTkDisplay)(unsafe.Pointer(dispPtr)).FserverWinPtr = libc.UintptrFromInt32(0) } else { (*TTkDisplay)(unsafe.Pointer(dispPtr)).FserverWinPtr = (*TTkWindow)(unsafe.Pointer(winPtr)).FparentPtr } } if (*TTkDisplay)(unsafe.Pointer(dispPtr)).FgrabWinPtr == winPtr { (*TTkDisplay)(unsafe.Pointer(dispPtr)).FgrabWinPtr = libc.UintptrFromInt32(0) } } /* *---------------------------------------------------------------------- * * EatGrabEvents -- * * This function is called to eliminate any Enter, Leave, FocusIn, or * FocusOut events in the event queue for a display that have mode * NotifyGrab or NotifyUngrab and have a serial number no less than a * given value and are not generated by the grab module. * * Results: * None. * * Side effects: * DispPtr's display gets sync-ed, and some of the events get removed * from the Tk event queue. * *---------------------------------------------------------------------- */ func _EatGrabEvents(tls *libc.TLS, dispPtr uintptr, serial uint32) { bp := tls.Alloc(32) defer tls.Free(32) /* Only discard events that have a serial * number at least this great. */ var prevProc uintptr var _ /* info at bp+0 */ TGrabInfo var _ /* prevArg at bp+16 */ uintptr _ = prevProc (*(*TGrabInfo)(unsafe.Pointer(bp))).Fdisplay = (*TTkDisplay)(unsafe.Pointer(dispPtr)).Fdisplay (*(*TGrabInfo)(unsafe.Pointer(bp))).Fserial = serial XTkpSync(tls, (*(*TGrabInfo)(unsafe.Pointer(bp))).Fdisplay) prevProc = XTk_RestrictEvents(tls, __ccgo_fp(_GrabRestrictProc), bp, bp+16) for libtcl9_0.XTcl_ServiceEvent(tls, libc.Int32FromInt32(1)<grabWinPtr will be modified later (by GrabWinEventProc) when * the event is removed from the grab event queue. * *---------------------------------------------------------------------- */ func _QueueGrabWindowChange(tls *libc.TLS, dispPtr uintptr, grabWinPtr uintptr) { /* Window that is to become the new grab * window (may be NULL). */ var grabEvPtr uintptr _ = grabEvPtr grabEvPtr = libtcl9_0.XTcl_Alloc(tls, uint64(32)) (*TNewGrabWinEvent)(unsafe.Pointer(grabEvPtr)).Fheader.Fproc = __ccgo_fp(_GrabWinEventProc) (*TNewGrabWinEvent)(unsafe.Pointer(grabEvPtr)).FdispPtr = dispPtr if grabWinPtr == libc.UintptrFromInt32(0) { (*TNewGrabWinEvent)(unsafe.Pointer(grabEvPtr)).FgrabWindow = uint64(0) } else { (*TNewGrabWinEvent)(unsafe.Pointer(grabEvPtr)).FgrabWindow = (*TTkWindow)(unsafe.Pointer(grabWinPtr)).Fwindow } libtcl9_0.XTcl_QueueEvent(tls, grabEvPtr, int32(TCL_QUEUE_MARK)) (*TTkDisplay)(unsafe.Pointer(dispPtr)).FeventualGrabWinPtr = grabWinPtr } /* *---------------------------------------------------------------------- * * GrabWinEventProc -- * * This function is invoked as a handler for Tcl_Events of type * NewGrabWinEvent. It updates the current grab window field in a * display. * * Results: * Returns 1 if the event was processed, 0 if it should be deferred for * processing later. * * Side effects: * The grabWinPtr field is modified in the display associated with the * event. * *---------------------------------------------------------------------- */ func _GrabWinEventProc(tls *libc.TLS, evPtr uintptr, dummy1400 int32) (r int32) { /* Flags argument to Tcl_DoOneEvent: indicates * what kinds of events are being processed * right now. */ var grabEvPtr uintptr _ = grabEvPtr grabEvPtr = evPtr (*TTkDisplay)(unsafe.Pointer((*TNewGrabWinEvent)(unsafe.Pointer(grabEvPtr)).FdispPtr)).FgrabWinPtr = XTk_IdToWindow(tls, (*TTkDisplay)(unsafe.Pointer((*TNewGrabWinEvent)(unsafe.Pointer(grabEvPtr)).FdispPtr)).Fdisplay, (*TNewGrabWinEvent)(unsafe.Pointer(grabEvPtr)).FgrabWindow) return int32(1) } /* *---------------------------------------------------------------------- * * FindCommonAncestor -- * * Given two windows, this function finds their least common ancestor and * also computes how many levels up this ancestor is from each of the * original windows. * * Results: * If the windows are in different applications or top-level windows, * then NULL is returned and *countPtr1 and *countPtr2 are set to the * depths of the two windows in their respective top-level windows (1 * means the window is a top-level, 2 means its parent is a top-level, * and so on). Otherwise, the return value is a pointer to the common * ancestor and the counts are set to the distance of winPtr1 and winPtr2 * from this ancestor (1 means they're children, 2 means grand-children, * etc.). * * Side effects: * None. * *---------------------------------------------------------------------- */ func _FindCommonAncestor(tls *libc.TLS, winPtr1 uintptr, winPtr2 uintptr, countPtr1 uintptr, countPtr2 uintptr) (r uintptr) { /* Store nesting level of winPtr2 within * common ancestor here. */ var ancestorPtr, winPtr uintptr var count1, count2, i int32 _, _, _, _, _ = ancestorPtr, count1, count2, i, winPtr /* * Mark winPtr1 and all of its ancestors with a special flag bit. */ if winPtr1 != libc.UintptrFromInt32(0) { winPtr = winPtr1 for { if !(winPtr != libc.UintptrFromInt32(0)) { break } *(*uint32)(unsafe.Pointer(winPtr + 280)) |= uint32(TK_GRAB_FLAG) if (*TTkWindow)(unsafe.Pointer(winPtr)).Fflags&uint32(TK_TOP_HIERARCHY) != 0 { break } goto _1 _1: ; winPtr = (*TTkWindow)(unsafe.Pointer(winPtr)).FparentPtr } } /* * Search upwards from winPtr2 until an ancestor of winPtr1 is found or a * top-level window is reached. */ winPtr = winPtr2 count2 = 0 ancestorPtr = libc.UintptrFromInt32(0) if winPtr2 != libc.UintptrFromInt32(0) { for { if !(winPtr != libc.UintptrFromInt32(0)) { break } if (*TTkWindow)(unsafe.Pointer(winPtr)).Fflags&uint32(TK_GRAB_FLAG) != 0 { ancestorPtr = winPtr break } if (*TTkWindow)(unsafe.Pointer(winPtr)).Fflags&uint32(TK_TOP_HIERARCHY) != 0 { count2++ break } goto _2 _2: ; count2++ winPtr = (*TTkWindow)(unsafe.Pointer(winPtr)).FparentPtr } } /* * Search upwards from winPtr1 again, clearing the flag bits and * remembering how many levels up we had to go. */ if winPtr1 == libc.UintptrFromInt32(0) { count1 = 0 } else { count1 = -int32(1) i = 0 winPtr = winPtr1 for { if !(winPtr != libc.UintptrFromInt32(0)) { break } *(*uint32)(unsafe.Pointer(winPtr + 280)) &= libc.Uint32FromInt32(^libc.Int32FromInt32(TK_GRAB_FLAG)) if winPtr == ancestorPtr { count1 = i } if (*TTkWindow)(unsafe.Pointer(winPtr)).Fflags&uint32(TK_TOP_HIERARCHY) != 0 { if count1 == -int32(1) { count1 = i + int32(1) } break } goto _3 _3: ; i++ winPtr = (*TTkWindow)(unsafe.Pointer(winPtr)).FparentPtr } } *(*int32)(unsafe.Pointer(countPtr1)) = count1 *(*int32)(unsafe.Pointer(countPtr2)) = count2 return ancestorPtr } /* *---------------------------------------------------------------------- * * TkPositionInTree -- * * Compute where the given window is relative to a particular subtree of * the window hierarchy. * * Results: * Returns TK_GRAB_IN_TREE if the window is contained in the subtree. * Returns TK_GRAB_ANCESTOR if the window is an ancestor of the subtree, * in the same toplevel. Otherwise it returns TK_GRAB_EXCLUDED. * * Side effects: * None. * *---------------------------------------------------------------------- */ func XTkPositionInTree(tls *libc.TLS, winPtr uintptr, treePtr uintptr) (r int32) { /* Root of tree to compare against. */ var winPtr2 uintptr _ = winPtr2 winPtr2 = winPtr for { if !(winPtr2 != treePtr) { break } if winPtr2 == libc.UintptrFromInt32(0) { winPtr2 = treePtr for { if !(winPtr2 != libc.UintptrFromInt32(0)) { break } if winPtr2 == winPtr { return int32(TK_GRAB_ANCESTOR) } if (*TTkWindow)(unsafe.Pointer(winPtr2)).Fflags&uint32(TK_TOP_HIERARCHY) != 0 { break } goto _2 _2: ; winPtr2 = (*TTkWindow)(unsafe.Pointer(winPtr2)).FparentPtr } return int32(TK_GRAB_EXCLUDED) } goto _1 _1: ; winPtr2 = (*TTkWindow)(unsafe.Pointer(winPtr2)).FparentPtr } return int32(TK_GRAB_IN_TREE) } /* *---------------------------------------------------------------------- * * TkGrabState -- * * Given a window, this function returns a value that indicates the grab * state of the application relative to the window. * * Results: * The return value is one of three things: * TK_GRAB_NONE - no grab is in effect. * TK_GRAB_IN_TREE - there is a grab in effect, and winPtr is in * the grabbed subtree. * TK_GRAB_ANCESTOR - there is a grab in effect; winPtr is an * ancestor of the grabbed window, in the same * toplevel. * TK_GRAB_EXCLUDED - there is a grab in effect; winPtr is outside * the tree of the grab and is not an ancestor of * the grabbed window in the same toplevel. * * Side effects: * None. * *---------------------------------------------------------------------- */ func XTkGrabState(tls *libc.TLS, winPtr uintptr) (r int32) { /* Window for which grab information is * needed. */ var grabWinPtr uintptr _ = grabWinPtr grabWinPtr = (*TTkDisplay)(unsafe.Pointer((*TTkWindow)(unsafe.Pointer(winPtr)).FdispPtr)).FgrabWinPtr if grabWinPtr == libc.UintptrFromInt32(0) { return TK_GRAB_NONE } if (*TTkWindow)(unsafe.Pointer(winPtr)).FmainPtr != (*TTkWindow)(unsafe.Pointer(grabWinPtr)).FmainPtr && !((*TTkDisplay)(unsafe.Pointer((*TTkWindow)(unsafe.Pointer(winPtr)).FdispPtr)).FgrabFlags&libc.Int32FromInt32(GRAB_GLOBAL) != 0) { return TK_GRAB_NONE } return XTkPositionInTree(tls, winPtr, grabWinPtr) } const ALLOCED_CONTAINER = 4 const CHECK_ONLY = 1 const CHECK_SPACE = 2 const COLUMN = 1 const DONT_PROPAGATE = 2 const GRID_DEFAULT_ANCHOR = 7 const MAX_ELEMENT = 10000 const PREALLOC = 10 const REL_HORIZ = 45 const REL_SKIP = 120 const REL_VERT = 94 const REQUESTED_RELAYOUT = 1 const ROW = 2 const STICK_EAST = 2 const STICK_NORTH = 1 const STICK_SOUTH = 4 const STICK_WEST = 8 const TYPICAL_SIZE = 25 const UNIFORM_PREALLOC = 10 /* * Local Variables: * mode: c * c-basic-offset: 4 * fill-column: 78 * End: */ /* * Convenience Macros */ /* * Pre-allocate enough row and column slots for "typical" sized tables this * value should be chosen so by the time the extra malloc's are required, the * layout calculations overwehlm them. [A "slot" contains information for * either a row or column, depending upon the context.] */ /* * Pre-allocate room for uniform groups during layout. */ /* * Data structures are allocated dynamically to support arbitrary sized * tables. However, the space is proportional to the highest numbered slot * with some non-default property. This limit is used to head off mistakes and * denial of service attacks by limiting the amount of storage required. */ /* * Special characters to support relative layouts. */ /* * Default value for 'grid anchor'. */ /* * Structure to hold information for grid containers. A slot is either a row or * column. */ type TSlotInfo = struct { FminSize int32 Fweight int32 Fpad int32 Funiform TTk_Uid Foffset int32 Ftemp int32 } /* * Structure to hold information during layout calculations. There is one of * these for each slot, an array for each of the rows or columns. */ type TGridLayout = struct { FbinNextPtr uintptr FminSize int32 Fpad int32 Fweight int32 Funiform TTk_Uid FminOffset int32 FmaxOffset int32 } /* * Keep one of these for each geometry container. */ type TGridContainer = struct { FcolumnPtr uintptr FrowPtr uintptr FcolumnEnd int32 FcolumnMax int32 FcolumnSpace int32 FrowEnd int32 FrowMax int32 FrowSpace int32 FstartX int32 FstartY int32 Fanchor TTk_Anchor } /* * For each window that the grid cares about (either because the window is * managed by the grid or because the window has content that are managed by * the grid), there is a structure of the following type: */ type TGridder = struct { Ftkwin TTk_Window FcontainerPtr uintptr FnextPtr uintptr FcontentPtr uintptr FcontainerDataPtr uintptr Fin uintptr Fcolumn int32 Frow int32 FnumCols int32 FnumRows int32 FpadX int32 FpadY int32 FpadLeft int32 FpadTop int32 FiPadX int32 FiPadY int32 Fsticky int32 FdoubleBw int32 FabortPtr uintptr Fflags int32 FbinNextPtr uintptr Fsize int32 } /* * Flag values for "sticky"ness. The 16 combinations subsume the packer's * notion of anchor and fill. * * STICK_NORTH This window sticks to the top of its cavity. * STICK_EAST This window sticks to the right edge of its * cavity. * STICK_SOUTH This window sticks to the bottom of its cavity. * STICK_WEST This window sticks to the left edge of its * cavity. */ /* * Structure to gather information about uniform groups during layout. */ type TUniformGroup = struct { Fgroup TTk_Uid FminSize int32 } var _gridMgrType = TTk_GeomMgr{ Fname: __ccgo_ts + 12090, } func init() { p := unsafe.Pointer(&_gridMgrType) *(*uintptr)(unsafe.Add(p, 8)) = __ccgo_fp(_GridReqProc) *(*uintptr)(unsafe.Add(p, 16)) = __ccgo_fp(_GridLostContentProc) } /* *---------------------------------------------------------------------- * * Tk_GridCmd -- * * This procedure is invoked to process the "grid" Tcl command. See the * user documentation for details on what it does. * * Results: * A standard Tcl result. * * Side effects: * See the user documentation. * *---------------------------------------------------------------------- */ func XTk_GridObjCmd(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) (r int32) { bp := tls.Alloc(48) defer tls.Free(48) /* Argument objects. */ var argv1 uintptr var tkwin TTk_Window var _ /* index at bp+0 */ int32 _, _ = argv1, tkwin tkwin = clientData if objc >= int32(2) { argv1 = libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8)), libc.UintptrFromInt32(0)) if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(argv1))) == int32('.') || libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(argv1))) == int32('x') || libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(argv1))) == int32('^') { return _ConfigureContent(tls, interp, tkwin, int64(objc-int32(1)), objv+uintptr(1)*8) } } if objc < int32(3) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(1), objv, __ccgo_ts+12175) return int32(TCL_ERROR) } if libtcl9_0.XTcl_GetIndexFromObjStruct(tls, libc.UintptrFromInt32(0), *(*uintptr)(unsafe.Pointer(objv + 1*8)), uintptr(unsafe.Pointer(&_optionStrings7)), libc.Int64FromUint64(libc.Uint64FromInt64(8)), __ccgo_ts+2689, libc.Int32FromInt32(0)|libc.Int32FromUint64(libc.Uint64FromInt64(4)< -option * grid columnconfigure -option value -option value * grid rowconfigure * grid rowconfigure -option * grid rowconfigure -option value -option value. */ fallthrough case 2: fallthrough case 10: return _GridRowColumnConfigureCommand(tls, tkwin, interp, int64(objc), objv) } /* This should not happen */ libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+12196, int64(-libc.Int32FromInt32(1)))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+16, __ccgo_ts+179, __ccgo_ts+536, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) } var _optionStrings7 = [14]uintptr{ 0: __ccgo_ts + 7881, 1: __ccgo_ts + 12095, 2: __ccgo_ts + 12100, 3: __ccgo_ts + 4740, 4: __ccgo_ts + 12116, 5: __ccgo_ts + 4750, 6: __ccgo_ts + 2671, 7: __ccgo_ts + 12124, 8: __ccgo_ts + 12133, 9: __ccgo_ts + 12143, 10: __ccgo_ts + 12150, 11: __ccgo_ts + 12163, 12: __ccgo_ts + 12168, 13: libc.UintptrFromInt32(0), } var _optionStringsNoDep = [13]uintptr{ 0: __ccgo_ts + 7881, 1: __ccgo_ts + 12095, 2: __ccgo_ts + 12100, 3: __ccgo_ts + 4740, 4: __ccgo_ts + 12116, 5: __ccgo_ts + 4750, 6: __ccgo_ts + 2671, 7: __ccgo_ts + 12124, 8: __ccgo_ts + 12133, 9: __ccgo_ts + 12143, 10: __ccgo_ts + 12150, 11: __ccgo_ts + 12163, 12: libc.UintptrFromInt32(0), } /* *---------------------------------------------------------------------- * * GridAnchorCommand -- * * Implementation of the [grid anchor] subcommand. See the user * documentation for details on what it does. * * Results: * Standard Tcl result. * * Side effects: * May recompute grid geometry. * *---------------------------------------------------------------------- */ func _GridAnchorCommand(tls *libc.TLS, tkwin TTk_Window, interp uintptr, objc TTcl_Size, objv uintptr) (r int32) { bp := tls.Alloc(16) defer tls.Free(16) /* Argument objects. */ var containerPtr, gridPtr, v1 uintptr var old TTk_Anchor var v2 int32 var _ /* container at bp+0 */ TTk_Window _, _, _, _, _ = containerPtr, gridPtr, old, v1, v2 if objc > int64(4) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(2), objv, __ccgo_ts+12219) return int32(TCL_ERROR) } if XTkGetWindowFromObj(tls, interp, tkwin, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp) != TCL_OK { return int32(TCL_ERROR) } v1 = _GetGrid(tls, *(*TTk_Window)(unsafe.Pointer(bp))) containerPtr = v1 if !(v1 != 0) { return TCL_OK } if objc == int64(3) { gridPtr = (*TGridder)(unsafe.Pointer(containerPtr)).FcontainerDataPtr if gridPtr != 0 { v2 = (*TGridContainer)(unsafe.Pointer(gridPtr)).Fanchor } else { v2 = int32(TK_ANCHOR_NW) } libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewStringObj(tls, XTk_NameOfAnchor(tls, v2), int64(-int32(1)))) return TCL_OK } _InitContainerData(tls, containerPtr) gridPtr = (*TGridder)(unsafe.Pointer(containerPtr)).FcontainerDataPtr old = (*TGridContainer)(unsafe.Pointer(gridPtr)).Fanchor if XTk_GetAnchorFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 3*8)), gridPtr+48) != TCL_OK { return int32(TCL_ERROR) } /* * Only request a relayout if the anchor changes. */ if old != (*TGridContainer)(unsafe.Pointer(gridPtr)).Fanchor { if (*TGridder)(unsafe.Pointer(containerPtr)).FabortPtr != libc.UintptrFromInt32(0) { *(*int32)(unsafe.Pointer((*TGridder)(unsafe.Pointer(containerPtr)).FabortPtr)) = int32(1) } if !((*TGridder)(unsafe.Pointer(containerPtr)).Fflags&libc.Int32FromInt32(REQUESTED_RELAYOUT) != 0) { *(*int32)(unsafe.Pointer(containerPtr + 104)) |= int32(REQUESTED_RELAYOUT) libtcl9_0.XTcl_DoWhenIdle(tls, __ccgo_fp(_ArrangeGrid), containerPtr) } } return TCL_OK } /* *---------------------------------------------------------------------- * * GridBboxCommand -- * * Implementation of the [grid bbox] subcommand. * * Results: * Standard Tcl result. * * Side effects: * Places bounding box information in the interp's result field. * *---------------------------------------------------------------------- */ func _GridBboxCommand(tls *libc.TLS, tkwin TTk_Window, interp uintptr, objc TTcl_Size, objv uintptr) (r int32) { bp := tls.Alloc(32) defer tls.Free(32) /* Argument objects. */ var containerPtr, gridPtr, v1 uintptr var endX, endY, height, temp, temp1, width, x, y, v2, v3 int32 var _ /* column at bp+12 */ int32 var _ /* column2 at bp+20 */ int32 var _ /* container at bp+0 */ TTk_Window var _ /* row at bp+8 */ int32 var _ /* row2 at bp+16 */ int32 _, _, _, _, _, _, _, _, _, _, _, _, _ = containerPtr, endX, endY, gridPtr, height, temp, temp1, width, x, y, v1, v2, v3 /* last column/row in the layout */ x = 0 y = 0 /* size of the bounding box */ if objc != int64(3) && objc != int64(5) && objc != int64(7) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(2), objv, __ccgo_ts+12235) return int32(TCL_ERROR) } if XTkGetWindowFromObj(tls, interp, tkwin, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp) != TCL_OK { return int32(TCL_ERROR) } v1 = _GetGrid(tls, *(*TTk_Window)(unsafe.Pointer(bp))) containerPtr = v1 if !(v1 != 0) { return TCL_OK } if objc >= int64(5) { if libtcl9_0.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 3*8)), bp+12) != TCL_OK { return int32(TCL_ERROR) } if libtcl9_0.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 4*8)), bp+8) != TCL_OK { return int32(TCL_ERROR) } *(*int32)(unsafe.Pointer(bp + 20)) = *(*int32)(unsafe.Pointer(bp + 12)) *(*int32)(unsafe.Pointer(bp + 16)) = *(*int32)(unsafe.Pointer(bp + 8)) } if objc == int64(7) { if libtcl9_0.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 5*8)), bp+20) != TCL_OK { return int32(TCL_ERROR) } if libtcl9_0.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 6*8)), bp+16) != TCL_OK { return int32(TCL_ERROR) } } gridPtr = (*TGridder)(unsafe.Pointer(containerPtr)).FcontainerDataPtr if gridPtr == libc.UintptrFromInt32(0) { libtcl9_0.XTcl_SetObjResult(tls, interp, _NewQuadObj(tls, 0, 0, 0, 0)) return TCL_OK } _SetGridSize(tls, containerPtr) if (*TGridContainer)(unsafe.Pointer(gridPtr)).FcolumnEnd > (*TGridContainer)(unsafe.Pointer(gridPtr)).FcolumnMax { v2 = (*TGridContainer)(unsafe.Pointer(gridPtr)).FcolumnEnd } else { v2 = (*TGridContainer)(unsafe.Pointer(gridPtr)).FcolumnMax } endX = v2 if (*TGridContainer)(unsafe.Pointer(gridPtr)).FrowEnd > (*TGridContainer)(unsafe.Pointer(gridPtr)).FrowMax { v3 = (*TGridContainer)(unsafe.Pointer(gridPtr)).FrowEnd } else { v3 = (*TGridContainer)(unsafe.Pointer(gridPtr)).FrowMax } endY = v3 if endX == 0 || endY == 0 { libtcl9_0.XTcl_SetObjResult(tls, interp, _NewQuadObj(tls, 0, 0, 0, 0)) return TCL_OK } if objc == int64(3) { *(*int32)(unsafe.Pointer(bp + 8)) = 0 *(*int32)(unsafe.Pointer(bp + 12)) = 0 *(*int32)(unsafe.Pointer(bp + 16)) = endY *(*int32)(unsafe.Pointer(bp + 20)) = endX } if *(*int32)(unsafe.Pointer(bp + 12)) > *(*int32)(unsafe.Pointer(bp + 20)) { temp = *(*int32)(unsafe.Pointer(bp + 12)) *(*int32)(unsafe.Pointer(bp + 12)) = *(*int32)(unsafe.Pointer(bp + 20)) *(*int32)(unsafe.Pointer(bp + 20)) = temp } if *(*int32)(unsafe.Pointer(bp + 8)) > *(*int32)(unsafe.Pointer(bp + 16)) { temp1 = *(*int32)(unsafe.Pointer(bp + 8)) *(*int32)(unsafe.Pointer(bp + 8)) = *(*int32)(unsafe.Pointer(bp + 16)) *(*int32)(unsafe.Pointer(bp + 16)) = temp1 } if *(*int32)(unsafe.Pointer(bp + 12)) > 0 && *(*int32)(unsafe.Pointer(bp + 12)) < endX { x = (*(*TSlotInfo)(unsafe.Pointer((*TGridContainer)(unsafe.Pointer(gridPtr)).FcolumnPtr + uintptr(*(*int32)(unsafe.Pointer(bp + 12))-int32(1))*32))).Foffset } else { if *(*int32)(unsafe.Pointer(bp + 12)) > 0 { x = (*(*TSlotInfo)(unsafe.Pointer((*TGridContainer)(unsafe.Pointer(gridPtr)).FcolumnPtr + uintptr(endX-int32(1))*32))).Foffset } } if *(*int32)(unsafe.Pointer(bp + 8)) > 0 && *(*int32)(unsafe.Pointer(bp + 8)) < endY { y = (*(*TSlotInfo)(unsafe.Pointer((*TGridContainer)(unsafe.Pointer(gridPtr)).FrowPtr + uintptr(*(*int32)(unsafe.Pointer(bp + 8))-int32(1))*32))).Foffset } else { if *(*int32)(unsafe.Pointer(bp + 8)) > 0 { y = (*(*TSlotInfo)(unsafe.Pointer((*TGridContainer)(unsafe.Pointer(gridPtr)).FrowPtr + uintptr(endY-int32(1))*32))).Foffset } } if *(*int32)(unsafe.Pointer(bp + 20)) < 0 { width = 0 } else { if *(*int32)(unsafe.Pointer(bp + 20)) >= endX { width = (*(*TSlotInfo)(unsafe.Pointer((*TGridContainer)(unsafe.Pointer(gridPtr)).FcolumnPtr + uintptr(endX-int32(1))*32))).Foffset - x } else { width = (*(*TSlotInfo)(unsafe.Pointer((*TGridContainer)(unsafe.Pointer(gridPtr)).FcolumnPtr + uintptr(*(*int32)(unsafe.Pointer(bp + 20)))*32))).Foffset - x } } if *(*int32)(unsafe.Pointer(bp + 16)) < 0 { height = 0 } else { if *(*int32)(unsafe.Pointer(bp + 16)) >= endY { height = (*(*TSlotInfo)(unsafe.Pointer((*TGridContainer)(unsafe.Pointer(gridPtr)).FrowPtr + uintptr(endY-int32(1))*32))).Foffset - y } else { height = (*(*TSlotInfo)(unsafe.Pointer((*TGridContainer)(unsafe.Pointer(gridPtr)).FrowPtr + uintptr(*(*int32)(unsafe.Pointer(bp + 16)))*32))).Foffset - y } } libtcl9_0.XTcl_SetObjResult(tls, interp, _NewQuadObj(tls, int64(x+(*TGridContainer)(unsafe.Pointer(gridPtr)).FstartX), int64(y+(*TGridContainer)(unsafe.Pointer(gridPtr)).FstartY), int64(width), int64(height))) return TCL_OK } /* *---------------------------------------------------------------------- * * GridForgetRemoveCommand -- * * Implementation of the [grid forget]/[grid remove] subcommands. See the * user documentation for details on what these do. * * Results: * Standard Tcl result. * * Side effects: * Removes a window from a grid layout. * *---------------------------------------------------------------------- */ func _GridForgetRemoveCommand(tls *libc.TLS, tkwin TTk_Window, interp uintptr, objc TTcl_Size, objv uintptr) (r int32) { bp := tls.Alloc(16) defer tls.Free(16) /* Argument objects. */ var _objPtr, _objPtr1, contentPtr, string1, v2, v4, v6 uintptr var c uint8 var i, v3, v5 TTcl_Size var _ /* content at bp+0 */ TTk_Window _, _, _, _, _, _, _, _, _, _, _ = _objPtr, _objPtr1, c, contentPtr, i, string1, v2, v3, v4, v5, v6 string1 = libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8)), libc.UintptrFromInt32(0)) c = *(*uint8)(unsafe.Pointer(string1)) i = int64(2) for { if !(i < objc) { break } if XTkGetWindowFromObj(tls, interp, tkwin, *(*uintptr)(unsafe.Pointer(objv + uintptr(i)*8)), bp) != TCL_OK { return int32(TCL_ERROR) } v2 = _GetGrid(tls, *(*TTk_Window)(unsafe.Pointer(bp))) contentPtr = v2 if !(v2 != 0) { goto _1 } if (*TGridder)(unsafe.Pointer(contentPtr)).FcontainerPtr != libc.UintptrFromInt32(0) { /* * For "forget", reset all the settings to their defaults */ if libc.Int32FromUint8(c) == int32('f') { (*TGridder)(unsafe.Pointer(contentPtr)).Fcolumn = -int32(1) (*TGridder)(unsafe.Pointer(contentPtr)).Frow = -int32(1) (*TGridder)(unsafe.Pointer(contentPtr)).FnumCols = int32(1) (*TGridder)(unsafe.Pointer(contentPtr)).FnumRows = int32(1) (*TGridder)(unsafe.Pointer(contentPtr)).FpadX = 0 (*TGridder)(unsafe.Pointer(contentPtr)).FpadY = 0 (*TGridder)(unsafe.Pointer(contentPtr)).FpadLeft = 0 (*TGridder)(unsafe.Pointer(contentPtr)).FpadTop = 0 (*TGridder)(unsafe.Pointer(contentPtr)).FiPadX = 0 (*TGridder)(unsafe.Pointer(contentPtr)).FiPadY = 0 if (*TGridder)(unsafe.Pointer(contentPtr)).Fin != libc.UintptrFromInt32(0) { _objPtr = (*TGridder)(unsafe.Pointer(contentPtr)).Fin v4 = _objPtr v3 = *(*TTcl_Size)(unsafe.Pointer(v4)) *(*TTcl_Size)(unsafe.Pointer(v4))-- if v3 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr) } (*TGridder)(unsafe.Pointer(contentPtr)).Fin = libc.UintptrFromInt32(0) } (*TGridder)(unsafe.Pointer(contentPtr)).FdoubleBw = int32(2) * (*TXWindowChanges)(unsafe.Pointer(tkwin+112)).Fborder_width if (*TGridder)(unsafe.Pointer(contentPtr)).Fflags&int32(REQUESTED_RELAYOUT) != 0 { libtcl9_0.XTcl_CancelIdleCall(tls, __ccgo_fp(_ArrangeGrid), contentPtr) } (*TGridder)(unsafe.Pointer(contentPtr)).Fflags = 0 (*TGridder)(unsafe.Pointer(contentPtr)).Fsticky = 0 } else { /* * When removing, store name of container to be able to * restore it later, even if the container is recreated. */ if (*TGridder)(unsafe.Pointer(contentPtr)).Fin != libc.UintptrFromInt32(0) { _objPtr1 = (*TGridder)(unsafe.Pointer(contentPtr)).Fin v6 = _objPtr1 v5 = *(*TTcl_Size)(unsafe.Pointer(v6)) *(*TTcl_Size)(unsafe.Pointer(v6))-- if v5 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr1) } (*TGridder)(unsafe.Pointer(contentPtr)).Fin = libc.UintptrFromInt32(0) } if (*TGridder)(unsafe.Pointer(contentPtr)).FcontainerPtr != libc.UintptrFromInt32(0) { (*TGridder)(unsafe.Pointer(contentPtr)).Fin = libtcl9_0.XTcl_NewStringObj(tls, (*TTk_FakeWin)(unsafe.Pointer((*TGridder1)(unsafe.Pointer((*TGridder)(unsafe.Pointer(contentPtr)).FcontainerPtr)).Ftkwin)).FpathName, int64(-libc.Int32FromInt32(1))) (*TTcl_Obj)(unsafe.Pointer((*TGridder)(unsafe.Pointer(contentPtr)).Fin)).FrefCount++ } } XTk_ManageGeometry(tls, *(*TTk_Window)(unsafe.Pointer(bp)), libc.UintptrFromInt32(0), libc.UintptrFromInt32(0)) if (*TGridder1)(unsafe.Pointer((*TGridder)(unsafe.Pointer(contentPtr)).FcontainerPtr)).Ftkwin != (*TTk_FakeWin)(unsafe.Pointer((*TGridder)(unsafe.Pointer(contentPtr)).Ftkwin)).FparentPtr { XTk_UnmaintainGeometry(tls, (*TGridder)(unsafe.Pointer(contentPtr)).Ftkwin, (*TGridder1)(unsafe.Pointer((*TGridder)(unsafe.Pointer(contentPtr)).FcontainerPtr)).Ftkwin) } _Unlink(tls, contentPtr) XTk_UnmapWindow(tls, (*TGridder)(unsafe.Pointer(contentPtr)).Ftkwin) } goto _1 _1: ; i++ } return TCL_OK } /* *---------------------------------------------------------------------- * * GridInfoCommand -- * * Implementation of the [grid info] subcommand. See the user * documentation for details on what it does. * * Results: * Standard Tcl result. * * Side effects: * Puts gridding information in the interpreter's result. * *---------------------------------------------------------------------- */ func _GridInfoCommand(tls *libc.TLS, tkwin TTk_Window, interp uintptr, objc TTcl_Size, objv uintptr) (r int32) { bp := tls.Alloc(16) defer tls.Free(16) /* Argument objects. */ var contentPtr, infoObj, v1 uintptr var _ /* content at bp+0 */ TTk_Window _, _, _ = contentPtr, infoObj, v1 if objc != int64(3) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(2), objv, __ccgo_ts+4814) return int32(TCL_ERROR) } if XTkGetWindowFromObj(tls, interp, tkwin, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp) != TCL_OK { return int32(TCL_ERROR) } v1 = _GetGrid(tls, *(*TTk_Window)(unsafe.Pointer(bp))) contentPtr = v1 if !(v1 != 0) { return TCL_OK } if (*TGridder)(unsafe.Pointer(contentPtr)).FcontainerPtr == libc.UintptrFromInt32(0) { libtcl9_0.XTcl_ResetResult(tls, interp) return TCL_OK } infoObj = libtcl9_0.XTcl_NewObj(tls) libtcl9_0.XTcl_DictObjPut(tls, libc.UintptrFromInt32(0), infoObj, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+12268, int64(-libc.Int32FromInt32(1))), XTk_NewWindowObj(tls, (*TGridder1)(unsafe.Pointer((*TGridder)(unsafe.Pointer(contentPtr)).FcontainerPtr)).Ftkwin)) libtcl9_0.XTcl_DictObjPut(tls, libc.UintptrFromInt32(0), infoObj, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+12272, int64(-libc.Int32FromInt32(1))), libtcl9_0.XTcl_NewWideIntObj(tls, int64((*TGridder)(unsafe.Pointer(contentPtr)).Fcolumn))) libtcl9_0.XTcl_DictObjPut(tls, libc.UintptrFromInt32(0), infoObj, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+12280, int64(-libc.Int32FromInt32(1))), libtcl9_0.XTcl_NewWideIntObj(tls, int64((*TGridder)(unsafe.Pointer(contentPtr)).Frow))) libtcl9_0.XTcl_DictObjPut(tls, libc.UintptrFromInt32(0), infoObj, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+12285, int64(-libc.Int32FromInt32(1))), libtcl9_0.XTcl_NewWideIntObj(tls, int64((*TGridder)(unsafe.Pointer(contentPtr)).FnumCols))) libtcl9_0.XTcl_DictObjPut(tls, libc.UintptrFromInt32(0), infoObj, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+12297, int64(-libc.Int32FromInt32(1))), libtcl9_0.XTcl_NewWideIntObj(tls, int64((*TGridder)(unsafe.Pointer(contentPtr)).FnumRows))) XTkAppendPadAmount(tls, infoObj, __ccgo_ts+12306, (*TGridder)(unsafe.Pointer(contentPtr)).FiPadX/int32(2), (*TGridder)(unsafe.Pointer(contentPtr)).FiPadX) XTkAppendPadAmount(tls, infoObj, __ccgo_ts+12313, (*TGridder)(unsafe.Pointer(contentPtr)).FiPadY/int32(2), (*TGridder)(unsafe.Pointer(contentPtr)).FiPadY) XTkAppendPadAmount(tls, infoObj, __ccgo_ts+12320, (*TGridder)(unsafe.Pointer(contentPtr)).FpadLeft, (*TGridder)(unsafe.Pointer(contentPtr)).FpadX) XTkAppendPadAmount(tls, infoObj, __ccgo_ts+12326, (*TGridder)(unsafe.Pointer(contentPtr)).FpadTop, (*TGridder)(unsafe.Pointer(contentPtr)).FpadY) libtcl9_0.XTcl_DictObjPut(tls, libc.UintptrFromInt32(0), infoObj, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+12332, int64(-libc.Int32FromInt32(1))), _StickyToObj(tls, (*TGridder)(unsafe.Pointer(contentPtr)).Fsticky)) libtcl9_0.XTcl_SetObjResult(tls, interp, infoObj) return TCL_OK } /* *---------------------------------------------------------------------- * * GridLocationCommand -- * * Implementation of the [grid location] subcommand. See the user * documentation for details on what it does. * * Results: * Standard Tcl result. * * Side effects: * Puts location information in the interpreter's result field. * *---------------------------------------------------------------------- */ func _GridLocationCommand(tls *libc.TLS, tkwin TTk_Window, interp uintptr, objc TTcl_Size, objv uintptr) (r int32) { bp := tls.Alloc(16) defer tls.Free(16) /* Argument objects. */ var containerPtr, gridPtr, slotPtr, v1 uintptr var endX, endY, i, j, v2, v3 int32 var _ /* container at bp+0 */ TTk_Window var _ /* x at bp+8 */ int32 var _ /* y at bp+12 */ int32 _, _, _, _, _, _, _, _, _, _ = containerPtr, endX, endY, gridPtr, i, j, slotPtr, v1, v2, v3 /* End of grid. */ if objc != int64(5) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(2), objv, __ccgo_ts+12340) return int32(TCL_ERROR) } if XTkGetWindowFromObj(tls, interp, tkwin, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp) != TCL_OK { return int32(TCL_ERROR) } if XTk_GetPixelsFromObj(tls, interp, *(*TTk_Window)(unsafe.Pointer(bp)), *(*uintptr)(unsafe.Pointer(objv + 3*8)), bp+8) != TCL_OK { return int32(TCL_ERROR) } if XTk_GetPixelsFromObj(tls, interp, *(*TTk_Window)(unsafe.Pointer(bp)), *(*uintptr)(unsafe.Pointer(objv + 4*8)), bp+12) != TCL_OK { return int32(TCL_ERROR) } v1 = _GetGrid(tls, *(*TTk_Window)(unsafe.Pointer(bp))) containerPtr = v1 if !(v1 != 0) { return TCL_OK } if (*TGridder)(unsafe.Pointer(containerPtr)).FcontainerDataPtr == libc.UintptrFromInt32(0) { libtcl9_0.XTcl_SetObjResult(tls, interp, _NewPairObj(tls, int64(-int32(1)), int64(-libc.Int32FromInt32(1)))) return TCL_OK } gridPtr = (*TGridder)(unsafe.Pointer(containerPtr)).FcontainerDataPtr /* * Update any pending requests. This is not always the steady state value, * as more configure events could be in the pipeline, but its as close as * its easy to get. */ for (*TGridder)(unsafe.Pointer(containerPtr)).Fflags&int32(REQUESTED_RELAYOUT) != 0 { libtcl9_0.XTcl_CancelIdleCall(tls, __ccgo_fp(_ArrangeGrid), containerPtr) _ArrangeGrid(tls, containerPtr) } _SetGridSize(tls, containerPtr) if (*TGridContainer)(unsafe.Pointer(gridPtr)).FcolumnEnd > (*TGridContainer)(unsafe.Pointer(gridPtr)).FcolumnMax { v2 = (*TGridContainer)(unsafe.Pointer(gridPtr)).FcolumnEnd } else { v2 = (*TGridContainer)(unsafe.Pointer(gridPtr)).FcolumnMax } endX = v2 if (*TGridContainer)(unsafe.Pointer(gridPtr)).FrowEnd > (*TGridContainer)(unsafe.Pointer(gridPtr)).FrowMax { v3 = (*TGridContainer)(unsafe.Pointer(gridPtr)).FrowEnd } else { v3 = (*TGridContainer)(unsafe.Pointer(gridPtr)).FrowMax } endY = v3 slotPtr = (*TGridContainer)(unsafe.Pointer((*TGridder)(unsafe.Pointer(containerPtr)).FcontainerDataPtr)).FcolumnPtr if *(*int32)(unsafe.Pointer(bp + 8)) < (*TGridContainer)(unsafe.Pointer((*TGridder)(unsafe.Pointer(containerPtr)).FcontainerDataPtr)).FstartX { i = -int32(1) } else { *(*int32)(unsafe.Pointer(bp + 8)) -= (*TGridContainer)(unsafe.Pointer((*TGridder)(unsafe.Pointer(containerPtr)).FcontainerDataPtr)).FstartX i = 0 for { if !((*(*TSlotInfo)(unsafe.Pointer(slotPtr + uintptr(i)*32))).Foffset < *(*int32)(unsafe.Pointer(bp + 8)) && i < endX) { break } /* null body */ goto _4 _4: ; i++ } } slotPtr = (*TGridContainer)(unsafe.Pointer((*TGridder)(unsafe.Pointer(containerPtr)).FcontainerDataPtr)).FrowPtr if *(*int32)(unsafe.Pointer(bp + 12)) < (*TGridContainer)(unsafe.Pointer((*TGridder)(unsafe.Pointer(containerPtr)).FcontainerDataPtr)).FstartY { j = -int32(1) } else { *(*int32)(unsafe.Pointer(bp + 12)) -= (*TGridContainer)(unsafe.Pointer((*TGridder)(unsafe.Pointer(containerPtr)).FcontainerDataPtr)).FstartY j = 0 for { if !((*(*TSlotInfo)(unsafe.Pointer(slotPtr + uintptr(j)*32))).Foffset < *(*int32)(unsafe.Pointer(bp + 12)) && j < endY) { break } /* null body */ goto _5 _5: ; j++ } } libtcl9_0.XTcl_SetObjResult(tls, interp, _NewPairObj(tls, int64(i), int64(j))) return TCL_OK } /* *---------------------------------------------------------------------- * * GridPropagateCommand -- * * Implementation of the [grid propagate] subcommand. See the user * documentation for details on what it does. * * Results: * Standard Tcl result. * * Side effects: * May alter geometry propagation for a widget. * *---------------------------------------------------------------------- */ func _GridPropagateCommand(tls *libc.TLS, tkwin TTk_Window, interp uintptr, objc TTcl_Size, objv uintptr) (r int32) { bp := tls.Alloc(16) defer tls.Free(16) /* Argument objects. */ var containerPtr, v1 uintptr var old int32 var _ /* container at bp+0 */ TTk_Window var _ /* propagate at bp+8 */ int32 _, _, _ = containerPtr, old, v1 if objc > int64(4) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(2), objv, __ccgo_ts+12351) return int32(TCL_ERROR) } if XTkGetWindowFromObj(tls, interp, tkwin, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp) != TCL_OK { return int32(TCL_ERROR) } v1 = _GetGrid(tls, *(*TTk_Window)(unsafe.Pointer(bp))) containerPtr = v1 if !(v1 != 0) { return TCL_OK } if objc == int64(3) { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewWideIntObj(tls, libc.BoolInt64(libc.BoolInt32(!((*TGridder)(unsafe.Pointer(containerPtr)).Fflags&libc.Int32FromInt32(DONT_PROPAGATE) != 0)) != 0))) return TCL_OK } if libtcl9_0.XTcl_GetBoolFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 3*8)), (libc.Int32FromInt32(TCL_NULL_OK)-libc.Int32FromInt32(2))&libc.Int32FromInt64(4), bp+8) != TCL_OK { return int32(TCL_ERROR) } /* * Only request a relayout if the propagation bit changes. */ old = libc.BoolInt32(!((*TGridder)(unsafe.Pointer(containerPtr)).Fflags&libc.Int32FromInt32(DONT_PROPAGATE) != 0)) if *(*int32)(unsafe.Pointer(bp + 8)) != old { if *(*int32)(unsafe.Pointer(bp + 8)) != 0 { /* * If we have content, we need to register as geometry container. */ if (*TGridder)(unsafe.Pointer(containerPtr)).FcontentPtr != libc.UintptrFromInt32(0) { if XTkSetGeometryContainer(tls, interp, *(*TTk_Window)(unsafe.Pointer(bp)), __ccgo_ts+12090) != TCL_OK { return int32(TCL_ERROR) } *(*int32)(unsafe.Pointer(containerPtr + 104)) |= int32(ALLOCED_CONTAINER) } *(*int32)(unsafe.Pointer(containerPtr + 104)) &= ^libc.Int32FromInt32(DONT_PROPAGATE) } else { if (*TGridder)(unsafe.Pointer(containerPtr)).Fflags&int32(ALLOCED_CONTAINER) != 0 { XTkFreeGeometryContainer(tls, *(*TTk_Window)(unsafe.Pointer(bp)), __ccgo_ts+12090) *(*int32)(unsafe.Pointer(containerPtr + 104)) &= ^libc.Int32FromInt32(ALLOCED_CONTAINER) } *(*int32)(unsafe.Pointer(containerPtr + 104)) |= int32(DONT_PROPAGATE) } /* * Re-arrange the container to allow new geometry information to * propagate upwards to the container's container. */ if (*TGridder)(unsafe.Pointer(containerPtr)).FabortPtr != libc.UintptrFromInt32(0) { *(*int32)(unsafe.Pointer((*TGridder)(unsafe.Pointer(containerPtr)).FabortPtr)) = int32(1) } if !((*TGridder)(unsafe.Pointer(containerPtr)).Fflags&libc.Int32FromInt32(REQUESTED_RELAYOUT) != 0) { *(*int32)(unsafe.Pointer(containerPtr + 104)) |= int32(REQUESTED_RELAYOUT) libtcl9_0.XTcl_DoWhenIdle(tls, __ccgo_fp(_ArrangeGrid), containerPtr) } } return TCL_OK } /* *---------------------------------------------------------------------- * * GridRowColumnConfigureCommand -- * * Implementation of the [grid rowconfigure] and [grid columnconfigure] * subcommands. See the user documentation for details on what these do. * * Results: * Standard Tcl result. * * Side effects: * Depends on arguments; see user documentation. * *---------------------------------------------------------------------- */ func _GridRowColumnConfigureCommand(tls *libc.TLS, tkwin TTk_Window, interp uintptr, objc TTcl_Size, objv uintptr) (r int32) { bp := tls.Alloc(96) defer tls.Free(96) /* Argument objects. */ var _objPtr, _objPtr1, _objPtr10, _objPtr11, _objPtr12, _objPtr13, _objPtr14, _objPtr15, _objPtr16, _objPtr2, _objPtr3, _objPtr4, _objPtr5, _objPtr6, _objPtr7, _objPtr8, _objPtr9, containerPtr, contentPtr, listCopy, res, slotPtr, string1, v11, v12, v13, v15, v17, v2, v21, v24, v26, v28, v30, v35, v36, v39, v4, v41, v43, v45, v47, v49, v51, v6, v7, v9 uintptr var allContent, minsize, ok, pad, slotType, weight, v18, v19, v22, v3, v31, v32 int32 var first, i, j, last, v1, v10, v14, v16, v23, v27, v29, v34, v38, v40, v42, v44, v46, v48, v5, v50, v8 TTcl_Size var uniform, value, v20 TTk_Uid var _ /* container at bp+0 */ TTk_Window var _ /* content at bp+8 */ TTk_Window var _ /* index at bp+40 */ int32 var _ /* lObjc at bp+24 */ TTcl_Size var _ /* lObjv at bp+32 */ uintptr var _ /* size at bp+20 */ int32 var _ /* slot at bp+16 */ int32 var _ /* wt at bp+44 */ int32 _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = _objPtr, _objPtr1, _objPtr10, _objPtr11, _objPtr12, _objPtr13, _objPtr14, _objPtr15, _objPtr16, _objPtr2, _objPtr3, _objPtr4, _objPtr5, _objPtr6, _objPtr7, _objPtr8, _objPtr9, allContent, containerPtr, contentPtr, first, i, j, last, listCopy, minsize, ok, pad, res, slotPtr, slotType, string1, uniform, value, weight, v1, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v2, v20, v21, v22, v23, v24, v26, v27, v28, v29, v3, v30, v31, v32, v34, v35, v36, v38, v39, v4, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v5, v50, v51, v6, v7, v8, v9 slotPtr = libc.UintptrFromInt32(0) if objc%int64(2) != 0 && objc > int64(6) || objc < int64(4) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(2), objv, __ccgo_ts+12391) return int32(TCL_ERROR) } if XTkGetWindowFromObj(tls, interp, tkwin, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp) != TCL_OK { return int32(TCL_ERROR) } listCopy = libtcl9_0.XTcl_DuplicateObj(tls, *(*uintptr)(unsafe.Pointer(objv + 3*8))) (*TTcl_Obj)(unsafe.Pointer(listCopy)).FrefCount++ if libtcl9_0.XTcl_ListObjGetElements(tls, interp, listCopy, bp+24, bp+32) != TCL_OK { _objPtr = listCopy v2 = _objPtr v1 = *(*TTcl_Size)(unsafe.Pointer(v2)) *(*TTcl_Size)(unsafe.Pointer(v2))-- if v1 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr) } return int32(TCL_ERROR) } string1 = libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8)), libc.UintptrFromInt32(0)) if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(string1))) == int32('c') { v3 = int32(COLUMN) } else { v3 = int32(ROW) } slotType = v3 if *(*TTcl_Size)(unsafe.Pointer(bp + 24)) == 0 { if slotType == int32(COLUMN) { v4 = __ccgo_ts + 12424 } else { v4 = __ccgo_ts + 12431 } libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+12435, libc.VaList(bp+56, v4))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+56, __ccgo_ts+179, __ccgo_ts+12459, __ccgo_ts+12464, libc.UintptrFromInt32(0))) _objPtr1 = listCopy v6 = _objPtr1 v5 = *(*TTcl_Size)(unsafe.Pointer(v6)) *(*TTcl_Size)(unsafe.Pointer(v6))-- if v5 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr1) } return int32(TCL_ERROR) } v7 = _GetGrid(tls, *(*TTk_Window)(unsafe.Pointer(bp))) containerPtr = v7 if !(v7 != 0) { return TCL_OK } first = 0 last = 0 if objc == int64(4) || objc == int64(5) { if *(*TTcl_Size)(unsafe.Pointer(bp + 24)) != int64(1) { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+12473, int64(-libc.Int32FromInt32(1)))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+56, __ccgo_ts+179, __ccgo_ts+12459, __ccgo_ts+12516, libc.UintptrFromInt32(0))) _objPtr2 = listCopy v9 = _objPtr2 v8 = *(*TTcl_Size)(unsafe.Pointer(v9)) *(*TTcl_Size)(unsafe.Pointer(v9))-- if v8 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr2) } return int32(TCL_ERROR) } if libtcl9_0.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 32)))), bp+16) != TCL_OK { libtcl9_0.XTcl_AppendResult(tls, interp, libc.VaList(bp+56, __ccgo_ts+12522, libc.UintptrFromInt32(0))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+56, __ccgo_ts+179, __ccgo_ts+12459, __ccgo_ts+12582, libc.UintptrFromInt32(0))) _objPtr3 = listCopy v11 = _objPtr3 v10 = *(*TTcl_Size)(unsafe.Pointer(v11)) *(*TTcl_Size)(unsafe.Pointer(v11))-- if v10 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr3) } return int32(TCL_ERROR) } ok = _CheckSlotData(tls, containerPtr, int64(*(*int32)(unsafe.Pointer(bp + 16))), slotType, int32(1)) if ok == TCL_OK { if slotType == int32(COLUMN) { v12 = (*TGridContainer)(unsafe.Pointer((*TGridder)(unsafe.Pointer(containerPtr)).FcontainerDataPtr)).FcolumnPtr } else { v12 = (*TGridContainer)(unsafe.Pointer((*TGridder)(unsafe.Pointer(containerPtr)).FcontainerDataPtr)).FrowPtr } slotPtr = v12 } /* * Return all of the options for this row or column. If the request is * out of range, return all 0's. */ if objc == int64(4) { minsize = 0 pad = 0 weight = 0 uniform = libc.UintptrFromInt32(0) res = libtcl9_0.XTcl_NewListObj(tls, 0, libc.UintptrFromInt32(0)) if ok == TCL_OK { minsize = (*(*TSlotInfo)(unsafe.Pointer(slotPtr + uintptr(*(*int32)(unsafe.Pointer(bp + 16)))*32))).FminSize pad = (*(*TSlotInfo)(unsafe.Pointer(slotPtr + uintptr(*(*int32)(unsafe.Pointer(bp + 16)))*32))).Fpad weight = (*(*TSlotInfo)(unsafe.Pointer(slotPtr + uintptr(*(*int32)(unsafe.Pointer(bp + 16)))*32))).Fweight uniform = (*(*TSlotInfo)(unsafe.Pointer(slotPtr + uintptr(*(*int32)(unsafe.Pointer(bp + 16)))*32))).Funiform } libtcl9_0.XTcl_ListObjAppendElement(tls, interp, res, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+12368, int64(-libc.Int32FromInt32(1)))) libtcl9_0.XTcl_ListObjAppendElement(tls, interp, res, libtcl9_0.XTcl_NewWideIntObj(tls, int64(minsize))) libtcl9_0.XTcl_ListObjAppendElement(tls, interp, res, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+12377, int64(-libc.Int32FromInt32(1)))) libtcl9_0.XTcl_ListObjAppendElement(tls, interp, res, libtcl9_0.XTcl_NewWideIntObj(tls, int64(pad))) libtcl9_0.XTcl_ListObjAppendElement(tls, interp, res, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+12382, int64(-libc.Int32FromInt32(1)))) if uniform == libc.UintptrFromInt32(0) { v13 = __ccgo_ts + 195 } else { v13 = uniform } libtcl9_0.XTcl_ListObjAppendElement(tls, interp, res, libtcl9_0.XTcl_NewStringObj(tls, v13, int64(-libc.Int32FromInt32(1)))) libtcl9_0.XTcl_ListObjAppendElement(tls, interp, res, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+9492, int64(-libc.Int32FromInt32(1)))) libtcl9_0.XTcl_ListObjAppendElement(tls, interp, res, libtcl9_0.XTcl_NewWideIntObj(tls, int64(weight))) libtcl9_0.XTcl_SetObjResult(tls, interp, res) _objPtr4 = listCopy v15 = _objPtr4 v14 = *(*TTcl_Size)(unsafe.Pointer(v15)) *(*TTcl_Size)(unsafe.Pointer(v15))-- if v14 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr4) } return TCL_OK } /* * If only one option is given, with no value, the current value is * returned. */ if libtcl9_0.XTcl_GetIndexFromObjStruct(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 4*8)), uintptr(unsafe.Pointer(&_optionStrings8)), libc.Int64FromUint64(libc.Uint64FromInt64(8)), __ccgo_ts+2689, libc.Int32FromInt32(0)|libc.Int32FromUint64(libc.Uint64FromInt64(4)<= 0 && (*(*TSlotInfo)(unsafe.Pointer(slotPtr + uintptr(last)*32))).Fweight == 0 && (*(*TSlotInfo)(unsafe.Pointer(slotPtr + uintptr(last)*32))).Fpad == 0 && (*(*TSlotInfo)(unsafe.Pointer(slotPtr + uintptr(last)*32))).FminSize == 0 && (*(*TSlotInfo)(unsafe.Pointer(slotPtr + uintptr(last)*32))).Funiform == libc.UintptrFromInt32(0) { last-- } (*TGridContainer)(unsafe.Pointer((*TGridder)(unsafe.Pointer(containerPtr)).FcontainerDataPtr)).FrowMax = int32(last + int64(1)) } else { last = int64((*TGridContainer)(unsafe.Pointer((*TGridder)(unsafe.Pointer(containerPtr)).FcontainerDataPtr)).FcolumnMax - int32(1)) for last >= 0 && (*(*TSlotInfo)(unsafe.Pointer(slotPtr + uintptr(last)*32))).Fweight == 0 && (*(*TSlotInfo)(unsafe.Pointer(slotPtr + uintptr(last)*32))).Fpad == 0 && (*(*TSlotInfo)(unsafe.Pointer(slotPtr + uintptr(last)*32))).FminSize == 0 && (*(*TSlotInfo)(unsafe.Pointer(slotPtr + uintptr(last)*32))).Funiform == libc.UintptrFromInt32(0) { last-- } (*TGridContainer)(unsafe.Pointer((*TGridder)(unsafe.Pointer(containerPtr)).FcontainerDataPtr)).FcolumnMax = int32(last + int64(1)) } } if (*TGridder)(unsafe.Pointer(containerPtr)).FabortPtr != libc.UintptrFromInt32(0) { *(*int32)(unsafe.Pointer((*TGridder)(unsafe.Pointer(containerPtr)).FabortPtr)) = int32(1) } if !((*TGridder)(unsafe.Pointer(containerPtr)).Fflags&libc.Int32FromInt32(REQUESTED_RELAYOUT) != 0) { *(*int32)(unsafe.Pointer(containerPtr + 104)) |= int32(REQUESTED_RELAYOUT) libtcl9_0.XTcl_DoWhenIdle(tls, __ccgo_fp(_ArrangeGrid), containerPtr) } return TCL_OK goto negativeIndex negativeIndex: ; libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+12709, libc.VaList(bp+56, libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(i)*8)), libc.UintptrFromInt32(0))))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+56, __ccgo_ts+179, __ccgo_ts+12459, __ccgo_ts+12750, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) } var _optionStrings8 = [5]uintptr{ 0: __ccgo_ts + 12368, 1: __ccgo_ts + 12377, 2: __ccgo_ts + 12382, 3: __ccgo_ts + 9492, 4: libc.UintptrFromInt32(0), } /* *---------------------------------------------------------------------- * * GridSizeCommand -- * * Implementation of the [grid size] subcommand. See the user * documentation for details on what it does. * * Results: * Standard Tcl result. * * Side effects: * Puts grid size information in the interpreter's result. * *---------------------------------------------------------------------- */ func _GridSizeCommand(tls *libc.TLS, tkwin TTk_Window, interp uintptr, objc TTcl_Size, objv uintptr) (r int32) { bp := tls.Alloc(16) defer tls.Free(16) /* Argument objects. */ var containerPtr, gridPtr, v1 uintptr var v2, v3 int32 var _ /* container at bp+0 */ TTk_Window _, _, _, _, _ = containerPtr, gridPtr, v1, v2, v3 /* pointer to grid data */ if objc != int64(3) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(2), objv, __ccgo_ts+4814) return int32(TCL_ERROR) } if XTkGetWindowFromObj(tls, interp, tkwin, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp) != TCL_OK { return int32(TCL_ERROR) } v1 = _GetGrid(tls, *(*TTk_Window)(unsafe.Pointer(bp))) containerPtr = v1 if !(v1 != 0) { return TCL_OK } if (*TGridder)(unsafe.Pointer(containerPtr)).FcontainerDataPtr != libc.UintptrFromInt32(0) { _SetGridSize(tls, containerPtr) gridPtr = (*TGridder)(unsafe.Pointer(containerPtr)).FcontainerDataPtr if (*TGridContainer)(unsafe.Pointer(gridPtr)).FcolumnEnd > (*TGridContainer)(unsafe.Pointer(gridPtr)).FcolumnMax { v2 = (*TGridContainer)(unsafe.Pointer(gridPtr)).FcolumnEnd } else { v2 = (*TGridContainer)(unsafe.Pointer(gridPtr)).FcolumnMax } if (*TGridContainer)(unsafe.Pointer(gridPtr)).FrowEnd > (*TGridContainer)(unsafe.Pointer(gridPtr)).FrowMax { v3 = (*TGridContainer)(unsafe.Pointer(gridPtr)).FrowEnd } else { v3 = (*TGridContainer)(unsafe.Pointer(gridPtr)).FrowMax } libtcl9_0.XTcl_SetObjResult(tls, interp, _NewPairObj(tls, int64(v2), int64(v3))) } else { libtcl9_0.XTcl_SetObjResult(tls, interp, _NewPairObj(tls, 0, 0)) } return TCL_OK } /* *---------------------------------------------------------------------- * * GridContentCommand -- * * Implementation of the [grid content] subcommand. See the user * documentation for details on what it does. * * Results: * Standard Tcl result. * * Side effects: * Places a list of content windows of the specified window in the * interpreter's result field. * *---------------------------------------------------------------------- */ func _GridContentCommand(tls *libc.TLS, tkwin TTk_Window, interp uintptr, objc TTcl_Size, objv uintptr) (r int32) { bp := tls.Alloc(64) defer tls.Free(64) /* Argument objects. */ var column, i, row int32 var containerPtr, contentPtr, res, v2 uintptr var _ /* container at bp+0 */ TTk_Window var _ /* index at bp+12 */ int32 var _ /* value at bp+8 */ int32 _, _, _, _, _, _, _ = column, containerPtr, contentPtr, i, res, row, v2 row = -int32(1) column = -int32(1) if objc < int64(3) || objc%int64(2) == 0 { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(2), objv, __ccgo_ts+4787) return int32(TCL_ERROR) } i = int32(3) for { if !(int64(i) < objc) { break } if libtcl9_0.XTcl_GetIndexFromObjStruct(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(i)*8)), uintptr(unsafe.Pointer(&_optionStrings9)), libc.Int64FromUint64(libc.Uint64FromInt64(8)), __ccgo_ts+2689, libc.Int32FromInt32(0)|libc.Int32FromUint64(libc.Uint64FromInt64(4)<= 0 && ((*TGridder)(unsafe.Pointer(contentPtr)).Fcolumn > column || (*TGridder)(unsafe.Pointer(contentPtr)).Fcolumn+(*TGridder)(unsafe.Pointer(contentPtr)).FnumCols-int32(1) < column) { goto _3 } if row >= 0 && ((*TGridder)(unsafe.Pointer(contentPtr)).Frow > row || (*TGridder)(unsafe.Pointer(contentPtr)).Frow+(*TGridder)(unsafe.Pointer(contentPtr)).FnumRows-int32(1) < row) { goto _3 } libtcl9_0.XTcl_ListObjAppendElement(tls, interp, res, XTk_NewWindowObj(tls, (*TGridder)(unsafe.Pointer(contentPtr)).Ftkwin)) goto _3 _3: ; contentPtr = (*TGridder)(unsafe.Pointer(contentPtr)).FnextPtr } libtcl9_0.XTcl_SetObjResult(tls, interp, res) return TCL_OK } var _optionStrings9 = [3]uintptr{ 0: __ccgo_ts + 12272, 1: __ccgo_ts + 12280, 2: libc.UintptrFromInt32(0), } /* *---------------------------------------------------------------------- * * GridReqProc -- * * This procedure is invoked by Tk_GeometryRequest for windows managed by * the grid. * * Results: * None. * * Side effects: * Arranges for tkwin, and all its managed siblings, to be re-arranged at * the next idle point. * *---------------------------------------------------------------------- */ func _GridReqProc(tls *libc.TLS, clientData uintptr, dummy1465 TTk_Window) { /* Other Tk-related information about the * window. */ var gridPtr uintptr _ = gridPtr gridPtr = clientData gridPtr = (*TGridder)(unsafe.Pointer(gridPtr)).FcontainerPtr if gridPtr != 0 && !((*TGridder)(unsafe.Pointer(gridPtr)).Fflags&libc.Int32FromInt32(REQUESTED_RELAYOUT) != 0) { *(*int32)(unsafe.Pointer(gridPtr + 104)) |= int32(REQUESTED_RELAYOUT) libtcl9_0.XTcl_DoWhenIdle(tls, __ccgo_fp(_ArrangeGrid), gridPtr) } } /* *---------------------------------------------------------------------- * * GridLostContentProc -- * * This procedure is invoked by Tk whenever some other geometry claims * control over a content that used to be managed by us. * * Results: * None. * * Side effects: * Forgets all grid-related information about the content. * *---------------------------------------------------------------------- */ func _GridLostContentProc(tls *libc.TLS, clientData uintptr, dummy1498 TTk_Window) { /* Tk's handle for the content window. */ var contentPtr uintptr _ = contentPtr contentPtr = clientData if (*TGridder1)(unsafe.Pointer((*TGridder)(unsafe.Pointer(contentPtr)).FcontainerPtr)).Ftkwin != (*TTk_FakeWin)(unsafe.Pointer((*TGridder)(unsafe.Pointer(contentPtr)).Ftkwin)).FparentPtr { XTk_UnmaintainGeometry(tls, (*TGridder)(unsafe.Pointer(contentPtr)).Ftkwin, (*TGridder1)(unsafe.Pointer((*TGridder)(unsafe.Pointer(contentPtr)).FcontainerPtr)).Ftkwin) } _Unlink(tls, contentPtr) XTk_UnmapWindow(tls, (*TGridder)(unsafe.Pointer(contentPtr)).Ftkwin) } /* *---------------------------------------------------------------------- * * AdjustOffsets -- * * This procedure adjusts the size of the layout to fit in the space * provided. If it needs more space, the extra is added according to the * weights. If it needs less, the space is removed according to the * weights, but at no time does the size drop below the minsize specified * for that slot. * * Results: * The size used by the layout. * * Side effects: * The slot offsets are modified to shrink the layout. * *---------------------------------------------------------------------- */ func _AdjustOffsets(tls *libc.TLS, size int32, slots TTcl_Size, slotPtr uintptr) (r int32) { /* Pointer to slot array. */ var current, current1, diff, maxDiff, minSize, newDiff, offset, totalWeight, weight, v6, v8 int32 var slot TTcl_Size _, _, _, _, _, _, _, _, _, _, _, _ = current, current1, diff, maxDiff, minSize, newDiff, offset, slot, totalWeight, weight, v6, v8 /* The most pixels that can be added on the * current pass. */ diff = size - (*(*TSlotInfo)(unsafe.Pointer(slotPtr + uintptr(slots-int64(1))*32))).Foffset /* * The layout is already the correct size; all done. */ if diff == 0 { return size } /* * If all the weights are zero, there is nothing more to do. */ totalWeight = 0 slot = 0 for { if !(slot < slots) { break } totalWeight += (*(*TSlotInfo)(unsafe.Pointer(slotPtr + uintptr(slot)*32))).Fweight goto _1 _1: ; slot++ } if totalWeight == 0 { return (*(*TSlotInfo)(unsafe.Pointer(slotPtr + uintptr(slots-int64(1))*32))).Foffset } /* * Add extra space according to the slot weights. This is done * cumulatively to prevent round-off error accumulation. */ if diff > 0 { weight = 0 slot = 0 for { if !(slot < slots) { break } weight += (*(*TSlotInfo)(unsafe.Pointer(slotPtr + uintptr(slot)*32))).Fweight (*(*TSlotInfo)(unsafe.Pointer(slotPtr + uintptr(slot)*32))).Foffset += diff * weight / totalWeight goto _2 _2: ; slot++ } return size } /* * The layout must shrink below its requested size. Compute the minimum * possible size by looking at the slot minSizes. Store each slot's * minimum size in temp. */ minSize = 0 slot = 0 for { if !(slot < slots) { break } if (*(*TSlotInfo)(unsafe.Pointer(slotPtr + uintptr(slot)*32))).Fweight > 0 { (*(*TSlotInfo)(unsafe.Pointer(slotPtr + uintptr(slot)*32))).Ftemp = (*(*TSlotInfo)(unsafe.Pointer(slotPtr + uintptr(slot)*32))).FminSize } else { if slot > 0 { (*(*TSlotInfo)(unsafe.Pointer(slotPtr + uintptr(slot)*32))).Ftemp = (*(*TSlotInfo)(unsafe.Pointer(slotPtr + uintptr(slot)*32))).Foffset - (*(*TSlotInfo)(unsafe.Pointer(slotPtr + uintptr(slot-int64(1))*32))).Foffset } else { (*(*TSlotInfo)(unsafe.Pointer(slotPtr + uintptr(slot)*32))).Ftemp = (*(*TSlotInfo)(unsafe.Pointer(slotPtr + uintptr(slot)*32))).Foffset } } minSize += (*(*TSlotInfo)(unsafe.Pointer(slotPtr + uintptr(slot)*32))).Ftemp goto _3 _3: ; slot++ } /* * If the requested size is less than the minimum required size, set the * slot sizes to their minimum values. */ if size <= minSize { offset = 0 slot = 0 for { if !(slot < slots) { break } offset += (*(*TSlotInfo)(unsafe.Pointer(slotPtr + uintptr(slot)*32))).Ftemp (*(*TSlotInfo)(unsafe.Pointer(slotPtr + uintptr(slot)*32))).Foffset = offset goto _4 _4: ; slot++ } return minSize } /* * Remove space from slots according to their weights. The weights get * renormalized anytime a slot shrinks to its minimum size. */ for diff < 0 { /* * Find the total weight for the shrinkable slots. */ totalWeight = 0 slot = 0 for { if !(slot < slots) { break } if slot == 0 { v6 = (*(*TSlotInfo)(unsafe.Pointer(slotPtr + uintptr(slot)*32))).Foffset } else { v6 = (*(*TSlotInfo)(unsafe.Pointer(slotPtr + uintptr(slot)*32))).Foffset - (*(*TSlotInfo)(unsafe.Pointer(slotPtr + uintptr(slot-int64(1))*32))).Foffset } current = v6 if current > (*(*TSlotInfo)(unsafe.Pointer(slotPtr + uintptr(slot)*32))).FminSize { totalWeight += (*(*TSlotInfo)(unsafe.Pointer(slotPtr + uintptr(slot)*32))).Fweight (*(*TSlotInfo)(unsafe.Pointer(slotPtr + uintptr(slot)*32))).Ftemp = (*(*TSlotInfo)(unsafe.Pointer(slotPtr + uintptr(slot)*32))).Fweight } else { (*(*TSlotInfo)(unsafe.Pointer(slotPtr + uintptr(slot)*32))).Ftemp = 0 } goto _5 _5: ; slot++ } if totalWeight == 0 { break } /* * Find the maximum amount of space we can distribute this pass. */ newDiff = diff slot = 0 for { if !(slot < slots) { break } /* Maximum diff that would cause this slot to * equal its minsize. */ if (*(*TSlotInfo)(unsafe.Pointer(slotPtr + uintptr(slot)*32))).Ftemp == 0 { goto _7 } if slot == 0 { v8 = (*(*TSlotInfo)(unsafe.Pointer(slotPtr + uintptr(slot)*32))).Foffset } else { v8 = (*(*TSlotInfo)(unsafe.Pointer(slotPtr + uintptr(slot)*32))).Foffset - (*(*TSlotInfo)(unsafe.Pointer(slotPtr + uintptr(slot-int64(1))*32))).Foffset } current1 = v8 maxDiff = totalWeight * ((*(*TSlotInfo)(unsafe.Pointer(slotPtr + uintptr(slot)*32))).FminSize - current1) / (*(*TSlotInfo)(unsafe.Pointer(slotPtr + uintptr(slot)*32))).Ftemp if maxDiff > newDiff { newDiff = maxDiff } goto _7 _7: ; slot++ } /* * Now distribute the space. */ weight = 0 slot = 0 for { if !(slot < slots) { break } weight += (*(*TSlotInfo)(unsafe.Pointer(slotPtr + uintptr(slot)*32))).Ftemp (*(*TSlotInfo)(unsafe.Pointer(slotPtr + uintptr(slot)*32))).Foffset += newDiff * weight / totalWeight goto _9 _9: ; slot++ } diff -= newDiff } return size } /* *---------------------------------------------------------------------- * * AdjustForSticky -- * * This procedure adjusts the size of a content in its cavity based on its * "sticky" flags. * * Results: * The input x, y, width, and height are changed to represent the desired * coordinates of the content. * * Side effects: * None. * *---------------------------------------------------------------------- */ func _AdjustForSticky(tls *libc.TLS, contentPtr uintptr, xPtr uintptr, yPtr uintptr, widthPtr uintptr, heightPtr uintptr) { /* Height of the cavity (in pixels). */ var diffx, diffy, sticky, v1, v2 int32 _, _, _, _, _ = diffx, diffy, sticky, v1, v2 diffx = 0 /* Cavity width - content width. */ diffy = 0 /* Cavity hight - content height. */ sticky = (*TGridder)(unsafe.Pointer(contentPtr)).Fsticky *(*int32)(unsafe.Pointer(xPtr)) += (*TGridder)(unsafe.Pointer(contentPtr)).FpadLeft *(*int32)(unsafe.Pointer(widthPtr)) -= (*TGridder)(unsafe.Pointer(contentPtr)).FpadX *(*int32)(unsafe.Pointer(yPtr)) += (*TGridder)(unsafe.Pointer(contentPtr)).FpadTop *(*int32)(unsafe.Pointer(heightPtr)) -= (*TGridder)(unsafe.Pointer(contentPtr)).FpadY if *(*int32)(unsafe.Pointer(widthPtr)) > (*TTk_FakeWin)(unsafe.Pointer((*TGridder)(unsafe.Pointer(contentPtr)).Ftkwin)).FreqWidth+(*TGridder)(unsafe.Pointer(contentPtr)).FiPadX { diffx = *(*int32)(unsafe.Pointer(widthPtr)) - ((*TTk_FakeWin)(unsafe.Pointer((*TGridder)(unsafe.Pointer(contentPtr)).Ftkwin)).FreqWidth + (*TGridder)(unsafe.Pointer(contentPtr)).FiPadX) *(*int32)(unsafe.Pointer(widthPtr)) = (*TTk_FakeWin)(unsafe.Pointer((*TGridder)(unsafe.Pointer(contentPtr)).Ftkwin)).FreqWidth + (*TGridder)(unsafe.Pointer(contentPtr)).FiPadX } if *(*int32)(unsafe.Pointer(heightPtr)) > (*TTk_FakeWin)(unsafe.Pointer((*TGridder)(unsafe.Pointer(contentPtr)).Ftkwin)).FreqHeight+(*TGridder)(unsafe.Pointer(contentPtr)).FiPadY { diffy = *(*int32)(unsafe.Pointer(heightPtr)) - ((*TTk_FakeWin)(unsafe.Pointer((*TGridder)(unsafe.Pointer(contentPtr)).Ftkwin)).FreqHeight + (*TGridder)(unsafe.Pointer(contentPtr)).FiPadY) *(*int32)(unsafe.Pointer(heightPtr)) = (*TTk_FakeWin)(unsafe.Pointer((*TGridder)(unsafe.Pointer(contentPtr)).Ftkwin)).FreqHeight + (*TGridder)(unsafe.Pointer(contentPtr)).FiPadY } if sticky&int32(STICK_EAST) != 0 && sticky&int32(STICK_WEST) != 0 { *(*int32)(unsafe.Pointer(widthPtr)) += diffx } if sticky&int32(STICK_NORTH) != 0 && sticky&int32(STICK_SOUTH) != 0 { *(*int32)(unsafe.Pointer(heightPtr)) += diffy } if !(sticky&libc.Int32FromInt32(STICK_WEST) != 0) { if sticky&int32(STICK_EAST) != 0 { v1 = diffx } else { v1 = diffx / int32(2) } *(*int32)(unsafe.Pointer(xPtr)) += v1 } if !(sticky&libc.Int32FromInt32(STICK_NORTH) != 0) { if sticky&int32(STICK_SOUTH) != 0 { v2 = diffy } else { v2 = diffy / int32(2) } *(*int32)(unsafe.Pointer(yPtr)) += v2 } } /* *---------------------------------------------------------------------- * * ArrangeGrid -- * * This procedure is invoked (using the Tcl_DoWhenIdle mechanism) to * re-layout a set of windows managed by the grid. It is invoked at idle * time so that a series of grid requests can be merged into a single * layout operation. * * Results: * None. * * Side effects: * The content of containerPtr may get resized or moved. * *---------------------------------------------------------------------- */ func _ArrangeGrid(tls *libc.TLS, clientData uintptr) { bp := tls.Alloc(32) defer tls.Free(32) /* Structure describing container whose content * are to be re-layed out. */ var col, realHeight, realWidth, row, usedX, usedY, v1, v2, v4, v5 int32 var containerPtr, contentPtr, slotPtr uintptr var _ /* abort at bp+0 */ int32 var _ /* height at bp+8 */ int32 var _ /* width at bp+4 */ int32 var _ /* x at bp+12 */ int32 var _ /* y at bp+16 */ int32 _, _, _, _, _, _, _, _, _, _, _, _, _ = col, containerPtr, contentPtr, realHeight, realWidth, row, slotPtr, usedX, usedY, v1, v2, v4, v5 containerPtr = clientData slotPtr = (*TGridder)(unsafe.Pointer(containerPtr)).FcontainerDataPtr *(*int32)(unsafe.Pointer(containerPtr + 104)) &= ^libc.Int32FromInt32(REQUESTED_RELAYOUT) /* * If the container has no content anymore, then don't change the container size. * Otherwise there is no way to "relinquish" control over the container * so another geometry manager can take over. */ if (*TGridder)(unsafe.Pointer(containerPtr)).FcontentPtr == libc.UintptrFromInt32(0) { return } if (*TGridder)(unsafe.Pointer(containerPtr)).FcontainerDataPtr == libc.UintptrFromInt32(0) { return } /* * Abort any nested call to ArrangeGrid for this window, since we'll do * everything necessary here, and set up so this call can be aborted if * necessary. */ if (*TGridder)(unsafe.Pointer(containerPtr)).FabortPtr != libc.UintptrFromInt32(0) { *(*int32)(unsafe.Pointer((*TGridder)(unsafe.Pointer(containerPtr)).FabortPtr)) = int32(1) } (*TGridder)(unsafe.Pointer(containerPtr)).FabortPtr = bp *(*int32)(unsafe.Pointer(bp)) = 0 libtcl9_0.XTcl_Preserve(tls, containerPtr) /* * Call the constraint engine to fill in the row and column offsets. */ _SetGridSize(tls, containerPtr) *(*int32)(unsafe.Pointer(bp + 4)) = _ResolveConstraints(tls, containerPtr, int32(COLUMN), 0) *(*int32)(unsafe.Pointer(bp + 8)) = _ResolveConstraints(tls, containerPtr, int32(ROW), 0) *(*int32)(unsafe.Pointer(bp + 4)) += (*TTk_FakeWin)(unsafe.Pointer((*TGridder)(unsafe.Pointer(containerPtr)).Ftkwin)).FinternalBorderLeft + (*TTk_FakeWin)(unsafe.Pointer((*TGridder)(unsafe.Pointer(containerPtr)).Ftkwin)).FinternalBorderRight *(*int32)(unsafe.Pointer(bp + 8)) += (*TTk_FakeWin)(unsafe.Pointer((*TGridder)(unsafe.Pointer(containerPtr)).Ftkwin)).FinternalBorderTop + (*TTk_FakeWin)(unsafe.Pointer((*TGridder)(unsafe.Pointer(containerPtr)).Ftkwin)).FinternalBorderBottom if *(*int32)(unsafe.Pointer(bp + 4)) < (*TTk_FakeWin)(unsafe.Pointer((*TGridder)(unsafe.Pointer(containerPtr)).Ftkwin)).FminReqWidth { *(*int32)(unsafe.Pointer(bp + 4)) = (*TTk_FakeWin)(unsafe.Pointer((*TGridder)(unsafe.Pointer(containerPtr)).Ftkwin)).FminReqWidth } if *(*int32)(unsafe.Pointer(bp + 8)) < (*TTk_FakeWin)(unsafe.Pointer((*TGridder)(unsafe.Pointer(containerPtr)).Ftkwin)).FminReqHeight { *(*int32)(unsafe.Pointer(bp + 8)) = (*TTk_FakeWin)(unsafe.Pointer((*TGridder)(unsafe.Pointer(containerPtr)).Ftkwin)).FminReqHeight } if (*(*int32)(unsafe.Pointer(bp + 4)) != (*TTk_FakeWin)(unsafe.Pointer((*TGridder)(unsafe.Pointer(containerPtr)).Ftkwin)).FreqWidth || *(*int32)(unsafe.Pointer(bp + 8)) != (*TTk_FakeWin)(unsafe.Pointer((*TGridder)(unsafe.Pointer(containerPtr)).Ftkwin)).FreqHeight) && !((*TGridder)(unsafe.Pointer(containerPtr)).Fflags&libc.Int32FromInt32(DONT_PROPAGATE) != 0) { XTk_GeometryRequest(tls, (*TGridder)(unsafe.Pointer(containerPtr)).Ftkwin, *(*int32)(unsafe.Pointer(bp + 4)), *(*int32)(unsafe.Pointer(bp + 8))) if *(*int32)(unsafe.Pointer(bp + 4)) > int32(1) && *(*int32)(unsafe.Pointer(bp + 8)) > int32(1) { *(*int32)(unsafe.Pointer(containerPtr + 104)) |= int32(REQUESTED_RELAYOUT) libtcl9_0.XTcl_DoWhenIdle(tls, __ccgo_fp(_ArrangeGrid), containerPtr) } (*TGridder)(unsafe.Pointer(containerPtr)).FabortPtr = libc.UintptrFromInt32(0) libtcl9_0.XTcl_Release(tls, containerPtr) return } /* * If the currently requested layout size doesn't match the container's * window size, then adjust the slot offsets according to the weights. If * all of the weights are zero, place the layout according to the anchor * value. */ realWidth = (*TTk_FakeWin)(unsafe.Pointer((*TGridder)(unsafe.Pointer(containerPtr)).Ftkwin)).Fchanges.Fwidth - (*TTk_FakeWin)(unsafe.Pointer((*TGridder)(unsafe.Pointer(containerPtr)).Ftkwin)).FinternalBorderLeft - (*TTk_FakeWin)(unsafe.Pointer((*TGridder)(unsafe.Pointer(containerPtr)).Ftkwin)).FinternalBorderRight realHeight = (*TTk_FakeWin)(unsafe.Pointer((*TGridder)(unsafe.Pointer(containerPtr)).Ftkwin)).Fchanges.Fheight - (*TTk_FakeWin)(unsafe.Pointer((*TGridder)(unsafe.Pointer(containerPtr)).Ftkwin)).FinternalBorderTop - (*TTk_FakeWin)(unsafe.Pointer((*TGridder)(unsafe.Pointer(containerPtr)).Ftkwin)).FinternalBorderBottom if (*TGridContainer)(unsafe.Pointer(slotPtr)).FcolumnEnd > (*TGridContainer)(unsafe.Pointer(slotPtr)).FcolumnMax { v1 = (*TGridContainer)(unsafe.Pointer(slotPtr)).FcolumnEnd } else { v1 = (*TGridContainer)(unsafe.Pointer(slotPtr)).FcolumnMax } usedX = _AdjustOffsets(tls, realWidth, int64(v1), (*TGridContainer)(unsafe.Pointer(slotPtr)).FcolumnPtr) if (*TGridContainer)(unsafe.Pointer(slotPtr)).FrowEnd > (*TGridContainer)(unsafe.Pointer(slotPtr)).FrowMax { v2 = (*TGridContainer)(unsafe.Pointer(slotPtr)).FrowEnd } else { v2 = (*TGridContainer)(unsafe.Pointer(slotPtr)).FrowMax } usedY = _AdjustOffsets(tls, realHeight, int64(v2), (*TGridContainer)(unsafe.Pointer(slotPtr)).FrowPtr) XTkComputeAnchor(tls, (*TGridContainer)(unsafe.Pointer((*TGridder)(unsafe.Pointer(containerPtr)).FcontainerDataPtr)).Fanchor, (*TGridder)(unsafe.Pointer(containerPtr)).Ftkwin, 0, 0, usedX, usedY, slotPtr+40, slotPtr+44) /* * Now adjust the actual size of the content to its cavity by computing the * cavity size, and adjusting the widget according to its stickyness. */ contentPtr = (*TGridder)(unsafe.Pointer(containerPtr)).FcontentPtr for { if !(contentPtr != libc.UintptrFromInt32(0) && !(*(*int32)(unsafe.Pointer(bp)) != 0)) { break } /* Top left coordinate */ col = (*TGridder)(unsafe.Pointer(contentPtr)).Fcolumn row = (*TGridder)(unsafe.Pointer(contentPtr)).Frow if col > 0 { v4 = (*(*TSlotInfo)(unsafe.Pointer((*TGridContainer)(unsafe.Pointer(slotPtr)).FcolumnPtr + uintptr(col-int32(1))*32))).Foffset } else { v4 = 0 } *(*int32)(unsafe.Pointer(bp + 12)) = v4 if row > 0 { v5 = (*(*TSlotInfo)(unsafe.Pointer((*TGridContainer)(unsafe.Pointer(slotPtr)).FrowPtr + uintptr(row-int32(1))*32))).Foffset } else { v5 = 0 } *(*int32)(unsafe.Pointer(bp + 16)) = v5 *(*int32)(unsafe.Pointer(bp + 4)) = (*(*TSlotInfo)(unsafe.Pointer((*TGridContainer)(unsafe.Pointer(slotPtr)).FcolumnPtr + uintptr((*TGridder)(unsafe.Pointer(contentPtr)).FnumCols+col-int32(1))*32))).Foffset - *(*int32)(unsafe.Pointer(bp + 12)) *(*int32)(unsafe.Pointer(bp + 8)) = (*(*TSlotInfo)(unsafe.Pointer((*TGridContainer)(unsafe.Pointer(slotPtr)).FrowPtr + uintptr((*TGridder)(unsafe.Pointer(contentPtr)).FnumRows+row-int32(1))*32))).Foffset - *(*int32)(unsafe.Pointer(bp + 16)) *(*int32)(unsafe.Pointer(bp + 12)) += (*TGridContainer)(unsafe.Pointer(slotPtr)).FstartX *(*int32)(unsafe.Pointer(bp + 16)) += (*TGridContainer)(unsafe.Pointer(slotPtr)).FstartY _AdjustForSticky(tls, contentPtr, bp+12, bp+16, bp+4, bp+8) /* * Now put the window in the proper spot. (This was taken directly * from tkPack.c.) If the content is a child of the container, then do this * here. Otherwise let Tk_MaintainGeometry do the work. */ if (*TGridder)(unsafe.Pointer(containerPtr)).Ftkwin == (*TTk_FakeWin)(unsafe.Pointer((*TGridder)(unsafe.Pointer(contentPtr)).Ftkwin)).FparentPtr { if *(*int32)(unsafe.Pointer(bp + 4)) <= 0 || *(*int32)(unsafe.Pointer(bp + 8)) <= 0 { XTk_UnmapWindow(tls, (*TGridder)(unsafe.Pointer(contentPtr)).Ftkwin) } else { if *(*int32)(unsafe.Pointer(bp + 12)) != (*TTk_FakeWin)(unsafe.Pointer((*TGridder)(unsafe.Pointer(contentPtr)).Ftkwin)).Fchanges.Fx || *(*int32)(unsafe.Pointer(bp + 16)) != (*TTk_FakeWin)(unsafe.Pointer((*TGridder)(unsafe.Pointer(contentPtr)).Ftkwin)).Fchanges.Fy || *(*int32)(unsafe.Pointer(bp + 4)) != (*TTk_FakeWin)(unsafe.Pointer((*TGridder)(unsafe.Pointer(contentPtr)).Ftkwin)).Fchanges.Fwidth || *(*int32)(unsafe.Pointer(bp + 8)) != (*TTk_FakeWin)(unsafe.Pointer((*TGridder)(unsafe.Pointer(contentPtr)).Ftkwin)).Fchanges.Fheight { XTk_MoveResizeWindow(tls, (*TGridder)(unsafe.Pointer(contentPtr)).Ftkwin, *(*int32)(unsafe.Pointer(bp + 12)), *(*int32)(unsafe.Pointer(bp + 16)), *(*int32)(unsafe.Pointer(bp + 4)), *(*int32)(unsafe.Pointer(bp + 8))) } if *(*int32)(unsafe.Pointer(bp)) != 0 { break } /* * Don't map the content if the container isn't mapped: wait until * the container gets mapped later. */ if (*TTk_FakeWin)(unsafe.Pointer((*TGridder)(unsafe.Pointer(containerPtr)).Ftkwin)).Fflags&uint32(TK_MAPPED) != 0 { XTk_MapWindow(tls, (*TGridder)(unsafe.Pointer(contentPtr)).Ftkwin) } } } else { if *(*int32)(unsafe.Pointer(bp + 4)) <= 0 || *(*int32)(unsafe.Pointer(bp + 8)) <= 0 { XTk_UnmaintainGeometry(tls, (*TGridder)(unsafe.Pointer(contentPtr)).Ftkwin, (*TGridder)(unsafe.Pointer(containerPtr)).Ftkwin) XTk_UnmapWindow(tls, (*TGridder)(unsafe.Pointer(contentPtr)).Ftkwin) } else { XTk_MaintainGeometry(tls, (*TGridder)(unsafe.Pointer(contentPtr)).Ftkwin, (*TGridder)(unsafe.Pointer(containerPtr)).Ftkwin, *(*int32)(unsafe.Pointer(bp + 12)), *(*int32)(unsafe.Pointer(bp + 16)), *(*int32)(unsafe.Pointer(bp + 4)), *(*int32)(unsafe.Pointer(bp + 8))) } } goto _3 _3: ; contentPtr = (*TGridder)(unsafe.Pointer(contentPtr)).FnextPtr } (*TGridder)(unsafe.Pointer(containerPtr)).FabortPtr = libc.UintptrFromInt32(0) libtcl9_0.XTcl_Release(tls, containerPtr) } /* *---------------------------------------------------------------------- * * ResolveConstraints -- * * Resolve all of the column and row boundaries. Most of the calculations * are identical for rows and columns, so this procedure is called twice, * once for rows, and again for columns. * * Results: * The offset (in pixels) from the left/top edge of this layout is * returned. * * Side effects: * The slot offsets are copied into the SlotInfo structure for the * geometry container. * *---------------------------------------------------------------------- */ func _ResolveConstraints(tls *libc.TLS, containerPtr uintptr, slotType int32, maxOffset int32) (r int32) { bp := tls.Alloc(1200) defer tls.Free(1200) /* The actual maximum size of this layout in * pixels, or 0 (not currently used). */ var accWeight, constraintCount, end, gridCount, grow, have, minSize, need, newHave, noWeights, offset, prevGrow, prevMinOffset, require, required, requiredSize, rightEdge, rightEdge1, size, size1, slot, slotCount, span, span1, start, startSlot, totalWeight, uniformGroups, uniformGroupsAlloced, weight, weight1, weight2, v1, v13, v16, v19, v23, v28, v30 int32 var contentPtr, layoutPtr, newUG, oldUG, slotPtr, uniformGroupPtr uintptr var newSize, oldSize Tsize_t var _ /* layoutData at bp+160 */ [26]TGridLayout var _ /* uniformPre at bp+0 */ [10]TUniformGroup _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = accWeight, constraintCount, contentPtr, end, gridCount, grow, have, layoutPtr, minSize, need, newHave, newSize, newUG, noWeights, offset, oldSize, oldUG, prevGrow, prevMinOffset, require, required, requiredSize, rightEdge, rightEdge1, size, size1, slot, slotCount, slotPtr, span, span1, start, startSlot, totalWeight, uniformGroupPtr, uniformGroups, uniformGroupsAlloced, weight, weight1, weight2, v1, v13, v16, v19, v23, v28, v30 if slotType == int32(COLUMN) { constraintCount = (*TGridContainer)(unsafe.Pointer((*TGridder)(unsafe.Pointer(containerPtr)).FcontainerDataPtr)).FcolumnMax slotCount = (*TGridContainer)(unsafe.Pointer((*TGridder)(unsafe.Pointer(containerPtr)).FcontainerDataPtr)).FcolumnEnd slotPtr = (*TGridContainer)(unsafe.Pointer((*TGridder)(unsafe.Pointer(containerPtr)).FcontainerDataPtr)).FcolumnPtr } else { constraintCount = (*TGridContainer)(unsafe.Pointer((*TGridder)(unsafe.Pointer(containerPtr)).FcontainerDataPtr)).FrowMax slotCount = (*TGridContainer)(unsafe.Pointer((*TGridder)(unsafe.Pointer(containerPtr)).FcontainerDataPtr)).FrowEnd slotPtr = (*TGridContainer)(unsafe.Pointer((*TGridder)(unsafe.Pointer(containerPtr)).FcontainerDataPtr)).FrowPtr } /* * Make sure there is enough memory for the layout. */ if constraintCount > slotCount { v1 = constraintCount } else { v1 = slotCount } gridCount = v1 if gridCount >= int32(TYPICAL_SIZE) { layoutPtr = libtcl9_0.XTcl_Alloc(tls, uint64(40)*libc.Uint64FromInt32(libc.Int32FromInt32(1)+gridCount)) } else { layoutPtr = bp + 160 } /* * Allocate an extra layout slot to represent the left/top edge of the 0th * slot to make it easier to calculate slot widths from offsets without * special case code. * * Initialize the "dummy" slot to the left/top of the table. This slot * avoids special casing the first slot. */ (*TGridLayout)(unsafe.Pointer(layoutPtr)).FminOffset = 0 (*TGridLayout)(unsafe.Pointer(layoutPtr)).FmaxOffset = 0 layoutPtr += 40 /* * Step 1. * Copy the slot constraints into the layout structure, and initialize the * rest of the fields. */ slot = 0 for { if !(slot < constraintCount) { break } (*(*TGridLayout)(unsafe.Pointer(layoutPtr + uintptr(slot)*40))).FminSize = (*(*TSlotInfo)(unsafe.Pointer(slotPtr + uintptr(slot)*32))).FminSize (*(*TGridLayout)(unsafe.Pointer(layoutPtr + uintptr(slot)*40))).Fweight = (*(*TSlotInfo)(unsafe.Pointer(slotPtr + uintptr(slot)*32))).Fweight (*(*TGridLayout)(unsafe.Pointer(layoutPtr + uintptr(slot)*40))).Funiform = (*(*TSlotInfo)(unsafe.Pointer(slotPtr + uintptr(slot)*32))).Funiform (*(*TGridLayout)(unsafe.Pointer(layoutPtr + uintptr(slot)*40))).Fpad = (*(*TSlotInfo)(unsafe.Pointer(slotPtr + uintptr(slot)*32))).Fpad (*(*TGridLayout)(unsafe.Pointer(layoutPtr + uintptr(slot)*40))).FbinNextPtr = libc.UintptrFromInt32(0) goto _2 _2: ; slot++ } for { if !(slot < gridCount) { break } (*(*TGridLayout)(unsafe.Pointer(layoutPtr + uintptr(slot)*40))).FminSize = 0 (*(*TGridLayout)(unsafe.Pointer(layoutPtr + uintptr(slot)*40))).Fweight = 0 (*(*TGridLayout)(unsafe.Pointer(layoutPtr + uintptr(slot)*40))).Funiform = libc.UintptrFromInt32(0) (*(*TGridLayout)(unsafe.Pointer(layoutPtr + uintptr(slot)*40))).Fpad = 0 (*(*TGridLayout)(unsafe.Pointer(layoutPtr + uintptr(slot)*40))).FbinNextPtr = libc.UintptrFromInt32(0) goto _3 _3: ; slot++ } /* * Step 2. * Content with a span of 1 are used to determine the minimum size of each * slot. Content whose span is two or more slots don't contribute to the * minimum size of each slot directly, but can cause slots to grow if * their size exceeds the the sizes of the slots they span. * * Bin all content whose spans are > 1 by their right edges. This allows * the computation on minimum and maximum possible layout sizes at each * slot boundary, without the need to re-sort the content. */ switch slotType { case int32(COLUMN): goto _4 case int32(ROW): goto _5 } goto _6 _4: ; contentPtr = (*TGridder)(unsafe.Pointer(containerPtr)).FcontentPtr _9: ; if !(contentPtr != libc.UintptrFromInt32(0)) { goto _7 } rightEdge = (*TGridder)(unsafe.Pointer(contentPtr)).Fcolumn + (*TGridder)(unsafe.Pointer(contentPtr)).FnumCols - int32(1) (*TGridder)(unsafe.Pointer(contentPtr)).Fsize = (*TTk_FakeWin)(unsafe.Pointer((*TGridder)(unsafe.Pointer(contentPtr)).Ftkwin)).FreqWidth + (*TGridder)(unsafe.Pointer(contentPtr)).FpadX + (*TGridder)(unsafe.Pointer(contentPtr)).FiPadX + (*TGridder)(unsafe.Pointer(contentPtr)).FdoubleBw if (*TGridder)(unsafe.Pointer(contentPtr)).FnumCols > int32(1) { (*TGridder)(unsafe.Pointer(contentPtr)).FbinNextPtr = (*(*TGridLayout)(unsafe.Pointer(layoutPtr + uintptr(rightEdge)*40))).FbinNextPtr (*(*TGridLayout)(unsafe.Pointer(layoutPtr + uintptr(rightEdge)*40))).FbinNextPtr = contentPtr } else { if rightEdge >= 0 { size = (*TGridder)(unsafe.Pointer(contentPtr)).Fsize + (*(*TGridLayout)(unsafe.Pointer(layoutPtr + uintptr(rightEdge)*40))).Fpad if size > (*(*TGridLayout)(unsafe.Pointer(layoutPtr + uintptr(rightEdge)*40))).FminSize { (*(*TGridLayout)(unsafe.Pointer(layoutPtr + uintptr(rightEdge)*40))).FminSize = size } } } goto _8 _8: ; contentPtr = (*TGridder)(unsafe.Pointer(contentPtr)).FnextPtr goto _9 goto _7 _7: ; goto _6 _5: ; contentPtr = (*TGridder)(unsafe.Pointer(containerPtr)).FcontentPtr for { if !(contentPtr != libc.UintptrFromInt32(0)) { break } rightEdge1 = (*TGridder)(unsafe.Pointer(contentPtr)).Frow + (*TGridder)(unsafe.Pointer(contentPtr)).FnumRows - int32(1) (*TGridder)(unsafe.Pointer(contentPtr)).Fsize = (*TTk_FakeWin)(unsafe.Pointer((*TGridder)(unsafe.Pointer(contentPtr)).Ftkwin)).FreqHeight + (*TGridder)(unsafe.Pointer(contentPtr)).FpadY + (*TGridder)(unsafe.Pointer(contentPtr)).FiPadY + (*TGridder)(unsafe.Pointer(contentPtr)).FdoubleBw if (*TGridder)(unsafe.Pointer(contentPtr)).FnumRows > int32(1) { (*TGridder)(unsafe.Pointer(contentPtr)).FbinNextPtr = (*(*TGridLayout)(unsafe.Pointer(layoutPtr + uintptr(rightEdge1)*40))).FbinNextPtr (*(*TGridLayout)(unsafe.Pointer(layoutPtr + uintptr(rightEdge1)*40))).FbinNextPtr = contentPtr } else { if rightEdge1 >= 0 { size1 = (*TGridder)(unsafe.Pointer(contentPtr)).Fsize + (*(*TGridLayout)(unsafe.Pointer(layoutPtr + uintptr(rightEdge1)*40))).Fpad if size1 > (*(*TGridLayout)(unsafe.Pointer(layoutPtr + uintptr(rightEdge1)*40))).FminSize { (*(*TGridLayout)(unsafe.Pointer(layoutPtr + uintptr(rightEdge1)*40))).FminSize = size1 } } } goto _10 _10: ; contentPtr = (*TGridder)(unsafe.Pointer(contentPtr)).FnextPtr } goto _6 _6: ; /* * Step 2b. * Consider demands on uniform sizes. */ uniformGroupPtr = bp uniformGroupsAlloced = int32(UNIFORM_PREALLOC) uniformGroups = 0 slot = 0 for { if !(slot < gridCount) { break } if (*(*TGridLayout)(unsafe.Pointer(layoutPtr + uintptr(slot)*40))).Funiform != libc.UintptrFromInt32(0) { start = 0 for { if !(start < uniformGroups) { break } if (*(*TUniformGroup)(unsafe.Pointer(uniformGroupPtr + uintptr(start)*16))).Fgroup == (*(*TGridLayout)(unsafe.Pointer(layoutPtr + uintptr(slot)*40))).Funiform { break } goto _12 _12: ; start++ } if start >= uniformGroups { /* * Have not seen that group before, set up data for it. */ if uniformGroups >= uniformGroupsAlloced { /* * We need to allocate more space. */ oldSize = libc.Uint64FromInt32(uniformGroupsAlloced) * uint64(16) newSize = libc.Uint64FromInt32(uniformGroupsAlloced+libc.Int32FromInt32(UNIFORM_PREALLOC)) * uint64(16) newUG = libtcl9_0.XTcl_Alloc(tls, newSize) oldUG = uniformGroupPtr libc.Xmemcpy(tls, newUG, oldUG, oldSize) if oldUG != bp { libtcl9_0.XTcl_Free(tls, oldUG) } uniformGroupPtr = newUG uniformGroupsAlloced += int32(UNIFORM_PREALLOC) } uniformGroups++ (*(*TUniformGroup)(unsafe.Pointer(uniformGroupPtr + uintptr(start)*16))).Fgroup = (*(*TGridLayout)(unsafe.Pointer(layoutPtr + uintptr(slot)*40))).Funiform (*(*TUniformGroup)(unsafe.Pointer(uniformGroupPtr + uintptr(start)*16))).FminSize = 0 } weight = (*(*TGridLayout)(unsafe.Pointer(layoutPtr + uintptr(slot)*40))).Fweight if weight > 0 { v13 = weight } else { v13 = int32(1) } weight = v13 minSize = ((*(*TGridLayout)(unsafe.Pointer(layoutPtr + uintptr(slot)*40))).FminSize + weight - int32(1)) / weight if minSize > (*(*TUniformGroup)(unsafe.Pointer(uniformGroupPtr + uintptr(start)*16))).FminSize { (*(*TUniformGroup)(unsafe.Pointer(uniformGroupPtr + uintptr(start)*16))).FminSize = minSize } } goto _11 _11: ; slot++ } /* * Data has been gathered about uniform groups. Now relayout accordingly. */ if uniformGroups > 0 { slot = 0 for { if !(slot < gridCount) { break } if (*(*TGridLayout)(unsafe.Pointer(layoutPtr + uintptr(slot)*40))).Funiform != libc.UintptrFromInt32(0) { start = 0 for { if !(start < uniformGroups) { break } if (*(*TUniformGroup)(unsafe.Pointer(uniformGroupPtr + uintptr(start)*16))).Fgroup == (*(*TGridLayout)(unsafe.Pointer(layoutPtr + uintptr(slot)*40))).Funiform { weight1 = (*(*TGridLayout)(unsafe.Pointer(layoutPtr + uintptr(slot)*40))).Fweight if weight1 > 0 { v16 = weight1 } else { v16 = int32(1) } weight1 = v16 (*(*TGridLayout)(unsafe.Pointer(layoutPtr + uintptr(slot)*40))).FminSize = (*(*TUniformGroup)(unsafe.Pointer(uniformGroupPtr + uintptr(start)*16))).FminSize * weight1 break } goto _15 _15: ; start++ } } goto _14 _14: ; slot++ } } if uniformGroupPtr != bp { libtcl9_0.XTcl_Free(tls, uniformGroupPtr) } /* * Step 3. * Determine the minimum slot offsets going from left to right that would * fit all of the content. This determines the minimum */ offset = 0 slot = libc.Int32FromInt32(0) for { if !(slot < gridCount) { break } (*(*TGridLayout)(unsafe.Pointer(layoutPtr + uintptr(slot)*40))).FminOffset = (*(*TGridLayout)(unsafe.Pointer(layoutPtr + uintptr(slot)*40))).FminSize + offset contentPtr = (*(*TGridLayout)(unsafe.Pointer(layoutPtr + uintptr(slot)*40))).FbinNextPtr for { if !(contentPtr != libc.UintptrFromInt32(0)) { break } if slotType == int32(COLUMN) { v19 = (*TGridder)(unsafe.Pointer(contentPtr)).FnumCols } else { v19 = (*TGridder)(unsafe.Pointer(contentPtr)).FnumRows } span = v19 required = (*TGridder)(unsafe.Pointer(contentPtr)).Fsize + (*(*TGridLayout)(unsafe.Pointer(layoutPtr + uintptr(slot-span)*40))).FminOffset if required > (*(*TGridLayout)(unsafe.Pointer(layoutPtr + uintptr(slot)*40))).FminOffset { (*(*TGridLayout)(unsafe.Pointer(layoutPtr + uintptr(slot)*40))).FminOffset = required } goto _18 _18: ; contentPtr = (*TGridder)(unsafe.Pointer(contentPtr)).FbinNextPtr } offset = (*(*TGridLayout)(unsafe.Pointer(layoutPtr + uintptr(slot)*40))).FminOffset goto _17 _17: ; slot++ } /* * At this point, we know the minimum required size of the entire layout. * It might be prudent to stop here if our "container" will resize itself to * this size. */ requiredSize = offset if maxOffset > offset { offset = maxOffset } /* * Step 4. * Determine the minimum slot offsets going from right to left, bounding * the pixel range of each slot boundary. Pre-fill all of the right * offsets with the actual size of the table; they will be reduced as * required. */ slot = 0 for { if !(slot < gridCount) { break } (*(*TGridLayout)(unsafe.Pointer(layoutPtr + uintptr(slot)*40))).FmaxOffset = offset goto _20 _20: ; slot++ } slot = gridCount - int32(1) for { if !(slot > 0) { break } contentPtr = (*(*TGridLayout)(unsafe.Pointer(layoutPtr + uintptr(slot)*40))).FbinNextPtr for { if !(contentPtr != libc.UintptrFromInt32(0)) { break } if slotType == int32(COLUMN) { v23 = (*TGridder)(unsafe.Pointer(contentPtr)).FnumCols } else { v23 = (*TGridder)(unsafe.Pointer(contentPtr)).FnumRows } span1 = v23 require = offset - (*TGridder)(unsafe.Pointer(contentPtr)).Fsize startSlot = slot - span1 if startSlot >= 0 && require < (*(*TGridLayout)(unsafe.Pointer(layoutPtr + uintptr(startSlot)*40))).FmaxOffset { (*(*TGridLayout)(unsafe.Pointer(layoutPtr + uintptr(startSlot)*40))).FmaxOffset = require } goto _22 _22: ; contentPtr = (*TGridder)(unsafe.Pointer(contentPtr)).FbinNextPtr } offset -= (*(*TGridLayout)(unsafe.Pointer(layoutPtr + uintptr(slot)*40))).FminSize slot-- if (*(*TGridLayout)(unsafe.Pointer(layoutPtr + uintptr(slot)*40))).FmaxOffset < offset { offset = (*(*TGridLayout)(unsafe.Pointer(layoutPtr + uintptr(slot)*40))).FmaxOffset } else { (*(*TGridLayout)(unsafe.Pointer(layoutPtr + uintptr(slot)*40))).FmaxOffset = offset } goto _21 _21: } /* * Step 5. * At this point, each slot boundary has a range of values that will * satisfy the overall layout size. Make repeated passes over the layout * structure looking for spans of slot boundaries where the minOffsets are * less than the maxOffsets, and adjust the offsets according to the slot * weights. At each pass, at least one slot boundary will have its range * of possible values fixed at a single value. */ start = 0 for { if !(start < gridCount) { break } totalWeight = 0 /* Sum of the weights for all of the slots in * this span. */ need = 0 /* Cumulative weights of the columns in this * span. */ noWeights = 0 /* True if the span has no weights. */ /* * Find a span by identifying ranges of slots whose edges are already * constrained at fixed offsets, but whose internal slot boundaries * have a range of possible positions. */ if (*(*TGridLayout)(unsafe.Pointer(layoutPtr + uintptr(start)*40))).FminOffset == (*(*TGridLayout)(unsafe.Pointer(layoutPtr + uintptr(start)*40))).FmaxOffset { start++ goto _24 } end = start + int32(1) for { if !(end < gridCount) { break } if (*(*TGridLayout)(unsafe.Pointer(layoutPtr + uintptr(end)*40))).FminOffset == (*(*TGridLayout)(unsafe.Pointer(layoutPtr + uintptr(end)*40))).FmaxOffset { break } goto _25 _25: ; end++ } /* * We found a span. Compute the total weight, minumum space required, * for this span, and the actual amount of space the span should use. */ slot = start for { if !(slot <= end) { break } totalWeight += (*(*TGridLayout)(unsafe.Pointer(layoutPtr + uintptr(slot)*40))).Fweight need += (*(*TGridLayout)(unsafe.Pointer(layoutPtr + uintptr(slot)*40))).FminSize goto _26 _26: ; slot++ } have = (*(*TGridLayout)(unsafe.Pointer(layoutPtr + uintptr(end)*40))).FmaxOffset - (*(*TGridLayout)(unsafe.Pointer(layoutPtr + uintptr(start-int32(1))*40))).FminOffset /* * If all the weights in the span are zero, then distribute the extra * space evenly. */ if totalWeight == 0 { noWeights++ totalWeight = end - start + int32(1) } /* * It might not be possible to give the span all of the space * available on this pass without violating the size constraints of * one or more of the internal slot boundaries. Try to determine the * maximum amount of space that when added to the entire span, would * cause a slot boundary to have its possible range reduced to one * value, and reduce the amount of extra space allocated on this pass * accordingly. * * The calculation is done cumulatively to avoid accumulating roundoff * errors. */ for cond := true; cond; cond = slot <= end { prevMinOffset = (*(*TGridLayout)(unsafe.Pointer(layoutPtr + uintptr(start-int32(1))*40))).FminOffset prevGrow = 0 accWeight = 0 slot = start for { if !(slot <= end) { break } if noWeights != 0 { v28 = int32(1) } else { v28 = (*(*TGridLayout)(unsafe.Pointer(layoutPtr + uintptr(slot)*40))).Fweight } weight2 = v28 accWeight += weight2 grow = (have-need)*accWeight/totalWeight - prevGrow prevGrow += grow if weight2 > 0 && prevMinOffset+(*(*TGridLayout)(unsafe.Pointer(layoutPtr + uintptr(slot)*40))).FminSize+grow > (*(*TGridLayout)(unsafe.Pointer(layoutPtr + uintptr(slot)*40))).FmaxOffset { /* * There is not enough room to grow that much. Calculate * how much this slot can grow and how much "have" that * corresponds to. */ grow = (*(*TGridLayout)(unsafe.Pointer(layoutPtr + uintptr(slot)*40))).FmaxOffset - (*(*TGridLayout)(unsafe.Pointer(layoutPtr + uintptr(slot)*40))).FminSize - prevMinOffset newHave = grow * totalWeight / weight2 if newHave > totalWeight { /* * By distributing multiples of totalWeight we * minimize rounding errors since they will only * happen in the last loop(s). */ newHave = newHave / totalWeight * totalWeight } if newHave <= 0 { /* * We can end up with a "have" of 0 here if the * previous slots have taken all the space. In that * case we cannot guess an appropriate "have" so we * just try some lower "have" that is >= 1, to make * sure this terminates. */ newHave = have - need - int32(1) if newHave > int32(3)*totalWeight { /* * Go down 25% for large values. */ newHave = newHave * int32(3) / int32(4) } if newHave > totalWeight { /* * Round down to a multiple of totalWeight. */ newHave = newHave / totalWeight * totalWeight } if newHave <= 0 { newHave = int32(1) } } have = newHave + need /* * Restart loop to check if the new "have" will fit. */ break } prevMinOffset += (*(*TGridLayout)(unsafe.Pointer(layoutPtr + uintptr(slot)*40))).FminSize + grow if prevMinOffset < (*(*TGridLayout)(unsafe.Pointer(layoutPtr + uintptr(slot)*40))).FminOffset { prevMinOffset = (*(*TGridLayout)(unsafe.Pointer(layoutPtr + uintptr(slot)*40))).FminOffset } goto _27 _27: ; slot++ } /* * Quit the outer loop if the inner loop ran all the way. */ } /* * Now distribute the extra space among the slots by adjusting the * minSizes and minOffsets. */ prevGrow = 0 accWeight = 0 slot = start for { if !(slot <= end) { break } if noWeights != 0 { v30 = int32(1) } else { v30 = (*(*TGridLayout)(unsafe.Pointer(layoutPtr + uintptr(slot)*40))).Fweight } accWeight += v30 grow = (have-need)*accWeight/totalWeight - prevGrow prevGrow += grow (*(*TGridLayout)(unsafe.Pointer(layoutPtr + uintptr(slot)*40))).FminSize += grow if (*(*TGridLayout)(unsafe.Pointer(layoutPtr + uintptr(slot-int32(1))*40))).FminOffset+(*(*TGridLayout)(unsafe.Pointer(layoutPtr + uintptr(slot)*40))).FminSize > (*(*TGridLayout)(unsafe.Pointer(layoutPtr + uintptr(slot)*40))).FminOffset { (*(*TGridLayout)(unsafe.Pointer(layoutPtr + uintptr(slot)*40))).FminOffset = (*(*TGridLayout)(unsafe.Pointer(layoutPtr + uintptr(slot-int32(1))*40))).FminOffset + (*(*TGridLayout)(unsafe.Pointer(layoutPtr + uintptr(slot)*40))).FminSize } goto _29 _29: ; slot++ } /* * Having pushed the top/left boundaries of the slots to take up extra * space, the bottom/right space is recalculated to propagate the new * space allocation. */ slot = end for { if !(slot > start) { break } /* * maxOffset may not go up. */ if (*(*TGridLayout)(unsafe.Pointer(layoutPtr + uintptr(slot)*40))).FmaxOffset-(*(*TGridLayout)(unsafe.Pointer(layoutPtr + uintptr(slot)*40))).FminSize < (*(*TGridLayout)(unsafe.Pointer(layoutPtr + uintptr(slot-int32(1))*40))).FmaxOffset { (*(*TGridLayout)(unsafe.Pointer(layoutPtr + uintptr(slot-int32(1))*40))).FmaxOffset = (*(*TGridLayout)(unsafe.Pointer(layoutPtr + uintptr(slot)*40))).FmaxOffset - (*(*TGridLayout)(unsafe.Pointer(layoutPtr + uintptr(slot)*40))).FminSize } goto _31 _31: ; slot-- } goto _24 _24: } /* * Step 6. * All of the space has been apportioned; copy the layout information back * into the container. */ slot = 0 for { if !(slot < gridCount) { break } (*(*TSlotInfo)(unsafe.Pointer(slotPtr + uintptr(slot)*32))).Foffset = (*(*TGridLayout)(unsafe.Pointer(layoutPtr + uintptr(slot)*40))).FminOffset goto _32 _32: ; slot++ } layoutPtr -= 40 if layoutPtr != bp+160 { libtcl9_0.XTcl_Free(tls, layoutPtr) } return requiredSize } /* *---------------------------------------------------------------------- * * GetGrid -- * * This internal procedure is used to locate a Grid structure for a given * window, creating one if one doesn't exist already, except if the window * is already dead. * * Results: * The return value is a pointer to the Grid structure corresponding to * tkwin, or NULL when tkwin is already dead. * * Side effects: * A new grid structure may be created. If so, then a callback is set up * to clean things up when the window is deleted. * *---------------------------------------------------------------------- */ func _GetGrid(tls *libc.TLS, tkwin TTk_Window) (r uintptr) { bp := tls.Alloc(16) defer tls.Free(16) /* Token for window for which grid structure * is desired. */ var dispPtr, gridPtr, hPtr uintptr var _ /* isNew at bp+0 */ int32 _, _, _ = dispPtr, gridPtr, hPtr dispPtr = (*TTkWindow)(unsafe.Pointer(tkwin)).FdispPtr if (*TTkWindow)(unsafe.Pointer(tkwin)).Fflags&uint32(TK_ALREADY_DEAD) != 0 { return libc.UintptrFromInt32(0) } if !((*TTkDisplay)(unsafe.Pointer(dispPtr)).FgridInit != 0) { libtcl9_0.XTcl_InitHashTable(tls, dispPtr+1848, int32(TCL_ONE_WORD_KEYS)) (*TTkDisplay)(unsafe.Pointer(dispPtr)).FgridInit = int32(1) } /* * See if there's already grid for this window. If not, then create a new * one. */ hPtr = (*(*func(*libc.TLS, uintptr, uintptr, uintptr) uintptr)(unsafe.Pointer(&struct{ uintptr }{(*TTcl_HashTable)(unsafe.Pointer(dispPtr + 1848)).FcreateProc})))(tls, dispPtr+1848, tkwin, bp) if !(*(*int32)(unsafe.Pointer(bp)) != 0) { return (*TTcl_HashEntry)(unsafe.Pointer(hPtr)).FclientData } gridPtr = libtcl9_0.XTcl_Alloc(tls, uint64(128)) (*TGridder)(unsafe.Pointer(gridPtr)).Ftkwin = tkwin (*TGridder)(unsafe.Pointer(gridPtr)).FcontainerPtr = libc.UintptrFromInt32(0) (*TGridder)(unsafe.Pointer(gridPtr)).FcontainerDataPtr = libc.UintptrFromInt32(0) (*TGridder)(unsafe.Pointer(gridPtr)).FnextPtr = libc.UintptrFromInt32(0) (*TGridder)(unsafe.Pointer(gridPtr)).FcontentPtr = libc.UintptrFromInt32(0) (*TGridder)(unsafe.Pointer(gridPtr)).FbinNextPtr = libc.UintptrFromInt32(0) (*TGridder)(unsafe.Pointer(gridPtr)).Fcolumn = -int32(1) (*TGridder)(unsafe.Pointer(gridPtr)).Frow = -int32(1) (*TGridder)(unsafe.Pointer(gridPtr)).FnumCols = int32(1) (*TGridder)(unsafe.Pointer(gridPtr)).FnumRows = int32(1) (*TGridder)(unsafe.Pointer(gridPtr)).FpadX = 0 (*TGridder)(unsafe.Pointer(gridPtr)).FpadY = 0 (*TGridder)(unsafe.Pointer(gridPtr)).FpadLeft = 0 (*TGridder)(unsafe.Pointer(gridPtr)).FpadTop = 0 (*TGridder)(unsafe.Pointer(gridPtr)).FiPadX = 0 (*TGridder)(unsafe.Pointer(gridPtr)).FiPadY = 0 (*TGridder)(unsafe.Pointer(gridPtr)).FdoubleBw = int32(2) * (*TXWindowChanges)(unsafe.Pointer(tkwin+112)).Fborder_width (*TGridder)(unsafe.Pointer(gridPtr)).FabortPtr = libc.UintptrFromInt32(0) (*TGridder)(unsafe.Pointer(gridPtr)).Fflags = 0 (*TGridder)(unsafe.Pointer(gridPtr)).Fsticky = 0 (*TGridder)(unsafe.Pointer(gridPtr)).Fsize = 0 (*TGridder)(unsafe.Pointer(gridPtr)).Fin = libc.UintptrFromInt32(0) (*TTcl_HashEntry)(unsafe.Pointer(hPtr)).FclientData = gridPtr XTk_CreateEventHandler(tls, tkwin, libc.Uint64FromInt64(libc.Int64FromInt64(1)< (*TGridder)(unsafe.Pointer(contentPtr)).FnumCols+(*TGridder)(unsafe.Pointer(contentPtr)).Fcolumn { v2 = maxX } else { v2 = (*TGridder)(unsafe.Pointer(contentPtr)).FnumCols + (*TGridder)(unsafe.Pointer(contentPtr)).Fcolumn } maxX = v2 if maxY > (*TGridder)(unsafe.Pointer(contentPtr)).FnumRows+(*TGridder)(unsafe.Pointer(contentPtr)).Frow { v3 = maxY } else { v3 = (*TGridder)(unsafe.Pointer(contentPtr)).FnumRows + (*TGridder)(unsafe.Pointer(contentPtr)).Frow } maxY = v3 goto _1 _1: ; contentPtr = (*TGridder)(unsafe.Pointer(contentPtr)).FnextPtr } (*TGridContainer)(unsafe.Pointer((*TGridder)(unsafe.Pointer(containerPtr)).FcontainerDataPtr)).FcolumnEnd = maxX (*TGridContainer)(unsafe.Pointer((*TGridder)(unsafe.Pointer(containerPtr)).FcontainerDataPtr)).FrowEnd = maxY _CheckSlotData(tls, containerPtr, int64(maxX), int32(COLUMN), int32(CHECK_SPACE)) _CheckSlotData(tls, containerPtr, int64(maxY), int32(ROW), int32(CHECK_SPACE)) } /* *---------------------------------------------------------------------- * * SetContentColumn -- * * Update column data for a content, checking that MAX_ELEMENT bound * is not passed. * * Results: * TCL_ERROR if out of bounds, TCL_OK otherwise * * Side effects: * Content fields are updated. * *---------------------------------------------------------------------- */ func _SetContentColumn(tls *libc.TLS, interp uintptr, contentPtr uintptr, column int32, numCols int32) (r int32) { bp := tls.Alloc(48) defer tls.Free(48) /* New columnspan or -1 to be unchanged. */ var lastCol, newColumn, newNumCols, v1, v2, v3 int32 _, _, _, _, _, _ = lastCol, newColumn, newNumCols, v1, v2, v3 if column >= 0 { v1 = column } else { v1 = (*TGridder)(unsafe.Pointer(contentPtr)).Fcolumn } newColumn = v1 if numCols >= int32(1) { v2 = numCols } else { v2 = (*TGridder)(unsafe.Pointer(contentPtr)).FnumCols } newNumCols = v2 if newColumn >= 0 { v3 = newColumn } else { v3 = 0 } lastCol = v3 + newNumCols if lastCol >= int32(MAX_ELEMENT) { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+12802, int64(-libc.Int32FromInt32(1)))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+8, __ccgo_ts+179, __ccgo_ts+12459, __ccgo_ts+12823, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) } (*TGridder)(unsafe.Pointer(contentPtr)).Fcolumn = newColumn (*TGridder)(unsafe.Pointer(contentPtr)).FnumCols = newNumCols return TCL_OK } /* *---------------------------------------------------------------------- * * SetContentRow -- * * Update row data for a content, checking that MAX_ELEMENT bound * is not passed. * * Results: * TCL_ERROR if out of bounds, TCL_OK otherwise * * Side effects: * Content fields are updated. * *---------------------------------------------------------------------- */ func _SetContentRow(tls *libc.TLS, interp uintptr, contentPtr uintptr, row int32, numRows int32) (r int32) { bp := tls.Alloc(48) defer tls.Free(48) /* New rowspan or -1 to be unchanged. */ var lastRow, newNumRows, newRow, v1, v2, v3 int32 _, _, _, _, _, _ = lastRow, newNumRows, newRow, v1, v2, v3 if row >= 0 { v1 = row } else { v1 = (*TGridder)(unsafe.Pointer(contentPtr)).Frow } newRow = v1 if numRows >= int32(1) { v2 = numRows } else { v2 = (*TGridder)(unsafe.Pointer(contentPtr)).FnumRows } newNumRows = v2 if newRow >= 0 { v3 = newRow } else { v3 = 0 } lastRow = v3 + newNumRows if lastRow >= int32(MAX_ELEMENT) { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+12834, int64(-libc.Int32FromInt32(1)))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+8, __ccgo_ts+179, __ccgo_ts+12459, __ccgo_ts+12852, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) } (*TGridder)(unsafe.Pointer(contentPtr)).Frow = newRow (*TGridder)(unsafe.Pointer(contentPtr)).FnumRows = newNumRows return TCL_OK } /* *---------------------------------------------------------------------- * * CheckSlotData -- * * This internal procedure is used to manage the storage for row and * column (slot) constraints. * * Results: * TRUE if the index is OK, False otherwise. * * Side effects: * A new container grid structure may be created. If so, then it is * initialized. In addition, additional storage for a row or column * constraints may be allocated, and the constraint maximums are * adjusted. * *---------------------------------------------------------------------- */ func _CheckSlotData(tls *libc.TLS, containerPtr uintptr, slot TTcl_Size, slotType int32, checkOnly int32) (r int32) { /* Don't allocate new space if true. */ var end, newNumSlot, v1, v2, v3 int32 var newSI, oldSI, v4 uintptr var newSize, oldSize Tsize_t var numSlot TTcl_Size _, _, _, _, _, _, _, _, _, _, _ = end, newNumSlot, newSI, newSize, numSlot, oldSI, oldSize, v1, v2, v3, v4 /* Last used constraint. */ /* * If slot is out of bounds, return immediately. */ if slot < 0 || slot >= int64(MAX_ELEMENT) { return int32(TCL_ERROR) } if checkOnly == int32(CHECK_ONLY) && (*TGridder)(unsafe.Pointer(containerPtr)).FcontainerDataPtr == libc.UintptrFromInt32(0) { return int32(TCL_ERROR) } /* * If we need to allocate more space, allocate a little extra to avoid * repeated re-alloc's for large tables. We need enough space to hold all * of the offsets as well. */ _InitContainerData(tls, containerPtr) if slotType == int32(ROW) { v1 = (*TGridContainer)(unsafe.Pointer((*TGridder)(unsafe.Pointer(containerPtr)).FcontainerDataPtr)).FrowMax } else { v1 = (*TGridContainer)(unsafe.Pointer((*TGridder)(unsafe.Pointer(containerPtr)).FcontainerDataPtr)).FcolumnMax } end = v1 if checkOnly == int32(CHECK_ONLY) { if int64(end) < slot { v2 = int32(TCL_ERROR) } else { v2 = TCL_OK } return v2 } else { if slotType == int32(ROW) { v3 = (*TGridContainer)(unsafe.Pointer((*TGridder)(unsafe.Pointer(containerPtr)).FcontainerDataPtr)).FrowSpace } else { v3 = (*TGridContainer)(unsafe.Pointer((*TGridder)(unsafe.Pointer(containerPtr)).FcontainerDataPtr)).FcolumnSpace } numSlot = int64(v3) if slot >= numSlot { newNumSlot = int32(slot + int64(PREALLOC)) oldSize = libc.Uint64FromInt64(numSlot) * uint64(32) newSize = libc.Uint64FromInt32(newNumSlot) * uint64(32) newSI = libtcl9_0.XTcl_Alloc(tls, newSize) if slotType == int32(ROW) { v4 = (*TGridContainer)(unsafe.Pointer((*TGridder)(unsafe.Pointer(containerPtr)).FcontainerDataPtr)).FrowPtr } else { v4 = (*TGridContainer)(unsafe.Pointer((*TGridder)(unsafe.Pointer(containerPtr)).FcontainerDataPtr)).FcolumnPtr } oldSI = v4 libc.Xmemcpy(tls, newSI, oldSI, oldSize) libc.Xmemset(tls, newSI+uintptr(numSlot)*32, 0, newSize-oldSize) libtcl9_0.XTcl_Free(tls, oldSI) if slotType == int32(ROW) { (*TGridContainer)(unsafe.Pointer((*TGridder)(unsafe.Pointer(containerPtr)).FcontainerDataPtr)).FrowPtr = newSI (*TGridContainer)(unsafe.Pointer((*TGridder)(unsafe.Pointer(containerPtr)).FcontainerDataPtr)).FrowSpace = newNumSlot } else { (*TGridContainer)(unsafe.Pointer((*TGridder)(unsafe.Pointer(containerPtr)).FcontainerDataPtr)).FcolumnPtr = newSI (*TGridContainer)(unsafe.Pointer((*TGridder)(unsafe.Pointer(containerPtr)).FcontainerDataPtr)).FcolumnSpace = newNumSlot } } if slot >= int64(end) && checkOnly != int32(CHECK_SPACE) { if slotType == int32(ROW) { (*TGridContainer)(unsafe.Pointer((*TGridder)(unsafe.Pointer(containerPtr)).FcontainerDataPtr)).FrowMax = int32(slot + int64(1)) } else { (*TGridContainer)(unsafe.Pointer((*TGridder)(unsafe.Pointer(containerPtr)).FcontainerDataPtr)).FcolumnMax = int32(slot + int64(1)) } } return TCL_OK } return r } /* *---------------------------------------------------------------------- * * InitContainerData -- * * This internal procedure is used to allocate and initialize the data * for a geometry container, if the data doesn't exist already. * * Results: * none * * Side effects: * A new container grid structure may be created. If so, then it is * initialized. * *---------------------------------------------------------------------- */ func _InitContainerData(tls *libc.TLS, containerPtr uintptr) { var gridPtr, v1 uintptr var size Tsize_t _, _, _ = gridPtr, size, v1 if (*TGridder)(unsafe.Pointer(containerPtr)).FcontainerDataPtr == libc.UintptrFromInt32(0) { v1 = libtcl9_0.XTcl_Alloc(tls, uint64(56)) (*TGridder)(unsafe.Pointer(containerPtr)).FcontainerDataPtr = v1 gridPtr = v1 size = libc.Uint64FromInt64(32) * libc.Uint64FromInt32(TYPICAL_SIZE) (*TGridContainer)(unsafe.Pointer(gridPtr)).FcolumnEnd = 0 (*TGridContainer)(unsafe.Pointer(gridPtr)).FcolumnMax = 0 (*TGridContainer)(unsafe.Pointer(gridPtr)).FcolumnPtr = libtcl9_0.XTcl_Alloc(tls, size) (*TGridContainer)(unsafe.Pointer(gridPtr)).FcolumnSpace = int32(TYPICAL_SIZE) (*TGridContainer)(unsafe.Pointer(gridPtr)).FrowEnd = 0 (*TGridContainer)(unsafe.Pointer(gridPtr)).FrowMax = 0 (*TGridContainer)(unsafe.Pointer(gridPtr)).FrowPtr = libtcl9_0.XTcl_Alloc(tls, size) (*TGridContainer)(unsafe.Pointer(gridPtr)).FrowSpace = int32(TYPICAL_SIZE) (*TGridContainer)(unsafe.Pointer(gridPtr)).FstartX = 0 (*TGridContainer)(unsafe.Pointer(gridPtr)).FstartY = 0 (*TGridContainer)(unsafe.Pointer(gridPtr)).Fanchor = int32(TK_ANCHOR_NW) libc.Xmemset(tls, (*TGridContainer)(unsafe.Pointer(gridPtr)).FcolumnPtr, 0, size) libc.Xmemset(tls, (*TGridContainer)(unsafe.Pointer(gridPtr)).FrowPtr, 0, size) } } /* *---------------------------------------------------------------------- * * Unlink -- * * Remove a grid from its container's list of content. * * Results: * None. * * Side effects: * The container will be scheduled for re-arranging, and the size of the * grid will be adjusted accordingly * *---------------------------------------------------------------------- */ func _Unlink(tls *libc.TLS, contentPtr uintptr) { /* Window to unlink. */ var containerPtr, contentPtr2 uintptr _, _ = containerPtr, contentPtr2 containerPtr = (*TGridder)(unsafe.Pointer(contentPtr)).FcontainerPtr if containerPtr == libc.UintptrFromInt32(0) { return } if (*TGridder)(unsafe.Pointer(containerPtr)).FcontentPtr == contentPtr { (*TGridder)(unsafe.Pointer(containerPtr)).FcontentPtr = (*TGridder)(unsafe.Pointer(contentPtr)).FnextPtr } else { contentPtr2 = (*TGridder)(unsafe.Pointer(containerPtr)).FcontentPtr for { if contentPtr2 == libc.UintptrFromInt32(0) { libtcl9_0.XTcl_Panic(tls, __ccgo_ts+12860, 0) } if (*TGridder)(unsafe.Pointer(contentPtr2)).FnextPtr == contentPtr { (*TGridder)(unsafe.Pointer(contentPtr2)).FnextPtr = (*TGridder)(unsafe.Pointer(contentPtr)).FnextPtr break } goto _1 _1: ; contentPtr2 = (*TGridder)(unsafe.Pointer(contentPtr2)).FnextPtr } } if !((*TGridder)(unsafe.Pointer(containerPtr)).Fflags&libc.Int32FromInt32(REQUESTED_RELAYOUT) != 0) { *(*int32)(unsafe.Pointer(containerPtr + 104)) |= int32(REQUESTED_RELAYOUT) libtcl9_0.XTcl_DoWhenIdle(tls, __ccgo_fp(_ArrangeGrid), containerPtr) } if (*TGridder)(unsafe.Pointer(containerPtr)).FabortPtr != libc.UintptrFromInt32(0) { *(*int32)(unsafe.Pointer((*TGridder)(unsafe.Pointer(containerPtr)).FabortPtr)) = int32(1) } _SetGridSize(tls, (*TGridder)(unsafe.Pointer(contentPtr)).FcontainerPtr) (*TGridder)(unsafe.Pointer(contentPtr)).FcontainerPtr = libc.UintptrFromInt32(0) /* * If we have emptied this container from content it means we are no longer * handling it and should mark it as free. * * Send the event "NoManagedChild" to the container to inform it about there * being no managed children inside it. */ if (*TGridder)(unsafe.Pointer(containerPtr)).FcontentPtr == libc.UintptrFromInt32(0) && (*TGridder)(unsafe.Pointer(containerPtr)).Fflags&int32(ALLOCED_CONTAINER) != 0 { XTkFreeGeometryContainer(tls, (*TGridder)(unsafe.Pointer(containerPtr)).Ftkwin, __ccgo_ts+12090) *(*int32)(unsafe.Pointer(containerPtr + 104)) &= ^libc.Int32FromInt32(ALLOCED_CONTAINER) XTk_SendVirtualEvent(tls, (*TGridder)(unsafe.Pointer(containerPtr)).Ftkwin, __ccgo_ts+12897, libc.UintptrFromInt32(0)) } } /* *---------------------------------------------------------------------- * * DestroyGrid -- * * This procedure is invoked by Tcl_EventuallyFree or Tcl_Release to * clean up the internal structure of a grid at a safe time (when no-one * is using it anymore). Cleaning up the grid involves freeing the main * structure for all windows and the container structure for geometry * managers. * * Results: * None. * * Side effects: * Everything associated with the grid is freed up. * *---------------------------------------------------------------------- */ func _DestroyGrid(tls *libc.TLS, memPtr uintptr) { /* Info about window that is now dead. */ var _objPtr, gridPtr, v2 uintptr var v1 TTcl_Size _, _, _, _ = _objPtr, gridPtr, v1, v2 gridPtr = memPtr if (*TGridder)(unsafe.Pointer(gridPtr)).Fflags&int32(REQUESTED_RELAYOUT) != 0 { libtcl9_0.XTcl_CancelIdleCall(tls, __ccgo_fp(_ArrangeGrid), gridPtr) } if (*TGridder)(unsafe.Pointer(gridPtr)).FcontainerDataPtr != libc.UintptrFromInt32(0) { if (*TGridContainer)(unsafe.Pointer((*TGridder)(unsafe.Pointer(gridPtr)).FcontainerDataPtr)).FrowPtr != libc.UintptrFromInt32(0) { libtcl9_0.XTcl_Free(tls, (*TGridContainer)(unsafe.Pointer((*TGridder)(unsafe.Pointer(gridPtr)).FcontainerDataPtr)).FrowPtr) } if (*TGridContainer)(unsafe.Pointer((*TGridder)(unsafe.Pointer(gridPtr)).FcontainerDataPtr)).FcolumnPtr != libc.UintptrFromInt32(0) { libtcl9_0.XTcl_Free(tls, (*TGridContainer)(unsafe.Pointer((*TGridder)(unsafe.Pointer(gridPtr)).FcontainerDataPtr)).FcolumnPtr) } libtcl9_0.XTcl_Free(tls, (*TGridder)(unsafe.Pointer(gridPtr)).FcontainerDataPtr) } if (*TGridder)(unsafe.Pointer(gridPtr)).Fin != libc.UintptrFromInt32(0) { _objPtr = (*TGridder)(unsafe.Pointer(gridPtr)).Fin v2 = _objPtr v1 = *(*TTcl_Size)(unsafe.Pointer(v2)) *(*TTcl_Size)(unsafe.Pointer(v2))-- if v1 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr) } } libtcl9_0.XTcl_Free(tls, gridPtr) } /* *---------------------------------------------------------------------- * * GridStructureProc -- * * This procedure is invoked by the Tk event dispatcher in response to * StructureNotify events. * * Results: * None. * * Side effects: * If a window was just deleted, clean up all its grid-related * information. If it was just resized, re-configure its content, if any. * *---------------------------------------------------------------------- */ func _GridStructureProc(tls *libc.TLS, clientData uintptr, eventPtr uintptr) { /* Describes what just happened. */ var contentPtr, contentPtr1, dispPtr, gridPtr, nextPtr uintptr _, _, _, _, _ = contentPtr, contentPtr1, dispPtr, gridPtr, nextPtr gridPtr = clientData dispPtr = (*TTkWindow)(unsafe.Pointer((*TGridder)(unsafe.Pointer(gridPtr)).Ftkwin)).FdispPtr if (*TXEvent)(unsafe.Pointer(eventPtr)).Ftype1 == int32(ConfigureNotify) { if (*TGridder)(unsafe.Pointer(gridPtr)).FcontentPtr != libc.UintptrFromInt32(0) && !((*TGridder)(unsafe.Pointer(gridPtr)).Fflags&libc.Int32FromInt32(REQUESTED_RELAYOUT) != 0) { *(*int32)(unsafe.Pointer(gridPtr + 104)) |= int32(REQUESTED_RELAYOUT) libtcl9_0.XTcl_DoWhenIdle(tls, __ccgo_fp(_ArrangeGrid), gridPtr) } if (*TGridder)(unsafe.Pointer(gridPtr)).FcontainerPtr != libc.UintptrFromInt32(0) && (*TGridder)(unsafe.Pointer(gridPtr)).FdoubleBw != int32(2)*(*TXWindowChanges)(unsafe.Pointer((*TGridder)(unsafe.Pointer(gridPtr)).Ftkwin+112)).Fborder_width { if !((*TGridder1)(unsafe.Pointer((*TGridder)(unsafe.Pointer(gridPtr)).FcontainerPtr)).Fflags&libc.Int32FromInt32(REQUESTED_RELAYOUT) != 0) { (*TGridder)(unsafe.Pointer(gridPtr)).FdoubleBw = int32(2) * (*TXWindowChanges)(unsafe.Pointer((*TGridder)(unsafe.Pointer(gridPtr)).Ftkwin+112)).Fborder_width *(*int32)(unsafe.Pointer((*TGridder)(unsafe.Pointer(gridPtr)).FcontainerPtr + 104)) |= int32(REQUESTED_RELAYOUT) libtcl9_0.XTcl_DoWhenIdle(tls, __ccgo_fp(_ArrangeGrid), (*TGridder)(unsafe.Pointer(gridPtr)).FcontainerPtr) } } } else { if (*TXEvent)(unsafe.Pointer(eventPtr)).Ftype1 == int32(DestroyNotify) { if (*TGridder)(unsafe.Pointer(gridPtr)).FcontainerPtr != libc.UintptrFromInt32(0) { _Unlink(tls, gridPtr) } contentPtr = (*TGridder)(unsafe.Pointer(gridPtr)).FcontentPtr for { if !(contentPtr != libc.UintptrFromInt32(0)) { break } XTk_ManageGeometry(tls, (*TGridder)(unsafe.Pointer(contentPtr)).Ftkwin, libc.UintptrFromInt32(0), libc.UintptrFromInt32(0)) XTk_UnmapWindow(tls, (*TGridder)(unsafe.Pointer(contentPtr)).Ftkwin) (*TGridder)(unsafe.Pointer(contentPtr)).FcontainerPtr = libc.UintptrFromInt32(0) nextPtr = (*TGridder)(unsafe.Pointer(contentPtr)).FnextPtr (*TGridder)(unsafe.Pointer(contentPtr)).FnextPtr = libc.UintptrFromInt32(0) goto _1 _1: ; contentPtr = nextPtr } libtcl9_0.XTcl_DeleteHashEntry(tls, (*(*func(*libc.TLS, uintptr, uintptr) uintptr)(unsafe.Pointer(&struct{ uintptr }{(*TTcl_HashTable)(unsafe.Pointer(dispPtr + 1848)).FfindProc})))(tls, dispPtr+1848, (*TGridder)(unsafe.Pointer(gridPtr)).Ftkwin)) if (*TGridder)(unsafe.Pointer(gridPtr)).Fflags&int32(REQUESTED_RELAYOUT) != 0 { libtcl9_0.XTcl_CancelIdleCall(tls, __ccgo_fp(_ArrangeGrid), gridPtr) } (*TGridder)(unsafe.Pointer(gridPtr)).Ftkwin = libc.UintptrFromInt32(0) libtcl9_0.XTcl_EventuallyFree(tls, gridPtr, __ccgo_fp(_DestroyGrid)) } else { if (*TXEvent)(unsafe.Pointer(eventPtr)).Ftype1 == int32(MapNotify) { if (*TGridder)(unsafe.Pointer(gridPtr)).FcontentPtr != libc.UintptrFromInt32(0) && !((*TGridder)(unsafe.Pointer(gridPtr)).Fflags&libc.Int32FromInt32(REQUESTED_RELAYOUT) != 0) { *(*int32)(unsafe.Pointer(gridPtr + 104)) |= int32(REQUESTED_RELAYOUT) libtcl9_0.XTcl_DoWhenIdle(tls, __ccgo_fp(_ArrangeGrid), gridPtr) } } else { if (*TXEvent)(unsafe.Pointer(eventPtr)).Ftype1 == int32(UnmapNotify) { contentPtr1 = (*TGridder)(unsafe.Pointer(gridPtr)).FcontentPtr for { if !(contentPtr1 != libc.UintptrFromInt32(0)) { break } XTk_UnmapWindow(tls, (*TGridder)(unsafe.Pointer(contentPtr1)).Ftkwin) goto _2 _2: ; contentPtr1 = (*TGridder)(unsafe.Pointer(contentPtr1)).FnextPtr } } } } } } /* *---------------------------------------------------------------------- * * ConfigureContent -- * * This implements the guts of the "grid configure" command. Given a list * of content and configuration options, it arranges for the grid to * manage the content and sets the specified options. Arguments consist * of windows or window shortcuts followed by "-option value" pairs. * * Results: * TCL_OK is returned if all went well. Otherwise, TCL_ERROR is returned * and the interp's result is set to contain an error message. * * Side effects: * Content windows get taken over by the grid. * *---------------------------------------------------------------------- */ func _ConfigureContent(tls *libc.TLS, interp uintptr, tkwin TTk_Window, objc TTcl_Size, objv uintptr) (r int32) { bp := tls.Alloc(80) defer tls.Free(80) /* Argument objects: contains one or more * window names followed by any number of * "option value" pairs. Caller must make sure * that there is at least one window name. */ var ancestor TTk_Window var container, containerPtr, contentPtr, lastWindow, otherPtr, string1, tempPtr, v11, v12, v15, v16, v19, v2, v3, v4, v6, v9 uintptr var defaultColumn, defaultColumnSpan, defaultRow, i, j, lastColumn, lastRow, match, numSkip, numWindows, positionGiven, sticky, width int32 var firstChar, prevChar uint8 var _ /* content at bp+8 */ TTk_Window var _ /* index at bp+28 */ int32 var _ /* length at bp+32 */ TTcl_Size var _ /* other at bp+0 */ TTk_Window var _ /* parent at bp+16 */ TTk_Window var _ /* tmp at bp+24 */ int32 _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = ancestor, container, containerPtr, contentPtr, defaultColumn, defaultColumnSpan, defaultRow, firstChar, i, j, lastColumn, lastRow, lastWindow, match, numSkip, numWindows, otherPtr, positionGiven, prevChar, sticky, string1, tempPtr, width, v11, v12, v15, v16, v19, v2, v3, v4, v6, v9 containerPtr = libc.UintptrFromInt32(0) defaultRow = -int32(1) defaultColumn = 0 /* Default column number */ defaultColumnSpan = int32(1) /* Number of 'x' found */ /* * Count the number of windows, or window short-cuts. */ firstChar = uint8(0) numWindows = 0 i = libc.Int32FromInt32(0) for { if !(int64(i) < objc) { break } prevChar = firstChar string1 = libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(i)*8)), bp+32) firstChar = *(*uint8)(unsafe.Pointer(string1)) if libc.Int32FromUint8(firstChar) == int32('.') { /* * Check that windows are valid, and locate the first content's * parent window (default for -in). */ if XTkGetWindowFromObj(tls, interp, tkwin, *(*uintptr)(unsafe.Pointer(objv + uintptr(i)*8)), bp+8) != TCL_OK { return int32(TCL_ERROR) } if containerPtr == libc.UintptrFromInt32(0) { /* * Is there any saved -in from a removed content? * If there is, it becomes default for -in. * If the stored container does not exist, just ignore it. */ v2 = _GetGrid(tls, *(*TTk_Window)(unsafe.Pointer(bp + 8))) contentPtr = v2 if !(v2 != 0) { goto _1 } if (*TGridder)(unsafe.Pointer(contentPtr)).Fin != libc.UintptrFromInt32(0) { if XTkGetWindowFromObj(tls, interp, *(*TTk_Window)(unsafe.Pointer(bp + 8)), (*TGridder)(unsafe.Pointer(contentPtr)).Fin, bp+16) == TCL_OK { v3 = _GetGrid(tls, *(*TTk_Window)(unsafe.Pointer(bp + 16))) containerPtr = v3 if !(v3 != 0) { goto _1 } _InitContainerData(tls, containerPtr) } } } if containerPtr == libc.UintptrFromInt32(0) { *(*TTk_Window)(unsafe.Pointer(bp + 16)) = (*TTk_FakeWin)(unsafe.Pointer(*(*TTk_Window)(unsafe.Pointer(bp + 8)))).FparentPtr if *(*TTk_Window)(unsafe.Pointer(bp + 16)) != libc.UintptrFromInt32(0) { v4 = _GetGrid(tls, *(*TTk_Window)(unsafe.Pointer(bp + 16))) containerPtr = v4 if !(v4 != 0) { goto _1 } _InitContainerData(tls, containerPtr) } } numWindows++ goto _1 } if *(*TTcl_Size)(unsafe.Pointer(bp + 32)) > int64(1) && i == 0 { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+12912, libc.VaList(bp+48, string1))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+48, __ccgo_ts+179, __ccgo_ts+12459, __ccgo_ts+12954, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) } if *(*TTcl_Size)(unsafe.Pointer(bp + 32)) > int64(1) && libc.Int32FromUint8(firstChar) == int32('-') { break } if *(*TTcl_Size)(unsafe.Pointer(bp + 32)) > int64(1) { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+12968, libc.VaList(bp+48, string1))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+48, __ccgo_ts+179, __ccgo_ts+12459, __ccgo_ts+12954, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) } if libc.Int32FromUint8(firstChar) == int32('-') && (numWindows == 0 || libc.Int32FromUint8(prevChar) == int32('x') || libc.Int32FromUint8(prevChar) == int32('^')) { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+13045, int64(-libc.Int32FromInt32(1)))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+48, __ccgo_ts+179, __ccgo_ts+12459, __ccgo_ts+13085, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) } if libc.Int32FromUint8(firstChar) == int32('^') || libc.Int32FromUint8(firstChar) == int32('x') || libc.Int32FromUint8(firstChar) == int32('-') { goto _1 } libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+13100, libc.VaList(bp+48, string1))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+48, __ccgo_ts+179, __ccgo_ts+12459, __ccgo_ts+13085, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) goto _1 _1: ; i++ } numWindows = i if (objc-int64(numWindows))&int64(1) != 0 { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+13157, int64(-libc.Int32FromInt32(1)))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+48, __ccgo_ts+179, __ccgo_ts+12459, __ccgo_ts+12954, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) } /* * Go through all options looking for -in and -row, which are needed to be * found first to handle the special case where ^ is used on a row without * windows names, but with an -in option. Since all options are checked * here, we do not need to handle the error case again later. */ i = numWindows for { if !(int64(i) < objc) { break } if libtcl9_0.XTcl_GetIndexFromObjStruct(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(i)*8)), uintptr(unsafe.Pointer(&_optionStrings10)), libc.Int64FromUint64(libc.Uint64FromInt64(8)), __ccgo_ts+2689, libc.Int32FromInt32(0)|libc.Int32FromUint64(libc.Uint64FromInt64(4)< * we have to translate that to strcmp here. */ func _NewNativeObj(tls *libc.TLS, string1 uintptr) (r uintptr) { bp := tls.Alloc(224) defer tls.Free(224) var obj, str uintptr var _ /* ds at bp+0 */ TTcl_DString _, _ = obj, str str = libtcl9_0.XTcl_ExternalToUtfDString(tls, libc.UintptrFromInt32(0), string1, libc.Int64FromUint64(libc.Xstrlen(tls, string1)), bp) obj = libtcl9_0.XTcl_NewStringObj(tls, str, (*TTcl_DString)(unsafe.Pointer(bp)).Flength) libtcl9_0.XTcl_DStringFree(tls, bp) return obj } type TInteractiveState = struct { Finput TTcl_Channel Ftty int32 Fcommand TTcl_DString Fline TTcl_DString FgotPartial int32 Finterp uintptr } /* *---------------------------------------------------------------------- * * Tk_MainEx -- * * Main program for Wish and most other Tk-based applications. * * Results: * None. This function never returns (it exits the process when it's * done). * * Side effects: * This function initializes the Tk world and then starts interpreting * commands; almost anything could happen, depending on the script being * interpreted. * *---------------------------------------------------------------------- */ func XTk_MainEx(tls *libc.TLS, argc TTcl_Size, argv uintptr, appInitProc uintptr, interp uintptr) { bp := tls.Alloc(512) defer tls.Free(512) var _objPtr, appName, argvPtr, path, value, v2 uintptr var chan1 TTcl_Channel var code, i, nullStdin, v4 int32 var v1, v3 TTcl_Size var _ /* encodingName at bp+0 */ uintptr var _ /* is at bp+8 */ TInteractiveState _, _, _, _, _, _, _, _, _, _, _, _, _ = _objPtr, appName, argvPtr, chan1, code, i, nullStdin, path, value, v1, v2, v3, v4 i = 0 nullStdin = 0 if 0 < argc { argc-- /* "consume" argv[0] */ i++ } /* * Ensure that we are getting a compatible version of Tcl. */ if libtcl9_0.XTcl_PkgInitStubsCheck(tls, interp, __ccgo_ts+8182, libc.Int32FromInt32(0)|libc.Int32FromInt32(TCL_MAJOR_VERSION)<= int64(3) && 0 == libc.Xstrcmp(tls, __ccgo_ts+8228, *(*uintptr)(unsafe.Pointer(argv + 1*8))) && int32('-') != libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(argv + 3*8))))) { value = _NewNativeObj(tls, *(*uintptr)(unsafe.Pointer(argv + 2*8))) libtcl9_0.XTcl_SetStartupScript(tls, _NewNativeObj(tls, *(*uintptr)(unsafe.Pointer(argv + 3*8))), libtcl9_0.XTcl_GetStringFromObj(tls, value, libc.UintptrFromInt32(0))) _objPtr = value v2 = _objPtr v1 = *(*TTcl_Size)(unsafe.Pointer(v2)) *(*TTcl_Size)(unsafe.Pointer(v2))-- if v1 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr) } argc -= int64(3) i += int32(3) } else { if argc >= int64(1) && int32('-') != libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(argv + 1*8))))) { libtcl9_0.XTcl_SetStartupScript(tls, _NewNativeObj(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))), libc.UintptrFromInt32(0)) argc-- i++ } } } path = libtcl9_0.XTcl_GetStartupScript(tls, bp) if path == libc.UintptrFromInt32(0) { appName = _NewNativeObj(tls, *(*uintptr)(unsafe.Pointer(argv))) } else { appName = path } libtcl9_0.XTcl_SetVar2Ex(tls, interp, __ccgo_ts+13937, libc.UintptrFromInt32(0), appName, int32(TCL_GLOBAL_ONLY)) libtcl9_0.XTcl_SetVar2Ex(tls, interp, __ccgo_ts+13943, libc.UintptrFromInt32(0), libtcl9_0.XTcl_NewWideIntObj(tls, argc), int32(TCL_GLOBAL_ONLY)) argvPtr = libtcl9_0.XTcl_NewListObj(tls, 0, libc.UintptrFromInt32(0)) for { v3 = argc argc-- if !(v3 != 0) { break } v4 = i i++ libtcl9_0.XTcl_ListObjAppendElement(tls, libc.UintptrFromInt32(0), argvPtr, _NewNativeObj(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(v4)*8)))) } libtcl9_0.XTcl_SetVar2Ex(tls, interp, __ccgo_ts+13948, libc.UintptrFromInt32(0), argvPtr, int32(TCL_GLOBAL_ONLY)) /* * Set the "tcl_interactive" variable. */ (*(*TInteractiveState)(unsafe.Pointer(bp + 8))).Ftty = libc.Xisatty(tls, 0) libtcl9_0.XTcl_SetVar2Ex(tls, interp, __ccgo_ts+13953, libc.UintptrFromInt32(0), libtcl9_0.XTcl_NewWideIntObj(tls, libc.BoolInt64(!(path != 0) && ((*(*TInteractiveState)(unsafe.Pointer(bp + 8))).Ftty != 0 || nullStdin != 0))), int32(TCL_GLOBAL_ONLY)) /* * Invoke application-specific initialization. */ if (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{appInitProc})))(tls, interp) != TCL_OK { XTkpDisplayWarning(tls, libtcl9_0.XTcl_GetStringFromObj(tls, libtcl9_0.XTcl_GetObjResult(tls, interp), libc.UintptrFromInt32(0)), __ccgo_ts+13969) } /* * Invoke the script specified on the command line, if any. Must fetch it * again, as the appInitProc might have reset it. */ path = libtcl9_0.XTcl_GetStartupScript(tls, bp) if path != libc.UintptrFromInt32(0) { libtcl9_0.XTcl_ResetResult(tls, interp) code = libtcl9_0.XTcl_FSEvalFileEx(tls, interp, path, *(*uintptr)(unsafe.Pointer(bp))) if code != TCL_OK { /* * The following statement guarantees that the errorInfo variable * is set properly. */ libtcl9_0.XTcl_AppendObjToErrorInfo(tls, interp, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+195, int64(-int32(1)))) XTkpDisplayWarning(tls, libtcl9_0.XTcl_GetVar2(tls, interp, __ccgo_ts+14012, libc.UintptrFromInt32(0), int32(TCL_GLOBAL_ONLY)), __ccgo_ts+14022) libtcl9_0.XTcl_DeleteInterp(tls, interp) libtcl9_0.XTcl_Exit(tls, int32(1)) } (*(*TInteractiveState)(unsafe.Pointer(bp + 8))).Ftty = 0 } else { /* * Evaluate the .rc file, if one has been specified. */ libtcl9_0.XTcl_SourceRCFile(tls, interp) /* * Establish a channel handler for stdin. */ (*(*TInteractiveState)(unsafe.Pointer(bp + 8))).Finput = libtcl9_0.XTcl_GetStdChannel(tls, libc.Int32FromInt32(1)< 0 && chan1 != libc.UintptrFromInt32(0) { if libtcl9_0.XTcl_WriteObj(tls, chan1, resultPtr) < 0 { libtcl9_0.XTcl_WriteChars(tls, chan1, __ccgo_ts+14048, int64(-int32(1))) } libtcl9_0.XTcl_WriteChars(tls, chan1, __ccgo_ts+14046, int64(1)) } _objPtr = resultPtr v3 = _objPtr v2 = *(*TTcl_Size)(unsafe.Pointer(v3)) *(*TTcl_Size)(unsafe.Pointer(v3))-- if v2 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr) } } } /* * If a tty stdin is still around, output a prompt. */ goto prompt prompt: ; if (*TInteractiveState)(unsafe.Pointer(isPtr)).Ftty != 0 && (*TInteractiveState)(unsafe.Pointer(isPtr)).Finput != libc.UintptrFromInt32(0) { _Prompt(tls, interp, isPtr) } libtcl9_0.XTcl_ResetResult(tls, interp) } /* *---------------------------------------------------------------------- * * Prompt -- * * Issue a prompt on standard output, or invoke a script to issue the * prompt. * * Results: * None. * * Side effects: * A prompt gets output, and a Tcl script may be evaluated in interp. * *---------------------------------------------------------------------- */ func _Prompt(tls *libc.TLS, interp uintptr, isPtr uintptr) { /* InteractiveState. */ var chan1 TTcl_Channel var code int32 var promptCmdPtr, v1 uintptr _, _, _, _ = chan1, code, promptCmdPtr, v1 if (*TInteractiveState)(unsafe.Pointer(isPtr)).FgotPartial != 0 { v1 = __ccgo_ts + 14077 } else { v1 = __ccgo_ts + 14089 } promptCmdPtr = libtcl9_0.XTcl_GetVar2Ex(tls, interp, v1, libc.UintptrFromInt32(0), int32(TCL_GLOBAL_ONLY)) if !(promptCmdPtr == libc.UintptrFromInt32(0)) { goto _2 } goto defaultPrompt defaultPrompt: ; if !((*TInteractiveState)(unsafe.Pointer(isPtr)).FgotPartial != 0) { chan1 = libtcl9_0.XTcl_GetStdChannel(tls, libc.Int32FromInt32(1)<deletionEpoch does not match epoch. */ type TWindowRep = struct { Ftkwin TTk_Window FmainPtr uintptr Fepoch Tsize_t } /* * The following structure defines the implementation of the "pixel" Tcl * object, used for measuring distances. The pixel object remembers its * initial display-independent settings. */ var _pixelObjType = TTkObjType{ FobjType: TTcl_ObjType{ Fname: __ccgo_ts + 14137, Fversion: uint64(libc.UintptrFromInt32(0) + 56), }, } func init() { p := unsafe.Pointer(&_pixelObjType) *(*uintptr)(unsafe.Add(p, 8)) = __ccgo_fp(_FreePixelInternalRep) *(*uintptr)(unsafe.Add(p, 16)) = __ccgo_fp(_DupPixelInternalRep) *(*uintptr)(unsafe.Add(p, 48)) = __ccgo_fp(XTkLengthOne) } func XTkLengthOne(tls *libc.TLS, dummy117 uintptr) (r TTcl_Size) { return int64(1) } /* * The following structure defines the implementation of the "pixel" Tcl * object, used for measuring distances. The pixel object remembers its * initial display-independent settings. */ var _mmObjType = TTkObjType{ FobjType: TTcl_ObjType{ Fname: __ccgo_ts + 14143, Fversion: uint64(libc.UintptrFromInt32(0) + 56), }, } func init() { p := unsafe.Pointer(&_mmObjType) *(*uintptr)(unsafe.Add(p, 8)) = __ccgo_fp(_FreeMMInternalRep) *(*uintptr)(unsafe.Add(p, 16)) = __ccgo_fp(_DupMMInternalRep) *(*uintptr)(unsafe.Add(p, 24)) = __ccgo_fp(_UpdateStringOfMM) *(*uintptr)(unsafe.Add(p, 48)) = __ccgo_fp(XTkLengthOne) } /* * The following structure defines the implementation of the "window" * Tcl object. */ var _windowObjType = TTkObjType{ FobjType: TTcl_ObjType{ Fname: __ccgo_ts + 4814, }, } func init() { p := unsafe.Pointer(&_windowObjType) *(*uintptr)(unsafe.Add(p, 8)) = __ccgo_fp(_FreeWindowInternalRep) *(*uintptr)(unsafe.Add(p, 16)) = __ccgo_fp(_DupWindowInternalRep) } /* *---------------------------------------------------------------------- * * GetTypeCache -- * * Get (and build if necessary) the cache of useful Tcl object types for * comparisons in the conversion functions. This allows optimized checks * for standard cases. * *---------------------------------------------------------------------- */ func _GetTypeCache(tls *libc.TLS) (r uintptr) { bp := tls.Alloc(48) defer tls.Free(48) var tsdPtr uintptr var _ /* obj at bp+0 */ TTcl_Obj _ = tsdPtr tsdPtr = libtcl9_0.XTcl_GetThreadData(tls, uintptr(unsafe.Pointer(&_dataKey5)), int64(8)) if (*TThreadSpecificData5)(unsafe.Pointer(tsdPtr)).FdoubleTypePtr == libc.UintptrFromInt32(0) { (*(*TTcl_Obj)(unsafe.Pointer(bp))).Flength = int64(3) (*(*TTcl_Obj)(unsafe.Pointer(bp))).Fbytes = __ccgo_ts + 14146 (*(*TTcl_Obj)(unsafe.Pointer(bp))).FtypePtr = libc.UintptrFromInt32(0) libtcl9_0.XTcl_GetDoubleFromObj(tls, libc.UintptrFromInt32(0), bp, bp+32) (*TThreadSpecificData5)(unsafe.Pointer(tsdPtr)).FdoubleTypePtr = (*(*TTcl_Obj)(unsafe.Pointer(bp))).FtypePtr } return tsdPtr } /* *---------------------------------------------------------------------- * * TkGetIntForIndex -- * * Almost the same as Tcl_GetIntForIndex, but it retrieves an int. Accepts * "" (empty string) as well. * * Results: * The return value is a standard Tcl object result. * * Side effects: * None * *---------------------------------------------------------------------- */ func XTkGetIntForIndex(tls *libc.TLS, indexObj uintptr, end TTcl_Size, lastOK int32, indexPtr uintptr) (r int32) { var value uintptr var v1 int64 _, _ = value, v1 if indexObj == libc.UintptrFromInt32(0) { *(*TTcl_Size)(unsafe.Pointer(indexPtr)) = int64(-libc.Int32FromInt32(1)) return TCL_OK } if libtcl9_0.XTcl_GetIntForIndex(tls, libc.UintptrFromInt32(0), indexObj, end+int64(lastOK), indexPtr) != TCL_OK { value = libtcl9_0.XTcl_GetStringFromObj(tls, indexObj, libc.UintptrFromInt32(0)) if !(*(*uint8)(unsafe.Pointer(value)) != 0) { /* empty string */ if end == int64(-int32(1)) { v1 = int64(-libc.Int32FromInt32(1)) - libc.Int64FromUint64(libc.Uint64FromInt32(-libc.Int32FromInt32(1))>>libc.Int32FromInt32(1)) } else { v1 = int64(-libc.Int32FromInt32(1)) } *(*TTcl_Size)(unsafe.Pointer(indexPtr)) = v1 return TCL_OK } return int32(TCL_ERROR) } return TCL_OK } /* *---------------------------------------------------------------------- * * GetPixelsFromObjEx -- * * Attempt to return a pixel value from the Tcl object "objPtr". If the * object is not already a pixel value, an attempt will be made to * convert it to one. * * Results: * The return value is a standard Tcl object result. If an error occurs * during conversion, an error message is left in the interpreter's * result unless "interp" is NULL. * * Side effects: * If the object is not already a pixel, the conversion will free any old * internal representation. * *---------------------------------------------------------------------- */ func _GetPixelsFromObjEx(tls *libc.TLS, interp uintptr, tkwin TTk_Window, objPtr uintptr, intPtr uintptr, dblPtr uintptr) (r int32) { bp := tls.Alloc(16) defer tls.Free(16) /* Places to store resulting pixels. */ var fresh, result int32 var pixelPtr uintptr var v1, v2 float64 var _ /* d at bp+0 */ float64 _, _, _, _, _ = fresh, pixelPtr, result, v1, v2 if (*TTcl_Obj)(unsafe.Pointer(objPtr)).FtypePtr != uintptr(unsafe.Pointer(&_pixelObjType)) { if libtcl9_0.XTcl_GetDoubleFromObj(tls, libc.UintptrFromInt32(0), objPtr, bp) == TCL_OK { if dblPtr != libc.UintptrFromInt32(0) { *(*float64)(unsafe.Pointer(dblPtr)) = *(*float64)(unsafe.Pointer(bp)) } if *(*float64)(unsafe.Pointer(bp)) < libc.Float64FromInt32(0) { v1 = *(*float64)(unsafe.Pointer(bp)) - float64(0.5) } else { v1 = *(*float64)(unsafe.Pointer(bp)) + float64(0.5) } *(*int32)(unsafe.Pointer(intPtr)) = int32(v1) return TCL_OK } } goto retry retry: ; fresh = libc.BoolInt32((*TTcl_Obj)(unsafe.Pointer(objPtr)).FtypePtr != uintptr(unsafe.Pointer(&_pixelObjType))) if fresh != 0 { result = _SetPixelFromAny(tls, interp, objPtr) if result != TCL_OK { return result } } if (*(*struct { Fptr1 uintptr Fptr2 uintptr })(unsafe.Pointer(objPtr + 32))).Fptr2 == uintptr(0) { *(*int32)(unsafe.Pointer(intPtr)) = int32(int64((*(*struct { Fptr1 uintptr Fptr2 uintptr })(unsafe.Pointer(objPtr + 32))).Fptr1)) if dblPtr != 0 { *(*float64)(unsafe.Pointer(dblPtr)) = float64(*(*int32)(unsafe.Pointer(intPtr))) } } else { pixelPtr = (*(*struct { Fptr1 uintptr Fptr2 uintptr })(unsafe.Pointer(objPtr + 32))).Fptr2 if !(fresh != 0) && (*TPixelRep)(unsafe.Pointer(pixelPtr)).Ftkwin != tkwin { /* * In the case of exo-screen conversions of non-pixels, we force a * recomputation from the string. */ _FreePixelInternalRep(tls, objPtr) goto retry } if (*TPixelRep)(unsafe.Pointer(pixelPtr)).Ftkwin != tkwin || dblPtr != 0 { *(*float64)(unsafe.Pointer(bp)) = (*TPixelRep)(unsafe.Pointer(pixelPtr)).Fvalue if (*TPixelRep)(unsafe.Pointer(pixelPtr)).Funits >= 0 { *(*float64)(unsafe.Pointer(bp)) *= float64(_bias[(*TPixelRep)(unsafe.Pointer(pixelPtr)).Funits] * float64((*TScreen)(unsafe.Pointer((*struct { Fext_data uintptr Fprivate1 uintptr Ffd int32 Fprivate2 int32 Fproto_major_version int32 Fproto_minor_version int32 Fvendor uintptr Fprivate3 TXID Fprivate4 TXID Fprivate5 TXID Fprivate6 int32 Fresource_alloc uintptr Fbyte_order int32 Fbitmap_unit int32 Fbitmap_pad int32 Fbitmap_bit_order int32 Fnformats int32 Fpixmap_format uintptr Fprivate8 int32 Frelease int32 Fprivate9 uintptr Fprivate10 uintptr Fqlen int32 Flast_request_read uint64 Frequest uint64 Fprivate11 TXPointer Fprivate12 TXPointer Fprivate13 TXPointer Fprivate14 TXPointer Fmax_request_size uint32 Fdb uintptr Fprivate15 uintptr Fdisplay_name uintptr Fdefault_screen int32 Fnscreens int32 Fscreens uintptr Fmotion_buffer uint64 Fprivate16 uint64 Fmin_keycode int32 Fmax_keycode int32 Fprivate17 TXPointer Fprivate18 TXPointer Fprivate19 int32 Fxdefaults uintptr })(unsafe.Pointer((*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fdisplay)).Fscreens+uintptr((*TTk_FakeWin)(unsafe.Pointer(tkwin)).FscreenNum)*128)).Fwidth)) *(*float64)(unsafe.Pointer(bp)) /= float64((*TScreen)(unsafe.Pointer((*struct { Fext_data uintptr Fprivate1 uintptr Ffd int32 Fprivate2 int32 Fproto_major_version int32 Fproto_minor_version int32 Fvendor uintptr Fprivate3 TXID Fprivate4 TXID Fprivate5 TXID Fprivate6 int32 Fresource_alloc uintptr Fbyte_order int32 Fbitmap_unit int32 Fbitmap_pad int32 Fbitmap_bit_order int32 Fnformats int32 Fpixmap_format uintptr Fprivate8 int32 Frelease int32 Fprivate9 uintptr Fprivate10 uintptr Fqlen int32 Flast_request_read uint64 Frequest uint64 Fprivate11 TXPointer Fprivate12 TXPointer Fprivate13 TXPointer Fprivate14 TXPointer Fmax_request_size uint32 Fdb uintptr Fprivate15 uintptr Fdisplay_name uintptr Fdefault_screen int32 Fnscreens int32 Fscreens uintptr Fmotion_buffer uint64 Fprivate16 uint64 Fmin_keycode int32 Fmax_keycode int32 Fprivate17 TXPointer Fprivate18 TXPointer Fprivate19 int32 Fxdefaults uintptr })(unsafe.Pointer((*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fdisplay)).Fscreens + uintptr((*TTk_FakeWin)(unsafe.Pointer(tkwin)).FscreenNum)*128)).Fmwidth) } if *(*float64)(unsafe.Pointer(bp)) < libc.Float64FromInt32(0) { v2 = *(*float64)(unsafe.Pointer(bp)) - float64(0.5) } else { v2 = *(*float64)(unsafe.Pointer(bp)) + float64(0.5) } (*TPixelRep)(unsafe.Pointer(pixelPtr)).FreturnValue = int32(v2) (*TPixelRep)(unsafe.Pointer(pixelPtr)).Ftkwin = tkwin if dblPtr != 0 { *(*float64)(unsafe.Pointer(dblPtr)) = *(*float64)(unsafe.Pointer(bp)) } } *(*int32)(unsafe.Pointer(intPtr)) = (*TPixelRep)(unsafe.Pointer(pixelPtr)).FreturnValue } return TCL_OK } var _bias = [4]float64{ 0: float64(1), 1: float64(10), 2: float64(25.4), 3: float64(0.35277777777777775), } /* *---------------------------------------------------------------------- * * Tk_GetPixelsFromObj -- * * Attempt to return a pixel value from the Tcl object "objPtr". If the * object is not already a pixel value, an attempt will be made to * convert it to one. * * Results: * The return value is a standard Tcl object result. If an error occurs * during conversion, an error message is left in the interpreter's * result unless "interp" is NULL. * * Side effects: * If the object is not already a pixel, the conversion will free any old * internal representation. * *---------------------------------------------------------------------- */ func XTk_GetPixelsFromObj(tls *libc.TLS, interp uintptr, tkwin TTk_Window, objPtr uintptr, intPtr uintptr) (r int32) { /* Place to store resulting pixels. */ return _GetPixelsFromObjEx(tls, interp, tkwin, objPtr, intPtr, libc.UintptrFromInt32(0)) } /* *---------------------------------------------------------------------- * * Tk_GetDoublePixelsFromObj -- * * Attempt to return a double pixel value from the Tcl object * "objPtr". If the object is not already a pixel value, an attempt will * be made to convert it to one, the internal unit being pixels. * * Results: * The return value is a standard Tcl object result. If an error occurs * during conversion, an error message is left in the interpreter's * result unless "interp" is NULL. * * Side effects: * If the object is not already a pixel, the conversion will free any old * internal representation. * *---------------------------------------------------------------------- */ func XTk_GetDoublePixelsFromObj(tls *libc.TLS, interp uintptr, tkwin TTk_Window, objPtr uintptr, doublePtr uintptr) (r int32) { bp := tls.Alloc(16) defer tls.Free(16) /* Place to store resulting pixels. */ var pixelPtr uintptr var result int32 var _ /* d at bp+0 */ float64 var _ /* val at bp+8 */ int32 _, _ = pixelPtr, result result = _GetPixelsFromObjEx(tls, interp, tkwin, objPtr, bp+8, bp) if result != TCL_OK { return result } if (*TTcl_Obj)(unsafe.Pointer(objPtr)).FtypePtr == uintptr(unsafe.Pointer(&_pixelObjType)) && !((*(*struct { Fptr1 uintptr Fptr2 uintptr })(unsafe.Pointer(objPtr + 32))).Fptr2 == libc.UintptrFromInt32(0)) { pixelPtr = (*(*struct { Fptr1 uintptr Fptr2 uintptr })(unsafe.Pointer(objPtr + 32))).Fptr2 if (*TPixelRep)(unsafe.Pointer(pixelPtr)).Funits >= 0 { /* * Internally "shimmer" to pixel units. */ (*TPixelRep)(unsafe.Pointer(pixelPtr)).Funits = -int32(1) (*TPixelRep)(unsafe.Pointer(pixelPtr)).Fvalue = *(*float64)(unsafe.Pointer(bp)) } } *(*float64)(unsafe.Pointer(doublePtr)) = *(*float64)(unsafe.Pointer(bp)) return TCL_OK } /* *---------------------------------------------------------------------- * * FreePixelInternalRep -- * * Deallocate the storage associated with a pixel object's internal * representation. * * Results: * None. * * Side effects: * Frees objPtr's internal representation and sets objPtr's internalRep * to NULL. * *---------------------------------------------------------------------- */ func _FreePixelInternalRep(tls *libc.TLS, objPtr uintptr) { /* Pixel object with internal rep to free. */ var pixelPtr uintptr _ = pixelPtr if !((*(*struct { Fptr1 uintptr Fptr2 uintptr })(unsafe.Pointer(objPtr + 32))).Fptr2 == libc.UintptrFromInt32(0)) { pixelPtr = (*(*struct { Fptr1 uintptr Fptr2 uintptr })(unsafe.Pointer(objPtr + 32))).Fptr2 libtcl9_0.XTcl_Free(tls, pixelPtr) } (*(*struct { Fptr1 uintptr Fptr2 uintptr })(unsafe.Pointer(objPtr + 32))).Fptr1 = uintptr(int64(libc.Int32FromInt32(0))) (*(*struct { Fptr1 uintptr Fptr2 uintptr })(unsafe.Pointer(objPtr + 32))).Fptr2 = uintptr(0) (*TTcl_Obj)(unsafe.Pointer(objPtr)).FtypePtr = libc.UintptrFromInt32(0) } /* *---------------------------------------------------------------------- * * DupPixelInternalRep -- * * Initialize the internal representation of a pixel Tcl_Obj to a copy of * the internal representation of an existing pixel object. * * Results: * None. * * Side effects: * copyPtr's internal rep is set to the pixel corresponding to srcPtr's * internal rep. * *---------------------------------------------------------------------- */ func _DupPixelInternalRep(tls *libc.TLS, srcPtr uintptr, copyPtr uintptr) { /* Object with internal rep to set. */ var newPtr, oldPtr uintptr _, _ = newPtr, oldPtr (*TTcl_Obj)(unsafe.Pointer(copyPtr)).FtypePtr = (*TTcl_Obj)(unsafe.Pointer(srcPtr)).FtypePtr if (*(*struct { Fptr1 uintptr Fptr2 uintptr })(unsafe.Pointer(srcPtr + 32))).Fptr2 == uintptr(0) { (*(*struct { Fptr1 uintptr Fptr2 uintptr })(unsafe.Pointer(copyPtr + 32))).Fptr1 = uintptr(int64((*(*struct { Fptr1 uintptr Fptr2 uintptr })(unsafe.Pointer(srcPtr + 32))).Fptr1)) (*(*struct { Fptr1 uintptr Fptr2 uintptr })(unsafe.Pointer(copyPtr + 32))).Fptr2 = uintptr(0) } else { oldPtr = (*(*struct { Fptr1 uintptr Fptr2 uintptr })(unsafe.Pointer(srcPtr + 32))).Fptr2 newPtr = libtcl9_0.XTcl_Alloc(tls, uint64(32)) (*TPixelRep)(unsafe.Pointer(newPtr)).Fvalue = (*TPixelRep)(unsafe.Pointer(oldPtr)).Fvalue (*TPixelRep)(unsafe.Pointer(newPtr)).Funits = (*TPixelRep)(unsafe.Pointer(oldPtr)).Funits (*TPixelRep)(unsafe.Pointer(newPtr)).Ftkwin = (*TPixelRep)(unsafe.Pointer(oldPtr)).Ftkwin (*TPixelRep)(unsafe.Pointer(newPtr)).FreturnValue = (*TPixelRep)(unsafe.Pointer(oldPtr)).FreturnValue (*(*struct { Fptr1 uintptr Fptr2 uintptr })(unsafe.Pointer(copyPtr + 32))).Fptr1 = libc.UintptrFromInt32(0) (*(*struct { Fptr1 uintptr Fptr2 uintptr })(unsafe.Pointer(copyPtr + 32))).Fptr2 = newPtr } } /* *---------------------------------------------------------------------- * * SetPixelFromAny -- * * Attempt to generate a pixel internal form for the Tcl object "objPtr". * * Results: * The return value is a standard Tcl result. If an error occurs during * conversion, an error message is left in the interpreter's result * unless "interp" is NULL. * * Side effects: * If no error occurs, a pixel representation of the object is stored * internally and the type of "objPtr" is set to pixel. * *---------------------------------------------------------------------- */ func _SetPixelFromAny(tls *libc.TLS, interp uintptr, objPtr uintptr) (r int32) { bp := tls.Alloc(64) defer tls.Free(64) /* The object to convert. */ var i, v1, v2 int32 var pixelPtr, rest, string1, typeCache, typePtr uintptr var savechar uint8 var v4 bool var _ /* d at bp+0 */ float64 var _ /* units at bp+8 */ int32 _, _, _, _, _, _, _, _, _, _ = i, pixelPtr, rest, savechar, string1, typeCache, typePtr, v1, v2, v4 typeCache = _GetTypeCache(tls) if (*TTcl_Obj)(unsafe.Pointer(objPtr)).FtypePtr != (*TThreadSpecificData5)(unsafe.Pointer(typeCache)).FdoubleTypePtr && libtcl9_0.XTcl_GetIntFromObj(tls, libc.UintptrFromInt32(0), objPtr, bp+8) == TCL_OK { *(*float64)(unsafe.Pointer(bp)) = float64(*(*int32)(unsafe.Pointer(bp + 8))) *(*int32)(unsafe.Pointer(bp + 8)) = -int32(1) /* * In the case of ints, we need to ensure that a valid string exists * in order for int-but-not-string objects to be converted back to * ints again from pixel obj types. */ libtcl9_0.XTcl_GetStringFromObj(tls, objPtr, libc.UintptrFromInt32(0)) } else { if libtcl9_0.XTcl_GetDoubleFromObj(tls, libc.UintptrFromInt32(0), objPtr, bp) == TCL_OK { *(*int32)(unsafe.Pointer(bp + 8)) = -int32(1) } else { string1 = libtcl9_0.XTcl_GetStringFromObj(tls, objPtr, libc.UintptrFromInt32(0)) rest = string1 + uintptr(libc.Xstrlen(tls, string1)) for { if v4 = rest > string1; v4 { v1 = libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(rest + uintptr(-libc.Int32FromInt32(1))))) v2 = libc.BoolInt32(v1 == int32(' ') || libc.Uint32FromInt32(v1)-uint32('\t') < uint32(5)) goto _3 _3: } if !(v4 && v2 != 0) { break } rest-- /* skip all spaces at the end */ } if rest > string1 { rest-- /* point to the character just before the last space */ } if !(rest == string1) { goto _5 } goto error error: ; if interp != libc.UintptrFromInt32(0) { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+11394, libc.VaList(bp+24, string1))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+24, __ccgo_ts+179, __ccgo_ts+182, __ccgo_ts+7935, libc.UintptrFromInt32(0))) } return int32(TCL_ERROR) _5: ; switch libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(rest))) { case int32('m'): *(*int32)(unsafe.Pointer(bp + 8)) = 0 case int32('c'): *(*int32)(unsafe.Pointer(bp + 8)) = int32(1) case int32('i'): *(*int32)(unsafe.Pointer(bp + 8)) = int32(2) case int32('p'): *(*int32)(unsafe.Pointer(bp + 8)) = int32(3) default: goto error } savechar = *(*uint8)(unsafe.Pointer(rest)) *(*uint8)(unsafe.Pointer(rest)) = uint8('\000') if libtcl9_0.XTcl_GetDouble(tls, libc.UintptrFromInt32(0), string1, bp) != TCL_OK { *(*uint8)(unsafe.Pointer(rest)) = savechar goto error } *(*uint8)(unsafe.Pointer(rest)) = savechar } } /* * Free the old internalRep before setting the new one. */ typePtr = (*TTcl_Obj)(unsafe.Pointer(objPtr)).FtypePtr if typePtr != libc.UintptrFromInt32(0) && (*TTcl_ObjType)(unsafe.Pointer(typePtr)).FfreeIntRepProc != libc.UintptrFromInt32(0) { (*(*func(*libc.TLS, uintptr))(unsafe.Pointer(&struct{ uintptr }{(*TTcl_ObjType)(unsafe.Pointer(typePtr)).FfreeIntRepProc})))(tls, objPtr) } (*TTcl_Obj)(unsafe.Pointer(objPtr)).FtypePtr = uintptr(unsafe.Pointer(&_pixelObjType)) i = int32(*(*float64)(unsafe.Pointer(bp))) if *(*int32)(unsafe.Pointer(bp + 8)) < 0 && float64(i) == *(*float64)(unsafe.Pointer(bp)) { (*(*struct { Fptr1 uintptr Fptr2 uintptr })(unsafe.Pointer(objPtr + 32))).Fptr1 = uintptr(int64(i)) (*(*struct { Fptr1 uintptr Fptr2 uintptr })(unsafe.Pointer(objPtr + 32))).Fptr2 = uintptr(0) } else { pixelPtr = libtcl9_0.XTcl_Alloc(tls, uint64(32)) (*TPixelRep)(unsafe.Pointer(pixelPtr)).Fvalue = *(*float64)(unsafe.Pointer(bp)) (*TPixelRep)(unsafe.Pointer(pixelPtr)).Funits = *(*int32)(unsafe.Pointer(bp + 8)) (*TPixelRep)(unsafe.Pointer(pixelPtr)).Ftkwin = libc.UintptrFromInt32(0) (*TPixelRep)(unsafe.Pointer(pixelPtr)).FreturnValue = i (*(*struct { Fptr1 uintptr Fptr2 uintptr })(unsafe.Pointer(objPtr + 32))).Fptr1 = libc.UintptrFromInt32(0) (*(*struct { Fptr1 uintptr Fptr2 uintptr })(unsafe.Pointer(objPtr + 32))).Fptr2 = pixelPtr } return TCL_OK } /* *---------------------------------------------------------------------- * * Tk_GetMMFromObj -- * * Attempt to return an mm value from the Tcl object "objPtr". If the * object is not already an mm value, an attempt will be made to convert * it to one. * * Results: * The return value is a standard Tcl object result. If an error occurs * during conversion, an error message is left in the interpreter's * result unless "interp" is NULL. * * Side effects: * If the object is not already a pixel, the conversion will free any old * internal representation. * *---------------------------------------------------------------------- */ func XTk_GetMMFromObj(tls *libc.TLS, interp uintptr, tkwin TTk_Window, objPtr uintptr, doublePtr uintptr) (r int32) { /* Place to store resulting millimeters. */ var d float64 var mmPtr uintptr var result int32 _, _, _ = d, mmPtr, result if (*TTcl_Obj)(unsafe.Pointer(objPtr)).FtypePtr != uintptr(unsafe.Pointer(&_mmObjType)) { result = _SetMMFromAny(tls, interp, objPtr) if result != TCL_OK { return result } } mmPtr = (*(*struct { Fptr1 uintptr Fptr2 uintptr })(unsafe.Pointer(objPtr + 32))).Fptr1 if (*TMMRep)(unsafe.Pointer(mmPtr)).Ftkwin != tkwin { d = (*TMMRep)(unsafe.Pointer(mmPtr)).Fvalue if (*TMMRep)(unsafe.Pointer(mmPtr)).Funits == -int32(1) { d /= float64((*TScreen)(unsafe.Pointer((*struct { Fext_data uintptr Fprivate1 uintptr Ffd int32 Fprivate2 int32 Fproto_major_version int32 Fproto_minor_version int32 Fvendor uintptr Fprivate3 TXID Fprivate4 TXID Fprivate5 TXID Fprivate6 int32 Fresource_alloc uintptr Fbyte_order int32 Fbitmap_unit int32 Fbitmap_pad int32 Fbitmap_bit_order int32 Fnformats int32 Fpixmap_format uintptr Fprivate8 int32 Frelease int32 Fprivate9 uintptr Fprivate10 uintptr Fqlen int32 Flast_request_read uint64 Frequest uint64 Fprivate11 TXPointer Fprivate12 TXPointer Fprivate13 TXPointer Fprivate14 TXPointer Fmax_request_size uint32 Fdb uintptr Fprivate15 uintptr Fdisplay_name uintptr Fdefault_screen int32 Fnscreens int32 Fscreens uintptr Fmotion_buffer uint64 Fprivate16 uint64 Fmin_keycode int32 Fmax_keycode int32 Fprivate17 TXPointer Fprivate18 TXPointer Fprivate19 int32 Fxdefaults uintptr })(unsafe.Pointer((*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fdisplay)).Fscreens + uintptr((*TTk_FakeWin)(unsafe.Pointer(tkwin)).FscreenNum)*128)).Fwidth) d *= float64((*TScreen)(unsafe.Pointer((*struct { Fext_data uintptr Fprivate1 uintptr Ffd int32 Fprivate2 int32 Fproto_major_version int32 Fproto_minor_version int32 Fvendor uintptr Fprivate3 TXID Fprivate4 TXID Fprivate5 TXID Fprivate6 int32 Fresource_alloc uintptr Fbyte_order int32 Fbitmap_unit int32 Fbitmap_pad int32 Fbitmap_bit_order int32 Fnformats int32 Fpixmap_format uintptr Fprivate8 int32 Frelease int32 Fprivate9 uintptr Fprivate10 uintptr Fqlen int32 Flast_request_read uint64 Frequest uint64 Fprivate11 TXPointer Fprivate12 TXPointer Fprivate13 TXPointer Fprivate14 TXPointer Fmax_request_size uint32 Fdb uintptr Fprivate15 uintptr Fdisplay_name uintptr Fdefault_screen int32 Fnscreens int32 Fscreens uintptr Fmotion_buffer uint64 Fprivate16 uint64 Fmin_keycode int32 Fmax_keycode int32 Fprivate17 TXPointer Fprivate18 TXPointer Fprivate19 int32 Fxdefaults uintptr })(unsafe.Pointer((*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fdisplay)).Fscreens + uintptr((*TTk_FakeWin)(unsafe.Pointer(tkwin)).FscreenNum)*128)).Fmwidth) } else { d *= _bias1[(*TMMRep)(unsafe.Pointer(mmPtr)).Funits] } (*TMMRep)(unsafe.Pointer(mmPtr)).Ftkwin = tkwin (*TMMRep)(unsafe.Pointer(mmPtr)).FreturnValue = d } *(*float64)(unsafe.Pointer(doublePtr)) = (*TMMRep)(unsafe.Pointer(mmPtr)).FreturnValue return TCL_OK } var _bias1 = [4]float64{ 0: float64(10), 1: float64(25.4), 2: float64(1), 3: float64(0.35277777777777775), } /* *---------------------------------------------------------------------- * * FreeMMInternalRep -- * * Deallocate the storage associated with a mm object's internal * representation. * * Results: * None. * * Side effects: * Frees objPtr's internal representation and sets objPtr's internalRep * to NULL. * *---------------------------------------------------------------------- */ func _FreeMMInternalRep(tls *libc.TLS, objPtr uintptr) { /* MM object with internal rep to free. */ libtcl9_0.XTcl_Free(tls, (*(*struct { Fptr1 uintptr Fptr2 uintptr })(unsafe.Pointer(objPtr + 32))).Fptr1) (*(*struct { Fptr1 uintptr Fptr2 uintptr })(unsafe.Pointer(objPtr + 32))).Fptr1 = libc.UintptrFromInt32(0) (*TTcl_Obj)(unsafe.Pointer(objPtr)).FtypePtr = libc.UintptrFromInt32(0) } /* *---------------------------------------------------------------------- * * DupMMInternalRep -- * * Initialize the internal representation of a pixel Tcl_Obj to a copy of * the internal representation of an existing pixel object. * * Results: * None. * * Side effects: * copyPtr's internal rep is set to the pixel corresponding to srcPtr's * internal rep. * *---------------------------------------------------------------------- */ func _DupMMInternalRep(tls *libc.TLS, srcPtr uintptr, copyPtr uintptr) { /* Object with internal rep to set. */ var newPtr, oldPtr uintptr _, _ = newPtr, oldPtr (*TTcl_Obj)(unsafe.Pointer(copyPtr)).FtypePtr = (*TTcl_Obj)(unsafe.Pointer(srcPtr)).FtypePtr oldPtr = (*(*struct { Fptr1 uintptr Fptr2 uintptr })(unsafe.Pointer(srcPtr + 32))).Fptr1 newPtr = libtcl9_0.XTcl_Alloc(tls, uint64(32)) (*TMMRep)(unsafe.Pointer(newPtr)).Fvalue = (*TMMRep)(unsafe.Pointer(oldPtr)).Fvalue (*TMMRep)(unsafe.Pointer(newPtr)).Funits = (*TMMRep)(unsafe.Pointer(oldPtr)).Funits (*TMMRep)(unsafe.Pointer(newPtr)).Ftkwin = (*TMMRep)(unsafe.Pointer(oldPtr)).Ftkwin (*TMMRep)(unsafe.Pointer(newPtr)).FreturnValue = (*TMMRep)(unsafe.Pointer(oldPtr)).FreturnValue (*(*struct { Fptr1 uintptr Fptr2 uintptr })(unsafe.Pointer(copyPtr + 32))).Fptr1 = newPtr } /* *---------------------------------------------------------------------- * * UpdateStringOfMM -- * * Update the string representation for a pixel Tcl_Obj this function is * only called, if the pixel Tcl_Obj has no unit, because with units the * string representation is created by SetMMFromAny * * Results: * None. * * Side effects: * The object's string is set to a valid string that results from the * double-to-string conversion. * *---------------------------------------------------------------------- */ func _UpdateStringOfMM(tls *libc.TLS, objPtr uintptr) { bp := tls.Alloc(32) defer tls.Free(32) /* pixel obj with string rep to update. */ var len1 Tsize_t var mmPtr uintptr var _ /* buffer at bp+0 */ [27]uint8 _, _ = len1, mmPtr mmPtr = (*(*struct { Fptr1 uintptr Fptr2 uintptr })(unsafe.Pointer(objPtr + 32))).Fptr1 /* assert( mmPtr->units == -1 && objPtr->bytes == NULL ); */ if (*TMMRep)(unsafe.Pointer(mmPtr)).Funits != -int32(1) || (*TTcl_Obj)(unsafe.Pointer(objPtr)).Fbytes != libc.UintptrFromInt32(0) { libtcl9_0.XTcl_Panic(tls, __ccgo_ts+14150, 0) } libtcl9_0.XTcl_PrintDouble(tls, libc.UintptrFromInt32(0), (*TMMRep)(unsafe.Pointer(mmPtr)).Fvalue, bp) len1 = libc.Xstrlen(tls, bp) (*TTcl_Obj)(unsafe.Pointer(objPtr)).Fbytes = libtcl9_0.XTcl_Alloc(tls, len1+uint64(1)) libc.Xstrcpy(tls, (*TTcl_Obj)(unsafe.Pointer(objPtr)).Fbytes, bp) (*TTcl_Obj)(unsafe.Pointer(objPtr)).Flength = libc.Int64FromUint64(len1) } /* *---------------------------------------------------------------------- * * SetMMFromAny -- * * Attempt to generate a mm internal form for the Tcl object "objPtr". * * Results: * The return value is a standard Tcl result. If an error occurs during * conversion, an error message is left in the interpreter's result * unless "interp" is NULL. * * Side effects: * If no error occurs, a mm representation of the object is stored * internally and the type of "objPtr" is set to mm. * *---------------------------------------------------------------------- */ func _SetMMFromAny(tls *libc.TLS, interp uintptr, objPtr uintptr) (r int32) { bp := tls.Alloc(64) defer tls.Free(64) /* The object to convert. */ var mmPtr, rest, string1, typeCache, typePtr uintptr var savechar uint8 var v1, v2 int32 var v4 bool var _ /* d at bp+0 */ float64 var _ /* units at bp+8 */ int32 _, _, _, _, _, _, _, _, _ = mmPtr, rest, savechar, string1, typeCache, typePtr, v1, v2, v4 typeCache = _GetTypeCache(tls) if (*TTcl_Obj)(unsafe.Pointer(objPtr)).FtypePtr != (*TThreadSpecificData5)(unsafe.Pointer(typeCache)).FdoubleTypePtr && libtcl9_0.XTcl_GetIntFromObj(tls, libc.UintptrFromInt32(0), objPtr, bp+8) == TCL_OK { *(*float64)(unsafe.Pointer(bp)) = float64(*(*int32)(unsafe.Pointer(bp + 8))) *(*int32)(unsafe.Pointer(bp + 8)) = -int32(1) /* * In the case of ints, we need to ensure that a valid string exists * in order for int-but-not-string objects to be converted back to * ints again from mm obj types. */ libtcl9_0.XTcl_GetStringFromObj(tls, objPtr, libc.UintptrFromInt32(0)) } else { if libtcl9_0.XTcl_GetDoubleFromObj(tls, libc.UintptrFromInt32(0), objPtr, bp) == TCL_OK { *(*int32)(unsafe.Pointer(bp + 8)) = -int32(1) } else { /* * It wasn't a known int or double, so parse it. */ string1 = libtcl9_0.XTcl_GetStringFromObj(tls, objPtr, libc.UintptrFromInt32(0)) rest = string1 + uintptr(libc.Xstrlen(tls, string1)) for { if v4 = rest > string1; v4 { v1 = libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(rest + uintptr(-libc.Int32FromInt32(1))))) v2 = libc.BoolInt32(v1 == int32(' ') || libc.Uint32FromInt32(v1)-uint32('\t') < uint32(5)) goto _3 _3: } if !(v4 && v2 != 0) { break } rest-- /* skip all spaces at the end */ } if rest > string1 { rest-- /* point to the character just before the last space */ } if !(rest == string1) { goto _5 } goto error error: ; libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+11394, libc.VaList(bp+24, string1))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+24, __ccgo_ts+179, __ccgo_ts+182, __ccgo_ts+7935, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) _5: ; switch libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(rest))) { case int32('c'): *(*int32)(unsafe.Pointer(bp + 8)) = 0 case int32('i'): *(*int32)(unsafe.Pointer(bp + 8)) = int32(1) case int32('m'): *(*int32)(unsafe.Pointer(bp + 8)) = int32(2) case int32('p'): *(*int32)(unsafe.Pointer(bp + 8)) = int32(3) default: goto error } savechar = *(*uint8)(unsafe.Pointer(rest)) *(*uint8)(unsafe.Pointer(rest)) = uint8('\000') if libtcl9_0.XTcl_GetDouble(tls, libc.UintptrFromInt32(0), string1, bp) != TCL_OK { *(*uint8)(unsafe.Pointer(rest)) = savechar goto error } *(*uint8)(unsafe.Pointer(rest)) = savechar } } /* * Free the old internalRep before setting the new one. */ typePtr = (*TTcl_Obj)(unsafe.Pointer(objPtr)).FtypePtr if typePtr != libc.UintptrFromInt32(0) && (*TTcl_ObjType)(unsafe.Pointer(typePtr)).FfreeIntRepProc != libc.UintptrFromInt32(0) { (*(*func(*libc.TLS, uintptr))(unsafe.Pointer(&struct{ uintptr }{(*TTcl_ObjType)(unsafe.Pointer(typePtr)).FfreeIntRepProc})))(tls, objPtr) } (*TTcl_Obj)(unsafe.Pointer(objPtr)).FtypePtr = uintptr(unsafe.Pointer(&_mmObjType)) mmPtr = libtcl9_0.XTcl_Alloc(tls, uint64(32)) (*TMMRep)(unsafe.Pointer(mmPtr)).Fvalue = *(*float64)(unsafe.Pointer(bp)) (*TMMRep)(unsafe.Pointer(mmPtr)).Funits = *(*int32)(unsafe.Pointer(bp + 8)) (*TMMRep)(unsafe.Pointer(mmPtr)).Ftkwin = libc.UintptrFromInt32(0) (*TMMRep)(unsafe.Pointer(mmPtr)).FreturnValue = *(*float64)(unsafe.Pointer(bp)) (*(*struct { Fptr1 uintptr Fptr2 uintptr })(unsafe.Pointer(objPtr + 32))).Fptr1 = mmPtr return TCL_OK } /* *---------------------------------------------------------------------- * * TkGetWindowFromObj -- * * Attempt to return a Tk_Window from the Tcl object "objPtr". If the * object is not already a Tk_Window, an attempt will be made to convert * it to one. * * Results: * The return value is a standard Tcl object result. If an error occurs * during conversion, an error message is left in the interpreter's * result unless "interp" is NULL. * * Side effects: * If the object is not already a Tk_Window, the conversion will free any * old internal representation. * *---------------------------------------------------------------------- */ func XTkGetWindowFromObj(tls *libc.TLS, interp uintptr, tkwin TTk_Window, objPtr uintptr, windowPtr uintptr) (r int32) { /* Place to store resulting window. */ var mainPtr, winPtr uintptr var result int32 var v1 uint64 _, _, _, _ = mainPtr, result, winPtr, v1 mainPtr = (*TTkWindow)(unsafe.Pointer(tkwin)).FmainPtr if (*TTcl_Obj)(unsafe.Pointer(objPtr)).FtypePtr != uintptr(unsafe.Pointer(&_windowObjType)) { result = _SetWindowFromAny(tls, interp, objPtr) if result != TCL_OK { return result } } winPtr = (*(*struct { Fptr1 uintptr Fptr2 uintptr })(unsafe.Pointer(objPtr + 32))).Fptr1 if (*TWindowRep)(unsafe.Pointer(winPtr)).Ftkwin == libc.UintptrFromInt32(0) || (*TWindowRep)(unsafe.Pointer(winPtr)).FmainPtr == libc.UintptrFromInt32(0) || (*TWindowRep)(unsafe.Pointer(winPtr)).FmainPtr != mainPtr || (*TWindowRep)(unsafe.Pointer(winPtr)).Fepoch != (*TTkMainInfo)(unsafe.Pointer(mainPtr)).FdeletionEpoch { /* * Cache is invalid. */ (*TWindowRep)(unsafe.Pointer(winPtr)).Ftkwin = XTk_NameToWindow(tls, interp, libtcl9_0.XTcl_GetStringFromObj(tls, objPtr, libc.UintptrFromInt32(0)), tkwin) if (*TWindowRep)(unsafe.Pointer(winPtr)).Ftkwin == libc.UintptrFromInt32(0) { /* ASSERT: Tk_NameToWindow has left error message in interp */ return int32(TCL_ERROR) } (*TWindowRep)(unsafe.Pointer(winPtr)).FmainPtr = mainPtr if mainPtr != 0 { v1 = (*TTkMainInfo)(unsafe.Pointer(mainPtr)).FdeletionEpoch } else { v1 = uint64(0) } (*TWindowRep)(unsafe.Pointer(winPtr)).Fepoch = v1 } *(*TTk_Window)(unsafe.Pointer(windowPtr)) = (*TWindowRep)(unsafe.Pointer(winPtr)).Ftkwin return TCL_OK } /* *---------------------------------------------------------------------- * * SetWindowFromAny -- * * Generate a windowObj internal form for the Tcl object "objPtr". * * Results: * Always returns TCL_OK. * * Side effects: * Sets objPtr's internal representation to an uninitialized windowObj. * Frees the old internal representation, if any. * * See also: * TkGetWindowFromObj, which initializes the WindowRep cache. * *---------------------------------------------------------------------- */ func _SetWindowFromAny(tls *libc.TLS, dummy946 uintptr, objPtr uintptr) (r int32) { /* The object to convert. */ var typePtr, winPtr uintptr _, _ = typePtr, winPtr /* * Free the old internalRep before setting the new one. */ libtcl9_0.XTcl_GetStringFromObj(tls, objPtr, libc.UintptrFromInt32(0)) typePtr = (*TTcl_Obj)(unsafe.Pointer(objPtr)).FtypePtr if typePtr != libc.UintptrFromInt32(0) && (*TTcl_ObjType)(unsafe.Pointer(typePtr)).FfreeIntRepProc != libc.UintptrFromInt32(0) { (*(*func(*libc.TLS, uintptr))(unsafe.Pointer(&struct{ uintptr }{(*TTcl_ObjType)(unsafe.Pointer(typePtr)).FfreeIntRepProc})))(tls, objPtr) } winPtr = libtcl9_0.XTcl_Alloc(tls, uint64(24)) (*TWindowRep)(unsafe.Pointer(winPtr)).Ftkwin = libc.UintptrFromInt32(0) (*TWindowRep)(unsafe.Pointer(winPtr)).FmainPtr = libc.UintptrFromInt32(0) (*TWindowRep)(unsafe.Pointer(winPtr)).Fepoch = uint64(0) (*(*struct { Fptr1 uintptr Fptr2 uintptr })(unsafe.Pointer(objPtr + 32))).Fptr1 = winPtr (*TTcl_Obj)(unsafe.Pointer(objPtr)).FtypePtr = uintptr(unsafe.Pointer(&_windowObjType)) return TCL_OK } /* *---------------------------------------------------------------------- * * DupWindowInternalRep -- * * Initialize the internal representation of a window Tcl_Obj to a copy * of the internal representation of an existing window object. * * Results: * None. * * Side effects: * copyPtr's internal rep is set to refer to the same window as srcPtr's * internal rep. * *---------------------------------------------------------------------- */ func _DupWindowInternalRep(tls *libc.TLS, srcPtr uintptr, copyPtr uintptr) { var newPtr, oldPtr uintptr _, _ = newPtr, oldPtr oldPtr = (*(*struct { Fptr1 uintptr Fptr2 uintptr })(unsafe.Pointer(srcPtr + 32))).Fptr1 newPtr = libtcl9_0.XTcl_Alloc(tls, uint64(24)) (*TWindowRep)(unsafe.Pointer(newPtr)).Ftkwin = (*TWindowRep)(unsafe.Pointer(oldPtr)).Ftkwin (*TWindowRep)(unsafe.Pointer(newPtr)).FmainPtr = (*TWindowRep)(unsafe.Pointer(oldPtr)).FmainPtr (*TWindowRep)(unsafe.Pointer(newPtr)).Fepoch = (*TWindowRep)(unsafe.Pointer(oldPtr)).Fepoch (*(*struct { Fptr1 uintptr Fptr2 uintptr })(unsafe.Pointer(copyPtr + 32))).Fptr1 = newPtr (*TTcl_Obj)(unsafe.Pointer(copyPtr)).FtypePtr = (*TTcl_Obj)(unsafe.Pointer(srcPtr)).FtypePtr } /* *---------------------------------------------------------------------- * * FreeWindowInternalRep -- * * Deallocate the storage associated with a window object's internal * representation. * * Results: * None. * * Side effects: * Frees objPtr's internal representation and sets objPtr's internalRep * to NULL. * *---------------------------------------------------------------------- */ func _FreeWindowInternalRep(tls *libc.TLS, objPtr uintptr) { /* Window object with internal rep to free. */ libtcl9_0.XTcl_Free(tls, (*(*struct { Fptr1 uintptr Fptr2 uintptr })(unsafe.Pointer(objPtr + 32))).Fptr1) (*(*struct { Fptr1 uintptr Fptr2 uintptr })(unsafe.Pointer(objPtr + 32))).Fptr1 = libc.UintptrFromInt32(0) (*TTcl_Obj)(unsafe.Pointer(objPtr)).FtypePtr = libc.UintptrFromInt32(0) } /* *---------------------------------------------------------------------- * * Tk_NewWindowObj -- * * This function allocates a new Tcl_Obj that refers to a particular * Tk window. * * Results: * A standard Tcl object reference, with refcount 0. * * Side effects: * None. * *---------------------------------------------------------------------- */ func XTk_NewWindowObj(tls *libc.TLS, tkwin TTk_Window) (r uintptr) { var mainPtr, objPtr, winPtr uintptr _, _, _ = mainPtr, objPtr, winPtr objPtr = libtcl9_0.XTcl_NewStringObj(tls, (*TTk_FakeWin)(unsafe.Pointer(tkwin)).FpathName, int64(-libc.Int32FromInt32(1))) mainPtr = (*TTkWindow)(unsafe.Pointer(tkwin)).FmainPtr _SetWindowFromAny(tls, libc.UintptrFromInt32(0), objPtr) winPtr = (*(*struct { Fptr1 uintptr Fptr2 uintptr })(unsafe.Pointer(objPtr + 32))).Fptr1 (*TWindowRep)(unsafe.Pointer(winPtr)).Ftkwin = tkwin (*TWindowRep)(unsafe.Pointer(winPtr)).FmainPtr = mainPtr (*TWindowRep)(unsafe.Pointer(winPtr)).Fepoch = (*TTkMainInfo)(unsafe.Pointer(mainPtr)).FdeletionEpoch return objPtr } /* *---------------------------------------------------------------------- * * TkParsePadAmount -- * * This function parses a padding specification and returns the * appropriate padding values. A padding specification can be either a * single pixel width, or a list of two pixel widths. If a single pixel * width, the amount specified is used for padding on both sides. If two * amounts are specified, then they specify the left/right or top/bottom * padding. * * Results: * A standard Tcl return value. * * Side effects: * An error message is written to the interpreter if something is not * right. * *---------------------------------------------------------------------- */ func XTkParsePadAmount(tls *libc.TLS, interp uintptr, tkwin TTk_Window, specObj uintptr, halfPtr uintptr, allPtr uintptr) (r int32) { bp := tls.Alloc(80) defer tls.Free(80) /* Write the total padding here */ var _ /* firstInt at bp+0 */ int32 var _ /* objc at bp+8 */ TTcl_Size var _ /* objv at bp+16 */ uintptr var _ /* secondInt at bp+4 */ int32 /* The objects in the list */ /* * Check for a common case where a single object would otherwise be * shimmered between a list and a pixel spec. */ if (*TTcl_Obj)(unsafe.Pointer(specObj)).FtypePtr == uintptr(unsafe.Pointer(&_pixelObjType)) { if XTk_GetPixelsFromObj(tls, interp, tkwin, specObj, bp) != TCL_OK { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+14187, libc.VaList(bp+32, libtcl9_0.XTcl_GetStringFromObj(tls, specObj, libc.UintptrFromInt32(0))))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+32, __ccgo_ts+179, __ccgo_ts+182, __ccgo_ts+14240, __ccgo_ts+14248, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) } *(*int32)(unsafe.Pointer(bp + 4)) = *(*int32)(unsafe.Pointer(bp)) goto done } /* * Pad specifications are a list of one or two elements, each of which is * a pixel specification. */ if libtcl9_0.XTcl_ListObjGetElements(tls, interp, specObj, bp+8, bp+16) != TCL_OK { return int32(TCL_ERROR) } if *(*TTcl_Size)(unsafe.Pointer(bp + 8)) != int64(1) && *(*TTcl_Size)(unsafe.Pointer(bp + 8)) != int64(2) { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+14253, int64(-libc.Int32FromInt32(1)))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+32, __ccgo_ts+179, __ccgo_ts+182, __ccgo_ts+14240, __ccgo_ts+14296, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) } /* * Parse the first part. */ if XTk_GetPixelsFromObj(tls, interp, tkwin, *(*uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 16)))), bp) != TCL_OK || *(*int32)(unsafe.Pointer(bp)) < 0 { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+14187, libc.VaList(bp+32, libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 16)))), libc.UintptrFromInt32(0))))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+32, __ccgo_ts+179, __ccgo_ts+182, __ccgo_ts+14240, __ccgo_ts+14248, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) } /* * Parse the second part if it exists, otherwise it is as if it was the * same as the first part. */ if *(*TTcl_Size)(unsafe.Pointer(bp + 8)) == int64(1) { *(*int32)(unsafe.Pointer(bp + 4)) = *(*int32)(unsafe.Pointer(bp)) } else { if XTk_GetPixelsFromObj(tls, interp, tkwin, *(*uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 16)) + 1*8)), bp+4) != TCL_OK || *(*int32)(unsafe.Pointer(bp + 4)) < 0 { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+14302, libc.VaList(bp+32, libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 16)) + 1*8)), libc.UintptrFromInt32(0))))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+32, __ccgo_ts+179, __ccgo_ts+182, __ccgo_ts+14240, __ccgo_ts+14248, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) } } /* * Write the parsed bits back into the receiving variables. */ goto done done: ; if halfPtr != uintptr(0) { *(*int32)(unsafe.Pointer(halfPtr)) = *(*int32)(unsafe.Pointer(bp)) } *(*int32)(unsafe.Pointer(allPtr)) = *(*int32)(unsafe.Pointer(bp)) + *(*int32)(unsafe.Pointer(bp + 4)) return TCL_OK } /* *---------------------------------------------------------------------- * * TkRegisterObjTypes -- * * Registers Tk's Tcl_ObjType structures with the Tcl run-time. * * Results: * None * * Side effects: * All instances of Tcl_ObjType structures used in Tk are registered with * Tcl. * *---------------------------------------------------------------------- */ func XTkRegisterObjTypes(tls *libc.TLS) { libtcl9_0.XTcl_RegisterObjType(tls, uintptr(unsafe.Pointer(&XtkBorderObjType))) libtcl9_0.XTcl_RegisterObjType(tls, uintptr(unsafe.Pointer(&XtkBitmapObjType))) libtcl9_0.XTcl_RegisterObjType(tls, uintptr(unsafe.Pointer(&XtkColorObjType))) libtcl9_0.XTcl_RegisterObjType(tls, uintptr(unsafe.Pointer(&XtkCursorObjType))) libtcl9_0.XTcl_RegisterObjType(tls, uintptr(unsafe.Pointer(&XtkFontObjType))) libtcl9_0.XTcl_RegisterObjType(tls, uintptr(unsafe.Pointer(&_mmObjType))) libtcl9_0.XTcl_RegisterObjType(tls, uintptr(unsafe.Pointer(&_pixelObjType))) libtcl9_0.XTcl_RegisterObjType(tls, uintptr(unsafe.Pointer(&XtkStateKeyObjType))) libtcl9_0.XTcl_RegisterObjType(tls, uintptr(unsafe.Pointer(&_windowObjType))) libtcl9_0.XTcl_RegisterObjType(tls, uintptr(unsafe.Pointer(&XtkTextIndexType))) } const TK_CONFIG_OPTION_SPECIFIED = 16 /* *-------------------------------------------------------------- * * Tk_ConfigureWidget -- * * Process command-line options and database options to fill in fields of * a widget record with resources and other parameters. * * Results: * A standard Tcl return value. In case of an error, the interp's result * will hold an error message. * * Side effects: * The fields of widgRec get filled in with information from objc/objv * and the option database. Old information in widgRec's fields gets * recycled. A copy of the spec-table is taken with (some of) the char* * fields converted into Tk_Uid fields; this copy will be released when * the interpreter terminates. * *-------------------------------------------------------------- */ func XTk_ConfigureWidget(tls *libc.TLS, interp uintptr, tkwin TTk_Window, specs uintptr, objc TTcl_Size, objv uintptr, widgRec uintptr, flags int32) (r int32) { bp := tls.Alloc(32) defer tls.Free(32) /* Used to specify additional flags that must * be present in config specs for them to be * considered. Also, may have * TK_CONFIG_ARGV_ONLY set. */ var _objPtr, _objPtr1, _objPtr2, _objPtr3, arg, arg1, arg2, specPtr, staticSpecs, v11, v5, v7, v9 uintptr var hateFlags, needFlags int32 var value TTk_Uid var v10, v4, v6, v8 TTcl_Size _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = _objPtr, _objPtr1, _objPtr2, _objPtr3, arg, arg1, arg2, hateFlags, needFlags, specPtr, staticSpecs, value, v10, v11, v4, v5, v6, v7, v8, v9 /* If a spec contains any bits here, it's not * considered. */ if tkwin == libc.UintptrFromInt32(0) { /* * Either we're not really in Tk, or the main window was destroyed and * we're on our way out of the application */ libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+14359, int64(-libc.Int32FromInt32(1)))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+8, __ccgo_ts+179, __ccgo_ts+14376, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) } needFlags = flags & ^(libc.Int32FromInt32(TK_CONFIG_USER_BIT) - libc.Int32FromInt32(1)) if (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fdepth <= int32(1) { hateFlags = libc.Int32FromInt32(1) << libc.Int32FromInt32(1) } else { hateFlags = libc.Int32FromInt32(1) << libc.Int32FromInt32(2) } /* * Get the build of the config for this interpreter. */ staticSpecs = _GetCachedSpecs(tls, interp, specs) specPtr = staticSpecs for { if !((*TTk_ConfigSpec)(unsafe.Pointer(specPtr)).Ftype1 != int32(TK_CONFIG_END)) { break } *(*int32)(unsafe.Pointer(specPtr + 48)) &= ^(libc.Int32FromInt32(1) << libc.Int32FromInt32(4)) goto _1 _1: ; specPtr += 64 } /* * Pass one: scan through all of the arguments, processing those that * match entries in the specs. */ for { if !(objc > 0) { break } arg = libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv)), libc.UintptrFromInt32(0)) specPtr = _FindConfigSpec(tls, interp, staticSpecs, arg, needFlags, hateFlags) if specPtr == libc.UintptrFromInt32(0) { return int32(TCL_ERROR) } /* * Process the entry. */ if objc < int64(2) { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+3180, libc.VaList(bp+8, arg))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+8, __ccgo_ts+179, __ccgo_ts+8014, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) } if _DoConfig(tls, interp, tkwin, specPtr, *(*uintptr)(unsafe.Pointer(objv + 1*8)), widgRec) != TCL_OK { libtcl9_0.XTcl_AppendObjToErrorInfo(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+8028, libc.VaList(bp+8, (*TTk_ConfigSpec)(unsafe.Pointer(specPtr)).FargvName))) return int32(TCL_ERROR) } if !(flags&libc.Int32FromInt32(TK_CONFIG_ARGV_ONLY) != 0) { *(*int32)(unsafe.Pointer(specPtr + 48)) |= libc.Int32FromInt32(1) << libc.Int32FromInt32(4) } goto _2 _2: ; objc -= int64(2) objv += uintptr(2) * 8 } /* * Pass two: scan through all of the specs again; if no command-line * argument matched a spec, then check for info in the option database. * If there was nothing in the database, then use the default. */ if !(flags&libc.Int32FromInt32(TK_CONFIG_ARGV_ONLY) != 0) { specPtr = staticSpecs for { if !((*TTk_ConfigSpec)(unsafe.Pointer(specPtr)).Ftype1 != int32(TK_CONFIG_END)) { break } if (*TTk_ConfigSpec)(unsafe.Pointer(specPtr)).FspecFlags&(libc.Int32FromInt32(1)< int32(TK_MAX_PRIO) { priority = int32(TK_MAX_PRIO) } } (*(*TElement)(unsafe.Pointer(bp))).Fpriority = priority< uint64(TMP_SIZE) { length = uint64(TMP_SIZE) } libc.Xstrncpy(tls, bp+24, field, length) (*(*[101]uint8)(unsafe.Pointer(bp + 24)))[length] = uint8(0) (*(*TElement)(unsafe.Pointer(bp))).FnameUid = XTk_GetUid(tls, bp+24) if libc.BoolInt32(uint32(*(*uint8)(unsafe.Pointer(field)))-uint32('A') < uint32(26)) != 0 { (*(*TElement)(unsafe.Pointer(bp))).Fflags |= int32(CLASS) } if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(p))) != 0 { /* * New element will be a node. If this option can't possibly apply * to this main window, then just skip it. Otherwise, add it to * the parent, if it isn't already there, and descend into it. */ (*(*TElement)(unsafe.Pointer(bp))).Fflags |= int32(NODE) if firstField != 0 && !((*(*TElement)(unsafe.Pointer(bp))).Fflags&libc.Int32FromInt32(WILDCARD) != 0) && (*(*TElement)(unsafe.Pointer(bp))).FnameUid != (*TTkWindow)(unsafe.Pointer(winPtr)).FnameUid && (*(*TElement)(unsafe.Pointer(bp))).FnameUid != (*TTkWindow)(unsafe.Pointer(winPtr)).FclassUid { return } elPtr = *(*uintptr)(unsafe.Pointer(arrayPtrPtr)) + 16 count = (*TElArray)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(arrayPtrPtr)))).FnumUsed for { if count == 0 { *(*uintptr)(unsafe.Pointer(bp + 8)) = _NewArray(tls, int32(5)) *(*uintptr)(unsafe.Pointer(arrayPtrPtr)) = _ExtendArray(tls, *(*uintptr)(unsafe.Pointer(arrayPtrPtr)), bp) arrayPtrPtr = (*TElArray)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(arrayPtrPtr)))).FnextToUse + uintptr(-libc.Int32FromInt32(1))*24 + 8 break } if (*TElement)(unsafe.Pointer(elPtr)).FnameUid == (*(*TElement)(unsafe.Pointer(bp))).FnameUid && (*TElement)(unsafe.Pointer(elPtr)).Fflags == (*(*TElement)(unsafe.Pointer(bp))).Fflags { arrayPtrPtr = elPtr + 8 break } goto _2 _2: ; elPtr += 24 count-- } if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(p))) == int32('.') { p++ } } else { /* * New element is a leaf. Add it to the parent, if it isn't * already there. If it exists already, keep whichever value has * highest priority. */ *(*TTk_Uid)(unsafe.Pointer(bp + 8)) = XTk_GetUid(tls, value) elPtr = *(*uintptr)(unsafe.Pointer(arrayPtrPtr)) + 16 count = (*TElArray)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(arrayPtrPtr)))).FnumUsed for { if count == 0 { *(*uintptr)(unsafe.Pointer(arrayPtrPtr)) = _ExtendArray(tls, *(*uintptr)(unsafe.Pointer(arrayPtrPtr)), bp) return } if (*TElement)(unsafe.Pointer(elPtr)).FnameUid == (*(*TElement)(unsafe.Pointer(bp))).FnameUid && (*TElement)(unsafe.Pointer(elPtr)).Fflags == (*(*TElement)(unsafe.Pointer(bp))).Fflags { if (*TElement)(unsafe.Pointer(elPtr)).Fpriority < (*(*TElement)(unsafe.Pointer(bp))).Fpriority { (*TElement)(unsafe.Pointer(elPtr)).Fpriority = (*(*TElement)(unsafe.Pointer(bp))).Fpriority *(*TTk_Uid)(unsafe.Pointer(elPtr + 8)) = *(*TTk_Uid)(unsafe.Pointer(bp + 8)) } return } goto _3 _3: ; elPtr += 24 count-- } } goto _1 _1: ; firstField = 0 } } /* *-------------------------------------------------------------- * * Tk_GetOption -- * * Retrieve an option from the option database. * * Results: * The return value is the value specified in the option database for the * given name and class on the given window. If there is nothing * specified in the database for that option, then NULL is returned. * * Side effects: * The internal caches used to speed up option mapping may be modified, * if this tkwin is different from the last tkwin used for option * retrieval. * *-------------------------------------------------------------- */ func XTk_GetOption(tls *libc.TLS, tkwin TTk_Window, name uintptr, className uintptr) (r TTk_Uid) { /* Class of option. NULL means there is no * class for this option: just check for * name. */ var bestPtr, currentPtr, elPtr, leafPtr, levelPtr, masqClass, masqName, nodePtr, tsdPtr uintptr var classId, nameId, nodeId, winClassId, winNameId TTk_Uid var classNameLength TTcl_Size var count, currentStack, leafCount int32 var stackDepth [8]int32 _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = bestPtr, classId, classNameLength, count, currentPtr, currentStack, elPtr, leafCount, leafPtr, levelPtr, masqClass, masqName, nameId, nodeId, nodePtr, stackDepth, tsdPtr, winClassId, winNameId classId = libc.UintptrFromInt32(0) tsdPtr = libtcl9_0.XTcl_GetThreadData(tls, uintptr(unsafe.Pointer(&_dataKey6)), int64(128)) /* * Note: no need to call OptionInit here: it will be done by the * SetupStacks call below (squeeze out those nanoseconds). */ if tkwin != (*TThreadSpecificData6)(unsafe.Pointer(tsdPtr)).FcachedWindow { _SetupStacks(tls, tkwin, int32(1)) } /* * Get a default "best" match. */ bestPtr = tsdPtr + 104 /* * For megawidget support, we want to have some widget options masquerade * as options for other widgets. For example, a combobox has a button in * it; this button ought to pick up the *Button.background, etc., options. * But because the class of the widget is Combobox, our normal search * won't get that option. * * To work around this, the option name field syntax was extended to allow * for a "." in the name; if this character occurs in the name, then it * indicates that this name contains a new window class and an option * name, ie, "Button.foreground". If we see this form in the name field, * we query the option database directly (since the option stacks will not * have the information we need). */ masqName = libc.Xstrchr(tls, name, libc.Int32FromUint8('.')) if masqName != libc.UintptrFromInt32(0) { /* * This option is masquerading with a different window class. Search * the stack to the depth it was before the current window's * information was pushed (the value for which is stored in the bases * field). */ levelPtr = (*TThreadSpecificData6)(unsafe.Pointer(tsdPtr)).Flevels + uintptr((*TThreadSpecificData6)(unsafe.Pointer(tsdPtr)).FcurLevel)*40 nameId = XTk_GetUid(tls, masqName+uintptr(1)) count = 0 for { if !(count < int32(NUM_STACKS)) { break } stackDepth[count] = *(*int32)(unsafe.Pointer(levelPtr + 8 + uintptr(count)*4)) goto _1 _1: ; count++ } } else { /* * No option masquerading here. Just use the current level to get the * stack depths. */ nameId = XTk_GetUid(tls, name) count = 0 for { if !(count < int32(NUM_STACKS)) { break } stackDepth[count] = (*TElArray)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(tsdPtr + 8 + uintptr(count)*8)))).FnumUsed goto _2 _2: ; count++ } } /* * Probe the stacks for matches. */ elPtr = *(*uintptr)(unsafe.Pointer(tsdPtr + 8)) + 16 count = stackDepth[EXACT_LEAF_NAME] for { if !(count > 0) { break } if (*TElement)(unsafe.Pointer(elPtr)).FnameUid == nameId && (*TElement)(unsafe.Pointer(elPtr)).Fpriority > (*TElement)(unsafe.Pointer(bestPtr)).Fpriority { bestPtr = elPtr } goto _3 _3: ; elPtr += 24 count-- } elPtr = *(*uintptr)(unsafe.Pointer(tsdPtr + 8 + 4*8)) + 16 count = stackDepth[int32(WILDCARD_LEAF_NAME)] for { if !(count > 0) { break } if (*TElement)(unsafe.Pointer(elPtr)).FnameUid == nameId && (*TElement)(unsafe.Pointer(elPtr)).Fpriority > (*TElement)(unsafe.Pointer(bestPtr)).Fpriority { bestPtr = elPtr } goto _4 _4: ; elPtr += 24 count-- } if className != libc.UintptrFromInt32(0) { classId = XTk_GetUid(tls, className) elPtr = *(*uintptr)(unsafe.Pointer(tsdPtr + 8 + 1*8)) + 16 count = stackDepth[int32(EXACT_LEAF_CLASS)] for { if !(count > 0) { break } if (*TElement)(unsafe.Pointer(elPtr)).FnameUid == classId && (*TElement)(unsafe.Pointer(elPtr)).Fpriority > (*TElement)(unsafe.Pointer(bestPtr)).Fpriority { bestPtr = elPtr } goto _5 _5: ; elPtr += 24 count-- } elPtr = *(*uintptr)(unsafe.Pointer(tsdPtr + 8 + 5*8)) + 16 count = stackDepth[int32(WILDCARD_LEAF_CLASS)] for { if !(count > 0) { break } if (*TElement)(unsafe.Pointer(elPtr)).FnameUid == classId && (*TElement)(unsafe.Pointer(elPtr)).Fpriority > (*TElement)(unsafe.Pointer(bestPtr)).Fpriority { bestPtr = elPtr } goto _6 _6: ; elPtr += 24 count-- } } /* * If this option was masquerading with a different window class, probe * the option database now. Note that this will be inefficient if the * option database is densely populated, or if the widget has many * masquerading options. */ if masqName != libc.UintptrFromInt32(0) { /* * Extract the masquerade class name from the name field. */ classNameLength = int64(masqName) - int64(name) masqClass = libtcl9_0.XTcl_Alloc(tls, libc.Uint64FromInt64(classNameLength+int64(1))) libc.Xstrncpy(tls, masqClass, name, libc.Uint64FromInt64(classNameLength)) *(*uint8)(unsafe.Pointer(masqClass + uintptr(classNameLength))) = uint8('\000') winClassId = XTk_GetUid(tls, masqClass) libtcl9_0.XTcl_Free(tls, masqClass) winNameId = (*TTkWindow)(unsafe.Pointer(tkwin)).FnameUid levelPtr = (*TThreadSpecificData6)(unsafe.Pointer(tsdPtr)).Flevels + uintptr((*TThreadSpecificData6)(unsafe.Pointer(tsdPtr)).FcurLevel)*40 currentPtr = uintptr(unsafe.Pointer(&_searchOrder)) for { if !(*(*int32)(unsafe.Pointer(currentPtr)) != -int32(1)) { break } currentStack = *(*int32)(unsafe.Pointer(currentPtr)) nodePtr = *(*uintptr)(unsafe.Pointer(tsdPtr + 8 + uintptr(currentStack)*8)) + 16 count = *(*int32)(unsafe.Pointer(levelPtr + 8 + uintptr(currentStack)*4)) /* * For wildcard stacks, check all entries; for non-wildcard * stacks, only check things that matched in the parent. */ if !(currentStack&libc.Int32FromInt32(WILDCARD) != 0) { nodePtr += uintptr(*(*int32)(unsafe.Pointer(levelPtr + uintptr(-libc.Int32FromInt32(1))*40 + 8 + uintptr(currentStack)*4))) * 24 count -= *(*int32)(unsafe.Pointer(levelPtr + uintptr(-libc.Int32FromInt32(1))*40 + 8 + uintptr(currentStack)*4)) } if currentStack&int32(CLASS) != 0 { nodeId = winClassId } else { nodeId = winNameId } for { if !(count > 0) { break } if (*TElement)(unsafe.Pointer(nodePtr)).FnameUid == nodeId { leafPtr = *(*uintptr)(unsafe.Pointer(nodePtr + 8)) + 16 leafCount = (*TElArray1)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(nodePtr + 8)))).FnumUsed for { if !(leafCount > 0) { break } if (*TElement)(unsafe.Pointer(leafPtr)).Fflags&int32(CLASS) != 0 && className != libc.UintptrFromInt32(0) { if (*TElement)(unsafe.Pointer(leafPtr)).FnameUid == classId && (*TElement)(unsafe.Pointer(leafPtr)).Fpriority > (*TElement)(unsafe.Pointer(bestPtr)).Fpriority { bestPtr = leafPtr } } else { if (*TElement)(unsafe.Pointer(leafPtr)).FnameUid == nameId && (*TElement)(unsafe.Pointer(leafPtr)).Fpriority > (*TElement)(unsafe.Pointer(bestPtr)).Fpriority { bestPtr = leafPtr } } goto _9 _9: ; leafPtr += 24 leafCount-- } } goto _8 _8: ; nodePtr += 24 count-- } goto _7 _7: ; currentPtr += 4 } } return *(*TTk_Uid)(unsafe.Pointer(bestPtr + 8)) } var _searchOrder = [5]int32{ 0: int32(EXACT_NODE_NAME), 1: int32(WILDCARD_NODE_NAME), 2: int32(EXACT_NODE_CLASS), 3: int32(WILDCARD_NODE_CLASS), 4: -int32(1), } /* *-------------------------------------------------------------- * * Tk_OptionObjCmd -- * * This function is invoked to process the "option" Tcl command. See the * user documentation for details on what it does. * * Results: * A standard Tcl result. * * Side effects: * See the user documentation. * *-------------------------------------------------------------- */ func XTk_OptionObjCmd(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) (r int32) { bp := tls.Alloc(16) defer tls.Free(16) /* Tcl_Obj arguments. */ var mainPtr, tsdPtr uintptr var priority, priority1, result int32 var tkwin, window TTk_Window var value TTk_Uid var _ /* index at bp+0 */ int32 _, _, _, _, _, _, _, _ = mainPtr, priority, priority1, result, tkwin, tsdPtr, value, window tkwin = clientData tsdPtr = libtcl9_0.XTcl_GetThreadData(tls, uintptr(unsafe.Pointer(&_dataKey6)), int64(128)) if objc < int32(2) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(1), objv, __ccgo_ts+14596) return int32(TCL_ERROR) } result = libtcl9_0.XTcl_GetIndexFromObjStruct(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 1*8)), uintptr(unsafe.Pointer(&_optionCmds)), libc.Int64FromUint64(libc.Uint64FromInt64(8)), __ccgo_ts+2689, libc.Int32FromInt32(0)|libc.Int32FromUint64(libc.Uint64FromInt64(4)< int32(100) { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+14727, libc.VaList(bp+16, string1))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+16, __ccgo_ts+179, __ccgo_ts+182, __ccgo_ts+14844, libc.UintptrFromInt32(0))) return -int32(1) } } } } } return priority } /* *---------------------------------------------------------------------- * * AddFromString -- * * Given a string containing lines in the standard format for X resources * (see other documentation for details on what this is), parse the * resource specifications and enter them as options for tkwin's main * window. * * Results: * The return value is a standard Tcl return code. In the case of an * error in parsing string, TCL_ERROR will be returned and an error * message will be left in the interp's result. The memory at string is * totally trashed by this function. If you care about its contents, make * a copy before calling here. * * Side effects: * None. * *---------------------------------------------------------------------- */ func _AddFromString(tls *libc.TLS, interp uintptr, tkwin TTk_Window, string1 uintptr, priority int32) (r int32) { bp := tls.Alloc(48) defer tls.Free(48) /* Priority level to use for options in this * string, such as TK_USER_DEFAULT_PRIO or * TK_INTERACTIVE_PRIO. Must be between 0 and * TK_MAX_PRIO. */ var dst, name, src, value, v1, v2, v3, v4, v5, v6 uintptr var lineNum int32 _, _, _, _, _, _, _, _, _, _, _ = dst, lineNum, name, src, value, v1, v2, v3, v4, v5, v6 src = string1 lineNum = int32(1) for int32(1) != 0 { /* * Skip leading white space and empty lines and comment lines, and * check for the end of the spec. */ for libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(src))) == int32(' ') || libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(src))) == int32('\t') { src++ } if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(src))) == int32('#') || libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(src))) == int32('!') { for cond := true; cond; cond = libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(src))) != int32('\n') && libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(src))) != 0 { src++ if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(src))) == int32('\\') && libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(src + 1))) == int32('\n') { src += uintptr(2) lineNum++ } } } if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(src))) == int32('\n') { src++ lineNum++ continue } if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(src))) == int32('\000') { break } /* * Parse off the option name, collapsing out backslash-newline * sequences of course. */ v1 = src name = v1 dst = v1 for libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(src))) != int32(':') { if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(src))) == int32('\000') || libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(src))) == int32('\n') { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+14853, libc.VaList(bp+8, lineNum))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+8, __ccgo_ts+179, __ccgo_ts+14878, __ccgo_ts+14887, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) } if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(src))) == int32('\\') && libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(src + 1))) == int32('\n') { src += uintptr(2) lineNum++ } else { *(*uint8)(unsafe.Pointer(dst)) = *(*uint8)(unsafe.Pointer(src)) dst++ src++ } } /* * Eliminate trailing white space on the name, and null-terminate * it. */ for dst != name && (libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(dst + uintptr(-libc.Int32FromInt32(1))))) == int32(' ') || libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(dst + uintptr(-libc.Int32FromInt32(1))))) == int32('\t')) { dst-- } *(*uint8)(unsafe.Pointer(dst)) = uint8('\000') /* * Skip white space between the name and the value. */ src++ for libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(src))) == int32(' ') || libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(src))) == int32('\t') { src++ } if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(src))) == int32('\\') && (libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(src + 1))) == int32('\t') || libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(src + 1))) == int32(' ')) { src++ } if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(src))) == int32('\000') { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+14893, libc.VaList(bp+8, lineNum))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+8, __ccgo_ts+179, __ccgo_ts+14878, __ccgo_ts+182, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) } /* * Parse off the value, squeezing out backslash-newline sequences * along the way. */ v2 = src value = v2 dst = v2 for libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(src))) != int32('\n') { if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(src))) == int32('\000') { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+14918, libc.VaList(bp+8, lineNum))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+8, __ccgo_ts+179, __ccgo_ts+14878, __ccgo_ts+14945, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) } if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(src))) == int32('\\') { if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(src + 1))) == int32('\n') { src += uintptr(2) lineNum++ continue } else { if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(src + 1))) == int32('n') { src += uintptr(2) v3 = dst dst++ *(*uint8)(unsafe.Pointer(v3)) = uint8('\n') continue } else { if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(src + 1))) == int32('\\') { src++ } else { if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(src + 1))) >= int32('0') && libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(src + 1))) <= int32('3') && libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(src + 2))) >= int32('0') && libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(src + 2))) <= int32('9') && libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(src + 3))) >= int32('0') && libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(src + 3))) <= int32('9') { v4 = dst dst++ *(*uint8)(unsafe.Pointer(v4)) = libc.Uint8FromInt32(libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(src + 1)))&int32(7)<= (*TElArray)(unsafe.Pointer(arrayPtr)).FarraySize { newSize = int32(2) * (*TElArray)(unsafe.Pointer(arrayPtr)).FarraySize arrayPtr = libtcl9_0.XTcl_Realloc(tls, arrayPtr, uint64(uint32(libc.Uint64FromInt64(40)+libc.Uint64FromInt32(newSize-libc.Int32FromInt32(1))*libc.Uint64FromInt64(24)))) (*TElArray)(unsafe.Pointer(arrayPtr)).FarraySize = newSize (*TElArray)(unsafe.Pointer(arrayPtr)).FnextToUse = arrayPtr + 16 + uintptr((*TElArray)(unsafe.Pointer(arrayPtr)).FnumUsed)*24 } *(*TElement)(unsafe.Pointer((*TElArray)(unsafe.Pointer(arrayPtr)).FnextToUse)) = *(*TElement)(unsafe.Pointer(elPtr)) (*TElArray)(unsafe.Pointer(arrayPtr)).FnextToUse += 24 (*TElArray)(unsafe.Pointer(arrayPtr)).FnumUsed++ return arrayPtr } /* *-------------------------------------------------------------- * * SetupStacks -- * * Arrange the stacks so that they cache all the option information for a * particular window. * * Results: * None. * * Side effects: * The stacks are modified to hold information for tkwin and all its * ancestors in the window hierarchy. * *-------------------------------------------------------------- */ func _SetupStacks(tls *libc.TLS, winPtr uintptr, leaf int32) { /* Non-zero means this is the leaf window * being probed. Zero means this is an * ancestor of the desired leaf. */ var arrayPtr, elPtr, iPtr, levelPtr, newLevels, tsdPtr uintptr var count, i, level int32 var id TTk_Uid var v2 TTcl_Size _, _, _, _, _, _, _, _, _, _, _ = arrayPtr, count, elPtr, i, iPtr, id, level, levelPtr, newLevels, tsdPtr, v2 tsdPtr = libtcl9_0.XTcl_GetThreadData(tls, uintptr(unsafe.Pointer(&_dataKey6)), int64(128)) if (*TTkMainInfo)(unsafe.Pointer((*TTkWindow)(unsafe.Pointer(winPtr)).FmainPtr)).FoptionRootPtr == libc.UintptrFromInt32(0) { _OptionInit(tls, (*TTkWindow)(unsafe.Pointer(winPtr)).FmainPtr) } /* * Step 1: make sure that options are cached for this window's parent. */ if (*TTkWindow)(unsafe.Pointer(winPtr)).FparentPtr != libc.UintptrFromInt32(0) { level = int32((*TTkWindow1)(unsafe.Pointer((*TTkWindow)(unsafe.Pointer(winPtr)).FparentPtr)).FoptionLevel) if level == -int32(1) || (*TThreadSpecificData6)(unsafe.Pointer(tsdPtr)).FcachedWindow == libc.UintptrFromInt32(0) { _SetupStacks(tls, (*TTkWindow)(unsafe.Pointer(winPtr)).FparentPtr, 0) level = int32((*TTkWindow1)(unsafe.Pointer((*TTkWindow)(unsafe.Pointer(winPtr)).FparentPtr)).FoptionLevel) } level++ } else { level = int32(1) } /* * Step 2: pop extra unneeded information off the stacks and mark those * windows as no longer having cached information. */ if (*TThreadSpecificData6)(unsafe.Pointer(tsdPtr)).FcurLevel >= level { for (*TThreadSpecificData6)(unsafe.Pointer(tsdPtr)).FcurLevel >= level { (*TTkWindow)(unsafe.Pointer((*(*TStackLevel)(unsafe.Pointer((*TThreadSpecificData6)(unsafe.Pointer(tsdPtr)).Flevels + uintptr((*TThreadSpecificData6)(unsafe.Pointer(tsdPtr)).FcurLevel)*40))).FwinPtr)).FoptionLevel = int64(-libc.Int32FromInt32(1)) (*TThreadSpecificData6)(unsafe.Pointer(tsdPtr)).FcurLevel-- } levelPtr = (*TThreadSpecificData6)(unsafe.Pointer(tsdPtr)).Flevels + uintptr(level)*40 i = 0 for { if !(i < int32(NUM_STACKS)) { break } arrayPtr = *(*uintptr)(unsafe.Pointer(tsdPtr + 8 + uintptr(i)*8)) (*TElArray)(unsafe.Pointer(arrayPtr)).FnumUsed = *(*int32)(unsafe.Pointer(levelPtr + 8 + uintptr(i)*4)) (*TElArray)(unsafe.Pointer(arrayPtr)).FnextToUse = arrayPtr + 16 + uintptr((*TElArray)(unsafe.Pointer(arrayPtr)).FnumUsed)*24 goto _1 _1: ; i++ } } v2 = int64(level) (*TTkWindow)(unsafe.Pointer(winPtr)).FoptionLevel = v2 (*TThreadSpecificData6)(unsafe.Pointer(tsdPtr)).FcurLevel = int32(v2) /* * Step 3: if the root database information isn't loaded or isn't valid, * initialize level 0 of the stack from the database root (this only * happens if winPtr is a main window). */ if (*TThreadSpecificData6)(unsafe.Pointer(tsdPtr)).FcurLevel == int32(1) && ((*TThreadSpecificData6)(unsafe.Pointer(tsdPtr)).FcachedWindow == libc.UintptrFromInt32(0) || (*TTkWindow)(unsafe.Pointer((*TThreadSpecificData6)(unsafe.Pointer(tsdPtr)).FcachedWindow)).FmainPtr != (*TTkWindow)(unsafe.Pointer(winPtr)).FmainPtr) { i = 0 for { if !(i < int32(NUM_STACKS)) { break } arrayPtr = *(*uintptr)(unsafe.Pointer(tsdPtr + 8 + uintptr(i)*8)) (*TElArray)(unsafe.Pointer(arrayPtr)).FnumUsed = 0 (*TElArray)(unsafe.Pointer(arrayPtr)).FnextToUse = arrayPtr + 16 goto _3 _3: ; i++ } _ExtendStacks(tls, (*TTkMainInfo)(unsafe.Pointer((*TTkWindow)(unsafe.Pointer(winPtr)).FmainPtr)).FoptionRootPtr, 0) } /* * Step 4: create a new stack level; grow the level array if we've run out * of levels. Clear the stacks for EXACT_LEAF_NAME and EXACT_LEAF_CLASS * (anything that was there is of no use any more). */ if (*TThreadSpecificData6)(unsafe.Pointer(tsdPtr)).FcurLevel >= (*TThreadSpecificData6)(unsafe.Pointer(tsdPtr)).FnumLevels { newLevels = libtcl9_0.XTcl_Alloc(tls, libc.Uint64FromInt32((*TThreadSpecificData6)(unsafe.Pointer(tsdPtr)).FnumLevels*int32(2))*uint64(40)) libc.Xmemcpy(tls, newLevels, (*TThreadSpecificData6)(unsafe.Pointer(tsdPtr)).Flevels, libc.Uint64FromInt32((*TThreadSpecificData6)(unsafe.Pointer(tsdPtr)).FnumLevels)*uint64(40)) libtcl9_0.XTcl_Free(tls, (*TThreadSpecificData6)(unsafe.Pointer(tsdPtr)).Flevels) *(*int32)(unsafe.Pointer(tsdPtr + 88)) *= int32(2) (*TThreadSpecificData6)(unsafe.Pointer(tsdPtr)).Flevels = newLevels } levelPtr = (*TThreadSpecificData6)(unsafe.Pointer(tsdPtr)).Flevels + uintptr((*TThreadSpecificData6)(unsafe.Pointer(tsdPtr)).FcurLevel)*40 (*TStackLevel)(unsafe.Pointer(levelPtr)).FwinPtr = winPtr arrayPtr = *(*uintptr)(unsafe.Pointer(tsdPtr + 8)) (*TElArray)(unsafe.Pointer(arrayPtr)).FnumUsed = 0 (*TElArray)(unsafe.Pointer(arrayPtr)).FnextToUse = arrayPtr + 16 arrayPtr = *(*uintptr)(unsafe.Pointer(tsdPtr + 8 + 1*8)) (*TElArray)(unsafe.Pointer(arrayPtr)).FnumUsed = 0 (*TElArray)(unsafe.Pointer(arrayPtr)).FnextToUse = arrayPtr + 16 i = 0 for { if !(i < int32(NUM_STACKS)) { break } *(*int32)(unsafe.Pointer(levelPtr + 8 + uintptr(i)*4)) = (*TElArray)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(tsdPtr + 8 + uintptr(i)*8)))).FnumUsed goto _4 _4: ; i++ } /* * Step 5: scan the current stack level looking for matches to this * window's name or class; where found, add new information to the stacks. */ iPtr = uintptr(unsafe.Pointer(&_searchOrder1)) for { if !(*(*int32)(unsafe.Pointer(iPtr)) != -int32(1)) { break } i = *(*int32)(unsafe.Pointer(iPtr)) if i&int32(CLASS) != 0 { id = (*TTkWindow)(unsafe.Pointer(winPtr)).FclassUid } else { id = (*TTkWindow)(unsafe.Pointer(winPtr)).FnameUid } elPtr = *(*uintptr)(unsafe.Pointer(tsdPtr + 8 + uintptr(i)*8)) + 16 count = *(*int32)(unsafe.Pointer(levelPtr + 8 + uintptr(i)*4)) /* * For wildcard stacks, check all entries; for non-wildcard stacks, * only check things that matched in the parent. */ if !(i&libc.Int32FromInt32(WILDCARD) != 0) { elPtr += uintptr(*(*int32)(unsafe.Pointer(levelPtr + uintptr(-libc.Int32FromInt32(1))*40 + 8 + uintptr(i)*4))) * 24 count -= *(*int32)(unsafe.Pointer(levelPtr + uintptr(-libc.Int32FromInt32(1))*40 + 8 + uintptr(i)*4)) } for { if !(count > 0) { break } if (*TElement)(unsafe.Pointer(elPtr)).FnameUid != id { goto _6 } _ExtendStacks(tls, *(*uintptr)(unsafe.Pointer(elPtr + 8)), leaf) goto _6 _6: ; elPtr += 24 count-- } goto _5 _5: ; iPtr += 4 } (*TThreadSpecificData6)(unsafe.Pointer(tsdPtr)).FcachedWindow = winPtr } /* * The following array defines the order in which the current stacks are * searched to find matching entries to add to the stacks. Given the * current priority-based scheme, the order below is no longer relevant; * all that matters is that an element is on the list *somewhere*. The * ordering is a relic of the old days when priorities were determined * differently. */ var _searchOrder1 = [5]int32{ 0: int32(WILDCARD_NODE_CLASS), 1: int32(WILDCARD_NODE_NAME), 2: int32(EXACT_NODE_CLASS), 3: int32(EXACT_NODE_NAME), 4: -int32(1), } /* *-------------------------------------------------------------- * * ExtendStacks -- * * Given an element array, copy all the elements from the array onto the * system stacks (except for irrelevant leaf elements). * * Results: * None. * * Side effects: * The option stacks are extended. * *-------------------------------------------------------------- */ func _ExtendStacks(tls *libc.TLS, arrayPtr uintptr, leaf int32) { /* If zero, then don't copy exact leaf * elements. */ var count int32 var elPtr, tsdPtr uintptr _, _, _ = count, elPtr, tsdPtr tsdPtr = libtcl9_0.XTcl_GetThreadData(tls, uintptr(unsafe.Pointer(&_dataKey6)), int64(128)) elPtr = arrayPtr + 16 count = (*TElArray)(unsafe.Pointer(arrayPtr)).FnumUsed for { if !(count > 0) { break } if !((*TElement)(unsafe.Pointer(elPtr)).Fflags&(libc.Int32FromInt32(NODE)|libc.Int32FromInt32(WILDCARD)) != 0) && !(leaf != 0) { goto _1 } *(*uintptr)(unsafe.Pointer(tsdPtr + 8 + uintptr((*TElement)(unsafe.Pointer(elPtr)).Fflags)*8)) = _ExtendArray(tls, *(*uintptr)(unsafe.Pointer(tsdPtr + 8 + uintptr((*TElement)(unsafe.Pointer(elPtr)).Fflags)*8)), elPtr) goto _1 _1: ; elPtr += 24 count-- } } /* *-------------------------------------------------------------- * * OptionThreadExitProc -- * * Free data structures for option handling. * * Results: * None. * * Side effects: * Option-related data structures get freed. * *-------------------------------------------------------------- */ func _OptionThreadExitProc(tls *libc.TLS, dummy1423 uintptr) { var i int32 var tsdPtr uintptr _, _ = i, tsdPtr tsdPtr = libtcl9_0.XTcl_GetThreadData(tls, uintptr(unsafe.Pointer(&_dataKey6)), int64(128)) if (*TThreadSpecificData6)(unsafe.Pointer(tsdPtr)).Finitialized != 0 { i = 0 for { if !(i < int32(NUM_STACKS)) { break } libtcl9_0.XTcl_Free(tls, *(*uintptr)(unsafe.Pointer(tsdPtr + 8 + uintptr(i)*8))) goto _1 _1: ; i++ } libtcl9_0.XTcl_Free(tls, (*TThreadSpecificData6)(unsafe.Pointer(tsdPtr)).Flevels) (*TThreadSpecificData6)(unsafe.Pointer(tsdPtr)).Finitialized = 0 } } /* *-------------------------------------------------------------- * * OptionInit -- * * Initialize data structures for option handling. * * Results: * None. * * Side effects: * Option-related data structures get initialized. * *-------------------------------------------------------------- */ func _OptionInit(tls *libc.TLS, mainPtr uintptr) { /* Top-level information about window that * isn't initialized yet. */ var defaultMatchPtr, interp, tsdPtr uintptr var i int32 _, _, _, _ = defaultMatchPtr, i, interp, tsdPtr tsdPtr = libtcl9_0.XTcl_GetThreadData(tls, uintptr(unsafe.Pointer(&_dataKey6)), int64(128)) defaultMatchPtr = tsdPtr + 104 /* * First, once-only initialization. */ if (*TThreadSpecificData6)(unsafe.Pointer(tsdPtr)).Finitialized == 0 { (*TThreadSpecificData6)(unsafe.Pointer(tsdPtr)).Finitialized = int32(1) (*TThreadSpecificData6)(unsafe.Pointer(tsdPtr)).FcachedWindow = libc.UintptrFromInt32(0) (*TThreadSpecificData6)(unsafe.Pointer(tsdPtr)).FnumLevels = int32(5) (*TThreadSpecificData6)(unsafe.Pointer(tsdPtr)).FcurLevel = -int32(1) (*TThreadSpecificData6)(unsafe.Pointer(tsdPtr)).Fserial = 0 (*TThreadSpecificData6)(unsafe.Pointer(tsdPtr)).Flevels = libtcl9_0.XTcl_Alloc(tls, libc.Uint64FromInt32(5)*libc.Uint64FromInt64(40)) i = 0 for { if !(i < int32(NUM_STACKS)) { break } *(*uintptr)(unsafe.Pointer(tsdPtr + 8 + uintptr(i)*8)) = _NewArray(tls, int32(10)) *(*int32)(unsafe.Pointer((*TThreadSpecificData6)(unsafe.Pointer(tsdPtr)).Flevels + 8 + uintptr(i)*4)) = 0 goto _1 _1: ; i++ } (*TElement)(unsafe.Pointer(defaultMatchPtr)).FnameUid = libc.UintptrFromInt32(0) *(*TTk_Uid)(unsafe.Pointer(defaultMatchPtr + 8)) = libc.UintptrFromInt32(0) (*TElement)(unsafe.Pointer(defaultMatchPtr)).Fpriority = -int32(1) (*TElement)(unsafe.Pointer(defaultMatchPtr)).Fflags = 0 libtcl9_0.XTcl_CreateThreadExitHandler(tls, __ccgo_fp(_OptionThreadExitProc), libc.UintptrFromInt32(0)) } /* * Then, per-main-window initialization. Create and delete dummy * interpreter for message logging. */ (*TTkMainInfo)(unsafe.Pointer(mainPtr)).FoptionRootPtr = _NewArray(tls, int32(20)) interp = libtcl9_0.XTcl_CreateInterp(tls) _GetDefaultOptions(tls, interp, (*TTkMainInfo)(unsafe.Pointer(mainPtr)).FwinPtr) libtcl9_0.XTcl_DeleteInterp(tls, interp) } /* *-------------------------------------------------------------- * * ClearOptionTree -- * * This function is called to erase everything in a hierarchical option * database. * * Results: * None. * * Side effects: * All the options associated with arrayPtr are deleted, along with all * option subtrees. The space pointed to by arrayPtr is freed. * *-------------------------------------------------------------- */ func _ClearOptionTree(tls *libc.TLS, arrayPtr uintptr) { /* Array of options; delete everything * referred to recursively by this. */ var count int32 var elPtr uintptr _, _ = count, elPtr count = (*TElArray)(unsafe.Pointer(arrayPtr)).FnumUsed elPtr = arrayPtr + 16 for { if !(count > 0) { break } if (*TElement)(unsafe.Pointer(elPtr)).Fflags&int32(NODE) != 0 { _ClearOptionTree(tls, *(*uintptr)(unsafe.Pointer(elPtr + 8))) } goto _1 _1: ; count-- elPtr += 24 } libtcl9_0.XTcl_Free(tls, arrayPtr) } /* *-------------------------------------------------------------- * * GetDefaultOptions -- * * This function is invoked to load the default set of options for a * window. * * Results: * None. * * Side effects: * Options are added to those for winPtr's main window. If there exists a * RESOURCE_MANAGER proprety for winPtr's display, that is used. * Otherwise, the .Xdefaults file in the user's home directory is used. * *-------------------------------------------------------------- */ func _GetDefaultOptions(tls *libc.TLS, interp uintptr, winPtr uintptr) (r int32) { bp := tls.Alloc(48) defer tls.Free(48) /* Fetch option defaults for main window * associated with this. */ var _objPtr, regPropPtr, xdefaults, v2 uintptr var result int32 var v1 TTcl_Size var _ /* actualFormat at bp+8 */ int32 var _ /* actualType at bp+32 */ TAtom var _ /* bytesAfter at bp+24 */ uint64 var _ /* numItems at bp+16 */ uint64 var _ /* regProp at bp+0 */ uintptr _, _, _, _, _, _ = _objPtr, regPropPtr, result, xdefaults, v1, v2 regPropPtr = bp result = TCL_OK /* * Try the RESOURCE_MANAGER property on the root window first. */ *(*uintptr)(unsafe.Pointer(bp)) = libc.UintptrFromInt32(0) result = libx11.XXGetWindowProperty(tls, (*TTkWindow)(unsafe.Pointer(winPtr)).Fdisplay, (*TScreen)(unsafe.Pointer((*struct { Fext_data uintptr Fprivate1 uintptr Ffd int32 Fprivate2 int32 Fproto_major_version int32 Fproto_minor_version int32 Fvendor uintptr Fprivate3 TXID Fprivate4 TXID Fprivate5 TXID Fprivate6 int32 Fresource_alloc uintptr Fbyte_order int32 Fbitmap_unit int32 Fbitmap_pad int32 Fbitmap_bit_order int32 Fnformats int32 Fpixmap_format uintptr Fprivate8 int32 Frelease int32 Fprivate9 uintptr Fprivate10 uintptr Fqlen int32 Flast_request_read uint64 Frequest uint64 Fprivate11 TXPointer Fprivate12 TXPointer Fprivate13 TXPointer Fprivate14 TXPointer Fmax_request_size uint32 Fdb uintptr Fprivate15 uintptr Fdisplay_name uintptr Fdefault_screen int32 Fnscreens int32 Fscreens uintptr Fmotion_buffer uint64 Fprivate16 uint64 Fmin_keycode int32 Fmax_keycode int32 Fprivate17 TXPointer Fprivate18 TXPointer Fprivate19 int32 Fxdefaults uintptr })(unsafe.Pointer((*TTkWindow)(unsafe.Pointer(winPtr)).Fdisplay)).Fscreens)).Froot, libc.Uint64FromInt32(23), 0, int64(100000), False, libc.Uint64FromInt32(31), bp+32, bp+8, bp+16, bp+24, regPropPtr) if result == Success && *(*TAtom)(unsafe.Pointer(bp + 32)) == libc.Uint64FromInt32(31) && *(*int32)(unsafe.Pointer(bp + 8)) == int32(8) { result = _AddFromString(tls, interp, winPtr, *(*uintptr)(unsafe.Pointer(bp)), int32(TK_USER_DEFAULT_PRIO)) libx11.XXFree(tls, *(*uintptr)(unsafe.Pointer(bp))) return result } /* * No luck there. Try a .Xdefaults file in the user's home directory. */ if *(*uintptr)(unsafe.Pointer(bp)) != libc.UintptrFromInt32(0) { libx11.XXFree(tls, *(*uintptr)(unsafe.Pointer(bp))) } if libtcl9_0.XTcl_EvalEx(tls, interp, __ccgo_ts+15069, int64(-libc.Int32FromInt32(1)), int32(TCL_EVAL_GLOBAL)) == TCL_OK { xdefaults = libtcl9_0.XTcl_GetObjResult(tls, interp) (*TTcl_Obj)(unsafe.Pointer(xdefaults)).FrefCount++ libtcl9_0.XTcl_ResetResult(tls, interp) result = _ReadOptionFile(tls, interp, winPtr, libtcl9_0.XTcl_GetStringFromObj(tls, xdefaults, libc.UintptrFromInt32(0)), int32(TK_USER_DEFAULT_PRIO)) _objPtr = xdefaults v2 = _objPtr v1 = *(*TTcl_Size)(unsafe.Pointer(v2)) *(*TTcl_Size)(unsafe.Pointer(v2))-- if v1 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr) } } return result } type TElArray1 = struct { FarraySize int32 FnumUsed int32 FnextToUse uintptr Fels [1]TElement } const ALLOCED_CONTAINER1 = 64 const DONT_PROPAGATE1 = 32 const EXPAND = 8 const FILLX = 2 const FILLY = 4 const OLD_STYLE = 16 const REQUESTED_REPACK = 1 /* * Local Variables: * mode: c * c-basic-offset: 4 * fill-column: 78 * End: */ type TSide = int32 const BOTTOM = 0 const LEFT = 1 const RIGHT = 2 const TOP = 3 var _sideNames = [5]uintptr{ 0: __ccgo_ts + 15099, 1: __ccgo_ts + 10966, 2: __ccgo_ts + 10971, 3: __ccgo_ts + 15106, 4: libc.UintptrFromInt32(0), } /* * For each window that the packer cares about (either because the window is * managed by the packer or because the window has content that are managed by * the packer), there is a structure of the following type: */ type TPacker = struct { Ftkwin TTk_Window FcontainerPtr uintptr FnextPtr uintptr FcontentPtr uintptr Fside TSide Fanchor TTk_Anchor FpadX int32 FpadY int32 FpadLeft int32 FpadTop int32 FiPadX int32 FiPadY int32 FdoubleBw int32 FabortPtr uintptr Fflags int32 } var _packerType = TTk_GeomMgr{ Fname: __ccgo_ts + 15110, } func init() { p := unsafe.Pointer(&_packerType) *(*uintptr)(unsafe.Add(p, 8)) = __ccgo_fp(_PackReqProc) *(*uintptr)(unsafe.Add(p, 16)) = __ccgo_fp(_PackLostContentProc) } /* *------------------------------------------------------------------------ * * TkAppendPadAmount -- * * This function generates a text value that describes one of the -padx, * -pady, -ipadx, or -ipady configuration options. The text value * generated is appended to the given Tcl_Obj. * * Results: * None. * * Side effects: * None. * *------------------------------------------------------------------------ */ func XTkAppendPadAmount(tls *libc.TLS, bufferObj uintptr, switchName uintptr, halfSpace int32, allSpace int32) { bp := tls.Alloc(16) defer tls.Free(16) /* The total amount of padding */ var _ /* padding at bp+0 */ [2]uintptr if halfSpace*int32(2) == allSpace { libtcl9_0.XTcl_DictObjPut(tls, libc.UintptrFromInt32(0), bufferObj, libtcl9_0.XTcl_NewStringObj(tls, switchName, int64(-libc.Int32FromInt32(1))), libtcl9_0.XTcl_NewWideIntObj(tls, int64(halfSpace))) } else { (*(*[2]uintptr)(unsafe.Pointer(bp)))[0] = libtcl9_0.XTcl_NewWideIntObj(tls, int64(halfSpace)) (*(*[2]uintptr)(unsafe.Pointer(bp)))[int32(1)] = libtcl9_0.XTcl_NewWideIntObj(tls, int64(allSpace-halfSpace)) libtcl9_0.XTcl_DictObjPut(tls, libc.UintptrFromInt32(0), bufferObj, libtcl9_0.XTcl_NewStringObj(tls, switchName, int64(-libc.Int32FromInt32(1))), libtcl9_0.XTcl_NewListObj(tls, int64(2), bp)) } } /* *------------------------------------------------------------------------ * * Tk_PackCmd -- * * This function is invoked to process the "pack" Tcl command. See the * user documentation for details on what it does. * * Results: * A standard Tcl result. * * Side effects: * See the user documentation. * *------------------------------------------------------------------------ */ func XTk_PackObjCmd(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) (r int32) { bp := tls.Alloc(96) defer tls.Free(96) /* Argument objects. */ var argv2, containerPtr, containerPtr1, contentPtr, contentPtr1, contentPtr2, infoObj, resultObj, string1, v2, v3, v4, v5 uintptr var i int32 var tkwin TTk_Window var _ /* container at bp+24 */ TTk_Window var _ /* container at bp+40 */ TTk_Window var _ /* content at bp+16 */ TTk_Window var _ /* content at bp+8 */ TTk_Window var _ /* index at bp+0 */ int32 var _ /* propagate at bp+32 */ int32 _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = argv2, containerPtr, containerPtr1, contentPtr, contentPtr1, contentPtr2, i, infoObj, resultObj, string1, tkwin, v2, v3, v4, v5 tkwin = clientData if objc >= int32(2) { string1 = libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8)), libc.UintptrFromInt32(0)) if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(string1))) == int32('.') { return _ConfigureContent1(tls, interp, tkwin, objc-int32(1), objv+uintptr(1)*8) } } if objc < int32(3) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(1), objv, __ccgo_ts+12175) return int32(TCL_ERROR) } if libtcl9_0.XTcl_GetIndexFromObjStruct(tls, libc.UintptrFromInt32(0), *(*uintptr)(unsafe.Pointer(objv + 1*8)), uintptr(unsafe.Pointer(&_optionStrings11)), libc.Int64FromUint64(libc.Uint64FromInt64(8)), __ccgo_ts+2689, libc.Int32FromInt32(0)|libc.Int32FromUint64(libc.Uint64FromInt64(4)< int32(4) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(2), objv, __ccgo_ts+12351) return int32(TCL_ERROR) } if XTkGetWindowFromObj(tls, interp, tkwin, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+24) != TCL_OK { return int32(TCL_ERROR) } v4 = _GetPacker(tls, *(*TTk_Window)(unsafe.Pointer(bp + 24))) containerPtr = v4 if !(v4 != 0) { return TCL_OK } if objc == int32(3) { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewWideIntObj(tls, libc.BoolInt64(libc.BoolInt32(!((*TPacker)(unsafe.Pointer(containerPtr)).Fflags&libc.Int32FromInt32(DONT_PROPAGATE1) != 0)) != 0))) return TCL_OK } if libtcl9_0.XTcl_GetBoolFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 3*8)), (libc.Int32FromInt32(TCL_NULL_OK)-libc.Int32FromInt32(2))&libc.Int32FromInt64(4), bp+32) != TCL_OK { return int32(TCL_ERROR) } if *(*int32)(unsafe.Pointer(bp + 32)) != 0 { /* * If we have content windows, we need to register as geometry container. */ if (*TPacker)(unsafe.Pointer(containerPtr)).FcontentPtr != libc.UintptrFromInt32(0) { if XTkSetGeometryContainer(tls, interp, *(*TTk_Window)(unsafe.Pointer(bp + 24)), __ccgo_ts+15110) != TCL_OK { return int32(TCL_ERROR) } *(*int32)(unsafe.Pointer(containerPtr + 80)) |= int32(ALLOCED_CONTAINER1) } *(*int32)(unsafe.Pointer(containerPtr + 80)) &= ^libc.Int32FromInt32(DONT_PROPAGATE1) /* * Repack the container to allow new geometry information to * propagate upwards to the container's container. */ if (*TPacker)(unsafe.Pointer(containerPtr)).FabortPtr != libc.UintptrFromInt32(0) { *(*int32)(unsafe.Pointer((*TPacker)(unsafe.Pointer(containerPtr)).FabortPtr)) = int32(1) } if !((*TPacker)(unsafe.Pointer(containerPtr)).Fflags&libc.Int32FromInt32(REQUESTED_REPACK) != 0) { *(*int32)(unsafe.Pointer(containerPtr + 80)) |= int32(REQUESTED_REPACK) libtcl9_0.XTcl_DoWhenIdle(tls, __ccgo_fp(_ArrangePacking), containerPtr) } } else { if (*TPacker)(unsafe.Pointer(containerPtr)).Fflags&int32(ALLOCED_CONTAINER1) != 0 { XTkFreeGeometryContainer(tls, *(*TTk_Window)(unsafe.Pointer(bp + 24)), __ccgo_ts+15110) *(*int32)(unsafe.Pointer(containerPtr + 80)) &= ^libc.Int32FromInt32(ALLOCED_CONTAINER1) } *(*int32)(unsafe.Pointer(containerPtr + 80)) |= int32(DONT_PROPAGATE1) } case 5: fallthrough case 1: if objc != int32(3) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(2), objv, __ccgo_ts+4814) return int32(TCL_ERROR) } if XTkGetWindowFromObj(tls, interp, tkwin, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+40) != TCL_OK { return int32(TCL_ERROR) } resultObj = libtcl9_0.XTcl_NewObj(tls) v5 = _GetPacker(tls, *(*TTk_Window)(unsafe.Pointer(bp + 40))) containerPtr1 = v5 if !(v5 != 0) { return TCL_OK } contentPtr2 = (*TPacker)(unsafe.Pointer(containerPtr1)).FcontentPtr for { if !(contentPtr2 != libc.UintptrFromInt32(0)) { break } libtcl9_0.XTcl_ListObjAppendElement(tls, libc.UintptrFromInt32(0), resultObj, XTk_NewWindowObj(tls, (*TPacker)(unsafe.Pointer(contentPtr2)).Ftkwin)) goto _6 _6: ; contentPtr2 = (*TPacker)(unsafe.Pointer(contentPtr2)).FnextPtr } libtcl9_0.XTcl_SetObjResult(tls, interp, resultObj) break } return TCL_OK } var _optionStrings11 = [7]uintptr{ 0: __ccgo_ts + 4740, 1: __ccgo_ts + 12116, 2: __ccgo_ts + 4750, 3: __ccgo_ts + 2671, 4: __ccgo_ts + 12133, 5: __ccgo_ts + 12168, 6: libc.UintptrFromInt32(0), } var _optionStringsNoDep1 = [6]uintptr{ 0: __ccgo_ts + 4740, 1: __ccgo_ts + 12116, 2: __ccgo_ts + 4750, 3: __ccgo_ts + 2671, 4: __ccgo_ts + 12133, 5: libc.UintptrFromInt32(0), } /* *------------------------------------------------------------------------ * * PackReqProc -- * * This function is invoked by Tk_GeometryRequest for windows managed by * the packer. * * Results: * None. * * Side effects: * Arranges for tkwin, and all its managed siblings, to be re-packed at * the next idle point. * *------------------------------------------------------------------------ */ func _PackReqProc(tls *libc.TLS, clientData uintptr, dummy429 TTk_Window) { /* Other Tk-related information about the * window. */ var packPtr uintptr _ = packPtr packPtr = clientData packPtr = (*TPacker)(unsafe.Pointer(packPtr)).FcontainerPtr if !((*TPacker)(unsafe.Pointer(packPtr)).Fflags&libc.Int32FromInt32(REQUESTED_REPACK) != 0) { *(*int32)(unsafe.Pointer(packPtr + 80)) |= int32(REQUESTED_REPACK) libtcl9_0.XTcl_DoWhenIdle(tls, __ccgo_fp(_ArrangePacking), packPtr) } } /* *------------------------------------------------------------------------ * * PackLostContentProc -- * * This function is invoked by Tk whenever some other geometry claims * control over a content window that used to be managed by us. * * Results: * None. * * Side effects: * Forgets all packer-related information about the content. * *------------------------------------------------------------------------ */ func _PackLostContentProc(tls *libc.TLS, clientData uintptr, dummy462 TTk_Window) { /* Tk's handle for the content window. */ var contentPtr uintptr _ = contentPtr contentPtr = clientData if (*TPacker1)(unsafe.Pointer((*TPacker)(unsafe.Pointer(contentPtr)).FcontainerPtr)).Ftkwin != (*TTk_FakeWin)(unsafe.Pointer((*TPacker)(unsafe.Pointer(contentPtr)).Ftkwin)).FparentPtr { XTk_UnmaintainGeometry(tls, (*TPacker)(unsafe.Pointer(contentPtr)).Ftkwin, (*TPacker1)(unsafe.Pointer((*TPacker)(unsafe.Pointer(contentPtr)).FcontainerPtr)).Ftkwin) } _Unlink1(tls, contentPtr) XTk_UnmapWindow(tls, (*TPacker)(unsafe.Pointer(contentPtr)).Ftkwin) } /* *------------------------------------------------------------------------ * * ArrangePacking -- * * This function is invoked (using the Tcl_DoWhenIdle mechanism) to * re-layout a set of windows managed by the packer. It is invoked at * idle time so that a series of packer requests can be merged into a * single layout operation. * * Results: * None. * * Side effects: * The packed content of containerPtr may get resized or moved. * *------------------------------------------------------------------------ */ func _ArrangePacking(tls *libc.TLS, clientData uintptr) { bp := tls.Alloc(16) defer tls.Free(16) /* Structure describing container whose content * are to be re-layed out. */ var borderBtm, borderLeft, borderRight, borderTop, borderX, borderY, cavityHeight, cavityWidth, cavityX, cavityY, frameHeight, frameWidth, frameX, frameY, height, maxHeight, maxWidth, tmp, width, x, y, v1, v2, v4, v5, v7, v8, v9 int32 var containerPtr, contentPtr uintptr var _ /* abort at bp+0 */ int32 _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = borderBtm, borderLeft, borderRight, borderTop, borderX, borderY, cavityHeight, cavityWidth, cavityX, cavityY, containerPtr, contentPtr, frameHeight, frameWidth, frameX, frameY, height, maxHeight, maxWidth, tmp, width, x, y, v1, v2, v4, v5, v7, v8, v9 containerPtr = clientData *(*int32)(unsafe.Pointer(containerPtr + 80)) &= ^libc.Int32FromInt32(REQUESTED_REPACK) /* * If the container has no content anymore, then leave the container's size as-is. * Otherwise there is no way to "relinquish" control over the container * so another geometry manager can take over. */ if (*TPacker)(unsafe.Pointer(containerPtr)).FcontentPtr == libc.UintptrFromInt32(0) { return } /* * Abort any nested call to ArrangePacking for this window, since we'll do * everything necessary here, and set up so this call can be aborted if * necessary. */ if (*TPacker)(unsafe.Pointer(containerPtr)).FabortPtr != libc.UintptrFromInt32(0) { *(*int32)(unsafe.Pointer((*TPacker)(unsafe.Pointer(containerPtr)).FabortPtr)) = int32(1) } (*TPacker)(unsafe.Pointer(containerPtr)).FabortPtr = bp *(*int32)(unsafe.Pointer(bp)) = 0 libtcl9_0.XTcl_Preserve(tls, containerPtr) /* * Pass #1: scan all the content to figure out the total amount of space * needed. Two separate width and height values are computed: * * width - Holds the sum of the widths (plus padding) of all the * content seen so far that were packed LEFT or RIGHT. * height - Holds the sum of the heights (plus padding) of all the * content seen so far that were packed TOP or BOTTOM. * * maxWidth - Gradually builds up the width needed by the container to * just barely satisfy all the content's needs. For each * content, the code computes the width needed for all the * content so far and updates maxWidth if the new value is * greater. * maxHeight - Same as maxWidth, except keeps height info. */ v1 = (*TTk_FakeWin)(unsafe.Pointer((*TPacker)(unsafe.Pointer(containerPtr)).Ftkwin)).FinternalBorderLeft + (*TTk_FakeWin)(unsafe.Pointer((*TPacker)(unsafe.Pointer(containerPtr)).Ftkwin)).FinternalBorderRight maxWidth = v1 width = v1 v2 = (*TTk_FakeWin)(unsafe.Pointer((*TPacker)(unsafe.Pointer(containerPtr)).Ftkwin)).FinternalBorderTop + (*TTk_FakeWin)(unsafe.Pointer((*TPacker)(unsafe.Pointer(containerPtr)).Ftkwin)).FinternalBorderBottom maxHeight = v2 height = v2 contentPtr = (*TPacker)(unsafe.Pointer(containerPtr)).FcontentPtr for { if !(contentPtr != libc.UintptrFromInt32(0)) { break } if (*TPacker)(unsafe.Pointer(contentPtr)).Fside == int32(TOP) || (*TPacker)(unsafe.Pointer(contentPtr)).Fside == int32(BOTTOM) { tmp = (*TTk_FakeWin)(unsafe.Pointer((*TPacker)(unsafe.Pointer(contentPtr)).Ftkwin)).FreqWidth + (*TPacker)(unsafe.Pointer(contentPtr)).FdoubleBw + (*TPacker)(unsafe.Pointer(contentPtr)).FpadX + (*TPacker)(unsafe.Pointer(contentPtr)).FiPadX + width if tmp > maxWidth { maxWidth = tmp } height += (*TTk_FakeWin)(unsafe.Pointer((*TPacker)(unsafe.Pointer(contentPtr)).Ftkwin)).FreqHeight + (*TPacker)(unsafe.Pointer(contentPtr)).FdoubleBw + (*TPacker)(unsafe.Pointer(contentPtr)).FpadY + (*TPacker)(unsafe.Pointer(contentPtr)).FiPadY } else { tmp = (*TTk_FakeWin)(unsafe.Pointer((*TPacker)(unsafe.Pointer(contentPtr)).Ftkwin)).FreqHeight + (*TPacker)(unsafe.Pointer(contentPtr)).FdoubleBw + (*TPacker)(unsafe.Pointer(contentPtr)).FpadY + (*TPacker)(unsafe.Pointer(contentPtr)).FiPadY + height if tmp > maxHeight { maxHeight = tmp } width += (*TTk_FakeWin)(unsafe.Pointer((*TPacker)(unsafe.Pointer(contentPtr)).Ftkwin)).FreqWidth + (*TPacker)(unsafe.Pointer(contentPtr)).FdoubleBw + (*TPacker)(unsafe.Pointer(contentPtr)).FpadX + (*TPacker)(unsafe.Pointer(contentPtr)).FiPadX } goto _3 _3: ; contentPtr = (*TPacker)(unsafe.Pointer(contentPtr)).FnextPtr } if width > maxWidth { maxWidth = width } if height > maxHeight { maxHeight = height } if maxWidth < (*TTk_FakeWin)(unsafe.Pointer((*TPacker)(unsafe.Pointer(containerPtr)).Ftkwin)).FminReqWidth { maxWidth = (*TTk_FakeWin)(unsafe.Pointer((*TPacker)(unsafe.Pointer(containerPtr)).Ftkwin)).FminReqWidth } if maxHeight < (*TTk_FakeWin)(unsafe.Pointer((*TPacker)(unsafe.Pointer(containerPtr)).Ftkwin)).FminReqHeight { maxHeight = (*TTk_FakeWin)(unsafe.Pointer((*TPacker)(unsafe.Pointer(containerPtr)).Ftkwin)).FminReqHeight } /* * If the total amount of space needed in the container window has changed, * and if we're propagating geometry information, then notify the next * geometry manager up and requeue ourselves to start again after the * container has had a chance to resize us. */ if (maxWidth != (*TTk_FakeWin)(unsafe.Pointer((*TPacker)(unsafe.Pointer(containerPtr)).Ftkwin)).FreqWidth || maxHeight != (*TTk_FakeWin)(unsafe.Pointer((*TPacker)(unsafe.Pointer(containerPtr)).Ftkwin)).FreqHeight) && !((*TPacker)(unsafe.Pointer(containerPtr)).Fflags&libc.Int32FromInt32(DONT_PROPAGATE1) != 0) { XTk_GeometryRequest(tls, (*TPacker)(unsafe.Pointer(containerPtr)).Ftkwin, maxWidth, maxHeight) *(*int32)(unsafe.Pointer(containerPtr + 80)) |= int32(REQUESTED_REPACK) libtcl9_0.XTcl_DoWhenIdle(tls, __ccgo_fp(_ArrangePacking), containerPtr) goto done } /* * Pass #2: scan the content a second time assigning new sizes. The * "cavity" variables keep track of the unclaimed space in the cavity of * the window; this shrinks inward as we allocate windows around the * edges. The "frame" variables keep track of the space allocated to the * current window and its frame. The current window is then placed * somewhere inside the frame, depending on anchor. */ v4 = (*TTk_FakeWin)(unsafe.Pointer((*TPacker)(unsafe.Pointer(containerPtr)).Ftkwin)).FinternalBorderLeft x = v4 cavityX = v4 v5 = (*TTk_FakeWin)(unsafe.Pointer((*TPacker)(unsafe.Pointer(containerPtr)).Ftkwin)).FinternalBorderTop y = v5 cavityY = v5 cavityWidth = (*TTk_FakeWin)(unsafe.Pointer((*TPacker)(unsafe.Pointer(containerPtr)).Ftkwin)).Fchanges.Fwidth - (*TTk_FakeWin)(unsafe.Pointer((*TPacker)(unsafe.Pointer(containerPtr)).Ftkwin)).FinternalBorderLeft - (*TTk_FakeWin)(unsafe.Pointer((*TPacker)(unsafe.Pointer(containerPtr)).Ftkwin)).FinternalBorderRight cavityHeight = (*TTk_FakeWin)(unsafe.Pointer((*TPacker)(unsafe.Pointer(containerPtr)).Ftkwin)).Fchanges.Fheight - (*TTk_FakeWin)(unsafe.Pointer((*TPacker)(unsafe.Pointer(containerPtr)).Ftkwin)).FinternalBorderTop - (*TTk_FakeWin)(unsafe.Pointer((*TPacker)(unsafe.Pointer(containerPtr)).Ftkwin)).FinternalBorderBottom contentPtr = (*TPacker)(unsafe.Pointer(containerPtr)).FcontentPtr for { if !(contentPtr != libc.UintptrFromInt32(0)) { break } if (*TPacker)(unsafe.Pointer(contentPtr)).Fside == int32(TOP) || (*TPacker)(unsafe.Pointer(contentPtr)).Fside == int32(BOTTOM) { frameWidth = cavityWidth frameHeight = (*TTk_FakeWin)(unsafe.Pointer((*TPacker)(unsafe.Pointer(contentPtr)).Ftkwin)).FreqHeight + (*TPacker)(unsafe.Pointer(contentPtr)).FdoubleBw + (*TPacker)(unsafe.Pointer(contentPtr)).FpadY + (*TPacker)(unsafe.Pointer(contentPtr)).FiPadY if (*TPacker)(unsafe.Pointer(contentPtr)).Fflags&int32(EXPAND) != 0 { frameHeight += _YExpansion(tls, contentPtr, cavityHeight) } cavityHeight -= frameHeight if cavityHeight < 0 { frameHeight += cavityHeight cavityHeight = 0 } frameX = cavityX if (*TPacker)(unsafe.Pointer(contentPtr)).Fside == int32(TOP) { frameY = cavityY cavityY += frameHeight } else { frameY = cavityY + cavityHeight } } else { frameHeight = cavityHeight frameWidth = (*TTk_FakeWin)(unsafe.Pointer((*TPacker)(unsafe.Pointer(contentPtr)).Ftkwin)).FreqWidth + (*TPacker)(unsafe.Pointer(contentPtr)).FdoubleBw + (*TPacker)(unsafe.Pointer(contentPtr)).FpadX + (*TPacker)(unsafe.Pointer(contentPtr)).FiPadX if (*TPacker)(unsafe.Pointer(contentPtr)).Fflags&int32(EXPAND) != 0 { frameWidth += _XExpansion(tls, contentPtr, cavityWidth) } cavityWidth -= frameWidth if cavityWidth < 0 { frameWidth += cavityWidth cavityWidth = 0 } frameY = cavityY if (*TPacker)(unsafe.Pointer(contentPtr)).Fside == int32(LEFT) { frameX = cavityX cavityX += frameWidth } else { frameX = cavityX + cavityWidth } } /* * Now that we've got the size of the frame for the window, compute * the window's actual size and location using the fill, padding, and * frame factors. The variables "borderX" and "borderY" are used to * handle the differences between old-style packing and the new style * (in old-style, iPadX and iPadY are always zero and padding is * completely ignored except when computing frame size). */ if (*TPacker)(unsafe.Pointer(contentPtr)).Fflags&int32(OLD_STYLE) != 0 { v7 = libc.Int32FromInt32(0) borderY = v7 borderX = v7 v8 = libc.Int32FromInt32(0) borderBtm = v8 borderTop = v8 v9 = libc.Int32FromInt32(0) borderRight = v9 borderLeft = v9 } else { borderX = (*TPacker)(unsafe.Pointer(contentPtr)).FpadX borderY = (*TPacker)(unsafe.Pointer(contentPtr)).FpadY borderLeft = (*TPacker)(unsafe.Pointer(contentPtr)).FpadLeft borderRight = borderX - borderLeft borderTop = (*TPacker)(unsafe.Pointer(contentPtr)).FpadTop borderBtm = borderY - borderTop } width = (*TTk_FakeWin)(unsafe.Pointer((*TPacker)(unsafe.Pointer(contentPtr)).Ftkwin)).FreqWidth + (*TPacker)(unsafe.Pointer(contentPtr)).FdoubleBw + (*TPacker)(unsafe.Pointer(contentPtr)).FiPadX if (*TPacker)(unsafe.Pointer(contentPtr)).Fflags&int32(FILLX) != 0 || width > frameWidth-borderX { width = frameWidth - borderX } height = (*TTk_FakeWin)(unsafe.Pointer((*TPacker)(unsafe.Pointer(contentPtr)).Ftkwin)).FreqHeight + (*TPacker)(unsafe.Pointer(contentPtr)).FdoubleBw + (*TPacker)(unsafe.Pointer(contentPtr)).FiPadY if (*TPacker)(unsafe.Pointer(contentPtr)).Fflags&int32(FILLY) != 0 || height > frameHeight-borderY { height = frameHeight - borderY } switch (*TPacker)(unsafe.Pointer(contentPtr)).Fanchor { case int32(TK_ANCHOR_N): x = frameX + (borderLeft+frameWidth-width-borderRight)/int32(2) y = frameY + borderTop case int32(TK_ANCHOR_NE): x = frameX + frameWidth - width - borderRight y = frameY + borderTop case int32(TK_ANCHOR_E): x = frameX + frameWidth - width - borderRight y = frameY + (borderTop+frameHeight-height-borderBtm)/int32(2) case int32(TK_ANCHOR_SE): x = frameX + frameWidth - width - borderRight y = frameY + frameHeight - height - borderBtm case int32(TK_ANCHOR_S): x = frameX + (borderLeft+frameWidth-width-borderRight)/int32(2) y = frameY + frameHeight - height - borderBtm case int32(TK_ANCHOR_SW): x = frameX + borderLeft y = frameY + frameHeight - height - borderBtm case int32(TK_ANCHOR_W): x = frameX + borderLeft y = frameY + (borderTop+frameHeight-height-borderBtm)/int32(2) case int32(TK_ANCHOR_NW): x = frameX + borderLeft y = frameY + borderTop default: x = frameX + (borderLeft+frameWidth-width-borderRight)/int32(2) y = frameY + (borderTop+frameHeight-height-borderBtm)/int32(2) break } width -= (*TPacker)(unsafe.Pointer(contentPtr)).FdoubleBw height -= (*TPacker)(unsafe.Pointer(contentPtr)).FdoubleBw /* * The final step is to set the position, size, and mapped/unmapped * state of the content. If the content is a child of the container, then do * this here. Otherwise let Tk_MaintainGeometry do the work. */ if (*TPacker)(unsafe.Pointer(containerPtr)).Ftkwin == (*TTk_FakeWin)(unsafe.Pointer((*TPacker)(unsafe.Pointer(contentPtr)).Ftkwin)).FparentPtr { if width <= 0 || height <= 0 { XTk_UnmapWindow(tls, (*TPacker)(unsafe.Pointer(contentPtr)).Ftkwin) } else { if x != (*TTk_FakeWin)(unsafe.Pointer((*TPacker)(unsafe.Pointer(contentPtr)).Ftkwin)).Fchanges.Fx || y != (*TTk_FakeWin)(unsafe.Pointer((*TPacker)(unsafe.Pointer(contentPtr)).Ftkwin)).Fchanges.Fy || width != (*TTk_FakeWin)(unsafe.Pointer((*TPacker)(unsafe.Pointer(contentPtr)).Ftkwin)).Fchanges.Fwidth || height != (*TTk_FakeWin)(unsafe.Pointer((*TPacker)(unsafe.Pointer(contentPtr)).Ftkwin)).Fchanges.Fheight { XTk_MoveResizeWindow(tls, (*TPacker)(unsafe.Pointer(contentPtr)).Ftkwin, x, y, width, height) } if *(*int32)(unsafe.Pointer(bp)) != 0 { goto done } /* * Don't map the content if the container isn't mapped: wait until * the container gets mapped later. */ if (*TTk_FakeWin)(unsafe.Pointer((*TPacker)(unsafe.Pointer(containerPtr)).Ftkwin)).Fflags&uint32(TK_MAPPED) != 0 { XTk_MapWindow(tls, (*TPacker)(unsafe.Pointer(contentPtr)).Ftkwin) } } } else { if width <= 0 || height <= 0 { XTk_UnmaintainGeometry(tls, (*TPacker)(unsafe.Pointer(contentPtr)).Ftkwin, (*TPacker)(unsafe.Pointer(containerPtr)).Ftkwin) XTk_UnmapWindow(tls, (*TPacker)(unsafe.Pointer(contentPtr)).Ftkwin) } else { XTk_MaintainGeometry(tls, (*TPacker)(unsafe.Pointer(contentPtr)).Ftkwin, (*TPacker)(unsafe.Pointer(containerPtr)).Ftkwin, x, y, width, height) } } /* * Changes to the window's structure could cause almost anything to * happen, including deleting the parent or child. If this happens, * we'll be told to abort. */ if *(*int32)(unsafe.Pointer(bp)) != 0 { goto done } goto _6 _6: ; contentPtr = (*TPacker)(unsafe.Pointer(contentPtr)).FnextPtr } goto done done: ; (*TPacker)(unsafe.Pointer(containerPtr)).FabortPtr = libc.UintptrFromInt32(0) libtcl9_0.XTcl_Release(tls, containerPtr) } /* *---------------------------------------------------------------------- * * XExpansion -- * * Given a list of packed content, the first of which is packed on the * left or right and is expandable, compute how much to expand the child. * * Results: * The return value is the number of additional pixels to give to the * child. * * Side effects: * None. * *---------------------------------------------------------------------- */ func _XExpansion(tls *libc.TLS, contentPtr uintptr, cavityWidth int32) (r int32) { /* Horizontal space left for all remaining * content. */ var childWidth, curExpand, minExpand, numExpand, v2 int32 _, _, _, _, _ = childWidth, curExpand, minExpand, numExpand, v2 /* * This function is tricky because windows packed top or bottom can be * interspersed among expandable windows packed left or right. Scan * through the list, keeping a running sum of the widths of all left and * right windows (actually, count the cavity space not allocated) and a * running count of all expandable left and right windows. At each top or * bottom window, and at the end of the list, compute the expansion factor * that seems reasonable at that point. Return the smallest factor seen at * any of these points. */ minExpand = cavityWidth numExpand = 0 for { if !(contentPtr != libc.UintptrFromInt32(0)) { break } childWidth = (*TTk_FakeWin)(unsafe.Pointer((*TPacker)(unsafe.Pointer(contentPtr)).Ftkwin)).FreqWidth + (*TPacker)(unsafe.Pointer(contentPtr)).FdoubleBw + (*TPacker)(unsafe.Pointer(contentPtr)).FpadX + (*TPacker)(unsafe.Pointer(contentPtr)).FiPadX if (*TPacker)(unsafe.Pointer(contentPtr)).Fside == int32(TOP) || (*TPacker)(unsafe.Pointer(contentPtr)).Fside == int32(BOTTOM) { if numExpand != 0 { curExpand = (cavityWidth - childWidth) / numExpand if curExpand < minExpand { minExpand = curExpand } } } else { cavityWidth -= childWidth if (*TPacker)(unsafe.Pointer(contentPtr)).Fflags&int32(EXPAND) != 0 { numExpand++ } } goto _1 _1: ; contentPtr = (*TPacker)(unsafe.Pointer(contentPtr)).FnextPtr } if numExpand != 0 { curExpand = cavityWidth / numExpand if curExpand < minExpand { minExpand = curExpand } } if minExpand < 0 { v2 = 0 } else { v2 = minExpand } return v2 } /* *---------------------------------------------------------------------- * * YExpansion -- * * Given a list of packed content, the first of which is packed on the top * or bottom and is expandable, compute how much to expand the child. * * Results: * The return value is the number of additional pixels to give to the * child. * * Side effects: * None. * *---------------------------------------------------------------------- */ func _YExpansion(tls *libc.TLS, contentPtr uintptr, cavityHeight int32) (r int32) { /* Vertical space left for all remaining * content. */ var childHeight, curExpand, minExpand, numExpand, v2 int32 _, _, _, _, _ = childHeight, curExpand, minExpand, numExpand, v2 /* * See comments for XExpansion. */ minExpand = cavityHeight numExpand = 0 for { if !(contentPtr != libc.UintptrFromInt32(0)) { break } childHeight = (*TTk_FakeWin)(unsafe.Pointer((*TPacker)(unsafe.Pointer(contentPtr)).Ftkwin)).FreqHeight + (*TPacker)(unsafe.Pointer(contentPtr)).FdoubleBw + (*TPacker)(unsafe.Pointer(contentPtr)).FpadY + (*TPacker)(unsafe.Pointer(contentPtr)).FiPadY if (*TPacker)(unsafe.Pointer(contentPtr)).Fside == int32(LEFT) || (*TPacker)(unsafe.Pointer(contentPtr)).Fside == int32(RIGHT) { if numExpand != 0 { curExpand = (cavityHeight - childHeight) / numExpand if curExpand < minExpand { minExpand = curExpand } } } else { cavityHeight -= childHeight if (*TPacker)(unsafe.Pointer(contentPtr)).Fflags&int32(EXPAND) != 0 { numExpand++ } } goto _1 _1: ; contentPtr = (*TPacker)(unsafe.Pointer(contentPtr)).FnextPtr } if numExpand != 0 { curExpand = cavityHeight / numExpand if curExpand < minExpand { minExpand = curExpand } } if minExpand < 0 { v2 = 0 } else { v2 = minExpand } return v2 } /* *------------------------------------------------------------------------ * * GetPacker -- * * This internal function is used to locate a Packer structure for a * window, creating one if one doesn't exist already, except if the window * is already dead. * * Results: * The return value is a pointer to the Packer structure corresponding to * tkwin, or NULL when tkwin is already dead. * * Side effects: * A new packer structure may be created. If so, then a callback is set * up to clean things up when the window is deleted. * *------------------------------------------------------------------------ */ func _GetPacker(tls *libc.TLS, tkwin TTk_Window) (r uintptr) { bp := tls.Alloc(16) defer tls.Free(16) /* Token for window for which packer structure * is desired. */ var dispPtr, hPtr, packPtr uintptr var v1, v2, v3 int32 var _ /* isNew at bp+0 */ int32 _, _, _, _, _, _ = dispPtr, hPtr, packPtr, v1, v2, v3 dispPtr = (*TTkWindow)(unsafe.Pointer(tkwin)).FdispPtr if (*TTkWindow)(unsafe.Pointer(tkwin)).Fflags&uint32(TK_ALREADY_DEAD) != 0 { return libc.UintptrFromInt32(0) } if !((*TTkDisplay)(unsafe.Pointer(dispPtr)).FpackInit != 0) { (*TTkDisplay)(unsafe.Pointer(dispPtr)).FpackInit = int32(1) libtcl9_0.XTcl_InitHashTable(tls, dispPtr+1968, int32(TCL_ONE_WORD_KEYS)) } /* * See if there's already packer for this window. If not, then create a * new one. */ hPtr = (*(*func(*libc.TLS, uintptr, uintptr, uintptr) uintptr)(unsafe.Pointer(&struct{ uintptr }{(*TTcl_HashTable)(unsafe.Pointer(dispPtr + 1968)).FcreateProc})))(tls, dispPtr+1968, tkwin, bp) if !(*(*int32)(unsafe.Pointer(bp)) != 0) { return (*TTcl_HashEntry)(unsafe.Pointer(hPtr)).FclientData } packPtr = libtcl9_0.XTcl_Alloc(tls, uint64(88)) (*TPacker)(unsafe.Pointer(packPtr)).Ftkwin = tkwin (*TPacker)(unsafe.Pointer(packPtr)).FcontainerPtr = libc.UintptrFromInt32(0) (*TPacker)(unsafe.Pointer(packPtr)).FnextPtr = libc.UintptrFromInt32(0) (*TPacker)(unsafe.Pointer(packPtr)).FcontentPtr = libc.UintptrFromInt32(0) (*TPacker)(unsafe.Pointer(packPtr)).Fside = int32(TOP) (*TPacker)(unsafe.Pointer(packPtr)).Fanchor = int32(TK_ANCHOR_CENTER) v1 = libc.Int32FromInt32(0) (*TPacker)(unsafe.Pointer(packPtr)).FpadY = v1 (*TPacker)(unsafe.Pointer(packPtr)).FpadX = v1 v2 = libc.Int32FromInt32(0) (*TPacker)(unsafe.Pointer(packPtr)).FpadTop = v2 (*TPacker)(unsafe.Pointer(packPtr)).FpadLeft = v2 v3 = libc.Int32FromInt32(0) (*TPacker)(unsafe.Pointer(packPtr)).FiPadY = v3 (*TPacker)(unsafe.Pointer(packPtr)).FiPadX = v3 (*TPacker)(unsafe.Pointer(packPtr)).FdoubleBw = int32(2) * (*TXWindowChanges)(unsafe.Pointer(tkwin+112)).Fborder_width (*TPacker)(unsafe.Pointer(packPtr)).FabortPtr = libc.UintptrFromInt32(0) (*TPacker)(unsafe.Pointer(packPtr)).Fflags = 0 (*TTcl_HashEntry)(unsafe.Pointer(hPtr)).FclientData = packPtr XTk_CreateEventHandler(tls, tkwin, libc.Uint64FromInt64(libc.Int64FromInt64(1)< objc { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+15257, libc.VaList(bp+40, libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(i)*8)), libc.UintptrFromInt32(0))))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+40, __ccgo_ts+179, __ccgo_ts+15152, __ccgo_ts+12954, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) } if libtcl9_0.XTcl_GetIndexFromObjStruct(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(i)*8)), uintptr(unsafe.Pointer(&_optionStrings12)), libc.Int64FromUint64(libc.Uint64FromInt64(8)), __ccgo_ts+2689, libc.Int32FromInt32(0)|libc.Int32FromUint64(libc.Uint64FromInt64(4)< libc.Float64FromInt32(0) { v4 = float64(0.5) } else { v4 = -libc.Float64FromFloat64(0.5) } x = int32(x1 + v4) y1 = float64((*TContent)(unsafe.Pointer(contentPtr)).Fy+containerY) + float64((*TContent)(unsafe.Pointer(contentPtr)).FrelY*float64(containerHeight)) if y1 > libc.Float64FromInt32(0) { v5 = float64(0.5) } else { v5 = -libc.Float64FromFloat64(0.5) } y = int32(y1 + v5) if (*TContent)(unsafe.Pointer(contentPtr)).FwidthObj != 0 || (*TContent)(unsafe.Pointer(contentPtr)).FrelWidthObj != 0 { width = 0 if (*TContent)(unsafe.Pointer(contentPtr)).FwidthObj != 0 { width += (*TContent)(unsafe.Pointer(contentPtr)).Fwidth } if (*TContent)(unsafe.Pointer(contentPtr)).FrelWidthObj != 0 { /* * The code below is a bit tricky. In order to round correctly * when both relX and relWidth are specified, compute the * location of the right edge and round that, then compute * width. If we compute the width and round it, rounding * errors in relX and relWidth accumulate. */ x2 = x1 + float64((*TContent)(unsafe.Pointer(contentPtr)).FrelWidth*float64(containerWidth)) if x2 > libc.Float64FromInt32(0) { v6 = float64(0.5) } else { v6 = -libc.Float64FromFloat64(0.5) } tmp = int32(x2 + v6) width += tmp - x } } else { width = (*TTk_FakeWin)(unsafe.Pointer((*TContent)(unsafe.Pointer(contentPtr)).Ftkwin)).FreqWidth + int32(2)*(*TXWindowChanges)(unsafe.Pointer((*TContent)(unsafe.Pointer(contentPtr)).Ftkwin+112)).Fborder_width } if (*TContent)(unsafe.Pointer(contentPtr)).FheightObj != 0 || (*TContent)(unsafe.Pointer(contentPtr)).FrelHeightObj != 0 { height = 0 if (*TContent)(unsafe.Pointer(contentPtr)).FheightObj != 0 { height += (*TContent)(unsafe.Pointer(contentPtr)).Fheight } if (*TContent)(unsafe.Pointer(contentPtr)).FrelHeightObj != 0 { /* * See note above for rounding errors in width computation. */ y2 = y1 + float64((*TContent)(unsafe.Pointer(contentPtr)).FrelHeight*float64(containerHeight)) if y2 > libc.Float64FromInt32(0) { v7 = float64(0.5) } else { v7 = -libc.Float64FromFloat64(0.5) } tmp = int32(y2 + v7) height += tmp - y } } else { height = (*TTk_FakeWin)(unsafe.Pointer((*TContent)(unsafe.Pointer(contentPtr)).Ftkwin)).FreqHeight + int32(2)*(*TXWindowChanges)(unsafe.Pointer((*TContent)(unsafe.Pointer(contentPtr)).Ftkwin+112)).Fborder_width } /* * Step 3: adjust the x and y positions so that the desired anchor * point on the content appears at that position. Also adjust for the * border mode and container's border. */ switch (*TContent)(unsafe.Pointer(contentPtr)).Fanchor { case int32(TK_ANCHOR_N): x -= width / int32(2) case int32(TK_ANCHOR_NE): x -= width case int32(TK_ANCHOR_E): x -= width y -= height / int32(2) case int32(TK_ANCHOR_SE): x -= width y -= height case int32(TK_ANCHOR_S): x -= width / int32(2) y -= height case int32(TK_ANCHOR_SW): y -= height case int32(TK_ANCHOR_W): y -= height / int32(2) case int32(TK_ANCHOR_NW): default: x -= width / int32(2) y -= height / int32(2) break } /* * Step 4: adjust width and height again to reflect inside dimensions * of window rather than outside. Also make sure that the width and * height aren't zero. */ width -= int32(2) * (*TXWindowChanges)(unsafe.Pointer((*TContent)(unsafe.Pointer(contentPtr)).Ftkwin+112)).Fborder_width height -= int32(2) * (*TXWindowChanges)(unsafe.Pointer((*TContent)(unsafe.Pointer(contentPtr)).Ftkwin+112)).Fborder_width if width <= 0 { width = int32(1) } if height <= 0 { height = int32(1) } /* * Step 5: reconfigure the window and map it if needed. If the content * is a child of the container, we do this ourselves. If the content isn't * a child of the container, let Tk_MaintainGeometry do the work (it will * re-adjust things as relevant windows map, unmap, and move). */ if (*TContainer)(unsafe.Pointer(containerPtr)).Ftkwin == (*TTk_FakeWin)(unsafe.Pointer((*TContent)(unsafe.Pointer(contentPtr)).Ftkwin)).FparentPtr { if x != (*TTk_FakeWin)(unsafe.Pointer((*TContent)(unsafe.Pointer(contentPtr)).Ftkwin)).Fchanges.Fx || y != (*TTk_FakeWin)(unsafe.Pointer((*TContent)(unsafe.Pointer(contentPtr)).Ftkwin)).Fchanges.Fy || width != (*TTk_FakeWin)(unsafe.Pointer((*TContent)(unsafe.Pointer(contentPtr)).Ftkwin)).Fchanges.Fwidth || height != (*TTk_FakeWin)(unsafe.Pointer((*TContent)(unsafe.Pointer(contentPtr)).Ftkwin)).Fchanges.Fheight { XTk_MoveResizeWindow(tls, (*TContent)(unsafe.Pointer(contentPtr)).Ftkwin, x, y, width, height) } if *(*int32)(unsafe.Pointer(bp)) != 0 { break } /* * Don't map the content unless the container is mapped: the content will * get mapped later, when the container is mapped. */ if (*TTk_FakeWin)(unsafe.Pointer((*TContainer)(unsafe.Pointer(containerPtr)).Ftkwin)).Fflags&uint32(TK_MAPPED) != 0 { XTk_MapWindow(tls, (*TContent)(unsafe.Pointer(contentPtr)).Ftkwin) } } else { if width <= 0 || height <= 0 { XTk_UnmaintainGeometry(tls, (*TContent)(unsafe.Pointer(contentPtr)).Ftkwin, (*TContainer)(unsafe.Pointer(containerPtr)).Ftkwin) XTk_UnmapWindow(tls, (*TContent)(unsafe.Pointer(contentPtr)).Ftkwin) } else { XTk_MaintainGeometry(tls, (*TContent)(unsafe.Pointer(contentPtr)).Ftkwin, (*TContainer)(unsafe.Pointer(containerPtr)).Ftkwin, x, y, width, height) } } goto _1 _1: ; contentPtr = (*TContent)(unsafe.Pointer(contentPtr)).FnextPtr } (*TContainer)(unsafe.Pointer(containerPtr)).FabortPtr = libc.UintptrFromInt32(0) libtcl9_0.XTcl_Release(tls, containerPtr) } /* *---------------------------------------------------------------------- * * PlaceStructureProc -- * * This function is invoked by the Tk event handler when StructureNotify * events occur for a container window. * * Results: * None. * * Side effects: * Structures get cleaned up if the window was deleted. If the window was * resized then content geometries get recomputed. * *---------------------------------------------------------------------- */ func _PlaceStructureProc(tls *libc.TLS, clientData uintptr, eventPtr uintptr) { /* Describes what just happened. */ var containerPtr, contentPtr, dispPtr, nextPtr uintptr _, _, _, _ = containerPtr, contentPtr, dispPtr, nextPtr containerPtr = clientData dispPtr = (*TTkWindow)(unsafe.Pointer((*TContainer)(unsafe.Pointer(containerPtr)).Ftkwin)).FdispPtr switch (*TXEvent)(unsafe.Pointer(eventPtr)).Ftype1 { case int32(ConfigureNotify): goto _1 case int32(DestroyNotify): goto _2 case int32(MapNotify): goto _3 case int32(UnmapNotify): goto _4 } goto _5 _1: ; if (*TContainer)(unsafe.Pointer(containerPtr)).FcontentPtr != libc.UintptrFromInt32(0) && !((*TContainer)(unsafe.Pointer(containerPtr)).Fflags&libc.Int32FromInt32(PARENT_RECONFIG_PENDING) != 0) { *(*int32)(unsafe.Pointer(containerPtr + 24)) |= int32(PARENT_RECONFIG_PENDING) libtcl9_0.XTcl_DoWhenIdle(tls, __ccgo_fp(_RecomputePlacement), containerPtr) } return _2: ; contentPtr = (*TContainer)(unsafe.Pointer(containerPtr)).FcontentPtr _8: ; if !(contentPtr != libc.UintptrFromInt32(0)) { goto _6 } (*TContent)(unsafe.Pointer(contentPtr)).FcontainerPtr = libc.UintptrFromInt32(0) nextPtr = (*TContent)(unsafe.Pointer(contentPtr)).FnextPtr (*TContent)(unsafe.Pointer(contentPtr)).FnextPtr = libc.UintptrFromInt32(0) goto _7 _7: ; contentPtr = nextPtr goto _8 goto _6 _6: ; libtcl9_0.XTcl_DeleteHashEntry(tls, (*(*func(*libc.TLS, uintptr, uintptr) uintptr)(unsafe.Pointer(&struct{ uintptr }{(*TTcl_HashTable)(unsafe.Pointer(dispPtr + 2080)).FfindProc})))(tls, dispPtr+2080, (*TContainer)(unsafe.Pointer(containerPtr)).Ftkwin)) if (*TContainer)(unsafe.Pointer(containerPtr)).Fflags&int32(PARENT_RECONFIG_PENDING) != 0 { libtcl9_0.XTcl_CancelIdleCall(tls, __ccgo_fp(_RecomputePlacement), containerPtr) } (*TContainer)(unsafe.Pointer(containerPtr)).Ftkwin = libc.UintptrFromInt32(0) if (*TContainer)(unsafe.Pointer(containerPtr)).FabortPtr != libc.UintptrFromInt32(0) { *(*int32)(unsafe.Pointer((*TContainer)(unsafe.Pointer(containerPtr)).FabortPtr)) = int32(1) } libtcl9_0.XTcl_EventuallyFree(tls, containerPtr, libc.UintptrFromInt32(3)) return _3: ; /* * When a container gets mapped, must redo the geometry computation so * that all of its content get remapped. */ if (*TContainer)(unsafe.Pointer(containerPtr)).FcontentPtr != libc.UintptrFromInt32(0) && !((*TContainer)(unsafe.Pointer(containerPtr)).Fflags&libc.Int32FromInt32(PARENT_RECONFIG_PENDING) != 0) { *(*int32)(unsafe.Pointer(containerPtr + 24)) |= int32(PARENT_RECONFIG_PENDING) libtcl9_0.XTcl_DoWhenIdle(tls, __ccgo_fp(_RecomputePlacement), containerPtr) } return _4: ; /* * Unmap all of the content when the container gets unmapped, so that they * don't keep redisplaying themselves. */ contentPtr = (*TContainer)(unsafe.Pointer(containerPtr)).FcontentPtr for { if !(contentPtr != libc.UintptrFromInt32(0)) { break } XTk_UnmapWindow(tls, (*TContent)(unsafe.Pointer(contentPtr)).Ftkwin) goto _9 _9: ; contentPtr = (*TContent)(unsafe.Pointer(contentPtr)).FnextPtr } return _5: } /* *---------------------------------------------------------------------- * * ContentStructureProc -- * * This function is invoked by the Tk event handler when StructureNotify * events occur for a content window. * * Results: * None. * * Side effects: * Structures get cleaned up if the window was deleted. * *---------------------------------------------------------------------- */ func _ContentStructureProc(tls *libc.TLS, clientData uintptr, eventPtr uintptr) { /* Describes what just happened. */ var contentPtr, dispPtr uintptr _, _ = contentPtr, dispPtr contentPtr = clientData dispPtr = (*TTkWindow)(unsafe.Pointer((*TContent)(unsafe.Pointer(contentPtr)).Ftkwin)).FdispPtr if (*TXEvent)(unsafe.Pointer(eventPtr)).Ftype1 == int32(DestroyNotify) { if (*TContent)(unsafe.Pointer(contentPtr)).FcontainerPtr != libc.UintptrFromInt32(0) { _UnlinkContent(tls, contentPtr) } libtcl9_0.XTcl_DeleteHashEntry(tls, (*(*func(*libc.TLS, uintptr, uintptr) uintptr)(unsafe.Pointer(&struct{ uintptr }{(*TTcl_HashTable)(unsafe.Pointer(dispPtr + 2184)).FfindProc})))(tls, dispPtr+2184, (*TContent)(unsafe.Pointer(contentPtr)).Ftkwin)) _FreeContent(tls, contentPtr) } } /* *---------------------------------------------------------------------- * * PlaceRequestProc -- * * This function is invoked by Tk whenever a content managed by us changes * its requested geometry. * * Results: * None. * * Side effects: * The window will get relayed out, if its requested size has anything to * do with its actual size. * *---------------------------------------------------------------------- */ func _PlaceRequestProc(tls *libc.TLS, clientData uintptr, dummy1182 TTk_Window) { /* Window that changed its desired size. */ var containerPtr, contentPtr uintptr _, _ = containerPtr, contentPtr contentPtr = clientData if ((*TContent)(unsafe.Pointer(contentPtr)).FwidthObj != 0 || (*TContent)(unsafe.Pointer(contentPtr)).FrelWidthObj != 0) && ((*TContent)(unsafe.Pointer(contentPtr)).FheightObj != 0 || (*TContent)(unsafe.Pointer(contentPtr)).FrelHeightObj != 0) { /* * Send a ConfigureNotify to indicate that the size change * request was rejected. */ XTkDoConfigureNotify(tls, (*TContent)(unsafe.Pointer(contentPtr)).Ftkwin) return } containerPtr = (*TContent)(unsafe.Pointer(contentPtr)).FcontainerPtr if containerPtr == libc.UintptrFromInt32(0) { return } if !((*TContainer)(unsafe.Pointer(containerPtr)).Fflags&libc.Int32FromInt32(PARENT_RECONFIG_PENDING) != 0) { *(*int32)(unsafe.Pointer(containerPtr + 24)) |= int32(PARENT_RECONFIG_PENDING) libtcl9_0.XTcl_DoWhenIdle(tls, __ccgo_fp(_RecomputePlacement), containerPtr) } } /* *-------------------------------------------------------------- * * PlaceLostContentProc -- * * This function is invoked by Tk whenever some other geometry claims * control over a content window that used to be managed by us. * * Results: * None. * * Side effects: * Forgets all placer-related information about the content window. * *-------------------------------------------------------------- */ func _PlaceLostContentProc(tls *libc.TLS, clientData uintptr, tkwin TTk_Window) { /* Tk's handle for the content window. */ var contentPtr, dispPtr uintptr _, _ = contentPtr, dispPtr contentPtr = clientData dispPtr = (*TTkWindow)(unsafe.Pointer((*TContent)(unsafe.Pointer(contentPtr)).Ftkwin)).FdispPtr if (*TContainer1)(unsafe.Pointer((*TContent)(unsafe.Pointer(contentPtr)).FcontainerPtr)).Ftkwin != (*TTk_FakeWin)(unsafe.Pointer((*TContent)(unsafe.Pointer(contentPtr)).Ftkwin)).FparentPtr { XTk_UnmaintainGeometry(tls, (*TContent)(unsafe.Pointer(contentPtr)).Ftkwin, (*TContainer1)(unsafe.Pointer((*TContent)(unsafe.Pointer(contentPtr)).FcontainerPtr)).Ftkwin) } XTk_UnmapWindow(tls, tkwin) _UnlinkContent(tls, contentPtr) libtcl9_0.XTcl_DeleteHashEntry(tls, (*(*func(*libc.TLS, uintptr, uintptr) uintptr)(unsafe.Pointer(&struct{ uintptr }{(*TTcl_HashTable)(unsafe.Pointer(dispPtr + 2184)).FfindProc})))(tls, dispPtr+2184, tkwin)) XTk_DeleteEventHandler(tls, tkwin, libc.Uint64FromInt64(libc.Int64FromInt64(1)< int64(TK_SEL_BYTES_AT_ONCE) { libtcl9_0.XTcl_Panic(tls, __ccgo_ts+16195, 0) } } (*(*[4001]uint8)(unsafe.Pointer(bp)))[count] = uint8(0) result = (*(*func(*libc.TLS, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{proc})))(tls, clientData, interp, bp) } else { offset = 0 result = TCL_OK (*(*TTkSelInProgress)(unsafe.Pointer(bp + 4008))).FselPtr = selPtr (*(*TTkSelInProgress)(unsafe.Pointer(bp + 4008))).FnextPtr = (*TThreadSpecificData7)(unsafe.Pointer(tsdPtr)).FpendingPtr (*TThreadSpecificData7)(unsafe.Pointer(tsdPtr)).FpendingPtr = bp + 4008 for int32(1) != 0 { count = (*(*func(*libc.TLS, uintptr, TTcl_Size, uintptr, TTcl_Size) TTcl_Size)(unsafe.Pointer(&struct{ uintptr }{(*TTkSelHandler)(unsafe.Pointer(selPtr)).Fproc})))(tls, (*TTkSelHandler)(unsafe.Pointer(selPtr)).FclientData, offset, bp, int64(TK_SEL_BYTES_AT_ONCE)) if count < 0 || (*(*TTkSelInProgress)(unsafe.Pointer(bp + 4008))).FselPtr == libc.UintptrFromInt32(0) { (*TThreadSpecificData7)(unsafe.Pointer(tsdPtr)).FpendingPtr = (*(*TTkSelInProgress)(unsafe.Pointer(bp + 4008))).FnextPtr goto cantget } if count > int64(TK_SEL_BYTES_AT_ONCE) { libtcl9_0.XTcl_Panic(tls, __ccgo_ts+16195, 0) } (*(*[4001]uint8)(unsafe.Pointer(bp)))[count] = uint8('\000') result = (*(*func(*libc.TLS, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{proc})))(tls, clientData, interp, bp) if result != TCL_OK || count < int64(TK_SEL_BYTES_AT_ONCE) || (*(*TTkSelInProgress)(unsafe.Pointer(bp + 4008))).FselPtr == libc.UintptrFromInt32(0) { break } offset += count } (*TThreadSpecificData7)(unsafe.Pointer(tsdPtr)).FpendingPtr = (*(*TTkSelInProgress)(unsafe.Pointer(bp + 4008))).FnextPtr } return result } /* * The selection is owned by some other process. */ return XTkSelGetSelection(tls, interp, tkwin, selection, target, proc, clientData) goto cantget cantget: ; libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+16237, libc.VaList(bp+4040, XTk_GetAtomName(tls, tkwin, selection), XTk_GetAtomName(tls, tkwin, target)))) return int32(TCL_ERROR) } /* *-------------------------------------------------------------- * * Tk_SelectionObjCmd -- * * This function is invoked to process the "selection" Tcl command. See * the user documentation for details on what it does. * * Results: * A standard Tcl result. * * Side effects: * See the user documentation. * *-------------------------------------------------------------- */ func XTk_SelectionObjCmd(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) (r int32) { bp := tls.Alloc(304) defer tls.Free(304) /* Argument objects. */ var cmdInfoPtr, commandObj, formatName, infoPtr, lostPtr, objs, path, selName, string1, targetName, targetName1, winPtr uintptr var count, result int32 var format, selection, target, target1 TAtom var tkwin TTk_Window var _ /* clearIndex at bp+4 */ int32 var _ /* cmdLength at bp+240 */ TTcl_Size var _ /* getIndex at bp+232 */ int32 var _ /* handleIndex at bp+248 */ int32 var _ /* index at bp+0 */ int32 var _ /* ownIndex at bp+252 */ int32 var _ /* selBytes at bp+8 */ TTcl_DString _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = cmdInfoPtr, commandObj, count, format, formatName, infoPtr, lostPtr, objs, path, result, selName, selection, string1, target, target1, targetName, targetName1, tkwin, winPtr tkwin = clientData path = libc.UintptrFromInt32(0) selName = libc.UintptrFromInt32(0) if objc < int32(2) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(1), objv, __ccgo_ts+4953) return int32(TCL_ERROR) } if libtcl9_0.XTcl_GetIndexFromObjStruct(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 1*8)), uintptr(unsafe.Pointer(&_optionStrings14)), libc.Int64FromUint64(libc.Uint64FromInt64(8)), __ccgo_ts+2689, libc.Int32FromInt32(0)|libc.Int32FromUint64(libc.Uint64FromInt64(4)< 0) { break } string1 = libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objs)), libc.UintptrFromInt32(0)) if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(string1))) != int32('-') { break } if count < int32(2) { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+3180, libc.VaList(bp+264, string1))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+264, __ccgo_ts+179, __ccgo_ts+16311, __ccgo_ts+182, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) } if libtcl9_0.XTcl_GetIndexFromObjStruct(tls, interp, *(*uintptr)(unsafe.Pointer(objs)), uintptr(unsafe.Pointer(&_clearOptionStrings1)), libc.Int64FromUint64(libc.Uint64FromInt64(8)), __ccgo_ts+2689, libc.Int32FromInt32(0)|libc.Int32FromUint64(libc.Uint64FromInt64(4)< int32(1) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(2), objv, __ccgo_ts+5040) return int32(TCL_ERROR) } } if path != libc.UintptrFromInt32(0) { tkwin = XTk_NameToWindow(tls, interp, path, tkwin) } if tkwin == libc.UintptrFromInt32(0) { return int32(TCL_ERROR) } if selName != libc.UintptrFromInt32(0) { selection = XTk_InternAtom(tls, tkwin, selName) } else { selection = libc.Uint64FromInt32(1) } XTk_ClearSelection(tls, tkwin, selection) case 1: targetName = libc.UintptrFromInt32(0) count = objc - int32(2) objs = objv + libc.UintptrFromInt32(2)*8 for { if !(count > 0) { break } string1 = libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objs)), libc.UintptrFromInt32(0)) if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(string1))) != int32('-') { break } if count < int32(2) { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+3180, libc.VaList(bp+264, string1))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+264, __ccgo_ts+179, __ccgo_ts+16311, __ccgo_ts+182, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) } if libtcl9_0.XTcl_GetIndexFromObjStruct(tls, interp, *(*uintptr)(unsafe.Pointer(objs)), uintptr(unsafe.Pointer(&_getOptionStrings1)), libc.Int64FromUint64(libc.Uint64FromInt64(8)), __ccgo_ts+2689, libc.Int32FromInt32(0)|libc.Int32FromUint64(libc.Uint64FromInt64(4)< int32(1) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(2), objv, __ccgo_ts+5040) return int32(TCL_ERROR) } else { if count == int32(1) { target = XTk_InternAtom(tls, tkwin, libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objs)), libc.UintptrFromInt32(0))) } else { if targetName != libc.UintptrFromInt32(0) { target = XTk_InternAtom(tls, tkwin, targetName) } else { target = libc.Uint64FromInt32(31) } } } libtcl9_0.XTcl_DStringInit(tls, bp+8) result = XTk_GetSelection(tls, interp, tkwin, selection, target, __ccgo_fp(_SelGetProc), bp+8) if result == TCL_OK { libtcl9_0.XTcl_DStringResult(tls, interp, bp+8) } else { libtcl9_0.XTcl_DStringFree(tls, bp+8) } return result case 2: targetName1 = libc.UintptrFromInt32(0) formatName = libc.UintptrFromInt32(0) count = objc - int32(2) objs = objv + libc.UintptrFromInt32(2)*8 for { if !(count > 0) { break } string1 = libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objs)), libc.UintptrFromInt32(0)) if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(string1))) != int32('-') { break } if count < int32(2) { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+3180, libc.VaList(bp+264, string1))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+264, __ccgo_ts+179, __ccgo_ts+16311, __ccgo_ts+182, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) } if libtcl9_0.XTcl_GetIndexFromObjStruct(tls, interp, *(*uintptr)(unsafe.Pointer(objs)), uintptr(unsafe.Pointer(&_handleOptionStrings)), libc.Int64FromUint64(libc.Uint64FromInt64(8)), __ccgo_ts+2689, libc.Int32FromInt32(0)|libc.Int32FromUint64(libc.Uint64FromInt64(4)< int32(4) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(2), objv, __ccgo_ts+16321) return int32(TCL_ERROR) } tkwin = XTk_NameToWindow(tls, interp, libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objs)), libc.UintptrFromInt32(0)), tkwin) if tkwin == libc.UintptrFromInt32(0) { return int32(TCL_ERROR) } if selName != libc.UintptrFromInt32(0) { selection = XTk_InternAtom(tls, tkwin, selName) } else { selection = libc.Uint64FromInt32(1) } if count > int32(2) { target1 = XTk_InternAtom(tls, tkwin, libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objs + 2*8)), libc.UintptrFromInt32(0))) } else { if targetName1 != libc.UintptrFromInt32(0) { target1 = XTk_InternAtom(tls, tkwin, targetName1) } else { target1 = libc.Uint64FromInt32(31) } } if count > int32(3) { format = XTk_InternAtom(tls, tkwin, libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objs + 3*8)), libc.UintptrFromInt32(0))) } else { if formatName != libc.UintptrFromInt32(0) { format = XTk_InternAtom(tls, tkwin, formatName) } else { format = libc.Uint64FromInt32(31) } } string1 = libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objs + 1*8)), bp+240) if *(*TTcl_Size)(unsafe.Pointer(bp + 240)) == 0 { XTk_DeleteSelHandler(tls, tkwin, selection, target1) } else { cmdInfoPtr = libtcl9_0.XTcl_Alloc(tls, uint64(libc.UintptrFromInt32(0)+36)+libc.Uint64FromInt32(1)+libc.Uint64FromInt64(*(*TTcl_Size)(unsafe.Pointer(bp + 240)))) (*TCommandInfo)(unsafe.Pointer(cmdInfoPtr)).Finterp = interp (*TCommandInfo)(unsafe.Pointer(cmdInfoPtr)).FcharOffset = 0 (*TCommandInfo)(unsafe.Pointer(cmdInfoPtr)).FbyteOffset = 0 *(*uint8)(unsafe.Pointer(cmdInfoPtr + 32)) = uint8('\000') (*TCommandInfo)(unsafe.Pointer(cmdInfoPtr)).FcmdLength = *(*TTcl_Size)(unsafe.Pointer(bp + 240)) libc.Xmemcpy(tls, cmdInfoPtr+36, string1, libc.Uint64FromInt64(*(*TTcl_Size)(unsafe.Pointer(bp + 240))+int64(1))) XTk_CreateSelHandler(tls, tkwin, selection, target1, __ccgo_fp(_HandleTclCommand), cmdInfoPtr, format) } return TCL_OK case 3: commandObj = libc.UintptrFromInt32(0) count = objc - int32(2) objs = objv + libc.UintptrFromInt32(2)*8 for { if !(count > 0) { break } string1 = libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objs)), libc.UintptrFromInt32(0)) if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(string1))) != int32('-') { break } if count < int32(2) { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+3180, libc.VaList(bp+264, string1))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+264, __ccgo_ts+179, __ccgo_ts+16311, __ccgo_ts+182, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) } if libtcl9_0.XTcl_GetIndexFromObjStruct(tls, interp, *(*uintptr)(unsafe.Pointer(objs)), uintptr(unsafe.Pointer(&_ownOptionStrings)), libc.Int64FromUint64(libc.Uint64FromInt64(8)), __ccgo_ts+2689, libc.Int32FromInt32(0)|libc.Int32FromUint64(libc.Uint64FromInt64(4)< int32(2) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(2), objv, __ccgo_ts+16365) return int32(TCL_ERROR) } if selName != libc.UintptrFromInt32(0) { selection = XTk_InternAtom(tls, tkwin, selName) } else { selection = libc.Uint64FromInt32(1) } if count == 0 { if path != libc.UintptrFromInt32(0) { tkwin = XTk_NameToWindow(tls, interp, path, tkwin) } if tkwin == libc.UintptrFromInt32(0) { return int32(TCL_ERROR) } winPtr = tkwin infoPtr = (*TTkDisplay)(unsafe.Pointer((*TTkWindow)(unsafe.Pointer(winPtr)).FdispPtr)).FselectionInfoPtr for { if !(infoPtr != libc.UintptrFromInt32(0)) { break } if (*TTkSelectionInfo)(unsafe.Pointer(infoPtr)).Fselection == selection { break } goto _5 _5: ; infoPtr = (*TTkSelectionInfo)(unsafe.Pointer(infoPtr)).FnextPtr } /* * Ignore the internal clipboard window. */ if infoPtr != libc.UintptrFromInt32(0) && (*TTkSelectionInfo)(unsafe.Pointer(infoPtr)).Fowner != (*TTkDisplay)(unsafe.Pointer((*TTkWindow)(unsafe.Pointer(winPtr)).FdispPtr)).FclipWindow { libtcl9_0.XTcl_SetObjResult(tls, interp, XTk_NewWindowObj(tls, (*TTkSelectionInfo)(unsafe.Pointer(infoPtr)).Fowner)) } return TCL_OK } tkwin = XTk_NameToWindow(tls, interp, libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objs)), libc.UintptrFromInt32(0)), tkwin) if tkwin == libc.UintptrFromInt32(0) { return int32(TCL_ERROR) } if count == int32(2) { commandObj = *(*uintptr)(unsafe.Pointer(objs + 1*8)) } if commandObj == libc.UintptrFromInt32(0) { XTk_OwnSelection(tls, tkwin, selection, libc.UintptrFromInt32(0), libc.UintptrFromInt32(0)) return TCL_OK } lostPtr = libtcl9_0.XTcl_Alloc(tls, uint64(16)) (*TLostCommand)(unsafe.Pointer(lostPtr)).Finterp = interp (*TLostCommand)(unsafe.Pointer(lostPtr)).FcmdObj = commandObj (*TTcl_Obj)(unsafe.Pointer(commandObj)).FrefCount++ XTk_OwnSelection(tls, tkwin, selection, __ccgo_fp(_LostSelection), lostPtr) return TCL_OK } return TCL_OK } var _optionStrings14 = [5]uintptr{ 0: __ccgo_ts + 4943, 1: __ccgo_ts + 4949, 2: __ccgo_ts + 16289, 3: __ccgo_ts + 16296, 4: libc.UintptrFromInt32(0), } var _clearOptionStrings1 = [3]uintptr{ 0: __ccgo_ts + 4970, 1: __ccgo_ts + 16300, 2: libc.UintptrFromInt32(0), } var _getOptionStrings1 = [4]uintptr{ 0: __ccgo_ts + 4970, 1: __ccgo_ts + 16300, 2: __ccgo_ts + 4989, 3: libc.UintptrFromInt32(0), } var _handleOptionStrings = [4]uintptr{ 0: __ccgo_ts + 4981, 1: __ccgo_ts + 16300, 2: __ccgo_ts + 4989, 3: libc.UintptrFromInt32(0), } var _ownOptionStrings = [4]uintptr{ 0: __ccgo_ts + 16356, 1: __ccgo_ts + 4970, 2: __ccgo_ts + 16300, 3: libc.UintptrFromInt32(0), } /* *---------------------------------------------------------------------- * * TkSelGetInProgress -- * * This function returns a pointer to the thread-local list of pending * searches. * * Results: * The return value is a pointer to the first search in progress, or NULL * if there are none. * * Side effects: * None. * *---------------------------------------------------------------------- */ func XTkSelGetInProgress(tls *libc.TLS) (r uintptr) { var tsdPtr uintptr _ = tsdPtr tsdPtr = libtcl9_0.XTcl_GetThreadData(tls, uintptr(unsafe.Pointer(&_dataKey7)), int64(8)) return (*TThreadSpecificData7)(unsafe.Pointer(tsdPtr)).FpendingPtr } // C documentation // // /* // *---------------------------------------------------------------------- // * // * TkSelSetInProgress -- // * // * This function is used to set the thread-local list of pending // * searches. It is required because the pending list is kept in thread // * local storage. // * // * Results: // * None. // * // * Side effects: // * None. // * // *---------------------------------------------------------------------- // */ func XTkSelSetInProgress(tls *libc.TLS, pendingPtr uintptr) { var tsdPtr uintptr _ = tsdPtr tsdPtr = libtcl9_0.XTcl_GetThreadData(tls, uintptr(unsafe.Pointer(&_dataKey7)), int64(8)) (*TThreadSpecificData7)(unsafe.Pointer(tsdPtr)).FpendingPtr = pendingPtr } /* *---------------------------------------------------------------------- * * TkSelDeadWindow -- * * This function is invoked just before a TkWindow is deleted. It * performs selection-related cleanup. * * Results: * None. * * Side effects: * Frees up memory associated with the selection. * *---------------------------------------------------------------------- */ func XTkSelDeadWindow(tls *libc.TLS, winPtr uintptr) { /* Window that's being deleted. */ var infoPtr, ipPtr, nextPtr, prevPtr, selPtr, tsdPtr uintptr _, _, _, _, _, _ = infoPtr, ipPtr, nextPtr, prevPtr, selPtr, tsdPtr tsdPtr = libtcl9_0.XTcl_GetThreadData(tls, uintptr(unsafe.Pointer(&_dataKey7)), int64(8)) /* * While deleting all the handlers, be careful to check whether * ConvertSelection or TkSelPropProc are about to process one of the * deleted handlers. */ for (*TTkWindow)(unsafe.Pointer(winPtr)).FselHandlerList != libc.UintptrFromInt32(0) { selPtr = (*TTkWindow)(unsafe.Pointer(winPtr)).FselHandlerList (*TTkWindow)(unsafe.Pointer(winPtr)).FselHandlerList = (*TTkSelHandler)(unsafe.Pointer(selPtr)).FnextPtr ipPtr = (*TThreadSpecificData7)(unsafe.Pointer(tsdPtr)).FpendingPtr for { if !(ipPtr != libc.UintptrFromInt32(0)) { break } if (*TTkSelInProgress)(unsafe.Pointer(ipPtr)).FselPtr == selPtr { (*TTkSelInProgress)(unsafe.Pointer(ipPtr)).FselPtr = libc.UintptrFromInt32(0) } goto _1 _1: ; ipPtr = (*TTkSelInProgress)(unsafe.Pointer(ipPtr)).FnextPtr } if (*TTkSelHandler)(unsafe.Pointer(selPtr)).Fproc == __ccgo_fp(_HandleTclCommand) { /* * Mark the CommandInfo as deleted and free it when we can. */ (*TCommandInfo)(unsafe.Pointer((*TTkSelHandler)(unsafe.Pointer(selPtr)).FclientData)).Finterp = libc.UintptrFromInt32(0) libtcl9_0.XTcl_EventuallyFree(tls, (*TTkSelHandler)(unsafe.Pointer(selPtr)).FclientData, libc.UintptrFromInt32(3)) } libtcl9_0.XTcl_Free(tls, selPtr) } /* * Remove selections owned by window being deleted. */ infoPtr = (*TTkDisplay)(unsafe.Pointer((*TTkWindow)(unsafe.Pointer(winPtr)).FdispPtr)).FselectionInfoPtr prevPtr = libc.UintptrFromInt32(0) for { if !(infoPtr != libc.UintptrFromInt32(0)) { break } nextPtr = (*TTkSelectionInfo)(unsafe.Pointer(infoPtr)).FnextPtr if (*TTkSelectionInfo)(unsafe.Pointer(infoPtr)).Fowner == winPtr { if (*TTkSelectionInfo)(unsafe.Pointer(infoPtr)).FclearProc == __ccgo_fp(_LostSelection) { libtcl9_0.XTcl_Free(tls, (*TTkSelectionInfo)(unsafe.Pointer(infoPtr)).FclearData) } libtcl9_0.XTcl_Free(tls, infoPtr) infoPtr = prevPtr if prevPtr == libc.UintptrFromInt32(0) { (*TTkDisplay)(unsafe.Pointer((*TTkWindow)(unsafe.Pointer(winPtr)).FdispPtr)).FselectionInfoPtr = nextPtr } else { (*TTkSelectionInfo)(unsafe.Pointer(prevPtr)).FnextPtr = nextPtr } } prevPtr = infoPtr goto _2 _2: ; infoPtr = nextPtr } } /* *---------------------------------------------------------------------- * * TkSelInit -- * * Initialize selection-related information for a display. * * Results: * None. * * Side effects: * Selection-related information is initialized. * *---------------------------------------------------------------------- */ func XTkSelInit(tls *libc.TLS, tkwin TTk_Window) { /* Window token (used to find display to * initialize). */ var dispPtr uintptr _ = dispPtr dispPtr = (*TTkWindow)(unsafe.Pointer(tkwin)).FdispPtr /* * Fetch commonly-used atoms. */ (*TTkDisplay)(unsafe.Pointer(dispPtr)).FmultipleAtom = XTk_InternAtom(tls, tkwin, __ccgo_ts+3171) (*TTkDisplay)(unsafe.Pointer(dispPtr)).FincrAtom = XTk_InternAtom(tls, tkwin, __ccgo_ts+16394) (*TTkDisplay)(unsafe.Pointer(dispPtr)).FtargetsAtom = XTk_InternAtom(tls, tkwin, __ccgo_ts+16399) (*TTkDisplay)(unsafe.Pointer(dispPtr)).FtimestampAtom = XTk_InternAtom(tls, tkwin, __ccgo_ts+16407) (*TTkDisplay)(unsafe.Pointer(dispPtr)).FtextAtom = XTk_InternAtom(tls, tkwin, __ccgo_ts+16417) (*TTkDisplay)(unsafe.Pointer(dispPtr)).FcompoundTextAtom = XTk_InternAtom(tls, tkwin, __ccgo_ts+16422) (*TTkDisplay)(unsafe.Pointer(dispPtr)).FapplicationAtom = XTk_InternAtom(tls, tkwin, __ccgo_ts+16436) (*TTkDisplay)(unsafe.Pointer(dispPtr)).FwindowAtom = XTk_InternAtom(tls, tkwin, __ccgo_ts+16451) (*TTkDisplay)(unsafe.Pointer(dispPtr)).FclipboardAtom = XTk_InternAtom(tls, tkwin, __ccgo_ts+4910) (*TTkDisplay)(unsafe.Pointer(dispPtr)).FatomPairAtom = XTk_InternAtom(tls, tkwin, __ccgo_ts+16461) /* * Using UTF8_STRING instead of the XA_UTF8_STRING macro allows us to * support older X servers that didn't have UTF8_STRING yet. This is * necessary on Unix systems. For more information, see: * https://www.cl.cam.ac.uk/~mgk25/unicode.html#x11 */ (*TTkDisplay)(unsafe.Pointer(dispPtr)).Futf8Atom = XTk_InternAtom(tls, tkwin, __ccgo_ts+16471) } /* *---------------------------------------------------------------------- * * TkSelClearSelection -- * * This function is invoked to process a SelectionClear event. * * Results: * None. * * Side effects: * Invokes the clear function for the window which lost the * selection. * *---------------------------------------------------------------------- */ func XTkSelClearSelection(tls *libc.TLS, tkwin TTk_Window, eventPtr uintptr) { /* X SelectionClear event. */ var dispPtr, infoPtr, prevPtr, winPtr uintptr _, _, _, _ = dispPtr, infoPtr, prevPtr, winPtr winPtr = tkwin dispPtr = (*TTkWindow)(unsafe.Pointer(winPtr)).FdispPtr /* * Invoke clear function for window that just lost the selection. This * code is a bit tricky, because any callbacks due to selection changes * between windows managed by the process have already been made. Thus, * ignore the event unless it refers to the window that's currently the * selection owner and the event was generated after the server saw the * SetSelectionOwner request. */ infoPtr = (*TTkDisplay)(unsafe.Pointer(dispPtr)).FselectionInfoPtr prevPtr = libc.UintptrFromInt32(0) for { if !(infoPtr != libc.UintptrFromInt32(0)) { break } if (*TTkSelectionInfo)(unsafe.Pointer(infoPtr)).Fselection == (*(*TXSelectionClearEvent)(unsafe.Pointer(eventPtr))).Fselection { break } prevPtr = infoPtr goto _1 _1: ; infoPtr = (*TTkSelectionInfo)(unsafe.Pointer(infoPtr)).FnextPtr } if infoPtr != libc.UintptrFromInt32(0) && (*TTkSelectionInfo)(unsafe.Pointer(infoPtr)).Fowner == tkwin && (*(*TXSelectionClearEvent)(unsafe.Pointer(eventPtr))).Fserial >= (*TTkSelectionInfo)(unsafe.Pointer(infoPtr)).Fserial { if prevPtr == libc.UintptrFromInt32(0) { (*TTkDisplay)(unsafe.Pointer(dispPtr)).FselectionInfoPtr = (*TTkSelectionInfo)(unsafe.Pointer(infoPtr)).FnextPtr } else { (*TTkSelectionInfo)(unsafe.Pointer(prevPtr)).FnextPtr = (*TTkSelectionInfo)(unsafe.Pointer(infoPtr)).FnextPtr } /* * Because of reentrancy problems, calling clearProc must be done * after the infoPtr has been removed from the selectionInfoPtr list * (clearProc could modify the list, e.g. by creating a new * selection). */ if (*TTkSelectionInfo)(unsafe.Pointer(infoPtr)).FclearProc != libc.UintptrFromInt32(0) { (*(*func(*libc.TLS, uintptr))(unsafe.Pointer(&struct{ uintptr }{(*TTkSelectionInfo)(unsafe.Pointer(infoPtr)).FclearProc})))(tls, (*TTkSelectionInfo)(unsafe.Pointer(infoPtr)).FclearData) } libtcl9_0.XTcl_Free(tls, infoPtr) } } /* *-------------------------------------------------------------- * * SelGetProc -- * * This function is invoked to process pieces of the selection as they * arrive during "selection get" commands. * * Results: * Always returns TCL_OK. * * Side effects: * Bytes get appended to the dynamic string pointed to by the clientData * argument. * *-------------------------------------------------------------- */ func _SelGetProc(tls *libc.TLS, clientData uintptr, dummy1296 uintptr, portion uintptr) (r int32) { /* New information to be appended. */ libtcl9_0.XTcl_DStringAppend(tls, clientData, portion, int64(-libc.Int32FromInt32(1))) return TCL_OK } /* *---------------------------------------------------------------------- * * HandleTclCommand -- * * This function acts as selection handler for handlers created by the * "selection handle" command. It invokes a Tcl command to retrieve the * selection. * * Results: * The return value is a count of the number of bytes actually stored at * buffer, or -1 if an error occurs while executing the Tcl command to * retrieve the selection. * * Side effects: * None except for things done by the Tcl command. * *---------------------------------------------------------------------- */ func _HandleTclCommand(tls *libc.TLS, clientData uintptr, offset TTcl_Size, buffer uintptr, maxBytes TTcl_Size) (r TTcl_Size) { bp := tls.Alloc(48) defer tls.Free(48) /* Maximum # of bytes to store at buffer. */ var _objPtr, cmdInfoPtr, command, interp, p, string1, v2 uintptr var charOffset, count, extraBytes, numChars, v1 TTcl_Size var code int32 var savedState TTcl_InterpState var v3 int64 var _ /* ch at bp+8 */ TTcl_UniChar var _ /* length at bp+0 */ TTcl_Size _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = _objPtr, charOffset, cmdInfoPtr, code, command, count, extraBytes, interp, numChars, p, savedState, string1, v1, v2, v3 cmdInfoPtr = clientData interp = (*TCommandInfo)(unsafe.Pointer(cmdInfoPtr)).Finterp /* * We must also protect the interpreter and the command from being deleted * too soon. */ libtcl9_0.XTcl_Preserve(tls, clientData) libtcl9_0.XTcl_Preserve(tls, interp) /* * Compute the proper byte offset in the case where the last chunk split a * character. */ if offset == (*TCommandInfo)(unsafe.Pointer(cmdInfoPtr)).FbyteOffset { charOffset = (*TCommandInfo)(unsafe.Pointer(cmdInfoPtr)).FcharOffset extraBytes = libc.Int64FromUint64(libc.Xstrlen(tls, cmdInfoPtr+32)) if extraBytes > 0 { libc.Xstrcpy(tls, buffer, cmdInfoPtr+32) maxBytes -= extraBytes buffer += uintptr(extraBytes) } } else { (*TCommandInfo)(unsafe.Pointer(cmdInfoPtr)).FbyteOffset = 0 (*TCommandInfo)(unsafe.Pointer(cmdInfoPtr)).FcharOffset = 0 extraBytes = 0 charOffset = 0 } /* * First, generate a command by taking the command string and appending * the offset and maximum # of bytes. */ command = libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+16483, libc.VaList(bp+24, cmdInfoPtr+36, charOffset, maxBytes)) (*TTcl_Obj)(unsafe.Pointer(command)).FrefCount++ /* * Execute the command. Be sure to restore the state of the interpreter * after executing the command. */ savedState = libtcl9_0.XTcl_SaveInterpState(tls, interp, TCL_OK) code = libtcl9_0.XTcl_EvalObjEx(tls, interp, command, int32(TCL_EVAL_GLOBAL)) _objPtr = command v2 = _objPtr v1 = *(*TTcl_Size)(unsafe.Pointer(v2)) *(*TTcl_Size)(unsafe.Pointer(v2))-- if v1 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr) } if code == TCL_OK { /* * TODO: This assumes that bytes are characters; that's not true! */ string1 = libtcl9_0.XTcl_GetStringFromObj(tls, libtcl9_0.XTcl_GetObjResult(tls, interp), bp) if *(*TTcl_Size)(unsafe.Pointer(bp)) > maxBytes { v3 = maxBytes } else { v3 = *(*TTcl_Size)(unsafe.Pointer(bp)) } count = v3 libc.Xmemcpy(tls, buffer, string1, libc.Uint64FromInt64(count)) *(*uint8)(unsafe.Pointer(buffer + uintptr(count))) = uint8('\000') /* * Update the partial character information for the next retrieval if * the command has not been deleted. */ if (*TCommandInfo)(unsafe.Pointer(cmdInfoPtr)).Finterp != libc.UintptrFromInt32(0) { if *(*TTcl_Size)(unsafe.Pointer(bp)) <= maxBytes { *(*TTcl_Size)(unsafe.Pointer(cmdInfoPtr + 16)) += libtcl9_0.XTcl_NumUtfChars(tls, string1, int64(-libc.Int32FromInt32(1))) *(*uint8)(unsafe.Pointer(cmdInfoPtr + 32)) = uint8('\000') } else { *(*TTcl_UniChar)(unsafe.Pointer(bp + 8)) = 0 p = string1 string1 += uintptr(count) numChars = 0 for p < string1 { p += uintptr(libtcl9_0.XTcl_UtfToUniChar(tls, p, bp+8)) numChars++ } *(*TTcl_Size)(unsafe.Pointer(cmdInfoPtr + 16)) += numChars *(*TTcl_Size)(unsafe.Pointer(bp)) = int64(p) - int64(string1) if *(*TTcl_Size)(unsafe.Pointer(bp)) > 0 { libc.Xstrncpy(tls, cmdInfoPtr+32, string1, libc.Uint64FromInt64(*(*TTcl_Size)(unsafe.Pointer(bp)))) } *(*uint8)(unsafe.Pointer(cmdInfoPtr + 32 + uintptr(*(*TTcl_Size)(unsafe.Pointer(bp))))) = uint8('\000') } *(*TTcl_Size)(unsafe.Pointer(cmdInfoPtr + 24)) += count + extraBytes } count += extraBytes } else { /* * Something went wrong. Log errors as background errors, and silently * drop everything else. */ if code == int32(TCL_ERROR) { libtcl9_0.XTcl_AppendObjToErrorInfo(tls, interp, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+16494, int64(-int32(1)))) libtcl9_0.XTcl_BackgroundException(tls, interp, code) } count = int64(-libc.Int32FromInt32(1)) } libtcl9_0.XTcl_RestoreInterpState(tls, interp, savedState) libtcl9_0.XTcl_Release(tls, clientData) libtcl9_0.XTcl_Release(tls, interp) return count } /* *---------------------------------------------------------------------- * * TkSelDefaultSelection -- * * This function is called to generate selection information for a few * standard targets such as TIMESTAMP and TARGETS. It is invoked only if * no handler has been declared by the application. * * Results: * If "target" is a standard target understood by this function, the * selection is converted to that form and stored as a character string * in buffer. The type of the selection (e.g. STRING or ATOM) is stored * in *typePtr, and the return value is a count of the # of non-NULL * bytes at buffer. If the target wasn't understood, or if there isn't * enough space at buffer to hold the entire selection (no INCR-mode * transfers for this stuff!), then TCL_INDEX_NONE is returned. * * Side effects: * None. * *---------------------------------------------------------------------- */ func XTkSelDefaultSelection(tls *libc.TLS, infoPtr uintptr, target TAtom, buffer uintptr, maxBytes TTcl_Size, typePtr uintptr) (r TTcl_Size) { bp := tls.Alloc(240) defer tls.Free(240) /* Store here the type of the selection, for * use in converting to proper X format. */ var atomString, dispPtr, name1, selPtr, winPtr uintptr var length, length1, length2 TTcl_Size var name TTk_Uid var _ /* ds at bp+0 */ TTcl_DString _, _, _, _, _, _, _, _, _ = atomString, dispPtr, length, length1, length2, name, name1, selPtr, winPtr winPtr = (*TTkSelectionInfo)(unsafe.Pointer(infoPtr)).Fowner dispPtr = (*TTkWindow)(unsafe.Pointer(winPtr)).FdispPtr if target == (*TTkDisplay)(unsafe.Pointer(dispPtr)).FtimestampAtom { if maxBytes < int64(20) { return int64(-libc.Int32FromInt32(1)) } libc.X__builtin_snprintf(tls, buffer, libc.Uint64FromInt64(maxBytes), __ccgo_ts+6567, libc.VaList(bp+232, uint32((*TTkSelectionInfo)(unsafe.Pointer(infoPtr)).Ftime))) *(*TAtom)(unsafe.Pointer(typePtr)) = libc.Uint64FromInt32(19) return libc.Int64FromUint64(libc.Xstrlen(tls, buffer)) } if target == (*TTkDisplay)(unsafe.Pointer(dispPtr)).FtargetsAtom { if maxBytes < int64(50) { return int64(-libc.Int32FromInt32(1)) } libtcl9_0.XTcl_DStringInit(tls, bp) libtcl9_0.XTcl_DStringAppend(tls, bp, __ccgo_ts+16528, int64(-libc.Int32FromInt32(1))) selPtr = (*TTkWindow)(unsafe.Pointer(winPtr)).FselHandlerList for { if !(selPtr != libc.UintptrFromInt32(0)) { break } if (*TTkSelHandler)(unsafe.Pointer(selPtr)).Fselection == (*TTkSelectionInfo)(unsafe.Pointer(infoPtr)).Fselection && (*TTkSelHandler)(unsafe.Pointer(selPtr)).Ftarget != (*TTkDisplay)(unsafe.Pointer(dispPtr)).FapplicationAtom && (*TTkSelHandler)(unsafe.Pointer(selPtr)).Ftarget != (*TTkDisplay)(unsafe.Pointer(dispPtr)).FwindowAtom { atomString = XTk_GetAtomName(tls, winPtr, (*TTkSelHandler)(unsafe.Pointer(selPtr)).Ftarget) libtcl9_0.XTcl_DStringAppendElement(tls, bp, atomString) } goto _1 _1: ; selPtr = (*TTkSelHandler)(unsafe.Pointer(selPtr)).FnextPtr } length = (*TTcl_DString)(unsafe.Pointer(bp)).Flength if length >= maxBytes { libtcl9_0.XTcl_DStringFree(tls, bp) return int64(-libc.Int32FromInt32(1)) } libc.Xmemcpy(tls, buffer, (*TTcl_DString)(unsafe.Pointer(bp)).Fstring1, libc.Uint64FromInt64(length+int64(1))) libtcl9_0.XTcl_DStringFree(tls, bp) *(*TAtom)(unsafe.Pointer(typePtr)) = libc.Uint64FromInt32(4) return length } if target == (*TTkDisplay)(unsafe.Pointer(dispPtr)).FapplicationAtom { name = (*TTkWindow1)(unsafe.Pointer((*TTkMainInfo)(unsafe.Pointer((*TTkWindow)(unsafe.Pointer(winPtr)).FmainPtr)).FwinPtr)).FnameUid length1 = libc.Int64FromUint64(libc.Xstrlen(tls, name)) if maxBytes <= length1 { return int64(-libc.Int32FromInt32(1)) } libc.Xstrcpy(tls, buffer, name) *(*TAtom)(unsafe.Pointer(typePtr)) = libc.Uint64FromInt32(31) return length1 } if target == (*TTkDisplay)(unsafe.Pointer(dispPtr)).FwindowAtom { name1 = (*TTkWindow)(unsafe.Pointer(winPtr)).FpathName length2 = libc.Int64FromUint64(libc.Xstrlen(tls, name1)) if maxBytes <= length2 { return int64(-libc.Int32FromInt32(1)) } libc.Xstrcpy(tls, buffer, name1) *(*TAtom)(unsafe.Pointer(typePtr)) = libc.Uint64FromInt32(31) return length2 } return int64(-libc.Int32FromInt32(1)) } /* *---------------------------------------------------------------------- * * LostSelection -- * * This function is invoked when a window has lost ownership of the * selection and the ownership was claimed with the command "selection * own". * * Results: * None. * * Side effects: * A Tcl script is executed; it can do almost anything. * *---------------------------------------------------------------------- */ func _LostSelection(tls *libc.TLS, clientData uintptr) { /* Pointer to LostCommand structure. */ var _objPtr, interp, lostPtr, v2 uintptr var code int32 var savedState TTcl_InterpState var v1 TTcl_Size _, _, _, _, _, _, _ = _objPtr, code, interp, lostPtr, savedState, v1, v2 lostPtr = clientData interp = (*TLostCommand)(unsafe.Pointer(lostPtr)).Finterp libtcl9_0.XTcl_Preserve(tls, interp) /* * Execute the command. Save the interpreter's result, if any, and restore * it after executing the command. */ savedState = libtcl9_0.XTcl_SaveInterpState(tls, interp, TCL_OK) libtcl9_0.XTcl_ResetResult(tls, interp) code = libtcl9_0.XTcl_EvalObjEx(tls, interp, (*TLostCommand)(unsafe.Pointer(lostPtr)).FcmdObj, int32(TCL_EVAL_GLOBAL)) if code != TCL_OK { libtcl9_0.XTcl_BackgroundException(tls, interp, code) } libtcl9_0.XTcl_RestoreInterpState(tls, interp, savedState) /* * Free the storage for the command, since we're done with it now. */ _objPtr = (*TLostCommand)(unsafe.Pointer(lostPtr)).FcmdObj v2 = _objPtr v1 = *(*TTcl_Size)(unsafe.Pointer(v2)) *(*TTcl_Size)(unsafe.Pointer(v2))-- if v1 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr) } libtcl9_0.XTcl_Free(tls, lostPtr) libtcl9_0.XTcl_Release(tls, interp) } /* * Local Variables: * mode: c * c-basic-offset: 4 * fill-column: 78 * End: */ /* * The following structure is used to cache widget option specs matching an * element's required options defined by Tk_ElementOptionSpecs. It also holds * information behind Tk_StyledElement opaque tokens. */ type TStyledWidgetSpec = struct { FelementPtr uintptr FoptionTable TTk_OptionTable FoptionsPtr uintptr } /* * Elements are declared using static templates. But static information must * be completed by dynamic information only accessible at runtime. For each * registered element, an instance of the following structure is stored in * each style engine and used to cache information about the widget types * (identified by their optionTable) that use the given element. */ type TStyledElement = struct { FspecPtr uintptr FnbWidgetSpecs int32 FwidgetSpecs uintptr } /* * The following structure holds information behind Tk_StyleEngine opaque * tokens. */ type TStyleEngine = struct { Fname uintptr Felements uintptr FparentPtr uintptr } /* * Styles are instances of style engines. The following structure holds * information behind Tk_Style opaque tokens. */ type TStyle = struct { Fname uintptr FenginePtr uintptr FclientData uintptr } /* * Each registered element uses an instance of the following structure. */ type TElement1 = struct { Fname uintptr Fid int32 FgenericId int32 Fcreated int32 } /* * Thread-local data. */ type TThreadSpecificData8 = struct { FnbInit Tsize_t FengineTable TTcl_HashTable FdefaultEnginePtr uintptr FstyleTable TTcl_HashTable FnbElements TTcl_Size FelementTable TTcl_HashTable Felements uintptr } var _dataKey8 TTcl_ThreadDataKey /* * The following structure defines the implementation of the "style" Tcl * object, used for drawing. The internalRep.twoPtrValue.ptr1 field of each * style object points to the Style structure for the stylefont, or NULL. */ var _styleObjType = TTkObjType{ FobjType: TTcl_ObjType{ Fname: __ccgo_ts + 16580, }, } func init() { p := unsafe.Pointer(&_styleObjType) *(*uintptr)(unsafe.Add(p, 8)) = __ccgo_fp(_FreeStyleObjProc) *(*uintptr)(unsafe.Add(p, 16)) = __ccgo_fp(_DupStyleObjProc) } /* *--------------------------------------------------------------------------- * * TkStylePkgInit -- * * This function is called when an application is created. It initializes * all the structures that are used by the style package on a per * application basis. * * Results: * Stores data in thread-local storage. * * Side effects: * Memory allocated. * *--------------------------------------------------------------------------- */ func XTkStylePkgInit(tls *libc.TLS, dummy183 uintptr) { /* The application being created. */ var tsdPtr uintptr _ = tsdPtr tsdPtr = libtcl9_0.XTcl_GetThreadData(tls, uintptr(unsafe.Pointer(&_dataKey8)), int64(344)) if (*TThreadSpecificData8)(unsafe.Pointer(tsdPtr)).FnbInit != uint64(0) { return } /* * Initialize tables. */ libtcl9_0.XTcl_InitHashTable(tls, tsdPtr+8, TCL_STRING_KEYS) libtcl9_0.XTcl_InitHashTable(tls, tsdPtr+120, TCL_STRING_KEYS) libtcl9_0.XTcl_InitHashTable(tls, tsdPtr+232, TCL_STRING_KEYS) (*TThreadSpecificData8)(unsafe.Pointer(tsdPtr)).FnbElements = 0 (*TThreadSpecificData8)(unsafe.Pointer(tsdPtr)).Felements = libc.UintptrFromInt32(0) /* * Create the default system engine. */ (*TThreadSpecificData8)(unsafe.Pointer(tsdPtr)).FdefaultEnginePtr = XTk_RegisterStyleEngine(tls, libc.UintptrFromInt32(0), libc.UintptrFromInt32(0)) /* * Create the default system style. */ XTk_CreateStyle(tls, libc.UintptrFromInt32(0), (*TThreadSpecificData8)(unsafe.Pointer(tsdPtr)).FdefaultEnginePtr, libc.UintptrFromInt32(0)) (*TThreadSpecificData8)(unsafe.Pointer(tsdPtr)).FnbInit++ } /* *--------------------------------------------------------------------------- * * TkStylePkgFree -- * * This function is called when an application is deleted. It deletes all * the structures that were used by the style package for this * application. * * Results: * None. * * Side effects: * Memory freed. * *--------------------------------------------------------------------------- */ func XTkStylePkgFree(tls *libc.TLS, dummy238 uintptr) { bp := tls.Alloc(32) defer tls.Free(32) /* The application being deleted. */ var enginePtr, entryPtr, tsdPtr uintptr var i TTcl_Size var _ /* search at bp+0 */ TTcl_HashSearch _, _, _, _ = enginePtr, entryPtr, i, tsdPtr tsdPtr = libtcl9_0.XTcl_GetThreadData(tls, uintptr(unsafe.Pointer(&_dataKey8)), int64(344)) (*TThreadSpecificData8)(unsafe.Pointer(tsdPtr)).FnbInit-- if (*TThreadSpecificData8)(unsafe.Pointer(tsdPtr)).FnbInit != uint64(0) { return } /* * Free styles. */ entryPtr = libtcl9_0.XTcl_FirstHashEntry(tls, tsdPtr+120, bp) for entryPtr != libc.UintptrFromInt32(0) { libtcl9_0.XTcl_Free(tls, (*TTcl_HashEntry)(unsafe.Pointer(entryPtr)).FclientData) entryPtr = libtcl9_0.XTcl_NextHashEntry(tls, bp) } libtcl9_0.XTcl_DeleteHashTable(tls, tsdPtr+120) /* * Free engines. */ entryPtr = libtcl9_0.XTcl_FirstHashEntry(tls, tsdPtr+8, bp) for entryPtr != libc.UintptrFromInt32(0) { enginePtr = (*TTcl_HashEntry)(unsafe.Pointer(entryPtr)).FclientData _FreeStyleEngine(tls, enginePtr) libtcl9_0.XTcl_Free(tls, enginePtr) entryPtr = libtcl9_0.XTcl_NextHashEntry(tls, bp) } libtcl9_0.XTcl_DeleteHashTable(tls, tsdPtr+8) /* * Free elements. */ i = 0 for { if !(i < (*TThreadSpecificData8)(unsafe.Pointer(tsdPtr)).FnbElements) { break } _FreeElement(tls, (*TThreadSpecificData8)(unsafe.Pointer(tsdPtr)).Felements+uintptr(i)*24) goto _1 _1: ; i++ } libtcl9_0.XTcl_DeleteHashTable(tls, tsdPtr+232) libtcl9_0.XTcl_Free(tls, (*TThreadSpecificData8)(unsafe.Pointer(tsdPtr)).Felements) } /* *--------------------------------------------------------------------------- * * Tk_RegisterStyleEngine -- * * This function is called to register a new style engine. Style engines * are stored in thread-local space. * * Results: * The newly allocated engine, or NULL if an engine with the same name * exists. * * Side effects: * Memory allocated. Data added to thread-local table. * *--------------------------------------------------------------------------- */ func XTk_RegisterStyleEngine(tls *libc.TLS, name uintptr, parent TTk_StyleEngine) (r TTk_StyleEngine) { bp := tls.Alloc(16) defer tls.Free(16) /* The engine's parent. NULL means the default * system engine. */ var enginePtr, entryPtr, tsdPtr, v1, v2 uintptr var _ /* newEntry at bp+0 */ int32 _, _, _, _, _ = enginePtr, entryPtr, tsdPtr, v1, v2 tsdPtr = libtcl9_0.XTcl_GetThreadData(tls, uintptr(unsafe.Pointer(&_dataKey8)), int64(344)) /* * Attempt to create a new entry in the engine table. */ if name != libc.UintptrFromInt32(0) { v1 = name } else { v1 = __ccgo_ts + 195 } entryPtr = (*(*func(*libc.TLS, uintptr, uintptr, uintptr) uintptr)(unsafe.Pointer(&struct{ uintptr }{(*TTcl_HashTable)(unsafe.Pointer(tsdPtr + 8)).FcreateProc})))(tls, tsdPtr+8, v1, bp) if !(*(*int32)(unsafe.Pointer(bp)) != 0) { /* * An engine was already registered by that name. */ return libc.UintptrFromInt32(0) } /* * Allocate and intitialize a new engine. */ enginePtr = libtcl9_0.XTcl_Alloc(tls, uint64(24)) if (*TTcl_HashTable)(unsafe.Pointer(tsdPtr+8)).FkeyType == int32(TCL_ONE_WORD_KEYS) || (*TTcl_HashTable)(unsafe.Pointer(tsdPtr+8)).FkeyType == -int32(1) { v2 = *(*uintptr)(unsafe.Pointer(entryPtr + 32)) } else { v2 = entryPtr + 32 } _InitStyleEngine(tls, enginePtr, v2, parent) (*TTcl_HashEntry)(unsafe.Pointer(entryPtr)).FclientData = enginePtr return enginePtr } /* *--------------------------------------------------------------------------- * * InitStyleEngine -- * * Initialize a newly allocated style engine. * * Results: * None. * * Side effects: * Memory allocated. * *--------------------------------------------------------------------------- */ func _InitStyleEngine(tls *libc.TLS, enginePtr uintptr, name uintptr, parentPtr uintptr) { /* The engine's parent. NULL means the default * system engine. */ var elementId TTcl_Size var tsdPtr uintptr _, _ = elementId, tsdPtr tsdPtr = libtcl9_0.XTcl_GetThreadData(tls, uintptr(unsafe.Pointer(&_dataKey8)), int64(344)) if name == libc.UintptrFromInt32(0) || libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(name))) == int32('\000') { /* * This is the default style engine. */ (*TStyleEngine)(unsafe.Pointer(enginePtr)).FparentPtr = libc.UintptrFromInt32(0) } else { if parentPtr == libc.UintptrFromInt32(0) { /* * The default style engine is the parent. */ (*TStyleEngine)(unsafe.Pointer(enginePtr)).FparentPtr = (*TThreadSpecificData8)(unsafe.Pointer(tsdPtr)).FdefaultEnginePtr } else { (*TStyleEngine)(unsafe.Pointer(enginePtr)).FparentPtr = parentPtr } } /* * Allocate and initialize elements array. */ if (*TThreadSpecificData8)(unsafe.Pointer(tsdPtr)).FnbElements > 0 { (*TStyleEngine)(unsafe.Pointer(enginePtr)).Felements = libtcl9_0.XTcl_Alloc(tls, uint64(24)*libc.Uint64FromInt64((*TThreadSpecificData8)(unsafe.Pointer(tsdPtr)).FnbElements)) elementId = 0 for { if !(elementId < (*TThreadSpecificData8)(unsafe.Pointer(tsdPtr)).FnbElements) { break } _InitStyledElement(tls, (*TStyleEngine)(unsafe.Pointer(enginePtr)).Felements+uintptr(elementId)*24) goto _1 _1: ; elementId++ } } else { (*TStyleEngine)(unsafe.Pointer(enginePtr)).Felements = libc.UintptrFromInt32(0) } } /* *--------------------------------------------------------------------------- * * FreeStyleEngine -- * * Free an engine and its associated data. * * Results: * None * * Side effects: * Memory freed. * *--------------------------------------------------------------------------- */ func _FreeStyleEngine(tls *libc.TLS, enginePtr uintptr) { /* The style engine to free. */ var elementId TTcl_Size var tsdPtr uintptr _, _ = elementId, tsdPtr tsdPtr = libtcl9_0.XTcl_GetThreadData(tls, uintptr(unsafe.Pointer(&_dataKey8)), int64(344)) /* * Free allocated elements. */ elementId = 0 for { if !(elementId < (*TThreadSpecificData8)(unsafe.Pointer(tsdPtr)).FnbElements) { break } _FreeStyledElement(tls, (*TStyleEngine)(unsafe.Pointer(enginePtr)).Felements+uintptr(elementId)*24) goto _1 _1: ; elementId++ } libtcl9_0.XTcl_Free(tls, (*TStyleEngine)(unsafe.Pointer(enginePtr)).Felements) } /* *--------------------------------------------------------------------------- * * Tk_GetStyleEngine -- * * Retrieve a registered style engine by its name. * * Results: * A pointer to the style engine, or NULL if none found. * * Side effects: * None. * *--------------------------------------------------------------------------- */ func XTk_GetStyleEngine(tls *libc.TLS, name uintptr) (r TTk_StyleEngine) { /* Name of the engine to retrieve. NULL or * empty means the default system engine. */ var entryPtr, tsdPtr, v1 uintptr _, _, _ = entryPtr, tsdPtr, v1 tsdPtr = libtcl9_0.XTcl_GetThreadData(tls, uintptr(unsafe.Pointer(&_dataKey8)), int64(344)) if name == libc.UintptrFromInt32(0) { return (*TThreadSpecificData8)(unsafe.Pointer(tsdPtr)).FdefaultEnginePtr } if name != libc.UintptrFromInt32(0) { v1 = name } else { v1 = __ccgo_ts + 195 } entryPtr = (*(*func(*libc.TLS, uintptr, uintptr) uintptr)(unsafe.Pointer(&struct{ uintptr }{(*TTcl_HashTable)(unsafe.Pointer(tsdPtr + 8)).FfindProc})))(tls, tsdPtr+8, v1) if !(entryPtr != 0) { return libc.UintptrFromInt32(0) } return (*TTcl_HashEntry)(unsafe.Pointer(entryPtr)).FclientData } /* *--------------------------------------------------------------------------- * * InitElement -- * * Initialize a newly allocated element. * * Results: * None. * * Side effects: * None. * *--------------------------------------------------------------------------- */ func _InitElement(tls *libc.TLS, elementPtr uintptr, name uintptr, id int32, genericId int32, created int32) { /* Boolean, whether the element was created * explicitly (was registered) or implicitly * (by a derived element). */ var v1 int32 _ = v1 (*TElement1)(unsafe.Pointer(elementPtr)).Fname = name (*TElement1)(unsafe.Pointer(elementPtr)).Fid = id (*TElement1)(unsafe.Pointer(elementPtr)).FgenericId = genericId if created != 0 { v1 = int32(1) } else { v1 = 0 } (*TElement1)(unsafe.Pointer(elementPtr)).Fcreated = v1 } /* *--------------------------------------------------------------------------- * * FreeElement -- * * Free an element and its associated data. * * Results: * None. * * Side effects: * Memory freed. * *--------------------------------------------------------------------------- */ func _FreeElement(tls *libc.TLS, dummy526 uintptr) { /* The element to free. */ /* Nothing to do. */ } /* *--------------------------------------------------------------------------- * * InitStyledElement -- * * Initialize a newly allocated styled element. * * Results: * None. * * Side effects: * None. * *--------------------------------------------------------------------------- */ func _InitStyledElement(tls *libc.TLS, elementPtr uintptr) { /* Points to an uninitialized element.*/ libc.Xmemset(tls, elementPtr, 0, uint64(24)) } /* *--------------------------------------------------------------------------- * * FreeStyledElement -- * * Free a styled element and its associated data. * * Results: * None. * * Side effects: * Memory freed. * *--------------------------------------------------------------------------- */ func _FreeStyledElement(tls *libc.TLS, elementPtr uintptr) { /* The styled element to free. */ var i int32 _ = i /* * Free allocated widget specs. */ i = 0 for { if !(i < (*TStyledElement)(unsafe.Pointer(elementPtr)).FnbWidgetSpecs) { break } _FreeWidgetSpec(tls, (*TStyledElement)(unsafe.Pointer(elementPtr)).FwidgetSpecs+uintptr(i)*24) goto _1 _1: ; i++ } libtcl9_0.XTcl_Free(tls, (*TStyledElement)(unsafe.Pointer(elementPtr)).FwidgetSpecs) } /* *--------------------------------------------------------------------------- * * CreateElement -- * * Find an existing or create a new element. * * Results: * The unique ID for the created or found element. * * Side effects: * Memory allocated. * *--------------------------------------------------------------------------- */ func _CreateElement(tls *libc.TLS, name uintptr, create int32) (r int32) { bp := tls.Alloc(32) defer tls.Free(32) /* Boolean, whether the element is being * created explicitly (being registered) or * implicitly (by a derived element). */ var dot, engineEntryPtr, enginePtr, entryPtr, tsdPtr, v2, v3 uintptr var elementId, genericId int32 var v1 TTcl_Size var _ /* newEntry at bp+24 */ int32 var _ /* search at bp+0 */ TTcl_HashSearch _, _, _, _, _, _, _, _, _, _ = dot, elementId, engineEntryPtr, enginePtr, entryPtr, genericId, tsdPtr, v1, v2, v3 tsdPtr = libtcl9_0.XTcl_GetThreadData(tls, uintptr(unsafe.Pointer(&_dataKey8)), int64(344)) genericId = -int32(1) /* * Find or create the element. */ entryPtr = (*(*func(*libc.TLS, uintptr, uintptr, uintptr) uintptr)(unsafe.Pointer(&struct{ uintptr }{(*TTcl_HashTable)(unsafe.Pointer(tsdPtr + 232)).FcreateProc})))(tls, tsdPtr+232, name, bp+24) if !(*(*int32)(unsafe.Pointer(bp + 24)) != 0) { elementId = int32(int64((*TTcl_HashEntry)(unsafe.Pointer(entryPtr)).FclientData)) if create != 0 { (*(*TElement1)(unsafe.Pointer((*TThreadSpecificData8)(unsafe.Pointer(tsdPtr)).Felements + uintptr(elementId)*24))).Fcreated = int32(1) } return elementId } /* * The element didn't exist. If it's a derived element, find or create its * generic element ID. */ dot = libc.Xstrchr(tls, name, int32('.')) if dot != 0 { genericId = _CreateElement(tls, dot+uintptr(1), 0) } v2 = tsdPtr + 224 v1 = *(*TTcl_Size)(unsafe.Pointer(v2)) *(*TTcl_Size)(unsafe.Pointer(v2))++ elementId = int32(v1) (*TTcl_HashEntry)(unsafe.Pointer(entryPtr)).FclientData = uintptr(int64(elementId)) /* * Reallocate element table. */ (*TThreadSpecificData8)(unsafe.Pointer(tsdPtr)).Felements = libtcl9_0.XTcl_Realloc(tls, (*TThreadSpecificData8)(unsafe.Pointer(tsdPtr)).Felements, uint64(24)*libc.Uint64FromInt64((*TThreadSpecificData8)(unsafe.Pointer(tsdPtr)).FnbElements)) if (*TTcl_HashTable)(unsafe.Pointer(tsdPtr+232)).FkeyType == int32(TCL_ONE_WORD_KEYS) || (*TTcl_HashTable)(unsafe.Pointer(tsdPtr+232)).FkeyType == -int32(1) { v3 = *(*uintptr)(unsafe.Pointer(entryPtr + 32)) } else { v3 = entryPtr + 32 } _InitElement(tls, (*TThreadSpecificData8)(unsafe.Pointer(tsdPtr)).Felements+uintptr(elementId)*24, v3, elementId, genericId, create) /* * Reallocate style engines' element table. */ engineEntryPtr = libtcl9_0.XTcl_FirstHashEntry(tls, tsdPtr+8, bp) for engineEntryPtr != libc.UintptrFromInt32(0) { enginePtr = (*TTcl_HashEntry)(unsafe.Pointer(engineEntryPtr)).FclientData (*TStyleEngine)(unsafe.Pointer(enginePtr)).Felements = libtcl9_0.XTcl_Realloc(tls, (*TStyleEngine)(unsafe.Pointer(enginePtr)).Felements, uint64(24)*libc.Uint64FromInt64((*TThreadSpecificData8)(unsafe.Pointer(tsdPtr)).FnbElements)) _InitStyledElement(tls, (*TStyleEngine)(unsafe.Pointer(enginePtr)).Felements+uintptr(elementId)*24) engineEntryPtr = libtcl9_0.XTcl_NextHashEntry(tls, bp) } return elementId } /* *--------------------------------------------------------------------------- * * Tk_GetElementId -- * * Find an existing element. * * Results: * The unique ID for the found element, or -1 if not found. * * Side effects: * Generic elements may be created. * *--------------------------------------------------------------------------- */ func XTk_GetElementId(tls *libc.TLS, name uintptr) (r int32) { /* Name of the element. */ var dot, entryPtr, tsdPtr uintptr var genericId int32 _, _, _, _ = dot, entryPtr, genericId, tsdPtr tsdPtr = libtcl9_0.XTcl_GetThreadData(tls, uintptr(unsafe.Pointer(&_dataKey8)), int64(344)) genericId = -int32(1) /* * Find the element Id. */ entryPtr = (*(*func(*libc.TLS, uintptr, uintptr) uintptr)(unsafe.Pointer(&struct{ uintptr }{(*TTcl_HashTable)(unsafe.Pointer(tsdPtr + 232)).FfindProc})))(tls, tsdPtr+232, name) if entryPtr != 0 { return int32(int64((*TTcl_HashEntry)(unsafe.Pointer(entryPtr)).FclientData)) } /* * Element not found. If the given name was derived, then first search for * the generic element. If found, create the new derived element. */ dot = libc.Xstrchr(tls, name, int32('.')) if !(dot != 0) { return -int32(1) } genericId = XTk_GetElementId(tls, dot+uintptr(1)) if genericId == -int32(1) { return -int32(1) } if !((*(*TElement1)(unsafe.Pointer((*TThreadSpecificData8)(unsafe.Pointer(tsdPtr)).Felements + uintptr(genericId)*24))).Fcreated != 0) { /* * The generic element was created implicitly and thus has no real * existence. */ return -int32(1) } else { /* * The generic element was created explicitly. Create the derived * element. */ return _CreateElement(tls, name, int32(1)) } return r } /* *--------------------------------------------------------------------------- * * Tk_RegisterStyledElement -- * * Register an implementation of a new or existing element for the given * style engine. * * Results: * The unique ID for the created or found element. * * Side effects: * Elements may be created. Memory allocated. * *--------------------------------------------------------------------------- */ func XTk_RegisterStyledElement(tls *libc.TLS, engine TTk_StyleEngine, templatePtr uintptr) (r int32) { /* Static template information about the * element. */ var dstOptions, elementPtr, specPtr, srcOptions uintptr var elementId, nbOptions int32 _, _, _, _, _, _ = dstOptions, elementId, elementPtr, nbOptions, specPtr, srcOptions if (*TTk_ElementSpec)(unsafe.Pointer(templatePtr)).Fversion != int32(TK_STYLE_VERSION_1) { /* * Version mismatch. Do nothing. */ return -int32(1) } if engine == libc.UintptrFromInt32(0) { engine = XTk_GetStyleEngine(tls, libc.UintptrFromInt32(0)) } /* * Register the element, allocating storage in the various engines if * necessary. */ elementId = _CreateElement(tls, (*TTk_ElementSpec)(unsafe.Pointer(templatePtr)).Fname, int32(1)) /* * Initialize the styled element. */ elementPtr = (*TStyleEngine)(unsafe.Pointer(engine)).Felements + uintptr(elementId)*24 specPtr = libtcl9_0.XTcl_Alloc(tls, uint64(56)) (*TTk_ElementSpec)(unsafe.Pointer(specPtr)).Fversion = (*TTk_ElementSpec)(unsafe.Pointer(templatePtr)).Fversion (*TTk_ElementSpec)(unsafe.Pointer(specPtr)).Fname = libtcl9_0.XTcl_Alloc(tls, libc.Xstrlen(tls, (*TTk_ElementSpec)(unsafe.Pointer(templatePtr)).Fname)+uint64(1)) libc.Xstrcpy(tls, (*TTk_ElementSpec)(unsafe.Pointer(specPtr)).Fname, (*TTk_ElementSpec)(unsafe.Pointer(templatePtr)).Fname) nbOptions = 0 nbOptions = 0 srcOptions = (*TTk_ElementSpec)(unsafe.Pointer(templatePtr)).Foptions for { if !((*TTk_ElementOptionSpec)(unsafe.Pointer(srcOptions)).Fname != libc.UintptrFromInt32(0)) { break } /* empty body */ goto _1 _1: ; nbOptions++ srcOptions += 16 } (*TTk_ElementSpec)(unsafe.Pointer(specPtr)).Foptions = libtcl9_0.XTcl_Alloc(tls, uint64(16)*libc.Uint64FromInt32(nbOptions+libc.Int32FromInt32(1))) srcOptions = (*TTk_ElementSpec)(unsafe.Pointer(templatePtr)).Foptions dstOptions = (*TTk_ElementSpec)(unsafe.Pointer(specPtr)).Foptions for { if (*TTk_ElementOptionSpec)(unsafe.Pointer(srcOptions)).Fname == libc.UintptrFromInt32(0) { (*TTk_ElementOptionSpec)(unsafe.Pointer(dstOptions)).Fname = libc.UintptrFromInt32(0) break } (*TTk_ElementOptionSpec)(unsafe.Pointer(dstOptions)).Fname = libtcl9_0.XTcl_Alloc(tls, libc.Xstrlen(tls, (*TTk_ElementOptionSpec)(unsafe.Pointer(srcOptions)).Fname)+uint64(1)) libc.Xstrcpy(tls, (*TTk_ElementOptionSpec)(unsafe.Pointer(dstOptions)).Fname, (*TTk_ElementOptionSpec)(unsafe.Pointer(srcOptions)).Fname) (*TTk_ElementOptionSpec)(unsafe.Pointer(dstOptions)).Ftype1 = (*TTk_ElementOptionSpec)(unsafe.Pointer(srcOptions)).Ftype1 goto _2 _2: ; srcOptions += 16 dstOptions += 16 } (*TTk_ElementSpec)(unsafe.Pointer(specPtr)).FgetSize = (*TTk_ElementSpec)(unsafe.Pointer(templatePtr)).FgetSize (*TTk_ElementSpec)(unsafe.Pointer(specPtr)).FgetBox = (*TTk_ElementSpec)(unsafe.Pointer(templatePtr)).FgetBox (*TTk_ElementSpec)(unsafe.Pointer(specPtr)).FgetBorderWidth = (*TTk_ElementSpec)(unsafe.Pointer(templatePtr)).FgetBorderWidth (*TTk_ElementSpec)(unsafe.Pointer(specPtr)).Fdraw = (*TTk_ElementSpec)(unsafe.Pointer(templatePtr)).Fdraw (*TStyledElement)(unsafe.Pointer(elementPtr)).FspecPtr = specPtr (*TStyledElement)(unsafe.Pointer(elementPtr)).FnbWidgetSpecs = 0 (*TStyledElement)(unsafe.Pointer(elementPtr)).FwidgetSpecs = libc.UintptrFromInt32(0) return elementId } /* *--------------------------------------------------------------------------- * * GetStyledElement -- * * Get a registered implementation of an existing element for the given * style engine. * * Results: * The styled element descriptor, or NULL if not found. * * Side effects: * None. * *--------------------------------------------------------------------------- */ func _GetStyledElement(tls *libc.TLS, enginePtr uintptr, elementId TTcl_Size) (r uintptr) { /* Unique element ID */ var elementPtr, enginePtr2, tsdPtr uintptr _, _, _ = elementPtr, enginePtr2, tsdPtr tsdPtr = libtcl9_0.XTcl_GetThreadData(tls, uintptr(unsafe.Pointer(&_dataKey8)), int64(344)) if enginePtr == libc.UintptrFromInt32(0) { enginePtr = (*TThreadSpecificData8)(unsafe.Pointer(tsdPtr)).FdefaultEnginePtr } for elementId != int64(-libc.Int32FromInt32(1)) && elementId < (*TThreadSpecificData8)(unsafe.Pointer(tsdPtr)).FnbElements { /* * Look for an implemented element through the engine chain. */ enginePtr2 = enginePtr for cond := true; cond; cond = enginePtr2 != libc.UintptrFromInt32(0) { elementPtr = (*TStyleEngine)(unsafe.Pointer(enginePtr2)).Felements + uintptr(elementId)*24 if (*TStyledElement)(unsafe.Pointer(elementPtr)).FspecPtr != libc.UintptrFromInt32(0) { return elementPtr } enginePtr2 = (*TStyleEngine)(unsafe.Pointer(enginePtr2)).FparentPtr } /* * None found, try with the generic element. */ elementId = int64((*(*TElement1)(unsafe.Pointer((*TThreadSpecificData8)(unsafe.Pointer(tsdPtr)).Felements + uintptr(elementId)*24))).FgenericId) } /* * No matching element found. */ return libc.UintptrFromInt32(0) } /* *--------------------------------------------------------------------------- * * InitWidgetSpec -- * * Initialize a newly allocated widget spec. * * Results: * None. * * Side effects: * Memory allocated. * *--------------------------------------------------------------------------- */ func _InitWidgetSpec(tls *libc.TLS, widgetSpecPtr uintptr, elementPtr uintptr, optionTable TTk_OptionTable) { /* The widget's option table. */ var elementOptionPtr, widgetOptionPtr uintptr var i, nbOptions int32 _, _, _, _ = elementOptionPtr, i, nbOptions, widgetOptionPtr (*TStyledWidgetSpec)(unsafe.Pointer(widgetSpecPtr)).FelementPtr = elementPtr (*TStyledWidgetSpec)(unsafe.Pointer(widgetSpecPtr)).FoptionTable = optionTable /* * Count the number of options. */ nbOptions = 0 elementOptionPtr = (*TTk_ElementSpec1)(unsafe.Pointer((*TStyledElement)(unsafe.Pointer(elementPtr)).FspecPtr)).Foptions for { if !((*TTk_ElementOptionSpec)(unsafe.Pointer(elementOptionPtr)).Fname != libc.UintptrFromInt32(0)) { break } /* empty body */ goto _1 _1: ; nbOptions++ elementOptionPtr += 16 } /* * Build the widget option list. */ (*TStyledWidgetSpec)(unsafe.Pointer(widgetSpecPtr)).FoptionsPtr = libtcl9_0.XTcl_Alloc(tls, uint64(8)*libc.Uint64FromInt32(nbOptions)) i = 0 elementOptionPtr = (*TTk_ElementSpec1)(unsafe.Pointer((*TStyledElement)(unsafe.Pointer(elementPtr)).FspecPtr)).Foptions for { if !(i < nbOptions) { break } widgetOptionPtr = XTkGetOptionSpec(tls, (*TTk_ElementOptionSpec)(unsafe.Pointer(elementOptionPtr)).Fname, optionTable) /* * Check that the widget option type is compatible with one of the * element's required types. */ if (*TTk_ElementOptionSpec)(unsafe.Pointer(elementOptionPtr)).Ftype1 == int32(TK_OPTION_END) || (*TTk_ElementOptionSpec)(unsafe.Pointer(elementOptionPtr)).Ftype1 == (*TTk_OptionSpec)(unsafe.Pointer(widgetOptionPtr)).Ftype1 { *(*uintptr)(unsafe.Pointer((*TStyledWidgetSpec)(unsafe.Pointer(widgetSpecPtr)).FoptionsPtr + uintptr(i)*8)) = widgetOptionPtr } else { *(*uintptr)(unsafe.Pointer((*TStyledWidgetSpec)(unsafe.Pointer(widgetSpecPtr)).FoptionsPtr + uintptr(i)*8)) = libc.UintptrFromInt32(0) } goto _2 _2: ; i++ elementOptionPtr += 16 } } /* *--------------------------------------------------------------------------- * * FreeWidgetSpec -- * * Free a widget spec and its associated data. * * Results: * None * * Side effects: * Memory freed. * *--------------------------------------------------------------------------- */ func _FreeWidgetSpec(tls *libc.TLS, widgetSpecPtr uintptr) { /* The widget spec to free. */ libtcl9_0.XTcl_Free(tls, (*TStyledWidgetSpec)(unsafe.Pointer(widgetSpecPtr)).FoptionsPtr) } /* *--------------------------------------------------------------------------- * * GetWidgetSpec -- * * Return a new or existing widget spec for the given element and widget * type (identified by its option table). * * Results: * A pointer to the matching widget spec. * * Side effects: * Memory may be allocated. * *--------------------------------------------------------------------------- */ func _GetWidgetSpec(tls *libc.TLS, elementPtr uintptr, optionTable TTk_OptionTable) (r uintptr) { /* The widget's option table. */ var i, v2 int32 var widgetSpecPtr, v3 uintptr _, _, _, _ = i, widgetSpecPtr, v2, v3 /* * Try to find an existing widget spec. */ i = 0 for { if !(i < (*TStyledElement)(unsafe.Pointer(elementPtr)).FnbWidgetSpecs) { break } widgetSpecPtr = (*TStyledElement)(unsafe.Pointer(elementPtr)).FwidgetSpecs + uintptr(i)*24 if (*TStyledWidgetSpec)(unsafe.Pointer(widgetSpecPtr)).FoptionTable == optionTable { return widgetSpecPtr } goto _1 _1: ; i++ } /* * Create and initialize a new widget spec. */ v3 = elementPtr + 8 v2 = *(*int32)(unsafe.Pointer(v3)) *(*int32)(unsafe.Pointer(v3))++ i = v2 (*TStyledElement)(unsafe.Pointer(elementPtr)).FwidgetSpecs = libtcl9_0.XTcl_Realloc(tls, (*TStyledElement)(unsafe.Pointer(elementPtr)).FwidgetSpecs, uint64(24)*libc.Uint64FromInt32((*TStyledElement)(unsafe.Pointer(elementPtr)).FnbWidgetSpecs)) widgetSpecPtr = (*TStyledElement)(unsafe.Pointer(elementPtr)).FwidgetSpecs + uintptr(i)*24 _InitWidgetSpec(tls, widgetSpecPtr, elementPtr, optionTable) return widgetSpecPtr } /* *--------------------------------------------------------------------------- * * Tk_GetStyledElement -- * * This function returns a styled instance of the given element. * * Results: * None. * * Side effects: * Cached data may be allocated or updated. * *--------------------------------------------------------------------------- */ func XTk_GetStyledElement(tls *libc.TLS, style TTk_Style, elementId TTcl_Size, optionTable TTk_OptionTable) (r TTk_StyledElement) { /* Option table for the widget. */ var elementPtr, stylePtr, v1 uintptr _, _, _ = elementPtr, stylePtr, v1 stylePtr = style /* * Get an element implementation and call corresponding hook. */ if stylePtr != 0 { v1 = (*TStyle)(unsafe.Pointer(stylePtr)).FenginePtr } else { v1 = libc.UintptrFromInt32(0) } elementPtr = _GetStyledElement(tls, v1, elementId) if !(elementPtr != 0) { return libc.UintptrFromInt32(0) } return _GetWidgetSpec(tls, elementPtr, optionTable) } /* *--------------------------------------------------------------------------- * * Tk_GetElementSize -- * * This function computes the size of the given widget element according * to its style. * * Results: * None. * * Side effects: * Cached data may be allocated or updated. * *--------------------------------------------------------------------------- */ func XTk_GetElementSize(tls *libc.TLS, style TTk_Style, element TTk_StyledElement, recordPtr uintptr, tkwin TTk_Window, width int32, height int32, inner int32, widthPtr uintptr, heightPtr uintptr) { /* Returned size. */ var stylePtr, widgetSpecPtr uintptr _, _ = stylePtr, widgetSpecPtr stylePtr = style widgetSpecPtr = element (*(*func(*libc.TLS, uintptr, uintptr, uintptr, TTk_Window, int32, int32, int32, uintptr, uintptr))(unsafe.Pointer(&struct{ uintptr }{(*TTk_ElementSpec1)(unsafe.Pointer((*TStyledElement1)(unsafe.Pointer((*TStyledWidgetSpec)(unsafe.Pointer(widgetSpecPtr)).FelementPtr)).FspecPtr)).FgetSize})))(tls, (*TStyle)(unsafe.Pointer(stylePtr)).FclientData, recordPtr, (*TStyledWidgetSpec)(unsafe.Pointer(widgetSpecPtr)).FoptionsPtr, tkwin, width, height, inner, widthPtr, heightPtr) } /* *--------------------------------------------------------------------------- * * Tk_GetElementBox -- * * This function computes the bounding or inscribed box coordinates of * the given widget element according to its style and within the given * limits. * * Results: * None. * * Side effects: * Cached data may be allocated or updated. * *--------------------------------------------------------------------------- */ func XTk_GetElementBox(tls *libc.TLS, style TTk_Style, element TTk_StyledElement, recordPtr uintptr, tkwin TTk_Window, x int32, y int32, width int32, height int32, inner int32, xPtr uintptr, yPtr uintptr, widthPtr uintptr, heightPtr uintptr) { /* Returned size. */ var stylePtr, widgetSpecPtr uintptr _, _ = stylePtr, widgetSpecPtr stylePtr = style widgetSpecPtr = element (*(*func(*libc.TLS, uintptr, uintptr, uintptr, TTk_Window, int32, int32, int32, int32, int32, uintptr, uintptr, uintptr, uintptr))(unsafe.Pointer(&struct{ uintptr }{(*TTk_ElementSpec1)(unsafe.Pointer((*TStyledElement1)(unsafe.Pointer((*TStyledWidgetSpec)(unsafe.Pointer(widgetSpecPtr)).FelementPtr)).FspecPtr)).FgetBox})))(tls, (*TStyle)(unsafe.Pointer(stylePtr)).FclientData, recordPtr, (*TStyledWidgetSpec)(unsafe.Pointer(widgetSpecPtr)).FoptionsPtr, tkwin, x, y, width, height, inner, xPtr, yPtr, widthPtr, heightPtr) } /* *--------------------------------------------------------------------------- * * Tk_GetElementBorderWidth -- * * This function computes the border widthof the given widget element * according to its style and within the given limits. * * Results: * Border width in pixels. This value is uniform for all four sides. * * Side effects: * Cached data may be allocated or updated. * *--------------------------------------------------------------------------- */ func XTk_GetElementBorderWidth(tls *libc.TLS, style TTk_Style, element TTk_StyledElement, recordPtr uintptr, tkwin TTk_Window) (r int32) { /* The widget window. */ var stylePtr, widgetSpecPtr uintptr _, _ = stylePtr, widgetSpecPtr stylePtr = style widgetSpecPtr = element return (*(*func(*libc.TLS, uintptr, uintptr, uintptr, TTk_Window) int32)(unsafe.Pointer(&struct{ uintptr }{(*TTk_ElementSpec1)(unsafe.Pointer((*TStyledElement1)(unsafe.Pointer((*TStyledWidgetSpec)(unsafe.Pointer(widgetSpecPtr)).FelementPtr)).FspecPtr)).FgetBorderWidth})))(tls, (*TStyle)(unsafe.Pointer(stylePtr)).FclientData, recordPtr, (*TStyledWidgetSpec)(unsafe.Pointer(widgetSpecPtr)).FoptionsPtr, tkwin) } /* *--------------------------------------------------------------------------- * * Tk_DrawElement -- * * This function draw the given widget element in a given drawable area. * * Results: * None * * Side effects: * Cached data may be allocated or updated. * *--------------------------------------------------------------------------- */ func XTk_DrawElement(tls *libc.TLS, style TTk_Style, element TTk_StyledElement, recordPtr uintptr, tkwin TTk_Window, d TDrawable, x int32, y int32, width int32, height int32, state int32) { /* Drawing state flags. */ var stylePtr, widgetSpecPtr uintptr _, _ = stylePtr, widgetSpecPtr stylePtr = style widgetSpecPtr = element (*(*func(*libc.TLS, uintptr, uintptr, uintptr, TTk_Window, TDrawable, int32, int32, int32, int32, int32))(unsafe.Pointer(&struct{ uintptr }{(*TTk_ElementSpec1)(unsafe.Pointer((*TStyledElement1)(unsafe.Pointer((*TStyledWidgetSpec)(unsafe.Pointer(widgetSpecPtr)).FelementPtr)).FspecPtr)).Fdraw})))(tls, (*TStyle)(unsafe.Pointer(stylePtr)).FclientData, recordPtr, (*TStyledWidgetSpec)(unsafe.Pointer(widgetSpecPtr)).FoptionsPtr, tkwin, d, x, y, width, height, state) } /* *--------------------------------------------------------------------------- * * Tk_CreateStyle -- * * This function is called to create a new style as an instance of the * given engine. Styles are stored in thread-local space. * * Results: * The newly allocated style, or NULL if the style already exists. * * Side effects: * Memory allocated. Data added to thread-local table. * *--------------------------------------------------------------------------- */ func XTk_CreateStyle(tls *libc.TLS, name uintptr, engine TTk_StyleEngine, clientData uintptr) (r TTk_Style) { bp := tls.Alloc(16) defer tls.Free(16) /* Private data passed as is to engine code. */ var entryPtr, stylePtr, tsdPtr, v1, v2, v3 uintptr var _ /* newEntry at bp+0 */ int32 _, _, _, _, _, _ = entryPtr, stylePtr, tsdPtr, v1, v2, v3 tsdPtr = libtcl9_0.XTcl_GetThreadData(tls, uintptr(unsafe.Pointer(&_dataKey8)), int64(344)) /* * Attempt to create a new entry in the style table. */ if name != 0 { v1 = name } else { v1 = __ccgo_ts + 195 } entryPtr = (*(*func(*libc.TLS, uintptr, uintptr, uintptr) uintptr)(unsafe.Pointer(&struct{ uintptr }{(*TTcl_HashTable)(unsafe.Pointer(tsdPtr + 120)).FcreateProc})))(tls, tsdPtr+120, v1, bp) if !(*(*int32)(unsafe.Pointer(bp)) != 0) { /* * A style was already registered by that name. */ return libc.UintptrFromInt32(0) } /* * Allocate and intitialize a new style. */ stylePtr = libtcl9_0.XTcl_Alloc(tls, uint64(24)) if (*TTcl_HashTable)(unsafe.Pointer(tsdPtr+120)).FkeyType == int32(TCL_ONE_WORD_KEYS) || (*TTcl_HashTable)(unsafe.Pointer(tsdPtr+120)).FkeyType == -int32(1) { v2 = *(*uintptr)(unsafe.Pointer(entryPtr + 32)) } else { v2 = entryPtr + 32 } if engine != libc.UintptrFromInt32(0) { v3 = engine } else { v3 = (*TThreadSpecificData8)(unsafe.Pointer(tsdPtr)).FdefaultEnginePtr } _InitStyle(tls, stylePtr, v2, v3, clientData) (*TTcl_HashEntry)(unsafe.Pointer(entryPtr)).FclientData = stylePtr return stylePtr } /* *--------------------------------------------------------------------------- * * Tk_NameOfStyle -- * * Given a style, return its registered name. * * Results: * The return value is the name that was passed to Tk_CreateStyle() to * create the style. The storage for the returned string is private (it * points to the corresponding hash key) The caller should not modify * this string. * * Side effects: * None. * *--------------------------------------------------------------------------- */ func XTk_NameOfStyle(tls *libc.TLS, style TTk_Style) (r uintptr) { /* Style whose name is desired. */ var stylePtr uintptr _ = stylePtr stylePtr = style return (*TStyle)(unsafe.Pointer(stylePtr)).Fname } /* *--------------------------------------------------------------------------- * * InitStyle -- * * Initialize a newly allocated style. * * Results: * None. * * Side effects: * None. * *--------------------------------------------------------------------------- */ func _InitStyle(tls *libc.TLS, stylePtr uintptr, name uintptr, enginePtr uintptr, clientData uintptr) { /* Private data passed as is to engine code. */ (*TStyle)(unsafe.Pointer(stylePtr)).Fname = name (*TStyle)(unsafe.Pointer(stylePtr)).FenginePtr = enginePtr (*TStyle)(unsafe.Pointer(stylePtr)).FclientData = clientData } /* *--------------------------------------------------------------------------- * * Tk_GetStyle -- * * Retrieve a registered style by its name. * * Results: * A pointer to the style engine, or NULL if none found. In the latter * case and if the interp is not NULL, an error message is left in the * interp's result. * * Side effects: * None. * *--------------------------------------------------------------------------- */ func XTk_GetStyle(tls *libc.TLS, interp uintptr, name uintptr) (r TTk_Style) { bp := tls.Alloc(48) defer tls.Free(48) /* Name of the style to retrieve. NULL or empty * means the default system style. */ var entryPtr, tsdPtr, v1 uintptr _, _, _ = entryPtr, tsdPtr, v1 tsdPtr = libtcl9_0.XTcl_GetThreadData(tls, uintptr(unsafe.Pointer(&_dataKey8)), int64(344)) /* * Search for a corresponding entry in the style table. */ if name != libc.UintptrFromInt32(0) { v1 = name } else { v1 = __ccgo_ts + 195 } entryPtr = (*(*func(*libc.TLS, uintptr, uintptr) uintptr)(unsafe.Pointer(&struct{ uintptr }{(*TTcl_HashTable)(unsafe.Pointer(tsdPtr + 120)).FfindProc})))(tls, tsdPtr+120, v1) if entryPtr == libc.UintptrFromInt32(0) { if interp != libc.UintptrFromInt32(0) { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+16586, libc.VaList(bp+8, name))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+8, __ccgo_ts+179, __ccgo_ts+3058, __ccgo_ts+16612, name, libc.UintptrFromInt32(0))) } return libc.UintptrFromInt32(0) } return (*TTcl_HashEntry)(unsafe.Pointer(entryPtr)).FclientData } /* *--------------------------------------------------------------------------- * * Tk_FreeStyle -- * * No-op. Present only for stubs compatibility. * *--------------------------------------------------------------------------- */ func XTk_FreeStyle(tls *libc.TLS, dummy1381 TTk_Style) { } /* *--------------------------------------------------------------------------- * * Tk_AllocStyleFromObj -- * * Map the string name of a style to a corresponding Tk_Style. The style * must have already been created by Tk_CreateStyle. * * Results: * The return value is a token for the style that matches objPtr, or NULL * if none found. If NULL is returned, an error message will be left in * interp's result object. * *--------------------------------------------------------------------------- */ func XTk_AllocStyleFromObj(tls *libc.TLS, interp uintptr, objPtr uintptr) (r TTk_Style) { /* Object containing name of the style to * retrieve. */ if (*TTcl_Obj)(unsafe.Pointer(objPtr)).FtypePtr != uintptr(unsafe.Pointer(&_styleObjType)) { if _SetStyleFromAny(tls, interp, objPtr) != TCL_OK { return libc.UintptrFromInt32(0) } } return (*(*struct { Fptr1 uintptr Fptr2 uintptr })(unsafe.Pointer(objPtr + 32))).Fptr1 } /* *---------------------------------------------------------------------- * * SetStyleFromAny -- * * Convert the internal representation of a Tcl object to the style * internal form. * * Results: * If an error occurs is returned (e.g. the style doesn't exist), an * error message will be left in interp's result and TCL_ERROR is returned. * * Side effects: * The object is left with its typePtr pointing to styleObjType. * *---------------------------------------------------------------------- */ func _SetStyleFromAny(tls *libc.TLS, interp uintptr, objPtr uintptr) (r int32) { /* The object to convert. */ var name, typePtr uintptr var style TTk_Style _, _, _ = name, style, typePtr /* * Free the old internalRep before setting the new one. */ name = libtcl9_0.XTcl_GetStringFromObj(tls, objPtr, libc.UintptrFromInt32(0)) typePtr = (*TTcl_Obj)(unsafe.Pointer(objPtr)).FtypePtr if typePtr != libc.UintptrFromInt32(0) && (*TTcl_ObjType)(unsafe.Pointer(typePtr)).FfreeIntRepProc != libc.UintptrFromInt32(0) { (*(*func(*libc.TLS, uintptr))(unsafe.Pointer(&struct{ uintptr }{(*TTcl_ObjType)(unsafe.Pointer(typePtr)).FfreeIntRepProc})))(tls, objPtr) } style = XTk_GetStyle(tls, interp, name) if style == libc.UintptrFromInt32(0) { return int32(TCL_ERROR) } (*TTcl_Obj)(unsafe.Pointer(objPtr)).FtypePtr = uintptr(unsafe.Pointer(&_styleObjType)) (*(*struct { Fptr1 uintptr Fptr2 uintptr })(unsafe.Pointer(objPtr + 32))).Fptr1 = style return TCL_OK } /* *--------------------------------------------------------------------------- * * FreeStyleObjProc -- * * This proc is called to release an object reference to a style. Called * when the object's internal rep is released. * * Results: * None. * *--------------------------------------------------------------------------- */ func _FreeStyleObjProc(tls *libc.TLS, objPtr uintptr) { /* The object we are releasing. */ (*(*struct { Fptr1 uintptr Fptr2 uintptr })(unsafe.Pointer(objPtr + 32))).Fptr1 = libc.UintptrFromInt32(0) (*TTcl_Obj)(unsafe.Pointer(objPtr)).FtypePtr = libc.UintptrFromInt32(0) } /* *--------------------------------------------------------------------------- * * DupStyleObjProc -- * * When a cached style object is duplicated, this is called to update the * internal reps. * *--------------------------------------------------------------------------- */ func _DupStyleObjProc(tls *libc.TLS, srcObjPtr uintptr, dupObjPtr uintptr) { /* The object we are copying to. */ (*TTcl_Obj)(unsafe.Pointer(dupObjPtr)).FtypePtr = (*TTcl_Obj)(unsafe.Pointer(srcObjPtr)).FtypePtr (*(*struct { Fptr1 uintptr Fptr2 uintptr })(unsafe.Pointer(dupObjPtr + 32))).Fptr1 = (*(*struct { Fptr1 uintptr Fptr2 uintptr })(unsafe.Pointer(srcObjPtr + 32))).Fptr1 } type TStyledElement1 = struct { FspecPtr uintptr FnbWidgetSpecs int32 FwidgetSpecs uintptr } type TTk_ElementSpec1 = struct { Fversion int32 Fname uintptr Foptions uintptr FgetSize uintptr FgetBox uintptr FgetBorderWidth uintptr Fdraw uintptr } type TTkUndoAtomType = int32 const TK_UNDO_SEPARATOR = 0 const TK_UNDO_ACTION = 1 type TTkUndoSubAtom = struct { Fcommand TTcl_Command FfuncPtr uintptr FclientData uintptr Faction uintptr Fnext uintptr } type TTkUndoAtom = struct { Ftype1 TTkUndoAtomType Fapply uintptr Frevert uintptr Fnext uintptr } type TTkUndoRedoStack = struct { FundoStack uintptr FredoStack uintptr Finterp uintptr Fmaxdepth int32 Fdepth int32 } /* *---------------------------------------------------------------------- * * TkUndoPushStack -- * * Push elem on the stack identified by stack. * * Results: * None. * * Side effects: * None. * *---------------------------------------------------------------------- */ func XTkUndoPushStack(tls *libc.TLS, stack uintptr, elem uintptr) { (*TTkUndoAtom)(unsafe.Pointer(elem)).Fnext = *(*uintptr)(unsafe.Pointer(stack)) *(*uintptr)(unsafe.Pointer(stack)) = elem } /* *---------------------------------------------------------------------- * * TkUndoPopStack -- * * Remove and return the top element from the stack identified by stack. * * Results: * None. * * Side effects: * None. * *---------------------------------------------------------------------- */ func XTkUndoPopStack(tls *libc.TLS, stack uintptr) (r uintptr) { var elem uintptr _ = elem elem = libc.UintptrFromInt32(0) if *(*uintptr)(unsafe.Pointer(stack)) != libc.UintptrFromInt32(0) { elem = *(*uintptr)(unsafe.Pointer(stack)) *(*uintptr)(unsafe.Pointer(stack)) = (*TTkUndoAtom)(unsafe.Pointer(elem)).Fnext } return elem } /* *---------------------------------------------------------------------- * * TkUndoInsertSeparator -- * * Insert a separator on the stack, indicating a border for an undo/redo * chunk. * * Results: * None. * * Side effects: * None. * *---------------------------------------------------------------------- */ func XTkUndoInsertSeparator(tls *libc.TLS, stack uintptr) (r int32) { var separator uintptr _ = separator if *(*uintptr)(unsafe.Pointer(stack)) != libc.UintptrFromInt32(0) && (*TTkUndoAtom)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(stack)))).Ftype1 != int32(TK_UNDO_SEPARATOR) { separator = libtcl9_0.XTcl_Alloc(tls, uint64(32)) (*TTkUndoAtom)(unsafe.Pointer(separator)).Ftype1 = int32(TK_UNDO_SEPARATOR) XTkUndoPushStack(tls, stack, separator) return int32(1) } return 0 } /* *---------------------------------------------------------------------- * * TkUndoClearStack -- * * Clear an entire undo or redo stack and destroy all elements in it. * * Results: * None. * * Side effects: * None. * *---------------------------------------------------------------------- */ func XTkUndoClearStack(tls *libc.TLS, stack uintptr) { /* An Undo or Redo stack */ var _objPtr, _objPtr1, elem, next, next1, sub, v1, v3, v5 uintptr var v2, v4 TTcl_Size _, _, _, _, _, _, _, _, _, _, _ = _objPtr, _objPtr1, elem, next, next1, sub, v1, v2, v3, v4, v5 for { v1 = XTkUndoPopStack(tls, stack) elem = v1 if !(v1 != libc.UintptrFromInt32(0)) { break } if (*TTkUndoAtom)(unsafe.Pointer(elem)).Ftype1 != int32(TK_UNDO_SEPARATOR) { sub = (*TTkUndoAtom)(unsafe.Pointer(elem)).Fapply for sub != libc.UintptrFromInt32(0) { next = (*TTkUndoSubAtom)(unsafe.Pointer(sub)).Fnext if (*TTkUndoSubAtom)(unsafe.Pointer(sub)).Faction != libc.UintptrFromInt32(0) { _objPtr = (*TTkUndoSubAtom)(unsafe.Pointer(sub)).Faction v3 = _objPtr v2 = *(*TTcl_Size)(unsafe.Pointer(v3)) *(*TTcl_Size)(unsafe.Pointer(v3))-- if v2 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr) } } libtcl9_0.XTcl_Free(tls, sub) sub = next } sub = (*TTkUndoAtom)(unsafe.Pointer(elem)).Frevert for sub != libc.UintptrFromInt32(0) { next1 = (*TTkUndoSubAtom)(unsafe.Pointer(sub)).Fnext if (*TTkUndoSubAtom)(unsafe.Pointer(sub)).Faction != libc.UintptrFromInt32(0) { _objPtr1 = (*TTkUndoSubAtom)(unsafe.Pointer(sub)).Faction v5 = _objPtr1 v4 = *(*TTcl_Size)(unsafe.Pointer(v5)) *(*TTcl_Size)(unsafe.Pointer(v5))-- if v4 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr1) } } libtcl9_0.XTcl_Free(tls, sub) sub = next1 } } libtcl9_0.XTcl_Free(tls, elem) } *(*uintptr)(unsafe.Pointer(stack)) = libc.UintptrFromInt32(0) } /* *---------------------------------------------------------------------- * * TkUndoPushAction -- * * Push a new elem on the stack identified by stack. Action and revert * are given through Tcl_Obj's to which we will retain a reference. (So * they can be passed in with a zero refCount if desired). * * Results: * None. * * Side effects: * None. * *---------------------------------------------------------------------- */ func XTkUndoPushAction(tls *libc.TLS, stack uintptr, apply uintptr, revert uintptr) { var atom uintptr _ = atom atom = libtcl9_0.XTcl_Alloc(tls, uint64(32)) (*TTkUndoAtom)(unsafe.Pointer(atom)).Ftype1 = int32(TK_UNDO_ACTION) (*TTkUndoAtom)(unsafe.Pointer(atom)).Fapply = apply (*TTkUndoAtom)(unsafe.Pointer(atom)).Frevert = revert XTkUndoPushStack(tls, stack, atom) XTkUndoClearStack(tls, stack+8) } /* *---------------------------------------------------------------------- * * TkUndoMakeCmdSubAtom -- * * Create a new undo/redo step which must later be place into an undo * stack with TkUndoPushAction. This sub-atom, if evaluated, will take * the given command (if non-NULL), find its full Tcl command string, and * then evaluate that command with the list elements of 'actionScript' * appended. * * If 'subAtomList' is non-NULL, the newly created sub-atom is added onto * the end of the linked list of which 'subAtomList' is a part. This * makes it easy to build up a sequence of actions which will be pushed * in one step. * * Note: if the undo stack can persist for longer than the Tcl_Command * provided, the stack will cause crashes when actions are evaluated. In * this case the 'command' argument should not be used. This is the case * with peer text widgets, for example. * * Results: * The newly created subAtom is returned. It must be passed to * TkUndoPushAction otherwise a memory leak will result. * * Side effects: * A refCount is retained on 'actionScript'. * *---------------------------------------------------------------------- */ func XTkUndoMakeCmdSubAtom(tls *libc.TLS, command TTcl_Command, actionScript uintptr, subAtomList uintptr) (r uintptr) { /* Add to the end of this list of actions if * non-NULL */ var atom uintptr _ = atom if command == libc.UintptrFromInt32(0) && actionScript == libc.UintptrFromInt32(0) { libtcl9_0.XTcl_Panic(tls, __ccgo_ts+16618, 0) } atom = libtcl9_0.XTcl_Alloc(tls, uint64(40)) (*TTkUndoSubAtom)(unsafe.Pointer(atom)).Fcommand = command (*TTkUndoSubAtom)(unsafe.Pointer(atom)).FfuncPtr = libc.UintptrFromInt32(0) (*TTkUndoSubAtom)(unsafe.Pointer(atom)).FclientData = libc.UintptrFromInt32(0) (*TTkUndoSubAtom)(unsafe.Pointer(atom)).Fnext = libc.UintptrFromInt32(0) (*TTkUndoSubAtom)(unsafe.Pointer(atom)).Faction = actionScript if (*TTkUndoSubAtom)(unsafe.Pointer(atom)).Faction != libc.UintptrFromInt32(0) { (*TTcl_Obj)(unsafe.Pointer((*TTkUndoSubAtom)(unsafe.Pointer(atom)).Faction)).FrefCount++ } if subAtomList != libc.UintptrFromInt32(0) { for (*TTkUndoSubAtom)(unsafe.Pointer(subAtomList)).Fnext != libc.UintptrFromInt32(0) { subAtomList = (*TTkUndoSubAtom)(unsafe.Pointer(subAtomList)).Fnext } (*TTkUndoSubAtom)(unsafe.Pointer(subAtomList)).Fnext = atom } return atom } /* *---------------------------------------------------------------------- * * TkUndoMakeSubAtom -- * * Create a new undo/redo step which must later be place into an undo * stack with TkUndoPushAction. This sub-atom, if evaluated, will take * the given C-funcPtr (which must be non-NULL), and call it with three * arguments: the undo stack's 'interp', the 'clientData' given and the * 'actionScript'. The callback should return a standard Tcl return code * (TCL_OK on success). * * If 'subAtomList' is non-NULL, the newly created sub-atom is added onto * the end of the linked list of which 'subAtomList' is a part. This * makes it easy to build up a sequence of actions which will be pushed * in one step. * * Results: * The newly created subAtom is returned. It must be passed to * TkUndoPushAction otherwise a memory leak will result. * * Side effects: * A refCount is retained on 'actionScript'. * *---------------------------------------------------------------------- */ func XTkUndoMakeSubAtom(tls *libc.TLS, funcPtr uintptr, clientData uintptr, actionScript uintptr, subAtomList uintptr) (r uintptr) { /* Add to the end of this list of actions if * non-NULL */ var atom uintptr _ = atom if funcPtr == libc.UintptrFromInt32(0) { libtcl9_0.XTcl_Panic(tls, __ccgo_ts+16672, 0) } atom = libtcl9_0.XTcl_Alloc(tls, uint64(40)) (*TTkUndoSubAtom)(unsafe.Pointer(atom)).Fcommand = libc.UintptrFromInt32(0) (*TTkUndoSubAtom)(unsafe.Pointer(atom)).FfuncPtr = funcPtr (*TTkUndoSubAtom)(unsafe.Pointer(atom)).FclientData = clientData (*TTkUndoSubAtom)(unsafe.Pointer(atom)).Fnext = libc.UintptrFromInt32(0) (*TTkUndoSubAtom)(unsafe.Pointer(atom)).Faction = actionScript if (*TTkUndoSubAtom)(unsafe.Pointer(atom)).Faction != libc.UintptrFromInt32(0) { (*TTcl_Obj)(unsafe.Pointer((*TTkUndoSubAtom)(unsafe.Pointer(atom)).Faction)).FrefCount++ } if subAtomList != libc.UintptrFromInt32(0) { for (*TTkUndoSubAtom)(unsafe.Pointer(subAtomList)).Fnext != libc.UintptrFromInt32(0) { subAtomList = (*TTkUndoSubAtom)(unsafe.Pointer(subAtomList)).Fnext } (*TTkUndoSubAtom)(unsafe.Pointer(subAtomList)).Fnext = atom } return atom } /* *---------------------------------------------------------------------- * * TkUndoInitStack -- * * Initialize a new undo/redo stack. * * Results: * An Undo/Redo stack pointer. * * Side effects: * None. * *---------------------------------------------------------------------- */ func XTkUndoInitStack(tls *libc.TLS, interp uintptr, maxdepth int32) (r uintptr) { /* The maximum stack depth */ var stack uintptr _ = stack /* An Undo/Redo stack */ stack = libtcl9_0.XTcl_Alloc(tls, uint64(32)) (*TTkUndoRedoStack)(unsafe.Pointer(stack)).FundoStack = libc.UintptrFromInt32(0) (*TTkUndoRedoStack)(unsafe.Pointer(stack)).FredoStack = libc.UintptrFromInt32(0) (*TTkUndoRedoStack)(unsafe.Pointer(stack)).Finterp = interp (*TTkUndoRedoStack)(unsafe.Pointer(stack)).Fmaxdepth = maxdepth (*TTkUndoRedoStack)(unsafe.Pointer(stack)).Fdepth = 0 return stack } /* *---------------------------------------------------------------------- * * TkUndoSetMaxDepth -- * * Set the maximum depth of stack. * * Results: * None. * * Side effects: * May delete elements from the stack if the new maximum depth is smaller * than the number of elements previously in the stack. * *---------------------------------------------------------------------- */ func XTkUndoSetMaxDepth(tls *libc.TLS, stack uintptr, maxdepth int32) { /* The maximum stack depth */ var _objPtr, _objPtr1, elem, next, next1, prevelem, sub, v2, v4 uintptr var sepNumber int32 var v1, v3 TTcl_Size _, _, _, _, _, _, _, _, _, _, _, _ = _objPtr, _objPtr1, elem, next, next1, prevelem, sepNumber, sub, v1, v2, v3, v4 (*TTkUndoRedoStack)(unsafe.Pointer(stack)).Fmaxdepth = maxdepth if (*TTkUndoRedoStack)(unsafe.Pointer(stack)).Fmaxdepth > 0 && (*TTkUndoRedoStack)(unsafe.Pointer(stack)).Fdepth > (*TTkUndoRedoStack)(unsafe.Pointer(stack)).Fmaxdepth { sepNumber = 0 /* * Maximum stack depth exceeded. We have to remove the last compound * elements on the stack. */ elem = (*TTkUndoRedoStack)(unsafe.Pointer(stack)).FundoStack prevelem = libc.UintptrFromInt32(0) for elem != libc.UintptrFromInt32(0) && sepNumber <= (*TTkUndoRedoStack)(unsafe.Pointer(stack)).Fmaxdepth { if (*TTkUndoAtom)(unsafe.Pointer(elem)).Ftype1 == int32(TK_UNDO_SEPARATOR) { sepNumber++ } prevelem = elem elem = (*TTkUndoAtom)(unsafe.Pointer(elem)).Fnext } (*TTkUndoAtom)(unsafe.Pointer(prevelem)).Fnext = libc.UintptrFromInt32(0) for elem != libc.UintptrFromInt32(0) { prevelem = elem if (*TTkUndoAtom)(unsafe.Pointer(elem)).Ftype1 != int32(TK_UNDO_SEPARATOR) { sub = (*TTkUndoAtom)(unsafe.Pointer(elem)).Fapply for sub != libc.UintptrFromInt32(0) { next = (*TTkUndoSubAtom)(unsafe.Pointer(sub)).Fnext if (*TTkUndoSubAtom)(unsafe.Pointer(sub)).Faction != libc.UintptrFromInt32(0) { _objPtr = (*TTkUndoSubAtom)(unsafe.Pointer(sub)).Faction v2 = _objPtr v1 = *(*TTcl_Size)(unsafe.Pointer(v2)) *(*TTcl_Size)(unsafe.Pointer(v2))-- if v1 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr) } } libtcl9_0.XTcl_Free(tls, sub) sub = next } sub = (*TTkUndoAtom)(unsafe.Pointer(elem)).Frevert for sub != libc.UintptrFromInt32(0) { next1 = (*TTkUndoSubAtom)(unsafe.Pointer(sub)).Fnext if (*TTkUndoSubAtom)(unsafe.Pointer(sub)).Faction != libc.UintptrFromInt32(0) { _objPtr1 = (*TTkUndoSubAtom)(unsafe.Pointer(sub)).Faction v4 = _objPtr1 v3 = *(*TTcl_Size)(unsafe.Pointer(v4)) *(*TTcl_Size)(unsafe.Pointer(v4))-- if v3 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr1) } } libtcl9_0.XTcl_Free(tls, sub) sub = next1 } } elem = (*TTkUndoAtom)(unsafe.Pointer(elem)).Fnext libtcl9_0.XTcl_Free(tls, prevelem) } (*TTkUndoRedoStack)(unsafe.Pointer(stack)).Fdepth = (*TTkUndoRedoStack)(unsafe.Pointer(stack)).Fmaxdepth } } /* *---------------------------------------------------------------------- * * TkUndoClearStacks -- * * Clear both the undo and redo stack. * * Results: * None. * * Side effects: * None. * *---------------------------------------------------------------------- */ func XTkUndoClearStacks(tls *libc.TLS, stack uintptr) { /* An Undo/Redo stack */ XTkUndoClearStack(tls, stack) XTkUndoClearStack(tls, stack+8) (*TTkUndoRedoStack)(unsafe.Pointer(stack)).Fdepth = 0 } /* *---------------------------------------------------------------------- * * TkUndoFreeStack * * Clear both the undo and redo stack and free the memory allocated to * the u/r stack pointer. * * Results: * None. * * Side effects: * None. * *---------------------------------------------------------------------- */ func XTkUndoFreeStack(tls *libc.TLS, stack uintptr) { /* An Undo/Redo stack */ XTkUndoClearStacks(tls, stack) libtcl9_0.XTcl_Free(tls, stack) } /* *---------------------------------------------------------------------- * * TkUndoCanRedo -- * * Returns true if redo is possible, i.e. if the redo stack is not empty. * * Results: * A boolean. * * Side effects: * None. * *---------------------------------------------------------------------- */ func XTkUndoCanRedo(tls *libc.TLS, stack uintptr) (r int32) { /* An Undo/Redo stack */ return libc.BoolInt32((*TTkUndoRedoStack)(unsafe.Pointer(stack)).FredoStack != libc.UintptrFromInt32(0)) } /* *---------------------------------------------------------------------- * * TkUndoCanUndo -- * * Returns true if undo is possible, i.e. if the undo stack is not empty. * * Results: * A boolean. * * Side effects: * None. * *---------------------------------------------------------------------- */ func XTkUndoCanUndo(tls *libc.TLS, stack uintptr) (r int32) { /* An Undo/Redo stack */ return libc.BoolInt32((*TTkUndoRedoStack)(unsafe.Pointer(stack)).FundoStack != libc.UintptrFromInt32(0)) } /* *---------------------------------------------------------------------- * * TkUndoInsertUndoSeparator -- * * Insert a separator on the undo stack, indicating a border for an * undo/redo chunk. * * Results: * None. * * Side effects: * None. * *---------------------------------------------------------------------- */ func XTkUndoInsertUndoSeparator(tls *libc.TLS, stack uintptr) { if XTkUndoInsertSeparator(tls, stack) != 0 { (*TTkUndoRedoStack)(unsafe.Pointer(stack)).Fdepth++ XTkUndoSetMaxDepth(tls, stack, (*TTkUndoRedoStack)(unsafe.Pointer(stack)).Fmaxdepth) } } /* *---------------------------------------------------------------------- * * TkUndoRevert -- * * Undo a compound action on the stack. * * Results: * A Tcl status code * * Side effects: * None. * *---------------------------------------------------------------------- */ func XTkUndoRevert(tls *libc.TLS, stack uintptr) (r int32) { var elem uintptr _ = elem /* * Insert a separator on the undo and the redo stack. */ XTkUndoInsertUndoSeparator(tls, stack) XTkUndoInsertSeparator(tls, stack+8) /* * Pop and skip the first separator if there is one. */ elem = XTkUndoPopStack(tls, stack) if elem == libc.UintptrFromInt32(0) { return int32(TCL_ERROR) } if (*TTkUndoAtom)(unsafe.Pointer(elem)).Ftype1 == int32(TK_UNDO_SEPARATOR) { libtcl9_0.XTcl_Free(tls, elem) elem = XTkUndoPopStack(tls, stack) } for elem != libc.UintptrFromInt32(0) && (*TTkUndoAtom)(unsafe.Pointer(elem)).Ftype1 != int32(TK_UNDO_SEPARATOR) { /* * Note that we currently ignore errors thrown here. */ _EvaluateActionList(tls, (*TTkUndoRedoStack)(unsafe.Pointer(stack)).Finterp, (*TTkUndoAtom)(unsafe.Pointer(elem)).Frevert) XTkUndoPushStack(tls, stack+8, elem) elem = XTkUndoPopStack(tls, stack) } /* * Insert a separator on the redo stack. */ XTkUndoInsertSeparator(tls, stack+8) (*TTkUndoRedoStack)(unsafe.Pointer(stack)).Fdepth-- return TCL_OK } /* *---------------------------------------------------------------------- * * TkUndoApply -- * * Redo a compound action on the stack. * * Results: * A Tcl status code * * Side effects: * None. * *---------------------------------------------------------------------- */ func XTkUndoApply(tls *libc.TLS, stack uintptr) (r int32) { var elem uintptr _ = elem /* * Insert a separator on the undo stack. */ XTkUndoInsertSeparator(tls, stack) /* * Pop and skip the first separator if there is one. */ elem = XTkUndoPopStack(tls, stack+8) if elem == libc.UintptrFromInt32(0) { return int32(TCL_ERROR) } if (*TTkUndoAtom)(unsafe.Pointer(elem)).Ftype1 == int32(TK_UNDO_SEPARATOR) { libtcl9_0.XTcl_Free(tls, elem) elem = XTkUndoPopStack(tls, stack+8) } for elem != libc.UintptrFromInt32(0) && (*TTkUndoAtom)(unsafe.Pointer(elem)).Ftype1 != int32(TK_UNDO_SEPARATOR) { /* * Note that we currently ignore errors thrown here. */ _EvaluateActionList(tls, (*TTkUndoRedoStack)(unsafe.Pointer(stack)).Finterp, (*TTkUndoAtom)(unsafe.Pointer(elem)).Fapply) XTkUndoPushStack(tls, stack, elem) elem = XTkUndoPopStack(tls, stack+8) } /* * Insert a separator on the undo stack. */ XTkUndoInsertSeparator(tls, stack) (*TTkUndoRedoStack)(unsafe.Pointer(stack)).Fdepth++ return TCL_OK } /* *---------------------------------------------------------------------- * * EvaluateActionList -- * * Execute a linked list of undo/redo sub-atoms. If any sub-atom returns * a non TCL_OK value, execution of subsequent sub-atoms is cancelled and * the error returned immediately. * * Results: * A Tcl status code * * Side effects: * The undo/redo subAtoms can perform arbitrary actions. * *---------------------------------------------------------------------- */ func _EvaluateActionList(tls *libc.TLS, interp uintptr, action uintptr) (r int32) { /* Head of linked list of action steps to * perform. */ var _objPtr, cmdNameObj, evalObj, v2 uintptr var result int32 var v1 TTcl_Size _, _, _, _, _, _ = _objPtr, cmdNameObj, evalObj, result, v1, v2 result = TCL_OK for action != libc.UintptrFromInt32(0) { if (*TTkUndoSubAtom)(unsafe.Pointer(action)).FfuncPtr != libc.UintptrFromInt32(0) { result = (*(*func(*libc.TLS, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*TTkUndoSubAtom)(unsafe.Pointer(action)).FfuncPtr})))(tls, interp, (*TTkUndoSubAtom)(unsafe.Pointer(action)).FclientData, (*TTkUndoSubAtom)(unsafe.Pointer(action)).Faction) } else { if (*TTkUndoSubAtom)(unsafe.Pointer(action)).Fcommand != libc.UintptrFromInt32(0) { cmdNameObj = libtcl9_0.XTcl_NewObj(tls) evalObj = libtcl9_0.XTcl_NewObj(tls) (*TTcl_Obj)(unsafe.Pointer(evalObj)).FrefCount++ libtcl9_0.XTcl_GetCommandFullName(tls, interp, (*TTkUndoSubAtom)(unsafe.Pointer(action)).Fcommand, cmdNameObj) libtcl9_0.XTcl_ListObjAppendElement(tls, libc.UintptrFromInt32(0), evalObj, cmdNameObj) if (*TTkUndoSubAtom)(unsafe.Pointer(action)).Faction != libc.UintptrFromInt32(0) { libtcl9_0.XTcl_ListObjAppendList(tls, libc.UintptrFromInt32(0), evalObj, (*TTkUndoSubAtom)(unsafe.Pointer(action)).Faction) } result = libtcl9_0.XTcl_EvalObjEx(tls, interp, evalObj, int32(TCL_EVAL_GLOBAL)) _objPtr = evalObj v2 = _objPtr v1 = *(*TTcl_Size)(unsafe.Pointer(v2)) *(*TTcl_Size)(unsafe.Pointer(v2))-- if v1 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr) } } else { result = libtcl9_0.XTcl_EvalObjEx(tls, interp, (*TTkUndoSubAtom)(unsafe.Pointer(action)).Faction, int32(TCL_EVAL_GLOBAL)) } } if result != TCL_OK { return result } action = (*TTkUndoSubAtom)(unsafe.Pointer(action)).Fnext } return result } /* *-------------------------------------------------------------- * * TkStateParseProc -- * * This function is invoked during option processing to handle the * "-state" and "-default" options. * * Results: * A standard Tcl return value. * * Side effects: * The state for a given item gets replaced by the state indicated in the * value argument. * *-------------------------------------------------------------- */ func XTkStateParseProc(tls *libc.TLS, clientData uintptr, interp uintptr, dummy57 TTk_Window, value uintptr, widgRec uintptr, offset TTcl_Size) (r int32) { bp := tls.Alloc(48) defer tls.Free(48) /* Offset into item. */ var c, flags int32 var length Tsize_t var msgObj, statePtr, v1 uintptr _, _, _, _, _, _ = c, flags, length, msgObj, statePtr, v1 flags = int32(int64(clientData)) statePtr = widgRec + uintptr(offset) if value == libc.UintptrFromInt32(0) || libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(value))) == 0 { *(*TTk_State)(unsafe.Pointer(statePtr)) = int32(TK_STATE_NULL) return TCL_OK } c = libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(value))) length = libc.Xstrlen(tls, value) if c == int32('n') && libc.Xstrncmp(tls, value, __ccgo_ts+9363, length) == 0 { *(*TTk_State)(unsafe.Pointer(statePtr)) = int32(TK_STATE_NORMAL) return TCL_OK } if c == int32('d') && libc.Xstrncmp(tls, value, __ccgo_ts+16715, length) == 0 { *(*TTk_State)(unsafe.Pointer(statePtr)) = int32(TK_STATE_DISABLED) return TCL_OK } if c == int32('a') && flags&int32(1) != 0 && libc.Xstrncmp(tls, value, __ccgo_ts+16724, length) == 0 { *(*TTk_State)(unsafe.Pointer(statePtr)) = int32(TK_STATE_ACTIVE) return TCL_OK } if c == int32('h') && flags&int32(2) != 0 && libc.Xstrncmp(tls, value, __ccgo_ts+16731, length) == 0 { *(*TTk_State)(unsafe.Pointer(statePtr)) = int32(TK_STATE_HIDDEN) return TCL_OK } if flags&int32(4) != 0 { v1 = __ccgo_ts + 16738 } else { v1 = __ccgo_ts + 16747 } msgObj = libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+16753, libc.VaList(bp+8, v1, value)) if flags&int32(1) != 0 { libtcl9_0.XTcl_AppendToObj(tls, msgObj, __ccgo_ts+16787, int64(-libc.Int32FromInt32(1))) } if flags&int32(2) != 0 { libtcl9_0.XTcl_AppendToObj(tls, msgObj, __ccgo_ts+16796, int64(-libc.Int32FromInt32(1))) } if flags&int32(3) != 0 { libtcl9_0.XTcl_AppendToObj(tls, msgObj, __ccgo_ts+16805, int64(-libc.Int32FromInt32(1))) } libtcl9_0.XTcl_AppendToObj(tls, msgObj, __ccgo_ts+16807, int64(-libc.Int32FromInt32(1))) libtcl9_0.XTcl_SetObjResult(tls, interp, msgObj) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+8, __ccgo_ts+179, __ccgo_ts+182, __ccgo_ts+16820, libc.UintptrFromInt32(0))) *(*TTk_State)(unsafe.Pointer(statePtr)) = int32(TK_STATE_NORMAL) return int32(TCL_ERROR) } /* *-------------------------------------------------------------- * * TkStatePrintProc -- * * This function is invoked by the Tk configuration code to produce a * printable string for the "-state" configuration option. * * Results: * The return value is a string describing the state for the item * referred to by "widgRec". In addition, *freeProcPtr is filled in with * the address of a function to call to free the result string when it's * no longer needed (or NULL to indicate that the string doesn't need to * be freed). * * Side effects: * None. * *-------------------------------------------------------------- */ func XTkStatePrintProc(tls *libc.TLS, dummy134 uintptr, dummy135 TTk_Window, widgRec uintptr, offset TTcl_Size, dummy138 uintptr) (r uintptr) { /* Pointer to variable to fill in with * information about how to reclaim storage * for return string. */ var statePtr uintptr _ = statePtr statePtr = widgRec + uintptr(offset) switch *(*TTk_State)(unsafe.Pointer(statePtr)) { case int32(TK_STATE_NORMAL): return __ccgo_ts + 9363 case int32(TK_STATE_DISABLED): return __ccgo_ts + 16715 case int32(TK_STATE_HIDDEN): return __ccgo_ts + 16731 case int32(TK_STATE_ACTIVE): return __ccgo_ts + 16724 default: return __ccgo_ts + 195 } return r } /* *-------------------------------------------------------------- * * TkOrientParseProc -- * * This function is invoked during option processing to handle the * "-orient" option. * * Results: * A standard Tcl return value. * * Side effects: * The orientation for a given item gets replaced by the orientation * indicated in the value argument. * *-------------------------------------------------------------- */ func XTkOrientParseProc(tls *libc.TLS, dummy178 uintptr, interp uintptr, dummy180 TTk_Window, value uintptr, widgRec uintptr, offset TTcl_Size) (r int32) { bp := tls.Alloc(48) defer tls.Free(48) /* Offset into item. */ var c int32 var length Tsize_t var orientPtr uintptr _, _, _ = c, length, orientPtr orientPtr = widgRec + uintptr(offset) if value == libc.UintptrFromInt32(0) || libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(value))) == 0 { *(*int32)(unsafe.Pointer(orientPtr)) = 0 return TCL_OK } c = libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(value))) length = libc.Xstrlen(tls, value) if c == int32('h') && libc.Xstrncmp(tls, value, __ccgo_ts+16826, length) == 0 { *(*int32)(unsafe.Pointer(orientPtr)) = 0 return TCL_OK } if c == int32('v') && libc.Xstrncmp(tls, value, __ccgo_ts+16837, length) == 0 { *(*int32)(unsafe.Pointer(orientPtr)) = int32(1) return TCL_OK } libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+16846, libc.VaList(bp+8, value))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+8, __ccgo_ts+179, __ccgo_ts+182, __ccgo_ts+16899, libc.UintptrFromInt32(0))) *(*int32)(unsafe.Pointer(orientPtr)) = 0 return int32(TCL_ERROR) } /* *-------------------------------------------------------------- * * TkOrientPrintProc -- * * This function is invoked by the Tk configuration code to produce a * printable string for the "-orient" configuration option. * * Results: * The return value is a string describing the orientation for the item * referred to by "widgRec". In addition, *freeProcPtr is filled in with * the address of a function to call to free the result string when it's * no longer needed (or NULL to indicate that the string doesn't need to * be freed). * * Side effects: * None. * *-------------------------------------------------------------- */ func XTkOrientPrintProc(tls *libc.TLS, dummy236 uintptr, dummy237 TTk_Window, widgRec uintptr, offset TTcl_Size, dummy240 uintptr) (r uintptr) { /* Pointer to variable to fill in with * information about how to reclaim storage * for return string. */ var statePtr uintptr _ = statePtr statePtr = widgRec + uintptr(offset) if *(*int32)(unsafe.Pointer(statePtr)) != 0 { return __ccgo_ts + 16837 } else { return __ccgo_ts + 16826 } return r } /* *---------------------------------------------------------------------- * * TkOffsetParseProc -- * * Converts the offset of a stipple or tile into the Tk_TSOffset * structure. * *---------------------------------------------------------------------- */ func XTkOffsetParseProc(tls *libc.TLS, clientData uintptr, interp uintptr, tkwin TTk_Window, value uintptr, widgRec uintptr, offset TTcl_Size) (r int32) { bp := tls.Alloc(64) defer tls.Free(64) /* Offset of tile in record */ var msgObj, offsetPtr, p, q uintptr var result int32 var _ /* tsoffset at bp+0 */ TTk_TSOffset _, _, _, _, _ = msgObj, offsetPtr, p, q, result offsetPtr = widgRec + uintptr(offset) if value == libc.UintptrFromInt32(0) || libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(value))) == 0 { (*(*TTk_TSOffset)(unsafe.Pointer(bp))).Fflags = libc.Int32FromInt32(TK_OFFSET_CENTER) | libc.Int32FromInt32(TK_OFFSET_MIDDLE) goto goodTSOffset } (*(*TTk_TSOffset)(unsafe.Pointer(bp))).Fflags = 0 p = value switch libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(value))) { case int32('#'): if int64(clientData)&int64(TK_OFFSET_RELATIVE) != 0 { (*(*TTk_TSOffset)(unsafe.Pointer(bp))).Fflags = int32(TK_OFFSET_RELATIVE) p++ break } goto badTSOffset case int32('e'): switch libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(value + 1))) { case int32('\000'): (*(*TTk_TSOffset)(unsafe.Pointer(bp))).Fflags = libc.Int32FromInt32(TK_OFFSET_RIGHT) | libc.Int32FromInt32(TK_OFFSET_MIDDLE) goto goodTSOffset case int32('n'): if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(value + 2))) != int32('d') || libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(value + 3))) != int32('\000') { goto badTSOffset } (*(*TTk_TSOffset)(unsafe.Pointer(bp))).Fflags = int32(INT_MAX) goto goodTSOffset } case int32('w'): if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(value + 1))) != int32('\000') { goto badTSOffset } (*(*TTk_TSOffset)(unsafe.Pointer(bp))).Fflags = libc.Int32FromInt32(TK_OFFSET_LEFT) | libc.Int32FromInt32(TK_OFFSET_MIDDLE) goto goodTSOffset case int32('n'): if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(value + 1))) != int32('\000') && libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(value + 2))) != int32('\000') { goto badTSOffset } switch libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(value + 1))) { case int32('\000'): (*(*TTk_TSOffset)(unsafe.Pointer(bp))).Fflags = libc.Int32FromInt32(TK_OFFSET_CENTER) | libc.Int32FromInt32(TK_OFFSET_TOP) goto goodTSOffset case int32('w'): (*(*TTk_TSOffset)(unsafe.Pointer(bp))).Fflags = libc.Int32FromInt32(TK_OFFSET_LEFT) | libc.Int32FromInt32(TK_OFFSET_TOP) goto goodTSOffset case int32('e'): (*(*TTk_TSOffset)(unsafe.Pointer(bp))).Fflags = libc.Int32FromInt32(TK_OFFSET_RIGHT) | libc.Int32FromInt32(TK_OFFSET_TOP) goto goodTSOffset } goto badTSOffset case int32('s'): if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(value + 1))) != int32('\000') && libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(value + 2))) != int32('\000') { goto badTSOffset } switch libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(value + 1))) { case int32('\000'): (*(*TTk_TSOffset)(unsafe.Pointer(bp))).Fflags = libc.Int32FromInt32(TK_OFFSET_CENTER) | libc.Int32FromInt32(TK_OFFSET_BOTTOM) goto goodTSOffset case int32('w'): (*(*TTk_TSOffset)(unsafe.Pointer(bp))).Fflags = libc.Int32FromInt32(TK_OFFSET_LEFT) | libc.Int32FromInt32(TK_OFFSET_BOTTOM) goto goodTSOffset case int32('e'): (*(*TTk_TSOffset)(unsafe.Pointer(bp))).Fflags = libc.Int32FromInt32(TK_OFFSET_RIGHT) | libc.Int32FromInt32(TK_OFFSET_BOTTOM) goto goodTSOffset } goto badTSOffset case int32('c'): if libc.Xstrncmp(tls, value, __ccgo_ts+10959, libc.Xstrlen(tls, value)) != 0 { goto badTSOffset } (*(*TTk_TSOffset)(unsafe.Pointer(bp))).Fflags = libc.Int32FromInt32(TK_OFFSET_CENTER) | libc.Int32FromInt32(TK_OFFSET_MIDDLE) goto goodTSOffset } /* * Check for an extra offset. */ q = libc.Xstrchr(tls, p, int32(',')) if q == libc.UintptrFromInt32(0) { if int64(clientData)&int64(TK_OFFSET_INDEX) != 0 { if libtcl9_0.XTcl_GetInt(tls, interp, p, bp) != TCL_OK { libtcl9_0.XTcl_ResetResult(tls, interp) goto badTSOffset } (*(*TTk_TSOffset)(unsafe.Pointer(bp))).Fflags |= int32(TK_OFFSET_INDEX) goto goodTSOffset } goto badTSOffset } *(*uint8)(unsafe.Pointer(q)) = uint8(0) result = XTk_GetPixels(tls, interp, tkwin, p, bp+4) *(*uint8)(unsafe.Pointer(q)) = uint8(',') if result != TCL_OK { return int32(TCL_ERROR) } if XTk_GetPixels(tls, interp, tkwin, q+uintptr(1), bp+8) != TCL_OK { return int32(TCL_ERROR) } /* * Below is a hack to allow the stipple/tile offset to be stored in the * internal tile structure. Most of the times, offsetPtr is a pointer to * an already existing tile structure. However if this structure is not * already created, we must do it with Tk_GetTile()!!!! */ goto goodTSOffset goodTSOffset: ; libc.Xmemcpy(tls, offsetPtr, bp, uint64(12)) return TCL_OK goto badTSOffset badTSOffset: ; msgObj = libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+16911, libc.VaList(bp+24, value)) if int64(clientData)&int64(TK_OFFSET_RELATIVE) != 0 { libtcl9_0.XTcl_AppendToObj(tls, msgObj, __ccgo_ts+16943, int64(-libc.Int32FromInt32(1))) } if int64(clientData)&int64(TK_OFFSET_INDEX) != 0 { libtcl9_0.XTcl_AppendToObj(tls, msgObj, __ccgo_ts+16952, int64(-libc.Int32FromInt32(1))) } libtcl9_0.XTcl_AppendToObj(tls, msgObj, __ccgo_ts+16962, int64(-libc.Int32FromInt32(1))) libtcl9_0.XTcl_SetObjResult(tls, interp, msgObj) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+24, __ccgo_ts+179, __ccgo_ts+182, __ccgo_ts+17002, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) } /* *---------------------------------------------------------------------- * * TkOffsetPrintProc -- * * Returns the offset of the tile. * * Results: * The offset of the tile is returned. * *---------------------------------------------------------------------- */ func XTkOffsetPrintProc(tls *libc.TLS, dummy418 uintptr, dummy419 TTk_Window, widgRec uintptr, offset TTcl_Size, freeProcPtr uintptr) (r uintptr) { bp := tls.Alloc(32) defer tls.Free(32) /* not used */ var offsetPtr, p, q, v1, v2 uintptr _, _, _, _, _ = offsetPtr, p, q, v1, v2 offsetPtr = widgRec + uintptr(offset) if (*TTk_TSOffset)(unsafe.Pointer(offsetPtr)).Fflags&int32(TK_OFFSET_INDEX) != 0 { if (*TTk_TSOffset)(unsafe.Pointer(offsetPtr)).Fflags >= int32(INT_MAX) { return __ccgo_ts + 8126 } p = libtcl9_0.XTcl_Alloc(tls, uint64(32)) libc.X__builtin_snprintf(tls, p, uint64(32), __ccgo_ts+14540, libc.VaList(bp+8, (*TTk_TSOffset)(unsafe.Pointer(offsetPtr)).Fflags & ^libc.Int32FromInt32(TK_OFFSET_INDEX))) *(*uintptr)(unsafe.Pointer(freeProcPtr)) = libc.UintptrFromInt32(3) return p } if (*TTk_TSOffset)(unsafe.Pointer(offsetPtr)).Fflags&int32(TK_OFFSET_TOP) != 0 { if (*TTk_TSOffset)(unsafe.Pointer(offsetPtr)).Fflags&int32(TK_OFFSET_LEFT) != 0 { return __ccgo_ts + 10956 } else { if (*TTk_TSOffset)(unsafe.Pointer(offsetPtr)).Fflags&int32(TK_OFFSET_CENTER) != 0 { return __ccgo_ts + 10939 } else { if (*TTk_TSOffset)(unsafe.Pointer(offsetPtr)).Fflags&int32(TK_OFFSET_RIGHT) != 0 { return __ccgo_ts + 10941 } } } } else { if (*TTk_TSOffset)(unsafe.Pointer(offsetPtr)).Fflags&int32(TK_OFFSET_MIDDLE) != 0 { if (*TTk_TSOffset)(unsafe.Pointer(offsetPtr)).Fflags&int32(TK_OFFSET_LEFT) != 0 { return __ccgo_ts + 10954 } else { if (*TTk_TSOffset)(unsafe.Pointer(offsetPtr)).Fflags&int32(TK_OFFSET_CENTER) != 0 { return __ccgo_ts + 10959 } else { if (*TTk_TSOffset)(unsafe.Pointer(offsetPtr)).Fflags&int32(TK_OFFSET_RIGHT) != 0 { return __ccgo_ts + 10944 } } } } else { if (*TTk_TSOffset)(unsafe.Pointer(offsetPtr)).Fflags&int32(TK_OFFSET_BOTTOM) != 0 { if (*TTk_TSOffset)(unsafe.Pointer(offsetPtr)).Fflags&int32(TK_OFFSET_LEFT) != 0 { return __ccgo_ts + 10951 } else { if (*TTk_TSOffset)(unsafe.Pointer(offsetPtr)).Fflags&int32(TK_OFFSET_CENTER) != 0 { return __ccgo_ts + 10949 } else { if (*TTk_TSOffset)(unsafe.Pointer(offsetPtr)).Fflags&int32(TK_OFFSET_RIGHT) != 0 { return __ccgo_ts + 10946 } } } } } } v1 = libtcl9_0.XTcl_Alloc(tls, uint64(32)) p = v1 q = v1 if (*TTk_TSOffset)(unsafe.Pointer(offsetPtr)).Fflags&int32(TK_OFFSET_RELATIVE) != 0 { v2 = q q++ *(*uint8)(unsafe.Pointer(v2)) = uint8('#') } libc.X__builtin_snprintf(tls, q, uint64(32), __ccgo_ts+17009, libc.VaList(bp+8, (*TTk_TSOffset)(unsafe.Pointer(offsetPtr)).Fxoffset, (*TTk_TSOffset)(unsafe.Pointer(offsetPtr)).Fyoffset)) *(*uintptr)(unsafe.Pointer(freeProcPtr)) = libc.UintptrFromInt32(3) return p } /* *---------------------------------------------------------------------- * * TkPixelParseProc -- * * Converts the name of an image into a tile. * *---------------------------------------------------------------------- */ func XTkPixelParseProc(tls *libc.TLS, clientData uintptr, interp uintptr, tkwin TTk_Window, value uintptr, widgRec uintptr, offset TTcl_Size) (r int32) { bp := tls.Alloc(48) defer tls.Free(48) /* Offset of tile in record */ var doublePtr uintptr var result int32 _, _ = doublePtr, result doublePtr = widgRec + uintptr(offset) result = XTkGetDoublePixels(tls, interp, tkwin, value, doublePtr) if result == TCL_OK && clientData == libc.UintptrFromInt32(0) && *(*float64)(unsafe.Pointer(doublePtr)) < float64(0) { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+11394, libc.VaList(bp+8, value))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+8, __ccgo_ts+179, __ccgo_ts+182, __ccgo_ts+7935, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) } return result } /* *---------------------------------------------------------------------- * * TkPixelPrintProc -- * * Returns the name of the tile. * * Results: * The name of the tile is returned. * *---------------------------------------------------------------------- */ func XTkPixelPrintProc(tls *libc.TLS, dummy519 uintptr, dummy520 TTk_Window, widgRec uintptr, offset TTcl_Size, freeProcPtr uintptr) (r uintptr) { /* not used */ var doublePtr, p uintptr _, _ = doublePtr, p doublePtr = widgRec + uintptr(offset) p = libtcl9_0.XTcl_Alloc(tls, uint64(24)) libtcl9_0.XTcl_PrintDouble(tls, libc.UintptrFromInt32(0), *(*float64)(unsafe.Pointer(doublePtr)), p) *(*uintptr)(unsafe.Pointer(freeProcPtr)) = libc.UintptrFromInt32(3) return p } /* *---------------------------------------------------------------------- * * TkDrawInsetFocusHighlight -- * * This function draws a rectangular ring around the outside of a widget * to indicate that it has received the input focus. It takes an * additional padding argument that specifies how much padding is present * outside the widget. * * Results: * None. * * Side effects: * A rectangle "width" pixels wide is drawn in "drawable", corresponding * to the outer area of "tkwin". * *---------------------------------------------------------------------- */ func XTkDrawInsetFocusHighlight(tls *libc.TLS, tkwin TTk_Window, gc TGC, width int32, drawable TDrawable, padding int32) { bp := tls.Alloc(32) defer tls.Free(32) /* Width of padding outside of widget. */ var _ /* rects at bp+0 */ [4]TXRectangle (*(*[4]TXRectangle)(unsafe.Pointer(bp)))[0].Fx = int16(padding) (*(*[4]TXRectangle)(unsafe.Pointer(bp)))[0].Fy = int16(padding) (*(*[4]TXRectangle)(unsafe.Pointer(bp)))[0].Fwidth = libc.Uint16FromInt32((*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fchanges.Fwidth - int32(2)*padding) (*(*[4]TXRectangle)(unsafe.Pointer(bp)))[0].Fheight = libc.Uint16FromInt32(width) (*(*[4]TXRectangle)(unsafe.Pointer(bp)))[int32(1)].Fx = int16(padding) (*(*[4]TXRectangle)(unsafe.Pointer(bp)))[int32(1)].Fy = int16((*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fchanges.Fheight - width - padding) (*(*[4]TXRectangle)(unsafe.Pointer(bp)))[int32(1)].Fwidth = libc.Uint16FromInt32((*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fchanges.Fwidth - int32(2)*padding) (*(*[4]TXRectangle)(unsafe.Pointer(bp)))[int32(1)].Fheight = libc.Uint16FromInt32(width) (*(*[4]TXRectangle)(unsafe.Pointer(bp)))[int32(2)].Fx = int16(padding) (*(*[4]TXRectangle)(unsafe.Pointer(bp)))[int32(2)].Fy = int16(width + padding) (*(*[4]TXRectangle)(unsafe.Pointer(bp)))[int32(2)].Fwidth = libc.Uint16FromInt32(width) (*(*[4]TXRectangle)(unsafe.Pointer(bp)))[int32(2)].Fheight = libc.Uint16FromInt32((*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fchanges.Fheight - int32(2)*width - int32(2)*padding) (*(*[4]TXRectangle)(unsafe.Pointer(bp)))[int32(3)].Fx = int16((*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fchanges.Fwidth - width - padding) (*(*[4]TXRectangle)(unsafe.Pointer(bp)))[int32(3)].Fy = (*(*[4]TXRectangle)(unsafe.Pointer(bp)))[int32(2)].Fy (*(*[4]TXRectangle)(unsafe.Pointer(bp)))[int32(3)].Fwidth = libc.Uint16FromInt32(width) (*(*[4]TXRectangle)(unsafe.Pointer(bp)))[int32(3)].Fheight = (*(*[4]TXRectangle)(unsafe.Pointer(bp)))[int32(2)].Fheight libx11.XXFillRectangles(tls, (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fdisplay, drawable, gc, bp, int32(4)) } /* *---------------------------------------------------------------------- * * Tk_DrawFocusHighlight -- * * This function draws a rectangular ring around the outside of a widget * to indicate that it has received the input focus. * * This function is now deprecated. Use Tk_DrawHighlightBorder instead, * since this function does not handle drawing the Focus ring properly on * the Macintosh - you need to know the background GC as well as the * foreground since the Mac focus ring separated from the widget by a 1 * pixel border. * * Results: * None. * * Side effects: * A rectangle "width" pixels wide is drawn in "drawable", corresponding * to the outer area of "tkwin". * *---------------------------------------------------------------------- */ func XTk_DrawFocusHighlight(tls *libc.TLS, tkwin TTk_Window, gc TGC, width int32, drawable TDrawable) { /* Where to draw the ring (typically a pixmap * for double buffering). */ XTkDrawInsetFocusHighlight(tls, tkwin, gc, width, drawable, 0) } /* *---------------------------------------------------------------------- * * TkDrawDottedRect -- * * This function draws a dotted rectangle, used as focus ring of Ttk * widgets and for rendering the active element of a listbox. * * Results: * None. * * Side effects: * A dotted rectangle is drawn in the specified Drawable. On the * windowing systems x11 and aqua the GC components line_style, * line_width, dashes, and dash_offset are modified as needed. * *---------------------------------------------------------------------- */ func XTkDrawDottedRect(tls *libc.TLS, disp uintptr, d TDrawable, gc TGC, x int32, y int32, width int32, height int32) { bp := tls.Alloc(128) defer tls.Free(128) /* Width & height, _including the border_. */ var dx, dy, heightMod2, widthMod2, x2, y2 int32 var _ /* gcValues at bp+0 */ TXGCValues _, _, _, _, _, _ = dx, dy, heightMod2, widthMod2, x2, y2 widthMod2 = width % int32(2) heightMod2 = height % int32(2) x2 = x + width - int32(1) y2 = y + height - int32(1) (*(*TXGCValues)(unsafe.Pointer(bp))).Fline_style = int32(LineOnOffDash) (*(*TXGCValues)(unsafe.Pointer(bp))).Fline_width = int32(1) (*(*TXGCValues)(unsafe.Pointer(bp))).Fdashes = uint8(1) (*(*TXGCValues)(unsafe.Pointer(bp))).Fdash_offset = 0 libx11.XXChangeGC(tls, disp, gc, libc.Uint64FromInt64(libc.Int64FromInt64(1)< libc.Float64FromInt32(0) { v1 = libc.Xceil(tls, *(*float64)(unsafe.Pointer(bp))) } else { v1 = libc.Xfloor(tls, *(*float64)(unsafe.Pointer(bp))) } *(*int32)(unsafe.Pointer(intPtr)) = int32(v1) length = libc.Xstrlen(tls, *(*uintptr)(unsafe.Pointer(argv + 4*8))) c = libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(argv + 4*8))))) if c == int32('p') && libc.Xstrncmp(tls, *(*uintptr)(unsafe.Pointer(argv + 4*8)), __ccgo_ts+17116, length) == 0 { return int32(TK_SCROLL_PAGES) } else { if c == int32('u') && libc.Xstrncmp(tls, *(*uintptr)(unsafe.Pointer(argv + 4*8)), __ccgo_ts+17122, length) == 0 { return int32(TK_SCROLL_UNITS) } } libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+17128, libc.VaList(bp+16, *(*uintptr)(unsafe.Pointer(argv + 4*8))))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+16, __ccgo_ts+179, __ccgo_ts+182, __ccgo_ts+17170, libc.UintptrFromInt32(0))) return int32(TK_SCROLL_ERROR) } } libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+17183, libc.VaList(bp+16, *(*uintptr)(unsafe.Pointer(argv + 2*8))))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+16, __ccgo_ts+5785, __ccgo_ts+3058, __ccgo_ts+5789, __ccgo_ts+2689, *(*uintptr)(unsafe.Pointer(argv + 2*8)), libc.UintptrFromInt32(0))) return int32(TK_SCROLL_ERROR) } /* *---------------------------------------------------------------------- * * Tk_GetScrollInfoObj -- * * This function is invoked to parse "xview" and "yview" scrolling * commands for widgets using the new scrolling command syntax ("moveto" * or "scroll" options). * * Results: * The return value is either TK_SCROLL_MOVETO, TK_SCROLL_PAGES, * TK_SCROLL_UNITS, or TK_SCROLL_ERROR. This indicates whether the * command was successfully parsed and what form the command took. If * TK_SCROLL_MOVETO, *dblPtr is filled in with the desired position; if * TK_SCROLL_PAGES or TK_SCROLL_UNITS, *intPtr is filled in with the * number of lines to move (may be negative); if TK_SCROLL_ERROR, the * interp's result contains an error message. * * Side effects: * None. * *---------------------------------------------------------------------- */ func XTk_GetScrollInfoObj(tls *libc.TLS, interp uintptr, objc TTcl_Size, objv uintptr, dblPtr uintptr, intPtr uintptr) (r int32) { bp := tls.Alloc(80) defer tls.Free(80) /* Filled in with number of pages or lines to * scroll, if any. */ var arg uintptr var v1 float64 var _ /* d at bp+8 */ float64 var _ /* length at bp+0 */ TTcl_Size _, _ = arg, v1 if objc+int64(1) < int64(5) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(2), objv, __ccgo_ts+17229) return int32(TK_SCROLL_ERROR) } arg = libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp) if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(arg))) == libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(__ccgo_ts + 17015))) && !(libc.Xstrncmp(tls, arg, __ccgo_ts+17015, libc.Uint64FromInt64(*(*TTcl_Size)(unsafe.Pointer(bp)))) != 0) { if objc != int64(4) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(2), objv, __ccgo_ts+17057) return int32(TK_SCROLL_ERROR) } if libtcl9_0.XTcl_GetDoubleFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 3*8)), dblPtr) != TCL_OK { return int32(TK_SCROLL_ERROR) } return int32(TK_SCROLL_MOVETO) } else { if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(arg))) == libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(__ccgo_ts + 17083))) && !(libc.Xstrncmp(tls, arg, __ccgo_ts+17083, libc.Uint64FromInt64(*(*TTcl_Size)(unsafe.Pointer(bp)))) != 0) { if objc != int64(5) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(2), objv, __ccgo_ts+17090) return int32(TK_SCROLL_ERROR) } if libtcl9_0.XTcl_GetDoubleFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 3*8)), bp+8) != TCL_OK { return int32(TK_SCROLL_ERROR) } if *(*float64)(unsafe.Pointer(bp + 8)) >= libc.Float64FromInt32(0) { v1 = libc.Xceil(tls, *(*float64)(unsafe.Pointer(bp + 8))) } else { v1 = libc.Xfloor(tls, *(*float64)(unsafe.Pointer(bp + 8))) } *(*int32)(unsafe.Pointer(intPtr)) = int32(v1) if dblPtr != 0 { *(*float64)(unsafe.Pointer(dblPtr)) = *(*float64)(unsafe.Pointer(bp + 8)) } arg = libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 4*8)), bp) if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(arg))) == libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(__ccgo_ts + 17116))) && !(libc.Xstrncmp(tls, arg, __ccgo_ts+17116, libc.Uint64FromInt64(*(*TTcl_Size)(unsafe.Pointer(bp)))) != 0) { return int32(TK_SCROLL_PAGES) } else { if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(arg))) == libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(__ccgo_ts + 17122))) && !(libc.Xstrncmp(tls, arg, __ccgo_ts+17122, libc.Uint64FromInt64(*(*TTcl_Size)(unsafe.Pointer(bp)))) != 0) { return int32(TK_SCROLL_UNITS) } } libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+17128, libc.VaList(bp+24, arg))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+24, __ccgo_ts+179, __ccgo_ts+182, __ccgo_ts+17170, libc.UintptrFromInt32(0))) return int32(TK_SCROLL_ERROR) } } libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+17183, libc.VaList(bp+24, arg))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+24, __ccgo_ts+5785, __ccgo_ts+3058, __ccgo_ts+5789, __ccgo_ts+2689, arg, libc.UintptrFromInt32(0))) return int32(TK_SCROLL_ERROR) } /* *--------------------------------------------------------------------------- * * TkComputeAnchor -- * * Determine where to place a rectangle so that it will be properly * anchored with respect to the given window. Used by widgets to align a * box of text inside a window. When anchoring with respect to one of the * sides, the rectangle be placed inside of the internal border of the * window. * * Results: * *xPtr and *yPtr set to the upper-left corner of the rectangle anchored * in the window. * * Side effects: * None. * *--------------------------------------------------------------------------- */ func XTkComputeAnchor(tls *libc.TLS, anchor TTk_Anchor, tkwin TTk_Window, padX int32, padY int32, innerWidth int32, innerHeight int32, xPtr uintptr, yPtr uintptr) { /* Returns upper-left corner of anchored * rectangle. */ /* * Handle the horizontal parts. */ switch anchor { case int32(TK_ANCHOR_NW): fallthrough case int32(TK_ANCHOR_W): fallthrough case int32(TK_ANCHOR_SW): *(*int32)(unsafe.Pointer(xPtr)) = (*TTk_FakeWin)(unsafe.Pointer(tkwin)).FinternalBorderLeft + padX case int32(TK_ANCHOR_NE): fallthrough case int32(TK_ANCHOR_E): fallthrough case int32(TK_ANCHOR_SE): *(*int32)(unsafe.Pointer(xPtr)) = (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fchanges.Fwidth - (*TTk_FakeWin)(unsafe.Pointer(tkwin)).FinternalBorderRight - padX - innerWidth default: *(*int32)(unsafe.Pointer(xPtr)) = ((*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fchanges.Fwidth-innerWidth-(*TTk_FakeWin)(unsafe.Pointer(tkwin)).FinternalBorderLeft-(*TTk_FakeWin)(unsafe.Pointer(tkwin)).FinternalBorderRight)/int32(2) + (*TTk_FakeWin)(unsafe.Pointer(tkwin)).FinternalBorderLeft break } /* * Handle the vertical parts. */ switch anchor { case int32(TK_ANCHOR_NW): fallthrough case int32(TK_ANCHOR_N): fallthrough case int32(TK_ANCHOR_NE): *(*int32)(unsafe.Pointer(yPtr)) = (*TTk_FakeWin)(unsafe.Pointer(tkwin)).FinternalBorderTop + padY case int32(TK_ANCHOR_SW): fallthrough case int32(TK_ANCHOR_S): fallthrough case int32(TK_ANCHOR_SE): *(*int32)(unsafe.Pointer(yPtr)) = (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fchanges.Fheight - (*TTk_FakeWin)(unsafe.Pointer(tkwin)).FinternalBorderBottom - padY - innerHeight default: *(*int32)(unsafe.Pointer(yPtr)) = ((*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fchanges.Fheight-innerHeight-(*TTk_FakeWin)(unsafe.Pointer(tkwin)).FinternalBorderTop-(*TTk_FakeWin)(unsafe.Pointer(tkwin)).FinternalBorderBottom)/int32(2) + (*TTk_FakeWin)(unsafe.Pointer(tkwin)).FinternalBorderTop break } } /* *--------------------------------------------------------------------------- * * TkFindStateString -- * * Given a lookup table, map a number to a string in the table. * * Results: * If numKey was equal to the numeric key of one of the elements in the * table, returns the string key of that element. Returns NULL if numKey * was not equal to any of the numeric keys in the table. * * Side effects. * None. * *--------------------------------------------------------------------------- */ func XTkFindStateString(tls *libc.TLS, mapPtr uintptr, numKey int32) (r uintptr) { /* The key to try to find in the table. */ for { if !((*TTkStateMap)(unsafe.Pointer(mapPtr)).FstrKey != libc.UintptrFromInt32(0)) { break } if numKey == (*TTkStateMap)(unsafe.Pointer(mapPtr)).FnumKey { return (*TTkStateMap)(unsafe.Pointer(mapPtr)).FstrKey } goto _1 _1: ; mapPtr += 16 } return libc.UintptrFromInt32(0) } /* *--------------------------------------------------------------------------- * * TkFindStateNum, TkFindStateNumObj -- * * Given a lookup table, map a string to a number in the table. * * Results: * If strKey was equal to the string keys of one of the elements in the * table, returns the numeric key of that element. Returns the numKey * associated with the last element (the NULL string one) in the table if * strKey was not equal to any of the string keys in the table. In that * case, an error message is also left in the interp's result (if interp * is not NULL). * * Side effects. * None. * *--------------------------------------------------------------------------- */ func XTkFindStateNum(tls *libc.TLS, interp uintptr, option uintptr, mapPtr uintptr, strKey uintptr) (r int32) { bp := tls.Alloc(48) defer tls.Free(48) /* String to try to find in lookup table. */ var mPtr, msgObj, v3 uintptr _, _, _ = mPtr, msgObj, v3 /* * See if the value is in the state map. */ mPtr = mapPtr for { if !((*TTkStateMap)(unsafe.Pointer(mPtr)).FstrKey != libc.UintptrFromInt32(0)) { break } if libc.Xstrcmp(tls, strKey, (*TTkStateMap)(unsafe.Pointer(mPtr)).FstrKey) == 0 { return (*TTkStateMap)(unsafe.Pointer(mPtr)).FnumKey } goto _1 _1: ; mPtr += 16 } /* * Not there. Generate an error message (if we can) and return the * default. */ if interp != libc.UintptrFromInt32(0) { mPtr = mapPtr msgObj = libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+17248, libc.VaList(bp+8, option, strKey, (*TTkStateMap)(unsafe.Pointer(mPtr)).FstrKey)) mPtr += 16 for { if !((*TTkStateMap)(unsafe.Pointer(mPtr)).FstrKey != libc.UintptrFromInt32(0)) { break } if (*(*TTkStateMap)(unsafe.Pointer(mPtr + 1*16))).FstrKey != libc.UintptrFromInt32(0) { v3 = __ccgo_ts + 195 } else { v3 = __ccgo_ts + 17278 } libtcl9_0.XTcl_AppendPrintfToObj(tls, msgObj, __ccgo_ts+17282, libc.VaList(bp+8, v3, (*TTkStateMap)(unsafe.Pointer(mPtr)).FstrKey)) goto _2 _2: ; mPtr += 16 } libtcl9_0.XTcl_SetObjResult(tls, interp, msgObj) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+8, __ccgo_ts+179, __ccgo_ts+3058, option, strKey, libc.UintptrFromInt32(0))) } return (*TTkStateMap)(unsafe.Pointer(mPtr)).FnumKey } func XTkFindStateNumObj(tls *libc.TLS, interp uintptr, optionPtr uintptr, mapPtr uintptr, keyPtr uintptr) (r int32) { bp := tls.Alloc(48) defer tls.Free(48) /* String key to find in lookup table. */ var key, mPtr, msgObj, typePtr, v3 uintptr _, _, _, _, _ = key, mPtr, msgObj, typePtr, v3 /* * See if the value is in the object cache. */ if (*TTcl_Obj)(unsafe.Pointer(keyPtr)).FtypePtr == uintptr(unsafe.Pointer(&XtkStateKeyObjType)) && (*(*struct { Fptr1 uintptr Fptr2 uintptr })(unsafe.Pointer(keyPtr + 32))).Fptr1 == mapPtr { return int32(int64((*(*struct { Fptr1 uintptr Fptr2 uintptr })(unsafe.Pointer(keyPtr + 32))).Fptr2)) } /* * Not there. Look in the state map. */ key = libtcl9_0.XTcl_GetStringFromObj(tls, keyPtr, libc.UintptrFromInt32(0)) mPtr = mapPtr for { if !((*TTkStateMap)(unsafe.Pointer(mPtr)).FstrKey != libc.UintptrFromInt32(0)) { break } if libc.Xstrcmp(tls, key, (*TTkStateMap)(unsafe.Pointer(mPtr)).FstrKey) == 0 { typePtr = (*TTcl_Obj)(unsafe.Pointer(keyPtr)).FtypePtr if typePtr != libc.UintptrFromInt32(0) && (*TTcl_ObjType)(unsafe.Pointer(typePtr)).FfreeIntRepProc != libc.UintptrFromInt32(0) { (*(*func(*libc.TLS, uintptr))(unsafe.Pointer(&struct{ uintptr }{(*TTcl_ObjType)(unsafe.Pointer(typePtr)).FfreeIntRepProc})))(tls, keyPtr) } (*(*struct { Fptr1 uintptr Fptr2 uintptr })(unsafe.Pointer(keyPtr + 32))).Fptr1 = mapPtr (*(*struct { Fptr1 uintptr Fptr2 uintptr })(unsafe.Pointer(keyPtr + 32))).Fptr2 = uintptr(int64((*TTkStateMap)(unsafe.Pointer(mPtr)).FnumKey)) (*TTcl_Obj)(unsafe.Pointer(keyPtr)).FtypePtr = uintptr(unsafe.Pointer(&XtkStateKeyObjType)) return (*TTkStateMap)(unsafe.Pointer(mPtr)).FnumKey } goto _1 _1: ; mPtr += 16 } /* * Not there either. Generate an error message (if we can) and return the * default. */ if interp != libc.UintptrFromInt32(0) { mPtr = mapPtr msgObj = libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+17248, libc.VaList(bp+8, libtcl9_0.XTcl_GetStringFromObj(tls, optionPtr, libc.UintptrFromInt32(0)), key, (*TTkStateMap)(unsafe.Pointer(mPtr)).FstrKey)) mPtr += 16 for { if !((*TTkStateMap)(unsafe.Pointer(mPtr)).FstrKey != libc.UintptrFromInt32(0)) { break } if (*(*TTkStateMap)(unsafe.Pointer(mPtr + 1*16))).FstrKey != libc.UintptrFromInt32(0) { v3 = __ccgo_ts + 195 } else { v3 = __ccgo_ts + 17289 } libtcl9_0.XTcl_AppendPrintfToObj(tls, msgObj, __ccgo_ts+17282, libc.VaList(bp+8, v3, (*TTkStateMap)(unsafe.Pointer(mPtr)).FstrKey)) goto _2 _2: ; mPtr += 16 } libtcl9_0.XTcl_SetObjResult(tls, interp, msgObj) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+8, __ccgo_ts+179, __ccgo_ts+3058, libtcl9_0.XTcl_GetStringFromObj(tls, optionPtr, libc.UintptrFromInt32(0)), key, libc.UintptrFromInt32(0))) } return (*TTkStateMap)(unsafe.Pointer(mPtr)).FnumKey } /* * ---------------------------------------------------------------------- * * TkBackgroundEvalObjv -- * * Evaluate a command while ensuring that we do not affect the * interpreters state. This is important when evaluating script * during background tasks. * * Results: * A standard Tcl result code. * * Side Effects: * The interpreters variables and code may be modified by the script * but the result will not be modified. * * ---------------------------------------------------------------------- */ func XTkBackgroundEvalObjv(tls *libc.TLS, interp uintptr, objc TTcl_Size, objv uintptr, flags int32) (r1 int32) { var _objPtr, v4 uintptr var n, v3 TTcl_Size var r int32 var state TTcl_InterpState _, _, _, _, _, _ = _objPtr, n, r, state, v3, v4 r = TCL_OK /* * Record the state of the interpreter. */ libtcl9_0.XTcl_Preserve(tls, interp) state = libtcl9_0.XTcl_SaveInterpState(tls, interp, TCL_OK) /* * Evaluate the command and handle any error. */ n = 0 for { if !(n < objc) { break } (*TTcl_Obj)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(objv + uintptr(n)*8)))).FrefCount++ goto _1 _1: ; n++ } r = libtcl9_0.XTcl_EvalObjv(tls, interp, objc, objv, flags) n = 0 for { if !(n < objc) { break } _objPtr = *(*uintptr)(unsafe.Pointer(objv + uintptr(n)*8)) v4 = _objPtr v3 = *(*TTcl_Size)(unsafe.Pointer(v4)) *(*TTcl_Size)(unsafe.Pointer(v4))-- if v3 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr) } goto _2 _2: ; n++ } if r == int32(TCL_ERROR) { libtcl9_0.XTcl_AppendObjToErrorInfo(tls, interp, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+17293, int64(-int32(1)))) libtcl9_0.XTcl_BackgroundException(tls, interp, r) } /* * Restore the state of the interpreter. */ libtcl9_0.XTcl_RestoreInterpState(tls, interp, state) libtcl9_0.XTcl_Release(tls, interp) return r } /* *---------------------------------------------------------------------- * * TkMakeEnsemble -- * * Create an ensemble from a table of implementation commands. This may * be called recursively to create sub-ensembles. * * Results: * Handle for the ensemble, or NULL if creation of it fails. * *---------------------------------------------------------------------- */ func XTkMakeEnsemble(tls *libc.TLS, interp uintptr, namesp uintptr, name uintptr, clientData uintptr, map1 uintptr) (r TTcl_Command) { bp := tls.Alloc(256) defer tls.Free(256) var _objPtr, dictObj, fqdnObj, nameObj, namespacePtr, v2 uintptr var ensemble TTcl_Command var i int32 var v1 TTcl_Size var _ /* ds at bp+0 */ TTcl_DString _, _, _, _, _, _, _, _, _ = _objPtr, dictObj, ensemble, fqdnObj, i, nameObj, namespacePtr, v1, v2 namespacePtr = libc.UintptrFromInt32(0) ensemble = libc.UintptrFromInt32(0) dictObj = libc.UintptrFromInt32(0) if map1 == libc.UintptrFromInt32(0) { return libc.UintptrFromInt32(0) } libtcl9_0.XTcl_DStringInit(tls, bp) namespacePtr = libtcl9_0.XTcl_FindNamespace(tls, interp, namesp, libc.UintptrFromInt32(0), 0) if namespacePtr == libc.UintptrFromInt32(0) { namespacePtr = libtcl9_0.XTcl_CreateNamespace(tls, interp, namesp, libc.UintptrFromInt32(0), libc.UintptrFromInt32(0)) if namespacePtr == libc.UintptrFromInt32(0) { libtcl9_0.XTcl_Panic(tls, __ccgo_ts+17325, libc.VaList(bp+232, namesp)) } } nameObj = libtcl9_0.XTcl_NewStringObj(tls, name, int64(-libc.Int32FromInt32(1))) ensemble = libtcl9_0.XTcl_FindEnsemble(tls, interp, nameObj, 0) _objPtr = nameObj v2 = _objPtr v1 = *(*TTcl_Size)(unsafe.Pointer(v2)) *(*TTcl_Size)(unsafe.Pointer(v2))-- if v1 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr) } if ensemble == libc.UintptrFromInt32(0) { ensemble = libtcl9_0.XTcl_CreateEnsemble(tls, interp, name, namespacePtr, int32(TCL_ENSEMBLE_PREFIX)) if ensemble == libc.UintptrFromInt32(0) { libtcl9_0.XTcl_Panic(tls, __ccgo_ts+17357, libc.VaList(bp+232, name)) } } libtcl9_0.XTcl_DStringSetLength(tls, bp, 0) libtcl9_0.XTcl_DStringAppend(tls, bp, namesp, int64(-libc.Int32FromInt32(1))) if !(libc.Xstrlen(tls, namesp) == uint64(2) && libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(namesp + 1))) == int32(':')) { libtcl9_0.XTcl_DStringAppend(tls, bp, __ccgo_ts+5388, int64(-libc.Int32FromInt32(1))) } libtcl9_0.XTcl_DStringAppend(tls, bp, name, int64(-libc.Int32FromInt32(1))) dictObj = libtcl9_0.XTcl_NewObj(tls) i = 0 for { if !((*(*TTkEnsemble)(unsafe.Pointer(map1 + uintptr(i)*24))).Fname != libc.UintptrFromInt32(0)) { break } nameObj = libtcl9_0.XTcl_NewStringObj(tls, (*(*TTkEnsemble)(unsafe.Pointer(map1 + uintptr(i)*24))).Fname, int64(-libc.Int32FromInt32(1))) fqdnObj = libtcl9_0.XTcl_NewStringObj(tls, (*TTcl_DString)(unsafe.Pointer(bp)).Fstring1, (*TTcl_DString)(unsafe.Pointer(bp)).Flength) libtcl9_0.XTcl_AppendStringsToObj(tls, fqdnObj, libc.VaList(bp+232, __ccgo_ts+5388, (*(*TTkEnsemble)(unsafe.Pointer(map1 + uintptr(i)*24))).Fname, libc.UintptrFromInt32(0))) libtcl9_0.XTcl_DictObjPut(tls, libc.UintptrFromInt32(0), dictObj, nameObj, fqdnObj) if (*(*TTkEnsemble)(unsafe.Pointer(map1 + uintptr(i)*24))).Fproc != 0 { libtcl9_0.XTcl_CreateObjCommand2(tls, interp, libtcl9_0.XTcl_GetStringFromObj(tls, fqdnObj, libc.UintptrFromInt32(0)), (*(*TTkEnsemble)(unsafe.Pointer(map1 + uintptr(i)*24))).Fproc, clientData, libc.UintptrFromInt32(0)) } else { if (*(*TTkEnsemble)(unsafe.Pointer(map1 + uintptr(i)*24))).Fsubensemble != 0 { XTkMakeEnsemble(tls, interp, (*TTcl_DString)(unsafe.Pointer(bp)).Fstring1, (*(*TTkEnsemble)(unsafe.Pointer(map1 + uintptr(i)*24))).Fname, clientData, (*(*TTkEnsemble)(unsafe.Pointer(map1 + uintptr(i)*24))).Fsubensemble) } } goto _3 _3: ; i++ } if ensemble != 0 { libtcl9_0.XTcl_SetEnsembleMappingDict(tls, interp, ensemble, dictObj) } libtcl9_0.XTcl_DStringFree(tls, bp) return ensemble } /* *---------------------------------------------------------------------- * * TkScalingLevel -- * * Returns the display's DPI scaling level as 1.0, 1.25, 1.5, .... * * Results: * The scaling level. * * Side effects: * None. * *---------------------------------------------------------------------- */ func XTkScalingLevel(tls *libc.TLS, tkwin TTk_Window) (r float64) { bp := tls.Alloc(16) defer tls.Free(16) var interp, scalingPctPtr uintptr var _ /* scalingPct at bp+0 */ int32 _, _ = interp, scalingPctPtr interp = XTk_Interp(tls, tkwin) scalingPctPtr = libtcl9_0.XTcl_GetVar2Ex(tls, interp, __ccgo_ts+5577, libc.UintptrFromInt32(0), int32(TCL_GLOBAL_ONLY)) if scalingPctPtr == libc.UintptrFromInt32(0) { return float64(1) } else { libtcl9_0.XTcl_GetIntFromObj(tls, interp, scalingPctPtr, bp) return float64(*(*int32)(unsafe.Pointer(bp))) / float64(100) } return r } /* *---------------------------------------------------------------------- * * Tk_SendVirtualEvent -- * * Send a virtual event notification to the specified target window. * Equivalent to: * "event generate $target <<$eventName>> -data $detail" * * Note that we use Tk_QueueWindowEvent, not Tk_HandleEvent, so this * routine does not reenter the interpreter. * *---------------------------------------------------------------------- */ func XTk_SendVirtualEvent(tls *libc.TLS, target TTk_Window, eventName uintptr, detail uintptr) { bp := tls.Alloc(192) defer tls.Free(192) var _ /* event at bp+0 */ struct { Fvirt [0]TXVirtualEvent Fgeneral TXEvent } libc.Xmemset(tls, bp, 0, uint64(192)) (*(*TXAnyEvent)(unsafe.Pointer(&*(*TXEvent)(unsafe.Pointer(bp))))).Ftype1 = libc.Int32FromInt32(MappingNotify) + libc.Int32FromInt32(1) (*(*TXAnyEvent)(unsafe.Pointer(&*(*TXEvent)(unsafe.Pointer(bp))))).Fserial = (*struct { Fext_data uintptr Fprivate1 uintptr Ffd int32 Fprivate2 int32 Fproto_major_version int32 Fproto_minor_version int32 Fvendor uintptr Fprivate3 TXID Fprivate4 TXID Fprivate5 TXID Fprivate6 int32 Fresource_alloc uintptr Fbyte_order int32 Fbitmap_unit int32 Fbitmap_pad int32 Fbitmap_bit_order int32 Fnformats int32 Fpixmap_format uintptr Fprivate8 int32 Frelease int32 Fprivate9 uintptr Fprivate10 uintptr Fqlen int32 Flast_request_read uint64 Frequest uint64 Fprivate11 TXPointer Fprivate12 TXPointer Fprivate13 TXPointer Fprivate14 TXPointer Fmax_request_size uint32 Fdb uintptr Fprivate15 uintptr Fdisplay_name uintptr Fdefault_screen int32 Fnscreens int32 Fscreens uintptr Fmotion_buffer uint64 Fprivate16 uint64 Fmin_keycode int32 Fmax_keycode int32 Fprivate17 TXPointer Fprivate18 TXPointer Fprivate19 int32 Fxdefaults uintptr })(unsafe.Pointer((*TTk_FakeWin)(unsafe.Pointer(target)).Fdisplay)).Frequest + uint64(1) (*(*TXAnyEvent)(unsafe.Pointer(&*(*TXEvent)(unsafe.Pointer(bp))))).Fsend_event = False (*(*TXAnyEvent)(unsafe.Pointer(&*(*TXEvent)(unsafe.Pointer(bp))))).Fwindow = (*TTk_FakeWin)(unsafe.Pointer(target)).Fwindow (*(*TXAnyEvent)(unsafe.Pointer(&*(*TXEvent)(unsafe.Pointer(bp))))).Fdisplay = (*TTk_FakeWin)(unsafe.Pointer(target)).Fdisplay (*(*TXVirtualEvent)(unsafe.Pointer(&*(*struct { Fvirt [0]TXVirtualEvent Fgeneral TXEvent })(unsafe.Pointer(bp))))).Fname = XTk_GetUid(tls, eventName) (*(*TXVirtualEvent)(unsafe.Pointer(&*(*struct { Fvirt [0]TXVirtualEvent Fgeneral TXEvent })(unsafe.Pointer(bp))))).Fuser_data = detail if detail != 0 { (*TTcl_Obj)(unsafe.Pointer(detail)).FrefCount++ } // Event code will DecrRefCount XTk_QueueWindowEvent(tls, bp, int32(TCL_QUEUE_TAIL)) } type TTkColormap = struct { Fcolormap TColormap Fvisual uintptr FrefCount Tsize_t Fshareable int32 FnextPtr uintptr } /* * Local Variables: * mode: c * c-basic-offset: 4 * fill-column: 78 * End: */ /* * The table below maps from symbolic names for visual classes to the * associated X class symbols. */ type TVisualDictionary = struct { Fname [12]uint8 FminLength uint16 Fclass int16 } var _visualNames = [10]TVisualDictionary{ 0: { Fname: [12]uint8{'b', 'e', 's', 't'}, FminLength: uint16(1), }, 1: { Fname: [12]uint8{'d', 'i', 'r', 'e', 'c', 't', 'c', 'o', 'l', 'o', 'r'}, FminLength: uint16(2), Fclass: int16(DirectColor), }, 2: { Fname: [12]uint8{'g', 'r', 'a', 'y', 's', 'c', 'a', 'l', 'e'}, FminLength: uint16(1), Fclass: int16(GrayScale), }, 3: { Fname: [12]uint8{'g', 'r', 'e', 'y', 's', 'c', 'a', 'l', 'e'}, FminLength: uint16(1), Fclass: int16(GrayScale), }, 4: { Fname: [12]uint8{'p', 's', 'e', 'u', 'd', 'o', 'c', 'o', 'l', 'o', 'r'}, FminLength: uint16(1), Fclass: int16(PseudoColor), }, 5: { Fname: [12]uint8{'s', 't', 'a', 't', 'i', 'c', 'c', 'o', 'l', 'o', 'r'}, FminLength: uint16(7), Fclass: int16(StaticColor), }, 6: { Fname: [12]uint8{'s', 't', 'a', 't', 'i', 'c', 'g', 'r', 'a', 'y'}, FminLength: uint16(7), }, 7: { Fname: [12]uint8{'s', 't', 'a', 't', 'i', 'c', 'g', 'r', 'e', 'y'}, FminLength: uint16(7), }, 8: { Fname: [12]uint8{'t', 'r', 'u', 'e', 'c', 'o', 'l', 'o', 'r'}, FminLength: uint16(1), Fclass: int16(TrueColor), }, 9: { Fname: [12]uint8{}, }, } /* * One of the following structures exists for each distinct non-default * colormap allocated for a display by Tk_GetColormap. */ type TTkColormap1 = struct { Fcolormap TColormap Fvisual uintptr FrefCount Tsize_t Fshareable int32 FnextPtr uintptr } /* *---------------------------------------------------------------------- * * Tk_GetVisual -- * * Given a string identifying a particular kind of visual, this procedure * returns a visual and depth that matches the specification. * * Results: * The return value is normally a pointer to a visual. If an error * occurred in looking up the visual, NULL is returned and an error * message is left in the interp's result. The depth of the visual is * returned to *depthPtr under normal returns. If colormapPtr is * non-NULL, then this procedure also finds a suitable colormap for use * with the visual in tkwin, and it returns that colormap in *colormapPtr * unless an error occurs. * * Side effects: * A new colormap may be allocated. * *---------------------------------------------------------------------- */ func XTk_GetVisual(tls *libc.TLS, interp uintptr, tkwin TTk_Window, string1 uintptr, depthPtr uintptr, colormapPtr uintptr) (r uintptr) { bp := tls.Alloc(128) defer tls.Free(128) /* If non-NULL, then a suitable colormap for * visual is placed here. This colormap must * eventually be freed by calling * Tk_FreeColormap. */ var bestPrio, c, i, prio, v3, v4, v8, v9 int32 var bestPtr, cmapPtr, dictPtr, dispPtr, msgObj, p, visInfoList, visual uintptr var length Tsize_t var mask int64 var tkwin2 TTk_Window var _ /* numVisuals at bp+64 */ int32 var _ /* templ at bp+0 */ TXVisualInfo var _ /* visualId at bp+68 */ int32 _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = bestPrio, bestPtr, c, cmapPtr, dictPtr, dispPtr, i, length, mask, msgObj, p, prio, tkwin2, visInfoList, visual, v3, v4, v8, v9 dispPtr = (*TTkWindow)(unsafe.Pointer(tkwin)).FdispPtr /* * Parse string and set up a template for use in searching for an * appropriate visual. */ c = libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(string1))) if c == int32('.') { /* * The string must be a window name. If the window is on the same * screen as tkwin, then just use its visual. Otherwise use the * information about the visual as a template for the search. */ tkwin2 = XTk_NameToWindow(tls, interp, string1, tkwin) if tkwin2 == libc.UintptrFromInt32(0) { return libc.UintptrFromInt32(0) } visual = (*TTk_FakeWin)(unsafe.Pointer(tkwin2)).Fvisual if (*struct { Fext_data uintptr Fprivate1 uintptr Ffd int32 Fprivate2 int32 Fproto_major_version int32 Fproto_minor_version int32 Fvendor uintptr Fprivate3 TXID Fprivate4 TXID Fprivate5 TXID Fprivate6 int32 Fresource_alloc uintptr Fbyte_order int32 Fbitmap_unit int32 Fbitmap_pad int32 Fbitmap_bit_order int32 Fnformats int32 Fpixmap_format uintptr Fprivate8 int32 Frelease int32 Fprivate9 uintptr Fprivate10 uintptr Fqlen int32 Flast_request_read uint64 Frequest uint64 Fprivate11 TXPointer Fprivate12 TXPointer Fprivate13 TXPointer Fprivate14 TXPointer Fmax_request_size uint32 Fdb uintptr Fprivate15 uintptr Fdisplay_name uintptr Fdefault_screen int32 Fnscreens int32 Fscreens uintptr Fmotion_buffer uint64 Fprivate16 uint64 Fmin_keycode int32 Fmax_keycode int32 Fprivate17 TXPointer Fprivate18 TXPointer Fprivate19 int32 Fxdefaults uintptr })(unsafe.Pointer((*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fdisplay)).Fscreens+uintptr((*TTk_FakeWin)(unsafe.Pointer(tkwin)).FscreenNum)*128 == (*struct { Fext_data uintptr Fprivate1 uintptr Ffd int32 Fprivate2 int32 Fproto_major_version int32 Fproto_minor_version int32 Fvendor uintptr Fprivate3 TXID Fprivate4 TXID Fprivate5 TXID Fprivate6 int32 Fresource_alloc uintptr Fbyte_order int32 Fbitmap_unit int32 Fbitmap_pad int32 Fbitmap_bit_order int32 Fnformats int32 Fpixmap_format uintptr Fprivate8 int32 Frelease int32 Fprivate9 uintptr Fprivate10 uintptr Fqlen int32 Flast_request_read uint64 Frequest uint64 Fprivate11 TXPointer Fprivate12 TXPointer Fprivate13 TXPointer Fprivate14 TXPointer Fmax_request_size uint32 Fdb uintptr Fprivate15 uintptr Fdisplay_name uintptr Fdefault_screen int32 Fnscreens int32 Fscreens uintptr Fmotion_buffer uint64 Fprivate16 uint64 Fmin_keycode int32 Fmax_keycode int32 Fprivate17 TXPointer Fprivate18 TXPointer Fprivate19 int32 Fxdefaults uintptr })(unsafe.Pointer((*TTk_FakeWin)(unsafe.Pointer(tkwin2)).Fdisplay)).Fscreens+uintptr((*TTk_FakeWin)(unsafe.Pointer(tkwin2)).FscreenNum)*128 { *(*int32)(unsafe.Pointer(depthPtr)) = (*TTk_FakeWin)(unsafe.Pointer(tkwin2)).Fdepth if colormapPtr != libc.UintptrFromInt32(0) { /* * Use the colormap from the other window too (but be sure to * increment its reference count if it's one of the ones * allocated here). */ *(*TColormap)(unsafe.Pointer(colormapPtr)) = (*TTk_FakeWin)(unsafe.Pointer(tkwin2)).Fatts.Fcolormap cmapPtr = (*TTkDisplay)(unsafe.Pointer(dispPtr)).FcmapPtr for { if !(cmapPtr != libc.UintptrFromInt32(0)) { break } if (*TTkColormap)(unsafe.Pointer(cmapPtr)).Fcolormap == *(*TColormap)(unsafe.Pointer(colormapPtr)) { (*TTkColormap)(unsafe.Pointer(cmapPtr)).FrefCount++ break } goto _1 _1: ; cmapPtr = (*TTkColormap)(unsafe.Pointer(cmapPtr)).FnextPtr } } return visual } (*(*TXVisualInfo)(unsafe.Pointer(bp))).Fdepth = (*TTk_FakeWin)(unsafe.Pointer(tkwin2)).Fdepth (*(*TXVisualInfo)(unsafe.Pointer(bp))).Fclass = (*TVisual)(unsafe.Pointer(visual)).Fclass (*(*TXVisualInfo)(unsafe.Pointer(bp))).Fred_mask = (*TVisual)(unsafe.Pointer(visual)).Fred_mask (*(*TXVisualInfo)(unsafe.Pointer(bp))).Fgreen_mask = (*TVisual)(unsafe.Pointer(visual)).Fgreen_mask (*(*TXVisualInfo)(unsafe.Pointer(bp))).Fblue_mask = (*TVisual)(unsafe.Pointer(visual)).Fblue_mask (*(*TXVisualInfo)(unsafe.Pointer(bp))).Fcolormap_size = (*TVisual)(unsafe.Pointer(visual)).Fmap_entries (*(*TXVisualInfo)(unsafe.Pointer(bp))).Fbits_per_rgb = (*TVisual)(unsafe.Pointer(visual)).Fbits_per_rgb mask = int64(libc.Int32FromInt32(VisualDepthMask) | libc.Int32FromInt32(VisualClassMask) | libc.Int32FromInt32(VisualRedMaskMask) | libc.Int32FromInt32(VisualGreenMaskMask) | libc.Int32FromInt32(VisualBlueMaskMask) | libc.Int32FromInt32(VisualColormapSizeMask) | libc.Int32FromInt32(VisualBitsPerRGBMask)) } else { if c == 0 || c == int32('d') && libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(string1 + 1))) != 0 && libc.Xstrncmp(tls, string1, __ccgo_ts+17388, libc.Xstrlen(tls, string1)) == 0 { /* * Use the default visual for the window's screen. */ if colormapPtr != libc.UintptrFromInt32(0) { *(*TColormap)(unsafe.Pointer(colormapPtr)) = (*TScreen)(unsafe.Pointer((*struct { Fext_data uintptr Fprivate1 uintptr Ffd int32 Fprivate2 int32 Fproto_major_version int32 Fproto_minor_version int32 Fvendor uintptr Fprivate3 TXID Fprivate4 TXID Fprivate5 TXID Fprivate6 int32 Fresource_alloc uintptr Fbyte_order int32 Fbitmap_unit int32 Fbitmap_pad int32 Fbitmap_bit_order int32 Fnformats int32 Fpixmap_format uintptr Fprivate8 int32 Frelease int32 Fprivate9 uintptr Fprivate10 uintptr Fqlen int32 Flast_request_read uint64 Frequest uint64 Fprivate11 TXPointer Fprivate12 TXPointer Fprivate13 TXPointer Fprivate14 TXPointer Fmax_request_size uint32 Fdb uintptr Fprivate15 uintptr Fdisplay_name uintptr Fdefault_screen int32 Fnscreens int32 Fscreens uintptr Fmotion_buffer uint64 Fprivate16 uint64 Fmin_keycode int32 Fmax_keycode int32 Fprivate17 TXPointer Fprivate18 TXPointer Fprivate19 int32 Fxdefaults uintptr })(unsafe.Pointer((*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fdisplay)).Fscreens + uintptr((*TTk_FakeWin)(unsafe.Pointer(tkwin)).FscreenNum)*128)).Fcmap } *(*int32)(unsafe.Pointer(depthPtr)) = (*TScreen)(unsafe.Pointer((*struct { Fext_data uintptr Fprivate1 uintptr Ffd int32 Fprivate2 int32 Fproto_major_version int32 Fproto_minor_version int32 Fvendor uintptr Fprivate3 TXID Fprivate4 TXID Fprivate5 TXID Fprivate6 int32 Fresource_alloc uintptr Fbyte_order int32 Fbitmap_unit int32 Fbitmap_pad int32 Fbitmap_bit_order int32 Fnformats int32 Fpixmap_format uintptr Fprivate8 int32 Frelease int32 Fprivate9 uintptr Fprivate10 uintptr Fqlen int32 Flast_request_read uint64 Frequest uint64 Fprivate11 TXPointer Fprivate12 TXPointer Fprivate13 TXPointer Fprivate14 TXPointer Fmax_request_size uint32 Fdb uintptr Fprivate15 uintptr Fdisplay_name uintptr Fdefault_screen int32 Fnscreens int32 Fscreens uintptr Fmotion_buffer uint64 Fprivate16 uint64 Fmin_keycode int32 Fmax_keycode int32 Fprivate17 TXPointer Fprivate18 TXPointer Fprivate19 int32 Fxdefaults uintptr })(unsafe.Pointer((*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fdisplay)).Fscreens + uintptr((*TTk_FakeWin)(unsafe.Pointer(tkwin)).FscreenNum)*128)).Froot_depth return (*TScreen)(unsafe.Pointer((*struct { Fext_data uintptr Fprivate1 uintptr Ffd int32 Fprivate2 int32 Fproto_major_version int32 Fproto_minor_version int32 Fvendor uintptr Fprivate3 TXID Fprivate4 TXID Fprivate5 TXID Fprivate6 int32 Fresource_alloc uintptr Fbyte_order int32 Fbitmap_unit int32 Fbitmap_pad int32 Fbitmap_bit_order int32 Fnformats int32 Fpixmap_format uintptr Fprivate8 int32 Frelease int32 Fprivate9 uintptr Fprivate10 uintptr Fqlen int32 Flast_request_read uint64 Frequest uint64 Fprivate11 TXPointer Fprivate12 TXPointer Fprivate13 TXPointer Fprivate14 TXPointer Fmax_request_size uint32 Fdb uintptr Fprivate15 uintptr Fdisplay_name uintptr Fdefault_screen int32 Fnscreens int32 Fscreens uintptr Fmotion_buffer uint64 Fprivate16 uint64 Fmin_keycode int32 Fmax_keycode int32 Fprivate17 TXPointer Fprivate18 TXPointer Fprivate19 int32 Fxdefaults uintptr })(unsafe.Pointer((*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fdisplay)).Fscreens + uintptr((*TTk_FakeWin)(unsafe.Pointer(tkwin)).FscreenNum)*128)).Froot_visual } else { if libc.BoolInt32(uint32(libc.Uint8FromInt32(c))-uint32('0') < uint32(10)) != 0 { /* * This is a visual ID. */ if libtcl9_0.XTcl_GetInt(tls, interp, string1, bp+68) == int32(TCL_ERROR) { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+17396, libc.VaList(bp+80, string1))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+80, __ccgo_ts+179, __ccgo_ts+182, __ccgo_ts+1055, libc.UintptrFromInt32(0))) return libc.UintptrFromInt32(0) } (*(*TXVisualInfo)(unsafe.Pointer(bp))).Fvisualid = libc.Uint64FromInt32(*(*int32)(unsafe.Pointer(bp + 68))) mask = int64(VisualIDMask) } else { /* * Parse the string into a class name (or "best") optionally followed * by whitespace and a depth. */ p = string1 for { if !(libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(p))) != 0) { break } v3 = libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(p))) v4 = libc.BoolInt32(v3 == int32(' ') || libc.Uint32FromInt32(v3)-uint32('\t') < uint32(5)) goto _5 _5: ; if v4 != 0 || libc.BoolInt32(uint32(*(*uint8)(unsafe.Pointer(p)))-uint32('0') < uint32(10)) != 0 { break } goto _2 _2: ; p++ } length = libc.Uint64FromInt64(int64(p) - int64(string1)) (*(*TXVisualInfo)(unsafe.Pointer(bp))).Fclass = -int32(1) dictPtr = uintptr(unsafe.Pointer(&_visualNames)) for { if !((*TVisualDictionary)(unsafe.Pointer(dictPtr)).FminLength != 0) { break } if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(dictPtr))) == c && length >= uint64((*TVisualDictionary)(unsafe.Pointer(dictPtr)).FminLength) && libc.Xstrncmp(tls, string1, dictPtr, length) == 0 { (*(*TXVisualInfo)(unsafe.Pointer(bp))).Fclass = int32((*TVisualDictionary)(unsafe.Pointer(dictPtr)).Fclass) break } goto _6 _6: ; dictPtr += 16 } if (*(*TXVisualInfo)(unsafe.Pointer(bp))).Fclass == -int32(1) { msgObj = libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+17430, libc.VaList(bp+80, string1)) dictPtr = uintptr(unsafe.Pointer(&_visualNames)) for { if !((*TVisualDictionary)(unsafe.Pointer(dictPtr)).FminLength != 0) { break } libtcl9_0.XTcl_AppendPrintfToObj(tls, msgObj, __ccgo_ts+17484, libc.VaList(bp+80, dictPtr)) goto _7 _7: ; dictPtr += 16 } libtcl9_0.XTcl_AppendToObj(tls, msgObj, __ccgo_ts+17489, int64(-libc.Int32FromInt32(1))) libtcl9_0.XTcl_SetObjResult(tls, interp, msgObj) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+80, __ccgo_ts+179, __ccgo_ts+3058, __ccgo_ts+6785, string1, libc.UintptrFromInt32(0))) return libc.UintptrFromInt32(0) } for { v8 = libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(p))) v9 = libc.BoolInt32(v8 == int32(' ') || libc.Uint32FromInt32(v8)-uint32('\t') < uint32(5)) goto _10 _10: if !(v9 != 0) { break } p++ } if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(p))) == 0 { (*(*TXVisualInfo)(unsafe.Pointer(bp))).Fdepth = int32(10000) } else { if libtcl9_0.XTcl_GetInt(tls, interp, p, bp+20) != TCL_OK { return libc.UintptrFromInt32(0) } } if c == int32('b') { mask = 0 } else { mask = int64(VisualClassMask) } } } } /* * Find all visuals that match the template we've just created, and return * an error if there are none that match. */ (*(*TXVisualInfo)(unsafe.Pointer(bp))).Fscreen = (*TTk_FakeWin)(unsafe.Pointer(tkwin)).FscreenNum mask |= int64(VisualScreenMask) visInfoList = libx11.XXGetVisualInfo(tls, (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fdisplay, mask, bp, bp+64) if visInfoList == libc.UintptrFromInt32(0) { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+17500, int64(-libc.Int32FromInt32(1)))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+80, __ccgo_ts+179, __ccgo_ts+6785, __ccgo_ts+17536, libc.UintptrFromInt32(0))) return libc.UintptrFromInt32(0) } /* * Search through the visuals that were returned to find the best one. * The choice is based on the following criteria, in decreasing order of * importance: * * 1. Depth: choose a visual with exactly the desired depth, else one with * more bits than requested but as few bits as possible, else one with * fewer bits but as many as possible. * 2. Class: some visual classes are more desirable than others; pick the * visual with the most desirable class. * 3. Default: the default visual for the screen gets preference over * other visuals, all else being equal. */ bestPrio = 0 bestPtr = libc.UintptrFromInt32(0) i = 0 for { if !(i < *(*int32)(unsafe.Pointer(bp + 64))) { break } switch (*(*TXVisualInfo)(unsafe.Pointer(visInfoList + uintptr(i)*64))).Fclass { case int32(DirectColor): prio = int32(5) case int32(GrayScale): prio = int32(1) case int32(PseudoColor): prio = int32(7) case int32(StaticColor): prio = int32(3) case StaticGray: prio = int32(1) case int32(TrueColor): prio = int32(5) default: prio = 0 break } if (*(*TXVisualInfo)(unsafe.Pointer(visInfoList + uintptr(i)*64))).Fvisual == (*TScreen)(unsafe.Pointer((*struct { Fext_data uintptr Fprivate1 uintptr Ffd int32 Fprivate2 int32 Fproto_major_version int32 Fproto_minor_version int32 Fvendor uintptr Fprivate3 TXID Fprivate4 TXID Fprivate5 TXID Fprivate6 int32 Fresource_alloc uintptr Fbyte_order int32 Fbitmap_unit int32 Fbitmap_pad int32 Fbitmap_bit_order int32 Fnformats int32 Fpixmap_format uintptr Fprivate8 int32 Frelease int32 Fprivate9 uintptr Fprivate10 uintptr Fqlen int32 Flast_request_read uint64 Frequest uint64 Fprivate11 TXPointer Fprivate12 TXPointer Fprivate13 TXPointer Fprivate14 TXPointer Fmax_request_size uint32 Fdb uintptr Fprivate15 uintptr Fdisplay_name uintptr Fdefault_screen int32 Fnscreens int32 Fscreens uintptr Fmotion_buffer uint64 Fprivate16 uint64 Fmin_keycode int32 Fmax_keycode int32 Fprivate17 TXPointer Fprivate18 TXPointer Fprivate19 int32 Fxdefaults uintptr })(unsafe.Pointer((*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fdisplay)).Fscreens+uintptr((*TTk_FakeWin)(unsafe.Pointer(tkwin)).FscreenNum)*128)).Froot_visual { prio++ } if bestPtr == libc.UintptrFromInt32(0) { goto newBest } if (*(*TXVisualInfo)(unsafe.Pointer(visInfoList + uintptr(i)*64))).Fdepth < (*TXVisualInfo)(unsafe.Pointer(bestPtr)).Fdepth { if (*(*TXVisualInfo)(unsafe.Pointer(visInfoList + uintptr(i)*64))).Fdepth >= (*(*TXVisualInfo)(unsafe.Pointer(bp))).Fdepth { goto newBest } } else { if (*(*TXVisualInfo)(unsafe.Pointer(visInfoList + uintptr(i)*64))).Fdepth > (*TXVisualInfo)(unsafe.Pointer(bestPtr)).Fdepth { if (*TXVisualInfo)(unsafe.Pointer(bestPtr)).Fdepth < (*(*TXVisualInfo)(unsafe.Pointer(bp))).Fdepth { goto newBest } } else { if prio > bestPrio { goto newBest } } } goto _11 goto newBest newBest: ; bestPtr = visInfoList + uintptr(i)*64 bestPrio = prio goto _11 _11: ; i++ } *(*int32)(unsafe.Pointer(depthPtr)) = (*TXVisualInfo)(unsafe.Pointer(bestPtr)).Fdepth visual = (*TXVisualInfo)(unsafe.Pointer(bestPtr)).Fvisual libx11.XXFree(tls, visInfoList) /* * If we need to find a colormap for this visual, do it now. If the visual * is the default visual for the screen, then use the default colormap. * Otherwise search for an existing colormap that's shareable. If all else * fails, create a new colormap. */ if colormapPtr != libc.UintptrFromInt32(0) { if visual == (*TScreen)(unsafe.Pointer((*struct { Fext_data uintptr Fprivate1 uintptr Ffd int32 Fprivate2 int32 Fproto_major_version int32 Fproto_minor_version int32 Fvendor uintptr Fprivate3 TXID Fprivate4 TXID Fprivate5 TXID Fprivate6 int32 Fresource_alloc uintptr Fbyte_order int32 Fbitmap_unit int32 Fbitmap_pad int32 Fbitmap_bit_order int32 Fnformats int32 Fpixmap_format uintptr Fprivate8 int32 Frelease int32 Fprivate9 uintptr Fprivate10 uintptr Fqlen int32 Flast_request_read uint64 Frequest uint64 Fprivate11 TXPointer Fprivate12 TXPointer Fprivate13 TXPointer Fprivate14 TXPointer Fmax_request_size uint32 Fdb uintptr Fprivate15 uintptr Fdisplay_name uintptr Fdefault_screen int32 Fnscreens int32 Fscreens uintptr Fmotion_buffer uint64 Fprivate16 uint64 Fmin_keycode int32 Fmax_keycode int32 Fprivate17 TXPointer Fprivate18 TXPointer Fprivate19 int32 Fxdefaults uintptr })(unsafe.Pointer((*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fdisplay)).Fscreens+uintptr((*TTk_FakeWin)(unsafe.Pointer(tkwin)).FscreenNum)*128)).Froot_visual { *(*TColormap)(unsafe.Pointer(colormapPtr)) = (*TScreen)(unsafe.Pointer((*struct { Fext_data uintptr Fprivate1 uintptr Ffd int32 Fprivate2 int32 Fproto_major_version int32 Fproto_minor_version int32 Fvendor uintptr Fprivate3 TXID Fprivate4 TXID Fprivate5 TXID Fprivate6 int32 Fresource_alloc uintptr Fbyte_order int32 Fbitmap_unit int32 Fbitmap_pad int32 Fbitmap_bit_order int32 Fnformats int32 Fpixmap_format uintptr Fprivate8 int32 Frelease int32 Fprivate9 uintptr Fprivate10 uintptr Fqlen int32 Flast_request_read uint64 Frequest uint64 Fprivate11 TXPointer Fprivate12 TXPointer Fprivate13 TXPointer Fprivate14 TXPointer Fmax_request_size uint32 Fdb uintptr Fprivate15 uintptr Fdisplay_name uintptr Fdefault_screen int32 Fnscreens int32 Fscreens uintptr Fmotion_buffer uint64 Fprivate16 uint64 Fmin_keycode int32 Fmax_keycode int32 Fprivate17 TXPointer Fprivate18 TXPointer Fprivate19 int32 Fxdefaults uintptr })(unsafe.Pointer((*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fdisplay)).Fscreens + uintptr((*TTk_FakeWin)(unsafe.Pointer(tkwin)).FscreenNum)*128)).Fcmap } else { cmapPtr = (*TTkDisplay)(unsafe.Pointer(dispPtr)).FcmapPtr for { if !(cmapPtr != libc.UintptrFromInt32(0)) { break } if (*TTkColormap)(unsafe.Pointer(cmapPtr)).Fshareable != 0 && (*TTkColormap)(unsafe.Pointer(cmapPtr)).Fvisual == visual { *(*TColormap)(unsafe.Pointer(colormapPtr)) = (*TTkColormap)(unsafe.Pointer(cmapPtr)).Fcolormap (*TTkColormap)(unsafe.Pointer(cmapPtr)).FrefCount++ goto done } goto _12 _12: ; cmapPtr = (*TTkColormap)(unsafe.Pointer(cmapPtr)).FnextPtr } cmapPtr = libtcl9_0.XTcl_Alloc(tls, uint64(40)) (*TTkColormap)(unsafe.Pointer(cmapPtr)).Fcolormap = libx11.XXCreateColormap(tls, (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fdisplay, (*TScreen)(unsafe.Pointer((*struct { Fext_data uintptr Fprivate1 uintptr Ffd int32 Fprivate2 int32 Fproto_major_version int32 Fproto_minor_version int32 Fvendor uintptr Fprivate3 TXID Fprivate4 TXID Fprivate5 TXID Fprivate6 int32 Fresource_alloc uintptr Fbyte_order int32 Fbitmap_unit int32 Fbitmap_pad int32 Fbitmap_bit_order int32 Fnformats int32 Fpixmap_format uintptr Fprivate8 int32 Frelease int32 Fprivate9 uintptr Fprivate10 uintptr Fqlen int32 Flast_request_read uint64 Frequest uint64 Fprivate11 TXPointer Fprivate12 TXPointer Fprivate13 TXPointer Fprivate14 TXPointer Fmax_request_size uint32 Fdb uintptr Fprivate15 uintptr Fdisplay_name uintptr Fdefault_screen int32 Fnscreens int32 Fscreens uintptr Fmotion_buffer uint64 Fprivate16 uint64 Fmin_keycode int32 Fmax_keycode int32 Fprivate17 TXPointer Fprivate18 TXPointer Fprivate19 int32 Fxdefaults uintptr })(unsafe.Pointer((*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fdisplay)).Fscreens+uintptr((*TTk_FakeWin)(unsafe.Pointer(tkwin)).FscreenNum)*128)).Froot, visual, AllocNone) (*TTkColormap)(unsafe.Pointer(cmapPtr)).Fvisual = visual (*TTkColormap)(unsafe.Pointer(cmapPtr)).FrefCount = uint64(1) (*TTkColormap)(unsafe.Pointer(cmapPtr)).Fshareable = int32(1) (*TTkColormap)(unsafe.Pointer(cmapPtr)).FnextPtr = (*TTkDisplay)(unsafe.Pointer(dispPtr)).FcmapPtr (*TTkDisplay)(unsafe.Pointer(dispPtr)).FcmapPtr = cmapPtr *(*TColormap)(unsafe.Pointer(colormapPtr)) = (*TTkColormap)(unsafe.Pointer(cmapPtr)).Fcolormap } } goto done done: ; return visual return r } /* *---------------------------------------------------------------------- * * Tk_GetColormap -- * * Given a string identifying a colormap, this procedure finds an * appropriate colormap. * * Results: * The return value is normally the X resource identifier for the * colormap. If an error occurs, None is returned and an error message is * placed in the interp's result. * * Side effects: * A reference count is incremented for the colormap, so Tk_FreeColormap * must eventually be called exactly once for each call to * Tk_GetColormap. * *---------------------------------------------------------------------- */ func XTk_GetColormap(tls *libc.TLS, interp uintptr, tkwin TTk_Window, string1 uintptr) (r TColormap) { bp := tls.Alloc(48) defer tls.Free(48) /* String that identifies colormap: either * "new" or the name of another window. */ var cmapPtr, dispPtr uintptr var colormap TColormap var other TTk_Window _, _, _, _ = cmapPtr, colormap, dispPtr, other dispPtr = (*TTkWindow)(unsafe.Pointer(tkwin)).FdispPtr /* * Allocate a new colormap, if that's what is wanted. */ if libc.Xstrcmp(tls, string1, __ccgo_ts+17550) == 0 { cmapPtr = libtcl9_0.XTcl_Alloc(tls, uint64(40)) (*TTkColormap)(unsafe.Pointer(cmapPtr)).Fcolormap = libx11.XXCreateColormap(tls, (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fdisplay, (*TScreen)(unsafe.Pointer((*struct { Fext_data uintptr Fprivate1 uintptr Ffd int32 Fprivate2 int32 Fproto_major_version int32 Fproto_minor_version int32 Fvendor uintptr Fprivate3 TXID Fprivate4 TXID Fprivate5 TXID Fprivate6 int32 Fresource_alloc uintptr Fbyte_order int32 Fbitmap_unit int32 Fbitmap_pad int32 Fbitmap_bit_order int32 Fnformats int32 Fpixmap_format uintptr Fprivate8 int32 Frelease int32 Fprivate9 uintptr Fprivate10 uintptr Fqlen int32 Flast_request_read uint64 Frequest uint64 Fprivate11 TXPointer Fprivate12 TXPointer Fprivate13 TXPointer Fprivate14 TXPointer Fmax_request_size uint32 Fdb uintptr Fprivate15 uintptr Fdisplay_name uintptr Fdefault_screen int32 Fnscreens int32 Fscreens uintptr Fmotion_buffer uint64 Fprivate16 uint64 Fmin_keycode int32 Fmax_keycode int32 Fprivate17 TXPointer Fprivate18 TXPointer Fprivate19 int32 Fxdefaults uintptr })(unsafe.Pointer((*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fdisplay)).Fscreens+uintptr((*TTk_FakeWin)(unsafe.Pointer(tkwin)).FscreenNum)*128)).Froot, (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fvisual, AllocNone) (*TTkColormap)(unsafe.Pointer(cmapPtr)).Fvisual = (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fvisual (*TTkColormap)(unsafe.Pointer(cmapPtr)).FrefCount = uint64(1) (*TTkColormap)(unsafe.Pointer(cmapPtr)).Fshareable = 0 (*TTkColormap)(unsafe.Pointer(cmapPtr)).FnextPtr = (*TTkDisplay)(unsafe.Pointer(dispPtr)).FcmapPtr (*TTkDisplay)(unsafe.Pointer(dispPtr)).FcmapPtr = cmapPtr return (*TTkColormap)(unsafe.Pointer(cmapPtr)).Fcolormap } /* * Use a colormap from an existing window. It must have the same visual as * tkwin (which means, among other things, that the other window must be * on the same screen). */ other = XTk_NameToWindow(tls, interp, string1, tkwin) if other == libc.UintptrFromInt32(0) { return uint64(0) } if (*struct { Fext_data uintptr Fprivate1 uintptr Ffd int32 Fprivate2 int32 Fproto_major_version int32 Fproto_minor_version int32 Fvendor uintptr Fprivate3 TXID Fprivate4 TXID Fprivate5 TXID Fprivate6 int32 Fresource_alloc uintptr Fbyte_order int32 Fbitmap_unit int32 Fbitmap_pad int32 Fbitmap_bit_order int32 Fnformats int32 Fpixmap_format uintptr Fprivate8 int32 Frelease int32 Fprivate9 uintptr Fprivate10 uintptr Fqlen int32 Flast_request_read uint64 Frequest uint64 Fprivate11 TXPointer Fprivate12 TXPointer Fprivate13 TXPointer Fprivate14 TXPointer Fmax_request_size uint32 Fdb uintptr Fprivate15 uintptr Fdisplay_name uintptr Fdefault_screen int32 Fnscreens int32 Fscreens uintptr Fmotion_buffer uint64 Fprivate16 uint64 Fmin_keycode int32 Fmax_keycode int32 Fprivate17 TXPointer Fprivate18 TXPointer Fprivate19 int32 Fxdefaults uintptr })(unsafe.Pointer((*TTk_FakeWin)(unsafe.Pointer(other)).Fdisplay)).Fscreens+uintptr((*TTk_FakeWin)(unsafe.Pointer(other)).FscreenNum)*128 != (*struct { Fext_data uintptr Fprivate1 uintptr Ffd int32 Fprivate2 int32 Fproto_major_version int32 Fproto_minor_version int32 Fvendor uintptr Fprivate3 TXID Fprivate4 TXID Fprivate5 TXID Fprivate6 int32 Fresource_alloc uintptr Fbyte_order int32 Fbitmap_unit int32 Fbitmap_pad int32 Fbitmap_bit_order int32 Fnformats int32 Fpixmap_format uintptr Fprivate8 int32 Frelease int32 Fprivate9 uintptr Fprivate10 uintptr Fqlen int32 Flast_request_read uint64 Frequest uint64 Fprivate11 TXPointer Fprivate12 TXPointer Fprivate13 TXPointer Fprivate14 TXPointer Fmax_request_size uint32 Fdb uintptr Fprivate15 uintptr Fdisplay_name uintptr Fdefault_screen int32 Fnscreens int32 Fscreens uintptr Fmotion_buffer uint64 Fprivate16 uint64 Fmin_keycode int32 Fmax_keycode int32 Fprivate17 TXPointer Fprivate18 TXPointer Fprivate19 int32 Fxdefaults uintptr })(unsafe.Pointer((*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fdisplay)).Fscreens+uintptr((*TTk_FakeWin)(unsafe.Pointer(tkwin)).FscreenNum)*128 { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+17554, libc.VaList(bp+8, string1))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+8, __ccgo_ts+179, __ccgo_ts+779, __ccgo_ts+17600, libc.UintptrFromInt32(0))) return uint64(0) } if (*TTk_FakeWin)(unsafe.Pointer(other)).Fvisual != (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fvisual { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+17607, libc.VaList(bp+8, string1))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+8, __ccgo_ts+179, __ccgo_ts+779, __ccgo_ts+17655, libc.UintptrFromInt32(0))) return uint64(0) } colormap = (*TTk_FakeWin)(unsafe.Pointer(other)).Fatts.Fcolormap /* * If the colormap was a special one allocated by code in this file, * increment its reference count. */ cmapPtr = (*TTkDisplay)(unsafe.Pointer(dispPtr)).FcmapPtr for { if !(cmapPtr != libc.UintptrFromInt32(0)) { break } if (*TTkColormap)(unsafe.Pointer(cmapPtr)).Fcolormap == colormap { (*TTkColormap)(unsafe.Pointer(cmapPtr)).FrefCount++ } goto _1 _1: ; cmapPtr = (*TTkColormap)(unsafe.Pointer(cmapPtr)).FnextPtr } return colormap } /* *---------------------------------------------------------------------- * * Tk_FreeColormap -- * * This procedure is called to release a colormap that was previously * allocated by Tk_GetColormap. * * Results: * None. * * Side effects: * The colormap's reference count is decremented. If this was the last * reference to the colormap, then the colormap is freed. * *---------------------------------------------------------------------- */ func XTk_FreeColormap(tls *libc.TLS, display uintptr, colormap TColormap) { /* Colormap that is no longer needed. Must * have been returned by previous call to * Tk_GetColormap, or preserved by a previous * call to Tk_PreserveColormap. */ var cmapPtr, dispPtr, prevPtr, v3 uintptr var v2 Tsize_t _, _, _, _, _ = cmapPtr, dispPtr, prevPtr, v2, v3 /* * Find Tk's information about the display, then see if this colormap is a * non-default one (if it's a default one, there won't be an entry for it * in the display's list). */ dispPtr = XTkGetDisplay(tls, display) if dispPtr == libc.UintptrFromInt32(0) { libtcl9_0.XTcl_Panic(tls, __ccgo_ts+17668, 0) } prevPtr = libc.UintptrFromInt32(0) cmapPtr = (*TTkDisplay)(unsafe.Pointer(dispPtr)).FcmapPtr for { if !(cmapPtr != libc.UintptrFromInt32(0)) { break } if (*TTkColormap)(unsafe.Pointer(cmapPtr)).Fcolormap == colormap { v3 = cmapPtr + 16 v2 = *(*Tsize_t)(unsafe.Pointer(v3)) *(*Tsize_t)(unsafe.Pointer(v3))-- if v2 <= uint64(1) { libx11.XXFreeColormap(tls, display, colormap) if prevPtr == libc.UintptrFromInt32(0) { (*TTkDisplay)(unsafe.Pointer(dispPtr)).FcmapPtr = (*TTkColormap)(unsafe.Pointer(cmapPtr)).FnextPtr } else { (*TTkColormap)(unsafe.Pointer(prevPtr)).FnextPtr = (*TTkColormap)(unsafe.Pointer(cmapPtr)).FnextPtr } libtcl9_0.XTcl_Free(tls, cmapPtr) } return } goto _1 _1: ; prevPtr = cmapPtr cmapPtr = (*TTkColormap)(unsafe.Pointer(cmapPtr)).FnextPtr } } /* *---------------------------------------------------------------------- * * Tk_PreserveColormap -- * * This procedure is called to indicate to Tk that the specified colormap * is being referenced from another location and should not be freed * until all extra references are eliminated. The colormap must have been * returned by Tk_GetColormap. * * Results: * None. * * Side effects: * The colormap's reference count is incremented, so Tk_FreeColormap must * eventually be called exactly once for each call to * Tk_PreserveColormap. * *---------------------------------------------------------------------- */ func XTk_PreserveColormap(tls *libc.TLS, display uintptr, colormap TColormap) { /* Colormap that should be preserved. */ var cmapPtr, dispPtr uintptr _, _ = cmapPtr, dispPtr /* * Find Tk's information about the display, then see if this colormap is a * non-default one (if it's a default one, there won't be an entry for it * in the display's list). */ dispPtr = XTkGetDisplay(tls, display) if dispPtr == libc.UintptrFromInt32(0) { libtcl9_0.XTcl_Panic(tls, __ccgo_ts+17710, 0) } cmapPtr = (*TTkDisplay)(unsafe.Pointer(dispPtr)).FcmapPtr for { if !(cmapPtr != libc.UintptrFromInt32(0)) { break } if (*TTkColormap)(unsafe.Pointer(cmapPtr)).Fcolormap == colormap { (*TTkColormap)(unsafe.Pointer(cmapPtr)).FrefCount++ return } goto _1 _1: ; cmapPtr = (*TTkColormap)(unsafe.Pointer(cmapPtr)).FnextPtr } } const ALL_EVENTS_MASK = 12681343 const FIXED_SIZE = 200 const FIXED_SPACE = 5 const HD_CLEANUP = 1 const HD_DESTROY_COUNT = 8 const HD_DESTROY_EVENT = 16 const HD_FOCUS = 2 const HD_MAIN_WIN = 4 const ISSAFE = 1 const PASSMAINWINDOW = 2 const SAVEUPDATECMD = 16 const TK_PATCH_LEVEL1 = "9.0.1+c8084d00ffd43c03186dbd9c2e61f8d29f1cfef21302f90bcfa88e0b4a51e984.gcc-1002.static.x11.no-xft" const TK_VERSION_UUID = 0 const USEINITPROC = 8 const WINMACONLY = 4 /* * Local Variables: * mode: c * c-basic-offset: 4 * fill-column: 78 * End: */ /* * Type used to keep track of Window objects that were only partially * deallocated by Tk_DestroyWindow. */ type TTkHalfdeadWindow = struct { Fflags int32 FwinPtr uintptr FnextPtr uintptr } type TThreadSpecificData9 = struct { FnumMainWindows int32 FmainWindowList uintptr FhalfdeadWindowList uintptr FdisplayList uintptr Finitialized int32 } var _dataKey9 TTcl_ThreadDataKey /* * Default values for "changes" and "atts" fields of TkWindows. Note that Tk * always requests all events for all windows, except StructureNotify events * on internal windows: these events are generated internally. */ var _defChanges = TXWindowChanges{ Fwidth: int32(1), Fheight: int32(1), } var _defAtts = TXSetWindowAttributes{ Fbit_gravity: int32(NorthWestGravity), Fwin_gravity: int32(NorthWestGravity), Fbacking_planes: uint64(libc.Uint32FromInt32(^libc.Int32FromInt32(0))), Fevent_mask: libc.Int64FromInt64(1)<. with the * dot and the screen being optional. */ screenName = XTkGetDefaultScreenName(tls, interp, screenName) if screenName == libc.UintptrFromInt32(0) { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+18247, int64(-libc.Int32FromInt32(1)))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+8, __ccgo_ts+179, __ccgo_ts+18300, libc.UintptrFromInt32(0))) return libc.UintptrFromInt32(0) } length = libc.Xstrlen(tls, screenName) screenId = 0 p = screenName + uintptr(length) - uintptr(1) for libc.BoolInt32(uint32(*(*uint8)(unsafe.Pointer(p)))-uint32('0') < uint32(10)) != 0 && p != screenName { p-- } if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(p))) == int32('.') && libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(p + 1))) != int32('\000') { length = libc.Uint64FromInt64(int64(p) - int64(screenName)) screenId = libc.Int32FromUint64(libc.Xstrtoul(tls, p+uintptr(1), libc.UintptrFromInt32(0), int32(10))) } /* * See if we already have a connection to this display. If not, then open * a new connection. */ dispPtr = (*TThreadSpecificData9)(unsafe.Pointer(tsdPtr)).FdisplayList for { if dispPtr == libc.UintptrFromInt32(0) { /* * The private function zeros out dispPtr when it is created, so * we only need to initialize the non-zero items. */ dispPtr = XTkpOpenDisplay(tls, screenName) if dispPtr == libc.UintptrFromInt32(0) { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+18311, libc.VaList(bp+8, screenName))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+8, __ccgo_ts+179, __ccgo_ts+18344, __ccgo_ts+18352, libc.UintptrFromInt32(0))) return libc.UintptrFromInt32(0) } (*TTkDisplay)(unsafe.Pointer(dispPtr)).FnextPtr = (*TThreadSpecificData9)(unsafe.Pointer(tsdPtr)).FdisplayList /* TkGetDisplayList(); */ (*TThreadSpecificData9)(unsafe.Pointer(tsdPtr)).FdisplayList = dispPtr (*TTkDisplay)(unsafe.Pointer(dispPtr)).FlastEventTime = uint64(0) (*TTkDisplay)(unsafe.Pointer(dispPtr)).FbindInfoStale = int32(1) (*TTkDisplay)(unsafe.Pointer(dispPtr)).FcursorFont = uint64(0) (*TTkDisplay)(unsafe.Pointer(dispPtr)).FwarpWindow = libc.UintptrFromInt32(0) (*TTkDisplay)(unsafe.Pointer(dispPtr)).FmultipleAtom = uint64(0) /* * By default we do want to collapse motion events in * Tk_QueueWindowEvent. */ *(*uint32)(unsafe.Pointer(dispPtr + 2632)) |= libc.Uint32FromInt32(libc.Int32FromInt32(1) << libc.Int32FromInt32(0)) libtcl9_0.XTcl_InitHashTable(tls, dispPtr+2496, int32(TCL_ONE_WORD_KEYS)) (*TTkDisplay)(unsafe.Pointer(dispPtr)).Fname = libtcl9_0.XTcl_Alloc(tls, length+uint64(1)) libc.Xstrncpy(tls, (*TTkDisplay)(unsafe.Pointer(dispPtr)).Fname, screenName, length) *(*uint8)(unsafe.Pointer((*TTkDisplay)(unsafe.Pointer(dispPtr)).Fname + uintptr(length))) = uint8('\000') break } if libc.Xstrncmp(tls, (*TTkDisplay)(unsafe.Pointer(dispPtr)).Fname, screenName, length) == 0 && libc.Int32FromUint8(*(*uint8)(unsafe.Pointer((*TTkDisplay)(unsafe.Pointer(dispPtr)).Fname + uintptr(length)))) == int32('\000') { break } goto _1 _1: ; dispPtr = (*TTkDisplay)(unsafe.Pointer(dispPtr)).FnextPtr } if screenId >= (*struct { Fext_data uintptr Fprivate1 uintptr Ffd int32 Fprivate2 int32 Fproto_major_version int32 Fproto_minor_version int32 Fvendor uintptr Fprivate3 TXID Fprivate4 TXID Fprivate5 TXID Fprivate6 int32 Fresource_alloc uintptr Fbyte_order int32 Fbitmap_unit int32 Fbitmap_pad int32 Fbitmap_bit_order int32 Fnformats int32 Fpixmap_format uintptr Fprivate8 int32 Frelease int32 Fprivate9 uintptr Fprivate10 uintptr Fqlen int32 Flast_request_read uint64 Frequest uint64 Fprivate11 TXPointer Fprivate12 TXPointer Fprivate13 TXPointer Fprivate14 TXPointer Fmax_request_size uint32 Fdb uintptr Fprivate15 uintptr Fdisplay_name uintptr Fdefault_screen int32 Fnscreens int32 Fscreens uintptr Fmotion_buffer uint64 Fprivate16 uint64 Fmin_keycode int32 Fmax_keycode int32 Fprivate17 TXPointer Fprivate18 TXPointer Fprivate19 int32 Fxdefaults uintptr })(unsafe.Pointer((*TTkDisplay)(unsafe.Pointer(dispPtr)).Fdisplay)).Fnscreens { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+18360, libc.VaList(bp+8, screenId))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+8, __ccgo_ts+179, __ccgo_ts+18344, __ccgo_ts+18383, libc.UintptrFromInt32(0))) return libc.UintptrFromInt32(0) } *(*int32)(unsafe.Pointer(screenPtr)) = screenId return dispPtr } /* *---------------------------------------------------------------------- * * TkGetDisplay -- * * Given an X display, TkGetDisplay returns the TkDisplay structure for * the display. * * Results: * The return value is a pointer to information about the display, or * NULL if the display did not have a TkDisplay structure. * * Side effects: * None. * *---------------------------------------------------------------------- */ func XTkGetDisplay(tls *libc.TLS, display uintptr) (r uintptr) { /* X's display pointer */ var dispPtr, tsdPtr uintptr _, _ = dispPtr, tsdPtr tsdPtr = libtcl9_0.XTcl_GetThreadData(tls, uintptr(unsafe.Pointer(&_dataKey9)), int64(40)) dispPtr = (*TThreadSpecificData9)(unsafe.Pointer(tsdPtr)).FdisplayList for { if !(dispPtr != libc.UintptrFromInt32(0)) { break } if (*TTkDisplay)(unsafe.Pointer(dispPtr)).Fdisplay == display { break } goto _1 _1: ; dispPtr = (*TTkDisplay)(unsafe.Pointer(dispPtr)).FnextPtr } return dispPtr } /* *-------------------------------------------------------------- * * TkGetDisplayList -- * * This function returns a pointer to the thread-local list of TkDisplays * corresponding to the open displays. * * Results: * The return value is a pointer to the first TkDisplay structure in * thread-local-storage. * * Side effects: * None. * *-------------------------------------------------------------- */ func XTkGetDisplayList(tls *libc.TLS) (r uintptr) { var tsdPtr uintptr _ = tsdPtr tsdPtr = libtcl9_0.XTcl_GetThreadData(tls, uintptr(unsafe.Pointer(&_dataKey9)), int64(40)) return (*TThreadSpecificData9)(unsafe.Pointer(tsdPtr)).FdisplayList } /* *-------------------------------------------------------------- * * TkGetMainInfoList -- * * This function returns a pointer to the list of structures containing * information about all main windows for the current thread. * * Results: * The return value is a pointer to the first TkMainInfo structure in * thread local storage. * * Side effects: * None. * *-------------------------------------------------------------- */ func XTkGetMainInfoList(tls *libc.TLS) (r uintptr) { var tsdPtr uintptr _ = tsdPtr tsdPtr = libtcl9_0.XTcl_GetThreadData(tls, uintptr(unsafe.Pointer(&_dataKey9)), int64(40)) return (*TThreadSpecificData9)(unsafe.Pointer(tsdPtr)).FmainWindowList } /* *-------------------------------------------------------------- * * TkAllocWindow -- * * This function creates and initializes a TkWindow structure. * * Results: * The return value is a pointer to the new window. * * Side effects: * A new window structure is allocated and all its fields are * initialized. * *-------------------------------------------------------------- */ func XTkAllocWindow(tls *libc.TLS, dispPtr uintptr, screenNum int32, parentPtr uintptr) (r uintptr) { /* Parent from which this window should * inherit visual information. NULL means use * screen defaults instead of inheriting. */ var winPtr uintptr var v1 int32 _, _ = winPtr, v1 winPtr = libtcl9_0.XTcl_Alloc(tls, uint64(440)) (*TTkWindow)(unsafe.Pointer(winPtr)).Fdisplay = (*TTkDisplay)(unsafe.Pointer(dispPtr)).Fdisplay (*TTkWindow)(unsafe.Pointer(winPtr)).FdispPtr = dispPtr (*TTkWindow)(unsafe.Pointer(winPtr)).FscreenNum = screenNum if parentPtr != libc.UintptrFromInt32(0) && (*TTkWindow)(unsafe.Pointer(parentPtr)).Fdisplay == (*TTkWindow)(unsafe.Pointer(winPtr)).Fdisplay && (*TTkWindow)(unsafe.Pointer(parentPtr)).FscreenNum == (*TTkWindow)(unsafe.Pointer(winPtr)).FscreenNum { (*TTkWindow)(unsafe.Pointer(winPtr)).Fvisual = (*TTkWindow)(unsafe.Pointer(parentPtr)).Fvisual (*TTkWindow)(unsafe.Pointer(winPtr)).Fdepth = (*TTkWindow)(unsafe.Pointer(parentPtr)).Fdepth } else { (*TTkWindow)(unsafe.Pointer(winPtr)).Fvisual = (*TScreen)(unsafe.Pointer((*struct { Fext_data uintptr Fprivate1 uintptr Ffd int32 Fprivate2 int32 Fproto_major_version int32 Fproto_minor_version int32 Fvendor uintptr Fprivate3 TXID Fprivate4 TXID Fprivate5 TXID Fprivate6 int32 Fresource_alloc uintptr Fbyte_order int32 Fbitmap_unit int32 Fbitmap_pad int32 Fbitmap_bit_order int32 Fnformats int32 Fpixmap_format uintptr Fprivate8 int32 Frelease int32 Fprivate9 uintptr Fprivate10 uintptr Fqlen int32 Flast_request_read uint64 Frequest uint64 Fprivate11 TXPointer Fprivate12 TXPointer Fprivate13 TXPointer Fprivate14 TXPointer Fmax_request_size uint32 Fdb uintptr Fprivate15 uintptr Fdisplay_name uintptr Fdefault_screen int32 Fnscreens int32 Fscreens uintptr Fmotion_buffer uint64 Fprivate16 uint64 Fmin_keycode int32 Fmax_keycode int32 Fprivate17 TXPointer Fprivate18 TXPointer Fprivate19 int32 Fxdefaults uintptr })(unsafe.Pointer((*TTkDisplay)(unsafe.Pointer(dispPtr)).Fdisplay)).Fscreens + uintptr(screenNum)*128)).Froot_visual (*TTkWindow)(unsafe.Pointer(winPtr)).Fdepth = (*TScreen)(unsafe.Pointer((*struct { Fext_data uintptr Fprivate1 uintptr Ffd int32 Fprivate2 int32 Fproto_major_version int32 Fproto_minor_version int32 Fvendor uintptr Fprivate3 TXID Fprivate4 TXID Fprivate5 TXID Fprivate6 int32 Fresource_alloc uintptr Fbyte_order int32 Fbitmap_unit int32 Fbitmap_pad int32 Fbitmap_bit_order int32 Fnformats int32 Fpixmap_format uintptr Fprivate8 int32 Frelease int32 Fprivate9 uintptr Fprivate10 uintptr Fqlen int32 Flast_request_read uint64 Frequest uint64 Fprivate11 TXPointer Fprivate12 TXPointer Fprivate13 TXPointer Fprivate14 TXPointer Fmax_request_size uint32 Fdb uintptr Fprivate15 uintptr Fdisplay_name uintptr Fdefault_screen int32 Fnscreens int32 Fscreens uintptr Fmotion_buffer uint64 Fprivate16 uint64 Fmin_keycode int32 Fmax_keycode int32 Fprivate17 TXPointer Fprivate18 TXPointer Fprivate19 int32 Fxdefaults uintptr })(unsafe.Pointer((*TTkDisplay)(unsafe.Pointer(dispPtr)).Fdisplay)).Fscreens + uintptr(screenNum)*128)).Froot_depth } (*TTkWindow)(unsafe.Pointer(winPtr)).Fwindow = uint64(0) (*TTkWindow)(unsafe.Pointer(winPtr)).FchildList = libc.UintptrFromInt32(0) (*TTkWindow)(unsafe.Pointer(winPtr)).FlastChildPtr = libc.UintptrFromInt32(0) (*TTkWindow)(unsafe.Pointer(winPtr)).FparentPtr = libc.UintptrFromInt32(0) (*TTkWindow)(unsafe.Pointer(winPtr)).FnextPtr = libc.UintptrFromInt32(0) (*TTkWindow)(unsafe.Pointer(winPtr)).FmainPtr = libc.UintptrFromInt32(0) (*TTkWindow)(unsafe.Pointer(winPtr)).FpathName = libc.UintptrFromInt32(0) (*TTkWindow)(unsafe.Pointer(winPtr)).FnameUid = libc.UintptrFromInt32(0) (*TTkWindow)(unsafe.Pointer(winPtr)).FclassUid = libc.UintptrFromInt32(0) (*TTkWindow)(unsafe.Pointer(winPtr)).Fchanges = _defChanges (*TTkWindow)(unsafe.Pointer(winPtr)).FdirtyChanges = libc.Uint32FromInt32(libc.Int32FromInt32(1)< uint64(FIXED_SPACE) { p = libtcl9_0.XTcl_Alloc(tls, numChars+uint64(1)) } else { p = bp } if numChars == uint64(0) { *(*uint8)(unsafe.Pointer(p)) = uint8('.') *(*uint8)(unsafe.Pointer(p + 1)) = uint8('\000') } else { libc.Xstrncpy(tls, p, pathName, numChars) *(*uint8)(unsafe.Pointer(p + uintptr(numChars))) = uint8('\000') } /* * Find the parent window. */ parent = XTk_NameToWindow(tls, interp, p, tkwin) if p != bp { libtcl9_0.XTcl_Free(tls, p) } if parent == libc.UintptrFromInt32(0) { return libc.UintptrFromInt32(0) } if (*TTkWindow)(unsafe.Pointer(parent)).Fflags&uint32(TK_ALREADY_DEAD) != 0 { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+18733, int64(-libc.Int32FromInt32(1)))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+16, __ccgo_ts+179, __ccgo_ts+18780, __ccgo_ts+18787, libc.UintptrFromInt32(0))) return libc.UintptrFromInt32(0) } else { if (*TTkWindow)(unsafe.Pointer(parent)).Fflags&uint32(TK_CONTAINER) != 0 { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+18799, int64(-libc.Int32FromInt32(1)))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+16, __ccgo_ts+179, __ccgo_ts+18780, __ccgo_ts+18852, libc.UintptrFromInt32(0))) return libc.UintptrFromInt32(0) } } /* * Create the window. */ if screenName == libc.UintptrFromInt32(0) { parentPtr = parent winPtr = XTkAllocWindow(tls, (*TTkWindow)(unsafe.Pointer(parentPtr)).FdispPtr, (*TTkWindow)(unsafe.Pointer(parentPtr)).FscreenNum, parentPtr) if _NameWindow(tls, interp, winPtr, parentPtr, pathName+uintptr(numChars)+uintptr(1)) != TCL_OK { XTk_DestroyWindow(tls, winPtr) return libc.UintptrFromInt32(0) } return winPtr } return _CreateTopLevelWindow(tls, interp, parent, pathName+uintptr(numChars)+uintptr(1), screenName, uint32(0)) } /* *-------------------------------------------------------------- * * Tk_DestroyWindow -- * * Destroy an existing window. After this call, the caller should never * again use the token. Note that this function can be reentered to * destroy a window that was only partially destroyed before a call to * exit. * * Results: * None. * * Side effects: * The window is deleted, along with all of its children. Relevant * callback functions are invoked. * *-------------------------------------------------------------- */ func _SendEnterLeaveForDestroy(tls *libc.TLS, dummy1376 TTk_Window) { } func XTk_DestroyWindow(tls *libc.TLS, tkwin TTk_Window) { bp := tls.Alloc(192) defer tls.Free(192) /* Window to destroy. */ var childPtr, childPtr1, cmdPtr, dispPtr, halfdeadPtr, prevPtr, prev_halfdeadPtr, tsdPtr, winPtr, v4 uintptr var v3 TTcl_Size var _ /* event at bp+0 */ TXEvent _, _, _, _, _, _, _, _, _, _, _ = childPtr, childPtr1, cmdPtr, dispPtr, halfdeadPtr, prevPtr, prev_halfdeadPtr, tsdPtr, winPtr, v3, v4 winPtr = tkwin dispPtr = (*TTkWindow)(unsafe.Pointer(winPtr)).FdispPtr tsdPtr = libtcl9_0.XTcl_GetThreadData(tls, uintptr(unsafe.Pointer(&_dataKey9)), int64(40)) if (*TTkWindow)(unsafe.Pointer(winPtr)).Fflags&uint32(TK_ALREADY_DEAD) != 0 { /* * A destroy event binding caused the window to be destroyed again. * Ignore the request. */ return } if (*TTkWindow)(unsafe.Pointer(winPtr)).Fflags&uint32(TK_DONT_DESTROY_WINDOW) == uint32(0) { _SendEnterLeaveForDestroy(tls, tkwin) } *(*uint32)(unsafe.Pointer(winPtr + 280)) |= uint32(TK_ALREADY_DEAD) /* * Unless we are cleaning up a half dead window from * DeleteWindowsExitProc, add this window to the half dead list. */ if (*TThreadSpecificData9)(unsafe.Pointer(tsdPtr)).FhalfdeadWindowList != 0 && (*TTkHalfdeadWindow)(unsafe.Pointer((*TThreadSpecificData9)(unsafe.Pointer(tsdPtr)).FhalfdeadWindowList)).Fflags&int32(HD_CLEANUP) != 0 && (*TTkHalfdeadWindow)(unsafe.Pointer((*TThreadSpecificData9)(unsafe.Pointer(tsdPtr)).FhalfdeadWindowList)).FwinPtr == winPtr { halfdeadPtr = (*TThreadSpecificData9)(unsafe.Pointer(tsdPtr)).FhalfdeadWindowList } else { halfdeadPtr = libtcl9_0.XTcl_Alloc(tls, uint64(24)) (*TTkHalfdeadWindow)(unsafe.Pointer(halfdeadPtr)).Fflags = 0 (*TTkHalfdeadWindow)(unsafe.Pointer(halfdeadPtr)).FwinPtr = winPtr (*TTkHalfdeadWindow)(unsafe.Pointer(halfdeadPtr)).FnextPtr = (*TThreadSpecificData9)(unsafe.Pointer(tsdPtr)).FhalfdeadWindowList (*TThreadSpecificData9)(unsafe.Pointer(tsdPtr)).FhalfdeadWindowList = halfdeadPtr } /* * Some cleanup needs to be done immediately, rather than later, because * it needs information that will be destroyed before we get to the main * cleanup point. For example, TkFocusDeadWindow needs to access the * parentPtr field from a window, but if a Destroy event handler deletes * the window's parent this field will be NULL before the main cleanup * point is reached. */ if !((*TTkHalfdeadWindow)(unsafe.Pointer(halfdeadPtr)).Fflags&libc.Int32FromInt32(HD_FOCUS) != 0) { *(*int32)(unsafe.Pointer(halfdeadPtr)) |= int32(HD_FOCUS) XTkFocusDeadWindow(tls, winPtr) } /* * If this is a main window, remove it from the list of main windows. * This needs to be done now (rather than later with all the other main * window cleanup) to handle situations where a destroy binding for a * window calls "exit". In this case the child window cleanup isn't * complete when exit is called. This situation is dealt with using the * half dead window list. Windows that are half dead gets cleaned up * during exit. * * Also decrement the display refcount so that if this is the last Tk * application in this process on this display, the display can be closed * and its data structures deleted. */ if !((*TTkHalfdeadWindow)(unsafe.Pointer(halfdeadPtr)).Fflags&libc.Int32FromInt32(HD_MAIN_WIN) != 0) && (*TTkWindow)(unsafe.Pointer(winPtr)).FmainPtr != libc.UintptrFromInt32(0) && (*TTkMainInfo)(unsafe.Pointer((*TTkWindow)(unsafe.Pointer(winPtr)).FmainPtr)).FwinPtr == winPtr { *(*int32)(unsafe.Pointer(halfdeadPtr)) |= int32(HD_MAIN_WIN) (*TTkDisplay)(unsafe.Pointer(dispPtr)).FrefCount-- if (*TThreadSpecificData9)(unsafe.Pointer(tsdPtr)).FmainWindowList == (*TTkWindow)(unsafe.Pointer(winPtr)).FmainPtr { (*TThreadSpecificData9)(unsafe.Pointer(tsdPtr)).FmainWindowList = (*TTkMainInfo)(unsafe.Pointer((*TTkWindow)(unsafe.Pointer(winPtr)).FmainPtr)).FnextPtr } else { prevPtr = (*TThreadSpecificData9)(unsafe.Pointer(tsdPtr)).FmainWindowList for { if !((*TTkMainInfo)(unsafe.Pointer(prevPtr)).FnextPtr != (*TTkWindow)(unsafe.Pointer(winPtr)).FmainPtr) { break } /* Empty loop body. */ goto _1 _1: ; prevPtr = (*TTkMainInfo)(unsafe.Pointer(prevPtr)).FnextPtr } (*TTkMainInfo)(unsafe.Pointer(prevPtr)).FnextPtr = (*TTkMainInfo)(unsafe.Pointer((*TTkWindow)(unsafe.Pointer(winPtr)).FmainPtr)).FnextPtr } (*TThreadSpecificData9)(unsafe.Pointer(tsdPtr)).FnumMainWindows-- } /* * Recursively destroy children. Note that this child window block may * need to be run multiple times in the case where a child window has a * Destroy binding that calls exit. */ if !((*TTkHalfdeadWindow)(unsafe.Pointer(halfdeadPtr)).Fflags&libc.Int32FromInt32(HD_DESTROY_COUNT) != 0) { *(*int32)(unsafe.Pointer(halfdeadPtr)) |= int32(HD_DESTROY_COUNT) } for (*TTkWindow)(unsafe.Pointer(winPtr)).FchildList != libc.UintptrFromInt32(0) { childPtr = (*TTkWindow)(unsafe.Pointer(winPtr)).FchildList *(*uint32)(unsafe.Pointer(childPtr + 280)) |= uint32(TK_DONT_DESTROY_WINDOW) XTk_DestroyWindow(tls, childPtr) if (*TTkWindow)(unsafe.Pointer(winPtr)).FchildList == childPtr { /* * The child didn't remove itself from the child list, so let's * remove it here. This can happen in some strange conditions, * such as when a Destroy event handler for a window destroys the * window's parent. */ (*TTkWindow)(unsafe.Pointer(winPtr)).FchildList = (*TTkWindow)(unsafe.Pointer(childPtr)).FnextPtr (*TTkWindow)(unsafe.Pointer(childPtr)).FparentPtr = libc.UintptrFromInt32(0) } } if (*TTkWindow)(unsafe.Pointer(winPtr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(TK_CONTAINER)|libc.Int32FromInt32(TK_BOTH_HALVES)) == libc.Uint32FromInt32(libc.Int32FromInt32(TK_CONTAINER)|libc.Int32FromInt32(TK_BOTH_HALVES)) { /* * This is the container for an embedded application, and the embedded * application is also in this process. Delete the embedded window * in-line here, for the same reasons we delete children in-line * (otherwise, for example, the Tk window may appear to exist even * though its X window is gone; this could cause errors). Special * note: it's possible that the embedded window has already been * deleted, in which case Tk_GetOtherWindow will return NULL. */ childPtr1 = XTk_GetOtherWindow(tls, tkwin) if childPtr1 != libc.UintptrFromInt32(0) { *(*uint32)(unsafe.Pointer(childPtr1 + 280)) |= uint32(TK_DONT_DESTROY_WINDOW) XTk_DestroyWindow(tls, childPtr1) } } /* * Generate a DestroyNotify event. In order for the DestroyNotify event to * be processed correctly, need to make sure the window exists. This is a * bit of a kludge, and may be unnecessarily expensive, but without it no * event handlers will get called for windows that don't exist yet. * * Note: if the window's pathName is NULL and the window is not an * anonymous window, it means that the window was not successfully * initialized in the first place, so we should not make the window exist * or generate the event. */ if !((*TTkHalfdeadWindow)(unsafe.Pointer(halfdeadPtr)).Fflags&libc.Int32FromInt32(HD_DESTROY_EVENT) != 0) && (*TTkWindow)(unsafe.Pointer(winPtr)).FpathName != libc.UintptrFromInt32(0) && !((*TTkWindow)(unsafe.Pointer(winPtr)).Fflags&libc.Uint32FromInt32(TK_ANONYMOUS_WINDOW) != 0) { *(*int32)(unsafe.Pointer(halfdeadPtr)) |= int32(HD_DESTROY_EVENT) if (*TTkWindow)(unsafe.Pointer(winPtr)).Fwindow == uint64(0) { XTk_MakeWindowExist(tls, tkwin) } (*(*TXEvent)(unsafe.Pointer(bp))).Ftype1 = int32(DestroyNotify) (*(*TXDestroyWindowEvent)(unsafe.Pointer(&*(*TXEvent)(unsafe.Pointer(bp))))).Fserial = (*struct { Fext_data uintptr Fprivate1 uintptr Ffd int32 Fprivate2 int32 Fproto_major_version int32 Fproto_minor_version int32 Fvendor uintptr Fprivate3 TXID Fprivate4 TXID Fprivate5 TXID Fprivate6 int32 Fresource_alloc uintptr Fbyte_order int32 Fbitmap_unit int32 Fbitmap_pad int32 Fbitmap_bit_order int32 Fnformats int32 Fpixmap_format uintptr Fprivate8 int32 Frelease int32 Fprivate9 uintptr Fprivate10 uintptr Fqlen int32 Flast_request_read uint64 Frequest uint64 Fprivate11 TXPointer Fprivate12 TXPointer Fprivate13 TXPointer Fprivate14 TXPointer Fmax_request_size uint32 Fdb uintptr Fprivate15 uintptr Fdisplay_name uintptr Fdefault_screen int32 Fnscreens int32 Fscreens uintptr Fmotion_buffer uint64 Fprivate16 uint64 Fmin_keycode int32 Fmax_keycode int32 Fprivate17 TXPointer Fprivate18 TXPointer Fprivate19 int32 Fxdefaults uintptr })(unsafe.Pointer((*TTkWindow)(unsafe.Pointer(winPtr)).Fdisplay)).Flast_request_read (*(*TXDestroyWindowEvent)(unsafe.Pointer(&*(*TXEvent)(unsafe.Pointer(bp))))).Fsend_event = False (*(*TXDestroyWindowEvent)(unsafe.Pointer(&*(*TXEvent)(unsafe.Pointer(bp))))).Fdisplay = (*TTkWindow)(unsafe.Pointer(winPtr)).Fdisplay (*(*TXDestroyWindowEvent)(unsafe.Pointer(&*(*TXEvent)(unsafe.Pointer(bp))))).Fevent = (*TTkWindow)(unsafe.Pointer(winPtr)).Fwindow (*(*TXDestroyWindowEvent)(unsafe.Pointer(&*(*TXEvent)(unsafe.Pointer(bp))))).Fwindow = (*TTkWindow)(unsafe.Pointer(winPtr)).Fwindow XTk_HandleEvent(tls, bp) } /* * No additional bindings that could call exit should be invoked from this * point on, so it is safe to remove this window from the half dead list. */ prev_halfdeadPtr = libc.UintptrFromInt32(0) halfdeadPtr = (*TThreadSpecificData9)(unsafe.Pointer(tsdPtr)).FhalfdeadWindowList for { if !(halfdeadPtr != libc.UintptrFromInt32(0)) { break } if (*TTkHalfdeadWindow)(unsafe.Pointer(halfdeadPtr)).FwinPtr == winPtr { if prev_halfdeadPtr == libc.UintptrFromInt32(0) { (*TThreadSpecificData9)(unsafe.Pointer(tsdPtr)).FhalfdeadWindowList = (*TTkHalfdeadWindow)(unsafe.Pointer(halfdeadPtr)).FnextPtr } else { (*TTkHalfdeadWindow)(unsafe.Pointer(prev_halfdeadPtr)).FnextPtr = (*TTkHalfdeadWindow)(unsafe.Pointer(halfdeadPtr)).FnextPtr } libtcl9_0.XTcl_Free(tls, halfdeadPtr) break } prev_halfdeadPtr = halfdeadPtr halfdeadPtr = (*TTkHalfdeadWindow)(unsafe.Pointer(halfdeadPtr)).FnextPtr goto _2 _2: } if halfdeadPtr == libc.UintptrFromInt32(0) { libtcl9_0.XTcl_Panic(tls, __ccgo_ts+18888, 0) } /* * Cleanup the data structures associated with this window. */ if (*TTkWindow)(unsafe.Pointer(winPtr)).FwmInfoPtr != 0 && (*TTkWindow)(unsafe.Pointer(winPtr)).Fflags&uint32(TK_WIN_MANAGED) != 0 { XTkWmDeadWindow(tls, winPtr) } else { if (*TTkWindow)(unsafe.Pointer(winPtr)).Fflags&uint32(TK_WM_COLORMAP_WINDOW) != 0 { XTkWmRemoveFromColormapWindows(tls, winPtr) } } if (*TTkWindow)(unsafe.Pointer(winPtr)).Fwindow != uint64(0) { if (*TTkWindow)(unsafe.Pointer(winPtr)).Fflags&uint32(TK_TOP_HIERARCHY) != 0 || !((*TTkWindow)(unsafe.Pointer(winPtr)).Fflags&libc.Uint32FromInt32(TK_DONT_DESTROY_WINDOW) != 0) { /* * The parent has already been destroyed and this isn't a * top-level window, so this window will be destroyed implicitly * when the parent's X window is destroyed; it's much faster not * to do an explicit destroy of this X window. */ libx11.XXDestroyWindow(tls, (*TTkWindow)(unsafe.Pointer(winPtr)).Fdisplay, (*TTkWindow)(unsafe.Pointer(winPtr)).Fwindow) } libtcl9_0.XTcl_DeleteHashEntry(tls, (*(*func(*libc.TLS, uintptr, uintptr) uintptr)(unsafe.Pointer(&struct{ uintptr }{(*TTcl_HashTable)(unsafe.Pointer(dispPtr + 2496)).FfindProc})))(tls, dispPtr+2496, uintptr((*TTkWindow)(unsafe.Pointer(winPtr)).Fwindow))) (*TTkWindow)(unsafe.Pointer(winPtr)).Fwindow = uint64(0) } _UnlinkWindow(tls, winPtr) XTkEventDeadWindow(tls, winPtr) if (*TTkWindow)(unsafe.Pointer(winPtr)).FinputContext != libc.UintptrFromInt32(0) && (*TTkWindow)(unsafe.Pointer(winPtr)).FximGeneration == (*TTkDisplay)(unsafe.Pointer((*TTkWindow)(unsafe.Pointer(winPtr)).FdispPtr)).FximGeneration { libx11.XXDestroyIC(tls, (*TTkWindow)(unsafe.Pointer(winPtr)).FinputContext) } (*TTkWindow)(unsafe.Pointer(winPtr)).FinputContext = libc.UintptrFromInt32(0) if (*TTkWindow)(unsafe.Pointer(winPtr)).FtagPtr != libc.UintptrFromInt32(0) { XTkFreeBindingTags(tls, winPtr) } XTkOptionDeadWindow(tls, winPtr) XTkSelDeadWindow(tls, winPtr) XTkGrabDeadWindow(tls, winPtr) if (*TTkWindow)(unsafe.Pointer(winPtr)).FgeomMgrName != libc.UintptrFromInt32(0) { libtcl9_0.XTcl_Free(tls, (*TTkWindow)(unsafe.Pointer(winPtr)).FgeomMgrName) (*TTkWindow)(unsafe.Pointer(winPtr)).FgeomMgrName = libc.UintptrFromInt32(0) } if (*TTkWindow)(unsafe.Pointer(winPtr)).FmainPtr != libc.UintptrFromInt32(0) { if (*TTkWindow)(unsafe.Pointer(winPtr)).FpathName != libc.UintptrFromInt32(0) { XTk_DeleteAllBindings(tls, (*TTkMainInfo)(unsafe.Pointer((*TTkWindow)(unsafe.Pointer(winPtr)).FmainPtr)).FbindingTable, (*TTkWindow)(unsafe.Pointer(winPtr)).FpathName) libtcl9_0.XTcl_DeleteHashEntry(tls, (*(*func(*libc.TLS, uintptr, uintptr) uintptr)(unsafe.Pointer(&struct{ uintptr }{(*TTcl_HashTable)(unsafe.Pointer((*TTkWindow)(unsafe.Pointer(winPtr)).FmainPtr + 24)).FfindProc})))(tls, (*TTkWindow)(unsafe.Pointer(winPtr)).FmainPtr+24, (*TTkWindow)(unsafe.Pointer(winPtr)).FpathName)) /* * The memory pointed to by pathName has been deallocated. Keep * users from accessing it after the window has been destroyed by * setting it to NULL. */ (*TTkWindow)(unsafe.Pointer(winPtr)).FpathName = libc.UintptrFromInt32(0) /* * Invalidate all objects referring to windows with the same main * window. */ (*TTkMainInfo)(unsafe.Pointer((*TTkWindow)(unsafe.Pointer(winPtr)).FmainPtr)).FdeletionEpoch++ } v4 = (*TTkWindow)(unsafe.Pointer(winPtr)).FmainPtr v3 = *(*TTcl_Size)(unsafe.Pointer(v4)) *(*TTcl_Size)(unsafe.Pointer(v4))-- if v3 <= int64(1) { /* * We just deleted the last window in the application. Delete the * TkMainInfo structure too and replace all of Tk's commands with * dummy commands that return errors. Also delete the "send" * command to unregister the interpreter. * * NOTE: Only replace the commands it if the interpreter is not * being deleted. If it *is*, the interpreter cleanup will do all * the needed work. */ if (*TTkMainInfo)(unsafe.Pointer((*TTkWindow)(unsafe.Pointer(winPtr)).FmainPtr)).Finterp != libc.UintptrFromInt32(0) && !(libtcl9_0.XTcl_InterpDeleted(tls, (*TTkMainInfo)(unsafe.Pointer((*TTkWindow)(unsafe.Pointer(winPtr)).FmainPtr)).Finterp) != 0) { cmdPtr = uintptr(unsafe.Pointer(&_commands)) for { if !((*TTkCmd)(unsafe.Pointer(cmdPtr)).Fname != libc.UintptrFromInt32(0)) { break } if (*TTkCmd)(unsafe.Pointer(cmdPtr)).Fflags&int32(SAVEUPDATECMD) != 0 { /* Restore Tcl's version of [update] */ if (*TTkMainInfo)(unsafe.Pointer((*TTkWindow)(unsafe.Pointer(winPtr)).FmainPtr)).FtclUpdateObjProc2 != libc.UintptrFromInt32(0) { libtcl9_0.XTcl_CreateObjCommand2(tls, (*TTkMainInfo)(unsafe.Pointer((*TTkWindow)(unsafe.Pointer(winPtr)).FmainPtr)).Finterp, (*TTkCmd)(unsafe.Pointer(cmdPtr)).Fname, (*TTkMainInfo)(unsafe.Pointer((*TTkWindow)(unsafe.Pointer(winPtr)).FmainPtr)).FtclUpdateObjProc2, libc.UintptrFromInt32(0), libc.UintptrFromInt32(0)) } else { if (*TTkMainInfo)(unsafe.Pointer((*TTkWindow)(unsafe.Pointer(winPtr)).FmainPtr)).FtclUpdateObjProc != libc.UintptrFromInt32(0) { libtcl9_0.XTcl_CreateObjCommand(tls, (*TTkMainInfo)(unsafe.Pointer((*TTkWindow)(unsafe.Pointer(winPtr)).FmainPtr)).Finterp, (*TTkCmd)(unsafe.Pointer(cmdPtr)).Fname, (*TTkMainInfo)(unsafe.Pointer((*TTkWindow)(unsafe.Pointer(winPtr)).FmainPtr)).FtclUpdateObjProc, libc.UintptrFromInt32(0), libc.UintptrFromInt32(0)) } } } else { libtcl9_0.XTcl_CreateObjCommand(tls, (*TTkMainInfo)(unsafe.Pointer((*TTkWindow)(unsafe.Pointer(winPtr)).FmainPtr)).Finterp, (*TTkCmd)(unsafe.Pointer(cmdPtr)).Fname, __ccgo_fp(XTkDeadAppObjCmd), libc.UintptrFromInt32(0), libc.UintptrFromInt32(0)) } goto _5 _5: ; cmdPtr += 24 } libtcl9_0.XTcl_CreateObjCommand(tls, (*TTkMainInfo)(unsafe.Pointer((*TTkWindow)(unsafe.Pointer(winPtr)).FmainPtr)).Finterp, __ccgo_ts+18923, __ccgo_fp(XTkDeadAppObjCmd), libc.UintptrFromInt32(0), libc.UintptrFromInt32(0)) libtcl9_0.XTcl_UnlinkVar(tls, (*TTkMainInfo)(unsafe.Pointer((*TTkWindow)(unsafe.Pointer(winPtr)).FmainPtr)).Finterp, __ccgo_ts+18545) libtcl9_0.XTcl_UnlinkVar(tls, (*TTkMainInfo)(unsafe.Pointer((*TTkWindow)(unsafe.Pointer(winPtr)).FmainPtr)).Finterp, __ccgo_ts+18565) } libtcl9_0.XTcl_DeleteHashTable(tls, (*TTkWindow)(unsafe.Pointer(winPtr)).FmainPtr+304) libtcl9_0.XTcl_DeleteHashTable(tls, (*TTkWindow)(unsafe.Pointer(winPtr)).FmainPtr+24) XTkBindFree(tls, (*TTkWindow)(unsafe.Pointer(winPtr)).FmainPtr) XTkDeleteAllImages(tls, (*TTkWindow)(unsafe.Pointer(winPtr)).FmainPtr) XTkFontPkgFree(tls, (*TTkWindow)(unsafe.Pointer(winPtr)).FmainPtr) XTkFocusFree(tls, (*TTkWindow)(unsafe.Pointer(winPtr)).FmainPtr) XTkStylePkgFree(tls, (*TTkWindow)(unsafe.Pointer(winPtr)).FmainPtr) XTtk_TkDestroyedHandler(tls, (*TTkMainInfo)(unsafe.Pointer((*TTkWindow)(unsafe.Pointer(winPtr)).FmainPtr)).Finterp) /* * When embedding Tk into other applications, make sure that all * destroy events reach the server. Otherwise the embedding * application may also attempt to destroy the windows, resulting * in an X error */ if (*TTkWindow)(unsafe.Pointer(winPtr)).Fflags&uint32(TK_EMBEDDED) != 0 { libx11.XXSync(tls, (*TTkWindow)(unsafe.Pointer(winPtr)).Fdisplay, False) } libtcl9_0.XTcl_Free(tls, (*TTkWindow)(unsafe.Pointer(winPtr)).FmainPtr) /* * If no other applications are using the display, close the * display now and relinquish its data structures. */ } } libtcl9_0.XTcl_EventuallyFree(tls, winPtr, libc.UintptrFromInt32(3)) } /* *-------------------------------------------------------------- * * Tk_MapWindow -- * * Map a window within its parent. This may require the window and/or its * parents to actually be created. * * Results: * None. * * Side effects: * The given window will be mapped. Windows may also be created. * *-------------------------------------------------------------- */ func XTk_MapWindow(tls *libc.TLS, tkwin TTk_Window) { bp := tls.Alloc(192) defer tls.Free(192) /* Token for window to map. */ var winPtr uintptr var _ /* event at bp+0 */ TXEvent _ = winPtr winPtr = tkwin if (*TTkWindow)(unsafe.Pointer(winPtr)).Fflags&uint32(TK_MAPPED) != 0 { return } if (*TTkWindow)(unsafe.Pointer(winPtr)).Fwindow == uint64(0) { XTk_MakeWindowExist(tls, tkwin) } /* * [Bug 2645457]: the previous call permits events to be processed and can * lead to the destruction of the window under some conditions. */ if (*TTkWindow)(unsafe.Pointer(winPtr)).Fflags&uint32(TK_ALREADY_DEAD) != 0 { return } if (*TTkWindow)(unsafe.Pointer(winPtr)).Fflags&uint32(TK_WIN_MANAGED) != 0 { /* * Lots of special processing has to be done for top-level windows. * Let tkWm.c handle everything itself. */ XTkWmMapWindow(tls, winPtr) return } *(*uint32)(unsafe.Pointer(winPtr + 280)) |= uint32(TK_MAPPED) libx11.XXMapWindow(tls, (*TTkWindow)(unsafe.Pointer(winPtr)).Fdisplay, (*TTkWindow)(unsafe.Pointer(winPtr)).Fwindow) (*(*TXEvent)(unsafe.Pointer(bp))).Ftype1 = int32(MapNotify) (*(*TXMapEvent)(unsafe.Pointer(&*(*TXEvent)(unsafe.Pointer(bp))))).Fserial = (*struct { Fext_data uintptr Fprivate1 uintptr Ffd int32 Fprivate2 int32 Fproto_major_version int32 Fproto_minor_version int32 Fvendor uintptr Fprivate3 TXID Fprivate4 TXID Fprivate5 TXID Fprivate6 int32 Fresource_alloc uintptr Fbyte_order int32 Fbitmap_unit int32 Fbitmap_pad int32 Fbitmap_bit_order int32 Fnformats int32 Fpixmap_format uintptr Fprivate8 int32 Frelease int32 Fprivate9 uintptr Fprivate10 uintptr Fqlen int32 Flast_request_read uint64 Frequest uint64 Fprivate11 TXPointer Fprivate12 TXPointer Fprivate13 TXPointer Fprivate14 TXPointer Fmax_request_size uint32 Fdb uintptr Fprivate15 uintptr Fdisplay_name uintptr Fdefault_screen int32 Fnscreens int32 Fscreens uintptr Fmotion_buffer uint64 Fprivate16 uint64 Fmin_keycode int32 Fmax_keycode int32 Fprivate17 TXPointer Fprivate18 TXPointer Fprivate19 int32 Fxdefaults uintptr })(unsafe.Pointer((*TTkWindow)(unsafe.Pointer(winPtr)).Fdisplay)).Flast_request_read (*(*TXMapEvent)(unsafe.Pointer(&*(*TXEvent)(unsafe.Pointer(bp))))).Fsend_event = False (*(*TXMapEvent)(unsafe.Pointer(&*(*TXEvent)(unsafe.Pointer(bp))))).Fdisplay = (*TTkWindow)(unsafe.Pointer(winPtr)).Fdisplay (*(*TXMapEvent)(unsafe.Pointer(&*(*TXEvent)(unsafe.Pointer(bp))))).Fevent = (*TTkWindow)(unsafe.Pointer(winPtr)).Fwindow (*(*TXMapEvent)(unsafe.Pointer(&*(*TXEvent)(unsafe.Pointer(bp))))).Fwindow = (*TTkWindow)(unsafe.Pointer(winPtr)).Fwindow (*(*TXMapEvent)(unsafe.Pointer(&*(*TXEvent)(unsafe.Pointer(bp))))).Foverride_redirect = (*TTkWindow)(unsafe.Pointer(winPtr)).Fatts.Foverride_redirect XTk_HandleEvent(tls, bp) } /* *-------------------------------------------------------------- * * Tk_MakeWindowExist -- * * Ensure that a particular window actually exists. This function should * not normally need to be invoked from outside the Tk package, but may * be needed if someone wants to manipulate a window before mapping it. * * Results: * None. * * Side effects: * When the function returns, the X window associated with tkwin is * guaranteed to exist. This may require the window's ancestors to be * created also. * *-------------------------------------------------------------- */ func XTk_MakeWindowExist(tls *libc.TLS, tkwin TTk_Window) { bp := tls.Alloc(48) defer tls.Free(48) /* Token for window. */ var createProc, hPtr, winPtr, winPtr2, v1, v2 uintptr var parent TWindow var _ /* changes at bp+8 */ TXWindowChanges var _ /* isNew at bp+0 */ int32 _, _, _, _, _, _, _ = createProc, hPtr, parent, winPtr, winPtr2, v1, v2 winPtr = tkwin if (*TTkWindow)(unsafe.Pointer(winPtr)).Fwindow != uint64(0) { return } if (*TTkWindow)(unsafe.Pointer(winPtr)).FparentPtr == libc.UintptrFromInt32(0) || (*TTkWindow)(unsafe.Pointer(winPtr)).Fflags&uint32(TK_TOP_HIERARCHY) != 0 { parent = libx11.XXRootWindow(tls, (*TTkWindow)(unsafe.Pointer(winPtr)).Fdisplay, (*TTkWindow)(unsafe.Pointer(winPtr)).FscreenNum) } else { if (*TTkWindow1)(unsafe.Pointer((*TTkWindow)(unsafe.Pointer(winPtr)).FparentPtr)).Fwindow == uint64(0) { XTk_MakeWindowExist(tls, (*TTkWindow)(unsafe.Pointer(winPtr)).FparentPtr) } parent = (*TTkWindow1)(unsafe.Pointer((*TTkWindow)(unsafe.Pointer(winPtr)).FparentPtr)).Fwindow } if (*TTkWindow)(unsafe.Pointer(winPtr)).FclassProcsPtr == libc.UintptrFromInt32(0) { v1 = libc.UintptrFromInt32(0) } else { if libc.Uint64FromInt64((*TTk_ClassProcs)(unsafe.Pointer((*TTkWindow)(unsafe.Pointer(winPtr)).FclassProcsPtr)).Fsize) <= uint64(libc.UintptrFromInt32(0)+16) { v2 = libc.UintptrFromInt32(0) } else { v2 = (*TTk_ClassProcs)(unsafe.Pointer((*TTkWindow)(unsafe.Pointer(winPtr)).FclassProcsPtr)).FcreateProc } v1 = v2 } createProc = v1 if createProc != libc.UintptrFromInt32(0) && parent != uint64(0) { (*TTkWindow)(unsafe.Pointer(winPtr)).Fwindow = (*(*func(*libc.TLS, TTk_Window, TWindow, uintptr) TWindow)(unsafe.Pointer(&struct{ uintptr }{createProc})))(tls, tkwin, parent, (*TTkWindow)(unsafe.Pointer(winPtr)).FinstanceData) } else { (*TTkWindow)(unsafe.Pointer(winPtr)).Fwindow = XTk_MakeWindow(tls, tkwin, parent) } hPtr = (*(*func(*libc.TLS, uintptr, uintptr, uintptr) uintptr)(unsafe.Pointer(&struct{ uintptr }{(*TTcl_HashTable)(unsafe.Pointer((*TTkWindow)(unsafe.Pointer(winPtr)).FdispPtr + 2496)).FcreateProc})))(tls, (*TTkWindow)(unsafe.Pointer(winPtr)).FdispPtr+2496, uintptr((*TTkWindow)(unsafe.Pointer(winPtr)).Fwindow), bp) (*TTcl_HashEntry)(unsafe.Pointer(hPtr)).FclientData = winPtr (*TTkWindow)(unsafe.Pointer(winPtr)).FdirtyAtts = uint64(0) (*TTkWindow)(unsafe.Pointer(winPtr)).FdirtyChanges = uint32(0) if !((*TTkWindow)(unsafe.Pointer(winPtr)).Fflags&libc.Uint32FromInt32(TK_TOP_HIERARCHY) != 0) { /* * If any siblings higher up in the stacking order have already been * created then move this window to its rightful position in the * stacking order. * * NOTE: this code ignores any changes anyone might have made to the * sibling and stack_mode field of the window's attributes, so it * really isn't safe for these to be manipulated except by calling * Tk_RestackWindow. */ winPtr2 = (*TTkWindow)(unsafe.Pointer(winPtr)).FnextPtr for { if !(winPtr2 != libc.UintptrFromInt32(0)) { break } if (*TTkWindow)(unsafe.Pointer(winPtr2)).Fwindow != uint64(0) && !((*TTkWindow)(unsafe.Pointer(winPtr2)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(TK_TOP_HIERARCHY)|libc.Int32FromInt32(TK_REPARENTED)) != 0) { (*(*TXWindowChanges)(unsafe.Pointer(bp + 8))).Fsibling = (*TTkWindow)(unsafe.Pointer(winPtr2)).Fwindow (*(*TXWindowChanges)(unsafe.Pointer(bp + 8))).Fstack_mode = int32(Below) libx11.XXConfigureWindow(tls, (*TTkWindow)(unsafe.Pointer(winPtr)).Fdisplay, (*TTkWindow)(unsafe.Pointer(winPtr)).Fwindow, libc.Uint32FromInt32(libc.Int32FromInt32(1)< bindings which could destroy the interpreter while the window * is being deleted. This would leave frames on the call stack pointing at * deleted memory, causing core dumps. */ for (*TThreadSpecificData9)(unsafe.Pointer(tsdPtr)).FhalfdeadWindowList != libc.UintptrFromInt32(0) { interp = (*TTkMainInfo)(unsafe.Pointer((*TTkWindow1)(unsafe.Pointer((*TTkHalfdeadWindow)(unsafe.Pointer((*TThreadSpecificData9)(unsafe.Pointer(tsdPtr)).FhalfdeadWindowList)).FwinPtr)).FmainPtr)).Finterp libtcl9_0.XTcl_Preserve(tls, interp) *(*int32)(unsafe.Pointer((*TThreadSpecificData9)(unsafe.Pointer(tsdPtr)).FhalfdeadWindowList)) |= int32(HD_CLEANUP) *(*uint32)(unsafe.Pointer((*TTkHalfdeadWindow)(unsafe.Pointer((*TThreadSpecificData9)(unsafe.Pointer(tsdPtr)).FhalfdeadWindowList)).FwinPtr + 280)) &= libc.Uint32FromInt32(^libc.Int32FromInt32(TK_ALREADY_DEAD)) XTk_DestroyWindow(tls, (*TTkHalfdeadWindow)(unsafe.Pointer((*TThreadSpecificData9)(unsafe.Pointer(tsdPtr)).FhalfdeadWindowList)).FwinPtr) libtcl9_0.XTcl_Release(tls, interp) } /* * Destroy any remaining main windows. */ for (*TThreadSpecificData9)(unsafe.Pointer(tsdPtr)).FmainWindowList != libc.UintptrFromInt32(0) { interp = (*TTkMainInfo)(unsafe.Pointer((*TThreadSpecificData9)(unsafe.Pointer(tsdPtr)).FmainWindowList)).Finterp libtcl9_0.XTcl_Preserve(tls, interp) XTk_DestroyWindow(tls, (*TTkMainInfo)(unsafe.Pointer((*TThreadSpecificData9)(unsafe.Pointer(tsdPtr)).FmainWindowList)).FwinPtr) libtcl9_0.XTcl_Release(tls, interp) } /* * Let error handlers catch up before actual close of displays. * Must be done before tsdPtr->displayList is cleared, otherwise * ErrorProc() in tkError.c cannot associate the pending X errors * to the remaining error handlers. */ dispPtr = (*TThreadSpecificData9)(unsafe.Pointer(tsdPtr)).FdisplayList for { if !(dispPtr != libc.UintptrFromInt32(0)) { break } libx11.XXSync(tls, (*TTkDisplay)(unsafe.Pointer(dispPtr)).Fdisplay, False) goto _1 _1: ; dispPtr = (*TTkDisplay)(unsafe.Pointer(dispPtr)).FnextPtr } /* * Iterate destroying the displays until no more displays remain. It is * possible for displays to get recreated during exit by any code that * calls GetScreen, so we must destroy these new displays as well as the * old ones. */ dispPtr = (*TThreadSpecificData9)(unsafe.Pointer(tsdPtr)).FdisplayList for { if !(dispPtr != libc.UintptrFromInt32(0)) { break } /* * Now iterate over the current list of open displays, and first set * the global pointer to NULL so we will be able to notice if any new * displays got created during deletion of the current set. We must * also do this to ensure that Tk_IdToWindow does not find the old * display as it is being destroyed, when it wants to see if it needs * to dispatch a message. */ (*TThreadSpecificData9)(unsafe.Pointer(tsdPtr)).FdisplayList = libc.UintptrFromInt32(0) for { if !(dispPtr != libc.UintptrFromInt32(0)) { break } nextPtr = (*TTkDisplay)(unsafe.Pointer(dispPtr)).FnextPtr _TkCloseDisplay(tls, dispPtr) goto _3 _3: ; dispPtr = nextPtr } goto _2 _2: ; dispPtr = (*TThreadSpecificData9)(unsafe.Pointer(tsdPtr)).FdisplayList } (*TThreadSpecificData9)(unsafe.Pointer(tsdPtr)).FnumMainWindows = 0 (*TThreadSpecificData9)(unsafe.Pointer(tsdPtr)).FmainWindowList = libc.UintptrFromInt32(0) (*TThreadSpecificData9)(unsafe.Pointer(tsdPtr)).Finitialized = 0 } /* *---------------------------------------------------------------------- * * Tk_Init -- * * This function is invoked to add Tk to an interpreter. It incorporates * all of Tk's commands into the interpreter and creates the main window * for a new Tk application. If the interpreter contains a variable * "argv", this function extracts several arguments from that variable, * uses them to configure the main window, and modifies argv to exclude * the arguments (see the "wish" documentation for a list of the * arguments that are extracted). * * Results: * Returns a standard Tcl completion code and sets the interp's result if * there is an error. * * Side effects: * Depends on various initialization scripts that get invoked. * *---------------------------------------------------------------------- */ func XTk_Init(tls *libc.TLS, interp uintptr) (r int32) { /* Interpreter to initialize. */ return _Initialize(tls, interp) } /* *---------------------------------------------------------------------- * * Tk_SafeInit -- * * This function is invoked to add Tk to a safe interpreter. It invokes * the internal function that does the real work. * * Results: * Returns a standard Tcl completion code and sets the interp's result if * there is an error. * * Side effects: * Depends on various initialization scripts that are invoked. * *---------------------------------------------------------------------- */ func XTk_SafeInit(tls *libc.TLS, interp uintptr) (r int32) { /* Interpreter to initialize. */ /* * Initialize the interpreter with Tk, safely. This removes all the Tk * commands that are unsafe. * * Rationale: * * - Toplevel and menu are unsafe because they can be used to cover the * entire screen and to steal input from the user. * - Continuous ringing of the bell is a nuisance. * - Cannot allow access to the clipboard because a malicious script can * replace the contents with the string "rm -r *" and lead to surprises * when the contents of the clipboard are pasted. Similarly, the * selection command is blocked. * - Cannot allow send because it can be used to cause unsafe interpreters * to execute commands. The tk command recreates the send command, so * that too must be hidden. * - Focus can be used to grab the focus away from another window, in * effect stealing user input. Cannot allow that. * NOTE: We currently do *not* hide focus as it would make it impossible * to provide keyboard input to Tk in a safe interpreter. * - Grab can be used to block the user from using any other apps on the * screen. * - Tkwait can block the containing process forever. Use bindings, * fileevents and split the protocol into before-the-wait and * after-the-wait parts. More work but necessary. * - Wm is unsafe because (if toplevels are allowed, in the future) it can * be used to remove decorations, move windows around, cover the entire * screen etc etc. * * Current risks: * * - No CPU time limit, no memory allocation limits, no color limits. * CPU time limits can be imposed by an unsafe parent interpreter. * * The actual code called is the same as Tk_Init but Tcl_IsSafe() is * checked at several places to differentiate the two initialisations. */ return _Initialize(tls, interp) } /* *---------------------------------------------------------------------- * * Initialize -- * * The core of the initialization code for Tk, called from Tk_Init and * Tk_SafeInit. * * Results: * A standard Tcl result. Also leaves an error message in the interp's * result if there was an error. * * Side effects: * Depends on the initialization scripts that are invoked. * *---------------------------------------------------------------------- */ func _CopyValue(tls *libc.TLS, dummy3178 uintptr, objPtr uintptr, dstPtr uintptr) (r int32) { *(*uintptr)(unsafe.Pointer(dstPtr)) = objPtr return int32(1) } func _Initialize(tls *libc.TLS, interp uintptr) (r int32) { bp := tls.Alloc(848) defer tls.Free(848) /* Interpreter to initialize. */ var _objPtr, _objPtr1, _objPtr2, _objPtr3, _objPtr4, _objPtr5, appNameObj, bytes, classObj, cmd, parent, parseList, tsdPtr, value, v11, v13, v2, v4, v5, v7, v9 uintptr var code int32 var v1, v10, v12, v3, v6, v8 TTcl_Size var _ /* colorMapObj at bp+16 */ uintptr var _ /* displayObj at bp+8 */ uintptr var _ /* geometryObj at bp+40 */ uintptr var _ /* nameDS at bp+560 */ TTcl_DString var _ /* nameObj at bp+0 */ uintptr var _ /* numBytes at bp+784 */ TTcl_Size var _ /* objc at bp+536 */ TTcl_Size var _ /* objc at bp+792 */ TTcl_Size var _ /* objv at bp+544 */ uintptr var _ /* objv at bp+800 */ uintptr var _ /* rest at bp+552 */ uintptr var _ /* sync at bp+48 */ int32 var _ /* table at bp+56 */ [10]TTcl_ArgvInfo var _ /* useObj at bp+24 */ uintptr var _ /* visualObj at bp+32 */ uintptr _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = _objPtr, _objPtr1, _objPtr2, _objPtr3, _objPtr4, _objPtr5, appNameObj, bytes, classObj, cmd, code, parent, parseList, tsdPtr, value, v1, v10, v11, v12, v13, v2, v3, v4, v5, v6, v7, v8, v9 code = TCL_OK value = libc.UintptrFromInt32(0) *(*uintptr)(unsafe.Pointer(bp)) = libc.UintptrFromInt32(0) appNameObj = libc.UintptrFromInt32(0) classObj = libc.UintptrFromInt32(0) *(*uintptr)(unsafe.Pointer(bp + 8)) = libc.UintptrFromInt32(0) *(*uintptr)(unsafe.Pointer(bp + 16)) = libc.UintptrFromInt32(0) *(*uintptr)(unsafe.Pointer(bp + 24)) = libc.UintptrFromInt32(0) *(*uintptr)(unsafe.Pointer(bp + 32)) = libc.UintptrFromInt32(0) *(*uintptr)(unsafe.Pointer(bp + 40)) = libc.UintptrFromInt32(0) *(*int32)(unsafe.Pointer(bp + 48)) = 0 *(*[10]TTcl_ArgvInfo)(unsafe.Pointer(bp + 56)) = [10]TTcl_ArgvInfo{ 0: { Ftype1: int32(TCL_ARGV_CONSTANT), FkeyStr: __ccgo_ts + 19055, FsrcPtr: uintptr(int64(libc.Int32FromInt32(1))), FdstPtr: bp + 48, FhelpStr: __ccgo_ts + 19061, }, 1: { Ftype1: int32(TCL_ARGV_FUNC), FkeyStr: __ccgo_ts + 19101, FsrcPtr: __ccgo_fp(_CopyValue), FdstPtr: bp + 16, FhelpStr: __ccgo_ts + 19111, }, 2: { Ftype1: int32(TCL_ARGV_FUNC), FkeyStr: __ccgo_ts + 19136, FsrcPtr: __ccgo_fp(_CopyValue), FdstPtr: bp + 8, FhelpStr: __ccgo_ts + 19145, }, 3: { Ftype1: int32(TCL_ARGV_FUNC), FkeyStr: __ccgo_ts + 19160, FsrcPtr: __ccgo_fp(_CopyValue), FdstPtr: bp + 40, FhelpStr: __ccgo_ts + 19170, }, 4: { Ftype1: int32(TCL_ARGV_FUNC), FkeyStr: __ccgo_ts + 19198, FsrcPtr: __ccgo_fp(_CopyValue), FdstPtr: bp, FhelpStr: __ccgo_ts + 19204, }, 5: { Ftype1: int32(TCL_ARGV_FUNC), FkeyStr: __ccgo_ts + 19232, FsrcPtr: __ccgo_fp(_CopyValue), FdstPtr: bp + 32, FhelpStr: __ccgo_ts + 19240, }, 6: { Ftype1: int32(TCL_ARGV_FUNC), FkeyStr: __ccgo_ts + 19263, FsrcPtr: __ccgo_fp(_CopyValue), FdstPtr: bp + 24, FhelpStr: __ccgo_ts + 19268, }, 7: { Ftype1: int32(TCL_ARGV_REST), FkeyStr: __ccgo_ts + 10042, FhelpStr: __ccgo_ts + 19311, }, 8: { Ftype1: int32(TCL_ARGV_HELP), FkeyStr: __ccgo_ts + 309, FhelpStr: __ccgo_ts + 315, }, 9: { Ftype1: int32(TCL_ARGV_END), }, } /* * Ensure that we are getting a compatible version of Tcl. */ if libtcl9_0.XTcl_PkgInitStubsCheck(tls, interp, __ccgo_ts+8182, libc.Int32FromInt32(0)|libc.Int32FromInt32(TCL_MAJOR_VERSION)< int32(2) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(1), objv, __ccgo_ts+20937) goto error } if (*TTkButton)(unsafe.Pointer(butPtr)).Ftype1 == int32(TYPE_CHECK_BUTTON) { if libtcl9_0.XTcl_ObjSetVar2(tls, interp, (*TTkButton)(unsafe.Pointer(butPtr)).FselVarNamePtr, libc.UintptrFromInt32(0), (*TTkButton)(unsafe.Pointer(butPtr)).FoffValuePtr, libc.Int32FromInt32(TCL_GLOBAL_ONLY)|libc.Int32FromInt32(TCL_LEAVE_ERR_MSG)) == libc.UintptrFromInt32(0) { goto error } } else { if (*TTkButton)(unsafe.Pointer(butPtr)).Fflags&(libc.Int32FromInt32(1)< int32(2) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(1), objv, __ccgo_ts+20924) goto error } if (*TTkButton)(unsafe.Pointer(butPtr)).Fstate != int32(STATE_DISABLED) { i = 0 for { if !(i < int32(4)) { break } if (*TTkButton)(unsafe.Pointer(butPtr)).Fstate == int32(STATE_NORMAL) { (*TTkButton)(unsafe.Pointer(butPtr)).Fstate = int32(STATE_ACTIVE) XTk_SetBackgroundFromBorder(tls, (*TTkButton)(unsafe.Pointer(butPtr)).Ftkwin, (*TTkButton)(unsafe.Pointer(butPtr)).FactiveBorder) } else { (*TTkButton)(unsafe.Pointer(butPtr)).Fstate = int32(STATE_NORMAL) XTk_SetBackgroundFromBorder(tls, (*TTkButton)(unsafe.Pointer(butPtr)).Ftkwin, (*TTkButton)(unsafe.Pointer(butPtr)).FnormalBorder) } XTkpDisplayButton(tls, butPtr) /* * Special note: must cancel any existing idle handler for * TkpDisplayButton; it's no longer needed, and * TkpDisplayButton cleared the REDRAW_PENDING flag. */ libtcl9_0.XTcl_CancelIdleCall(tls, __ccgo_fp(XTkpDisplayButton), butPtr) libx11.XXFlush(tls, (*TTkButton)(unsafe.Pointer(butPtr)).Fdisplay) /* * On the mac you can not sleep in a display proc, and the * flash command doesn't do anything anyway. */ libtcl9_0.XTcl_Sleep(tls, int32(50)) goto _2 _2: ; i++ } } case int32(COMMAND_INVOKE): if objc > int32(2) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(1), objv, __ccgo_ts+20930) goto error } if (*TTkButton)(unsafe.Pointer(butPtr)).Fstate != int32(STATE_DISABLED) { result = XTkInvokeButton(tls, butPtr) } case int32(COMMAND_SELECT): if objc > int32(2) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(1), objv, __ccgo_ts+20946) goto error } if libtcl9_0.XTcl_ObjSetVar2(tls, interp, (*TTkButton)(unsafe.Pointer(butPtr)).FselVarNamePtr, libc.UintptrFromInt32(0), (*TTkButton)(unsafe.Pointer(butPtr)).FonValuePtr, libc.Int32FromInt32(TCL_GLOBAL_ONLY)|libc.Int32FromInt32(TCL_LEAVE_ERR_MSG)) == libc.UintptrFromInt32(0) { goto error } case int32(COMMAND_TOGGLE): if objc > int32(2) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(1), objv, __ccgo_ts+20953) goto error } if (*TTkButton)(unsafe.Pointer(butPtr)).Fflags&(libc.Int32FromInt32(1)<= int32(TYPE_CHECK_BUTTON) { if (*TTkButton)(unsafe.Pointer(butPtr)).FselVarNamePtr == libc.UintptrFromInt32(0) { (*TTkButton)(unsafe.Pointer(butPtr)).FselVarNamePtr = libtcl9_0.XTcl_NewStringObj(tls, (*TTk_FakeWin)(unsafe.Pointer((*TTkButton)(unsafe.Pointer(butPtr)).Ftkwin)).FnameUid, int64(-libc.Int32FromInt32(1))) (*TTcl_Obj)(unsafe.Pointer((*TTkButton)(unsafe.Pointer(butPtr)).FselVarNamePtr)).FrefCount++ } namePtr = (*TTkButton)(unsafe.Pointer(butPtr)).FselVarNamePtr /* * Select the button if the associated variable has the * appropriate value, initialize the variable if it doesn't exist, * then set a trace on the variable to monitor future changes to * its value. */ valuePtr = libtcl9_0.XTcl_ObjGetVar2(tls, interp, namePtr, libc.UintptrFromInt32(0), int32(TCL_GLOBAL_ONLY)) *(*int32)(unsafe.Pointer(butPtr + 452)) &= ^(libc.Int32FromInt32(1) << libc.Int32FromInt32(1)) *(*int32)(unsafe.Pointer(butPtr + 452)) &= ^(libc.Int32FromInt32(1) << libc.Int32FromInt32(4)) if valuePtr != libc.UintptrFromInt32(0) { value = libtcl9_0.XTcl_GetStringFromObj(tls, valuePtr, libc.UintptrFromInt32(0)) if libc.Xstrcmp(tls, value, libtcl9_0.XTcl_GetStringFromObj(tls, (*TTkButton)(unsafe.Pointer(butPtr)).FonValuePtr, libc.UintptrFromInt32(0))) == 0 { *(*int32)(unsafe.Pointer(butPtr + 452)) |= libc.Int32FromInt32(1) << libc.Int32FromInt32(1) } else { if libc.Xstrcmp(tls, value, libtcl9_0.XTcl_GetStringFromObj(tls, (*TTkButton)(unsafe.Pointer(butPtr)).FtristateValuePtr, libc.UintptrFromInt32(0))) == 0 { *(*int32)(unsafe.Pointer(butPtr + 452)) |= libc.Int32FromInt32(1) << libc.Int32FromInt32(4) /* * For checkbuttons if the tristate value is the * same as the offvalue then prefer off to tristate */ if (*TTkButton)(unsafe.Pointer(butPtr)).FoffValuePtr != 0 && libc.Xstrcmp(tls, value, libtcl9_0.XTcl_GetStringFromObj(tls, (*TTkButton)(unsafe.Pointer(butPtr)).FoffValuePtr, libc.UintptrFromInt32(0))) == 0 { *(*int32)(unsafe.Pointer(butPtr + 452)) &= ^(libc.Int32FromInt32(1) << libc.Int32FromInt32(4)) } } } } else { if (*TTkButton)(unsafe.Pointer(butPtr)).Ftype1 == int32(TYPE_CHECK_BUTTON) { v12 = (*TTkButton)(unsafe.Pointer(butPtr)).FoffValuePtr } else { v12 = libtcl9_0.XTcl_NewObj(tls) } if libtcl9_0.XTcl_ObjSetVar2(tls, interp, namePtr, libc.UintptrFromInt32(0), v12, libc.Int32FromInt32(TCL_GLOBAL_ONLY)|libc.Int32FromInt32(TCL_LEAVE_ERR_MSG)) == libc.UintptrFromInt32(0) { goto _1 } /* * If a radiobutton has the empty string as value it should be * selected. */ if (*TTkButton)(unsafe.Pointer(butPtr)).Ftype1 == int32(TYPE_RADIO_BUTTON) && libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(libtcl9_0.XTcl_GetStringFromObj(tls, (*TTkButton)(unsafe.Pointer(butPtr)).FonValuePtr, libc.UintptrFromInt32(0))))) == int32('\000') { *(*int32)(unsafe.Pointer(butPtr + 452)) |= libc.Int32FromInt32(1) << libc.Int32FromInt32(1) } } } /* * Get the images for the widget, if there are any. Allocate the new * images before freeing the old ones, so that the reference counts * don't go to zero and cause image data to be discarded. */ if (*TTkButton)(unsafe.Pointer(butPtr)).FimagePtr != libc.UintptrFromInt32(0) { image = XTk_GetImage(tls, (*TTkButton)(unsafe.Pointer(butPtr)).Finterp, (*TTkButton)(unsafe.Pointer(butPtr)).Ftkwin, libtcl9_0.XTcl_GetStringFromObj(tls, (*TTkButton)(unsafe.Pointer(butPtr)).FimagePtr, libc.UintptrFromInt32(0)), __ccgo_fp(_ButtonImageProc), butPtr) if image == libc.UintptrFromInt32(0) { goto _1 } } else { image = libc.UintptrFromInt32(0) } if (*TTkButton)(unsafe.Pointer(butPtr)).Fimage != libc.UintptrFromInt32(0) { XTk_FreeImage(tls, (*TTkButton)(unsafe.Pointer(butPtr)).Fimage) } (*TTkButton)(unsafe.Pointer(butPtr)).Fimage = image if (*TTkButton)(unsafe.Pointer(butPtr)).FselectImagePtr != libc.UintptrFromInt32(0) { image = XTk_GetImage(tls, (*TTkButton)(unsafe.Pointer(butPtr)).Finterp, (*TTkButton)(unsafe.Pointer(butPtr)).Ftkwin, libtcl9_0.XTcl_GetStringFromObj(tls, (*TTkButton)(unsafe.Pointer(butPtr)).FselectImagePtr, libc.UintptrFromInt32(0)), __ccgo_fp(_ButtonSelectImageProc), butPtr) if image == libc.UintptrFromInt32(0) { goto _1 } } else { image = libc.UintptrFromInt32(0) } if (*TTkButton)(unsafe.Pointer(butPtr)).FselectImage != libc.UintptrFromInt32(0) { XTk_FreeImage(tls, (*TTkButton)(unsafe.Pointer(butPtr)).FselectImage) } (*TTkButton)(unsafe.Pointer(butPtr)).FselectImage = image if (*TTkButton)(unsafe.Pointer(butPtr)).FtristateImagePtr != libc.UintptrFromInt32(0) { image = XTk_GetImage(tls, (*TTkButton)(unsafe.Pointer(butPtr)).Finterp, (*TTkButton)(unsafe.Pointer(butPtr)).Ftkwin, libtcl9_0.XTcl_GetStringFromObj(tls, (*TTkButton)(unsafe.Pointer(butPtr)).FtristateImagePtr, libc.UintptrFromInt32(0)), __ccgo_fp(_ButtonTristateImageProc), butPtr) if image == libc.UintptrFromInt32(0) { goto _1 } } else { image = libc.UintptrFromInt32(0) } if (*TTkButton)(unsafe.Pointer(butPtr)).FtristateImage != libc.UintptrFromInt32(0) { XTk_FreeImage(tls, (*TTkButton)(unsafe.Pointer(butPtr)).FtristateImage) } (*TTkButton)(unsafe.Pointer(butPtr)).FtristateImage = image haveImage = 0 if (*TTkButton)(unsafe.Pointer(butPtr)).FimagePtr != libc.UintptrFromInt32(0) || (*TTkButton)(unsafe.Pointer(butPtr)).Fbitmap != uint64(0) { haveImage = int32(1) } if (!(haveImage != 0) || (*TTkButton)(unsafe.Pointer(butPtr)).Fcompound != int32(COMPOUND_NONE)) && (*TTkButton)(unsafe.Pointer(butPtr)).FtextVarNamePtr != libc.UintptrFromInt32(0) { namePtr1 = (*TTkButton)(unsafe.Pointer(butPtr)).FtextVarNamePtr valuePtr1 = libtcl9_0.XTcl_ObjGetVar2(tls, interp, namePtr1, libc.UintptrFromInt32(0), int32(TCL_GLOBAL_ONLY)) if valuePtr1 == libc.UintptrFromInt32(0) { if libtcl9_0.XTcl_ObjSetVar2(tls, interp, namePtr1, libc.UintptrFromInt32(0), (*TTkButton)(unsafe.Pointer(butPtr)).FtextPtr, libc.Int32FromInt32(TCL_GLOBAL_ONLY)|libc.Int32FromInt32(TCL_LEAVE_ERR_MSG)) == libc.UintptrFromInt32(0) { goto _1 } } else { if (*TTkButton)(unsafe.Pointer(butPtr)).FtextPtr != libc.UintptrFromInt32(0) { _objPtr5 = (*TTkButton)(unsafe.Pointer(butPtr)).FtextPtr v14 = _objPtr5 v13 = *(*TTcl_Size)(unsafe.Pointer(v14)) *(*TTcl_Size)(unsafe.Pointer(v14))-- if v13 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr5) } } (*TTkButton)(unsafe.Pointer(butPtr)).FtextPtr = valuePtr1 (*TTcl_Obj)(unsafe.Pointer((*TTkButton)(unsafe.Pointer(butPtr)).FtextPtr)).FrefCount++ } } if !((*TTkButton)(unsafe.Pointer(butPtr)).Fbitmap != uint64(0) || (*TTkButton)(unsafe.Pointer(butPtr)).FimagePtr != libc.UintptrFromInt32(0)) { goto _15 } /* * The button must display the contents of an image or bitmap. */ if !(XTk_GetPixelsFromObj(tls, interp, (*TTkButton)(unsafe.Pointer(butPtr)).Ftkwin, (*TTkButton)(unsafe.Pointer(butPtr)).FwidthObj, bp+532) != TCL_OK) { goto _17 } goto widthError widthError: ; libtcl9_0.XTcl_AppendObjToErrorInfo(tls, interp, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+21001, int64(-int32(1)))) goto _1 _17: ; if !(XTk_GetPixelsFromObj(tls, interp, (*TTkButton)(unsafe.Pointer(butPtr)).Ftkwin, (*TTkButton)(unsafe.Pointer(butPtr)).FheightObj, bp+536) != TCL_OK) { goto _18 } goto heightError heightError: ; libtcl9_0.XTcl_AppendObjToErrorInfo(tls, interp, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+21035, int64(-int32(1)))) goto _1 _18: ; goto _16 _15: ; /* * The button displays an ordinary text string. */ if libtcl9_0.XTcl_GetIntFromObj(tls, interp, (*TTkButton)(unsafe.Pointer(butPtr)).FwidthObj, bp+532) != TCL_OK { goto widthError } if libtcl9_0.XTcl_GetIntFromObj(tls, interp, (*TTkButton)(unsafe.Pointer(butPtr)).FheightObj, bp+536) != TCL_OK { goto heightError } _16: ; break goto _1 _1: ; error1++ } if !(error1 != 0) { XTk_FreeSavedOptions(tls, bp) } /* * Reestablish the variable traces, if they're needed. */ if (*TTkButton)(unsafe.Pointer(butPtr)).FtextVarNamePtr != libc.UintptrFromInt32(0) { libtcl9_0.XTcl_TraceVar2(tls, interp, libtcl9_0.XTcl_GetStringFromObj(tls, (*TTkButton)(unsafe.Pointer(butPtr)).FtextVarNamePtr, libc.UintptrFromInt32(0)), libc.UintptrFromInt32(0), libc.Int32FromInt32(TCL_GLOBAL_ONLY)|libc.Int32FromInt32(TCL_TRACE_WRITES)|libc.Int32FromInt32(TCL_TRACE_UNSETS), __ccgo_fp(_ButtonTextVarProc), butPtr) } if (*TTkButton)(unsafe.Pointer(butPtr)).FselVarNamePtr != libc.UintptrFromInt32(0) { libtcl9_0.XTcl_TraceVar2(tls, interp, libtcl9_0.XTcl_GetStringFromObj(tls, (*TTkButton)(unsafe.Pointer(butPtr)).FselVarNamePtr, libc.UintptrFromInt32(0)), libc.UintptrFromInt32(0), libc.Int32FromInt32(TCL_GLOBAL_ONLY)|libc.Int32FromInt32(TCL_TRACE_WRITES)|libc.Int32FromInt32(TCL_TRACE_UNSETS), __ccgo_fp(_ButtonVarProc), butPtr) } XTkButtonWorldChanged(tls, butPtr) if error1 != 0 { libtcl9_0.XTcl_SetObjResult(tls, interp, errorResult) _objPtr6 = errorResult v20 = _objPtr6 v19 = *(*TTcl_Size)(unsafe.Pointer(v20)) *(*TTcl_Size)(unsafe.Pointer(v20))-- if v19 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr6) } return int32(TCL_ERROR) } else { return TCL_OK } return r } /* *--------------------------------------------------------------------------- * * TkButtonWorldChanged -- * * This function is called when the world has changed in some way and the * widget needs to recompute all its graphics contexts and determine its * new geometry. * * Results: * None. * * Side effects: * Button will be relayed out and redisplayed. * *--------------------------------------------------------------------------- */ func XTkButtonWorldChanged(tls *libc.TLS, instanceData uintptr) { bp := tls.Alloc(128) defer tls.Free(128) /* Information about widget. */ var butPtr uintptr var mask uint64 var newGC TGC var _ /* gcValues at bp+0 */ TXGCValues _, _, _ = butPtr, mask, newGC butPtr = instanceData /* * Recompute GCs. */ (*(*TXGCValues)(unsafe.Pointer(bp))).Ffont = XTk_FontId(tls, (*TTkButton)(unsafe.Pointer(butPtr)).Ftkfont) (*(*TXGCValues)(unsafe.Pointer(bp))).Fforeground = (*TXColor)(unsafe.Pointer((*TTkButton)(unsafe.Pointer(butPtr)).FnormalFg)).Fpixel (*(*TXGCValues)(unsafe.Pointer(bp))).Fbackground = (*TXColor)(unsafe.Pointer(XTk_3DBorderColor(tls, (*TTkButton)(unsafe.Pointer(butPtr)).FnormalBorder))).Fpixel /* * Note: GraphicsExpose events are disabled in normalTextGC because it's * used to copy stuff from an off-screen pixmap onto the screen (we know * that there's no problem with obscured areas). */ (*(*TXGCValues)(unsafe.Pointer(bp))).Fgraphics_exposures = False mask = libc.Uint64FromInt64(libc.Int64FromInt64(1)< 0 { goto redraw } } } else { if (*TXEvent)(unsafe.Pointer(eventPtr)).Ftype1 == int32(FocusOut) { if (*(*TXFocusChangeEvent)(unsafe.Pointer(eventPtr))).Fdetail != int32(NotifyInferior) { *(*int32)(unsafe.Pointer(butPtr + 452)) &= ^(libc.Int32FromInt32(1) << libc.Int32FromInt32(2)) XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), (*TTkButton)(unsafe.Pointer(butPtr)).Ftkwin, (*TTkButton)(unsafe.Pointer(butPtr)).FhighlightWidthObj, bp) if *(*int32)(unsafe.Pointer(bp)) > 0 { goto redraw } } } } } } } return goto redraw redraw: ; if (*TTkButton)(unsafe.Pointer(butPtr)).Ftkwin != libc.UintptrFromInt32(0) && !((*TTkButton)(unsafe.Pointer(butPtr)).Fflags&(libc.Int32FromInt32(1)<textVarNamePtr ? */ probe = libc.UintptrFromInt32(0) for cond := true; cond; cond = probe != 0 { probe = libtcl9_0.XTcl_VarTraceInfo2(tls, interp, libtcl9_0.XTcl_GetStringFromObj(tls, (*TTkButton)(unsafe.Pointer(butPtr)).FtextVarNamePtr, libc.UintptrFromInt32(0)), libc.UintptrFromInt32(0), libc.Int32FromInt32(TCL_GLOBAL_ONLY)|libc.Int32FromInt32(TCL_TRACE_WRITES)|libc.Int32FromInt32(TCL_TRACE_UNSETS), __ccgo_fp(_ButtonTextVarProc), probe) if probe == butPtr { break } } if probe != 0 { /* * We were able to fetch the unset trace for our * textVarNamePtr, which means it is not unset and not * the cause of this unset trace. Instead some outdated * former textvariable must be, and we should ignore it. */ return libc.UintptrFromInt32(0) } libtcl9_0.XTcl_ObjSetVar2(tls, interp, (*TTkButton)(unsafe.Pointer(butPtr)).FtextVarNamePtr, libc.UintptrFromInt32(0), (*TTkButton)(unsafe.Pointer(butPtr)).FtextPtr, int32(TCL_GLOBAL_ONLY)) libtcl9_0.XTcl_TraceVar2(tls, interp, libtcl9_0.XTcl_GetStringFromObj(tls, (*TTkButton)(unsafe.Pointer(butPtr)).FtextVarNamePtr, libc.UintptrFromInt32(0)), libc.UintptrFromInt32(0), libc.Int32FromInt32(TCL_GLOBAL_ONLY)|libc.Int32FromInt32(TCL_TRACE_WRITES)|libc.Int32FromInt32(TCL_TRACE_UNSETS), __ccgo_fp(_ButtonTextVarProc), clientData) } return libc.UintptrFromInt32(0) } valuePtr = libtcl9_0.XTcl_ObjGetVar2(tls, interp, (*TTkButton)(unsafe.Pointer(butPtr)).FtextVarNamePtr, libc.UintptrFromInt32(0), int32(TCL_GLOBAL_ONLY)) if valuePtr == libc.UintptrFromInt32(0) { valuePtr = libtcl9_0.XTcl_NewObj(tls) } _objPtr = (*TTkButton)(unsafe.Pointer(butPtr)).FtextPtr v2 = _objPtr v1 = *(*TTcl_Size)(unsafe.Pointer(v2)) *(*TTcl_Size)(unsafe.Pointer(v2))-- if v1 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr) } (*TTkButton)(unsafe.Pointer(butPtr)).FtextPtr = valuePtr (*TTcl_Obj)(unsafe.Pointer((*TTkButton)(unsafe.Pointer(butPtr)).FtextPtr)).FrefCount++ XTkpComputeButtonGeometry(tls, butPtr) if (*TTkButton)(unsafe.Pointer(butPtr)).Ftkwin != libc.UintptrFromInt32(0) && (*TTk_FakeWin)(unsafe.Pointer((*TTkButton)(unsafe.Pointer(butPtr)).Ftkwin)).Fflags&uint32(TK_MAPPED) != 0 && !((*TTkButton)(unsafe.Pointer(butPtr)).Fflags&(libc.Int32FromInt32(1)< int64(1) { *(*TTcl_Size)(unsafe.Pointer(bp + 8))-- } XTk_CharBbox(tls, (*TEntry)(unsafe.Pointer(entryPtr)).FtextLayout, *(*TTcl_Size)(unsafe.Pointer(bp + 8)), bp+16, bp+20, bp+24, bp+28) (*(*[4]uintptr)(unsafe.Pointer(bp + 32)))[0] = libtcl9_0.XTcl_NewWideIntObj(tls, int64(*(*int32)(unsafe.Pointer(bp + 16))+(*TEntry)(unsafe.Pointer(entryPtr)).FlayoutX)) (*(*[4]uintptr)(unsafe.Pointer(bp + 32)))[int32(1)] = libtcl9_0.XTcl_NewWideIntObj(tls, int64(*(*int32)(unsafe.Pointer(bp + 20))+(*TEntry)(unsafe.Pointer(entryPtr)).FlayoutY)) (*(*[4]uintptr)(unsafe.Pointer(bp + 32)))[int32(2)] = libtcl9_0.XTcl_NewWideIntObj(tls, int64(*(*int32)(unsafe.Pointer(bp + 24)))) (*(*[4]uintptr)(unsafe.Pointer(bp + 32)))[int32(3)] = libtcl9_0.XTcl_NewWideIntObj(tls, int64(*(*int32)(unsafe.Pointer(bp + 28)))) libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewListObj(tls, int64(4), bp+32)) case int32(COMMAND_CGET1): if objc != int32(3) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(2), objv, __ccgo_ts+2689) goto error } objPtr = XTk_GetOptionValue(tls, interp, entryPtr, (*TEntry)(unsafe.Pointer(entryPtr)).FoptionTable, *(*uintptr)(unsafe.Pointer(objv + 2*8)), (*TEntry)(unsafe.Pointer(entryPtr)).Ftkwin) if objPtr == libc.UintptrFromInt32(0) { goto error } libtcl9_0.XTcl_SetObjResult(tls, interp, objPtr) case int32(COMMAND_CONFIGURE1): if objc <= int32(3) { if objc == int32(3) { v1 = *(*uintptr)(unsafe.Pointer(objv + 2*8)) } else { v1 = libc.UintptrFromInt32(0) } objPtr = XTk_GetOptionInfo(tls, interp, entryPtr, (*TEntry)(unsafe.Pointer(entryPtr)).FoptionTable, v1, (*TEntry)(unsafe.Pointer(entryPtr)).Ftkwin) if objPtr == libc.UintptrFromInt32(0) { goto error } libtcl9_0.XTcl_SetObjResult(tls, interp, objPtr) } else { result = _ConfigureEntry(tls, interp, entryPtr, int64(objc-int32(2)), objv+uintptr(2)*8) } case int32(COMMAND_DELETE): if objc < int32(3) || objc > int32(4) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(2), objv, __ccgo_ts+22240) goto error } if _GetEntryIndex(tls, interp, entryPtr, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+64) != TCL_OK { goto error } if objc == int32(3) { *(*TTcl_Size)(unsafe.Pointer(bp + 72)) = *(*TTcl_Size)(unsafe.Pointer(bp + 64)) + int64(1) } else { if _GetEntryIndex(tls, interp, entryPtr, *(*uintptr)(unsafe.Pointer(objv + 3*8)), bp+72) != TCL_OK { goto error } } if *(*TTcl_Size)(unsafe.Pointer(bp + 72)) >= *(*TTcl_Size)(unsafe.Pointer(bp + 64)) && (*TEntry)(unsafe.Pointer(entryPtr)).Fstate == int32(STATE_NORMAL1) { code = _DeleteChars(tls, entryPtr, *(*TTcl_Size)(unsafe.Pointer(bp + 64)), *(*TTcl_Size)(unsafe.Pointer(bp + 72))-*(*TTcl_Size)(unsafe.Pointer(bp + 64))) if code != TCL_OK { goto error } } case int32(COMMAND_GET): if objc != int32(2) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(2), objv, libc.UintptrFromInt32(0)) goto error } libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewStringObj(tls, (*TEntry)(unsafe.Pointer(entryPtr)).Fstring1, int64(-libc.Int32FromInt32(1)))) case int32(COMMAND_ICURSOR): if objc != int32(3) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(2), objv, __ccgo_ts+22263) goto error } if _GetEntryIndex(tls, interp, entryPtr, *(*uintptr)(unsafe.Pointer(objv + 2*8)), entryPtr+56) != TCL_OK { goto error } _EventuallyRedraw(tls, entryPtr) case int32(COMMAND_INDEX): if objc != int32(3) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(2), objv, __ccgo_ts+22267) goto error } if _GetEntryIndex(tls, interp, entryPtr, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+80) != TCL_OK { goto error } if *(*TTcl_Size)(unsafe.Pointer(bp + 80)) == int64(-libc.Int32FromInt32(1)) { v2 = libtcl9_0.XTcl_NewObj(tls) } else { v2 = libtcl9_0.XTcl_NewWideIntObj(tls, *(*TTcl_Size)(unsafe.Pointer(bp + 80))) } libtcl9_0.XTcl_SetObjResult(tls, interp, v2) case int32(COMMAND_INSERT): if objc != int32(4) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(2), objv, __ccgo_ts+22274) goto error } if _GetEntryIndex(tls, interp, entryPtr, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+88) != TCL_OK { goto error } if (*TEntry)(unsafe.Pointer(entryPtr)).Fstate == int32(STATE_NORMAL1) { code1 = _InsertChars(tls, entryPtr, *(*TTcl_Size)(unsafe.Pointer(bp + 88)), *(*uintptr)(unsafe.Pointer(objv + 3*8))) if code1 != TCL_OK { goto error } } case int32(COMMAND_SCAN): if objc != int32(4) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(2), objv, __ccgo_ts+22285) goto error } if libtcl9_0.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 3*8)), bp+96) != TCL_OK { goto error } minorCmd = libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8)), libc.UintptrFromInt32(0)) if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(minorCmd))) == int32('m') && libc.Xstrncmp(tls, minorCmd, __ccgo_ts+2046, libc.Xstrlen(tls, minorCmd)) == 0 { (*TEntry)(unsafe.Pointer(entryPtr)).FscanMarkX = *(*int32)(unsafe.Pointer(bp + 96)) (*TEntry)(unsafe.Pointer(entryPtr)).FscanMarkIndex = int32((*TEntry)(unsafe.Pointer(entryPtr)).FleftIndex) } else { if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(minorCmd))) == int32('d') && libc.Xstrncmp(tls, minorCmd, __ccgo_ts+22299, libc.Xstrlen(tls, minorCmd)) == 0 { _EntryScanTo(tls, entryPtr, *(*int32)(unsafe.Pointer(bp + 96))) } else { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+22306, libc.VaList(bp+184, minorCmd))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+184, __ccgo_ts+5785, __ccgo_ts+3058, __ccgo_ts+5789, __ccgo_ts+22351, minorCmd, libc.UintptrFromInt32(0))) goto error } } case int32(COMMAND_SELECTION): if objc < int32(3) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(2), objv, __ccgo_ts+22363) goto error } /* * Parse the selection sub-command, using the command table * "selCmdNames" defined above. */ result = libtcl9_0.XTcl_GetIndexFromObjStruct(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), uintptr(unsafe.Pointer(&_selCmdNames)), libc.Int64FromUint64(libc.Uint64FromInt64(8)), __ccgo_ts+22378, libc.Int32FromInt32(0)|libc.Int32FromUint64(libc.Uint64FromInt64(4)< half2 { (*TEntry)(unsafe.Pointer(entryPtr)).FselectAnchor = (*TEntry)(unsafe.Pointer(entryPtr)).FselectFirst } else { /* * We're at about the halfway point in the selection; just * keep the existing anchor. */ } } } _EntrySelectTo(tls, entryPtr, *(*TTcl_Size)(unsafe.Pointer(bp + 104))) case int32(SELECTION_CLEAR): if objc != int32(3) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(3), objv, libc.UintptrFromInt32(0)) goto error } if (*TEntry)(unsafe.Pointer(entryPtr)).FselectFirst != int64(-libc.Int32FromInt32(1)) { (*TEntry)(unsafe.Pointer(entryPtr)).FselectFirst = int64(-libc.Int32FromInt32(1)) (*TEntry)(unsafe.Pointer(entryPtr)).FselectLast = int64(-libc.Int32FromInt32(1)) _EventuallyRedraw(tls, entryPtr) } goto done case int32(SELECTION_FROM): if objc != int32(4) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(3), objv, __ccgo_ts+22152) goto error } if _GetEntryIndex(tls, interp, entryPtr, *(*uintptr)(unsafe.Pointer(objv + 3*8)), bp+104) != TCL_OK { goto error } (*TEntry)(unsafe.Pointer(entryPtr)).FselectAnchor = *(*TTcl_Size)(unsafe.Pointer(bp + 104)) case int32(SELECTION_PRESENT): if objc != int32(3) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(3), objv, libc.UintptrFromInt32(0)) goto error } libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewWideIntObj(tls, libc.BoolInt64(libc.BoolInt32((*TEntry)(unsafe.Pointer(entryPtr)).FselectFirst != int64(-libc.Int32FromInt32(1))) != 0))) goto done case int32(SELECTION_RANGE): if objc != int32(5) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(3), objv, __ccgo_ts+22395) goto error } if _GetEntryIndex(tls, interp, entryPtr, *(*uintptr)(unsafe.Pointer(objv + 3*8)), bp+104) != TCL_OK { goto error } if _GetEntryIndex(tls, interp, entryPtr, *(*uintptr)(unsafe.Pointer(objv + 4*8)), bp+112) != TCL_OK { goto error } if *(*TTcl_Size)(unsafe.Pointer(bp + 104)) >= *(*TTcl_Size)(unsafe.Pointer(bp + 112)) { (*TEntry)(unsafe.Pointer(entryPtr)).FselectFirst = int64(-libc.Int32FromInt32(1)) (*TEntry)(unsafe.Pointer(entryPtr)).FselectLast = int64(-libc.Int32FromInt32(1)) } else { (*TEntry)(unsafe.Pointer(entryPtr)).FselectFirst = *(*TTcl_Size)(unsafe.Pointer(bp + 104)) (*TEntry)(unsafe.Pointer(entryPtr)).FselectLast = *(*TTcl_Size)(unsafe.Pointer(bp + 112)) } if !((*TEntry)(unsafe.Pointer(entryPtr)).Fflags&libc.Int32FromInt32(GOT_SELECTION) != 0) && (*TEntry)(unsafe.Pointer(entryPtr)).FexportSelection != 0 && !(libtcl9_0.XTcl_IsSafe(tls, (*TEntry)(unsafe.Pointer(entryPtr)).Finterp) != 0) { XTk_OwnSelection(tls, (*TEntry)(unsafe.Pointer(entryPtr)).Ftkwin, libc.Uint64FromInt32(1), __ccgo_fp(_EntryLostSelection), entryPtr) *(*int32)(unsafe.Pointer(entryPtr + 416)) |= int32(GOT_SELECTION) } _EventuallyRedraw(tls, entryPtr) case int32(SELECTION_TO): if objc != int32(4) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(3), objv, __ccgo_ts+22152) goto error } if _GetEntryIndex(tls, interp, entryPtr, *(*uintptr)(unsafe.Pointer(objv + 3*8)), bp+104) != TCL_OK { goto error } _EntrySelectTo(tls, entryPtr, *(*TTcl_Size)(unsafe.Pointer(bp + 104))) break } case int32(COMMAND_VALIDATE): if objc != int32(2) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(2), objv, libc.UintptrFromInt32(0)) goto error } *(*int32)(unsafe.Pointer(bp + 4)) = (*TEntry)(unsafe.Pointer(entryPtr)).Fvalidate (*TEntry)(unsafe.Pointer(entryPtr)).Fvalidate = int32(VALIDATE_ALL) code2 = _EntryValidateChange(tls, entryPtr, libc.UintptrFromInt32(0), (*TEntry)(unsafe.Pointer(entryPtr)).Fstring1, int64(-int32(1)), int32(VALIDATE_FORCED)) if (*TEntry)(unsafe.Pointer(entryPtr)).Fvalidate != int32(VALIDATE_NONE) { (*TEntry)(unsafe.Pointer(entryPtr)).Fvalidate = *(*int32)(unsafe.Pointer(bp + 4)) } libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewWideIntObj(tls, libc.BoolInt64(libc.BoolInt32(code2 == TCL_OK) != 0))) case int32(COMMAND_XVIEW): if objc == int32(2) { _EntryVisibleRange(tls, entryPtr, bp+128, bp+136) (*(*[2]uintptr)(unsafe.Pointer(bp + 144)))[0] = libtcl9_0.XTcl_NewDoubleObj(tls, *(*float64)(unsafe.Pointer(bp + 128))) (*(*[2]uintptr)(unsafe.Pointer(bp + 144)))[int32(1)] = libtcl9_0.XTcl_NewDoubleObj(tls, *(*float64)(unsafe.Pointer(bp + 136))) libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewListObj(tls, int64(2), bp+144)) goto done } else { if objc == int32(3) { if _GetEntryIndex(tls, interp, entryPtr, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+120) != TCL_OK { goto error } } else { *(*TTcl_Size)(unsafe.Pointer(bp + 120)) = (*TEntry)(unsafe.Pointer(entryPtr)).FleftIndex switch XTk_GetScrollInfoObj(tls, interp, int64(objc), objv, bp+160, bp+168) { case int32(TK_SCROLL_MOVETO): *(*TTcl_Size)(unsafe.Pointer(bp + 120)) = int64(int32(float64(*(*float64)(unsafe.Pointer(bp + 160))*float64((*TEntry)(unsafe.Pointer(entryPtr)).FnumChars)) + libc.Float64FromFloat64(0.5))) case int32(TK_SCROLL_PAGES): charsPerPage = ((*TTk_FakeWin)(unsafe.Pointer((*TEntry)(unsafe.Pointer(entryPtr)).Ftkwin)).Fchanges.Fwidth-int32(2)*(*TEntry)(unsafe.Pointer(entryPtr)).Finset)/(*TEntry)(unsafe.Pointer(entryPtr)).FavgWidth - int32(2) if charsPerPage < int32(1) { charsPerPage = int32(1) } *(*TTcl_Size)(unsafe.Pointer(bp + 120)) += int64(*(*int32)(unsafe.Pointer(bp + 168)) * charsPerPage) case int32(TK_SCROLL_UNITS): *(*TTcl_Size)(unsafe.Pointer(bp + 120)) += int64(*(*int32)(unsafe.Pointer(bp + 168))) default: goto error } } } if *(*TTcl_Size)(unsafe.Pointer(bp + 120)) >= (*TEntry)(unsafe.Pointer(entryPtr)).FnumChars { *(*TTcl_Size)(unsafe.Pointer(bp + 120)) = (*TEntry)(unsafe.Pointer(entryPtr)).FnumChars - int64(1) } if int32(*(*TTcl_Size)(unsafe.Pointer(bp + 120))) < 0 { *(*TTcl_Size)(unsafe.Pointer(bp + 120)) = 0 } (*TEntry)(unsafe.Pointer(entryPtr)).FleftIndex = *(*TTcl_Size)(unsafe.Pointer(bp + 120)) *(*int32)(unsafe.Pointer(entryPtr + 416)) |= int32(UPDATE_SCROLLBAR) _EntryComputeGeometry(tls, entryPtr) _EventuallyRedraw(tls, entryPtr) break } goto done done: ; libtcl9_0.XTcl_Release(tls, entryPtr) return result goto error error: ; libtcl9_0.XTcl_Release(tls, entryPtr) return int32(TCL_ERROR) } /* *---------------------------------------------------------------------- * * DestroyEntry -- * * This function is invoked by Tcl_EventuallyFree or Tcl_Release to clean * up the internal structure of an entry at a safe time (when no-one is * using it anymore). * * Results: * None. * * Side effects: * Everything associated with the entry is freed up. * *---------------------------------------------------------------------- */ func _DestroyEntry(tls *libc.TLS, memPtr uintptr) { /* Info about entry widget. */ var _objPtr, entryPtr, sbPtr, v2 uintptr var v1 TTcl_Size _, _, _, _, _ = _objPtr, entryPtr, sbPtr, v1, v2 entryPtr = memPtr /* * Free up all the stuff that requires special handling, then let * Tk_FreeOptions handle all the standard option-related stuff. */ libtcl9_0.XTcl_Free(tls, (*TEntry)(unsafe.Pointer(entryPtr)).Fstring1) if (*TEntry)(unsafe.Pointer(entryPtr)).FtextVarNameObj != libc.UintptrFromInt32(0) { libtcl9_0.XTcl_UntraceVar2(tls, (*TEntry)(unsafe.Pointer(entryPtr)).Finterp, libtcl9_0.XTcl_GetStringFromObj(tls, (*TEntry)(unsafe.Pointer(entryPtr)).FtextVarNameObj, libc.UintptrFromInt32(0)), libc.UintptrFromInt32(0), libc.Int32FromInt32(TCL_GLOBAL_ONLY)|libc.Int32FromInt32(TCL_TRACE_WRITES)|libc.Int32FromInt32(TCL_TRACE_UNSETS), __ccgo_fp(_EntryTextVarProc), entryPtr) *(*int32)(unsafe.Pointer(entryPtr + 416)) &= ^libc.Int32FromInt32(ENTRY_VAR_TRACED) } if (*TEntry)(unsafe.Pointer(entryPtr)).FtextGC != libc.UintptrFromInt32(0) { XTk_FreeGC(tls, (*TEntry)(unsafe.Pointer(entryPtr)).Fdisplay, (*TEntry)(unsafe.Pointer(entryPtr)).FtextGC) } if (*TEntry)(unsafe.Pointer(entryPtr)).FselTextGC != libc.UintptrFromInt32(0) { XTk_FreeGC(tls, (*TEntry)(unsafe.Pointer(entryPtr)).Fdisplay, (*TEntry)(unsafe.Pointer(entryPtr)).FselTextGC) } libtcl9_0.XTcl_DeleteTimerHandler(tls, (*TEntry)(unsafe.Pointer(entryPtr)).FinsertBlinkHandler) if (*TEntry)(unsafe.Pointer(entryPtr)).FdisplayString != (*TEntry)(unsafe.Pointer(entryPtr)).Fstring1 { libtcl9_0.XTcl_Free(tls, (*TEntry)(unsafe.Pointer(entryPtr)).FdisplayString) } if (*TEntry)(unsafe.Pointer(entryPtr)).Ftype1 == int32(TK_SPINBOX) { sbPtr = entryPtr if (*TSpinbox)(unsafe.Pointer(sbPtr)).FlistObj != libc.UintptrFromInt32(0) { _objPtr = (*TSpinbox)(unsafe.Pointer(sbPtr)).FlistObj v2 = _objPtr v1 = *(*TTcl_Size)(unsafe.Pointer(v2)) *(*TTcl_Size)(unsafe.Pointer(v2))-- if v1 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr) } (*TSpinbox)(unsafe.Pointer(sbPtr)).FlistObj = libc.UintptrFromInt32(0) } if (*TSpinbox)(unsafe.Pointer(sbPtr)).FformatBuf != 0 { libtcl9_0.XTcl_Free(tls, (*TSpinbox)(unsafe.Pointer(sbPtr)).FformatBuf) } } XTk_FreeTextLayout(tls, (*TEntry)(unsafe.Pointer(entryPtr)).FtextLayout) XTk_FreeConfigOptions(tls, entryPtr, (*TEntry)(unsafe.Pointer(entryPtr)).FoptionTable, (*TEntry)(unsafe.Pointer(entryPtr)).Ftkwin) libtcl9_0.XTcl_Release(tls, (*TEntry)(unsafe.Pointer(entryPtr)).Ftkwin) (*TEntry)(unsafe.Pointer(entryPtr)).Ftkwin = libc.UintptrFromInt32(0) libtcl9_0.XTcl_Free(tls, entryPtr) } /* *---------------------------------------------------------------------- * * ConfigureEntry -- * * This function is called to process an argv/argc list, plus the Tk * option database, in order to configure (or reconfigure) an entry * widget. * * Results: * The return value is a standard Tcl result. If TCL_ERROR is returned, * then the interp's result contains an error message. * * Side effects: * Configuration information, such as colors, border width, etc. get set * for entryPtr; old resources get freed, if there were any. * *---------------------------------------------------------------------- */ func _ConfigureEntry(tls *libc.TLS, interp uintptr, entryPtr uintptr, objc TTcl_Size, objv uintptr) (r int32) { bp := tls.Alloc(608) defer tls.Free(608) /* Argument objects. */ var _objPtr, _objPtr1, _objPtr2, _objPtr3, _objPtr4, _objPtr5, _objPtr6, errorResult, fmt, newObjPtr, oldFormat, oldValues, sbPtr, value, v11, v15, v17, v3, v5, v7, v9 uintptr var border TTk_3DBorder var code, error1, oldExport, validate, valuesChanged int32 var formatLen, formatSpace Tsize_t var oldFrom, oldTo, tmpFromTo float64 var v10, v14, v16, v2, v4, v6, v8 TTcl_Size var _ /* borderWidth at bp+512 */ int32 var _ /* dvalue at bp+560 */ float64 var _ /* fbuf at bp+540 */ [4]uint8 var _ /* highlightWidth at bp+516 */ int32 var _ /* insertBorderWidth at bp+524 */ int32 var _ /* insertWidth at bp+520 */ int32 var _ /* max at bp+536 */ int32 var _ /* min at bp+532 */ int32 var _ /* nelems at bp+544 */ TTcl_Size var _ /* objPtr at bp+552 */ uintptr var _ /* savedOptions at bp+0 */ TTk_SavedOptions var _ /* selBorderWidth at bp+528 */ int32 _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = _objPtr, _objPtr1, _objPtr2, _objPtr3, _objPtr4, _objPtr5, _objPtr6, border, code, error1, errorResult, fmt, formatLen, formatSpace, newObjPtr, oldExport, oldFormat, oldFrom, oldTo, oldValues, sbPtr, tmpFromTo, validate, value, valuesChanged, v10, v11, v14, v15, v16, v17, v2, v3, v4, v5, v6, v7, v8, v9 errorResult = libc.UintptrFromInt32(0) sbPtr = entryPtr /* Only used when this widget is of type * TK_SPINBOX */ oldValues = libc.UintptrFromInt32(0) oldFormat = libc.UintptrFromInt32(0) oldExport = 0 valuesChanged = 0 oldFrom = float64(0) oldTo = float64(0) formatSpace = libc.Uint64FromInt32(libc.Int32FromInt32(TCL_MAX_PREC) + libc.Int32FromInt32(10)) /* * Eliminate any existing trace on a variable monitored by the entry. */ if (*TEntry)(unsafe.Pointer(entryPtr)).FtextVarNameObj != libc.UintptrFromInt32(0) && (*TEntry)(unsafe.Pointer(entryPtr)).Fflags&int32(ENTRY_VAR_TRACED) != 0 { libtcl9_0.XTcl_UntraceVar2(tls, interp, libtcl9_0.XTcl_GetStringFromObj(tls, (*TEntry)(unsafe.Pointer(entryPtr)).FtextVarNameObj, libc.UintptrFromInt32(0)), libc.UintptrFromInt32(0), libc.Int32FromInt32(TCL_GLOBAL_ONLY)|libc.Int32FromInt32(TCL_TRACE_WRITES)|libc.Int32FromInt32(TCL_TRACE_UNSETS), __ccgo_fp(_EntryTextVarProc), entryPtr) *(*int32)(unsafe.Pointer(entryPtr + 416)) &= ^libc.Int32FromInt32(ENTRY_VAR_TRACED) } /* * Store old values that we need to effect certain behavior if they change * value. */ oldExport = libc.BoolInt32((*TEntry)(unsafe.Pointer(entryPtr)).FexportSelection != 0 && !(libtcl9_0.XTcl_IsSafe(tls, (*TEntry)(unsafe.Pointer(entryPtr)).Finterp) != 0)) if (*TEntry)(unsafe.Pointer(entryPtr)).Ftype1 == int32(TK_SPINBOX) { oldValues = (*TSpinbox)(unsafe.Pointer(sbPtr)).FvalueObj oldFormat = (*TSpinbox)(unsafe.Pointer(sbPtr)).FreqFormatObj oldFrom = (*TSpinbox)(unsafe.Pointer(sbPtr)).FfromValue oldTo = (*TSpinbox)(unsafe.Pointer(sbPtr)).FtoValue } error1 = 0 for { if !(error1 <= int32(1)) { break } if !(error1 != 0) { /* * First pass: set options to new values. */ if XTk_SetOptions(tls, interp, entryPtr, (*TEntry)(unsafe.Pointer(entryPtr)).FoptionTable, objc, objv, (*TEntry)(unsafe.Pointer(entryPtr)).Ftkwin, bp, libc.UintptrFromInt32(0)) != TCL_OK { goto _1 } } else { /* * Second pass: restore options to old values. */ errorResult = libtcl9_0.XTcl_GetObjResult(tls, interp) (*TTcl_Obj)(unsafe.Pointer(errorResult)).FrefCount++ XTk_RestoreSavedOptions(tls, bp) } /* * A few other options also need special processing, such as parsing * the geometry and setting the background from a 3-D border. */ if (*TEntry)(unsafe.Pointer(entryPtr)).Fstate == int32(STATE_DISABLED1) && (*TEntry)(unsafe.Pointer(entryPtr)).FdisabledBorder != libc.UintptrFromInt32(0) { border = (*TEntry)(unsafe.Pointer(entryPtr)).FdisabledBorder } else { if (*TEntry)(unsafe.Pointer(entryPtr)).Fstate == int32(STATE_READONLY) && (*TEntry)(unsafe.Pointer(entryPtr)).FreadonlyBorder != libc.UintptrFromInt32(0) { border = (*TEntry)(unsafe.Pointer(entryPtr)).FreadonlyBorder } else { border = (*TEntry)(unsafe.Pointer(entryPtr)).FnormalBorder } } XTk_SetBackgroundFromBorder(tls, (*TEntry)(unsafe.Pointer(entryPtr)).Ftkwin, border) XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), (*TEntry)(unsafe.Pointer(entryPtr)).Ftkwin, (*TEntry)(unsafe.Pointer(entryPtr)).FborderWidthObj, bp+512) if *(*int32)(unsafe.Pointer(bp + 512)) < 0 { *(*int32)(unsafe.Pointer(bp + 512)) = 0 _objPtr = (*TEntry)(unsafe.Pointer(entryPtr)).FborderWidthObj v3 = _objPtr v2 = *(*TTcl_Size)(unsafe.Pointer(v3)) *(*TTcl_Size)(unsafe.Pointer(v3))-- if v2 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr) } (*TEntry)(unsafe.Pointer(entryPtr)).FborderWidthObj = libtcl9_0.XTcl_NewWideIntObj(tls, int64(libc.Int32FromInt32(0))) (*TTcl_Obj)(unsafe.Pointer((*TEntry)(unsafe.Pointer(entryPtr)).FborderWidthObj)).FrefCount++ } XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), (*TEntry)(unsafe.Pointer(entryPtr)).Ftkwin, (*TEntry)(unsafe.Pointer(entryPtr)).FhighlightWidthObj, bp+516) if *(*int32)(unsafe.Pointer(bp + 516)) < 0 { *(*int32)(unsafe.Pointer(bp + 516)) = 0 _objPtr1 = (*TEntry)(unsafe.Pointer(entryPtr)).FhighlightWidthObj v5 = _objPtr1 v4 = *(*TTcl_Size)(unsafe.Pointer(v5)) *(*TTcl_Size)(unsafe.Pointer(v5))-- if v4 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr1) } (*TEntry)(unsafe.Pointer(entryPtr)).FhighlightWidthObj = libtcl9_0.XTcl_NewWideIntObj(tls, int64(libc.Int32FromInt32(0))) (*TTcl_Obj)(unsafe.Pointer((*TEntry)(unsafe.Pointer(entryPtr)).FhighlightWidthObj)).FrefCount++ } XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), (*TEntry)(unsafe.Pointer(entryPtr)).Ftkwin, (*TEntry)(unsafe.Pointer(entryPtr)).FinsertBorderWidthObj, bp+524) if *(*int32)(unsafe.Pointer(bp + 524)) < 0 { *(*int32)(unsafe.Pointer(bp + 524)) = 0 _objPtr2 = (*TEntry)(unsafe.Pointer(entryPtr)).FinsertBorderWidthObj v7 = _objPtr2 v6 = *(*TTcl_Size)(unsafe.Pointer(v7)) *(*TTcl_Size)(unsafe.Pointer(v7))-- if v6 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr2) } (*TEntry)(unsafe.Pointer(entryPtr)).FinsertBorderWidthObj = libtcl9_0.XTcl_NewWideIntObj(tls, int64(libc.Int32FromInt32(0))) (*TTcl_Obj)(unsafe.Pointer((*TEntry)(unsafe.Pointer(entryPtr)).FinsertBorderWidthObj)).FrefCount++ } XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), (*TEntry)(unsafe.Pointer(entryPtr)).Ftkwin, (*TEntry)(unsafe.Pointer(entryPtr)).FinsertWidthObj, bp+520) if *(*int32)(unsafe.Pointer(bp + 520)) < 0 { *(*int32)(unsafe.Pointer(bp + 520)) = 0 _objPtr3 = (*TEntry)(unsafe.Pointer(entryPtr)).FinsertWidthObj v9 = _objPtr3 v8 = *(*TTcl_Size)(unsafe.Pointer(v9)) *(*TTcl_Size)(unsafe.Pointer(v9))-- if v8 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr3) } (*TEntry)(unsafe.Pointer(entryPtr)).FinsertWidthObj = libtcl9_0.XTcl_NewWideIntObj(tls, int64(libc.Int32FromInt32(0))) (*TTcl_Obj)(unsafe.Pointer((*TEntry)(unsafe.Pointer(entryPtr)).FinsertWidthObj)).FrefCount++ } XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), (*TEntry)(unsafe.Pointer(entryPtr)).Ftkwin, (*TEntry)(unsafe.Pointer(entryPtr)).FselBorderWidthObj, bp+528) if *(*int32)(unsafe.Pointer(bp + 528)) < 0 { *(*int32)(unsafe.Pointer(bp + 528)) = 0 _objPtr4 = (*TEntry)(unsafe.Pointer(entryPtr)).FselBorderWidthObj v11 = _objPtr4 v10 = *(*TTcl_Size)(unsafe.Pointer(v11)) *(*TTcl_Size)(unsafe.Pointer(v11))-- if v10 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr4) } (*TEntry)(unsafe.Pointer(entryPtr)).FselBorderWidthObj = libtcl9_0.XTcl_NewWideIntObj(tls, int64(libc.Int32FromInt32(0))) (*TTcl_Obj)(unsafe.Pointer((*TEntry)(unsafe.Pointer(entryPtr)).FselBorderWidthObj)).FrefCount++ } if (*TEntry)(unsafe.Pointer(entryPtr)).Ftype1 == int32(TK_SPINBOX) { if (*TSpinbox)(unsafe.Pointer(sbPtr)).FfromValue > (*TSpinbox)(unsafe.Pointer(sbPtr)).FtoValue { /* * Swap -from and -to values. */ tmpFromTo = (*TSpinbox)(unsafe.Pointer(sbPtr)).FfromValue (*TSpinbox)(unsafe.Pointer(sbPtr)).FfromValue = (*TSpinbox)(unsafe.Pointer(sbPtr)).FtoValue (*TSpinbox)(unsafe.Pointer(sbPtr)).FtoValue = tmpFromTo } if !((*TSpinbox)(unsafe.Pointer(sbPtr)).FreqFormatObj != 0 && oldFormat != (*TSpinbox)(unsafe.Pointer(sbPtr)).FreqFormatObj) { goto _12 } fmt = libtcl9_0.XTcl_GetStringFromObj(tls, (*TSpinbox)(unsafe.Pointer(sbPtr)).FreqFormatObj, libc.UintptrFromInt32(0)) formatLen = libc.Xstrlen(tls, fmt) if !(libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(fmt))) != int32('%') || libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(fmt + uintptr(formatLen-uint64(1))))) != int32('f')) { goto _13 } goto badFormatOpt badFormatOpt: ; libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+22405, libc.VaList(bp+576, libtcl9_0.XTcl_GetStringFromObj(tls, (*TSpinbox)(unsafe.Pointer(sbPtr)).FreqFormatObj, libc.UintptrFromInt32(0))))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+576, __ccgo_ts+179, __ccgo_ts+22439, __ccgo_ts+22447, libc.UintptrFromInt32(0))) goto _1 _13: ; if libc.Xsscanf(tls, fmt, __ccgo_ts+22461, libc.VaList(bp+576, bp+532, bp+536, bp+540)) == int32(3) && *(*int32)(unsafe.Pointer(bp + 536)) >= 0 { formatSpace = libc.Uint64FromInt32(*(*int32)(unsafe.Pointer(bp + 532)) + *(*int32)(unsafe.Pointer(bp + 536)) + int32(1)) } else { if (libc.Xsscanf(tls, fmt, __ccgo_ts+22473, libc.VaList(bp+576, bp+532, bp+540)) == int32(2) || libc.Xsscanf(tls, fmt, __ccgo_ts+22483, libc.VaList(bp+576, bp+532, bp+540)) == int32(2) || libc.Xsscanf(tls, fmt, __ccgo_ts+22492, libc.VaList(bp+576, bp+532, bp+540)) == int32(2)) && *(*int32)(unsafe.Pointer(bp + 532)) >= 0 { formatSpace = libc.Uint64FromInt32(*(*int32)(unsafe.Pointer(bp + 532)) + int32(1)) } else { goto badFormatOpt } } if formatSpace < libc.Uint64FromInt32(libc.Int32FromInt32(TCL_MAX_PREC)+libc.Int32FromInt32(10)) { formatSpace = libc.Uint64FromInt32(libc.Int32FromInt32(TCL_MAX_PREC) + libc.Int32FromInt32(10)) } (*TSpinbox)(unsafe.Pointer(sbPtr)).FformatBuf = libtcl9_0.XTcl_Realloc(tls, (*TSpinbox)(unsafe.Pointer(sbPtr)).FformatBuf, formatSpace) /* * We perturb the value of oldFrom to allow us to go into the * branch below that will reformat the displayed value. */ oldFrom = (*TSpinbox)(unsafe.Pointer(sbPtr)).FfromValue - libc.Float64FromInt32(1) _12: ; /* * See if we have to rearrange our listObj data. */ if oldValues != (*TSpinbox)(unsafe.Pointer(sbPtr)).FvalueObj { if (*TSpinbox)(unsafe.Pointer(sbPtr)).FlistObj != libc.UintptrFromInt32(0) { _objPtr5 = (*TSpinbox)(unsafe.Pointer(sbPtr)).FlistObj v15 = _objPtr5 v14 = *(*TTcl_Size)(unsafe.Pointer(v15)) *(*TTcl_Size)(unsafe.Pointer(v15))-- if v14 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr5) } } (*TSpinbox)(unsafe.Pointer(sbPtr)).FlistObj = libc.UintptrFromInt32(0) if (*TSpinbox)(unsafe.Pointer(sbPtr)).FvalueObj != libc.UintptrFromInt32(0) { newObjPtr = (*TSpinbox)(unsafe.Pointer(sbPtr)).FvalueObj if libtcl9_0.XTcl_ListObjLength(tls, interp, newObjPtr, bp+544) != TCL_OK { valuesChanged = -int32(1) goto _1 } (*TSpinbox)(unsafe.Pointer(sbPtr)).FlistObj = newObjPtr (*TTcl_Obj)(unsafe.Pointer((*TSpinbox)(unsafe.Pointer(sbPtr)).FlistObj)).FrefCount++ (*TSpinbox)(unsafe.Pointer(sbPtr)).FnElements = int32(*(*TTcl_Size)(unsafe.Pointer(bp + 544))) (*TSpinbox)(unsafe.Pointer(sbPtr)).FeIndex = 0 valuesChanged++ } } } /* * Restart the cursor timing sequence in case the on-time or off-time * just changed. Set validate temporarily to none, so the configure * doesn't cause it to be triggered. */ if (*TEntry)(unsafe.Pointer(entryPtr)).Fflags&int32(GOT_FOCUS1) != 0 { validate = (*TEntry)(unsafe.Pointer(entryPtr)).Fvalidate (*TEntry)(unsafe.Pointer(entryPtr)).Fvalidate = int32(VALIDATE_NONE) _EntryFocusProc(tls, entryPtr, int32(1)) (*TEntry)(unsafe.Pointer(entryPtr)).Fvalidate = validate } /* * Claim the selection if we've suddenly started exporting it. */ if (*TEntry)(unsafe.Pointer(entryPtr)).FexportSelection != 0 && !(oldExport != 0) && !(libtcl9_0.XTcl_IsSafe(tls, (*TEntry)(unsafe.Pointer(entryPtr)).Finterp) != 0) && (*TEntry)(unsafe.Pointer(entryPtr)).FselectFirst != int64(-libc.Int32FromInt32(1)) && !((*TEntry)(unsafe.Pointer(entryPtr)).Fflags&libc.Int32FromInt32(GOT_SELECTION) != 0) { XTk_OwnSelection(tls, (*TEntry)(unsafe.Pointer(entryPtr)).Ftkwin, libc.Uint64FromInt32(1), __ccgo_fp(_EntryLostSelection), entryPtr) *(*int32)(unsafe.Pointer(entryPtr + 416)) |= int32(GOT_SELECTION) } /* * Recompute the window's geometry and arrange for it to be * redisplayed. */ XTk_SetInternalBorder(tls, (*TEntry)(unsafe.Pointer(entryPtr)).Ftkwin, *(*int32)(unsafe.Pointer(bp + 512))+*(*int32)(unsafe.Pointer(bp + 516))) (*TEntry)(unsafe.Pointer(entryPtr)).Finset = *(*int32)(unsafe.Pointer(bp + 516)) + *(*int32)(unsafe.Pointer(bp + 512)) + int32(XPAD) break goto _1 _1: ; error1++ } if !(error1 != 0) { XTk_FreeSavedOptions(tls, bp) } /* * If the entry is tied to the value of a variable, create the variable if * it doesn't exist, and set the entry's value from the variable's value. */ if (*TEntry)(unsafe.Pointer(entryPtr)).FtextVarNameObj != libc.UintptrFromInt32(0) { value = libtcl9_0.XTcl_GetVar2(tls, interp, libtcl9_0.XTcl_GetStringFromObj(tls, (*TEntry)(unsafe.Pointer(entryPtr)).FtextVarNameObj, libc.UintptrFromInt32(0)), libc.UintptrFromInt32(0), int32(TCL_GLOBAL_ONLY)) if value == libc.UintptrFromInt32(0) { /* * Since any trace on the textvariable was eliminated above, * the only possible reason for EntryValueChanged to return * an error is that the textvariable lives in a namespace * that does not (yet) exist. Indeed, namespaces are not * automatically created as needed. Don't trap this error * here, better do it below when attempting to trace the * variable. */ _EntryValueChanged(tls, entryPtr, libc.UintptrFromInt32(0)) } else { _EntrySetValue(tls, entryPtr, value) } } if (*TEntry)(unsafe.Pointer(entryPtr)).Ftype1 == int32(TK_SPINBOX) { _ComputeFormat(tls, sbPtr) if valuesChanged > 0 { /* * No check for error return, because there shouldn't be one given * the check for valid list above. */ libtcl9_0.XTcl_ListObjIndex(tls, interp, (*TSpinbox)(unsafe.Pointer(sbPtr)).FlistObj, 0, bp+552) /* * No check for error return here as well, because any possible * error will be trapped below when attempting tracing. */ _EntryValueChanged(tls, entryPtr, libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(bp + 552)), libc.UintptrFromInt32(0))) } else { if (*TSpinbox)(unsafe.Pointer(sbPtr)).FvalueObj == libc.UintptrFromInt32(0) && !(libc.Xfabs(tls, (*TSpinbox)(unsafe.Pointer(sbPtr)).FfromValue-(*TSpinbox)(unsafe.Pointer(sbPtr)).FtoValue) < libc.Float64FromFloat64(1e-09)) && (!(libc.Xfabs(tls, (*TSpinbox)(unsafe.Pointer(sbPtr)).FfromValue-oldFrom) < libc.Float64FromFloat64(1e-09)) || !(libc.Xfabs(tls, (*TSpinbox)(unsafe.Pointer(sbPtr)).FtoValue-oldTo) < libc.Float64FromFloat64(1e-09))) { if libc.Xsscanf(tls, (*TEntry)(unsafe.Pointer(entryPtr)).Fstring1, __ccgo_ts+22502, libc.VaList(bp+576, bp+560)) <= 0 { /* Scan failure */ *(*float64)(unsafe.Pointer(bp + 560)) = (*TSpinbox)(unsafe.Pointer(sbPtr)).FfromValue } else { if *(*float64)(unsafe.Pointer(bp + 560)) > (*TSpinbox)(unsafe.Pointer(sbPtr)).FtoValue { *(*float64)(unsafe.Pointer(bp + 560)) = (*TSpinbox)(unsafe.Pointer(sbPtr)).FtoValue } else { if *(*float64)(unsafe.Pointer(bp + 560)) < (*TSpinbox)(unsafe.Pointer(sbPtr)).FfromValue { *(*float64)(unsafe.Pointer(bp + 560)) = (*TSpinbox)(unsafe.Pointer(sbPtr)).FfromValue } } } libc.X__builtin_snprintf(tls, (*TSpinbox)(unsafe.Pointer(sbPtr)).FformatBuf, formatSpace, (*TSpinbox)(unsafe.Pointer(sbPtr)).FvalueFormat, libc.VaList(bp+576, *(*float64)(unsafe.Pointer(bp + 560)))) /* * No check for error return here as well, because any possible * error will be trapped below when attempting tracing. */ _EntryValueChanged(tls, entryPtr, (*TSpinbox)(unsafe.Pointer(sbPtr)).FformatBuf) } } } /* * Set up a trace on the variable's value after we've possibly constrained * the value according to new -from/-to values. */ if (*TEntry)(unsafe.Pointer(entryPtr)).FtextVarNameObj != libc.UintptrFromInt32(0) && !((*TEntry)(unsafe.Pointer(entryPtr)).Fflags&libc.Int32FromInt32(ENTRY_VAR_TRACED) != 0) { code = libtcl9_0.XTcl_TraceVar2(tls, interp, libtcl9_0.XTcl_GetStringFromObj(tls, (*TEntry)(unsafe.Pointer(entryPtr)).FtextVarNameObj, libc.UintptrFromInt32(0)), libc.UintptrFromInt32(0), libc.Int32FromInt32(TCL_GLOBAL_ONLY)|libc.Int32FromInt32(TCL_TRACE_WRITES)|libc.Int32FromInt32(TCL_TRACE_UNSETS), __ccgo_fp(_EntryTextVarProc), entryPtr) if code != TCL_OK { return int32(TCL_ERROR) } *(*int32)(unsafe.Pointer(entryPtr + 416)) |= int32(ENTRY_VAR_TRACED) } _EntryWorldChanged(tls, entryPtr) if error1 != 0 { libtcl9_0.XTcl_SetObjResult(tls, interp, errorResult) _objPtr6 = errorResult v17 = _objPtr6 v16 = *(*TTcl_Size)(unsafe.Pointer(v17)) *(*TTcl_Size)(unsafe.Pointer(v17))-- if v16 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr6) } return int32(TCL_ERROR) } else { return TCL_OK } return r } /* *--------------------------------------------------------------------------- * * EntryWorldChanged -- * * This function is called when the world has changed in some way and the * widget needs to recompute all its graphics contexts and determine its * new geometry. * * Results: * None. * * Side effects: * Entry will be relayed out and redisplayed. * *--------------------------------------------------------------------------- */ func _EntryWorldChanged(tls *libc.TLS, instanceData uintptr) { bp := tls.Alloc(128) defer tls.Free(128) /* Information about widget. */ var border TTk_3DBorder var colorPtr, entryPtr uintptr var gc TGC var mask uint64 var _ /* gcValues at bp+0 */ TXGCValues _, _, _, _, _ = border, colorPtr, entryPtr, gc, mask gc = libc.UintptrFromInt32(0) entryPtr = instanceData (*TEntry)(unsafe.Pointer(entryPtr)).FavgWidth = XTk_TextWidth(tls, (*TEntry)(unsafe.Pointer(entryPtr)).Ftkfont, __ccgo_ts+10533, int64(1)) if (*TEntry)(unsafe.Pointer(entryPtr)).FavgWidth == 0 { (*TEntry)(unsafe.Pointer(entryPtr)).FavgWidth = int32(1) } if (*TEntry)(unsafe.Pointer(entryPtr)).Ftype1 == int32(TK_SPINBOX) { /* * Compute the button width for a spinbox */ (*TEntry)(unsafe.Pointer(entryPtr)).FxWidth = (*TEntry)(unsafe.Pointer(entryPtr)).FavgWidth + libc.Int32FromInt32(2)*(libc.Int32FromInt32(1)+libc.Int32FromInt32(XPAD)) if (*TEntry)(unsafe.Pointer(entryPtr)).FxWidth < int32(11) { (*TEntry)(unsafe.Pointer(entryPtr)).FxWidth = int32(11) /* we want a min visible size */ } } /* * Default background and foreground are from the normal state. In a * disabled state, both of those may be overridden; in the readonly state, * the background may be overridden. */ border = (*TEntry)(unsafe.Pointer(entryPtr)).FnormalBorder colorPtr = (*TEntry)(unsafe.Pointer(entryPtr)).FfgColorPtr switch (*TEntry)(unsafe.Pointer(entryPtr)).Fstate { case int32(STATE_DISABLED1): if (*TEntry)(unsafe.Pointer(entryPtr)).FdisabledBorder != libc.UintptrFromInt32(0) { border = (*TEntry)(unsafe.Pointer(entryPtr)).FdisabledBorder } if (*TEntry)(unsafe.Pointer(entryPtr)).FdfgColorPtr != libc.UintptrFromInt32(0) { colorPtr = (*TEntry)(unsafe.Pointer(entryPtr)).FdfgColorPtr } case int32(STATE_READONLY): if (*TEntry)(unsafe.Pointer(entryPtr)).FreadonlyBorder != libc.UintptrFromInt32(0) { border = (*TEntry)(unsafe.Pointer(entryPtr)).FreadonlyBorder } break } XTk_SetBackgroundFromBorder(tls, (*TEntry)(unsafe.Pointer(entryPtr)).Ftkwin, border) (*(*TXGCValues)(unsafe.Pointer(bp))).Fforeground = (*TXColor)(unsafe.Pointer(colorPtr)).Fpixel (*(*TXGCValues)(unsafe.Pointer(bp))).Ffont = XTk_FontId(tls, (*TEntry)(unsafe.Pointer(entryPtr)).Ftkfont) (*(*TXGCValues)(unsafe.Pointer(bp))).Fgraphics_exposures = False mask = libc.Uint64FromInt64(libc.Int64FromInt64(1)< (*TEntry)(unsafe.Pointer(entryPtr)).FleftIndex { if (*TEntry)(unsafe.Pointer(entryPtr)).FselectFirst <= (*TEntry)(unsafe.Pointer(entryPtr)).FleftIndex { *(*int32)(unsafe.Pointer(bp)) = (*TEntry)(unsafe.Pointer(entryPtr)).FleftX } else { XTk_CharBbox(tls, (*TEntry)(unsafe.Pointer(entryPtr)).FtextLayout, (*TEntry)(unsafe.Pointer(entryPtr)).FselectFirst, bp, libc.UintptrFromInt32(0), libc.UintptrFromInt32(0), libc.UintptrFromInt32(0)) *(*int32)(unsafe.Pointer(bp)) += (*TEntry)(unsafe.Pointer(entryPtr)).FlayoutX } if *(*int32)(unsafe.Pointer(bp))-*(*int32)(unsafe.Pointer(bp + 28)) < xBound { XTk_CharBbox(tls, (*TEntry)(unsafe.Pointer(entryPtr)).FtextLayout, (*TEntry)(unsafe.Pointer(entryPtr)).FselectLast, bp+4, libc.UintptrFromInt32(0), libc.UintptrFromInt32(0), libc.UintptrFromInt32(0)) *(*int32)(unsafe.Pointer(bp + 4)) += (*TEntry)(unsafe.Pointer(entryPtr)).FlayoutX XTk_Fill3DRectangle(tls, tkwin, pixmap, (*TEntry)(unsafe.Pointer(entryPtr)).FselBorder, *(*int32)(unsafe.Pointer(bp))-*(*int32)(unsafe.Pointer(bp + 28)), baseY-(*(*TTk_FontMetrics)(unsafe.Pointer(bp + 12))).Fascent-*(*int32)(unsafe.Pointer(bp + 28)), *(*int32)(unsafe.Pointer(bp + 4))-*(*int32)(unsafe.Pointer(bp))+int32(2)**(*int32)(unsafe.Pointer(bp + 28)), (*(*TTk_FontMetrics)(unsafe.Pointer(bp + 12))).Fascent+(*(*TTk_FontMetrics)(unsafe.Pointer(bp + 12))).Fdescent+int32(2)**(*int32)(unsafe.Pointer(bp + 28)), *(*int32)(unsafe.Pointer(bp + 28)), int32(TK_RELIEF_RAISED)) } } /* * Draw a special background for the insertion cursor, overriding even the * selection background. As a special hack to keep the cursor visible when * the insertion cursor color is the same as the color for selected text * (e.g., on mono displays), write background in the cursor area (instead * of nothing) when the cursor isn't on. Otherwise the selection would * hide the cursor. */ XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), tkwin, (*TEntry)(unsafe.Pointer(entryPtr)).FinsertWidthObj, bp+32) if (*TEntry)(unsafe.Pointer(entryPtr)).Fstate == int32(STATE_NORMAL1) && (*TEntry)(unsafe.Pointer(entryPtr)).Fflags&int32(GOT_FOCUS1) != 0 { XTk_CharBbox(tls, (*TEntry)(unsafe.Pointer(entryPtr)).FtextLayout, (*TEntry)(unsafe.Pointer(entryPtr)).FinsertPos, bp+8, libc.UintptrFromInt32(0), libc.UintptrFromInt32(0), libc.UintptrFromInt32(0)) *(*int32)(unsafe.Pointer(bp + 8)) += (*TEntry)(unsafe.Pointer(entryPtr)).FlayoutX if *(*int32)(unsafe.Pointer(bp + 32)) <= int32(1) { v1 = int32(1) } else { v1 = *(*int32)(unsafe.Pointer(bp + 32)) / int32(2) } *(*int32)(unsafe.Pointer(bp + 8)) -= v1 XTk_SetCaretPos(tls, (*TEntry)(unsafe.Pointer(entryPtr)).Ftkwin, *(*int32)(unsafe.Pointer(bp + 8)), baseY-(*(*TTk_FontMetrics)(unsafe.Pointer(bp + 12))).Fascent, (*(*TTk_FontMetrics)(unsafe.Pointer(bp + 12))).Fascent+(*(*TTk_FontMetrics)(unsafe.Pointer(bp + 12))).Fdescent) if (*TEntry)(unsafe.Pointer(entryPtr)).FinsertPos >= (*TEntry)(unsafe.Pointer(entryPtr)).FleftIndex && *(*int32)(unsafe.Pointer(bp + 8)) < xBound { if (*TEntry)(unsafe.Pointer(entryPtr)).Fflags&int32(CURSOR_ON) != 0 { XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), (*TEntry)(unsafe.Pointer(entryPtr)).Ftkwin, (*TEntry)(unsafe.Pointer(entryPtr)).FinsertBorderWidthObj, bp+40) if *(*int32)(unsafe.Pointer(bp + 40)) > *(*int32)(unsafe.Pointer(bp + 32))/int32(2) { *(*int32)(unsafe.Pointer(bp + 40)) = *(*int32)(unsafe.Pointer(bp + 32)) / int32(2) } XTk_Fill3DRectangle(tls, tkwin, pixmap, (*TEntry)(unsafe.Pointer(entryPtr)).FinsertBorder, *(*int32)(unsafe.Pointer(bp + 8)), baseY-(*(*TTk_FontMetrics)(unsafe.Pointer(bp + 12))).Fascent, *(*int32)(unsafe.Pointer(bp + 32)), (*(*TTk_FontMetrics)(unsafe.Pointer(bp + 12))).Fascent+(*(*TTk_FontMetrics)(unsafe.Pointer(bp + 12))).Fdescent, *(*int32)(unsafe.Pointer(bp + 40)), int32(TK_RELIEF_RAISED)) } else { if (*TEntry)(unsafe.Pointer(entryPtr)).FinsertBorder == (*TEntry)(unsafe.Pointer(entryPtr)).FselBorder { XTk_Fill3DRectangle(tls, tkwin, pixmap, border, *(*int32)(unsafe.Pointer(bp + 8)), baseY-(*(*TTk_FontMetrics)(unsafe.Pointer(bp + 12))).Fascent, *(*int32)(unsafe.Pointer(bp + 32)), (*(*TTk_FontMetrics)(unsafe.Pointer(bp + 12))).Fascent+(*(*TTk_FontMetrics)(unsafe.Pointer(bp + 12))).Fdescent, 0, TK_RELIEF_FLAT) } } } } if (*TEntry)(unsafe.Pointer(entryPtr)).FnumChars == 0 && (*TEntry)(unsafe.Pointer(entryPtr)).FplaceholderChars != 0 { /* * Draw the placeholder text. */ XTk_DrawTextLayout(tls, (*TEntry)(unsafe.Pointer(entryPtr)).Fdisplay, pixmap, (*TEntry)(unsafe.Pointer(entryPtr)).FplaceholderGC, (*TEntry)(unsafe.Pointer(entryPtr)).FplaceholderLayout, (*TEntry)(unsafe.Pointer(entryPtr)).FplaceholderX, (*TEntry)(unsafe.Pointer(entryPtr)).FlayoutY, int64((*TEntry)(unsafe.Pointer(entryPtr)).FplaceholderLeftIndex), (*TEntry)(unsafe.Pointer(entryPtr)).FplaceholderChars) } else { if showSelection != 0 && (*TEntry)(unsafe.Pointer(entryPtr)).Fstate != int32(STATE_DISABLED1) && (*TEntry)(unsafe.Pointer(entryPtr)).FselTextGC != (*TEntry)(unsafe.Pointer(entryPtr)).FtextGC && (*TEntry)(unsafe.Pointer(entryPtr)).FselectFirst < (*TEntry)(unsafe.Pointer(entryPtr)).FselectLast { if (*TEntry)(unsafe.Pointer(entryPtr)).FselectFirst < (*TEntry)(unsafe.Pointer(entryPtr)).FleftIndex { selFirst = (*TEntry)(unsafe.Pointer(entryPtr)).FleftIndex } else { selFirst = (*TEntry)(unsafe.Pointer(entryPtr)).FselectFirst } if (*TEntry)(unsafe.Pointer(entryPtr)).FleftIndex < selFirst { XTk_DrawTextLayout(tls, (*TEntry)(unsafe.Pointer(entryPtr)).Fdisplay, pixmap, (*TEntry)(unsafe.Pointer(entryPtr)).FtextGC, (*TEntry)(unsafe.Pointer(entryPtr)).FtextLayout, (*TEntry)(unsafe.Pointer(entryPtr)).FlayoutX, (*TEntry)(unsafe.Pointer(entryPtr)).FlayoutY, (*TEntry)(unsafe.Pointer(entryPtr)).FleftIndex, selFirst) } XTk_DrawTextLayout(tls, (*TEntry)(unsafe.Pointer(entryPtr)).Fdisplay, pixmap, (*TEntry)(unsafe.Pointer(entryPtr)).FselTextGC, (*TEntry)(unsafe.Pointer(entryPtr)).FtextLayout, (*TEntry)(unsafe.Pointer(entryPtr)).FlayoutX, (*TEntry)(unsafe.Pointer(entryPtr)).FlayoutY, selFirst, (*TEntry)(unsafe.Pointer(entryPtr)).FselectLast) if (*TEntry)(unsafe.Pointer(entryPtr)).FselectLast < (*TEntry)(unsafe.Pointer(entryPtr)).FnumChars { XTk_DrawTextLayout(tls, (*TEntry)(unsafe.Pointer(entryPtr)).Fdisplay, pixmap, (*TEntry)(unsafe.Pointer(entryPtr)).FtextGC, (*TEntry)(unsafe.Pointer(entryPtr)).FtextLayout, (*TEntry)(unsafe.Pointer(entryPtr)).FlayoutX, (*TEntry)(unsafe.Pointer(entryPtr)).FlayoutY, (*TEntry)(unsafe.Pointer(entryPtr)).FselectLast, (*TEntry)(unsafe.Pointer(entryPtr)).FnumChars) } } else { /* * Draw the entire visible text */ XTk_DrawTextLayout(tls, (*TEntry)(unsafe.Pointer(entryPtr)).Fdisplay, pixmap, (*TEntry)(unsafe.Pointer(entryPtr)).FtextGC, (*TEntry)(unsafe.Pointer(entryPtr)).FtextLayout, (*TEntry)(unsafe.Pointer(entryPtr)).FlayoutX, (*TEntry)(unsafe.Pointer(entryPtr)).FlayoutY, (*TEntry)(unsafe.Pointer(entryPtr)).FleftIndex, (*TEntry)(unsafe.Pointer(entryPtr)).FnumChars) } } if (*TEntry)(unsafe.Pointer(entryPtr)).Ftype1 == int32(TK_SPINBOX) { sbPtr = entryPtr /* * Draw the spin button controls. */ if XTkpDrawSpinboxButtons(tls, sbPtr, pixmap) == 0 { xWidth = (*TEntry)(unsafe.Pointer(entryPtr)).FxWidth pad = libc.Int32FromInt32(XPAD) + libc.Int32FromInt32(1) inset = (*TEntry)(unsafe.Pointer(entryPtr)).Finset - int32(XPAD) startx = (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fchanges.Fwidth - (xWidth + inset) height = ((*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fchanges.Fheight - int32(2)*inset) / int32(2) if (*TSpinbox)(unsafe.Pointer(sbPtr)).FselElement == int32(SEL_BUTTONUP) { v2 = int32(TK_RELIEF_SUNKEN) } else { v2 = int32(TK_RELIEF_RAISED) } XTk_Fill3DRectangle(tls, tkwin, pixmap, (*TSpinbox)(unsafe.Pointer(sbPtr)).FbuttonBorder, startx, inset, xWidth, height, int32(1), v2) if (*TSpinbox)(unsafe.Pointer(sbPtr)).FselElement == int32(SEL_BUTTONDOWN) { v3 = int32(TK_RELIEF_SUNKEN) } else { v3 = int32(TK_RELIEF_RAISED) } XTk_Fill3DRectangle(tls, tkwin, pixmap, (*TSpinbox)(unsafe.Pointer(sbPtr)).FbuttonBorder, startx, inset+height, xWidth, height, int32(1), v3) xWidth -= int32(2) * pad /* * Only draw the triangles if we have enough display space */ if xWidth > int32(1) { space = height - int32(2)*pad /* * Ensure width of triangle is odd to guarantee a sharp tip */ if !(xWidth%libc.Int32FromInt32(2) != 0) { xWidth++ } tHeight = (xWidth + int32(1)) / int32(2) if tHeight > space { tHeight = space } space = (space - tHeight) / int32(2) startx += pad starty = inset + height - pad - space offset = libc.BoolInt32((*TSpinbox)(unsafe.Pointer(sbPtr)).FselElement == int32(SEL_BUTTONUP)) /* * The points are slightly different for the up and down * arrows because (for *.x), we need to account for a bug in * the way XFillPolygon draws triangles, and we want to shift * the arrows differently when allowing for depressed * behavior. */ (*(*[3]TXPoint)(unsafe.Pointer(bp + 44)))[0].Fx = int16(startx + offset) if offset != 0 { v4 = 0 } else { v4 = -int32(1) } (*(*[3]TXPoint)(unsafe.Pointer(bp + 44)))[0].Fy = int16(starty + v4) (*(*[3]TXPoint)(unsafe.Pointer(bp + 44)))[int32(1)].Fx = int16(startx + xWidth/int32(2) + offset) if offset != 0 { v5 = 0 } else { v5 = -int32(1) } (*(*[3]TXPoint)(unsafe.Pointer(bp + 44)))[int32(1)].Fy = int16(starty - tHeight + v5) (*(*[3]TXPoint)(unsafe.Pointer(bp + 44)))[int32(2)].Fx = int16(startx + xWidth + offset) (*(*[3]TXPoint)(unsafe.Pointer(bp + 44)))[int32(2)].Fy = (*(*[3]TXPoint)(unsafe.Pointer(bp + 44)))[0].Fy libx11.XXFillPolygon(tls, (*TEntry)(unsafe.Pointer(entryPtr)).Fdisplay, pixmap, (*TEntry)(unsafe.Pointer(entryPtr)).FtextGC, bp+44, int32(3), int32(Convex), CoordModeOrigin) starty = inset + height + pad + space offset = libc.BoolInt32((*TSpinbox)(unsafe.Pointer(sbPtr)).FselElement == int32(SEL_BUTTONDOWN)) (*(*[3]TXPoint)(unsafe.Pointer(bp + 44)))[0].Fx = int16(startx + int32(1) + offset) if offset != 0 { v6 = int32(1) } else { v6 = 0 } (*(*[3]TXPoint)(unsafe.Pointer(bp + 44)))[0].Fy = int16(starty + v6) (*(*[3]TXPoint)(unsafe.Pointer(bp + 44)))[int32(1)].Fx = int16(startx + xWidth/int32(2) + offset) if offset != 0 { v7 = 0 } else { v7 = -int32(1) } (*(*[3]TXPoint)(unsafe.Pointer(bp + 44)))[int32(1)].Fy = int16(starty + tHeight + v7) (*(*[3]TXPoint)(unsafe.Pointer(bp + 44)))[int32(2)].Fx = int16(startx - int32(1) + xWidth + offset) (*(*[3]TXPoint)(unsafe.Pointer(bp + 44)))[int32(2)].Fy = (*(*[3]TXPoint)(unsafe.Pointer(bp + 44)))[0].Fy libx11.XXFillPolygon(tls, (*TEntry)(unsafe.Pointer(entryPtr)).Fdisplay, pixmap, (*TEntry)(unsafe.Pointer(entryPtr)).FtextGC, bp+44, int32(3), int32(Convex), CoordModeOrigin) } } } /* * Draw the border and focus highlight last, so they will overwrite any * text that extends past the viewable part of the window. */ XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), (*TEntry)(unsafe.Pointer(entryPtr)).Ftkwin, (*TEntry)(unsafe.Pointer(entryPtr)).FborderWidthObj, bp+24) XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), (*TEntry)(unsafe.Pointer(entryPtr)).Ftkwin, (*TEntry)(unsafe.Pointer(entryPtr)).FhighlightWidthObj, bp+36) if !(XTkpDrawEntryBorderAndFocus(tls, entryPtr, pixmap, libc.BoolInt32((*TEntry)(unsafe.Pointer(entryPtr)).Ftype1 == int32(TK_SPINBOX))) != 0) { xBound = *(*int32)(unsafe.Pointer(bp + 36)) if (*TEntry)(unsafe.Pointer(entryPtr)).Frelief != TK_RELIEF_FLAT { XTk_Draw3DRectangle(tls, tkwin, pixmap, border, xBound, xBound, (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fchanges.Fwidth-int32(2)*xBound, (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fchanges.Fheight-int32(2)*xBound, *(*int32)(unsafe.Pointer(bp + 24)), (*TEntry)(unsafe.Pointer(entryPtr)).Frelief) } if xBound > 0 { bgGC = XTk_GCForColor(tls, (*TEntry)(unsafe.Pointer(entryPtr)).FhighlightBgColorPtr, pixmap) if (*TEntry)(unsafe.Pointer(entryPtr)).Fflags&int32(GOT_FOCUS1) != 0 { fgGC = XTk_GCForColor(tls, (*TEntry)(unsafe.Pointer(entryPtr)).FhighlightColorPtr, pixmap) XTk_DrawHighlightBorder(tls, tkwin, fgGC, bgGC, xBound, pixmap) } else { XTk_DrawHighlightBorder(tls, tkwin, bgGC, bgGC, xBound, pixmap) } } } /* * Everything's been redisplayed; now copy the pixmap onto the screen and * free up the pixmap. */ libx11.XXCopyArea(tls, (*TEntry)(unsafe.Pointer(entryPtr)).Fdisplay, pixmap, (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fwindow, (*TEntry)(unsafe.Pointer(entryPtr)).FtextGC, 0, 0, libc.Uint32FromInt32((*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fchanges.Fwidth), libc.Uint32FromInt32((*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fchanges.Fheight), 0, 0) XTk_FreePixmap(tls, (*TEntry)(unsafe.Pointer(entryPtr)).Fdisplay, pixmap) *(*int32)(unsafe.Pointer(entryPtr + 416)) &= ^libc.Int32FromInt32(BORDER_NEEDED) } /* *---------------------------------------------------------------------- * * EntryComputeGeometry -- * * This function is invoked to recompute information about where in its * window an entry's string will be displayed. It also computes the * requested size for the window. * * Results: * None. * * Side effects: * The leftX and tabOrigin fields are recomputed for entryPtr, and * leftIndex may be adjusted. Tk_GeometryRequest is called to register * the desired dimensions for the window. * *---------------------------------------------------------------------- */ func _EntryComputeGeometry(tls *libc.TLS, entryPtr uintptr) { bp := tls.Alloc(48) defer tls.Free(48) /* Widget record for entry. */ var i, overflow, size, width, v2 int32 var maxOffScreen TTcl_Size var p, v3 uintptr var _ /* buf at bp+30 */ [6]uint8 var _ /* ch at bp+24 */ int32 var _ /* fm at bp+12 */ TTk_FontMetrics var _ /* height at bp+8 */ int32 var _ /* rightX at bp+4 */ int32 var _ /* totalLength at bp+0 */ int32 _, _, _, _, _, _, _, _ = i, maxOffScreen, overflow, p, size, width, v2, v3 if (*TEntry)(unsafe.Pointer(entryPtr)).FdisplayString != (*TEntry)(unsafe.Pointer(entryPtr)).Fstring1 { libtcl9_0.XTcl_Free(tls, (*TEntry)(unsafe.Pointer(entryPtr)).FdisplayString) (*TEntry)(unsafe.Pointer(entryPtr)).FdisplayString = (*TEntry)(unsafe.Pointer(entryPtr)).Fstring1 (*TEntry)(unsafe.Pointer(entryPtr)).FnumDisplayBytes = (*TEntry)(unsafe.Pointer(entryPtr)).FnumBytes } /* * If we're displaying a special character instead of the value of the * entry, recompute the displayString. */ if (*TEntry)(unsafe.Pointer(entryPtr)).FshowCharObj != libc.UintptrFromInt32(0) { /* * Normalize the special character so we can safely duplicate it in * the display string. If we didn't do this, then two malformed * characters might end up looking like one valid UTF character in the * resulting string. */ libtcl9_0.XTcl_UtfToUniChar(tls, libtcl9_0.XTcl_GetStringFromObj(tls, (*TEntry)(unsafe.Pointer(entryPtr)).FshowCharObj, libc.UintptrFromInt32(0)), bp+24) size = int32(libtcl9_0.XTcl_UniCharToUtf(tls, *(*int32)(unsafe.Pointer(bp + 24)), bp+30)) (*TEntry)(unsafe.Pointer(entryPtr)).FnumDisplayBytes = (*TEntry)(unsafe.Pointer(entryPtr)).FnumChars * int64(size) p = libtcl9_0.XTcl_Alloc(tls, libc.Uint64FromInt64((*TEntry)(unsafe.Pointer(entryPtr)).FnumDisplayBytes+int64(1))) (*TEntry)(unsafe.Pointer(entryPtr)).FdisplayString = p i = int32((*TEntry)(unsafe.Pointer(entryPtr)).FnumChars) for { v2 = i i-- if !(v2 > 0) { break } libc.Xmemcpy(tls, p, bp+30, libc.Uint64FromInt32(size)) p += uintptr(size) goto _1 _1: } *(*uint8)(unsafe.Pointer(p)) = uint8('\000') } /* Recompute layout of placeholder text. * Only the placeholderX and placeholderLeftIndex value is needed. * We use the same font so we can use the layoutY value from below. */ XTk_FreeTextLayout(tls, (*TEntry)(unsafe.Pointer(entryPtr)).FplaceholderLayout) if (*TEntry)(unsafe.Pointer(entryPtr)).FplaceholderObj != 0 { (*TEntry)(unsafe.Pointer(entryPtr)).FplaceholderChars = libc.Int64FromUint64(libc.Xstrlen(tls, libtcl9_0.XTcl_GetStringFromObj(tls, (*TEntry)(unsafe.Pointer(entryPtr)).FplaceholderObj, libc.UintptrFromInt32(0)))) (*TEntry)(unsafe.Pointer(entryPtr)).FplaceholderLayout = XTk_ComputeTextLayout(tls, (*TEntry)(unsafe.Pointer(entryPtr)).Ftkfont, libtcl9_0.XTcl_GetStringFromObj(tls, (*TEntry)(unsafe.Pointer(entryPtr)).FplaceholderObj, libc.UintptrFromInt32(0)), (*TEntry)(unsafe.Pointer(entryPtr)).FplaceholderChars, 0, (*TEntry)(unsafe.Pointer(entryPtr)).Fjustify, int32(TK_IGNORE_NEWLINES), bp, libc.UintptrFromInt32(0)) overflow = *(*int32)(unsafe.Pointer(bp)) - ((*TTk_FakeWin)(unsafe.Pointer((*TEntry)(unsafe.Pointer(entryPtr)).Ftkwin)).Fchanges.Fwidth - int32(2)*(*TEntry)(unsafe.Pointer(entryPtr)).Finset - (*TEntry)(unsafe.Pointer(entryPtr)).FxWidth) if overflow <= 0 { (*TEntry)(unsafe.Pointer(entryPtr)).FplaceholderLeftIndex = 0 if (*TEntry)(unsafe.Pointer(entryPtr)).Fjustify == int32(TK_JUSTIFY_LEFT) { (*TEntry)(unsafe.Pointer(entryPtr)).FplaceholderX = (*TEntry)(unsafe.Pointer(entryPtr)).Finset } else { if (*TEntry)(unsafe.Pointer(entryPtr)).Fjustify == int32(TK_JUSTIFY_RIGHT) { (*TEntry)(unsafe.Pointer(entryPtr)).FplaceholderX = (*TTk_FakeWin)(unsafe.Pointer((*TEntry)(unsafe.Pointer(entryPtr)).Ftkwin)).Fchanges.Fwidth - (*TEntry)(unsafe.Pointer(entryPtr)).Finset - (*TEntry)(unsafe.Pointer(entryPtr)).FxWidth - *(*int32)(unsafe.Pointer(bp)) } else { (*TEntry)(unsafe.Pointer(entryPtr)).FplaceholderX = ((*TTk_FakeWin)(unsafe.Pointer((*TEntry)(unsafe.Pointer(entryPtr)).Ftkwin)).Fchanges.Fwidth - (*TEntry)(unsafe.Pointer(entryPtr)).FxWidth - *(*int32)(unsafe.Pointer(bp))) / int32(2) } } } else { /* * The whole string can't fit in the window. Compute the maximum * number of characters that may be off-screen to the left without * leaving empty space on the right of the window, then don't let * placeholderLeftIndex be any greater than that. */ maxOffScreen = int64(XTk_PointToChar(tls, (*TEntry)(unsafe.Pointer(entryPtr)).FplaceholderLayout, overflow, 0)) XTk_CharBbox(tls, (*TEntry)(unsafe.Pointer(entryPtr)).FplaceholderLayout, maxOffScreen, bp+4, libc.UintptrFromInt32(0), libc.UintptrFromInt32(0), libc.UintptrFromInt32(0)) if *(*int32)(unsafe.Pointer(bp + 4)) < overflow { maxOffScreen++ } (*TEntry)(unsafe.Pointer(entryPtr)).FplaceholderLeftIndex = int32(maxOffScreen) XTk_CharBbox(tls, (*TEntry)(unsafe.Pointer(entryPtr)).FplaceholderLayout, int64((*TEntry)(unsafe.Pointer(entryPtr)).FplaceholderLeftIndex), bp+4, libc.UintptrFromInt32(0), libc.UintptrFromInt32(0), libc.UintptrFromInt32(0)) (*TEntry)(unsafe.Pointer(entryPtr)).FplaceholderX = (*TEntry)(unsafe.Pointer(entryPtr)).Finset - *(*int32)(unsafe.Pointer(bp + 4)) } } else { (*TEntry)(unsafe.Pointer(entryPtr)).FplaceholderChars = 0 if (*TEntry)(unsafe.Pointer(entryPtr)).FplaceholderObj != 0 { v3 = libtcl9_0.XTcl_GetStringFromObj(tls, (*TEntry)(unsafe.Pointer(entryPtr)).FplaceholderObj, libc.UintptrFromInt32(0)) } else { v3 = libc.UintptrFromInt32(0) } (*TEntry)(unsafe.Pointer(entryPtr)).FplaceholderLayout = XTk_ComputeTextLayout(tls, (*TEntry)(unsafe.Pointer(entryPtr)).Ftkfont, v3, 0, 0, (*TEntry)(unsafe.Pointer(entryPtr)).Fjustify, int32(TK_IGNORE_NEWLINES), libc.UintptrFromInt32(0), libc.UintptrFromInt32(0)) (*TEntry)(unsafe.Pointer(entryPtr)).FplaceholderX = (*TEntry)(unsafe.Pointer(entryPtr)).Finset } XTk_FreeTextLayout(tls, (*TEntry)(unsafe.Pointer(entryPtr)).FtextLayout) (*TEntry)(unsafe.Pointer(entryPtr)).FtextLayout = XTk_ComputeTextLayout(tls, (*TEntry)(unsafe.Pointer(entryPtr)).Ftkfont, (*TEntry)(unsafe.Pointer(entryPtr)).FdisplayString, (*TEntry)(unsafe.Pointer(entryPtr)).FnumChars, 0, (*TEntry)(unsafe.Pointer(entryPtr)).Fjustify, int32(TK_IGNORE_NEWLINES), bp, bp+8) (*TEntry)(unsafe.Pointer(entryPtr)).FlayoutY = ((*TTk_FakeWin)(unsafe.Pointer((*TEntry)(unsafe.Pointer(entryPtr)).Ftkwin)).Fchanges.Fheight - *(*int32)(unsafe.Pointer(bp + 8))) / int32(2) /* * Recompute where the leftmost character on the display will be drawn * (entryPtr->leftX) and adjust leftIndex if necessary so that we don't * let characters hang off the edge of the window unless the entire window * is full. */ overflow = *(*int32)(unsafe.Pointer(bp)) - ((*TTk_FakeWin)(unsafe.Pointer((*TEntry)(unsafe.Pointer(entryPtr)).Ftkwin)).Fchanges.Fwidth - int32(2)*(*TEntry)(unsafe.Pointer(entryPtr)).Finset - (*TEntry)(unsafe.Pointer(entryPtr)).FxWidth) if overflow <= 0 { (*TEntry)(unsafe.Pointer(entryPtr)).FleftIndex = 0 if (*TEntry)(unsafe.Pointer(entryPtr)).Fjustify == int32(TK_JUSTIFY_LEFT) { (*TEntry)(unsafe.Pointer(entryPtr)).FleftX = (*TEntry)(unsafe.Pointer(entryPtr)).Finset } else { if (*TEntry)(unsafe.Pointer(entryPtr)).Fjustify == int32(TK_JUSTIFY_RIGHT) { (*TEntry)(unsafe.Pointer(entryPtr)).FleftX = (*TTk_FakeWin)(unsafe.Pointer((*TEntry)(unsafe.Pointer(entryPtr)).Ftkwin)).Fchanges.Fwidth - (*TEntry)(unsafe.Pointer(entryPtr)).Finset - (*TEntry)(unsafe.Pointer(entryPtr)).FxWidth - *(*int32)(unsafe.Pointer(bp)) } else { (*TEntry)(unsafe.Pointer(entryPtr)).FleftX = ((*TTk_FakeWin)(unsafe.Pointer((*TEntry)(unsafe.Pointer(entryPtr)).Ftkwin)).Fchanges.Fwidth - (*TEntry)(unsafe.Pointer(entryPtr)).FxWidth - *(*int32)(unsafe.Pointer(bp))) / int32(2) } } (*TEntry)(unsafe.Pointer(entryPtr)).FlayoutX = (*TEntry)(unsafe.Pointer(entryPtr)).FleftX } else { /* * The whole string can't fit in the window. Compute the maximum * number of characters that may be off-screen to the left without * leaving empty space on the right of the window, then don't let * leftIndex be any greater than that. */ maxOffScreen = int64(XTk_PointToChar(tls, (*TEntry)(unsafe.Pointer(entryPtr)).FtextLayout, overflow, 0)) XTk_CharBbox(tls, (*TEntry)(unsafe.Pointer(entryPtr)).FtextLayout, maxOffScreen, bp+4, libc.UintptrFromInt32(0), libc.UintptrFromInt32(0), libc.UintptrFromInt32(0)) if *(*int32)(unsafe.Pointer(bp + 4)) < overflow { maxOffScreen++ } if (*TEntry)(unsafe.Pointer(entryPtr)).FleftIndex > maxOffScreen { (*TEntry)(unsafe.Pointer(entryPtr)).FleftIndex = maxOffScreen } XTk_CharBbox(tls, (*TEntry)(unsafe.Pointer(entryPtr)).FtextLayout, (*TEntry)(unsafe.Pointer(entryPtr)).FleftIndex, bp+4, libc.UintptrFromInt32(0), libc.UintptrFromInt32(0), libc.UintptrFromInt32(0)) (*TEntry)(unsafe.Pointer(entryPtr)).FleftX = (*TEntry)(unsafe.Pointer(entryPtr)).Finset (*TEntry)(unsafe.Pointer(entryPtr)).FlayoutX = (*TEntry)(unsafe.Pointer(entryPtr)).FleftX - *(*int32)(unsafe.Pointer(bp + 4)) } XTk_GetFontMetrics(tls, (*TEntry)(unsafe.Pointer(entryPtr)).Ftkfont, bp+12) *(*int32)(unsafe.Pointer(bp + 8)) = (*(*TTk_FontMetrics)(unsafe.Pointer(bp + 12))).Flinespace + int32(2)*(*TEntry)(unsafe.Pointer(entryPtr)).Finset + libc.Int32FromInt32(2)*(libc.Int32FromInt32(YPAD)-libc.Int32FromInt32(XPAD)) if (*TEntry)(unsafe.Pointer(entryPtr)).FprefWidth > 0 { width = (*TEntry)(unsafe.Pointer(entryPtr)).FprefWidth*(*TEntry)(unsafe.Pointer(entryPtr)).FavgWidth + int32(2)*(*TEntry)(unsafe.Pointer(entryPtr)).Finset } else { if *(*int32)(unsafe.Pointer(bp)) == 0 { width = (*TEntry)(unsafe.Pointer(entryPtr)).FavgWidth + int32(2)*(*TEntry)(unsafe.Pointer(entryPtr)).Finset } else { width = *(*int32)(unsafe.Pointer(bp)) + int32(2)*(*TEntry)(unsafe.Pointer(entryPtr)).Finset } } /* * Add one extra length for the spin buttons */ width += (*TEntry)(unsafe.Pointer(entryPtr)).FxWidth XTk_GeometryRequest(tls, (*TEntry)(unsafe.Pointer(entryPtr)).Ftkwin, width, *(*int32)(unsafe.Pointer(bp + 8))) } /* *---------------------------------------------------------------------- * * InsertChars -- * * Add new characters to an entry widget. * * Results: * A standard Tcl result. If an error occurred then an error message is * left in the interp's result. * * Side effects: * New information gets added to entryPtr; it will be redisplayed soon, * but not necessarily immediately. * *---------------------------------------------------------------------- */ func _InsertChars(tls *libc.TLS, entryPtr uintptr, index TTcl_Size, obj uintptr) (r int32) { /* New characters to add. */ var byteCount, byteIndex, charsAdded, newByteCount, oldChars Tsize_t var newStr, string1, value, p1, p2, p3, p4, p5, p6 uintptr _, _, _, _, _, _, _, _, _, _, _, _, _, _ = byteCount, byteIndex, charsAdded, newByteCount, newStr, oldChars, string1, value, p1, p2, p3, p4, p5, p6 value = libtcl9_0.XTcl_GetStringFromObj(tls, obj, libc.UintptrFromInt32(0)) string1 = (*TEntry)(unsafe.Pointer(entryPtr)).Fstring1 byteIndex = libc.Uint64FromInt64(int64(libtcl9_0.XTcl_UtfAtIndex(tls, string1, index)) - int64(string1)) byteCount = libc.Xstrlen(tls, value) if byteCount == uint64(0) { return TCL_OK } newByteCount = libc.Uint64FromInt64((*TEntry)(unsafe.Pointer(entryPtr)).FnumBytes) + byteCount + uint64(1) newStr = libtcl9_0.XTcl_Alloc(tls, newByteCount) libc.Xmemcpy(tls, newStr, string1, byteIndex) libc.Xstrcpy(tls, newStr+uintptr(byteIndex), value) libc.Xstrcpy(tls, newStr+uintptr(byteIndex)+uintptr(byteCount), string1+uintptr(byteIndex)) if ((*TEntry)(unsafe.Pointer(entryPtr)).Fvalidate == int32(VALIDATE_KEY) || (*TEntry)(unsafe.Pointer(entryPtr)).Fvalidate == int32(VALIDATE_ALL)) && _EntryValidateChange(tls, entryPtr, value, newStr, index, int32(VALIDATE_INSERT)) != TCL_OK { libtcl9_0.XTcl_Free(tls, newStr) return TCL_OK } libtcl9_0.XTcl_Free(tls, string1) (*TEntry)(unsafe.Pointer(entryPtr)).Fstring1 = newStr /* * The following construction is used because inserting improperly formed * UTF-8 sequences between other improperly formed UTF-8 sequences could * result in actually forming valid UTF-8 sequences; the number of * characters added may not be Tcl_NumUtfChars(string, TCL_INDEX_NONE), because of * context. The actual number of characters added is how many characters * are in the string now minus the number that used to be there. */ oldChars = libc.Uint64FromInt64((*TEntry)(unsafe.Pointer(entryPtr)).FnumChars) (*TEntry)(unsafe.Pointer(entryPtr)).FnumChars = libtcl9_0.XTcl_NumUtfChars(tls, newStr, int64(-libc.Int32FromInt32(1))) charsAdded = libc.Uint64FromInt64((*TEntry)(unsafe.Pointer(entryPtr)).FnumChars) - oldChars p1 = entryPtr + 312 *(*TTcl_Size)(unsafe.Pointer(p1)) = TTcl_Size(uint64(*(*TTcl_Size)(unsafe.Pointer(p1))) + byteCount) if (*TEntry)(unsafe.Pointer(entryPtr)).FdisplayString == string1 { (*TEntry)(unsafe.Pointer(entryPtr)).FdisplayString = newStr (*TEntry)(unsafe.Pointer(entryPtr)).FnumDisplayBytes = (*TEntry)(unsafe.Pointer(entryPtr)).FnumBytes } /* * Inserting characters invalidates all indexes into the string. Touch up * the indexes so that they still refer to the same characters (at new * positions). When updating the selection end-points, don't include the * new text in the selection unless it was completely surrounded by the * selection. */ if (*TEntry)(unsafe.Pointer(entryPtr)).FselectFirst >= index { p2 = entryPtr + 64 *(*TTcl_Size)(unsafe.Pointer(p2)) = TTcl_Size(uint64(*(*TTcl_Size)(unsafe.Pointer(p2))) + charsAdded) } if (*TEntry)(unsafe.Pointer(entryPtr)).FselectLast > index { p3 = entryPtr + 72 *(*TTcl_Size)(unsafe.Pointer(p3)) = TTcl_Size(uint64(*(*TTcl_Size)(unsafe.Pointer(p3))) + charsAdded) } if (*TEntry)(unsafe.Pointer(entryPtr)).FselectAnchor > index || (*TEntry)(unsafe.Pointer(entryPtr)).FselectFirst >= index { p4 = entryPtr + 80 *(*TTcl_Size)(unsafe.Pointer(p4)) = TTcl_Size(uint64(*(*TTcl_Size)(unsafe.Pointer(p4))) + charsAdded) } if (*TEntry)(unsafe.Pointer(entryPtr)).FleftIndex > index { p5 = entryPtr + 368 *(*TTcl_Size)(unsafe.Pointer(p5)) = TTcl_Size(uint64(*(*TTcl_Size)(unsafe.Pointer(p5))) + charsAdded) } if (*TEntry)(unsafe.Pointer(entryPtr)).FinsertPos >= index { p6 = entryPtr + 56 *(*TTcl_Size)(unsafe.Pointer(p6)) = TTcl_Size(uint64(*(*TTcl_Size)(unsafe.Pointer(p6))) + charsAdded) } return _EntryValueChanged(tls, entryPtr, libc.UintptrFromInt32(0)) } /* *---------------------------------------------------------------------- * * DeleteChars -- * * Remove one or more characters from an entry widget. * * Results: * A standard Tcl result. If an error occurred then an error message is * left in the interp's result. * * Side effects: * Memory gets freed, the entry gets modified and (eventually) * redisplayed. * *---------------------------------------------------------------------- */ func _DeleteChars(tls *libc.TLS, entryPtr uintptr, index TTcl_Size, count TTcl_Size) (r int32) { /* How many characters to delete. */ var byteCount, byteIndex, newByteCount int32 var newStr, string1, toDelete uintptr _, _, _, _, _, _ = byteCount, byteIndex, newByteCount, newStr, string1, toDelete if index+count > (*TEntry)(unsafe.Pointer(entryPtr)).FnumChars { count = (*TEntry)(unsafe.Pointer(entryPtr)).FnumChars - index } if int32(count) <= 0 { return TCL_OK } string1 = (*TEntry)(unsafe.Pointer(entryPtr)).Fstring1 byteIndex = int32(int64(libtcl9_0.XTcl_UtfAtIndex(tls, string1, index)) - int64(string1)) byteCount = int32(int64(libtcl9_0.XTcl_UtfAtIndex(tls, string1+uintptr(byteIndex), count)) - int64(string1+uintptr(byteIndex))) newByteCount = int32((*TEntry)(unsafe.Pointer(entryPtr)).FnumBytes + int64(1) - int64(byteCount)) newStr = libtcl9_0.XTcl_Alloc(tls, libc.Uint64FromInt32(newByteCount)) libc.Xmemcpy(tls, newStr, string1, libc.Uint64FromInt32(byteIndex)) libc.Xstrcpy(tls, newStr+uintptr(byteIndex), string1+uintptr(byteIndex)+uintptr(byteCount)) toDelete = libtcl9_0.XTcl_Alloc(tls, libc.Uint64FromInt32(byteCount+int32(1))) libc.Xmemcpy(tls, toDelete, string1+uintptr(byteIndex), libc.Uint64FromInt32(byteCount)) *(*uint8)(unsafe.Pointer(toDelete + uintptr(byteCount))) = uint8('\000') if ((*TEntry)(unsafe.Pointer(entryPtr)).Fvalidate == int32(VALIDATE_KEY) || (*TEntry)(unsafe.Pointer(entryPtr)).Fvalidate == int32(VALIDATE_ALL)) && _EntryValidateChange(tls, entryPtr, toDelete, newStr, index, int32(VALIDATE_DELETE)) != TCL_OK { libtcl9_0.XTcl_Free(tls, newStr) libtcl9_0.XTcl_Free(tls, toDelete) return TCL_OK } libtcl9_0.XTcl_Free(tls, toDelete) libtcl9_0.XTcl_Free(tls, (*TEntry)(unsafe.Pointer(entryPtr)).Fstring1) (*TEntry)(unsafe.Pointer(entryPtr)).Fstring1 = newStr *(*TTcl_Size)(unsafe.Pointer(entryPtr + 320)) -= count *(*TTcl_Size)(unsafe.Pointer(entryPtr + 312)) -= int64(byteCount) if (*TEntry)(unsafe.Pointer(entryPtr)).FdisplayString == string1 { (*TEntry)(unsafe.Pointer(entryPtr)).FdisplayString = newStr (*TEntry)(unsafe.Pointer(entryPtr)).FnumDisplayBytes = (*TEntry)(unsafe.Pointer(entryPtr)).FnumBytes } /* * Deleting characters results in the remaining characters being * renumbered. Update the various indexes into the string to reflect this * change. */ if (*TEntry)(unsafe.Pointer(entryPtr)).FselectFirst >= index { if (*TEntry)(unsafe.Pointer(entryPtr)).FselectFirst >= index+count { *(*TTcl_Size)(unsafe.Pointer(entryPtr + 64)) -= count } else { (*TEntry)(unsafe.Pointer(entryPtr)).FselectFirst = index } } if (*TEntry)(unsafe.Pointer(entryPtr)).FselectLast >= index { if (*TEntry)(unsafe.Pointer(entryPtr)).FselectLast >= index+count { *(*TTcl_Size)(unsafe.Pointer(entryPtr + 72)) -= count } else { (*TEntry)(unsafe.Pointer(entryPtr)).FselectLast = index } } if (*TEntry)(unsafe.Pointer(entryPtr)).FselectLast <= (*TEntry)(unsafe.Pointer(entryPtr)).FselectFirst { (*TEntry)(unsafe.Pointer(entryPtr)).FselectFirst = int64(-libc.Int32FromInt32(1)) (*TEntry)(unsafe.Pointer(entryPtr)).FselectLast = int64(-libc.Int32FromInt32(1)) } if (*TEntry)(unsafe.Pointer(entryPtr)).FselectAnchor >= index { if (*TEntry)(unsafe.Pointer(entryPtr)).FselectAnchor >= index+count { *(*TTcl_Size)(unsafe.Pointer(entryPtr + 80)) -= count } else { (*TEntry)(unsafe.Pointer(entryPtr)).FselectAnchor = index } } if (*TEntry)(unsafe.Pointer(entryPtr)).FleftIndex > index { if (*TEntry)(unsafe.Pointer(entryPtr)).FleftIndex >= index+count { *(*TTcl_Size)(unsafe.Pointer(entryPtr + 368)) -= count } else { (*TEntry)(unsafe.Pointer(entryPtr)).FleftIndex = index } } if (*TEntry)(unsafe.Pointer(entryPtr)).FinsertPos >= index { if (*TEntry)(unsafe.Pointer(entryPtr)).FinsertPos >= index+count { *(*TTcl_Size)(unsafe.Pointer(entryPtr + 56)) -= count } else { (*TEntry)(unsafe.Pointer(entryPtr)).FinsertPos = index } } return _EntryValueChanged(tls, entryPtr, libc.UintptrFromInt32(0)) } /* *---------------------------------------------------------------------- * * EntryValueChanged -- * * This function is invoked when characters are inserted into an entry or * deleted from it. It updates the entry's associated variable, if there * is one, and does other bookkeeping such as arranging for redisplay. * * Results: * A standard Tcl result. If an error occurred then an error message is * left in the interp's result. * * Side effects: * None. * *---------------------------------------------------------------------- */ func _EntryValueChanged(tls *libc.TLS, entryPtr uintptr, newValue uintptr) (r int32) { /* If this value is not NULL, we first force * the value of the entry to this. */ if newValue != libc.UintptrFromInt32(0) { _EntrySetValue(tls, entryPtr, newValue) } if (*TEntry)(unsafe.Pointer(entryPtr)).FtextVarNameObj == libc.UintptrFromInt32(0) { newValue = libc.UintptrFromInt32(0) } else { newValue = libtcl9_0.XTcl_SetVar2(tls, (*TEntry)(unsafe.Pointer(entryPtr)).Finterp, libtcl9_0.XTcl_GetStringFromObj(tls, (*TEntry)(unsafe.Pointer(entryPtr)).FtextVarNameObj, libc.UintptrFromInt32(0)), libc.UintptrFromInt32(0), (*TEntry)(unsafe.Pointer(entryPtr)).Fstring1, libc.Int32FromInt32(TCL_GLOBAL_ONLY)|libc.Int32FromInt32(TCL_LEAVE_ERR_MSG)) } if newValue != libc.UintptrFromInt32(0) && libc.Xstrcmp(tls, newValue, (*TEntry)(unsafe.Pointer(entryPtr)).Fstring1) != 0 { /* * The value of the variable is different than what we asked for. * This means that a trace on the variable modified it. In this case * our trace function wasn't invoked since the modification came while * a trace was already active on the variable. So, update our value to * reflect the variable's latest value. */ _EntrySetValue(tls, entryPtr, newValue) } else { /* * Arrange for redisplay. */ *(*int32)(unsafe.Pointer(entryPtr + 416)) |= int32(UPDATE_SCROLLBAR) _EntryComputeGeometry(tls, entryPtr) _EventuallyRedraw(tls, entryPtr) } /* * An error may have happened when setting the textvariable in case there * is a trace on that variable and the trace proc triggered an error. * Another possibility is that the textvariable is in a namespace that * does not (yet) exist. * Signal this error. */ if (*TEntry)(unsafe.Pointer(entryPtr)).FtextVarNameObj != libc.UintptrFromInt32(0) && newValue == libc.UintptrFromInt32(0) { return int32(TCL_ERROR) } return TCL_OK } /* *---------------------------------------------------------------------- * * EntrySetValue -- * * Replace the contents of a text entry with a given value. This function * is invoked when updating the entry from the entry's associated * variable. * * Results: * None. * * Side effects: * The string displayed in the entry will change. The selection, * insertion point, and view may have to be adjusted to keep them within * the bounds of the new string. Note: this function does *not* update * the entry's associated variable, since that could result in an * infinite loop. * *---------------------------------------------------------------------- */ func _EntrySetValue(tls *libc.TLS, entryPtr uintptr, value uintptr) { /* New text to display in entry. */ var malloced, valueLen int32 var oldSource, tmp, tmp1 uintptr _, _, _, _, _ = malloced, oldSource, tmp, tmp1, valueLen malloced = 0 if libc.Xstrcmp(tls, value, (*TEntry)(unsafe.Pointer(entryPtr)).Fstring1) == 0 { return } valueLen = libc.Int32FromUint64(libc.Xstrlen(tls, value)) if (*TEntry)(unsafe.Pointer(entryPtr)).Fflags&int32(VALIDATE_VAR) != 0 { *(*int32)(unsafe.Pointer(entryPtr + 416)) |= int32(VALIDATE_ABORT) } else { /* * If we validate, we create a copy of the value, as it may point to * volatile memory, like the value of the -textvar which may get freed * during validation */ tmp = libtcl9_0.XTcl_Alloc(tls, libc.Uint64FromInt32(valueLen+int32(1))) libc.Xstrcpy(tls, tmp, value) value = tmp malloced = int32(1) *(*int32)(unsafe.Pointer(entryPtr + 416)) |= int32(VALIDATE_VAR) _EntryValidateChange(tls, entryPtr, libc.UintptrFromInt32(0), value, int64(-libc.Int32FromInt32(1)), int32(VALIDATE_FORCED)) *(*int32)(unsafe.Pointer(entryPtr + 416)) &= ^libc.Int32FromInt32(VALIDATE_VAR) /* * If VALIDATE_ABORT has been set, then this operation should be * aborted because the validatecommand did something else instead */ if (*TEntry)(unsafe.Pointer(entryPtr)).Fflags&int32(VALIDATE_ABORT) != 0 { *(*int32)(unsafe.Pointer(entryPtr + 416)) &= ^libc.Int32FromInt32(VALIDATE_ABORT) libtcl9_0.XTcl_Free(tls, value) return } } oldSource = (*TEntry)(unsafe.Pointer(entryPtr)).Fstring1 libtcl9_0.XTcl_Free(tls, (*TEntry)(unsafe.Pointer(entryPtr)).Fstring1) if malloced != 0 { (*TEntry)(unsafe.Pointer(entryPtr)).Fstring1 = value } else { tmp1 = libtcl9_0.XTcl_Alloc(tls, libc.Uint64FromInt32(valueLen+int32(1))) libc.Xstrcpy(tls, tmp1, value) (*TEntry)(unsafe.Pointer(entryPtr)).Fstring1 = tmp1 } (*TEntry)(unsafe.Pointer(entryPtr)).FnumBytes = int64(valueLen) (*TEntry)(unsafe.Pointer(entryPtr)).FnumChars = libtcl9_0.XTcl_NumUtfChars(tls, value, int64(valueLen)) if (*TEntry)(unsafe.Pointer(entryPtr)).FdisplayString == oldSource { (*TEntry)(unsafe.Pointer(entryPtr)).FdisplayString = (*TEntry)(unsafe.Pointer(entryPtr)).Fstring1 (*TEntry)(unsafe.Pointer(entryPtr)).FnumDisplayBytes = (*TEntry)(unsafe.Pointer(entryPtr)).FnumBytes } if (*TEntry)(unsafe.Pointer(entryPtr)).FselectFirst != int64(-libc.Int32FromInt32(1)) { if (*TEntry)(unsafe.Pointer(entryPtr)).FselectFirst >= (*TEntry)(unsafe.Pointer(entryPtr)).FnumChars { (*TEntry)(unsafe.Pointer(entryPtr)).FselectFirst = int64(-libc.Int32FromInt32(1)) (*TEntry)(unsafe.Pointer(entryPtr)).FselectLast = int64(-libc.Int32FromInt32(1)) } else { if (*TEntry)(unsafe.Pointer(entryPtr)).FselectLast > (*TEntry)(unsafe.Pointer(entryPtr)).FnumChars { (*TEntry)(unsafe.Pointer(entryPtr)).FselectLast = (*TEntry)(unsafe.Pointer(entryPtr)).FnumChars } } } if (*TEntry)(unsafe.Pointer(entryPtr)).FleftIndex >= (*TEntry)(unsafe.Pointer(entryPtr)).FnumChars { if (*TEntry)(unsafe.Pointer(entryPtr)).FnumChars > 0 { (*TEntry)(unsafe.Pointer(entryPtr)).FleftIndex = (*TEntry)(unsafe.Pointer(entryPtr)).FnumChars - int64(1) } else { (*TEntry)(unsafe.Pointer(entryPtr)).FleftIndex = 0 } } if (*TEntry)(unsafe.Pointer(entryPtr)).FinsertPos > (*TEntry)(unsafe.Pointer(entryPtr)).FnumChars { (*TEntry)(unsafe.Pointer(entryPtr)).FinsertPos = (*TEntry)(unsafe.Pointer(entryPtr)).FnumChars } *(*int32)(unsafe.Pointer(entryPtr + 416)) |= int32(UPDATE_SCROLLBAR) _EntryComputeGeometry(tls, entryPtr) _EventuallyRedraw(tls, entryPtr) } /* *-------------------------------------------------------------- * * EntryEventProc -- * * This function is invoked by the Tk dispatcher for various events on * entries. * * Results: * None. * * Side effects: * When the window gets deleted, internal structures get cleaned up. * When it gets exposed, it is redisplayed. * *-------------------------------------------------------------- */ func _EntryEventProc(tls *libc.TLS, clientData uintptr, eventPtr uintptr) { /* Information about event. */ var cursor TTk_Cursor var elem int32 var entryPtr, sbPtr uintptr _, _, _, _ = cursor, elem, entryPtr, sbPtr entryPtr = clientData if (*TEntry)(unsafe.Pointer(entryPtr)).Ftype1 == int32(TK_SPINBOX) && (*TXEvent)(unsafe.Pointer(eventPtr)).Ftype1 == int32(MotionNotify) { sbPtr = clientData elem = _GetSpinboxElement(tls, sbPtr, (*(*TXMotionEvent)(unsafe.Pointer(eventPtr))).Fx, (*(*TXMotionEvent)(unsafe.Pointer(eventPtr))).Fy) if elem != (*TSpinbox)(unsafe.Pointer(sbPtr)).FcurElement { (*TSpinbox)(unsafe.Pointer(sbPtr)).FcurElement = elem if elem == int32(SEL_ENTRY) { cursor = (*TEntry)(unsafe.Pointer(entryPtr)).Fcursor } else { if elem == int32(SEL_BUTTONDOWN) || elem == int32(SEL_BUTTONUP) { cursor = (*TSpinbox)(unsafe.Pointer(sbPtr)).FbCursor } else { cursor = libc.UintptrFromInt32(0) } } if cursor != libc.UintptrFromInt32(0) { XTk_DefineCursor(tls, (*TEntry)(unsafe.Pointer(entryPtr)).Ftkwin, cursor) } else { XTk_UndefineCursor(tls, (*TEntry)(unsafe.Pointer(entryPtr)).Ftkwin) } } return } switch (*TXEvent)(unsafe.Pointer(eventPtr)).Ftype1 { case int32(Expose): _EventuallyRedraw(tls, entryPtr) *(*int32)(unsafe.Pointer(entryPtr + 416)) |= int32(BORDER_NEEDED) case int32(DestroyNotify): if !((*TEntry)(unsafe.Pointer(entryPtr)).Fflags&libc.Int32FromInt32(ENTRY_DELETED) != 0) { *(*int32)(unsafe.Pointer(entryPtr + 416)) |= libc.Int32FromInt32(ENTRY_DELETED) | libc.Int32FromInt32(VALIDATE_ABORT) libtcl9_0.XTcl_DeleteCommandFromToken(tls, (*TEntry)(unsafe.Pointer(entryPtr)).Finterp, (*TEntry)(unsafe.Pointer(entryPtr)).FwidgetCmd) if (*TEntry)(unsafe.Pointer(entryPtr)).Fflags&int32(REDRAW_PENDING) != 0 { libtcl9_0.XTcl_CancelIdleCall(tls, __ccgo_fp(_DisplayEntry), clientData) } libtcl9_0.XTcl_EventuallyFree(tls, clientData, __ccgo_fp(_DestroyEntry)) } case int32(ConfigureNotify): libtcl9_0.XTcl_Preserve(tls, entryPtr) *(*int32)(unsafe.Pointer(entryPtr + 416)) |= int32(UPDATE_SCROLLBAR) _EntryComputeGeometry(tls, entryPtr) _EventuallyRedraw(tls, entryPtr) libtcl9_0.XTcl_Release(tls, entryPtr) case int32(FocusIn): fallthrough case int32(FocusOut): if (*(*TXFocusChangeEvent)(unsafe.Pointer(eventPtr))).Fdetail != int32(NotifyInferior) { _EntryFocusProc(tls, entryPtr, libc.BoolInt32((*TXEvent)(unsafe.Pointer(eventPtr)).Ftype1 == int32(FocusIn))) } break } } /* *---------------------------------------------------------------------- * * EntryCmdDeletedProc -- * * This function is invoked when a widget command is deleted. If the * widget isn't already in the process of being destroyed, this command * destroys it. * * Results: * None. * * Side effects: * The widget is destroyed. * *---------------------------------------------------------------------- */ func _EntryCmdDeletedProc(tls *libc.TLS, clientData uintptr) { /* Pointer to widget record for widget. */ var entryPtr uintptr _ = entryPtr entryPtr = clientData /* * This function could be invoked either because the window was destroyed * and the command was then deleted (in which case tkwin is NULL) or * because the command was deleted, and then this function destroys the * widget. */ if !((*TEntry)(unsafe.Pointer(entryPtr)).Fflags&libc.Int32FromInt32(ENTRY_DELETED) != 0) { XTk_DestroyWindow(tls, (*TEntry)(unsafe.Pointer(entryPtr)).Ftkwin) } } /* *--------------------------------------------------------------------------- * * GetEntryIndex -- * * Parse an index into an entry and return either its value or an error. * * Results: * A standard Tcl result. If all went well, then *indexPtr is filled in * with the character index (into entryPtr) corresponding to string. The * index value is guaranteed to lie between 0 and the number of * characters in the string, inclusive. If an error occurs then an error * message is left in the interp's result. * * Side effects: * None. * *--------------------------------------------------------------------------- */ func _GetEntryIndex(tls *libc.TLS, interp uintptr, entryPtr uintptr, indexObj uintptr, indexPtr uintptr) (r int32) { bp := tls.Alloc(64) defer tls.Free(64) /* Where to store converted character index */ var maxWidth, roundUp int32 var string1, v7, v8, v9 uintptr var _ /* idx at bp+8 */ TTcl_Size var _ /* length at bp+0 */ TTcl_Size var _ /* x at bp+16 */ int32 _, _, _, _, _, _ = maxWidth, roundUp, string1, v7, v8, v9 if TCL_OK == XTkGetIntForIndex(tls, indexObj, (*TEntry)(unsafe.Pointer(entryPtr)).FnumChars-int64(1), int32(1), bp+8) { if *(*TTcl_Size)(unsafe.Pointer(bp + 8)) < 0 { *(*TTcl_Size)(unsafe.Pointer(bp + 8)) = 0 } else { if *(*TTcl_Size)(unsafe.Pointer(bp + 8)) > (*TEntry)(unsafe.Pointer(entryPtr)).FnumChars { *(*TTcl_Size)(unsafe.Pointer(bp + 8)) = (*TEntry)(unsafe.Pointer(entryPtr)).FnumChars } } *(*TTcl_Size)(unsafe.Pointer(indexPtr)) = *(*TTcl_Size)(unsafe.Pointer(bp + 8)) return TCL_OK } string1 = libtcl9_0.XTcl_GetStringFromObj(tls, indexObj, bp) switch libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(string1))) { case int32('a'): goto _1 case int32('i'): goto _2 case int32('s'): goto _3 case int32('@'): goto _4 default: goto _5 } goto _6 _1: ; if libc.Xstrncmp(tls, string1, __ccgo_ts+7881, libc.Uint64FromInt64(*(*TTcl_Size)(unsafe.Pointer(bp)))) != 0 { goto badIndex } *(*TTcl_Size)(unsafe.Pointer(indexPtr)) = (*TEntry)(unsafe.Pointer(entryPtr)).FselectAnchor goto _6 _2: ; if libc.Xstrncmp(tls, string1, __ccgo_ts+22158, libc.Uint64FromInt64(*(*TTcl_Size)(unsafe.Pointer(bp)))) != 0 { goto badIndex } *(*TTcl_Size)(unsafe.Pointer(indexPtr)) = (*TEntry)(unsafe.Pointer(entryPtr)).FinsertPos goto _6 _3: ; if (*TEntry)(unsafe.Pointer(entryPtr)).FselectFirst < 0 { libtcl9_0.XTcl_ResetResult(tls, interp) libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+22506, libc.VaList(bp+32, (*TTk_FakeWin)(unsafe.Pointer((*TEntry)(unsafe.Pointer(entryPtr)).Ftkwin)).FpathName))) if (*TEntry)(unsafe.Pointer(entryPtr)).Ftype1 == int32(TK_ENTRY) { v7 = __ccgo_ts + 22535 } else { v7 = __ccgo_ts + 22439 } libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+32, __ccgo_ts+179, v7, __ccgo_ts+22541, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) } if *(*TTcl_Size)(unsafe.Pointer(bp)) < int64(5) { goto badIndex } if libc.Xstrncmp(tls, string1, __ccgo_ts+22554, libc.Uint64FromInt64(*(*TTcl_Size)(unsafe.Pointer(bp)))) == 0 { *(*TTcl_Size)(unsafe.Pointer(indexPtr)) = (*TEntry)(unsafe.Pointer(entryPtr)).FselectFirst } else { if libc.Xstrncmp(tls, string1, __ccgo_ts+22564, libc.Uint64FromInt64(*(*TTcl_Size)(unsafe.Pointer(bp)))) == 0 { *(*TTcl_Size)(unsafe.Pointer(indexPtr)) = (*TEntry)(unsafe.Pointer(entryPtr)).FselectLast } else { goto badIndex } } goto _6 _4: ; if libtcl9_0.XTcl_GetInt(tls, libc.UintptrFromInt32(0), string1+uintptr(1), bp+16) != TCL_OK { goto badIndex } if *(*int32)(unsafe.Pointer(bp + 16)) < (*TEntry)(unsafe.Pointer(entryPtr)).Finset { *(*int32)(unsafe.Pointer(bp + 16)) = (*TEntry)(unsafe.Pointer(entryPtr)).Finset } roundUp = 0 maxWidth = (*TTk_FakeWin)(unsafe.Pointer((*TEntry)(unsafe.Pointer(entryPtr)).Ftkwin)).Fchanges.Fwidth - (*TEntry)(unsafe.Pointer(entryPtr)).Finset - (*TEntry)(unsafe.Pointer(entryPtr)).FxWidth - int32(1) if *(*int32)(unsafe.Pointer(bp + 16)) > maxWidth { *(*int32)(unsafe.Pointer(bp + 16)) = maxWidth roundUp = int32(1) } *(*TTcl_Size)(unsafe.Pointer(indexPtr)) = int64(XTk_PointToChar(tls, (*TEntry)(unsafe.Pointer(entryPtr)).FtextLayout, *(*int32)(unsafe.Pointer(bp + 16))-(*TEntry)(unsafe.Pointer(entryPtr)).FlayoutX, 0)) /* * Special trick: if the x-position was off-screen to the right, round * the index up to refer to the character just after the last visible * one on the screen. This is needed to enable the last character to * be selected, for example. */ if roundUp != 0 && *(*TTcl_Size)(unsafe.Pointer(indexPtr)) < (*TEntry)(unsafe.Pointer(entryPtr)).FnumChars { *(*TTcl_Size)(unsafe.Pointer(indexPtr)) += int64(1) } goto _6 _5: ; goto badIndex badIndex: ; if (*TEntry)(unsafe.Pointer(entryPtr)).Ftype1 == int32(TK_ENTRY) { v8 = __ccgo_ts + 17887 } else { v8 = __ccgo_ts + 17988 } libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+22573, libc.VaList(bp+32, v8, string1))) if (*TEntry)(unsafe.Pointer(entryPtr)).Ftype1 == int32(TK_ENTRY) { v9 = __ccgo_ts + 22535 } else { v9 = __ccgo_ts + 22439 } libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+32, __ccgo_ts+179, v9, __ccgo_ts+22591, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) _6: ; return TCL_OK } /* *---------------------------------------------------------------------- * * EntryScanTo -- * * Given a y-coordinate (presumably of the curent mouse location) drag * the view in the window to implement the scan operation. * * Results: * None. * * Side effects: * The view in the window may change. * *---------------------------------------------------------------------- */ func _EntryScanTo(tls *libc.TLS, entryPtr uintptr, x int32) { /* X-coordinate to use for scan operation. */ var newLeftIndex TTcl_Size var v1, v2 int32 _, _, _ = newLeftIndex, v1, v2 /* * Compute new leftIndex for entry by amplifying the difference between * the current position and the place where the scan started (the "mark" * position). If we run off the left or right side of the entry, then * reset the mark point so that the current position continues to * correspond to the edge of the window. This means that the picture will * start dragging as soon as the mouse reverses direction (without this * reset, might have to slide mouse a long ways back before the picture * starts moving again). */ newLeftIndex = int64((*TEntry)(unsafe.Pointer(entryPtr)).FscanMarkIndex - int32(10)*(x-(*TEntry)(unsafe.Pointer(entryPtr)).FscanMarkX)/(*TEntry)(unsafe.Pointer(entryPtr)).FavgWidth) if newLeftIndex >= (*TEntry)(unsafe.Pointer(entryPtr)).FnumChars { v1 = int32((*TEntry)(unsafe.Pointer(entryPtr)).FnumChars - libc.Int64FromInt32(1)) (*TEntry)(unsafe.Pointer(entryPtr)).FscanMarkIndex = v1 newLeftIndex = int64(v1) (*TEntry)(unsafe.Pointer(entryPtr)).FscanMarkX = x } if newLeftIndex < 0 { v2 = libc.Int32FromInt32(0) (*TEntry)(unsafe.Pointer(entryPtr)).FscanMarkIndex = v2 newLeftIndex = int64(v2) (*TEntry)(unsafe.Pointer(entryPtr)).FscanMarkX = x } if newLeftIndex != (*TEntry)(unsafe.Pointer(entryPtr)).FleftIndex { (*TEntry)(unsafe.Pointer(entryPtr)).FleftIndex = newLeftIndex *(*int32)(unsafe.Pointer(entryPtr + 416)) |= int32(UPDATE_SCROLLBAR) _EntryComputeGeometry(tls, entryPtr) if newLeftIndex != (*TEntry)(unsafe.Pointer(entryPtr)).FleftIndex { (*TEntry)(unsafe.Pointer(entryPtr)).FscanMarkIndex = int32((*TEntry)(unsafe.Pointer(entryPtr)).FleftIndex) (*TEntry)(unsafe.Pointer(entryPtr)).FscanMarkX = x } _EventuallyRedraw(tls, entryPtr) } } /* *---------------------------------------------------------------------- * * EntrySelectTo -- * * Modify the selection by moving its un-anchored end. This could make * the selection either larger or smaller. * * Results: * None. * * Side effects: * The selection changes. * *---------------------------------------------------------------------- */ func _EntrySelectTo(tls *libc.TLS, entryPtr uintptr, index TTcl_Size) { /* Character index of element that is to * become the "other" end of the selection. */ var newFirst, newLast, v1 TTcl_Size _, _, _ = newFirst, newLast, v1 /* * Grab the selection if we don't own it already. */ if !((*TEntry)(unsafe.Pointer(entryPtr)).Fflags&libc.Int32FromInt32(GOT_SELECTION) != 0) && (*TEntry)(unsafe.Pointer(entryPtr)).FexportSelection != 0 && !(libtcl9_0.XTcl_IsSafe(tls, (*TEntry)(unsafe.Pointer(entryPtr)).Finterp) != 0) { XTk_OwnSelection(tls, (*TEntry)(unsafe.Pointer(entryPtr)).Ftkwin, libc.Uint64FromInt32(1), __ccgo_fp(_EntryLostSelection), entryPtr) *(*int32)(unsafe.Pointer(entryPtr + 416)) |= int32(GOT_SELECTION) } /* * Pick new starting and ending points for the selection. */ if (*TEntry)(unsafe.Pointer(entryPtr)).FselectAnchor > (*TEntry)(unsafe.Pointer(entryPtr)).FnumChars { (*TEntry)(unsafe.Pointer(entryPtr)).FselectAnchor = (*TEntry)(unsafe.Pointer(entryPtr)).FnumChars } if (*TEntry)(unsafe.Pointer(entryPtr)).FselectAnchor <= index { newFirst = (*TEntry)(unsafe.Pointer(entryPtr)).FselectAnchor newLast = index } else { newFirst = index newLast = (*TEntry)(unsafe.Pointer(entryPtr)).FselectAnchor if newLast < 0 { v1 = int64(-libc.Int32FromInt32(1)) newLast = v1 newFirst = v1 } } if (*TEntry)(unsafe.Pointer(entryPtr)).FselectFirst == newFirst && (*TEntry)(unsafe.Pointer(entryPtr)).FselectLast == newLast { return } (*TEntry)(unsafe.Pointer(entryPtr)).FselectFirst = newFirst (*TEntry)(unsafe.Pointer(entryPtr)).FselectLast = newLast _EventuallyRedraw(tls, entryPtr) } /* *---------------------------------------------------------------------- * * EntryFetchSelection -- * * This function is called back by Tk when the selection is requested by * someone. It returns part or all of the selection in a buffer provided * by the caller. * * Results: * The return value is the number of non-NULL bytes stored at buffer. * Buffer is filled (or partially filled) with a NULL-terminated string * containing part or all of the selection, as given by offset and * maxBytes. * * Side effects: * None. * *---------------------------------------------------------------------- */ func _EntryFetchSelection(tls *libc.TLS, clientData uintptr, offset TTcl_Size, buffer uintptr, maxBytes TTcl_Size) (r TTcl_Size) { /* Maximum number of bytes to place at buffer, * not including terminating NUL character. */ var byteCount TTcl_Size var entryPtr, selEnd, selStart, string1 uintptr _, _, _, _, _ = byteCount, entryPtr, selEnd, selStart, string1 entryPtr = clientData if (*TEntry)(unsafe.Pointer(entryPtr)).FselectFirst < 0 || !((*TEntry)(unsafe.Pointer(entryPtr)).FexportSelection != 0) || libtcl9_0.XTcl_IsSafe(tls, (*TEntry)(unsafe.Pointer(entryPtr)).Finterp) != 0 { return int64(-int32(1)) } string1 = (*TEntry)(unsafe.Pointer(entryPtr)).FdisplayString selStart = libtcl9_0.XTcl_UtfAtIndex(tls, string1, (*TEntry)(unsafe.Pointer(entryPtr)).FselectFirst) selEnd = libtcl9_0.XTcl_UtfAtIndex(tls, selStart, (*TEntry)(unsafe.Pointer(entryPtr)).FselectLast-(*TEntry)(unsafe.Pointer(entryPtr)).FselectFirst) if selEnd <= selStart+uintptr(offset) { return 0 } byteCount = int64(selEnd) - int64(selStart) - offset if byteCount > maxBytes { byteCount = maxBytes } libc.Xmemcpy(tls, buffer, selStart+uintptr(offset), libc.Uint64FromInt64(byteCount)) *(*uint8)(unsafe.Pointer(buffer + uintptr(byteCount))) = uint8('\000') return byteCount } /* *---------------------------------------------------------------------- * * EntryLostSelection -- * * This function is called back by Tk when the selection is grabbed away * from an entry widget. * * Results: * None. * * Side effects: * The existing selection is unhighlighted, and the window is marked as * not containing a selection. * *---------------------------------------------------------------------- */ func _EntryLostSelection(tls *libc.TLS, clientData uintptr) { /* Information about entry widget. */ var entryPtr uintptr _ = entryPtr entryPtr = clientData *(*int32)(unsafe.Pointer(entryPtr + 416)) &= ^libc.Int32FromInt32(GOT_SELECTION) /* * On Windows and Mac systems, we want to remember the selection for the * next time the focus enters the window. On Unix, we need to clear the * selection since it is always visible. * This is controlled by ::tk::AlwaysShowSelection. */ if XTk_AlwaysShowSelection(tls, (*TEntry)(unsafe.Pointer(entryPtr)).Ftkwin) != 0 && (*TEntry)(unsafe.Pointer(entryPtr)).FselectFirst != int64(-libc.Int32FromInt32(1)) && (*TEntry)(unsafe.Pointer(entryPtr)).FexportSelection != 0 && !(libtcl9_0.XTcl_IsSafe(tls, (*TEntry)(unsafe.Pointer(entryPtr)).Finterp) != 0) { (*TEntry)(unsafe.Pointer(entryPtr)).FselectFirst = int64(-libc.Int32FromInt32(1)) (*TEntry)(unsafe.Pointer(entryPtr)).FselectLast = int64(-libc.Int32FromInt32(1)) _EventuallyRedraw(tls, entryPtr) } } /* *---------------------------------------------------------------------- * * EventuallyRedraw -- * * Ensure that an entry is eventually redrawn on the display. * * Results: * None. * * Side effects: * Information gets redisplayed. Right now we don't do selective * redisplays: the whole window will be redrawn. This doesn't seem to * hurt performance noticeably, but if it does then this could be * changed. * *---------------------------------------------------------------------- */ func _EventuallyRedraw(tls *libc.TLS, entryPtr uintptr) { /* Information about widget. */ if (*TEntry)(unsafe.Pointer(entryPtr)).Fflags&int32(ENTRY_DELETED) != 0 || !((*TTk_FakeWin)(unsafe.Pointer((*TEntry)(unsafe.Pointer(entryPtr)).Ftkwin)).Fflags&libc.Uint32FromInt32(TK_MAPPED) != 0) { return } /* * Right now we don't do selective redisplays: the whole window will be * redrawn. This doesn't seem to hurt performance noticeably, but if it * does then this could be changed. */ if !((*TEntry)(unsafe.Pointer(entryPtr)).Fflags&libc.Int32FromInt32(REDRAW_PENDING) != 0) { *(*int32)(unsafe.Pointer(entryPtr + 416)) |= int32(REDRAW_PENDING) libtcl9_0.XTcl_DoWhenIdle(tls, __ccgo_fp(_DisplayEntry), entryPtr) } } /* *---------------------------------------------------------------------- * * EntryVisibleRange -- * * Return information about the range of the entry that is currently * visible. * * Results: * *firstPtr and *lastPtr are modified to hold fractions between 0 and 1 * identifying the range of characters visible in the entry. * * Side effects: * None. * *---------------------------------------------------------------------- */ func _EntryVisibleRange(tls *libc.TLS, entryPtr uintptr, firstPtr uintptr, lastPtr uintptr) { /* Return position of char just after last * visible one. */ var charsInWindow int32 _ = charsInWindow if (*TEntry)(unsafe.Pointer(entryPtr)).FnumChars == 0 { *(*float64)(unsafe.Pointer(firstPtr)) = float64(0) *(*float64)(unsafe.Pointer(lastPtr)) = float64(1) } else { charsInWindow = XTk_PointToChar(tls, (*TEntry)(unsafe.Pointer(entryPtr)).FtextLayout, (*TTk_FakeWin)(unsafe.Pointer((*TEntry)(unsafe.Pointer(entryPtr)).Ftkwin)).Fchanges.Fwidth-(*TEntry)(unsafe.Pointer(entryPtr)).Finset-(*TEntry)(unsafe.Pointer(entryPtr)).FxWidth-(*TEntry)(unsafe.Pointer(entryPtr)).FlayoutX-int32(1), 0) if charsInWindow < int32((*TEntry)(unsafe.Pointer(entryPtr)).FnumChars) { charsInWindow++ } charsInWindow = int32(int64(charsInWindow) - (*TEntry)(unsafe.Pointer(entryPtr)).FleftIndex) if charsInWindow == 0 { charsInWindow = int32(1) } *(*float64)(unsafe.Pointer(firstPtr)) = float64((*TEntry)(unsafe.Pointer(entryPtr)).FleftIndex) / float64((*TEntry)(unsafe.Pointer(entryPtr)).FnumChars) *(*float64)(unsafe.Pointer(lastPtr)) = float64((*TEntry)(unsafe.Pointer(entryPtr)).FleftIndex+int64(charsInWindow)) / float64((*TEntry)(unsafe.Pointer(entryPtr)).FnumChars) } } /* *---------------------------------------------------------------------- * * EntryUpdateScrollbar -- * * This function is invoked whenever information has changed in an entry * in a way that would invalidate a scrollbar display. If there is an * associated scrollbar, then this function updates it by invoking a Tcl * command. * * Results: * None. * * Side effects: * A Tcl command is invoked, and an additional command may be * invoked to process errors in the command. * *---------------------------------------------------------------------- */ func _EntryUpdateScrollbar(tls *libc.TLS, entryPtr uintptr) { bp := tls.Alloc(320) defer tls.Free(320) /* Information about widget. */ var code int32 var interp uintptr var _ /* buf at bp+72 */ TTcl_DString var _ /* first at bp+56 */ float64 var _ /* firstStr at bp+0 */ [27]uint8 var _ /* last at bp+64 */ float64 var _ /* lastStr at bp+27 */ [27]uint8 _, _ = code, interp if (*TEntry)(unsafe.Pointer(entryPtr)).FscrollCmdObj == libc.UintptrFromInt32(0) { return } interp = (*TEntry)(unsafe.Pointer(entryPtr)).Finterp libtcl9_0.XTcl_Preserve(tls, interp) _EntryVisibleRange(tls, entryPtr, bp+56, bp+64) libtcl9_0.XTcl_PrintDouble(tls, libc.UintptrFromInt32(0), *(*float64)(unsafe.Pointer(bp + 56)), bp) libtcl9_0.XTcl_PrintDouble(tls, libc.UintptrFromInt32(0), *(*float64)(unsafe.Pointer(bp + 64)), bp+27) libtcl9_0.XTcl_DStringInit(tls, bp+72) libtcl9_0.XTcl_DStringAppend(tls, bp+72, libtcl9_0.XTcl_GetStringFromObj(tls, (*TEntry)(unsafe.Pointer(entryPtr)).FscrollCmdObj, libc.UintptrFromInt32(0)), int64(-libc.Int32FromInt32(1))) libtcl9_0.XTcl_DStringAppend(tls, bp+72, __ccgo_ts+634, int64(-libc.Int32FromInt32(1))) libtcl9_0.XTcl_DStringAppend(tls, bp+72, bp, int64(-libc.Int32FromInt32(1))) libtcl9_0.XTcl_DStringAppend(tls, bp+72, __ccgo_ts+634, int64(-libc.Int32FromInt32(1))) libtcl9_0.XTcl_DStringAppend(tls, bp+72, bp+27, int64(-libc.Int32FromInt32(1))) code = libtcl9_0.XTcl_EvalEx(tls, interp, (*TTcl_DString)(unsafe.Pointer(bp+72)).Fstring1, int64(-libc.Int32FromInt32(1)), int32(TCL_EVAL_GLOBAL)) libtcl9_0.XTcl_DStringFree(tls, bp+72) if code != TCL_OK { libtcl9_0.XTcl_AppendObjToErrorInfo(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+22601, libc.VaList(bp+304, (*TTk_FakeWin)(unsafe.Pointer((*TEntry)(unsafe.Pointer(entryPtr)).Ftkwin)).FpathName))) libtcl9_0.XTcl_BackgroundException(tls, interp, code) } libtcl9_0.XTcl_ResetResult(tls, interp) libtcl9_0.XTcl_Release(tls, interp) } /* *---------------------------------------------------------------------- * * EntryBlinkProc -- * * This function is called as a timer handler to blink the insertion * cursor off and on. * * Results: * None. * * Side effects: * The cursor gets turned on or off, redisplay gets invoked, and this * function reschedules itself. * *---------------------------------------------------------------------- */ func _EntryBlinkProc(tls *libc.TLS, clientData uintptr) { /* Pointer to record describing entry. */ var entryPtr uintptr _ = entryPtr entryPtr = clientData if (*TEntry)(unsafe.Pointer(entryPtr)).Fstate == int32(STATE_DISABLED1) || (*TEntry)(unsafe.Pointer(entryPtr)).Fstate == int32(STATE_READONLY) || !((*TEntry)(unsafe.Pointer(entryPtr)).Fflags&libc.Int32FromInt32(GOT_FOCUS1) != 0) || (*TEntry)(unsafe.Pointer(entryPtr)).FinsertOffTime == 0 { return } if (*TEntry)(unsafe.Pointer(entryPtr)).Fflags&int32(CURSOR_ON) != 0 { *(*int32)(unsafe.Pointer(entryPtr + 416)) &= ^libc.Int32FromInt32(CURSOR_ON) (*TEntry)(unsafe.Pointer(entryPtr)).FinsertBlinkHandler = libtcl9_0.XTcl_CreateTimerHandler(tls, (*TEntry)(unsafe.Pointer(entryPtr)).FinsertOffTime, __ccgo_fp(_EntryBlinkProc), entryPtr) } else { *(*int32)(unsafe.Pointer(entryPtr + 416)) |= int32(CURSOR_ON) (*TEntry)(unsafe.Pointer(entryPtr)).FinsertBlinkHandler = libtcl9_0.XTcl_CreateTimerHandler(tls, (*TEntry)(unsafe.Pointer(entryPtr)).FinsertOnTime, __ccgo_fp(_EntryBlinkProc), entryPtr) } _EventuallyRedraw(tls, entryPtr) } /* *---------------------------------------------------------------------- * * EntryFocusProc -- * * This function is called whenever the entry gets or loses the input * focus. It's also called whenever the window is reconfigured while it * has the focus. * * Results: * None. * * Side effects: * The cursor gets turned on or off. * *---------------------------------------------------------------------- */ func _EntryFocusProc(tls *libc.TLS, entryPtr uintptr, gotFocus int32) { /* 1 means window is getting focus, 0 means * it's losing it. */ libtcl9_0.XTcl_DeleteTimerHandler(tls, (*TEntry)(unsafe.Pointer(entryPtr)).FinsertBlinkHandler) if gotFocus != 0 { *(*int32)(unsafe.Pointer(entryPtr + 416)) |= libc.Int32FromInt32(GOT_FOCUS1) | libc.Int32FromInt32(CURSOR_ON) if (*TEntry)(unsafe.Pointer(entryPtr)).FinsertOffTime != 0 { (*TEntry)(unsafe.Pointer(entryPtr)).FinsertBlinkHandler = libtcl9_0.XTcl_CreateTimerHandler(tls, (*TEntry)(unsafe.Pointer(entryPtr)).FinsertOnTime, __ccgo_fp(_EntryBlinkProc), entryPtr) } if (*TEntry)(unsafe.Pointer(entryPtr)).Fvalidate == int32(VALIDATE_ALL) || (*TEntry)(unsafe.Pointer(entryPtr)).Fvalidate == int32(VALIDATE_FOCUS) || (*TEntry)(unsafe.Pointer(entryPtr)).Fvalidate == int32(VALIDATE_FOCUSIN) { _EntryValidateChange(tls, entryPtr, libc.UintptrFromInt32(0), (*TEntry)(unsafe.Pointer(entryPtr)).Fstring1, int64(-libc.Int32FromInt32(1)), int32(VALIDATE_FOCUSIN)) } } else { *(*int32)(unsafe.Pointer(entryPtr + 416)) &= ^(libc.Int32FromInt32(GOT_FOCUS1) | libc.Int32FromInt32(CURSOR_ON)) (*TEntry)(unsafe.Pointer(entryPtr)).FinsertBlinkHandler = libc.UintptrFromInt32(0) if (*TEntry)(unsafe.Pointer(entryPtr)).Fvalidate == int32(VALIDATE_ALL) || (*TEntry)(unsafe.Pointer(entryPtr)).Fvalidate == int32(VALIDATE_FOCUS) || (*TEntry)(unsafe.Pointer(entryPtr)).Fvalidate == int32(VALIDATE_FOCUSOUT) { _EntryValidateChange(tls, entryPtr, libc.UintptrFromInt32(0), (*TEntry)(unsafe.Pointer(entryPtr)).Fstring1, int64(-libc.Int32FromInt32(1)), int32(VALIDATE_FOCUSOUT)) } } _EventuallyRedraw(tls, entryPtr) } /* *-------------------------------------------------------------- * * EntryTextVarProc -- * * This function is invoked when someone changes the variable whose * contents are to be displayed in an entry. * * Results: * NULL is always returned. * * Side effects: * The text displayed in the entry will change to match the variable. * *-------------------------------------------------------------- */ func _EntryTextVarProc(tls *libc.TLS, clientData uintptr, interp uintptr, dummy3280 uintptr, dummy3281 uintptr, flags int32) (r uintptr) { /* Information about what happened. */ var entryPtr, probe, value uintptr _, _, _ = entryPtr, probe, value entryPtr = clientData if (*TEntry)(unsafe.Pointer(entryPtr)).Fflags&int32(ENTRY_DELETED) != 0 { /* * Just abort early if we entered here while being deleted. */ return libc.UintptrFromInt32(0) } /* * If the variable is unset, then immediately recreate it unless the whole * interpreter is going away. */ if flags&int32(TCL_TRACE_UNSETS) != 0 { if !(libtcl9_0.XTcl_InterpDeleted(tls, interp) != 0) && (*TEntry)(unsafe.Pointer(entryPtr)).FtextVarNameObj != 0 { probe = libc.UintptrFromInt32(0) for cond := true; cond; cond = probe != 0 { probe = libtcl9_0.XTcl_VarTraceInfo2(tls, interp, libtcl9_0.XTcl_GetStringFromObj(tls, (*TEntry)(unsafe.Pointer(entryPtr)).FtextVarNameObj, libc.UintptrFromInt32(0)), libc.UintptrFromInt32(0), libc.Int32FromInt32(TCL_GLOBAL_ONLY)|libc.Int32FromInt32(TCL_TRACE_WRITES)|libc.Int32FromInt32(TCL_TRACE_UNSETS), __ccgo_fp(_EntryTextVarProc), probe) if probe == entryPtr { break } } if probe != 0 { /* * We were able to fetch the unset trace for our * textVarName, which means it is not unset and not * the cause of this unset trace. Instead some outdated * former variable must be, and we should ignore it. */ return libc.UintptrFromInt32(0) } libtcl9_0.XTcl_SetVar2(tls, interp, libtcl9_0.XTcl_GetStringFromObj(tls, (*TEntry)(unsafe.Pointer(entryPtr)).FtextVarNameObj, libc.UintptrFromInt32(0)), libc.UintptrFromInt32(0), (*TEntry)(unsafe.Pointer(entryPtr)).Fstring1, int32(TCL_GLOBAL_ONLY)) libtcl9_0.XTcl_TraceVar2(tls, interp, libtcl9_0.XTcl_GetStringFromObj(tls, (*TEntry)(unsafe.Pointer(entryPtr)).FtextVarNameObj, libc.UintptrFromInt32(0)), libc.UintptrFromInt32(0), libc.Int32FromInt32(TCL_GLOBAL_ONLY)|libc.Int32FromInt32(TCL_TRACE_WRITES)|libc.Int32FromInt32(TCL_TRACE_UNSETS), __ccgo_fp(_EntryTextVarProc), clientData) *(*int32)(unsafe.Pointer(entryPtr + 416)) |= int32(ENTRY_VAR_TRACED) } return libc.UintptrFromInt32(0) } /* * Update the entry's text with the value of the variable, unless the * entry already has that value (this happens when the variable changes * value because we changed it because someone typed in the entry). */ value = libtcl9_0.XTcl_GetVar2(tls, interp, libtcl9_0.XTcl_GetStringFromObj(tls, (*TEntry)(unsafe.Pointer(entryPtr)).FtextVarNameObj, libc.UintptrFromInt32(0)), libc.UintptrFromInt32(0), int32(TCL_GLOBAL_ONLY)) if value == libc.UintptrFromInt32(0) { value = __ccgo_ts + 195 } _EntrySetValue(tls, entryPtr, value) return libc.UintptrFromInt32(0) } /* *-------------------------------------------------------------- * * EntryValidate -- * * This function is invoked when any character is added or removed from * the entry widget, or a focus has trigerred validation. * * Results: * TCL_OK if the validatecommand passes the new string. TCL_BREAK if the * vcmd executed OK, but rejects the string. TCL_ERROR if an error * occurred while executing the vcmd or a valid Tcl_Bool is not returned. * * Side effects: * An error condition may arise * *-------------------------------------------------------------- */ func _EntryValidate(tls *libc.TLS, entryPtr uintptr, cmd uintptr) (r int32) { bp := tls.Alloc(32) defer tls.Free(32) /* Validation command (NULL-terminated * string). */ var code, v1 int32 var interp uintptr var _ /* isOK at bp+0 */ int32 _, _, _ = code, interp, v1 interp = (*TEntry)(unsafe.Pointer(entryPtr)).Finterp code = libtcl9_0.XTcl_EvalEx(tls, interp, cmd, int64(-libc.Int32FromInt32(1)), libc.Int32FromInt32(TCL_EVAL_GLOBAL)|libc.Int32FromInt32(TCL_EVAL_DIRECT)) /* * We accept TCL_OK and TCL_RETURN as valid return codes from the command * callback. */ if code != TCL_OK && code != int32(TCL_RETURN) { libtcl9_0.XTcl_AppendObjToErrorInfo(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+22652, libc.VaList(bp+16, (*TTk_FakeWin)(unsafe.Pointer((*TEntry)(unsafe.Pointer(entryPtr)).Ftkwin)).FpathName))) libtcl9_0.XTcl_BackgroundException(tls, interp, code) return int32(TCL_ERROR) } /* * The command callback should return an acceptable Tcl boolean. */ if libtcl9_0.XTcl_GetBoolFromObj(tls, interp, libtcl9_0.XTcl_GetObjResult(tls, interp), (libc.Int32FromInt32(TCL_NULL_OK)-libc.Int32FromInt32(2))&libc.Int32FromInt64(4), bp) != TCL_OK { libtcl9_0.XTcl_AppendObjToErrorInfo(tls, interp, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+22696, int64(-int32(1)))) libtcl9_0.XTcl_BackgroundException(tls, interp, int32(TCL_ERROR)) libtcl9_0.XTcl_ResetResult(tls, interp) return int32(TCL_ERROR) } libtcl9_0.XTcl_ResetResult(tls, interp) if *(*int32)(unsafe.Pointer(bp)) != 0 { v1 = TCL_OK } else { v1 = int32(TCL_BREAK) } return v1 } /* *-------------------------------------------------------------- * * EntryValidateChange -- * * This function is invoked when any character is added or removed from * the entry widget, or a focus has trigerred validation. * * Results: * TCL_OK if the validatecommand accepts the new string, TCL_ERROR if any * problems occurred with validatecommand. * * Side effects: * The insertion/deletion may be aborted, and the validatecommand might * turn itself off (if an error or loop condition arises). * *-------------------------------------------------------------- */ func _EntryValidateChange(tls *libc.TLS, entryPtr uintptr, change uintptr, newValue uintptr, index TTcl_Size, type1 int32) (r int32) { bp := tls.Alloc(224) defer tls.Free(224) /* forced, delete, insert, focusin or * focusout */ var code, result, varValidate, v1, v2 int32 var p, v3 uintptr var _ /* script at bp+0 */ TTcl_DString _, _, _, _, _, _, _ = code, p, result, varValidate, v1, v2, v3 varValidate = (*TEntry)(unsafe.Pointer(entryPtr)).Fflags & int32(VALIDATE_VAR) if (*TEntry)(unsafe.Pointer(entryPtr)).FvalidateCmdObj == libc.UintptrFromInt32(0) || (*TEntry)(unsafe.Pointer(entryPtr)).Fvalidate == int32(VALIDATE_NONE) { if (*TEntry)(unsafe.Pointer(entryPtr)).Fflags&int32(VALIDATING) != 0 { *(*int32)(unsafe.Pointer(entryPtr + 416)) |= int32(VALIDATE_ABORT) } if varValidate != 0 { v1 = int32(TCL_ERROR) } else { v1 = TCL_OK } return v1 } /* * If we're already validating, then we're hitting a loop condition. Set * validate to none to disallow further validations, arrange for flags * to prevent current validation from finishing, and return. */ if (*TEntry)(unsafe.Pointer(entryPtr)).Fflags&int32(VALIDATING) != 0 { (*TEntry)(unsafe.Pointer(entryPtr)).Fvalidate = int32(VALIDATE_NONE) *(*int32)(unsafe.Pointer(entryPtr + 416)) |= int32(VALIDATE_ABORT) if varValidate != 0 { v2 = int32(TCL_ERROR) } else { v2 = TCL_OK } return v2 } *(*int32)(unsafe.Pointer(entryPtr + 416)) |= int32(VALIDATING) /* * Now form command string and run through the -validatecommand */ libtcl9_0.XTcl_DStringInit(tls, bp) if (*TEntry)(unsafe.Pointer(entryPtr)).FvalidateCmdObj != 0 { v3 = libtcl9_0.XTcl_GetStringFromObj(tls, (*TEntry)(unsafe.Pointer(entryPtr)).FvalidateCmdObj, libc.UintptrFromInt32(0)) } else { v3 = libc.UintptrFromInt32(0) } _ExpandPercents1(tls, entryPtr, v3, change, newValue, index, type1, bp) libtcl9_0.XTcl_DStringAppend(tls, bp, __ccgo_ts+195, int64(1)) p = (*TTcl_DString)(unsafe.Pointer(bp)).Fstring1 code = _EntryValidate(tls, entryPtr, p) libtcl9_0.XTcl_DStringFree(tls, bp) /* * If e->validate has become VALIDATE_NONE during the validation, or we * now have VALIDATE_VAR set (from EntrySetValue) and didn't before, it * means that a loop condition almost occurred. Do not allow this * validation result to finish. */ if (*TEntry)(unsafe.Pointer(entryPtr)).Fvalidate == int32(VALIDATE_NONE) || !(varValidate != 0) && (*TEntry)(unsafe.Pointer(entryPtr)).Fflags&int32(VALIDATE_VAR) != 0 { code = int32(TCL_ERROR) } /* * It's possible that the user deleted the entry during validation. In * that case, abort future validation and return an error. */ if (*TEntry)(unsafe.Pointer(entryPtr)).Fflags&int32(ENTRY_DELETED) != 0 { return int32(TCL_ERROR) } /* * If validate will return ERROR, then disallow further validations * Otherwise, if it didn't accept the new string (returned TCL_BREAK) then * eval the invalidCmd (if it's set) */ if code == int32(TCL_ERROR) { (*TEntry)(unsafe.Pointer(entryPtr)).Fvalidate = int32(VALIDATE_NONE) } else { if code == int32(TCL_BREAK) { /* * If we were doing forced validation (like via a variable trace) and * the command returned 0, the we turn off validation because we * assume that textvariables have precedence in managing the value. * We also don't call the invcmd, as it may want to do entry * manipulation which the setting of the var will later wipe anyway. */ if varValidate != 0 { (*TEntry)(unsafe.Pointer(entryPtr)).Fvalidate = int32(VALIDATE_NONE) } else { if (*TEntry)(unsafe.Pointer(entryPtr)).FinvalidCmdObj != libc.UintptrFromInt32(0) { libtcl9_0.XTcl_DStringInit(tls, bp) _ExpandPercents1(tls, entryPtr, libtcl9_0.XTcl_GetStringFromObj(tls, (*TEntry)(unsafe.Pointer(entryPtr)).FinvalidCmdObj, libc.UintptrFromInt32(0)), change, newValue, index, type1, bp) libtcl9_0.XTcl_DStringAppend(tls, bp, __ccgo_ts+195, int64(1)) p = (*TTcl_DString)(unsafe.Pointer(bp)).Fstring1 result = libtcl9_0.XTcl_EvalEx(tls, (*TEntry)(unsafe.Pointer(entryPtr)).Finterp, p, int64(-libc.Int32FromInt32(1)), libc.Int32FromInt32(TCL_EVAL_GLOBAL)|libc.Int32FromInt32(TCL_EVAL_DIRECT)) if result != TCL_OK { libtcl9_0.XTcl_AppendObjToErrorInfo(tls, (*TEntry)(unsafe.Pointer(entryPtr)).Finterp, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+22750, int64(-int32(1)))) libtcl9_0.XTcl_BackgroundException(tls, (*TEntry)(unsafe.Pointer(entryPtr)).Finterp, result) code = int32(TCL_ERROR) (*TEntry)(unsafe.Pointer(entryPtr)).Fvalidate = int32(VALIDATE_NONE) } libtcl9_0.XTcl_DStringFree(tls, bp) /* * It's possible that the user deleted the entry during * validation. In that case, abort future validation and return an * error. */ if (*TEntry)(unsafe.Pointer(entryPtr)).Fflags&int32(ENTRY_DELETED) != 0 { return int32(TCL_ERROR) } } } } } *(*int32)(unsafe.Pointer(entryPtr + 416)) &= ^libc.Int32FromInt32(VALIDATING) return code } /* *-------------------------------------------------------------- * * ExpandPercents -- * * Given a command and an event, produce a new command by replacing % * constructs in the original command with information from the X event. * * Results: * The new expanded command is appended to the dynamic string given by * dsPtr. * * Side effects: * None. * *-------------------------------------------------------------- */ func _ExpandPercents1(tls *libc.TLS, entryPtr uintptr, before uintptr, change uintptr, newValue uintptr, index TTcl_Size, type1 int32, dsPtr uintptr) { bp := tls.Alloc(80) defer tls.Free(80) /* Dynamic string in which to append new * command. */ var length, number, spaceNeeded int32 var string1 uintptr var _ /* ch at bp+4 */ int32 var _ /* cvtFlags at bp+0 */ int32 var _ /* numStorage at bp+8 */ [48]uint8 _, _, _, _ = length, number, spaceNeeded, string1 for int32(1) != 0 { if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(before))) == int32('\000') { break } /* * Find everything up to the next % character and append it to the * result string. */ string1 = before /* * No need to convert '%', as it is in ascii range. */ string1 = libtcl9_0.XTcl_UtfFindFirst(tls, before, int32('%')) if string1 == libc.UintptrFromInt32(0) { libtcl9_0.XTcl_DStringAppend(tls, dsPtr, before, int64(-libc.Int32FromInt32(1))) break } else { if string1 != before { libtcl9_0.XTcl_DStringAppend(tls, dsPtr, before, int64(string1)-int64(before)) before = string1 } } /* * There's a percent sequence here. Process it. */ before++ /* skip over % */ if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(before))) != int32('\000') { before += uintptr(libtcl9_0.XTcl_UtfToUniChar(tls, before, bp+4)) } else { *(*int32)(unsafe.Pointer(bp + 4)) = int32('%') } if type1 == int32(VALIDATE_BUTTON) { /* * -command %-substitution */ switch *(*int32)(unsafe.Pointer(bp + 4)) { case int32('s'): /* Current string value of spinbox */ string1 = (*TEntry)(unsafe.Pointer(entryPtr)).Fstring1 case int32('d'): /* direction, up or down */ string1 = change case int32('W'): /* widget name */ string1 = (*TTk_FakeWin)(unsafe.Pointer((*TEntry)(unsafe.Pointer(entryPtr)).Ftkwin)).FpathName default: length = int32(libtcl9_0.XTcl_UniCharToUtf(tls, *(*int32)(unsafe.Pointer(bp + 4)), bp+8)) (*(*[48]uint8)(unsafe.Pointer(bp + 8)))[length] = uint8('\000') string1 = bp + 8 break } } else { /* * -validatecommand / -invalidcommand %-substitution */ switch *(*int32)(unsafe.Pointer(bp + 4)) { case int32('d'): /* Type of call that caused validation */ switch type1 { case int32(VALIDATE_INSERT): number = int32(1) case int32(VALIDATE_DELETE): number = 0 default: number = -int32(1) break } libc.X__builtin_snprintf(tls, bp+8, uint64(48), __ccgo_ts+14540, libc.VaList(bp+64, number)) string1 = bp + 8 case int32('i'): /* index of insert/delete */ libc.X__builtin_snprintf(tls, bp+8, uint64(48), __ccgo_ts+14540, libc.VaList(bp+64, int32(index))) string1 = bp + 8 case int32('P'): /* 'Peeked' new value of the string */ string1 = newValue case int32('s'): /* Current string value of spinbox */ string1 = (*TEntry)(unsafe.Pointer(entryPtr)).Fstring1 case int32('S'): /* string to be inserted/deleted, if any */ string1 = change case int32('v'): /* type of validation currently set */ string1 = _validateStrings[(*TEntry)(unsafe.Pointer(entryPtr)).Fvalidate] case int32('V'): /* type of validation in effect */ switch type1 { case int32(VALIDATE_INSERT): fallthrough case int32(VALIDATE_DELETE): string1 = _validateStrings[int32(VALIDATE_KEY)] case int32(VALIDATE_FORCED): string1 = __ccgo_ts + 22793 default: string1 = _validateStrings[type1] break } case int32('W'): /* widget name */ string1 = (*TTk_FakeWin)(unsafe.Pointer((*TEntry)(unsafe.Pointer(entryPtr)).Ftkwin)).FpathName default: length = int32(libtcl9_0.XTcl_UniCharToUtf(tls, *(*int32)(unsafe.Pointer(bp + 4)), bp+8)) (*(*[48]uint8)(unsafe.Pointer(bp + 8)))[length] = uint8('\000') string1 = bp + 8 break } } spaceNeeded = int32(libtcl9_0.XTcl_ScanCountedElement(tls, string1, int64(-libc.Int32FromInt32(1)), bp)) length = int32((*TTcl_DString)(unsafe.Pointer(dsPtr)).Flength) libtcl9_0.XTcl_DStringSetLength(tls, dsPtr, int64(length+spaceNeeded)) spaceNeeded = int32(libtcl9_0.XTcl_ConvertCountedElement(tls, string1, int64(-libc.Int32FromInt32(1)), (*TTcl_DString)(unsafe.Pointer(dsPtr)).Fstring1+uintptr(length), *(*int32)(unsafe.Pointer(bp))|int32(TCL_DONT_USE_BRACES))) libtcl9_0.XTcl_DStringSetLength(tls, dsPtr, int64(length+spaceNeeded)) } } /* *-------------------------------------------------------------- * * Tk_SpinboxObjCmd -- * * This function is invoked to process the "spinbox" Tcl command. See the * user documentation for details on what it does. * * Results: * A standard Tcl result. * * Side effects: * See the user documentation. * *-------------------------------------------------------------- */ func XTk_SpinboxObjCmd(tls *libc.TLS, dummy3735 uintptr, interp uintptr, objc int32, objv uintptr) (r int32) { /* Argument objects. */ var entryPtr, sbPtr, tmp uintptr var optionTable TTk_OptionTable var tkwin TTk_Window _, _, _, _, _ = entryPtr, optionTable, sbPtr, tkwin, tmp if objc < int32(2) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(1), objv, __ccgo_ts+20960) return int32(TCL_ERROR) } tkwin = XTk_CreateWindowFromPath(tls, interp, XTk_MainWindow(tls, interp), libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8)), libc.UintptrFromInt32(0)), libc.UintptrFromInt32(0)) if tkwin == libc.UintptrFromInt32(0) { return int32(TCL_ERROR) } /* * Create the option table for this widget class. If it has already been * created, Tk will return the cached value. */ optionTable = XTk_CreateOptionTable(tls, interp, uintptr(unsafe.Pointer(&_sbOptSpec))) /* * Initialize the fields of the structure that won't be initialized by * ConfigureEntry, or that ConfigureEntry requires to be initialized * already (e.g. resource pointers). Only the non-NULL/0 data must be * initialized as memset covers the rest. */ sbPtr = libtcl9_0.XTcl_Alloc(tls, uint64(640)) entryPtr = sbPtr libc.Xmemset(tls, sbPtr, 0, uint64(640)) (*TEntry)(unsafe.Pointer(entryPtr)).Ftkwin = tkwin (*TEntry)(unsafe.Pointer(entryPtr)).Fdisplay = (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fdisplay (*TEntry)(unsafe.Pointer(entryPtr)).Finterp = interp (*TEntry)(unsafe.Pointer(entryPtr)).FwidgetCmd = libtcl9_0.XTcl_CreateObjCommand(tls, interp, (*TTk_FakeWin)(unsafe.Pointer((*TEntry)(unsafe.Pointer(entryPtr)).Ftkwin)).FpathName, __ccgo_fp(_SpinboxWidgetObjCmd), sbPtr, __ccgo_fp(_EntryCmdDeletedProc)) (*TEntry)(unsafe.Pointer(entryPtr)).FoptionTable = optionTable (*TEntry)(unsafe.Pointer(entryPtr)).Ftype1 = int32(TK_SPINBOX) tmp = libtcl9_0.XTcl_Alloc(tls, uint64(1)) *(*uint8)(unsafe.Pointer(tmp)) = uint8('\000') (*TEntry)(unsafe.Pointer(entryPtr)).Fstring1 = tmp (*TEntry)(unsafe.Pointer(entryPtr)).FselectFirst = int64(-libc.Int32FromInt32(1)) (*TEntry)(unsafe.Pointer(entryPtr)).FselectLast = int64(-libc.Int32FromInt32(1)) (*TEntry)(unsafe.Pointer(entryPtr)).Fcursor = libc.UintptrFromInt32(0) (*TEntry)(unsafe.Pointer(entryPtr)).FexportSelection = int32(1) (*TEntry)(unsafe.Pointer(entryPtr)).Fjustify = int32(TK_JUSTIFY_LEFT) (*TEntry)(unsafe.Pointer(entryPtr)).Frelief = TK_RELIEF_FLAT (*TEntry)(unsafe.Pointer(entryPtr)).Fstate = int32(STATE_NORMAL1) (*TEntry)(unsafe.Pointer(entryPtr)).FdisplayString = (*TEntry)(unsafe.Pointer(entryPtr)).Fstring1 (*TEntry)(unsafe.Pointer(entryPtr)).Finset = int32(XPAD) (*TEntry)(unsafe.Pointer(entryPtr)).FtextGC = libc.UintptrFromInt32(0) (*TEntry)(unsafe.Pointer(entryPtr)).FselTextGC = libc.UintptrFromInt32(0) (*TEntry)(unsafe.Pointer(entryPtr)).FhighlightGC = libc.UintptrFromInt32(0) (*TEntry)(unsafe.Pointer(entryPtr)).FavgWidth = int32(1) (*TEntry)(unsafe.Pointer(entryPtr)).Fvalidate = int32(VALIDATE_NONE) (*TSpinbox)(unsafe.Pointer(sbPtr)).FselElement = int32(SEL_NONE) (*TSpinbox)(unsafe.Pointer(sbPtr)).FcurElement = int32(SEL_NONE) (*TSpinbox)(unsafe.Pointer(sbPtr)).FbCursor = libc.UintptrFromInt32(0) (*TSpinbox)(unsafe.Pointer(sbPtr)).FrepeatDelay = int32(400) (*TSpinbox)(unsafe.Pointer(sbPtr)).FrepeatInterval = int32(100) (*TSpinbox)(unsafe.Pointer(sbPtr)).FfromValue = float64(0) (*TSpinbox)(unsafe.Pointer(sbPtr)).FtoValue = float64(100) (*TSpinbox)(unsafe.Pointer(sbPtr)).Fincrement = float64(1) (*TSpinbox)(unsafe.Pointer(sbPtr)).FformatBuf = libtcl9_0.XTcl_Alloc(tls, libc.Uint64FromInt32(libc.Int32FromInt32(TCL_MAX_PREC)+libc.Int32FromInt32(10))) (*TSpinbox)(unsafe.Pointer(sbPtr)).FbdRelief = TK_RELIEF_FLAT (*TSpinbox)(unsafe.Pointer(sbPtr)).FbuRelief = TK_RELIEF_FLAT (*TEntry)(unsafe.Pointer(entryPtr)).FplaceholderGC = libc.UintptrFromInt32(0) /* * Keep a hold of the associated tkwin until we destroy the spinbox, * otherwise Tk might free it while we still need it. */ libtcl9_0.XTcl_Preserve(tls, (*TEntry)(unsafe.Pointer(entryPtr)).Ftkwin) XTk_SetClass(tls, (*TEntry)(unsafe.Pointer(entryPtr)).Ftkwin, __ccgo_ts+22800) XTk_SetClassProcs(tls, (*TEntry)(unsafe.Pointer(entryPtr)).Ftkwin, uintptr(unsafe.Pointer(&_entryClass)), entryPtr) XTk_CreateEventHandler(tls, (*TEntry)(unsafe.Pointer(entryPtr)).Ftkwin, libc.Uint64FromInt64(libc.Int64FromInt64(1)< 0 { *(*TTcl_Size)(unsafe.Pointer(bp + 8))-- } XTk_CharBbox(tls, (*TEntry)(unsafe.Pointer(entryPtr)).FtextLayout, *(*TTcl_Size)(unsafe.Pointer(bp + 8)), bp+16, bp+20, bp+24, bp+28) (*(*[4]uintptr)(unsafe.Pointer(bp + 32)))[0] = libtcl9_0.XTcl_NewWideIntObj(tls, int64(*(*int32)(unsafe.Pointer(bp + 16))+(*TEntry)(unsafe.Pointer(entryPtr)).FlayoutX)) (*(*[4]uintptr)(unsafe.Pointer(bp + 32)))[int32(1)] = libtcl9_0.XTcl_NewWideIntObj(tls, int64(*(*int32)(unsafe.Pointer(bp + 20))+(*TEntry)(unsafe.Pointer(entryPtr)).FlayoutY)) (*(*[4]uintptr)(unsafe.Pointer(bp + 32)))[int32(2)] = libtcl9_0.XTcl_NewWideIntObj(tls, int64(*(*int32)(unsafe.Pointer(bp + 24)))) (*(*[4]uintptr)(unsafe.Pointer(bp + 32)))[int32(3)] = libtcl9_0.XTcl_NewWideIntObj(tls, int64(*(*int32)(unsafe.Pointer(bp + 28)))) libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewListObj(tls, int64(4), bp+32)) case int32(SB_CMD_CGET): if objc != int32(3) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(2), objv, __ccgo_ts+2689) goto error } objPtr = XTk_GetOptionValue(tls, interp, entryPtr, (*TEntry)(unsafe.Pointer(entryPtr)).FoptionTable, *(*uintptr)(unsafe.Pointer(objv + 2*8)), (*TEntry)(unsafe.Pointer(entryPtr)).Ftkwin) if objPtr == libc.UintptrFromInt32(0) { goto error } libtcl9_0.XTcl_SetObjResult(tls, interp, objPtr) case int32(SB_CMD_CONFIGURE): if objc <= int32(3) { if objc == int32(3) { v1 = *(*uintptr)(unsafe.Pointer(objv + 2*8)) } else { v1 = libc.UintptrFromInt32(0) } objPtr = XTk_GetOptionInfo(tls, interp, entryPtr, (*TEntry)(unsafe.Pointer(entryPtr)).FoptionTable, v1, (*TEntry)(unsafe.Pointer(entryPtr)).Ftkwin) if objPtr == libc.UintptrFromInt32(0) { goto error } libtcl9_0.XTcl_SetObjResult(tls, interp, objPtr) } else { result = _ConfigureEntry(tls, interp, entryPtr, int64(objc-int32(2)), objv+uintptr(2)*8) } case int32(SB_CMD_DELETE): if objc < int32(3) || objc > int32(4) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(2), objv, __ccgo_ts+22240) goto error } if _GetEntryIndex(tls, interp, entryPtr, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+64) != TCL_OK { goto error } if objc == int32(3) { *(*TTcl_Size)(unsafe.Pointer(bp + 72)) = *(*TTcl_Size)(unsafe.Pointer(bp + 64)) + int64(1) } else { if _GetEntryIndex(tls, interp, entryPtr, *(*uintptr)(unsafe.Pointer(objv + 3*8)), bp+72) != TCL_OK { goto error } } if *(*TTcl_Size)(unsafe.Pointer(bp + 72)) >= *(*TTcl_Size)(unsafe.Pointer(bp + 64)) && (*TEntry)(unsafe.Pointer(entryPtr)).Fstate == int32(STATE_NORMAL1) { code = _DeleteChars(tls, entryPtr, *(*TTcl_Size)(unsafe.Pointer(bp + 64)), *(*TTcl_Size)(unsafe.Pointer(bp + 72))-*(*TTcl_Size)(unsafe.Pointer(bp + 64))) if code != TCL_OK { goto error } } case int32(SB_CMD_GET): if objc != int32(2) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(2), objv, libc.UintptrFromInt32(0)) goto error } libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewStringObj(tls, (*TEntry)(unsafe.Pointer(entryPtr)).Fstring1, int64(-libc.Int32FromInt32(1)))) case int32(SB_CMD_ICURSOR): if objc != int32(3) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(2), objv, __ccgo_ts+22263) goto error } if _GetEntryIndex(tls, interp, entryPtr, *(*uintptr)(unsafe.Pointer(objv + 2*8)), entryPtr+56) != TCL_OK { goto error } _EventuallyRedraw(tls, entryPtr) case int32(SB_CMD_IDENTIFY): if objc != int32(4) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(2), objv, __ccgo_ts+22808) goto error } if libtcl9_0.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+80) != TCL_OK || libtcl9_0.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 3*8)), bp+84) != TCL_OK { goto error } elem = _GetSpinboxElement(tls, sbPtr, *(*int32)(unsafe.Pointer(bp + 80)), *(*int32)(unsafe.Pointer(bp + 84))) if elem != int32(SEL_NONE) { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewStringObj(tls, _selElementNames[elem], int64(-libc.Int32FromInt32(1)))) } case int32(SB_CMD_INDEX): if objc != int32(3) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(2), objv, __ccgo_ts+22267) goto error } if _GetEntryIndex(tls, interp, entryPtr, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+88) != TCL_OK { goto error } if *(*TTcl_Size)(unsafe.Pointer(bp + 88)) == int64(-libc.Int32FromInt32(1)) { v2 = libtcl9_0.XTcl_NewObj(tls) } else { v2 = libtcl9_0.XTcl_NewWideIntObj(tls, *(*TTcl_Size)(unsafe.Pointer(bp + 88))) } libtcl9_0.XTcl_SetObjResult(tls, interp, v2) case int32(SB_CMD_INSERT): if objc != int32(4) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(2), objv, __ccgo_ts+22274) goto error } if _GetEntryIndex(tls, interp, entryPtr, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+96) != TCL_OK { goto error } if (*TEntry)(unsafe.Pointer(entryPtr)).Fstate == int32(STATE_NORMAL1) { code1 = _InsertChars(tls, entryPtr, *(*TTcl_Size)(unsafe.Pointer(bp + 96)), *(*uintptr)(unsafe.Pointer(objv + 3*8))) if code1 != TCL_OK { goto error } } case int32(SB_CMD_INVOKE): if objc != int32(3) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(2), objv, __ccgo_ts+22812) goto error } result = libtcl9_0.XTcl_GetIndexFromObjStruct(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), uintptr(unsafe.Pointer(&_selElementNames)), libc.Int64FromUint64(libc.Uint64FromInt64(8)), __ccgo_ts+22206, libc.Int32FromInt32(0)|libc.Int32FromUint64(libc.Uint64FromInt64(4)< half2 { (*TEntry)(unsafe.Pointer(entryPtr)).FselectAnchor = (*TEntry)(unsafe.Pointer(entryPtr)).FselectFirst } else { /* * We're at about the halfway point in the selection; just * keep the existing anchor. */ } } } _EntrySelectTo(tls, entryPtr, *(*TTcl_Size)(unsafe.Pointer(bp + 112))) case int32(SB_SEL_CLEAR): if objc != int32(3) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(3), objv, libc.UintptrFromInt32(0)) goto error } if (*TEntry)(unsafe.Pointer(entryPtr)).FselectFirst != int64(-libc.Int32FromInt32(1)) { (*TEntry)(unsafe.Pointer(entryPtr)).FselectFirst = int64(-libc.Int32FromInt32(1)) (*TEntry)(unsafe.Pointer(entryPtr)).FselectLast = int64(-libc.Int32FromInt32(1)) _EventuallyRedraw(tls, entryPtr) } goto done case int32(SB_SEL_FROM): if objc != int32(4) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(3), objv, __ccgo_ts+22152) goto error } if _GetEntryIndex(tls, interp, entryPtr, *(*uintptr)(unsafe.Pointer(objv + 3*8)), bp+112) != TCL_OK { goto error } (*TEntry)(unsafe.Pointer(entryPtr)).FselectAnchor = *(*TTcl_Size)(unsafe.Pointer(bp + 112)) case int32(SB_SEL_PRESENT): if objc != int32(3) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(3), objv, libc.UintptrFromInt32(0)) goto error } libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewWideIntObj(tls, libc.BoolInt64(libc.BoolInt32((*TEntry)(unsafe.Pointer(entryPtr)).FselectFirst != int64(-libc.Int32FromInt32(1))) != 0))) goto done case int32(SB_SEL_RANGE): if objc != int32(5) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(3), objv, __ccgo_ts+22395) goto error } if _GetEntryIndex(tls, interp, entryPtr, *(*uintptr)(unsafe.Pointer(objv + 3*8)), bp+112) != TCL_OK { goto error } if _GetEntryIndex(tls, interp, entryPtr, *(*uintptr)(unsafe.Pointer(objv + 4*8)), bp+120) != TCL_OK { goto error } if *(*TTcl_Size)(unsafe.Pointer(bp + 112)) >= *(*TTcl_Size)(unsafe.Pointer(bp + 120)) { (*TEntry)(unsafe.Pointer(entryPtr)).FselectFirst = int64(-libc.Int32FromInt32(1)) (*TEntry)(unsafe.Pointer(entryPtr)).FselectLast = int64(-libc.Int32FromInt32(1)) } else { (*TEntry)(unsafe.Pointer(entryPtr)).FselectFirst = *(*TTcl_Size)(unsafe.Pointer(bp + 112)) (*TEntry)(unsafe.Pointer(entryPtr)).FselectLast = *(*TTcl_Size)(unsafe.Pointer(bp + 120)) } if !((*TEntry)(unsafe.Pointer(entryPtr)).Fflags&libc.Int32FromInt32(GOT_SELECTION) != 0) && (*TEntry)(unsafe.Pointer(entryPtr)).FexportSelection != 0 && !(libtcl9_0.XTcl_IsSafe(tls, (*TEntry)(unsafe.Pointer(entryPtr)).Finterp) != 0) { XTk_OwnSelection(tls, (*TEntry)(unsafe.Pointer(entryPtr)).Ftkwin, libc.Uint64FromInt32(1), __ccgo_fp(_EntryLostSelection), entryPtr) *(*int32)(unsafe.Pointer(entryPtr + 416)) |= int32(GOT_SELECTION) } _EventuallyRedraw(tls, entryPtr) case int32(SB_SEL_TO): if objc != int32(4) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(3), objv, __ccgo_ts+22152) goto error } if _GetEntryIndex(tls, interp, entryPtr, *(*uintptr)(unsafe.Pointer(objv + 3*8)), bp+112) != TCL_OK { goto error } _EntrySelectTo(tls, entryPtr, *(*TTcl_Size)(unsafe.Pointer(bp + 112))) case int32(SB_SEL_ELEMENT): if objc < int32(3) || objc > int32(4) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(3), objv, __ccgo_ts+22821) goto error } if objc == int32(3) { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewStringObj(tls, _selElementNames[(*TSpinbox)(unsafe.Pointer(sbPtr)).FselElement], int64(-libc.Int32FromInt32(1)))) } else { lastElement = (*TSpinbox)(unsafe.Pointer(sbPtr)).FselElement result = libtcl9_0.XTcl_GetIndexFromObjStruct(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 3*8)), uintptr(unsafe.Pointer(&_selElementNames)), libc.Int64FromUint64(libc.Uint64FromInt64(8)), __ccgo_ts+22832, libc.Int32FromInt32(0)|libc.Int32FromUint64(libc.Uint64FromInt64(4)< int32(3) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(2), objv, __ccgo_ts+22850) goto error } if objc == int32(3) { code2 = _EntryValueChanged(tls, entryPtr, libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8)), libc.UintptrFromInt32(0))) if code2 != TCL_OK { goto error } } libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewStringObj(tls, (*TEntry)(unsafe.Pointer(entryPtr)).Fstring1, int64(-libc.Int32FromInt32(1)))) case int32(SB_CMD_VALIDATE): if objc != int32(2) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(2), objv, libc.UintptrFromInt32(0)) goto error } *(*int32)(unsafe.Pointer(bp + 4)) = (*TEntry)(unsafe.Pointer(entryPtr)).Fvalidate (*TEntry)(unsafe.Pointer(entryPtr)).Fvalidate = int32(VALIDATE_ALL) code3 = _EntryValidateChange(tls, entryPtr, libc.UintptrFromInt32(0), (*TEntry)(unsafe.Pointer(entryPtr)).Fstring1, int64(-libc.Int32FromInt32(1)), int32(VALIDATE_FORCED)) if (*TEntry)(unsafe.Pointer(entryPtr)).Fvalidate != int32(VALIDATE_NONE) { (*TEntry)(unsafe.Pointer(entryPtr)).Fvalidate = *(*int32)(unsafe.Pointer(bp + 4)) } libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewWideIntObj(tls, libc.BoolInt64(libc.BoolInt32(code3 == TCL_OK) != 0))) case int32(SB_CMD_XVIEW): if objc == int32(2) { _EntryVisibleRange(tls, entryPtr, bp+136, bp+144) (*(*[2]uintptr)(unsafe.Pointer(bp + 152)))[0] = libtcl9_0.XTcl_NewDoubleObj(tls, *(*float64)(unsafe.Pointer(bp + 136))) (*(*[2]uintptr)(unsafe.Pointer(bp + 152)))[int32(1)] = libtcl9_0.XTcl_NewDoubleObj(tls, *(*float64)(unsafe.Pointer(bp + 144))) libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewListObj(tls, int64(2), bp+152)) goto done } else { if objc == int32(3) { if _GetEntryIndex(tls, interp, entryPtr, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+128) != TCL_OK { goto error } } else { *(*TTcl_Size)(unsafe.Pointer(bp + 128)) = (*TEntry)(unsafe.Pointer(entryPtr)).FleftIndex switch XTk_GetScrollInfoObj(tls, interp, int64(objc), objv, bp+168, bp+176) { case int32(TK_SCROLL_MOVETO): *(*TTcl_Size)(unsafe.Pointer(bp + 128)) = int64(float64(*(*float64)(unsafe.Pointer(bp + 168))*float64((*TEntry)(unsafe.Pointer(entryPtr)).FnumChars)) + libc.Float64FromFloat64(0.5)) case int32(TK_SCROLL_PAGES): charsPerPage = ((*TTk_FakeWin)(unsafe.Pointer((*TEntry)(unsafe.Pointer(entryPtr)).Ftkwin)).Fchanges.Fwidth-int32(2)*(*TEntry)(unsafe.Pointer(entryPtr)).Finset-(*TEntry)(unsafe.Pointer(entryPtr)).FxWidth)/(*TEntry)(unsafe.Pointer(entryPtr)).FavgWidth - int32(2) if charsPerPage < int32(1) { charsPerPage = int32(1) } *(*TTcl_Size)(unsafe.Pointer(bp + 128)) += int64(*(*int32)(unsafe.Pointer(bp + 176)) * charsPerPage) case int32(TK_SCROLL_UNITS): *(*TTcl_Size)(unsafe.Pointer(bp + 128)) += int64(*(*int32)(unsafe.Pointer(bp + 176))) default: goto error } } } if *(*TTcl_Size)(unsafe.Pointer(bp + 128)) >= (*TEntry)(unsafe.Pointer(entryPtr)).FnumChars { *(*TTcl_Size)(unsafe.Pointer(bp + 128)) = (*TEntry)(unsafe.Pointer(entryPtr)).FnumChars - int64(1) } if *(*TTcl_Size)(unsafe.Pointer(bp + 128)) < 0 { *(*TTcl_Size)(unsafe.Pointer(bp + 128)) = 0 } (*TEntry)(unsafe.Pointer(entryPtr)).FleftIndex = *(*TTcl_Size)(unsafe.Pointer(bp + 128)) *(*int32)(unsafe.Pointer(entryPtr + 416)) |= int32(UPDATE_SCROLLBAR) _EntryComputeGeometry(tls, entryPtr) _EventuallyRedraw(tls, entryPtr) break } goto done done: ; libtcl9_0.XTcl_Release(tls, entryPtr) return result goto error error: ; libtcl9_0.XTcl_Release(tls, entryPtr) return int32(TCL_ERROR) } /* *--------------------------------------------------------------------------- * * GetSpinboxElement -- * * Return the element associated with an x,y coord. * * Results: * Element type as enum selelement. * * Side effects: * None. * *--------------------------------------------------------------------------- */ func _GetSpinboxElement(tls *libc.TLS, sbPtr uintptr, x int32, y int32) (r int32) { /* Widget-relative coordinates. */ var entryPtr uintptr _ = entryPtr entryPtr = sbPtr if x < 0 || y < 0 || y > (*TTk_FakeWin)(unsafe.Pointer((*TEntry)(unsafe.Pointer(entryPtr)).Ftkwin)).Fchanges.Fheight || x > (*TTk_FakeWin)(unsafe.Pointer((*TEntry)(unsafe.Pointer(entryPtr)).Ftkwin)).Fchanges.Fwidth { return int32(SEL_NONE) } if x > (*TTk_FakeWin)(unsafe.Pointer((*TEntry)(unsafe.Pointer(entryPtr)).Ftkwin)).Fchanges.Fwidth-(*TEntry)(unsafe.Pointer(entryPtr)).Finset-(*TEntry)(unsafe.Pointer(entryPtr)).FxWidth { if y > (*TTk_FakeWin)(unsafe.Pointer((*TEntry)(unsafe.Pointer(entryPtr)).Ftkwin)).Fchanges.Fheight/int32(2) { return int32(SEL_BUTTONDOWN) } else { return int32(SEL_BUTTONUP) } } return int32(SEL_ENTRY) } /* *-------------------------------------------------------------- * * SpinboxInvoke -- * * This function is invoked when the invoke method for the widget is * called. * * Results: * TCL_OK. * * Side effects: * A background error condition may arise when invoking the callback. * The widget value may change. * *-------------------------------------------------------------- */ func _SpinboxInvoke(tls *libc.TLS, interp uintptr, sbPtr uintptr, element int32) (r int32) { bp := tls.Alloc(288) defer tls.Free(288) /* Element to invoke, either the "up" or * "down" button. */ var bytes, entryPtr, type1, v3, v5 uintptr var code, up, v2, v4 int32 var i, length TTcl_Size var _ /* dvalue at bp+256 */ float64 var _ /* elemLen at bp+240 */ TTcl_Size var _ /* listc at bp+232 */ TTcl_Size var _ /* listv at bp+248 */ uintptr var _ /* objPtr at bp+224 */ uintptr var _ /* script at bp+0 */ TTcl_DString _, _, _, _, _, _, _, _, _, _, _ = bytes, code, entryPtr, i, length, type1, up, v2, v3, v4, v5 entryPtr = sbPtr switch element { case int32(SEL_BUTTONUP): type1 = __ccgo_ts + 22859 up = int32(1) case int32(SEL_BUTTONDOWN): type1 = __ccgo_ts + 22862 up = 0 default: return TCL_OK } code = TCL_OK if libc.Xfabs(tls, (*TSpinbox)(unsafe.Pointer(sbPtr)).Fincrement) > float64(1e-09) { if (*TSpinbox)(unsafe.Pointer(sbPtr)).FlistObj != libc.UintptrFromInt32(0) { libtcl9_0.XTcl_ListObjIndex(tls, interp, (*TSpinbox)(unsafe.Pointer(sbPtr)).FlistObj, int64((*TSpinbox)(unsafe.Pointer(sbPtr)).FeIndex), bp+224) if libc.Xstrcmp(tls, libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(bp + 224)), libc.UintptrFromInt32(0)), (*TEntry)(unsafe.Pointer(entryPtr)).Fstring1) != 0 { length = (*TEntry)(unsafe.Pointer(entryPtr)).FnumChars libtcl9_0.XTcl_ListObjGetElements(tls, interp, (*TSpinbox)(unsafe.Pointer(sbPtr)).FlistObj, bp+232, bp+248) i = 0 for { if !(i < *(*TTcl_Size)(unsafe.Pointer(bp + 232))) { break } bytes = libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 248)) + uintptr(i)*8)), bp+240) if length == *(*TTcl_Size)(unsafe.Pointer(bp + 240)) && libc.Xmemcmp(tls, bytes, (*TEntry)(unsafe.Pointer(entryPtr)).Fstring1, libc.Uint64FromInt64(length)) == 0 { (*TSpinbox)(unsafe.Pointer(sbPtr)).FeIndex = int32(i) break } goto _1 _1: ; i++ } } if up != 0 { v3 = sbPtr + 632 *(*int32)(unsafe.Pointer(v3))++ v2 = *(*int32)(unsafe.Pointer(v3)) if v2 >= (*TSpinbox)(unsafe.Pointer(sbPtr)).FnElements { if (*TSpinbox)(unsafe.Pointer(sbPtr)).Fwrap != 0 { (*TSpinbox)(unsafe.Pointer(sbPtr)).FeIndex = 0 } else { (*TSpinbox)(unsafe.Pointer(sbPtr)).FeIndex = (*TSpinbox)(unsafe.Pointer(sbPtr)).FnElements - int32(1) } } } else { v5 = sbPtr + 632 *(*int32)(unsafe.Pointer(v5))-- v4 = *(*int32)(unsafe.Pointer(v5)) if v4 < 0 { if (*TSpinbox)(unsafe.Pointer(sbPtr)).Fwrap != 0 { (*TSpinbox)(unsafe.Pointer(sbPtr)).FeIndex = (*TSpinbox)(unsafe.Pointer(sbPtr)).FnElements - int32(1) } else { (*TSpinbox)(unsafe.Pointer(sbPtr)).FeIndex = 0 } } } libtcl9_0.XTcl_ListObjIndex(tls, interp, (*TSpinbox)(unsafe.Pointer(sbPtr)).FlistObj, int64((*TSpinbox)(unsafe.Pointer(sbPtr)).FeIndex), bp+224) code = _EntryValueChanged(tls, entryPtr, libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(bp + 224)), libc.UintptrFromInt32(0))) } else { if !(libc.Xfabs(tls, (*TSpinbox)(unsafe.Pointer(sbPtr)).FfromValue-(*TSpinbox)(unsafe.Pointer(sbPtr)).FtoValue) < libc.Float64FromFloat64(1e-09)) { if libc.Xsscanf(tls, (*TEntry)(unsafe.Pointer(entryPtr)).Fstring1, __ccgo_ts+22502, libc.VaList(bp+272, bp+256)) <= 0 { /* * If the string doesn't scan as a double value, just * use the -from value */ *(*float64)(unsafe.Pointer(bp + 256)) = (*TSpinbox)(unsafe.Pointer(sbPtr)).FfromValue } else { if up != 0 { *(*float64)(unsafe.Pointer(bp + 256)) += (*TSpinbox)(unsafe.Pointer(sbPtr)).Fincrement if *(*float64)(unsafe.Pointer(bp + 256)) > (*TSpinbox)(unsafe.Pointer(sbPtr)).FtoValue { if (*TSpinbox)(unsafe.Pointer(sbPtr)).Fwrap != 0 { *(*float64)(unsafe.Pointer(bp + 256)) = (*TSpinbox)(unsafe.Pointer(sbPtr)).FfromValue } else { *(*float64)(unsafe.Pointer(bp + 256)) = (*TSpinbox)(unsafe.Pointer(sbPtr)).FtoValue } } else { if *(*float64)(unsafe.Pointer(bp + 256)) < (*TSpinbox)(unsafe.Pointer(sbPtr)).FfromValue { /* * It's possible that when pressing up, we are still less * than the fromValue, because the user may have * manipulated the value by hand. */ *(*float64)(unsafe.Pointer(bp + 256)) = (*TSpinbox)(unsafe.Pointer(sbPtr)).FfromValue } } } else { *(*float64)(unsafe.Pointer(bp + 256)) -= (*TSpinbox)(unsafe.Pointer(sbPtr)).Fincrement if *(*float64)(unsafe.Pointer(bp + 256)) < (*TSpinbox)(unsafe.Pointer(sbPtr)).FfromValue { if (*TSpinbox)(unsafe.Pointer(sbPtr)).Fwrap != 0 { *(*float64)(unsafe.Pointer(bp + 256)) = (*TSpinbox)(unsafe.Pointer(sbPtr)).FtoValue } else { *(*float64)(unsafe.Pointer(bp + 256)) = (*TSpinbox)(unsafe.Pointer(sbPtr)).FfromValue } } else { if *(*float64)(unsafe.Pointer(bp + 256)) > (*TSpinbox)(unsafe.Pointer(sbPtr)).FtoValue { /* * It's possible that when pressing down, we are still * greater than the toValue, because the user may have * manipulated the value by hand. */ *(*float64)(unsafe.Pointer(bp + 256)) = (*TSpinbox)(unsafe.Pointer(sbPtr)).FtoValue } } } } libc.X__builtin_snprintf(tls, (*TSpinbox)(unsafe.Pointer(sbPtr)).FformatBuf, libc.Uint64FromInt32(libc.Int32FromInt32(TCL_MAX_PREC)+libc.Int32FromInt32(10)), (*TSpinbox)(unsafe.Pointer(sbPtr)).FvalueFormat, libc.VaList(bp+272, *(*float64)(unsafe.Pointer(bp + 256)))) code = _EntryValueChanged(tls, entryPtr, (*TSpinbox)(unsafe.Pointer(sbPtr)).FformatBuf) } } } if code != TCL_OK { return int32(TCL_ERROR) } if (*TSpinbox)(unsafe.Pointer(sbPtr)).FcommandObj != libc.UintptrFromInt32(0) { libtcl9_0.XTcl_DStringInit(tls, bp) _ExpandPercents1(tls, entryPtr, libtcl9_0.XTcl_GetStringFromObj(tls, (*TSpinbox)(unsafe.Pointer(sbPtr)).FcommandObj, libc.UintptrFromInt32(0)), type1, __ccgo_ts+195, 0, int32(VALIDATE_BUTTON), bp) libtcl9_0.XTcl_DStringAppend(tls, bp, __ccgo_ts+195, int64(1)) code = libtcl9_0.XTcl_EvalEx(tls, interp, (*TTcl_DString)(unsafe.Pointer(bp)).Fstring1, int64(-libc.Int32FromInt32(1)), libc.Int32FromInt32(TCL_EVAL_GLOBAL)|libc.Int32FromInt32(TCL_EVAL_DIRECT)) libtcl9_0.XTcl_DStringFree(tls, bp) if code != TCL_OK { libtcl9_0.XTcl_AppendObjToErrorInfo(tls, interp, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+22867, int64(-int32(1)))) libtcl9_0.XTcl_BackgroundException(tls, interp, code) /* * Yes, it's an error, but a bg one, so we return OK */ return TCL_OK } libtcl9_0.XTcl_ResetResult(tls, interp) } return TCL_OK } /* *---------------------------------------------------------------------- * * ComputeFormat -- * * This function is invoked to recompute the "format" fields of a * spinbox's widget record, which determines how the value of the dial is * converted to a string. * * Results: * Tcl result code. * * Side effects: * The format fields of the spinbox are modified. * *---------------------------------------------------------------------- */ func _ComputeFormat(tls *libc.TLS, sbPtr uintptr) (r int32) { bp := tls.Alloc(16) defer tls.Free(16) /* Information about dial widget. */ var afterDecimal, eDigits, fDigits, leastSigDigit, mostSigDigit, numDigits, v1 int32 var maxValue, x float64 _, _, _, _, _, _, _, _, _ = afterDecimal, eDigits, fDigits, leastSigDigit, maxValue, mostSigDigit, numDigits, x, v1 /* * Compute the displacement from the decimal of the most significant digit * required for any number in the dial's range. */ if (*TSpinbox)(unsafe.Pointer(sbPtr)).FreqFormatObj != 0 { (*TSpinbox)(unsafe.Pointer(sbPtr)).FvalueFormat = libtcl9_0.XTcl_GetStringFromObj(tls, (*TSpinbox)(unsafe.Pointer(sbPtr)).FreqFormatObj, libc.UintptrFromInt32(0)) return TCL_OK } maxValue = libc.Xfabs(tls, (*TSpinbox)(unsafe.Pointer(sbPtr)).FfromValue) x = libc.Xfabs(tls, (*TSpinbox)(unsafe.Pointer(sbPtr)).FtoValue) if x > maxValue { maxValue = x } if maxValue == libc.Float64FromInt32(0) { maxValue = libc.Float64FromInt32(1) } mostSigDigit = int32(libc.Xfloor(tls, libc.Xlog10(tls, maxValue))) if libc.Xfabs(tls, (*TSpinbox)(unsafe.Pointer(sbPtr)).Fincrement) > float64(1e-09) { /* * A increment was specified, so use it. */ leastSigDigit = int32(libc.Xfloor(tls, libc.Xlog10(tls, (*TSpinbox)(unsafe.Pointer(sbPtr)).Fincrement))) } else { leastSigDigit = 0 } numDigits = mostSigDigit - leastSigDigit + int32(1) if numDigits < int32(1) { numDigits = int32(1) } /* * Compute the number of characters required using "e" format and "f" * format, and then choose whichever one takes fewer characters. */ eDigits = numDigits + int32(4) if numDigits > int32(1) { eDigits++ /* Decimal point. */ } afterDecimal = numDigits - mostSigDigit - int32(1) if afterDecimal < 0 { afterDecimal = 0 } if mostSigDigit >= 0 { v1 = mostSigDigit + afterDecimal } else { v1 = afterDecimal } fDigits = v1 if afterDecimal > 0 { fDigits++ /* Decimal point. */ } if mostSigDigit < 0 { fDigits++ /* Zero to left of decimal point. */ } if fDigits <= eDigits { libc.X__builtin_snprintf(tls, sbPtr+600, uint64(16), __ccgo_ts+22905, libc.VaList(bp+8, afterDecimal)) } else { libc.X__builtin_snprintf(tls, sbPtr+600, uint64(16), __ccgo_ts+22912, libc.VaList(bp+8, numDigits-int32(1))) } (*TSpinbox)(unsafe.Pointer(sbPtr)).FvalueFormat = sbPtr + 600 return TCL_OK } const GOT_FOCUS2 = 4 const LABELMARGIN = 4 const LABELSPACING = 1 /* * Local Variables: * mode: c * c-basic-offset: 4 * fill-column: 78 * End: */ /* * default.h -- * * This file defines the defaults for all options for all of * the Tk widgets. * * Copyright © 1991-1994 The Regents of the University of California. * Copyright © 1994 Sun Microsystems, Inc. * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. */ /* * tkUnixDefault.h -- * * This file defines the defaults for all options for all of * the Tk widgets. * * Copyright © 1991-1994 The Regents of the University of California. * Copyright © 1994-1997 Sun Microsystems, Inc. * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. */ /* * The definitions below provide symbolic names for the default colors. * NORMAL_BG - Normal background color. * ACTIVE_BG - Background color when widget is active. * SELECT_BG - Background color for selected text. * TROUGH - Background color for troughs in scales and scrollbars. * INDICATOR - Color for indicator when button is selected. * DISABLED - Foreground color when widget is disabled. * PLACEHOLDER_FG - Foreground color for placeholder text. */ /* * Defaults for labels, buttons, checkbuttons, and radiobuttons: */ /* * Defaults for canvases: */ /* * Defaults for entries: */ /* * Defaults for frames: */ /* * Defaults for labelframes: */ /* * Defaults for listboxes: */ /* * Defaults for individual entries of menus: */ /* * Defaults for menus overall: */ /* * Defaults for menubuttons: */ /* * Defaults for messages: */ /* * Defaults for panedwindows */ /* * Defaults for panedwindow panes */ /* * Defaults for scales: */ /* * Defaults for scrollbars: */ /* * Defaults for texts: */ /* * Defaults for canvas text: */ /* * Defaults for canvas items * (arcs, bitmaps, lines, polygons, rectangles, and ovals): */ /* * Defaults for toplevels (most of the defaults for frames also apply * to toplevels): */ /* * Defaults for busy windows: */ /* * The following enum is used to define the type of the frame. */ type FrameType = int32 const TYPE_FRAME = 0 const TYPE_TOPLEVEL = 1 const TYPE_LABELFRAME = 2 /* * A data structure of the following type is kept for each * frame that currently exists for this process: */ type TFrame = struct { Ftkwin TTk_Window Fdisplay uintptr Finterp uintptr FwidgetCmd TTcl_Command FoptionTable TTk_OptionTable FclassNameObj uintptr Ftype1 int32 FscreenNameObj uintptr FvisualNameObj uintptr FcolormapNameObj uintptr FmenuNameObj uintptr Fcolormap TColormap Fborder TTk_3DBorder FborderWidthObj uintptr Frelief int32 FhighlightWidthObj uintptr FhighlightBgColorPtr uintptr FhighlightColorPtr uintptr FwidthObj uintptr FheightObj uintptr Fcursor TTk_Cursor FtakeFocusObj uintptr FisContainer int32 FuseThisObj uintptr Fflags int32 FpadXObj uintptr FpadYObj uintptr FbgimgPtr uintptr Fbgimg TTk_Image Ftile int32 FcopyGC TGC } /* * A data structure of the following type is kept for each labelframe widget * managed by this file: */ type TLabelframe = struct { Fframe TFrame FtextPtr uintptr Ftkfont TTk_Font FtextColorPtr uintptr FlabelAnchor int32 FlabelWin TTk_Window FtextGC TGC FtextLayout TTk_TextLayout FlabelBox TXRectangle FlabelReqWidth int32 FlabelReqHeight int32 FlabelTextX int32 FlabelTextY int32 } /* * The following macros define how many extra pixels to leave around a label's * text. */ /* * Flag bits for frames: * * REDRAW_PENDING: Non-zero means a DoWhenIdle handler has * already been queued to redraw this window. * GOT_FOCUS: Non-zero means this widget currently has the * input focus. */ /* * The following enum is used to define a type for the -labelanchor option of * the Labelframe widget. These values are used as indices into the string * table below. */ type labelanchor = int32 const LABELANCHOR_E = 0 const LABELANCHOR_EN = 1 const LABELANCHOR_ES = 2 const LABELANCHOR_N = 3 const LABELANCHOR_NE = 4 const LABELANCHOR_NW = 5 const LABELANCHOR_S = 6 const LABELANCHOR_SE = 7 const LABELANCHOR_SW = 8 const LABELANCHOR_W = 9 const LABELANCHOR_WN = 10 const LABELANCHOR_WS = 11 var _labelAnchorStrings = [13]uintptr{ 0: __ccgo_ts + 10944, 1: __ccgo_ts + 22919, 2: __ccgo_ts + 22922, 3: __ccgo_ts + 10939, 4: __ccgo_ts + 10941, 5: __ccgo_ts + 10956, 6: __ccgo_ts + 10949, 7: __ccgo_ts + 10946, 8: __ccgo_ts + 10951, 9: __ccgo_ts + 10954, 10: __ccgo_ts + 22925, 11: __ccgo_ts + 22928, 12: libc.UintptrFromInt32(0), } /* * Information used for parsing configuration options. There are one common * table used by all and one table for each widget class. */ var _commonOptSpec = [15]TTk_OptionSpec{ 0: { Ftype1: int32(TK_OPTION_BORDER), FoptionName: __ccgo_ts + 19898, FdbName: __ccgo_ts + 19910, FdbClass: __ccgo_ts + 19872, FdefValue: __ccgo_ts + 19921, FobjOffset: int64(-libc.Int32FromInt32(1)), FinternalOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 96)), Fflags: int32(TCL_NULL_OK), FclientData: __ccgo_ts + 19883, }, 1: { Ftype1: int32(TK_OPTION_SYNONYM), FoptionName: __ccgo_ts + 19933, FinternalOffset: int64(-libc.Int32FromInt32(1)), FclientData: __ccgo_ts + 19898, }, 2: { Ftype1: int32(TK_OPTION_STRING), FoptionName: __ccgo_ts + 19101, FdbName: __ccgo_ts + 22931, FdbClass: __ccgo_ts + 1916, FdefValue: __ccgo_ts + 195, FobjOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 72)), FinternalOffset: int64(-libc.Int32FromInt32(1)), Fflags: int32(TCL_NULL_OK), }, 3: { FoptionName: __ccgo_ts + 22940, FdbName: __ccgo_ts + 22951, FdbClass: __ccgo_ts + 22961, FdefValue: __ccgo_ts + 10533, FobjOffset: int64(-libc.Int32FromInt32(1)), FinternalOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 176)), }, 4: { Ftype1: int32(TK_OPTION_CURSOR), FoptionName: __ccgo_ts + 4638, FdbName: __ccgo_ts + 4646, FdbClass: __ccgo_ts + 4653, FdefValue: __ccgo_ts + 195, FobjOffset: int64(-libc.Int32FromInt32(1)), FinternalOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 160)), Fflags: int32(TCL_NULL_OK), }, 5: { Ftype1: int32(TK_OPTION_PIXELS), FoptionName: __ccgo_ts + 2870, FdbName: __ccgo_ts + 6172, FdbClass: __ccgo_ts + 20122, FdefValue: __ccgo_ts + 10533, FobjOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 152)), FinternalOffset: int64(-libc.Int32FromInt32(1)), }, 6: { Ftype1: int32(TK_OPTION_COLOR), FoptionName: __ccgo_ts + 20129, FdbName: __ccgo_ts + 20150, FdbClass: __ccgo_ts + 20170, FdefValue: __ccgo_ts + 19921, FobjOffset: int64(-libc.Int32FromInt32(1)), FinternalOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 128)), }, 7: { Ftype1: int32(TK_OPTION_COLOR), FoptionName: __ccgo_ts + 20190, FdbName: __ccgo_ts + 20206, FdbClass: __ccgo_ts + 20221, FdefValue: __ccgo_ts + 19829, FobjOffset: int64(-libc.Int32FromInt32(1)), FinternalOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 136)), }, 8: { Ftype1: int32(TK_OPTION_PIXELS), FoptionName: __ccgo_ts + 20236, FdbName: __ccgo_ts + 20256, FdbClass: __ccgo_ts + 20275, FdefValue: __ccgo_ts + 10533, FobjOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 120)), FinternalOffset: int64(-libc.Int32FromInt32(1)), }, 9: { Ftype1: int32(TK_OPTION_PIXELS), FoptionName: __ccgo_ts + 12320, FdbName: __ccgo_ts + 20332, FdbClass: __ccgo_ts + 20337, FdefValue: __ccgo_ts + 10533, FobjOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 200)), FinternalOffset: int64(-libc.Int32FromInt32(1)), }, 10: { Ftype1: int32(TK_OPTION_PIXELS), FoptionName: __ccgo_ts + 12326, FdbName: __ccgo_ts + 20341, FdbClass: __ccgo_ts + 20337, FdefValue: __ccgo_ts + 10533, FobjOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 208)), FinternalOffset: int64(-libc.Int32FromInt32(1)), }, 11: { Ftype1: int32(TK_OPTION_STRING), FoptionName: __ccgo_ts + 20367, FdbName: __ccgo_ts + 20378, FdbClass: __ccgo_ts + 20388, FdefValue: __ccgo_ts + 10533, FobjOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 168)), FinternalOffset: int64(-libc.Int32FromInt32(1)), Fflags: int32(TCL_NULL_OK), }, 12: { Ftype1: int32(TK_OPTION_STRING), FoptionName: __ccgo_ts + 19232, FdbName: __ccgo_ts + 6393, FdbClass: __ccgo_ts + 22971, FdefValue: __ccgo_ts + 195, FobjOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 64)), FinternalOffset: int64(-libc.Int32FromInt32(1)), Fflags: int32(TCL_NULL_OK), }, 13: { Ftype1: int32(TK_OPTION_PIXELS), FoptionName: __ccgo_ts + 2987, FdbName: __ccgo_ts + 6446, FdbClass: __ccgo_ts + 20455, FdefValue: __ccgo_ts + 10533, FobjOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 144)), FinternalOffset: int64(-libc.Int32FromInt32(1)), }, 14: { Ftype1: int32(TK_OPTION_END), }, } var _frameOptSpec = [8]TTk_OptionSpec{ 0: { Ftype1: int32(TK_OPTION_STRING), FoptionName: __ccgo_ts + 22978, FdbName: __ccgo_ts + 22995, FdbClass: __ccgo_ts + 23011, FobjOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 216)), FinternalOffset: int64(-libc.Int32FromInt32(1)), Fflags: int32(TCL_NULL_OK), }, 1: { Ftype1: int32(TK_OPTION_SYNONYM), FoptionName: __ccgo_ts + 19929, FinternalOffset: int64(-libc.Int32FromInt32(1)), FclientData: __ccgo_ts + 2814, }, 2: { Ftype1: int32(TK_OPTION_SYNONYM), FoptionName: __ccgo_ts + 23027, FinternalOffset: int64(-libc.Int32FromInt32(1)), FclientData: __ccgo_ts + 22978, }, 3: { Ftype1: int32(TK_OPTION_PIXELS), FoptionName: __ccgo_ts + 2814, FdbName: __ccgo_ts + 19952, FdbClass: __ccgo_ts + 19964, FdefValue: __ccgo_ts + 10533, FobjOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 104)), FinternalOffset: int64(-libc.Int32FromInt32(1)), }, 4: { Ftype1: int32(TK_OPTION_STRING), FoptionName: __ccgo_ts + 23034, FdbName: __ccgo_ts + 6138, FdbClass: __ccgo_ts + 23041, FdefValue: __ccgo_ts + 23047, FobjOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 40)), FinternalOffset: int64(-libc.Int32FromInt32(1)), }, 5: { Ftype1: int32(TK_OPTION_RELIEF), FoptionName: __ccgo_ts + 20346, FdbName: __ccgo_ts + 82, FdbClass: __ccgo_ts + 20354, FdefValue: __ccgo_ts, FobjOffset: int64(-libc.Int32FromInt32(1)), FinternalOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 112)), }, 6: { FoptionName: __ccgo_ts + 23053, FdbName: __ccgo_ts + 23059, FdbClass: __ccgo_ts + 23064, FdefValue: __ccgo_ts + 10533, FobjOffset: int64(-libc.Int32FromInt32(1)), FinternalOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 232)), }, 7: { Ftype1: int32(TK_OPTION_END), FclientData: uintptr(unsafe.Pointer(&_commonOptSpec)), }, } var _toplevelOptSpec = [11]TTk_OptionSpec{ 0: { Ftype1: int32(TK_OPTION_STRING), FoptionName: __ccgo_ts + 22978, FdbName: __ccgo_ts + 22995, FdbClass: __ccgo_ts + 23011, FobjOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 216)), FinternalOffset: int64(-libc.Int32FromInt32(1)), Fflags: int32(TCL_NULL_OK), }, 1: { Ftype1: int32(TK_OPTION_SYNONYM), FoptionName: __ccgo_ts + 19929, FinternalOffset: int64(-libc.Int32FromInt32(1)), FclientData: __ccgo_ts + 2814, }, 2: { Ftype1: int32(TK_OPTION_SYNONYM), FoptionName: __ccgo_ts + 23027, FinternalOffset: int64(-libc.Int32FromInt32(1)), FclientData: __ccgo_ts + 22978, }, 3: { Ftype1: int32(TK_OPTION_PIXELS), FoptionName: __ccgo_ts + 2814, FdbName: __ccgo_ts + 19952, FdbClass: __ccgo_ts + 19964, FdefValue: __ccgo_ts + 10533, FobjOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 104)), FinternalOffset: int64(-libc.Int32FromInt32(1)), }, 4: { Ftype1: int32(TK_OPTION_STRING), FoptionName: __ccgo_ts + 23034, FdbName: __ccgo_ts + 6138, FdbClass: __ccgo_ts + 23041, FdefValue: __ccgo_ts + 23069, FobjOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 40)), FinternalOffset: int64(-libc.Int32FromInt32(1)), }, 5: { Ftype1: int32(TK_OPTION_STRING), FoptionName: __ccgo_ts + 23078, FdbName: __ccgo_ts + 17924, FdbClass: __ccgo_ts + 23084, FdefValue: __ccgo_ts + 195, FobjOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 80)), FinternalOffset: int64(-libc.Int32FromInt32(1)), Fflags: int32(TCL_NULL_OK), }, 6: { Ftype1: int32(TK_OPTION_RELIEF), FoptionName: __ccgo_ts + 20346, FdbName: __ccgo_ts + 82, FdbClass: __ccgo_ts + 20354, FdefValue: __ccgo_ts, FobjOffset: int64(-libc.Int32FromInt32(1)), FinternalOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 112)), }, 7: { Ftype1: int32(TK_OPTION_STRING), FoptionName: __ccgo_ts + 19488, FdbName: __ccgo_ts + 6270, FdbClass: __ccgo_ts + 23089, FdefValue: __ccgo_ts + 195, FobjOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 56)), FinternalOffset: int64(-libc.Int32FromInt32(1)), Fflags: int32(TCL_NULL_OK), }, 8: { FoptionName: __ccgo_ts + 23053, FdbName: __ccgo_ts + 23059, FdbClass: __ccgo_ts + 23064, FdefValue: __ccgo_ts + 10533, FobjOffset: int64(-libc.Int32FromInt32(1)), FinternalOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 232)), }, 9: { Ftype1: int32(TK_OPTION_STRING), FoptionName: __ccgo_ts + 19263, FdbName: __ccgo_ts + 23096, FdbClass: __ccgo_ts + 23100, FdefValue: __ccgo_ts + 195, FobjOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 184)), FinternalOffset: int64(-libc.Int32FromInt32(1)), Fflags: int32(TCL_NULL_OK), }, 10: { Ftype1: int32(TK_OPTION_END), FclientData: uintptr(unsafe.Pointer(&_commonOptSpec)), }, } var _labelframeOptSpec = [11]TTk_OptionSpec{ 0: { Ftype1: int32(TK_OPTION_SYNONYM), FoptionName: __ccgo_ts + 19929, FinternalOffset: int64(-libc.Int32FromInt32(1)), FclientData: __ccgo_ts + 2814, }, 1: { Ftype1: int32(TK_OPTION_PIXELS), FoptionName: __ccgo_ts + 2814, FdbName: __ccgo_ts + 19952, FdbClass: __ccgo_ts + 19964, FdefValue: __ccgo_ts + 21412, FobjOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 104)), FinternalOffset: int64(-libc.Int32FromInt32(1)), }, 2: { Ftype1: int32(TK_OPTION_STRING), FoptionName: __ccgo_ts + 23034, FdbName: __ccgo_ts + 6138, FdbClass: __ccgo_ts + 23041, FdefValue: __ccgo_ts + 23104, FobjOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 40)), FinternalOffset: int64(-libc.Int32FromInt32(1)), }, 3: { Ftype1: int32(TK_OPTION_SYNONYM), FoptionName: __ccgo_ts + 20070, FdbName: __ccgo_ts + 20074, FinternalOffset: int64(-libc.Int32FromInt32(1)), FclientData: __ccgo_ts + 20085, }, 4: { Ftype1: int32(TK_OPTION_FONT), FoptionName: __ccgo_ts + 20097, FdbName: __ccgo_ts + 9358, FdbClass: __ccgo_ts + 20103, FdefValue: __ccgo_ts + 20108, FobjOffset: int64(-libc.Int32FromInt32(1)), FinternalOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 256)), }, 5: { Ftype1: int32(TK_OPTION_COLOR), FoptionName: __ccgo_ts + 20085, FdbName: __ccgo_ts + 20074, FdbClass: __ccgo_ts + 19810, FdefValue: __ccgo_ts + 19829, FobjOffset: int64(-libc.Int32FromInt32(1)), FinternalOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 264)), }, 6: { Ftype1: int32(TK_OPTION_STRING_TABLE), FoptionName: __ccgo_ts + 23115, FdbName: __ccgo_ts + 23128, FdbClass: __ccgo_ts + 23140, FdefValue: __ccgo_ts + 10956, FobjOffset: int64(-libc.Int32FromInt32(1)), FinternalOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 272)), FclientData: uintptr(unsafe.Pointer(&_labelAnchorStrings)), }, 7: { Ftype1: int32(TK_OPTION_WINDOW), FoptionName: __ccgo_ts + 23152, FdbName: __ccgo_ts + 23165, FdbClass: __ccgo_ts + 23177, FobjOffset: int64(-libc.Int32FromInt32(1)), FinternalOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 280)), Fflags: int32(TCL_NULL_OK), }, 8: { Ftype1: int32(TK_OPTION_RELIEF), FoptionName: __ccgo_ts + 20346, FdbName: __ccgo_ts + 82, FdbClass: __ccgo_ts + 20354, FdefValue: __ccgo_ts + 5, FobjOffset: int64(-libc.Int32FromInt32(1)), FinternalOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 112)), }, 9: { Ftype1: int32(TK_OPTION_STRING), FoptionName: __ccgo_ts + 20398, FdbName: __ccgo_ts + 17996, FdbClass: __ccgo_ts + 20404, FdefValue: __ccgo_ts + 195, FobjOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 248)), FinternalOffset: int64(-libc.Int32FromInt32(1)), Fflags: int32(TCL_NULL_OK), }, 10: { Ftype1: int32(TK_OPTION_END), FclientData: uintptr(unsafe.Pointer(&_commonOptSpec)), }, } /* * Class names for widgets, indexed by FrameType. */ var _classNames1 = [3]uintptr{ 0: __ccgo_ts + 23047, 1: __ccgo_ts + 23069, 2: __ccgo_ts + 23104, } /* * The following table maps from FrameType to the option template for that * class of widgets. */ var _optionSpecs2 = [3]uintptr{ 0: uintptr(unsafe.Pointer(&_frameOptSpec)), 1: uintptr(unsafe.Pointer(&_toplevelOptSpec)), 2: uintptr(unsafe.Pointer(&_labelframeOptSpec)), } /* * The structure below defines frame class behavior by means of functions that * can be invoked from generic window code. */ var _frameClass = TTk_ClassProcs{ Fsize: int64(32), } func init() { p := unsafe.Pointer(&_frameClass) *(*uintptr)(unsafe.Add(p, 8)) = __ccgo_fp(_FrameWorldChanged) } /* * The structure below defines the official type record for the labelframe's * geometry manager: */ var _frameGeomType = TTk_GeomMgr{ Fname: __ccgo_ts + 17905, } func init() { p := unsafe.Pointer(&_frameGeomType) *(*uintptr)(unsafe.Add(p, 8)) = __ccgo_fp(_FrameRequestProc) *(*uintptr)(unsafe.Add(p, 16)) = __ccgo_fp(_FrameLostContentProc) } /* *-------------------------------------------------------------- * * Tk_FrameObjCmd, Tk_ToplevelObjCmd, Tk_LabelframeObjCmd -- * * These functions are invoked to process the "frame", "toplevel" and * "labelframe" Tcl commands. See the user documentation for details on * what they do. * * Results: * A standard Tcl result. * * Side effects: * See the user documentation. These functions are just wrappers; they * call CreateFrame to do all of the real work. * *-------------------------------------------------------------- */ func XTk_FrameObjCmd(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) (r int32) { /* Argument objects. */ return XTkCreateFrame(tls, clientData, interp, int64(objc), objv, int32(TYPE_FRAME), libc.UintptrFromInt32(0)) } func XTk_ToplevelObjCmd(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) (r int32) { /* Argument objects. */ return XTkCreateFrame(tls, clientData, interp, int64(objc), objv, int32(TYPE_TOPLEVEL), libc.UintptrFromInt32(0)) } func XTk_LabelframeObjCmd(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) (r int32) { /* Argument objects. */ return XTkCreateFrame(tls, clientData, interp, int64(objc), objv, int32(TYPE_LABELFRAME), libc.UintptrFromInt32(0)) } /* *-------------------------------------------------------------- * * TkCreateFrame -- * * This function is the old command function for the "frame" and * "toplevel" commands. Now it is used directly by Tk_Init to create a * new main window. See the user documentation for the "frame" and * "toplevel" commands for details on what it does. * * Results: * A standard Tcl result. * * Side effects: * See the user documentation. * *-------------------------------------------------------------- */ func XTkCreateFrame(tls *libc.TLS, dummy439 uintptr, interp uintptr, objc TTcl_Size, objv uintptr, type1 int32, appName uintptr) (r int32) { bp := tls.Alloc(64) defer tls.Free(64) /* Should only be non-NULL if there are no * Main window associated with the * interpreter. Gives the base name to use for * the new application. */ var arg, className, colormapName, framePtr, labelframePtr, screenName, useOption, visual, visualName, v1, v2, v3, v4, v6, v7 uintptr var i TTcl_Size var mask uint32 var newWin, tkwin TTk_Window var optionTable TTk_OptionTable var _ /* colormap at bp+16 */ TColormap var _ /* depth at bp+0 */ int32 var _ /* length at bp+8 */ TTcl_Size _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = arg, className, colormapName, framePtr, i, labelframePtr, mask, newWin, optionTable, screenName, tkwin, useOption, visual, visualName, v1, v2, v3, v4, v6, v7 if objc < int64(2) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(1), objv, __ccgo_ts+20960) return int32(TCL_ERROR) } /* * Create the option table for this widget class. If it has already been * created, the cached pointer will be returned. */ optionTable = XTk_CreateOptionTable(tls, interp, _optionSpecs2[type1]) /* * Pre-process the argument list. Scan through it to find any "-class", * "-screen", "-visual", and "-colormap" options. These arguments need to * be processed specially, before the window is configured using the usual * Tk mechanisms. */ v4 = libc.UintptrFromInt32(0) useOption = v4 v3 = v4 visualName = v3 v2 = v3 screenName = v2 v1 = v2 colormapName = v1 className = v1 *(*TColormap)(unsafe.Pointer(bp + 16)) = uint64(0) i = int64(2) for { if !(i < objc) { break } arg = libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(i)*8)), bp+8) if *(*TTcl_Size)(unsafe.Pointer(bp + 8)) < int64(2) { goto _5 } if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(arg + 1))) == int32('c') && *(*TTcl_Size)(unsafe.Pointer(bp + 8)) >= int64(3) && libc.Xstrncmp(tls, arg, __ccgo_ts+23034, libc.Uint64FromInt64(*(*TTcl_Size)(unsafe.Pointer(bp + 8)))) == 0 { className = libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(i+int64(1))*8)), libc.UintptrFromInt32(0)) } else { if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(arg + 1))) == int32('c') && *(*TTcl_Size)(unsafe.Pointer(bp + 8)) >= int64(3) && libc.Xstrncmp(tls, arg, __ccgo_ts+19101, libc.Uint64FromInt64(*(*TTcl_Size)(unsafe.Pointer(bp + 8)))) == 0 { colormapName = libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(i+int64(1))*8)), libc.UintptrFromInt32(0)) } else { if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(arg + 1))) == int32('s') && type1 == int32(TYPE_TOPLEVEL) && libc.Xstrncmp(tls, arg, __ccgo_ts+19488, libc.Uint64FromInt64(*(*TTcl_Size)(unsafe.Pointer(bp + 8)))) == 0 { screenName = libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(i+int64(1))*8)), libc.UintptrFromInt32(0)) } else { if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(arg + 1))) == int32('u') && type1 == int32(TYPE_TOPLEVEL) && libc.Xstrncmp(tls, arg, __ccgo_ts+19263, libc.Uint64FromInt64(*(*TTcl_Size)(unsafe.Pointer(bp + 8)))) == 0 { useOption = libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(i+int64(1))*8)), libc.UintptrFromInt32(0)) } else { if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(arg + 1))) == int32('v') && libc.Xstrncmp(tls, arg, __ccgo_ts+19232, libc.Uint64FromInt64(*(*TTcl_Size)(unsafe.Pointer(bp + 8)))) == 0 { visualName = libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(i+int64(1))*8)), libc.UintptrFromInt32(0)) } } } } } goto _5 _5: ; i += int64(2) } /* * Create the window, and deal with the special options -use, -classname, * -colormap, -screenname, and -visual. These options must be handle * before calling ConfigureFrame below, and they must also be processed in * a particular order, for the following reasons: * 1. Must set the window's class before calling ConfigureFrame, so that * unspecified options are looked up in the option database using the * correct class. * 2. Must set visual information before calling ConfigureFrame so that * colors are allocated in a proper colormap. * 3. Must call Tk_UseWindow before setting non-default visual * information, since Tk_UseWindow changes the defaults. */ if screenName == libc.UintptrFromInt32(0) { if type1 == int32(TYPE_TOPLEVEL) { v6 = __ccgo_ts + 195 } else { v6 = libc.UintptrFromInt32(0) } screenName = v6 } /* * Main window associated with interpreter. If we're called by Tk_Init to * create a new application, then this is NULL. */ tkwin = XTk_MainWindow(tls, interp) if tkwin != libc.UintptrFromInt32(0) { newWin = XTk_CreateWindowFromPath(tls, interp, tkwin, libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8)), libc.UintptrFromInt32(0)), screenName) } else { if appName == libc.UintptrFromInt32(0) { /* * This occurs when someone tried to create a frame/toplevel while we * are being destroyed. Let an error be thrown. */ libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+23189, libc.VaList(bp+32, libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8)), libc.UintptrFromInt32(0))))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+32, __ccgo_ts+179, __ccgo_ts+23218, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) } else { /* * We were called from Tk_Init; create a new application. */ newWin = XTkCreateMainWindow(tls, interp, screenName, appName) } } if newWin == libc.UintptrFromInt32(0) { goto error } /* * Mark Tk frames as suitable candidates for [wm manage]. */ *(*uint32)(unsafe.Pointer(newWin + 280)) |= uint32(TK_WM_MANAGEABLE) if className == libc.UintptrFromInt32(0) { className = XTk_GetOption(tls, newWin, __ccgo_ts+6138, __ccgo_ts+23041) if className == libc.UintptrFromInt32(0) { className = _classNames1[type1] } } XTk_SetClass(tls, newWin, className) if useOption == libc.UintptrFromInt32(0) { useOption = XTk_GetOption(tls, newWin, __ccgo_ts+23096, __ccgo_ts+23100) } if useOption != libc.UintptrFromInt32(0) && libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(useOption))) != 0 && XTk_UseWindow(tls, interp, newWin, useOption) != TCL_OK { goto error } if visualName == libc.UintptrFromInt32(0) { visualName = XTk_GetOption(tls, newWin, __ccgo_ts+6393, __ccgo_ts+22971) } if colormapName == libc.UintptrFromInt32(0) { colormapName = XTk_GetOption(tls, newWin, __ccgo_ts+22931, __ccgo_ts+1916) } if colormapName != libc.UintptrFromInt32(0) && libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(colormapName))) == 0 { colormapName = libc.UintptrFromInt32(0) } if visualName != libc.UintptrFromInt32(0) { if colormapName == libc.UintptrFromInt32(0) { v7 = bp + 16 } else { v7 = libc.UintptrFromInt32(0) } visual = XTk_GetVisual(tls, interp, newWin, visualName, bp, v7) if visual == libc.UintptrFromInt32(0) { goto error } XTk_SetWindowVisual(tls, newWin, visual, *(*int32)(unsafe.Pointer(bp)), *(*TColormap)(unsafe.Pointer(bp + 16))) } if colormapName != libc.UintptrFromInt32(0) { *(*TColormap)(unsafe.Pointer(bp + 16)) = XTk_GetColormap(tls, interp, newWin, colormapName) if *(*TColormap)(unsafe.Pointer(bp + 16)) == uint64(0) { goto error } XTk_SetWindowColormap(tls, newWin, *(*TColormap)(unsafe.Pointer(bp + 16))) } /* * For top-level windows, provide an initial geometry request of 200x200, * just so the window looks nicer on the screen if it doesn't request a * size for itself. */ if type1 == int32(TYPE_TOPLEVEL) { XTk_GeometryRequest(tls, newWin, int32(200), int32(200)) } /* * Create the widget record, process configuration options, and create * event handlers. Then fill in a few additional fields in the widget * record from the special options. */ if type1 == int32(TYPE_LABELFRAME) { framePtr = libtcl9_0.XTcl_Alloc(tls, uint64(328)) libc.Xmemset(tls, framePtr, 0, uint64(328)) } else { framePtr = libtcl9_0.XTcl_Alloc(tls, uint64(248)) libc.Xmemset(tls, framePtr, 0, uint64(248)) } (*TFrame)(unsafe.Pointer(framePtr)).Ftkwin = newWin (*TFrame)(unsafe.Pointer(framePtr)).Fdisplay = (*TTk_FakeWin)(unsafe.Pointer(newWin)).Fdisplay (*TFrame)(unsafe.Pointer(framePtr)).Finterp = interp (*TFrame)(unsafe.Pointer(framePtr)).FwidgetCmd = libtcl9_0.XTcl_CreateObjCommand(tls, interp, (*TTk_FakeWin)(unsafe.Pointer(newWin)).FpathName, __ccgo_fp(_FrameWidgetObjCmd), framePtr, __ccgo_fp(_FrameCmdDeletedProc)) (*TFrame)(unsafe.Pointer(framePtr)).FoptionTable = optionTable (*TFrame)(unsafe.Pointer(framePtr)).Ftype1 = type1 (*TFrame)(unsafe.Pointer(framePtr)).Fcolormap = *(*TColormap)(unsafe.Pointer(bp + 16)) (*TFrame)(unsafe.Pointer(framePtr)).Frelief = TK_RELIEF_FLAT (*TFrame)(unsafe.Pointer(framePtr)).Fcursor = libc.UintptrFromInt32(0) if (*TFrame)(unsafe.Pointer(framePtr)).Ftype1 == int32(TYPE_LABELFRAME) { labelframePtr = framePtr (*TLabelframe)(unsafe.Pointer(labelframePtr)).FlabelAnchor = int32(LABELANCHOR_NW) (*TLabelframe)(unsafe.Pointer(labelframePtr)).FtextGC = libc.UintptrFromInt32(0) } /* * Store backreference to frame widget in window structure. */ XTk_SetClassProcs(tls, newWin, uintptr(unsafe.Pointer(&_frameClass)), framePtr) mask = libc.Uint32FromInt64(libc.Int64FromInt64(1)<= int64(2) && libc.Xstrncmp(tls, arg, __ccgo_ts+23034, libc.Uint64FromInt64(*(*TTcl_Size)(unsafe.Pointer(bp + 8)))) == 0 || c == int32('c') && *(*TTcl_Size)(unsafe.Pointer(bp + 8)) >= int64(3) && libc.Xstrncmp(tls, arg, __ccgo_ts+19101, libc.Uint64FromInt64(*(*TTcl_Size)(unsafe.Pointer(bp + 8)))) == 0 || c == int32('c') && *(*TTcl_Size)(unsafe.Pointer(bp + 8)) >= int64(3) && libc.Xstrncmp(tls, arg, __ccgo_ts+22940, libc.Uint64FromInt64(*(*TTcl_Size)(unsafe.Pointer(bp + 8)))) == 0 || c == int32('s') && (*TFrame)(unsafe.Pointer(framePtr)).Ftype1 == int32(TYPE_TOPLEVEL) && libc.Xstrncmp(tls, arg, __ccgo_ts+19488, libc.Uint64FromInt64(*(*TTcl_Size)(unsafe.Pointer(bp + 8)))) == 0 || c == int32('u') && (*TFrame)(unsafe.Pointer(framePtr)).Ftype1 == int32(TYPE_TOPLEVEL) && libc.Xstrncmp(tls, arg, __ccgo_ts+19263, libc.Uint64FromInt64(*(*TTcl_Size)(unsafe.Pointer(bp + 8)))) == 0 || c == int32('v') && libc.Xstrncmp(tls, arg, __ccgo_ts+19232, libc.Uint64FromInt64(*(*TTcl_Size)(unsafe.Pointer(bp + 8)))) == 0 { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+23317, libc.VaList(bp+24, arg))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+24, __ccgo_ts+179, __ccgo_ts+23299, __ccgo_ts+23364, libc.UintptrFromInt32(0))) result = int32(TCL_ERROR) goto done } goto _2 _2: ; i++ } result = _ConfigureFrame(tls, interp, framePtr, int64(objc-int32(2)), objv+uintptr(2)*8) } break } goto done done: ; libtcl9_0.XTcl_Release(tls, framePtr) return result } var _frameOptions = [3]uintptr{ 0: __ccgo_ts + 4735, 1: __ccgo_ts + 4740, 2: libc.UintptrFromInt32(0), } /* *---------------------------------------------------------------------- * * DestroyFrame -- * * This function is invoked by Tcl_EventuallyFree or Tcl_Release to clean * up the internal structure of a frame at a safe time (when no-one is * using it anymore). * * Results: * None. * * Side effects: * Everything associated with the frame is freed up. * *---------------------------------------------------------------------- */ func _DestroyFrame(tls *libc.TLS, memPtr uintptr) { /* Info about frame widget. */ var framePtr, labelframePtr uintptr _, _ = framePtr, labelframePtr framePtr = memPtr labelframePtr = memPtr if (*TFrame)(unsafe.Pointer(framePtr)).Ftype1 == int32(TYPE_LABELFRAME) { XTk_FreeTextLayout(tls, (*TLabelframe)(unsafe.Pointer(labelframePtr)).FtextLayout) if (*TLabelframe)(unsafe.Pointer(labelframePtr)).FtextGC != libc.UintptrFromInt32(0) { XTk_FreeGC(tls, (*TFrame)(unsafe.Pointer(framePtr)).Fdisplay, (*TLabelframe)(unsafe.Pointer(labelframePtr)).FtextGC) } } if (*TFrame)(unsafe.Pointer(framePtr)).FcopyGC != libc.UintptrFromInt32(0) { XTk_FreeGC(tls, (*TFrame)(unsafe.Pointer(framePtr)).Fdisplay, (*TFrame)(unsafe.Pointer(framePtr)).FcopyGC) } if (*TFrame)(unsafe.Pointer(framePtr)).Fcolormap != uint64(0) { XTk_FreeColormap(tls, (*TFrame)(unsafe.Pointer(framePtr)).Fdisplay, (*TFrame)(unsafe.Pointer(framePtr)).Fcolormap) } if (*TFrame)(unsafe.Pointer(framePtr)).Fbgimg != 0 { XTk_FreeImage(tls, (*TFrame)(unsafe.Pointer(framePtr)).Fbgimg) } libtcl9_0.XTcl_Free(tls, framePtr) } /* *---------------------------------------------------------------------- * * DestroyFramePartly -- * * This function is invoked to clean up everything that needs tkwin to be * defined when deleted. During the destruction process tkwin is always * set to NULL and this function must be called before that happens. * * Results: * None. * * Side effects: * Some things associated with the frame are freed up. * *---------------------------------------------------------------------- */ func _DestroyFramePartly(tls *libc.TLS, framePtr uintptr) { /* Info about frame widget. */ var labelframePtr uintptr _ = labelframePtr labelframePtr = framePtr if (*TFrame)(unsafe.Pointer(framePtr)).Ftype1 == int32(TYPE_LABELFRAME) && (*TLabelframe)(unsafe.Pointer(labelframePtr)).FlabelWin != libc.UintptrFromInt32(0) { XTk_DeleteEventHandler(tls, (*TLabelframe)(unsafe.Pointer(labelframePtr)).FlabelWin, libc.Uint64FromInt64(libc.Int64FromInt64(1)<= int32(LABELANCHOR_N) && (*TLabelframe)(unsafe.Pointer(labelframePtr)).FlabelAnchor <= int32(LABELANCHOR_SW) { if (*TLabelframe)(unsafe.Pointer(labelframePtr)).FlabelReqHeight < *(*int32)(unsafe.Pointer(bp + 144)) { (*TLabelframe)(unsafe.Pointer(labelframePtr)).FlabelReqHeight = *(*int32)(unsafe.Pointer(bp + 144)) } } else { if (*TLabelframe)(unsafe.Pointer(labelframePtr)).FlabelReqWidth < *(*int32)(unsafe.Pointer(bp + 144)) { (*TLabelframe)(unsafe.Pointer(labelframePtr)).FlabelReqWidth = *(*int32)(unsafe.Pointer(bp + 144)) } } } /* * Calculate individual border widths. */ XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), (*TFrame)(unsafe.Pointer(framePtr)).Ftkwin, (*TFrame)(unsafe.Pointer(framePtr)).FhighlightWidthObj, bp+148) v4 = *(*int32)(unsafe.Pointer(bp + 144)) + *(*int32)(unsafe.Pointer(bp + 148)) bWidthLeft = v4 v3 = v4 bWidthRight = v3 v2 = v3 bWidthTop = v2 bWidthBottom = v2 XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), (*TFrame)(unsafe.Pointer(framePtr)).Ftkwin, (*TFrame)(unsafe.Pointer(framePtr)).FpadXObj, bp+128) XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), (*TFrame)(unsafe.Pointer(framePtr)).Ftkwin, (*TFrame)(unsafe.Pointer(framePtr)).FpadYObj, bp+132) bWidthLeft += *(*int32)(unsafe.Pointer(bp + 128)) bWidthRight += *(*int32)(unsafe.Pointer(bp + 128)) bWidthTop += *(*int32)(unsafe.Pointer(bp + 132)) bWidthBottom += *(*int32)(unsafe.Pointer(bp + 132)) if anyTextLabel != 0 || anyWindowLabel != 0 { switch (*TLabelframe)(unsafe.Pointer(labelframePtr)).FlabelAnchor { case int32(LABELANCHOR_E): fallthrough case int32(LABELANCHOR_EN): fallthrough case int32(LABELANCHOR_ES): bWidthRight += (*TLabelframe)(unsafe.Pointer(labelframePtr)).FlabelReqWidth - *(*int32)(unsafe.Pointer(bp + 144)) case int32(LABELANCHOR_N): fallthrough case int32(LABELANCHOR_NE): fallthrough case int32(LABELANCHOR_NW): bWidthTop += (*TLabelframe)(unsafe.Pointer(labelframePtr)).FlabelReqHeight - *(*int32)(unsafe.Pointer(bp + 144)) case int32(LABELANCHOR_S): fallthrough case int32(LABELANCHOR_SE): fallthrough case int32(LABELANCHOR_SW): bWidthBottom += (*TLabelframe)(unsafe.Pointer(labelframePtr)).FlabelReqHeight - *(*int32)(unsafe.Pointer(bp + 144)) default: bWidthLeft += (*TLabelframe)(unsafe.Pointer(labelframePtr)).FlabelReqWidth - *(*int32)(unsafe.Pointer(bp + 144)) break } } XTk_SetInternalBorderEx(tls, tkwin, bWidthLeft, bWidthRight, bWidthTop, bWidthBottom) _ComputeFrameGeometry(tls, framePtr) /* * A labelframe should request size for its label. */ if (*TFrame)(unsafe.Pointer(framePtr)).Ftype1 == int32(TYPE_LABELFRAME) { minwidth = (*TLabelframe)(unsafe.Pointer(labelframePtr)).FlabelReqWidth minheight = (*TLabelframe)(unsafe.Pointer(labelframePtr)).FlabelReqHeight padding = *(*int32)(unsafe.Pointer(bp + 148)) if *(*int32)(unsafe.Pointer(bp + 144)) > 0 { padding += *(*int32)(unsafe.Pointer(bp + 144)) + int32(LABELMARGIN) } padding *= int32(2) if (*TLabelframe)(unsafe.Pointer(labelframePtr)).FlabelAnchor >= int32(LABELANCHOR_N) && (*TLabelframe)(unsafe.Pointer(labelframePtr)).FlabelAnchor <= int32(LABELANCHOR_SW) { minwidth += padding minheight += *(*int32)(unsafe.Pointer(bp + 144)) + *(*int32)(unsafe.Pointer(bp + 148)) } else { minheight += padding minwidth += *(*int32)(unsafe.Pointer(bp + 144)) + *(*int32)(unsafe.Pointer(bp + 148)) } XTk_SetMinimumRequestSize(tls, tkwin, minwidth, minheight) } XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), (*TFrame)(unsafe.Pointer(framePtr)).Ftkwin, (*TFrame)(unsafe.Pointer(framePtr)).FwidthObj, bp+136) XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), (*TFrame)(unsafe.Pointer(framePtr)).Ftkwin, (*TFrame)(unsafe.Pointer(framePtr)).FheightObj, bp+140) if *(*int32)(unsafe.Pointer(bp + 136)) > 0 || *(*int32)(unsafe.Pointer(bp + 140)) > 0 { XTk_GeometryRequest(tls, tkwin, *(*int32)(unsafe.Pointer(bp + 136)), *(*int32)(unsafe.Pointer(bp + 140))) } if (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fflags&uint32(TK_MAPPED) != 0 { if !((*TFrame)(unsafe.Pointer(framePtr)).Fflags&libc.Int32FromInt32(REDRAW_PENDING) != 0) { libtcl9_0.XTcl_DoWhenIdle(tls, __ccgo_fp(_DisplayFrame), framePtr) } *(*int32)(unsafe.Pointer(framePtr + 192)) |= int32(REDRAW_PENDING) } } /* *---------------------------------------------------------------------- * * ComputeFrameGeometry -- * * This function is called to compute various geometrical information for * a frame, such as where various things get displayed. It's called when * the window is reconfigured. * * Results: * None. * * Side effects: * Display-related numbers get changed in *framePtr. * *---------------------------------------------------------------------- */ func _ComputeFrameGeometry(tls *libc.TLS, framePtr uintptr) { bp := tls.Alloc(16) defer tls.Free(16) /* Information about widget. */ var labelframePtr uintptr var maxHeight, maxWidth, otherHeight, otherHeightT, otherWidth, otherWidthT, padding int32 var tkwin TTk_Window var _ /* borderWidth at bp+0 */ int32 var _ /* highlightWidth at bp+4 */ int32 _, _, _, _, _, _, _, _, _ = labelframePtr, maxHeight, maxWidth, otherHeight, otherHeightT, otherWidth, otherWidthT, padding, tkwin labelframePtr = framePtr /* * We have nothing to do here unless there is a label. */ if (*TFrame)(unsafe.Pointer(framePtr)).Ftype1 != int32(TYPE_LABELFRAME) { return } if (*TLabelframe)(unsafe.Pointer(labelframePtr)).FtextPtr == libc.UintptrFromInt32(0) && (*TLabelframe)(unsafe.Pointer(labelframePtr)).FlabelWin == libc.UintptrFromInt32(0) { return } tkwin = (*TFrame)(unsafe.Pointer(framePtr)).Ftkwin /* * Calculate the available size for the label */ (*TLabelframe)(unsafe.Pointer(labelframePtr)).FlabelBox.Fwidth = libc.Uint16FromInt32((*TLabelframe)(unsafe.Pointer(labelframePtr)).FlabelReqWidth) (*TLabelframe)(unsafe.Pointer(labelframePtr)).FlabelBox.Fheight = libc.Uint16FromInt32((*TLabelframe)(unsafe.Pointer(labelframePtr)).FlabelReqHeight) XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), (*TFrame)(unsafe.Pointer(framePtr)).Ftkwin, (*TFrame)(unsafe.Pointer(framePtr)).FborderWidthObj, bp) XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), (*TFrame)(unsafe.Pointer(framePtr)).Ftkwin, (*TFrame)(unsafe.Pointer(framePtr)).FhighlightWidthObj, bp+4) padding = *(*int32)(unsafe.Pointer(bp + 4)) if *(*int32)(unsafe.Pointer(bp)) > 0 { padding += *(*int32)(unsafe.Pointer(bp)) + int32(LABELMARGIN) } padding *= int32(2) maxHeight = (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fchanges.Fheight maxWidth = (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fchanges.Fwidth if (*TLabelframe)(unsafe.Pointer(labelframePtr)).FlabelAnchor >= int32(LABELANCHOR_N) && (*TLabelframe)(unsafe.Pointer(labelframePtr)).FlabelAnchor <= int32(LABELANCHOR_SW) { maxWidth -= padding if maxWidth < int32(1) { maxWidth = int32(1) } } else { maxHeight -= padding if maxHeight < int32(1) { maxHeight = int32(1) } } if libc.Int32FromUint16((*TLabelframe)(unsafe.Pointer(labelframePtr)).FlabelBox.Fwidth) > maxWidth { (*TLabelframe)(unsafe.Pointer(labelframePtr)).FlabelBox.Fwidth = libc.Uint16FromInt32(maxWidth) } if libc.Int32FromUint16((*TLabelframe)(unsafe.Pointer(labelframePtr)).FlabelBox.Fheight) > maxHeight { (*TLabelframe)(unsafe.Pointer(labelframePtr)).FlabelBox.Fheight = libc.Uint16FromInt32(maxHeight) } /* * Calculate label and text position. The text's position is based on the * requested size (= the text's real size) to get proper alignment if the * text does not fit. */ otherWidth = (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fchanges.Fwidth - libc.Int32FromUint16((*TLabelframe)(unsafe.Pointer(labelframePtr)).FlabelBox.Fwidth) otherHeight = (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fchanges.Fheight - libc.Int32FromUint16((*TLabelframe)(unsafe.Pointer(labelframePtr)).FlabelBox.Fheight) otherWidthT = (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fchanges.Fwidth - (*TLabelframe)(unsafe.Pointer(labelframePtr)).FlabelReqWidth otherHeightT = (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fchanges.Fheight - (*TLabelframe)(unsafe.Pointer(labelframePtr)).FlabelReqHeight padding = *(*int32)(unsafe.Pointer(bp + 4)) switch (*TLabelframe)(unsafe.Pointer(labelframePtr)).FlabelAnchor { case int32(LABELANCHOR_E): fallthrough case int32(LABELANCHOR_EN): fallthrough case int32(LABELANCHOR_ES): (*TLabelframe)(unsafe.Pointer(labelframePtr)).FlabelTextX = otherWidthT - padding (*TLabelframe)(unsafe.Pointer(labelframePtr)).FlabelBox.Fx = int16(otherWidth - padding) case int32(LABELANCHOR_N): fallthrough case int32(LABELANCHOR_NE): fallthrough case int32(LABELANCHOR_NW): (*TLabelframe)(unsafe.Pointer(labelframePtr)).FlabelTextY = padding (*TLabelframe)(unsafe.Pointer(labelframePtr)).FlabelBox.Fy = int16(padding) case int32(LABELANCHOR_S): fallthrough case int32(LABELANCHOR_SE): fallthrough case int32(LABELANCHOR_SW): (*TLabelframe)(unsafe.Pointer(labelframePtr)).FlabelTextY = otherHeightT - padding (*TLabelframe)(unsafe.Pointer(labelframePtr)).FlabelBox.Fy = int16(otherHeight - padding) default: (*TLabelframe)(unsafe.Pointer(labelframePtr)).FlabelTextX = padding (*TLabelframe)(unsafe.Pointer(labelframePtr)).FlabelBox.Fx = int16(padding) break } if *(*int32)(unsafe.Pointer(bp)) > 0 { padding += *(*int32)(unsafe.Pointer(bp)) + int32(LABELMARGIN) } switch (*TLabelframe)(unsafe.Pointer(labelframePtr)).FlabelAnchor { case int32(LABELANCHOR_NW): fallthrough case int32(LABELANCHOR_SW): (*TLabelframe)(unsafe.Pointer(labelframePtr)).FlabelTextX = padding (*TLabelframe)(unsafe.Pointer(labelframePtr)).FlabelBox.Fx = int16(padding) case int32(LABELANCHOR_N): fallthrough case int32(LABELANCHOR_S): (*TLabelframe)(unsafe.Pointer(labelframePtr)).FlabelTextX = otherWidthT / int32(2) (*TLabelframe)(unsafe.Pointer(labelframePtr)).FlabelBox.Fx = int16(otherWidth / int32(2)) case int32(LABELANCHOR_NE): fallthrough case int32(LABELANCHOR_SE): (*TLabelframe)(unsafe.Pointer(labelframePtr)).FlabelTextX = otherWidthT - padding (*TLabelframe)(unsafe.Pointer(labelframePtr)).FlabelBox.Fx = int16(otherWidth - padding) case int32(LABELANCHOR_EN): fallthrough case int32(LABELANCHOR_WN): (*TLabelframe)(unsafe.Pointer(labelframePtr)).FlabelTextY = padding (*TLabelframe)(unsafe.Pointer(labelframePtr)).FlabelBox.Fy = int16(padding) case int32(LABELANCHOR_E): fallthrough case int32(LABELANCHOR_W): (*TLabelframe)(unsafe.Pointer(labelframePtr)).FlabelTextY = otherHeightT / int32(2) (*TLabelframe)(unsafe.Pointer(labelframePtr)).FlabelBox.Fy = int16(otherHeight / int32(2)) default: (*TLabelframe)(unsafe.Pointer(labelframePtr)).FlabelTextY = otherHeightT - padding (*TLabelframe)(unsafe.Pointer(labelframePtr)).FlabelBox.Fy = int16(otherHeight - padding) break } } /* *---------------------------------------------------------------------- * * DisplayFrame -- * * This function is invoked to display a frame widget. * * Results: * None. * * Side effects: * Commands are output to X to display the frame in its current mode. * *---------------------------------------------------------------------- */ func _DisplayFrame(tls *libc.TLS, clientData uintptr) { bp := tls.Alloc(16) defer tls.Free(16) /* Information about widget. */ var bdX1, bdX2, bdY1, bdY2, useClipping, v1, v2, v5 int32 var bgGC, fgGC TGC var framePtr, labelframePtr uintptr var pixmap TPixmap var tkwin TTk_Window var _ /* borderWidth at bp+0 */ int32 var _ /* highlightWidth at bp+4 */ int32 _, _, _, _, _, _, _, _, _, _, _, _, _, _ = bdX1, bdX2, bdY1, bdY2, bgGC, fgGC, framePtr, labelframePtr, pixmap, tkwin, useClipping, v1, v2, v5 framePtr = clientData tkwin = (*TFrame)(unsafe.Pointer(framePtr)).Ftkwin useClipping = False *(*int32)(unsafe.Pointer(framePtr + 192)) &= ^libc.Int32FromInt32(REDRAW_PENDING) if (*TFrame)(unsafe.Pointer(framePtr)).Ftkwin == libc.UintptrFromInt32(0) || !((*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fflags&libc.Uint32FromInt32(TK_MAPPED) != 0) { return } /* * Highlight shall always be drawn if it exists, so do that first. */ XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), (*TFrame)(unsafe.Pointer(framePtr)).Ftkwin, (*TFrame)(unsafe.Pointer(framePtr)).FhighlightWidthObj, bp+4) if *(*int32)(unsafe.Pointer(bp + 4)) > 0 { bgGC = XTk_GCForColor(tls, (*TFrame)(unsafe.Pointer(framePtr)).FhighlightBgColorPtr, (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fwindow) if (*TFrame)(unsafe.Pointer(framePtr)).Fflags&int32(GOT_FOCUS2) != 0 { fgGC = XTk_GCForColor(tls, (*TFrame)(unsafe.Pointer(framePtr)).FhighlightColorPtr, (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fwindow) XTk_DrawHighlightBorder(tls, tkwin, fgGC, bgGC, *(*int32)(unsafe.Pointer(bp + 4)), (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fwindow) } else { XTk_DrawHighlightBorder(tls, tkwin, bgGC, bgGC, *(*int32)(unsafe.Pointer(bp + 4)), (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fwindow) } } /* * If -background is set to "", no interior is drawn. */ if (*TFrame)(unsafe.Pointer(framePtr)).Fborder == libc.UintptrFromInt32(0) { return } /* * In order to avoid screen flashes, this function redraws the frame into * off-screen memory, then copies it back on-screen in a single operation. * This means there's no point in time where the on-screen image has been * cleared. * Also, ensure that the pixmap size is at least 1x1 pixels to prevent * crashes, see [610aa08858]. */ if (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fchanges.Fwidth > 0 { v1 = (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fchanges.Fwidth } else { v1 = int32(1) } if (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fchanges.Fheight > 0 { v2 = (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fchanges.Fheight } else { v2 = int32(1) } pixmap = XTk_GetPixmap(tls, (*TFrame)(unsafe.Pointer(framePtr)).Fdisplay, (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fwindow, v1, v2, (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fdepth) XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), (*TFrame)(unsafe.Pointer(framePtr)).Ftkwin, (*TFrame)(unsafe.Pointer(framePtr)).FborderWidthObj, bp) if !((*TFrame)(unsafe.Pointer(framePtr)).Ftype1 != int32(TYPE_LABELFRAME)) { goto _3 } /* * Pass to platform specific draw function. In general, it just draws * a simple rectangle, but it may "theme" the background. */ goto noLabel noLabel: ; XTkpDrawFrameEx(tls, tkwin, pixmap, (*TFrame)(unsafe.Pointer(framePtr)).Fborder, *(*int32)(unsafe.Pointer(bp + 4)), *(*int32)(unsafe.Pointer(bp)), (*TFrame)(unsafe.Pointer(framePtr)).Frelief) if (*TFrame)(unsafe.Pointer(framePtr)).Fbgimg != 0 { _DrawFrameBackground(tls, tkwin, pixmap, *(*int32)(unsafe.Pointer(bp + 4)), *(*int32)(unsafe.Pointer(bp)), (*TFrame)(unsafe.Pointer(framePtr)).Fbgimg, (*TFrame)(unsafe.Pointer(framePtr)).Ftile) } goto _4 _3: ; labelframePtr = framePtr if (*TLabelframe)(unsafe.Pointer(labelframePtr)).FtextPtr == libc.UintptrFromInt32(0) && (*TLabelframe)(unsafe.Pointer(labelframePtr)).FlabelWin == libc.UintptrFromInt32(0) { goto noLabel } /* * Clear the pixmap. */ XTk_Fill3DRectangle(tls, tkwin, pixmap, (*TFrame)(unsafe.Pointer(framePtr)).Fborder, 0, 0, (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fchanges.Fwidth, (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fchanges.Fheight, 0, TK_RELIEF_FLAT) /* * Calculate how the label affects the border's position. */ v5 = *(*int32)(unsafe.Pointer(bp + 4)) bdY1 = v5 bdX1 = v5 bdX2 = (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fchanges.Fwidth - *(*int32)(unsafe.Pointer(bp + 4)) bdY2 = (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fchanges.Fheight - *(*int32)(unsafe.Pointer(bp + 4)) switch (*TLabelframe)(unsafe.Pointer(labelframePtr)).FlabelAnchor { case int32(LABELANCHOR_E): fallthrough case int32(LABELANCHOR_EN): fallthrough case int32(LABELANCHOR_ES): bdX2 -= (libc.Int32FromUint16((*TLabelframe)(unsafe.Pointer(labelframePtr)).FlabelBox.Fwidth) - *(*int32)(unsafe.Pointer(bp))) / int32(2) case int32(LABELANCHOR_N): fallthrough case int32(LABELANCHOR_NE): fallthrough case int32(LABELANCHOR_NW): /* * Since the glyphs of the text tend to be in the lower part we * favor a lower border position by rounding up. */ bdY1 += (libc.Int32FromUint16((*TLabelframe)(unsafe.Pointer(labelframePtr)).FlabelBox.Fheight) - *(*int32)(unsafe.Pointer(bp)) + int32(1)) / int32(2) case int32(LABELANCHOR_S): fallthrough case int32(LABELANCHOR_SE): fallthrough case int32(LABELANCHOR_SW): bdY2 -= (libc.Int32FromUint16((*TLabelframe)(unsafe.Pointer(labelframePtr)).FlabelBox.Fheight) - *(*int32)(unsafe.Pointer(bp))) / int32(2) default: bdX1 += (libc.Int32FromUint16((*TLabelframe)(unsafe.Pointer(labelframePtr)).FlabelBox.Fwidth) - *(*int32)(unsafe.Pointer(bp))) / int32(2) break } /* * Draw border */ XTk_Draw3DRectangle(tls, tkwin, pixmap, (*TFrame)(unsafe.Pointer(framePtr)).Fborder, bdX1, bdY1, bdX2-bdX1, bdY2-bdY1, *(*int32)(unsafe.Pointer(bp)), (*TFrame)(unsafe.Pointer(framePtr)).Frelief) if (*TLabelframe)(unsafe.Pointer(labelframePtr)).FlabelWin == libc.UintptrFromInt32(0) { /* * Clear behind the label */ XTk_Fill3DRectangle(tls, tkwin, pixmap, (*TFrame)(unsafe.Pointer(framePtr)).Fborder, int32((*TLabelframe)(unsafe.Pointer(labelframePtr)).FlabelBox.Fx), int32((*TLabelframe)(unsafe.Pointer(labelframePtr)).FlabelBox.Fy), libc.Int32FromUint16((*TLabelframe)(unsafe.Pointer(labelframePtr)).FlabelBox.Fwidth), libc.Int32FromUint16((*TLabelframe)(unsafe.Pointer(labelframePtr)).FlabelBox.Fheight), 0, TK_RELIEF_FLAT) /* * Draw label. If there is not room for the entire label, use * clipping to get a nice appearance. */ if libc.Int32FromUint16((*TLabelframe)(unsafe.Pointer(labelframePtr)).FlabelBox.Fwidth) < (*TLabelframe)(unsafe.Pointer(labelframePtr)).FlabelReqWidth || libc.Int32FromUint16((*TLabelframe)(unsafe.Pointer(labelframePtr)).FlabelBox.Fheight) < (*TLabelframe)(unsafe.Pointer(labelframePtr)).FlabelReqHeight { useClipping = int32(True) libx11.XXSetClipRectangles(tls, (*TFrame)(unsafe.Pointer(framePtr)).Fdisplay, (*TLabelframe)(unsafe.Pointer(labelframePtr)).FtextGC, 0, 0, labelframePtr+304, int32(1), Unsorted) } XTk_DrawTextLayout(tls, (*TFrame)(unsafe.Pointer(framePtr)).Fdisplay, pixmap, (*TLabelframe)(unsafe.Pointer(labelframePtr)).FtextGC, (*TLabelframe)(unsafe.Pointer(labelframePtr)).FtextLayout, (*TLabelframe)(unsafe.Pointer(labelframePtr)).FlabelTextX+int32(LABELSPACING), (*TLabelframe)(unsafe.Pointer(labelframePtr)).FlabelTextY+int32(LABELSPACING), 0, int64(-int32(1))) if useClipping != 0 { libx11.XXSetClipMask(tls, (*TFrame)(unsafe.Pointer(framePtr)).Fdisplay, (*TLabelframe)(unsafe.Pointer(labelframePtr)).FtextGC, uint64(0)) } } else { /* * Reposition and map the window (but in different ways depending * on whether the frame is the window's parent). */ if (*TFrame)(unsafe.Pointer(framePtr)).Ftkwin == (*TTk_FakeWin)(unsafe.Pointer((*TLabelframe)(unsafe.Pointer(labelframePtr)).FlabelWin)).FparentPtr { if int32((*TLabelframe)(unsafe.Pointer(labelframePtr)).FlabelBox.Fx) != (*TTk_FakeWin)(unsafe.Pointer((*TLabelframe)(unsafe.Pointer(labelframePtr)).FlabelWin)).Fchanges.Fx || int32((*TLabelframe)(unsafe.Pointer(labelframePtr)).FlabelBox.Fy) != (*TTk_FakeWin)(unsafe.Pointer((*TLabelframe)(unsafe.Pointer(labelframePtr)).FlabelWin)).Fchanges.Fy || libc.Int32FromUint16((*TLabelframe)(unsafe.Pointer(labelframePtr)).FlabelBox.Fwidth) != (*TTk_FakeWin)(unsafe.Pointer((*TLabelframe)(unsafe.Pointer(labelframePtr)).FlabelWin)).Fchanges.Fwidth || libc.Int32FromUint16((*TLabelframe)(unsafe.Pointer(labelframePtr)).FlabelBox.Fheight) != (*TTk_FakeWin)(unsafe.Pointer((*TLabelframe)(unsafe.Pointer(labelframePtr)).FlabelWin)).Fchanges.Fheight { XTk_MoveResizeWindow(tls, (*TLabelframe)(unsafe.Pointer(labelframePtr)).FlabelWin, int32((*TLabelframe)(unsafe.Pointer(labelframePtr)).FlabelBox.Fx), int32((*TLabelframe)(unsafe.Pointer(labelframePtr)).FlabelBox.Fy), libc.Int32FromUint16((*TLabelframe)(unsafe.Pointer(labelframePtr)).FlabelBox.Fwidth), libc.Int32FromUint16((*TLabelframe)(unsafe.Pointer(labelframePtr)).FlabelBox.Fheight)) } XTk_MapWindow(tls, (*TLabelframe)(unsafe.Pointer(labelframePtr)).FlabelWin) } else { XTk_MaintainGeometry(tls, (*TLabelframe)(unsafe.Pointer(labelframePtr)).FlabelWin, (*TFrame)(unsafe.Pointer(framePtr)).Ftkwin, int32((*TLabelframe)(unsafe.Pointer(labelframePtr)).FlabelBox.Fx), int32((*TLabelframe)(unsafe.Pointer(labelframePtr)).FlabelBox.Fy), libc.Int32FromUint16((*TLabelframe)(unsafe.Pointer(labelframePtr)).FlabelBox.Fwidth), libc.Int32FromUint16((*TLabelframe)(unsafe.Pointer(labelframePtr)).FlabelBox.Fheight)) } } _4: ; /* * Everything's been redisplayed; now copy the pixmap onto the screen and * free up the pixmap. */ libx11.XXCopyArea(tls, (*TFrame)(unsafe.Pointer(framePtr)).Fdisplay, pixmap, (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fwindow, (*TFrame)(unsafe.Pointer(framePtr)).FcopyGC, *(*int32)(unsafe.Pointer(bp + 4)), *(*int32)(unsafe.Pointer(bp + 4)), libc.Uint32FromInt32((*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fchanges.Fwidth-libc.Int32FromInt32(2)**(*int32)(unsafe.Pointer(bp + 4))), libc.Uint32FromInt32((*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fchanges.Fheight-libc.Int32FromInt32(2)**(*int32)(unsafe.Pointer(bp + 4))), *(*int32)(unsafe.Pointer(bp + 4)), *(*int32)(unsafe.Pointer(bp + 4))) XTk_FreePixmap(tls, (*TFrame)(unsafe.Pointer(framePtr)).Fdisplay, pixmap) } /* *---------------------------------------------------------------------- * * TkpDrawFrame -- * * This procedure draws the rectangular frame area. * * Results: * None. * * Side effects: * Draws inside the tkwin area. * *---------------------------------------------------------------------- */ func XTkpDrawFrame(tls *libc.TLS, tkwin TTk_Window, border TTk_3DBorder, highlightWidth int32, borderWidth int32, relief int32) { /* * Legacy shim to allow for external callers. Internal ones use * non-exposed TkpDrawFrameEx directly so they can use double-buffering. */ XTkpDrawFrameEx(tls, tkwin, (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fwindow, border, highlightWidth, borderWidth, relief) } /* *-------------------------------------------------------------- * * FrameEventProc -- * * This function is invoked by the Tk dispatcher on structure changes to * a frame. For frames with 3D borders, this function is also invoked for * exposures. * * Results: * None. * * Side effects: * When the window gets deleted, internal structures get cleaned up. * When it gets exposed, it is redisplayed. * *-------------------------------------------------------------- */ func _FrameEventProc(tls *libc.TLS, clientData uintptr, eventPtr uintptr) { bp := tls.Alloc(16) defer tls.Free(16) /* Information about event. */ var _objPtr, framePtr, v2, v3 uintptr var v1 TTcl_Size var _ /* highlightWidth at bp+0 */ int32 var _ /* highlightWidth at bp+4 */ int32 _, _, _, _, _ = _objPtr, framePtr, v1, v2, v3 framePtr = clientData if (*TXEvent)(unsafe.Pointer(eventPtr)).Ftype1 == int32(Expose) && (*(*TXExposeEvent)(unsafe.Pointer(eventPtr))).Fcount == 0 { goto redraw } else { if (*TXEvent)(unsafe.Pointer(eventPtr)).Ftype1 == int32(ConfigureNotify) { _ComputeFrameGeometry(tls, framePtr) goto redraw } else { if (*TXEvent)(unsafe.Pointer(eventPtr)).Ftype1 == int32(DestroyNotify) { if (*TFrame)(unsafe.Pointer(framePtr)).FmenuNameObj != libc.UintptrFromInt32(0) { XTk_SetWindowMenubar(tls, (*TFrame)(unsafe.Pointer(framePtr)).Finterp, (*TFrame)(unsafe.Pointer(framePtr)).Ftkwin, libtcl9_0.XTcl_GetStringFromObj(tls, (*TFrame)(unsafe.Pointer(framePtr)).FmenuNameObj, libc.UintptrFromInt32(0)), libc.UintptrFromInt32(0)) _objPtr = (*TFrame)(unsafe.Pointer(framePtr)).FmenuNameObj v2 = _objPtr v1 = *(*TTcl_Size)(unsafe.Pointer(v2)) *(*TTcl_Size)(unsafe.Pointer(v2))-- if v1 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr) } (*TFrame)(unsafe.Pointer(framePtr)).FmenuNameObj = libc.UintptrFromInt32(0) } if (*TFrame)(unsafe.Pointer(framePtr)).Ftkwin != libc.UintptrFromInt32(0) { /* * If this window is a container, then this event could be coming * from the embedded application, in which case Tk_DestroyWindow * hasn't been called yet. When Tk_DestroyWindow is called later, * then another destroy event will be generated. We need to be * sure we ignore the second event, since the frame could be gone * by then. To do so, delete the event handler explicitly * (normally it's done implicitly by Tk_DestroyWindow). */ /* * Since the tkwin pointer will be gone when we reach * DestroyFrame, we must free all options now. */ _DestroyFramePartly(tls, framePtr) XTk_DeleteEventHandler(tls, (*TFrame)(unsafe.Pointer(framePtr)).Ftkwin, libc.Uint64FromInt64(libc.Int64FromInt64(1)< 0 { goto redraw } } } else { if (*TXEvent)(unsafe.Pointer(eventPtr)).Ftype1 == int32(FocusOut) { if (*(*TXFocusChangeEvent)(unsafe.Pointer(eventPtr))).Fdetail != int32(NotifyInferior) { *(*int32)(unsafe.Pointer(framePtr + 192)) &= ^libc.Int32FromInt32(GOT_FOCUS2) XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), (*TFrame)(unsafe.Pointer(framePtr)).Ftkwin, (*TFrame)(unsafe.Pointer(framePtr)).FhighlightWidthObj, bp+4) if *(*int32)(unsafe.Pointer(bp + 4)) > 0 { goto redraw } } } else { if (*TXEvent)(unsafe.Pointer(eventPtr)).Ftype1 == libc.Int32FromInt32(MappingNotify)+libc.Int32FromInt32(2) { if (*TFrame)(unsafe.Pointer(framePtr)).FmenuNameObj != 0 { v3 = libtcl9_0.XTcl_GetStringFromObj(tls, (*TFrame)(unsafe.Pointer(framePtr)).FmenuNameObj, libc.UintptrFromInt32(0)) } else { v3 = libc.UintptrFromInt32(0) } XTk_SetMainMenubar(tls, (*TFrame)(unsafe.Pointer(framePtr)).Finterp, (*TFrame)(unsafe.Pointer(framePtr)).Ftkwin, v3) } } } } } } return goto redraw redraw: ; if (*TFrame)(unsafe.Pointer(framePtr)).Ftkwin != libc.UintptrFromInt32(0) && !((*TFrame)(unsafe.Pointer(framePtr)).Fflags&libc.Int32FromInt32(REDRAW_PENDING) != 0) { libtcl9_0.XTcl_DoWhenIdle(tls, __ccgo_fp(_DisplayFrame), framePtr) *(*int32)(unsafe.Pointer(framePtr + 192)) |= int32(REDRAW_PENDING) } } /* *---------------------------------------------------------------------- * * FrameCmdDeletedProc -- * * This function is invoked when a widget command is deleted. If the * widget isn't already in the process of being destroyed, this command * destroys it. * * Results: * None. * * Side effects: * The widget is destroyed. * *---------------------------------------------------------------------- */ func _FrameCmdDeletedProc(tls *libc.TLS, clientData uintptr) { /* Pointer to widget record for widget. */ var _objPtr, framePtr, v2 uintptr var tkwin TTk_Window var v1 TTcl_Size _, _, _, _, _ = _objPtr, framePtr, tkwin, v1, v2 framePtr = clientData tkwin = (*TFrame)(unsafe.Pointer(framePtr)).Ftkwin if (*TFrame)(unsafe.Pointer(framePtr)).FmenuNameObj != libc.UintptrFromInt32(0) { XTk_SetWindowMenubar(tls, (*TFrame)(unsafe.Pointer(framePtr)).Finterp, (*TFrame)(unsafe.Pointer(framePtr)).Ftkwin, libtcl9_0.XTcl_GetStringFromObj(tls, (*TFrame)(unsafe.Pointer(framePtr)).FmenuNameObj, libc.UintptrFromInt32(0)), libc.UintptrFromInt32(0)) _objPtr = (*TFrame)(unsafe.Pointer(framePtr)).FmenuNameObj v2 = _objPtr v1 = *(*TTcl_Size)(unsafe.Pointer(v2)) *(*TTcl_Size)(unsafe.Pointer(v2))-- if v1 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr) } (*TFrame)(unsafe.Pointer(framePtr)).FmenuNameObj = libc.UintptrFromInt32(0) } /* * This function could be invoked either because the window was destroyed * and the command was then deleted (in which case tkwin is NULL) or * because the command was deleted, and then this function destroys the * widget. */ if tkwin != libc.UintptrFromInt32(0) { /* * Some options need tkwin to be freed, so we free them here, before * setting tkwin to NULL. */ _DestroyFramePartly(tls, framePtr) (*TFrame)(unsafe.Pointer(framePtr)).Ftkwin = libc.UintptrFromInt32(0) XTk_DestroyWindow(tls, tkwin) } } /* *---------------------------------------------------------------------- * * MapFrame -- * * This function is invoked as a when-idle handler to map a newly-created * top-level frame. * * Results: * None. * * Side effects: * The frame given by the clientData argument is mapped. * *---------------------------------------------------------------------- */ func _MapFrame(tls *libc.TLS, clientData uintptr) { /* Pointer to frame structure. */ var framePtr uintptr _ = framePtr framePtr = clientData /* * Wait for all other background events to be processed before mapping * window. This ensures that the window's correct geometry will have been * determined before it is first mapped, so that the window manager * doesn't get a false idea of its desired geometry. */ libtcl9_0.XTcl_Preserve(tls, framePtr) for int32(1) != 0 { if libtcl9_0.XTcl_DoOneEvent(tls, libc.Int32FromInt32(1)< width { w = width + bw - x } y = bw for { if !(y < height+bw) { break } h = *(*int32)(unsafe.Pointer(bp + 4)) if y-bw+*(*int32)(unsafe.Pointer(bp + 4)) > height { h = height + bw - y } XTk_RedrawImage(tls, bgimg, 0, 0, w, h, pixmap, x, y) goto _2 _2: ; y += *(*int32)(unsafe.Pointer(bp + 4)) } goto _1 _1: ; x += *(*int32)(unsafe.Pointer(bp)) } } else { if width > *(*int32)(unsafe.Pointer(bp)) { x1 = 0 xOff = ((*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fchanges.Fwidth - *(*int32)(unsafe.Pointer(bp))) / int32(2) w1 = *(*int32)(unsafe.Pointer(bp)) } else { x1 = (*(*int32)(unsafe.Pointer(bp)) - width) / int32(2) xOff = bw w1 = width } if height > *(*int32)(unsafe.Pointer(bp + 4)) { y1 = 0 yOff = ((*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fchanges.Fheight - *(*int32)(unsafe.Pointer(bp + 4))) / int32(2) h1 = *(*int32)(unsafe.Pointer(bp + 4)) } else { y1 = (*(*int32)(unsafe.Pointer(bp + 4)) - height) / int32(2) yOff = bw h1 = height } XTk_RedrawImage(tls, bgimg, x1, y1, w1, h1, pixmap, xOff, yOff) } } const GOT_FOCUS3 = 8 const LISTBOX_DELETED = 32 const MAXWIDTH_IS_STALE = 16 const UPDATE_H_SCROLLBAR = 4 const UPDATE_V_SCROLLBAR = 2 /* * Local Variables: * mode: c * c-basic-offset: 4 * fill-column: 78 * End: */ /* * default.h -- * * This file defines the defaults for all options for all of * the Tk widgets. * * Copyright © 1991-1994 The Regents of the University of California. * Copyright © 1994 Sun Microsystems, Inc. * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. */ /* * tkUnixDefault.h -- * * This file defines the defaults for all options for all of * the Tk widgets. * * Copyright © 1991-1994 The Regents of the University of California. * Copyright © 1994-1997 Sun Microsystems, Inc. * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. */ /* * The definitions below provide symbolic names for the default colors. * NORMAL_BG - Normal background color. * ACTIVE_BG - Background color when widget is active. * SELECT_BG - Background color for selected text. * TROUGH - Background color for troughs in scales and scrollbars. * INDICATOR - Color for indicator when button is selected. * DISABLED - Foreground color when widget is disabled. * PLACEHOLDER_FG - Foreground color for placeholder text. */ /* * Defaults for labels, buttons, checkbuttons, and radiobuttons: */ /* * Defaults for canvases: */ /* * Defaults for entries: */ /* * Defaults for frames: */ /* * Defaults for labelframes: */ /* * Defaults for listboxes: */ /* * Defaults for individual entries of menus: */ /* * Defaults for menus overall: */ /* * Defaults for menubuttons: */ /* * Defaults for messages: */ /* * Defaults for panedwindows */ /* * Defaults for panedwindow panes */ /* * Defaults for scales: */ /* * Defaults for scrollbars: */ /* * Defaults for texts: */ /* * Defaults for canvas text: */ /* * Defaults for canvas items * (arcs, bitmaps, lines, polygons, rectangles, and ovals): */ /* * Defaults for toplevels (most of the defaults for frames also apply * to toplevels): */ /* * Defaults for busy windows: */ type TListboxOptionTables = struct { FlistboxOptionTable TTk_OptionTable FitemAttrOptionTable TTk_OptionTable } /* * A data structure of the following type is kept for each listbox widget * managed by this file: */ type TListbox = struct { Ftkwin TTk_Window Fdisplay uintptr Finterp uintptr FwidgetCmd TTcl_Command FoptionTable TTk_OptionTable FitemAttrOptionTable TTk_OptionTable FlistVarNameObj uintptr FlistObj uintptr FnElements TTcl_Size Fselection uintptr FitemAttrTable uintptr FnormalBorder TTk_3DBorder FborderWidthObj uintptr Frelief int32 FhighlightWidthObj uintptr FhighlightBgColorPtr uintptr FhighlightColorPtr uintptr Finset int32 Ftkfont TTk_Font FfgColorPtr uintptr FdfgColorPtr uintptr FtextGC TGC FselBorder TTk_3DBorder FselBorderWidthObj uintptr FselFgColorPtr uintptr FselTextGC TGC Fwidth int32 Fheight int32 FlineHeight int32 FtopIndex int32 FfullLines int32 FpartialLine int32 FsetGrid int32 FmaxWidth int32 FxScrollUnit int32 FxOffset int32 FselectModeObj uintptr FnumSelected int32 FselectAnchor int32 FexportSelection int32 Factive int32 FactiveStyle int32 FscanMarkX int32 FscanMarkY int32 FscanMarkXOffset int32 FscanMarkYIndex int32 Fcursor TTk_Cursor FtakeFocusObj uintptr FyScrollCmdObj uintptr FxScrollCmdObj uintptr Fstate int32 Fgray TPixmap Fflags int32 Fjustify TTk_Justify } /* * How to encode the keys for the hash tables used to store what items are * selected and what the attributes are. */ /* * ItemAttr structures are used to store item configuration information for * the items in a listbox */ type TItemAttr = struct { Fborder TTk_3DBorder FselBorder TTk_3DBorder FfgColor uintptr FselFgColor uintptr } type activeStyle = int32 const ACTIVE_STYLE_DOTBOX = 0 const ACTIVE_STYLE_NONE = 1 const ACTIVE_STYLE_UNDERLINE = 2 var _activeStyleStrings = [4]uintptr{ 0: __ccgo_ts + 23458, 1: __ccgo_ts + 8223, 2: __ccgo_ts + 9388, 3: libc.UintptrFromInt32(0), } /* * The optionSpecs table defines the valid configuration options for the * listbox widget. */ var _optionSpecs3 = [29]TTk_OptionSpec{ 0: { Ftype1: int32(TK_OPTION_STRING_TABLE), FoptionName: __ccgo_ts + 23465, FdbName: __ccgo_ts + 23478, FdbClass: __ccgo_ts + 23490, FdefValue: __ccgo_ts + 23458, FobjOffset: int64(-libc.Int32FromInt32(1)), FinternalOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 272)), FclientData: uintptr(unsafe.Pointer(&_activeStyleStrings)), }, 1: { Ftype1: int32(TK_OPTION_BORDER), FoptionName: __ccgo_ts + 19898, FdbName: __ccgo_ts + 19910, FdbClass: __ccgo_ts + 19872, FdefValue: __ccgo_ts + 19883, FobjOffset: int64(-libc.Int32FromInt32(1)), FinternalOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 88)), FclientData: __ccgo_ts + 19883, }, 2: { Ftype1: int32(TK_OPTION_SYNONYM), FoptionName: __ccgo_ts + 19929, FinternalOffset: int64(-libc.Int32FromInt32(1)), FclientData: __ccgo_ts + 2814, }, 3: { Ftype1: int32(TK_OPTION_SYNONYM), FoptionName: __ccgo_ts + 19933, FinternalOffset: int64(-libc.Int32FromInt32(1)), FclientData: __ccgo_ts + 19898, }, 4: { Ftype1: int32(TK_OPTION_PIXELS), FoptionName: __ccgo_ts + 2814, FdbName: __ccgo_ts + 19952, FdbClass: __ccgo_ts + 19964, FdefValue: __ccgo_ts + 14538, FobjOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 96)), FinternalOffset: int64(-libc.Int32FromInt32(1)), }, 5: { Ftype1: int32(TK_OPTION_CURSOR), FoptionName: __ccgo_ts + 4638, FdbName: __ccgo_ts + 4646, FdbClass: __ccgo_ts + 4653, FdefValue: __ccgo_ts + 195, FobjOffset: int64(-libc.Int32FromInt32(1)), FinternalOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 296)), Fflags: int32(TCL_NULL_OK), }, 6: { Ftype1: int32(TK_OPTION_COLOR), FoptionName: __ccgo_ts + 20004, FdbName: __ccgo_ts + 20024, FdbClass: __ccgo_ts + 20043, FdefValue: __ccgo_ts + 20062, FobjOffset: int64(-libc.Int32FromInt32(1)), FinternalOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 160)), Fflags: int32(TCL_NULL_OK), }, 7: { FoptionName: __ccgo_ts + 21164, FdbName: __ccgo_ts + 21181, FdbClass: __ccgo_ts + 21197, FdefValue: __ccgo_ts + 14538, FobjOffset: int64(-libc.Int32FromInt32(1)), FinternalOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 264)), }, 8: { Ftype1: int32(TK_OPTION_SYNONYM), FoptionName: __ccgo_ts + 20070, FdbName: __ccgo_ts + 20074, FinternalOffset: int64(-libc.Int32FromInt32(1)), FclientData: __ccgo_ts + 20085, }, 9: { Ftype1: int32(TK_OPTION_FONT), FoptionName: __ccgo_ts + 20097, FdbName: __ccgo_ts + 9358, FdbClass: __ccgo_ts + 20103, FdefValue: __ccgo_ts + 20108, FobjOffset: int64(-libc.Int32FromInt32(1)), FinternalOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 144)), }, 10: { Ftype1: int32(TK_OPTION_COLOR), FoptionName: __ccgo_ts + 20085, FdbName: __ccgo_ts + 20074, FdbClass: __ccgo_ts + 19810, FdefValue: __ccgo_ts + 19829, FobjOffset: int64(-libc.Int32FromInt32(1)), FinternalOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 152)), }, 11: { Ftype1: int32(TK_OPTION_INT), FoptionName: __ccgo_ts + 2870, FdbName: __ccgo_ts + 6172, FdbClass: __ccgo_ts + 20122, FdefValue: __ccgo_ts + 23502, FobjOffset: int64(-libc.Int32FromInt32(1)), FinternalOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 212)), }, 12: { Ftype1: int32(TK_OPTION_COLOR), FoptionName: __ccgo_ts + 20129, FdbName: __ccgo_ts + 20150, FdbClass: __ccgo_ts + 20170, FdefValue: __ccgo_ts + 19921, FobjOffset: int64(-libc.Int32FromInt32(1)), FinternalOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 120)), }, 13: { Ftype1: int32(TK_OPTION_COLOR), FoptionName: __ccgo_ts + 20190, FdbName: __ccgo_ts + 20206, FdbClass: __ccgo_ts + 20221, FdefValue: __ccgo_ts + 19829, FobjOffset: int64(-libc.Int32FromInt32(1)), FinternalOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 128)), }, 14: { Ftype1: int32(TK_OPTION_PIXELS), FoptionName: __ccgo_ts + 20236, FdbName: __ccgo_ts + 20256, FdbClass: __ccgo_ts + 20275, FdefValue: __ccgo_ts + 14538, FobjOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 112)), FinternalOffset: int64(-libc.Int32FromInt32(1)), }, 15: { Ftype1: int32(TK_OPTION_JUSTIFY), FoptionName: __ccgo_ts + 20307, FdbName: __ccgo_ts + 20316, FdbClass: __ccgo_ts + 20324, FdefValue: __ccgo_ts + 10966, FobjOffset: int64(-libc.Int32FromInt32(1)), FinternalOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 348)), }, 16: { Ftype1: int32(TK_OPTION_RELIEF), FoptionName: __ccgo_ts + 20346, FdbName: __ccgo_ts + 82, FdbClass: __ccgo_ts + 20354, FdefValue: __ccgo_ts + 31, FobjOffset: int64(-libc.Int32FromInt32(1)), FinternalOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 104)), }, 17: { Ftype1: int32(TK_OPTION_BORDER), FoptionName: __ccgo_ts + 21638, FdbName: __ccgo_ts + 21656, FdbClass: __ccgo_ts + 19810, FdefValue: __ccgo_ts + 21673, FobjOffset: int64(-libc.Int32FromInt32(1)), FinternalOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 176)), FclientData: __ccgo_ts + 19829, }, 18: { Ftype1: int32(TK_OPTION_PIXELS), FoptionName: __ccgo_ts + 21681, FdbName: __ccgo_ts + 21700, FdbClass: __ccgo_ts + 19964, FdefValue: __ccgo_ts + 10533, FobjOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 184)), FinternalOffset: int64(-libc.Int32FromInt32(1)), }, 19: { Ftype1: int32(TK_OPTION_COLOR), FoptionName: __ccgo_ts + 21718, FdbName: __ccgo_ts + 21736, FdbClass: __ccgo_ts + 19872, FdefValue: __ccgo_ts + 19829, FobjOffset: int64(-libc.Int32FromInt32(1)), FinternalOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 192)), Fflags: int32(TCL_NULL_OK), FclientData: __ccgo_ts + 19883, }, 20: { Ftype1: int32(TK_OPTION_STRING), FoptionName: __ccgo_ts + 23505, FdbName: __ccgo_ts + 23517, FdbClass: __ccgo_ts + 23528, FdefValue: __ccgo_ts + 23539, FobjOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 248)), FinternalOffset: int64(-libc.Int32FromInt32(1)), Fflags: int32(TCL_NULL_OK), }, 21: { FoptionName: __ccgo_ts + 23546, FdbName: __ccgo_ts + 23555, FdbClass: __ccgo_ts + 23563, FdefValue: __ccgo_ts + 10533, FobjOffset: int64(-libc.Int32FromInt32(1)), FinternalOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 232)), }, 22: { Ftype1: int32(TK_OPTION_STRING_TABLE), FoptionName: __ccgo_ts + 2957, FdbName: __ccgo_ts + 16747, FdbClass: __ccgo_ts + 20361, FdefValue: __ccgo_ts + 9363, FobjOffset: int64(-libc.Int32FromInt32(1)), FinternalOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 328)), FclientData: uintptr(unsafe.Pointer(&XtkStateStrings)) + 1*8, }, 23: { Ftype1: int32(TK_OPTION_STRING), FoptionName: __ccgo_ts + 20367, FdbName: __ccgo_ts + 20378, FdbClass: __ccgo_ts + 20388, FobjOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 304)), FinternalOffset: int64(-libc.Int32FromInt32(1)), Fflags: int32(TCL_NULL_OK), }, 24: { Ftype1: int32(TK_OPTION_INT), FoptionName: __ccgo_ts + 2987, FdbName: __ccgo_ts + 6446, FdbClass: __ccgo_ts + 20455, FdefValue: __ccgo_ts + 21847, FobjOffset: int64(-libc.Int32FromInt32(1)), FinternalOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 208)), }, 25: { Ftype1: int32(TK_OPTION_STRING), FoptionName: __ccgo_ts + 21850, FdbName: __ccgo_ts + 21866, FdbClass: __ccgo_ts + 21881, FdefValue: __ccgo_ts + 195, FobjOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 320)), FinternalOffset: int64(-libc.Int32FromInt32(1)), Fflags: int32(TCL_NULL_OK), }, 26: { Ftype1: int32(TK_OPTION_STRING), FoptionName: __ccgo_ts + 23571, FdbName: __ccgo_ts + 23587, FdbClass: __ccgo_ts + 21881, FdefValue: __ccgo_ts + 195, FobjOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 312)), FinternalOffset: int64(-libc.Int32FromInt32(1)), Fflags: int32(TCL_NULL_OK), }, 27: { Ftype1: int32(TK_OPTION_STRING), FoptionName: __ccgo_ts + 23602, FdbName: __ccgo_ts + 23616, FdbClass: __ccgo_ts + 20436, FdefValue: __ccgo_ts + 195, FobjOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 48)), FinternalOffset: int64(-libc.Int32FromInt32(1)), Fflags: int32(TCL_NULL_OK), }, 28: { Ftype1: int32(TK_OPTION_END), FinternalOffset: int64(-libc.Int32FromInt32(1)), }, } /* * The itemAttrOptionSpecs table defines the valid configuration options for * listbox items. */ var _itemAttrOptionSpecs = [7]TTk_OptionSpec{ 0: { Ftype1: int32(TK_OPTION_BORDER), FoptionName: __ccgo_ts + 19898, FobjOffset: int64(-libc.Int32FromInt32(1)), Fflags: int32(TCL_NULL_OK), }, 1: { Ftype1: int32(TK_OPTION_SYNONYM), FoptionName: __ccgo_ts + 19933, FinternalOffset: int64(-libc.Int32FromInt32(1)), FclientData: __ccgo_ts + 19898, }, 2: { Ftype1: int32(TK_OPTION_SYNONYM), FoptionName: __ccgo_ts + 20070, FdbName: __ccgo_ts + 20074, FinternalOffset: int64(-libc.Int32FromInt32(1)), FclientData: __ccgo_ts + 20085, }, 3: { Ftype1: int32(TK_OPTION_COLOR), FoptionName: __ccgo_ts + 20085, FobjOffset: int64(-libc.Int32FromInt32(1)), FinternalOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 16)), Fflags: int32(TCL_NULL_OK), }, 4: { Ftype1: int32(TK_OPTION_BORDER), FoptionName: __ccgo_ts + 21638, FobjOffset: int64(-libc.Int32FromInt32(1)), FinternalOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 8)), Fflags: int32(TCL_NULL_OK), }, 5: { Ftype1: int32(TK_OPTION_COLOR), FoptionName: __ccgo_ts + 21718, FobjOffset: int64(-libc.Int32FromInt32(1)), FinternalOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 24)), Fflags: int32(TCL_NULL_OK), }, 6: { Ftype1: int32(TK_OPTION_END), FinternalOffset: int64(-libc.Int32FromInt32(1)), }, } /* * The following tables define the listbox widget commands (and sub-commands) * and map the indexes into the string tables into enumerated types used to * dispatch the listbox widget command. */ var _commandNames1 = [19]uintptr{ 0: __ccgo_ts + 23629, 1: __ccgo_ts + 12095, 2: __ccgo_ts + 4735, 3: __ccgo_ts + 4740, 4: __ccgo_ts + 23638, 5: __ccgo_ts + 2655, 6: __ccgo_ts + 4949, 7: __ccgo_ts + 22152, 8: __ccgo_ts + 22158, 9: __ccgo_ts + 23651, 10: __ccgo_ts + 23660, 11: __ccgo_ts + 23674, 12: __ccgo_ts + 22165, 13: __ccgo_ts + 23682, 14: __ccgo_ts + 17828, 15: __ccgo_ts + 12163, 16: __ccgo_ts + 22170, 17: __ccgo_ts + 23686, 18: libc.UintptrFromInt32(0), } const COMMAND_ACTIVATE = 0 const COMMAND_BBOX1 = 1 const COMMAND_CGET2 = 2 const COMMAND_CONFIGURE2 = 3 const COMMAND_CURSELECTION = 4 const COMMAND_DELETE1 = 5 const COMMAND_GET1 = 6 const COMMAND_INDEX1 = 7 const COMMAND_INSERT1 = 8 const COMMAND_ITEMCGET = 9 const COMMAND_ITEMCONFIGURE = 10 const COMMAND_NEAREST = 11 const COMMAND_SCAN1 = 12 const COMMAND_SEE = 13 const COMMAND_SELECTION1 = 14 const COMMAND_SIZE = 15 const COMMAND_XVIEW1 = 16 const COMMAND_YVIEW = 17 var _selCommandNames = [5]uintptr{ 0: __ccgo_ts + 7881, 1: __ccgo_ts + 4943, 2: __ccgo_ts + 23692, 3: __ccgo_ts + 11726, 4: libc.UintptrFromInt32(0), } type selcommand = int32 const SELECTION_ANCHOR = 0 const SELECTION_INCLUDES = 2 const SELECTION_SET = 3 var _scanCommandNames = [3]uintptr{ 0: __ccgo_ts + 22299, 1: __ccgo_ts + 2046, 2: libc.UintptrFromInt32(0), } type scancommand = int32 const SCAN_DRAGTO = 0 const SCAN_MARK = 1 var _indexNames = [3]uintptr{ 0: __ccgo_ts + 16724, 1: __ccgo_ts + 7881, 2: libc.UintptrFromInt32(0), } type indices = int32 const INDEX_ACTIVE = 0 const INDEX_ANCHOR = 1 /* * The structure below defines button class behavior by means of procedures * that can be invoked from generic window code. */ var _listboxClass = TTk_ClassProcs{ Fsize: int64(32), } func init() { p := unsafe.Pointer(&_listboxClass) *(*uintptr)(unsafe.Add(p, 8)) = __ccgo_fp(_ListboxWorldChanged) } /* *-------------------------------------------------------------- * * Tk_ListboxObjCmd -- * * This procedure is invoked to process the "listbox" Tcl command. See * the user documentation for details on what it does. * * Results: * A standard Tcl result. * * Side effects: * See the user documentation. * *-------------------------------------------------------------- */ func XTk_ListboxObjCmd(tls *libc.TLS, dummy463 uintptr, interp uintptr, objc int32, objv uintptr) (r int32) { /* Argument objects. */ var listPtr, optionTables uintptr var tkwin TTk_Window _, _, _ = listPtr, optionTables, tkwin if objc < int32(2) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(1), objv, __ccgo_ts+20960) return int32(TCL_ERROR) } tkwin = XTk_CreateWindowFromPath(tls, interp, XTk_MainWindow(tls, interp), libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8)), libc.UintptrFromInt32(0)), libc.UintptrFromInt32(0)) if tkwin == libc.UintptrFromInt32(0) { return int32(TCL_ERROR) } optionTables = libtcl9_0.XTcl_GetAssocData(tls, interp, __ccgo_ts+23701, libc.UintptrFromInt32(0)) if optionTables == libc.UintptrFromInt32(0) { /* * We haven't created the option tables for this widget class yet. Do * it now and save the a pointer to them as the void *for the * command, so future invocations will have access to it. */ optionTables = libtcl9_0.XTcl_Alloc(tls, uint64(16)) /* * Set up an exit handler to free the optionTables struct. */ libtcl9_0.XTcl_SetAssocData(tls, interp, __ccgo_ts+23701, __ccgo_fp(_DestroyListboxOptionTables), optionTables) /* * Create the listbox option table and the listbox item option table. */ (*TListboxOptionTables)(unsafe.Pointer(optionTables)).FlistboxOptionTable = XTk_CreateOptionTable(tls, interp, uintptr(unsafe.Pointer(&_optionSpecs3))) (*TListboxOptionTables)(unsafe.Pointer(optionTables)).FitemAttrOptionTable = XTk_CreateOptionTable(tls, interp, uintptr(unsafe.Pointer(&_itemAttrOptionSpecs))) } /* * Initialize the fields of the structure that won't be initialized by * ConfigureListbox, or that ConfigureListbox requires to be initialized * already (e.g. resource pointers). */ listPtr = libtcl9_0.XTcl_Alloc(tls, uint64(352)) libc.Xmemset(tls, listPtr, 0, uint64(352)) (*TListbox)(unsafe.Pointer(listPtr)).Ftkwin = tkwin (*TListbox)(unsafe.Pointer(listPtr)).Fdisplay = (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fdisplay (*TListbox)(unsafe.Pointer(listPtr)).Finterp = interp (*TListbox)(unsafe.Pointer(listPtr)).FwidgetCmd = libtcl9_0.XTcl_CreateObjCommand(tls, interp, (*TTk_FakeWin)(unsafe.Pointer((*TListbox)(unsafe.Pointer(listPtr)).Ftkwin)).FpathName, __ccgo_fp(_ListboxWidgetObjCmd), listPtr, __ccgo_fp(_ListboxCmdDeletedProc)) (*TListbox)(unsafe.Pointer(listPtr)).FoptionTable = (*TListboxOptionTables)(unsafe.Pointer(optionTables)).FlistboxOptionTable (*TListbox)(unsafe.Pointer(listPtr)).FitemAttrOptionTable = (*TListboxOptionTables)(unsafe.Pointer(optionTables)).FitemAttrOptionTable (*TListbox)(unsafe.Pointer(listPtr)).Fselection = libtcl9_0.XTcl_Alloc(tls, uint64(104)) libtcl9_0.XTcl_InitHashTable(tls, (*TListbox)(unsafe.Pointer(listPtr)).Fselection, int32(TCL_ONE_WORD_KEYS)) (*TListbox)(unsafe.Pointer(listPtr)).FitemAttrTable = libtcl9_0.XTcl_Alloc(tls, uint64(104)) libtcl9_0.XTcl_InitHashTable(tls, (*TListbox)(unsafe.Pointer(listPtr)).FitemAttrTable, int32(TCL_ONE_WORD_KEYS)) (*TListbox)(unsafe.Pointer(listPtr)).Frelief = int32(TK_RELIEF_RAISED) (*TListbox)(unsafe.Pointer(listPtr)).FtextGC = libc.UintptrFromInt32(0) (*TListbox)(unsafe.Pointer(listPtr)).FselFgColorPtr = libc.UintptrFromInt32(0) (*TListbox)(unsafe.Pointer(listPtr)).FselTextGC = libc.UintptrFromInt32(0) (*TListbox)(unsafe.Pointer(listPtr)).FfullLines = int32(1) (*TListbox)(unsafe.Pointer(listPtr)).FxScrollUnit = int32(1) (*TListbox)(unsafe.Pointer(listPtr)).FexportSelection = int32(1) (*TListbox)(unsafe.Pointer(listPtr)).Fcursor = libc.UintptrFromInt32(0) (*TListbox)(unsafe.Pointer(listPtr)).Fstate = int32(STATE_NORMAL1) (*TListbox)(unsafe.Pointer(listPtr)).Fgray = uint64(0) (*TListbox)(unsafe.Pointer(listPtr)).Fjustify = int32(TK_JUSTIFY_LEFT) /* * Keep a hold of the associated tkwin until we destroy the listbox, * otherwise Tk might free it while we still need it. */ libtcl9_0.XTcl_Preserve(tls, (*TListbox)(unsafe.Pointer(listPtr)).Ftkwin) XTk_SetClass(tls, (*TListbox)(unsafe.Pointer(listPtr)).Ftkwin, __ccgo_ts+23721) XTk_SetClassProcs(tls, (*TListbox)(unsafe.Pointer(listPtr)).Ftkwin, uintptr(unsafe.Pointer(&_listboxClass)), listPtr) XTk_CreateEventHandler(tls, (*TListbox)(unsafe.Pointer(listPtr)).Ftkwin, libc.Uint64FromInt64(libc.Int64FromInt64(1)<= (*TListbox)(unsafe.Pointer(listPtr)).FnElements { *(*TTcl_Size)(unsafe.Pointer(bp + 8)) = (*TListbox)(unsafe.Pointer(listPtr)).FnElements - int64(1) } if *(*TTcl_Size)(unsafe.Pointer(bp + 8)) < 0 { *(*TTcl_Size)(unsafe.Pointer(bp + 8)) = 0 } (*TListbox)(unsafe.Pointer(listPtr)).Factive = int32(*(*TTcl_Size)(unsafe.Pointer(bp + 8))) _EventuallyRedrawRange(tls, listPtr, int64((*TListbox)(unsafe.Pointer(listPtr)).Factive), int64((*TListbox)(unsafe.Pointer(listPtr)).Factive)) result = TCL_OK case int32(COMMAND_BBOX1): if objc != int32(3) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(2), objv, __ccgo_ts+22152) result = int32(TCL_ERROR) break } result = _GetListboxIndex(tls, interp, listPtr, *(*uintptr)(unsafe.Pointer(objv + 2*8)), 0, bp+8) if result != TCL_OK { break } result = _ListboxBboxSubCmd(tls, interp, listPtr, int32(*(*TTcl_Size)(unsafe.Pointer(bp + 8)))) case int32(COMMAND_CGET2): if objc != int32(3) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(2), objv, __ccgo_ts+2689) result = int32(TCL_ERROR) break } objPtr = XTk_GetOptionValue(tls, interp, listPtr, (*TListbox)(unsafe.Pointer(listPtr)).FoptionTable, *(*uintptr)(unsafe.Pointer(objv + 2*8)), (*TListbox)(unsafe.Pointer(listPtr)).Ftkwin) if objPtr == libc.UintptrFromInt32(0) { result = int32(TCL_ERROR) break } libtcl9_0.XTcl_SetObjResult(tls, interp, objPtr) result = TCL_OK case int32(COMMAND_CONFIGURE2): if objc <= int32(3) { if objc == int32(3) { v1 = *(*uintptr)(unsafe.Pointer(objv + 2*8)) } else { v1 = libc.UintptrFromInt32(0) } objPtr = XTk_GetOptionInfo(tls, interp, listPtr, (*TListbox)(unsafe.Pointer(listPtr)).FoptionTable, v1, (*TListbox)(unsafe.Pointer(listPtr)).Ftkwin) if objPtr == libc.UintptrFromInt32(0) { result = int32(TCL_ERROR) break } libtcl9_0.XTcl_SetObjResult(tls, interp, objPtr) result = TCL_OK } else { result = _ConfigureListbox(tls, interp, listPtr, int64(objc-int32(2)), objv+uintptr(2)*8) } case int32(COMMAND_CURSELECTION): if objc != int32(2) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(2), objv, libc.UintptrFromInt32(0)) result = int32(TCL_ERROR) break } /* * Of course, it would be more efficient to use the Tcl_HashTable * search functions (Tcl_FirstHashEntry, Tcl_NextHashEntry), but then * the result wouldn't be in sorted order. So instead we loop through * the indices in order, adding them to the result if they are * selected. */ objPtr = libtcl9_0.XTcl_NewObj(tls) i = 0 for { if !(i < int32((*TListbox)(unsafe.Pointer(listPtr)).FnElements)) { break } if (*(*func(*libc.TLS, uintptr, uintptr) uintptr)(unsafe.Pointer(&struct{ uintptr }{(*TTcl_HashTable)(unsafe.Pointer((*TListbox)(unsafe.Pointer(listPtr)).Fselection)).FfindProc})))(tls, (*TListbox)(unsafe.Pointer(listPtr)).Fselection, uintptr(int64(i))) != 0 { libtcl9_0.XTcl_ListObjAppendElement(tls, libc.UintptrFromInt32(0), objPtr, libtcl9_0.XTcl_NewWideIntObj(tls, int64(i))) } goto _2 _2: ; i++ } libtcl9_0.XTcl_SetObjResult(tls, interp, objPtr) result = TCL_OK case int32(COMMAND_DELETE1): if objc < int32(3) || objc > int32(4) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(2), objv, __ccgo_ts+22240) result = int32(TCL_ERROR) break } result = _GetListboxIndex(tls, interp, listPtr, *(*uintptr)(unsafe.Pointer(objv + 2*8)), 0, bp+16) if result != TCL_OK { break } if !((*TListbox)(unsafe.Pointer(listPtr)).Fstate&int32(STATE_NORMAL1) != 0) { break } if *(*TTcl_Size)(unsafe.Pointer(bp + 16)) < int64(int32((*TListbox)(unsafe.Pointer(listPtr)).FnElements)) { /* * if a "last index" was given, get it now; otherwise, use the * first index as the last index. */ if objc == int32(4) { result = _GetListboxIndex(tls, interp, listPtr, *(*uintptr)(unsafe.Pointer(objv + 3*8)), 0, bp+24) if result != TCL_OK { break } } else { *(*TTcl_Size)(unsafe.Pointer(bp + 24)) = *(*TTcl_Size)(unsafe.Pointer(bp + 16)) } if *(*TTcl_Size)(unsafe.Pointer(bp + 24)) >= int64(int32((*TListbox)(unsafe.Pointer(listPtr)).FnElements)) { *(*TTcl_Size)(unsafe.Pointer(bp + 24)) = (*TListbox)(unsafe.Pointer(listPtr)).FnElements - int64(1) } result = _ListboxDeleteSubCmd(tls, listPtr, int32(*(*TTcl_Size)(unsafe.Pointer(bp + 16))), int32(*(*TTcl_Size)(unsafe.Pointer(bp + 24)))) } else { result = TCL_OK } case int32(COMMAND_GET1): if objc != int32(3) && objc != int32(4) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(2), objv, __ccgo_ts+22240) result = int32(TCL_ERROR) break } result = _GetListboxIndex(tls, interp, listPtr, *(*uintptr)(unsafe.Pointer(objv + 2*8)), 0, bp+40) if result != TCL_OK { break } *(*TTcl_Size)(unsafe.Pointer(bp + 48)) = *(*TTcl_Size)(unsafe.Pointer(bp + 40)) if objc == int32(4) { result = _GetListboxIndex(tls, interp, listPtr, *(*uintptr)(unsafe.Pointer(objv + 3*8)), 0, bp+48) if result != TCL_OK { break } } if *(*TTcl_Size)(unsafe.Pointer(bp + 40)) >= int64(int32((*TListbox)(unsafe.Pointer(listPtr)).FnElements)) { result = TCL_OK break } if *(*TTcl_Size)(unsafe.Pointer(bp + 48)) >= int64(int32((*TListbox)(unsafe.Pointer(listPtr)).FnElements)) { *(*TTcl_Size)(unsafe.Pointer(bp + 48)) = (*TListbox)(unsafe.Pointer(listPtr)).FnElements - int64(1) } if *(*TTcl_Size)(unsafe.Pointer(bp + 40)) < 0 { *(*TTcl_Size)(unsafe.Pointer(bp + 40)) = 0 } if *(*TTcl_Size)(unsafe.Pointer(bp + 40)) > *(*TTcl_Size)(unsafe.Pointer(bp + 48)) { result = TCL_OK break } result = libtcl9_0.XTcl_ListObjGetElements(tls, interp, (*TListbox)(unsafe.Pointer(listPtr)).FlistObj, bp+32, bp+56) if result != TCL_OK { break } if objc == int32(3) { /* * One element request - we return a string */ libtcl9_0.XTcl_SetObjResult(tls, interp, *(*uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 56)) + uintptr(*(*TTcl_Size)(unsafe.Pointer(bp + 40)))*8))) } else { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewListObj(tls, *(*TTcl_Size)(unsafe.Pointer(bp + 48))-*(*TTcl_Size)(unsafe.Pointer(bp + 40))+int64(1), *(*uintptr)(unsafe.Pointer(bp + 56))+uintptr(*(*TTcl_Size)(unsafe.Pointer(bp + 40)))*8)) } result = TCL_OK case int32(COMMAND_INDEX1): if objc != int32(3) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(2), objv, __ccgo_ts+22152) result = int32(TCL_ERROR) break } result = _GetListboxIndex(tls, interp, listPtr, *(*uintptr)(unsafe.Pointer(objv + 2*8)), int32(1), bp+8) if result != TCL_OK { break } if *(*TTcl_Size)(unsafe.Pointer(bp + 8)) == int64(-libc.Int32FromInt32(1)) { v3 = libtcl9_0.XTcl_NewObj(tls) } else { v3 = libtcl9_0.XTcl_NewWideIntObj(tls, *(*TTcl_Size)(unsafe.Pointer(bp + 8))) } libtcl9_0.XTcl_SetObjResult(tls, interp, v3) result = TCL_OK case int32(COMMAND_INSERT1): if objc < int32(3) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(2), objv, __ccgo_ts+23729) result = int32(TCL_ERROR) break } result = _GetListboxIndex(tls, interp, listPtr, *(*uintptr)(unsafe.Pointer(objv + 2*8)), int32(1), bp+8) if result != TCL_OK { break } if !((*TListbox)(unsafe.Pointer(listPtr)).Fstate&int32(STATE_NORMAL1) != 0) { break } result = _ListboxInsertSubCmd(tls, listPtr, *(*TTcl_Size)(unsafe.Pointer(bp + 8)), int64(objc-int32(3)), objv+uintptr(3)*8) case int32(COMMAND_ITEMCGET): if objc != int32(4) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(2), objv, __ccgo_ts+23749) result = int32(TCL_ERROR) break } result = _GetListboxIndex(tls, interp, listPtr, *(*uintptr)(unsafe.Pointer(objv + 2*8)), 0, bp+8) if result != TCL_OK { break } if *(*TTcl_Size)(unsafe.Pointer(bp + 8)) < 0 || *(*TTcl_Size)(unsafe.Pointer(bp + 8)) >= int64(int32((*TListbox)(unsafe.Pointer(listPtr)).FnElements)) { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+23762, libc.VaList(bp+88, libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8)), libc.UintptrFromInt32(0))))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+88, __ccgo_ts+179, __ccgo_ts+23792, __ccgo_ts+23800, libc.UintptrFromInt32(0))) result = int32(TCL_ERROR) break } attrPtr = _ListboxGetItemAttributes(tls, interp, listPtr, int32(*(*TTcl_Size)(unsafe.Pointer(bp + 8)))) objPtr = XTk_GetOptionValue(tls, interp, attrPtr, (*TListbox)(unsafe.Pointer(listPtr)).FitemAttrOptionTable, *(*uintptr)(unsafe.Pointer(objv + 3*8)), (*TListbox)(unsafe.Pointer(listPtr)).Ftkwin) if objPtr == libc.UintptrFromInt32(0) { result = int32(TCL_ERROR) break } libtcl9_0.XTcl_SetObjResult(tls, interp, objPtr) result = TCL_OK case int32(COMMAND_ITEMCONFIGURE): if objc < int32(3) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(2), objv, __ccgo_ts+23811) result = int32(TCL_ERROR) break } result = _GetListboxIndex(tls, interp, listPtr, *(*uintptr)(unsafe.Pointer(objv + 2*8)), 0, bp+8) if result != TCL_OK { break } if *(*TTcl_Size)(unsafe.Pointer(bp + 8)) < 0 || *(*TTcl_Size)(unsafe.Pointer(bp + 8)) >= int64(int32((*TListbox)(unsafe.Pointer(listPtr)).FnElements)) { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+23762, libc.VaList(bp+88, libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8)), libc.UintptrFromInt32(0))))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+88, __ccgo_ts+179, __ccgo_ts+23792, __ccgo_ts+23800, libc.UintptrFromInt32(0))) result = int32(TCL_ERROR) break } attrPtr1 = _ListboxGetItemAttributes(tls, interp, listPtr, int32(*(*TTcl_Size)(unsafe.Pointer(bp + 8)))) if objc <= int32(4) { if objc == int32(4) { v4 = *(*uintptr)(unsafe.Pointer(objv + 3*8)) } else { v4 = libc.UintptrFromInt32(0) } objPtr = XTk_GetOptionInfo(tls, interp, attrPtr1, (*TListbox)(unsafe.Pointer(listPtr)).FitemAttrOptionTable, v4, (*TListbox)(unsafe.Pointer(listPtr)).Ftkwin) if objPtr == libc.UintptrFromInt32(0) { result = int32(TCL_ERROR) break } libtcl9_0.XTcl_SetObjResult(tls, interp, objPtr) result = TCL_OK } else { result = _ConfigureListboxItem(tls, interp, listPtr, attrPtr1, int64(objc-int32(3)), objv+uintptr(3)*8, *(*TTcl_Size)(unsafe.Pointer(bp + 8))) } case int32(COMMAND_NEAREST): if objc != int32(3) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(2), objv, __ccgo_ts+6454) result = int32(TCL_ERROR) break } result = libtcl9_0.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+64) if result != TCL_OK { break } *(*TTcl_Size)(unsafe.Pointer(bp + 8)) = int64(_NearestListboxElement(tls, listPtr, *(*int32)(unsafe.Pointer(bp + 64)))) libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewWideIntObj(tls, *(*TTcl_Size)(unsafe.Pointer(bp + 8)))) result = TCL_OK case int32(COMMAND_SCAN1): if objc != int32(5) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(2), objv, __ccgo_ts+23837) result = int32(TCL_ERROR) break } if libtcl9_0.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 3*8)), bp+68) != TCL_OK || libtcl9_0.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 4*8)), bp+72) != TCL_OK { result = int32(TCL_ERROR) break } result = libtcl9_0.XTcl_GetIndexFromObjStruct(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), uintptr(unsafe.Pointer(&_scanCommandNames)), libc.Int64FromUint64(libc.Uint64FromInt64(8)), __ccgo_ts+2689, libc.Int32FromInt32(0)|libc.Int32FromUint64(libc.Uint64FromInt64(4)<= int64(int32((*TListbox)(unsafe.Pointer(listPtr)).FnElements)) { *(*TTcl_Size)(unsafe.Pointer(bp + 8)) = (*TListbox)(unsafe.Pointer(listPtr)).FnElements - int64(1) } if *(*TTcl_Size)(unsafe.Pointer(bp + 8)) < 0 { *(*TTcl_Size)(unsafe.Pointer(bp + 8)) = 0 } diff = int32(int64((*TListbox)(unsafe.Pointer(listPtr)).FtopIndex) - *(*TTcl_Size)(unsafe.Pointer(bp + 8))) if diff > 0 { if diff <= (*TListbox)(unsafe.Pointer(listPtr)).FfullLines/int32(3) { _ChangeListboxView(tls, listPtr, int32(*(*TTcl_Size)(unsafe.Pointer(bp + 8)))) } else { _ChangeListboxView(tls, listPtr, int32(*(*TTcl_Size)(unsafe.Pointer(bp + 8))-int64(((*TListbox)(unsafe.Pointer(listPtr)).FfullLines-int32(1))/int32(2)))) } } else { diff = int32(*(*TTcl_Size)(unsafe.Pointer(bp + 8)) - int64((*TListbox)(unsafe.Pointer(listPtr)).FtopIndex+(*TListbox)(unsafe.Pointer(listPtr)).FfullLines-libc.Int32FromInt32(1))) if diff > 0 { if diff <= (*TListbox)(unsafe.Pointer(listPtr)).FfullLines/int32(3) { _ChangeListboxView(tls, listPtr, (*TListbox)(unsafe.Pointer(listPtr)).FtopIndex+diff) } else { _ChangeListboxView(tls, listPtr, int32(*(*TTcl_Size)(unsafe.Pointer(bp + 8))-int64(((*TListbox)(unsafe.Pointer(listPtr)).FfullLines-int32(1))/int32(2)))) } } } result = TCL_OK case int32(COMMAND_SELECTION1): result = _ListboxSelectionSubCmd(tls, interp, listPtr, int64(objc), objv) case int32(COMMAND_SIZE): if objc != int32(2) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(2), objv, libc.UintptrFromInt32(0)) result = int32(TCL_ERROR) break } libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewWideIntObj(tls, (*TListbox)(unsafe.Pointer(listPtr)).FnElements)) result = TCL_OK case int32(COMMAND_XVIEW1): result = _ListboxXviewSubCmd(tls, interp, listPtr, int64(objc), objv) case int32(COMMAND_YVIEW): result = _ListboxYviewSubCmd(tls, interp, listPtr, int64(objc), objv) break } libtcl9_0.XTcl_Release(tls, listPtr) return result } /* *---------------------------------------------------------------------- * * ListboxBboxSubCmd -- * * This procedure is invoked to process a listbox bbox request. See the * user documentation for more information. * * Results: * A standard Tcl result. * * Side effects: * For valid indices, places the bbox of the requested element in the * interpreter's result. * *---------------------------------------------------------------------- */ func _ListboxBboxSubCmd(tls *libc.TLS, interp uintptr, listPtr uintptr, index int32) (r int32) { bp := tls.Alloc(64) defer tls.Free(64) /* Index of the element to get bbox info on */ var lastVisibleIndex, pixelWidth, result, x, y int32 var stringRep uintptr var tkwin TTk_Window var _ /* el at bp+0 */ uintptr var _ /* fm at bp+48 */ TTk_FontMetrics var _ /* results at bp+8 */ [4]uintptr var _ /* selBorderWidth at bp+60 */ int32 var _ /* stringLen at bp+40 */ TTcl_Size _, _, _, _, _, _, _ = lastVisibleIndex, pixelWidth, result, stringRep, tkwin, x, y tkwin = (*TListbox)(unsafe.Pointer(listPtr)).Ftkwin /* * Determine the index of the last visible item in the listbox. */ lastVisibleIndex = (*TListbox)(unsafe.Pointer(listPtr)).FtopIndex + (*TListbox)(unsafe.Pointer(listPtr)).FfullLines + (*TListbox)(unsafe.Pointer(listPtr)).FpartialLine if int32((*TListbox)(unsafe.Pointer(listPtr)).FnElements) < lastVisibleIndex { lastVisibleIndex = int32((*TListbox)(unsafe.Pointer(listPtr)).FnElements) } /* * Only allow bbox requests for indices that are visible. */ if (*TListbox)(unsafe.Pointer(listPtr)).FtopIndex <= index && index < lastVisibleIndex { /* * Compute the pixel width of the requested element. */ result = libtcl9_0.XTcl_ListObjIndex(tls, interp, (*TListbox)(unsafe.Pointer(listPtr)).FlistObj, int64(index), bp) if result != TCL_OK { return result } stringRep = libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(bp)), bp+40) XTk_GetFontMetrics(tls, (*TListbox)(unsafe.Pointer(listPtr)).Ftkfont, bp+48) pixelWidth = XTk_TextWidth(tls, (*TListbox)(unsafe.Pointer(listPtr)).Ftkfont, stringRep, *(*TTcl_Size)(unsafe.Pointer(bp + 40))) XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), (*TListbox)(unsafe.Pointer(listPtr)).Ftkwin, (*TListbox)(unsafe.Pointer(listPtr)).FselBorderWidthObj, bp+60) if (*TListbox)(unsafe.Pointer(listPtr)).Fjustify == int32(TK_JUSTIFY_LEFT) { x = (*TListbox)(unsafe.Pointer(listPtr)).Finset + *(*int32)(unsafe.Pointer(bp + 60)) - (*TListbox)(unsafe.Pointer(listPtr)).FxOffset } else { if (*TListbox)(unsafe.Pointer(listPtr)).Fjustify == int32(TK_JUSTIFY_RIGHT) { x = (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fchanges.Fwidth - ((*TListbox)(unsafe.Pointer(listPtr)).Finset + *(*int32)(unsafe.Pointer(bp + 60))) - pixelWidth - (*TListbox)(unsafe.Pointer(listPtr)).FxOffset + _GetMaxOffset(tls, listPtr) } else { x = ((*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fchanges.Fwidth-pixelWidth)/int32(2) - (*TListbox)(unsafe.Pointer(listPtr)).FxOffset + _GetMaxOffset(tls, listPtr)/int32(2) } } y = (index-(*TListbox)(unsafe.Pointer(listPtr)).FtopIndex)*(*TListbox)(unsafe.Pointer(listPtr)).FlineHeight + (*TListbox)(unsafe.Pointer(listPtr)).Finset + *(*int32)(unsafe.Pointer(bp + 60)) (*(*[4]uintptr)(unsafe.Pointer(bp + 8)))[0] = libtcl9_0.XTcl_NewWideIntObj(tls, int64(x)) (*(*[4]uintptr)(unsafe.Pointer(bp + 8)))[int32(1)] = libtcl9_0.XTcl_NewWideIntObj(tls, int64(y)) (*(*[4]uintptr)(unsafe.Pointer(bp + 8)))[int32(2)] = libtcl9_0.XTcl_NewWideIntObj(tls, int64(pixelWidth)) (*(*[4]uintptr)(unsafe.Pointer(bp + 8)))[int32(3)] = libtcl9_0.XTcl_NewWideIntObj(tls, int64((*(*TTk_FontMetrics)(unsafe.Pointer(bp + 48))).Flinespace)) libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewListObj(tls, int64(4), bp+8)) } return TCL_OK } /* *---------------------------------------------------------------------- * * ListboxSelectionSubCmd -- * * This procedure is invoked to process the selection sub command for * listbox widgets. * * Results: * Standard Tcl result. * * Side effects: * May set the interpreter's result field. * *---------------------------------------------------------------------- */ func _ListboxSelectionSubCmd(tls *libc.TLS, interp uintptr, listPtr uintptr, objc TTcl_Size, objv uintptr) (r int32) { bp := tls.Alloc(32) defer tls.Free(32) /* Array of arguments to the procedure */ var result int32 var _ /* first at bp+8 */ TTcl_Size var _ /* last at bp+16 */ TTcl_Size var _ /* selCmdIndex at bp+0 */ int32 _ = result result = TCL_OK if objc != int64(4) && objc != int64(5) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(2), objv, __ccgo_ts+23853) return int32(TCL_ERROR) } result = _GetListboxIndex(tls, interp, listPtr, *(*uintptr)(unsafe.Pointer(objv + 3*8)), 0, bp+8) if result != TCL_OK { return result } *(*TTcl_Size)(unsafe.Pointer(bp + 16)) = *(*TTcl_Size)(unsafe.Pointer(bp + 8)) if objc == int64(5) { result = _GetListboxIndex(tls, interp, listPtr, *(*uintptr)(unsafe.Pointer(objv + 4*8)), 0, bp+16) if result != TCL_OK { return result } } result = libtcl9_0.XTcl_GetIndexFromObjStruct(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), uintptr(unsafe.Pointer(&_selCommandNames)), libc.Int64FromUint64(libc.Uint64FromInt64(8)), __ccgo_ts+2689, libc.Int32FromInt32(0)|libc.Int32FromUint64(libc.Uint64FromInt64(4)<= int64(int32((*TListbox)(unsafe.Pointer(listPtr)).FnElements)) { *(*TTcl_Size)(unsafe.Pointer(bp + 8)) = (*TListbox)(unsafe.Pointer(listPtr)).FnElements - int64(1) } if *(*TTcl_Size)(unsafe.Pointer(bp + 8)) < 0 { *(*TTcl_Size)(unsafe.Pointer(bp + 8)) = 0 } (*TListbox)(unsafe.Pointer(listPtr)).FselectAnchor = int32(*(*TTcl_Size)(unsafe.Pointer(bp + 8))) result = TCL_OK case int32(SELECTION_CLEAR): result = _ListboxSelect(tls, listPtr, int32(*(*TTcl_Size)(unsafe.Pointer(bp + 8))), int32(*(*TTcl_Size)(unsafe.Pointer(bp + 16))), 0) case int32(SELECTION_INCLUDES): if objc != int64(4) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(3), objv, __ccgo_ts+22152) return int32(TCL_ERROR) } libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewWideIntObj(tls, libc.BoolInt64(libc.BoolInt32((*(*func(*libc.TLS, uintptr, uintptr) uintptr)(unsafe.Pointer(&struct{ uintptr }{(*TTcl_HashTable)(unsafe.Pointer((*TListbox)(unsafe.Pointer(listPtr)).Fselection)).FfindProc})))(tls, (*TListbox)(unsafe.Pointer(listPtr)).Fselection, uintptr(*(*TTcl_Size)(unsafe.Pointer(bp + 8)))) != libc.UintptrFromInt32(0)) != 0))) result = TCL_OK case int32(SELECTION_SET): result = _ListboxSelect(tls, listPtr, int32(*(*TTcl_Size)(unsafe.Pointer(bp + 8))), int32(*(*TTcl_Size)(unsafe.Pointer(bp + 16))), int32(1)) break } return result } /* *---------------------------------------------------------------------- * * ListboxXviewSubCmd -- * * Process the listbox "xview" subcommand. * * Results: * Standard Tcl result. * * Side effects: * May change the listbox viewing area; may set the interpreter's result. * *---------------------------------------------------------------------- */ func _ListboxXviewSubCmd(tls *libc.TLS, interp uintptr, listPtr uintptr, objc TTcl_Size, objv uintptr) (r int32) { bp := tls.Alloc(48) defer tls.Free(48) /* Array of arguments to the procedure */ var fraction2 float64 var offset, windowUnits, windowWidth int32 var _ /* count at bp+4 */ int32 var _ /* fraction at bp+8 */ float64 var _ /* index at bp+0 */ int32 var _ /* results at bp+24 */ [2]uintptr var _ /* selBorderWidth at bp+16 */ int32 _, _, _, _ = fraction2, offset, windowUnits, windowWidth offset = 0 XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), (*TListbox)(unsafe.Pointer(listPtr)).Ftkwin, (*TListbox)(unsafe.Pointer(listPtr)).FselBorderWidthObj, bp+16) windowWidth = (*TTk_FakeWin)(unsafe.Pointer((*TListbox)(unsafe.Pointer(listPtr)).Ftkwin)).Fchanges.Fwidth - int32(2)*((*TListbox)(unsafe.Pointer(listPtr)).Finset+*(*int32)(unsafe.Pointer(bp + 16))) if objc == int64(2) { if (*TListbox)(unsafe.Pointer(listPtr)).FmaxWidth == 0 { (*(*[2]uintptr)(unsafe.Pointer(bp + 24)))[0] = libtcl9_0.XTcl_NewDoubleObj(tls, float64(0)) (*(*[2]uintptr)(unsafe.Pointer(bp + 24)))[int32(1)] = libtcl9_0.XTcl_NewDoubleObj(tls, float64(1)) } else { *(*float64)(unsafe.Pointer(bp + 8)) = float64((*TListbox)(unsafe.Pointer(listPtr)).FxOffset) / float64((*TListbox)(unsafe.Pointer(listPtr)).FmaxWidth) fraction2 = float64((*TListbox)(unsafe.Pointer(listPtr)).FxOffset+windowWidth) / float64((*TListbox)(unsafe.Pointer(listPtr)).FmaxWidth) if fraction2 > float64(1) { fraction2 = float64(1) } (*(*[2]uintptr)(unsafe.Pointer(bp + 24)))[0] = libtcl9_0.XTcl_NewDoubleObj(tls, *(*float64)(unsafe.Pointer(bp + 8))) (*(*[2]uintptr)(unsafe.Pointer(bp + 24)))[int32(1)] = libtcl9_0.XTcl_NewDoubleObj(tls, fraction2) } libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewListObj(tls, int64(2), bp+24)) } else { if objc == int64(3) { if libtcl9_0.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp) != TCL_OK { return int32(TCL_ERROR) } _ChangeListboxOffset(tls, listPtr, *(*int32)(unsafe.Pointer(bp))*(*TListbox)(unsafe.Pointer(listPtr)).FxScrollUnit) } else { switch XTk_GetScrollInfoObj(tls, interp, objc, objv, bp+8, bp+4) { case int32(TK_SCROLL_MOVETO): offset = int32(float64(*(*float64)(unsafe.Pointer(bp + 8))*float64((*TListbox)(unsafe.Pointer(listPtr)).FmaxWidth)) + libc.Float64FromFloat64(0.5)) case int32(TK_SCROLL_PAGES): windowUnits = windowWidth / (*TListbox)(unsafe.Pointer(listPtr)).FxScrollUnit if windowUnits > int32(2) { offset = (*TListbox)(unsafe.Pointer(listPtr)).FxOffset + *(*int32)(unsafe.Pointer(bp + 4))*(*TListbox)(unsafe.Pointer(listPtr)).FxScrollUnit*(windowUnits-int32(2)) } else { offset = (*TListbox)(unsafe.Pointer(listPtr)).FxOffset + *(*int32)(unsafe.Pointer(bp + 4))*(*TListbox)(unsafe.Pointer(listPtr)).FxScrollUnit } case int32(TK_SCROLL_UNITS): offset = (*TListbox)(unsafe.Pointer(listPtr)).FxOffset + *(*int32)(unsafe.Pointer(bp + 4))*(*TListbox)(unsafe.Pointer(listPtr)).FxScrollUnit default: return int32(TCL_ERROR) } _ChangeListboxOffset(tls, listPtr, offset) } } return TCL_OK } /* *---------------------------------------------------------------------- * * ListboxYviewSubCmd -- * * Process the listbox "yview" subcommand. * * Results: * Standard Tcl result. * * Side effects: * May change the listbox viewing area; may set the interpreter's result. * *---------------------------------------------------------------------- */ func _ListboxYviewSubCmd(tls *libc.TLS, interp uintptr, listPtr uintptr, objc TTcl_Size, objv uintptr) (r int32) { bp := tls.Alloc(48) defer tls.Free(48) /* Array of arguments to the procedure */ var fraction2, numEls float64 var _ /* count at bp+8 */ int32 var _ /* fraction at bp+16 */ float64 var _ /* index at bp+0 */ TTcl_Size var _ /* results at bp+24 */ [2]uintptr _, _ = fraction2, numEls if objc == int64(2) { if (*TListbox)(unsafe.Pointer(listPtr)).FnElements == 0 { (*(*[2]uintptr)(unsafe.Pointer(bp + 24)))[0] = libtcl9_0.XTcl_NewDoubleObj(tls, float64(0)) (*(*[2]uintptr)(unsafe.Pointer(bp + 24)))[int32(1)] = libtcl9_0.XTcl_NewDoubleObj(tls, float64(1)) } else { numEls = float64((*TListbox)(unsafe.Pointer(listPtr)).FnElements) *(*float64)(unsafe.Pointer(bp + 16)) = float64((*TListbox)(unsafe.Pointer(listPtr)).FtopIndex) / numEls fraction2 = float64((*TListbox)(unsafe.Pointer(listPtr)).FtopIndex+(*TListbox)(unsafe.Pointer(listPtr)).FfullLines) / numEls if fraction2 > float64(1) { fraction2 = float64(1) } (*(*[2]uintptr)(unsafe.Pointer(bp + 24)))[0] = libtcl9_0.XTcl_NewDoubleObj(tls, *(*float64)(unsafe.Pointer(bp + 16))) (*(*[2]uintptr)(unsafe.Pointer(bp + 24)))[int32(1)] = libtcl9_0.XTcl_NewDoubleObj(tls, fraction2) } libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewListObj(tls, int64(2), bp+24)) } else { if objc == int64(3) { if _GetListboxIndex(tls, interp, listPtr, *(*uintptr)(unsafe.Pointer(objv + 2*8)), 0, bp) != TCL_OK { return int32(TCL_ERROR) } _ChangeListboxView(tls, listPtr, int32(*(*TTcl_Size)(unsafe.Pointer(bp)))) } else { switch XTk_GetScrollInfoObj(tls, interp, objc, objv, bp+16, bp+8) { case int32(TK_SCROLL_MOVETO): *(*TTcl_Size)(unsafe.Pointer(bp)) = int64(float64(float64((*TListbox)(unsafe.Pointer(listPtr)).FnElements)**(*float64)(unsafe.Pointer(bp + 16))) + libc.Float64FromFloat64(0.5)) case int32(TK_SCROLL_PAGES): if (*TListbox)(unsafe.Pointer(listPtr)).FfullLines > int32(2) { *(*TTcl_Size)(unsafe.Pointer(bp)) = int64((*TListbox)(unsafe.Pointer(listPtr)).FtopIndex + *(*int32)(unsafe.Pointer(bp + 8))*((*TListbox)(unsafe.Pointer(listPtr)).FfullLines-int32(2))) } else { *(*TTcl_Size)(unsafe.Pointer(bp)) = int64((*TListbox)(unsafe.Pointer(listPtr)).FtopIndex + *(*int32)(unsafe.Pointer(bp + 8))) } case int32(TK_SCROLL_UNITS): *(*TTcl_Size)(unsafe.Pointer(bp)) = int64((*TListbox)(unsafe.Pointer(listPtr)).FtopIndex + *(*int32)(unsafe.Pointer(bp + 8))) default: return int32(TCL_ERROR) } _ChangeListboxView(tls, listPtr, int32(*(*TTcl_Size)(unsafe.Pointer(bp)))) } } return TCL_OK } /* *---------------------------------------------------------------------- * * ListboxGetItemAttributes -- * * Returns a pointer to the ItemAttr record for a given index, creating * one if it does not already exist. * * Results: * Pointer to an ItemAttr record. * * Side effects: * Memory may be allocated for the ItemAttr record. * *---------------------------------------------------------------------- */ func _ListboxGetItemAttributes(tls *libc.TLS, interp uintptr, listPtr uintptr, index int32) (r uintptr) { bp := tls.Alloc(16) defer tls.Free(16) /* Index of the item to retrieve attributes * for. */ var attrs, entry uintptr var _ /* isNew at bp+0 */ int32 _, _ = attrs, entry entry = (*(*func(*libc.TLS, uintptr, uintptr, uintptr) uintptr)(unsafe.Pointer(&struct{ uintptr }{(*TTcl_HashTable)(unsafe.Pointer((*TListbox)(unsafe.Pointer(listPtr)).FitemAttrTable)).FcreateProc})))(tls, (*TListbox)(unsafe.Pointer(listPtr)).FitemAttrTable, uintptr(int64(index)), bp) if *(*int32)(unsafe.Pointer(bp)) != 0 { attrs = libtcl9_0.XTcl_Alloc(tls, uint64(32)) (*TItemAttr)(unsafe.Pointer(attrs)).Fborder = libc.UintptrFromInt32(0) (*TItemAttr)(unsafe.Pointer(attrs)).FselBorder = libc.UintptrFromInt32(0) (*TItemAttr)(unsafe.Pointer(attrs)).FfgColor = libc.UintptrFromInt32(0) (*TItemAttr)(unsafe.Pointer(attrs)).FselFgColor = libc.UintptrFromInt32(0) XTk_InitOptions(tls, interp, attrs, (*TListbox)(unsafe.Pointer(listPtr)).FitemAttrOptionTable, (*TListbox)(unsafe.Pointer(listPtr)).Ftkwin) (*TTcl_HashEntry)(unsafe.Pointer(entry)).FclientData = attrs } else { attrs = (*TTcl_HashEntry)(unsafe.Pointer(entry)).FclientData } return attrs } /* *---------------------------------------------------------------------- * * DestroyListbox -- * * This procedure is invoked by Tcl_EventuallyFree or Tcl_Release to * clean up the internal structure of a listbox at a safe time (when * no-one is using it anymore). * * Results: * None. * * Side effects: * Everything associated with the listbox is freed up. * *---------------------------------------------------------------------- */ func _DestroyListbox(tls *libc.TLS, memPtr uintptr) { bp := tls.Alloc(32) defer tls.Free(32) /* Info about listbox widget. */ var _objPtr, entry, listPtr, v2 uintptr var v1 TTcl_Size var _ /* search at bp+0 */ TTcl_HashSearch _, _, _, _, _ = _objPtr, entry, listPtr, v1, v2 listPtr = memPtr /* * If we have an internal list object, free it. */ if (*TListbox)(unsafe.Pointer(listPtr)).FlistObj != libc.UintptrFromInt32(0) { _objPtr = (*TListbox)(unsafe.Pointer(listPtr)).FlistObj v2 = _objPtr v1 = *(*TTcl_Size)(unsafe.Pointer(v2)) *(*TTcl_Size)(unsafe.Pointer(v2))-- if v1 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr) } (*TListbox)(unsafe.Pointer(listPtr)).FlistObj = libc.UintptrFromInt32(0) } if (*TListbox)(unsafe.Pointer(listPtr)).FlistVarNameObj != libc.UintptrFromInt32(0) { libtcl9_0.XTcl_UntraceVar2(tls, (*TListbox)(unsafe.Pointer(listPtr)).Finterp, libtcl9_0.XTcl_GetStringFromObj(tls, (*TListbox)(unsafe.Pointer(listPtr)).FlistVarNameObj, libc.UintptrFromInt32(0)), libc.UintptrFromInt32(0), libc.Int32FromInt32(TCL_GLOBAL_ONLY)|libc.Int32FromInt32(TCL_TRACE_WRITES)|libc.Int32FromInt32(TCL_TRACE_UNSETS), __ccgo_fp(_ListboxListVarProc), listPtr) } /* * Free the selection hash table. */ libtcl9_0.XTcl_DeleteHashTable(tls, (*TListbox)(unsafe.Pointer(listPtr)).Fselection) libtcl9_0.XTcl_Free(tls, (*TListbox)(unsafe.Pointer(listPtr)).Fselection) /* * Free the item attribute hash table. */ entry = libtcl9_0.XTcl_FirstHashEntry(tls, (*TListbox)(unsafe.Pointer(listPtr)).FitemAttrTable, bp) for { if !(entry != libc.UintptrFromInt32(0)) { break } libtcl9_0.XTcl_Free(tls, (*TTcl_HashEntry)(unsafe.Pointer(entry)).FclientData) goto _3 _3: ; entry = libtcl9_0.XTcl_NextHashEntry(tls, bp) } libtcl9_0.XTcl_DeleteHashTable(tls, (*TListbox)(unsafe.Pointer(listPtr)).FitemAttrTable) libtcl9_0.XTcl_Free(tls, (*TListbox)(unsafe.Pointer(listPtr)).FitemAttrTable) /* * Free up all the stuff that requires special handling, then let * Tk_FreeOptions handle all the standard option-related stuff. */ if (*TListbox)(unsafe.Pointer(listPtr)).FtextGC != libc.UintptrFromInt32(0) { XTk_FreeGC(tls, (*TListbox)(unsafe.Pointer(listPtr)).Fdisplay, (*TListbox)(unsafe.Pointer(listPtr)).FtextGC) } if (*TListbox)(unsafe.Pointer(listPtr)).FselTextGC != libc.UintptrFromInt32(0) { XTk_FreeGC(tls, (*TListbox)(unsafe.Pointer(listPtr)).Fdisplay, (*TListbox)(unsafe.Pointer(listPtr)).FselTextGC) } if (*TListbox)(unsafe.Pointer(listPtr)).Fgray != uint64(0) { XTk_FreeBitmap(tls, (*TTk_FakeWin)(unsafe.Pointer((*TListbox)(unsafe.Pointer(listPtr)).Ftkwin)).Fdisplay, (*TListbox)(unsafe.Pointer(listPtr)).Fgray) } XTk_FreeConfigOptions(tls, listPtr, (*TListbox)(unsafe.Pointer(listPtr)).FoptionTable, (*TListbox)(unsafe.Pointer(listPtr)).Ftkwin) libtcl9_0.XTcl_Release(tls, (*TListbox)(unsafe.Pointer(listPtr)).Ftkwin) (*TListbox)(unsafe.Pointer(listPtr)).Ftkwin = libc.UintptrFromInt32(0) libtcl9_0.XTcl_Free(tls, listPtr) } /* *---------------------------------------------------------------------- * * DestroyListboxOptionTables -- * * This procedure is registered as an exit callback when the listbox * command is first called. It cleans up the OptionTables structure * allocated by that command. * * Results: * None. * * Side effects: * Frees memory. * *---------------------------------------------------------------------- */ func _DestroyListboxOptionTables(tls *libc.TLS, clientData uintptr, dummy1527 uintptr) { /* Pointer to the calling interp */ libtcl9_0.XTcl_Free(tls, clientData) return } /* *---------------------------------------------------------------------- * * ConfigureListbox -- * * This procedure is called to process an objv/objc list, plus the Tk * option database, in order to configure (or reconfigure) a listbox * widget. * * Results: * The return value is a standard Tcl result. If TCL_ERROR is returned, * then the interp's result contains an error message. * * Side effects: * Configuration information, such as colors, border width, etc. get set * for listPtr; old resources get freed, if there were any. * *---------------------------------------------------------------------- */ func _ConfigureListbox(tls *libc.TLS, interp uintptr, listPtr uintptr, objc TTcl_Size, objv uintptr) (r int32) { bp := tls.Alloc(560) defer tls.Free(560) /* Arguments. */ var _objPtr, _objPtr1, _objPtr2, _objPtr3, _objPtr4, errorResult, listVarObj, oldListObj, v10, v12, v3, v5, v7, v8 uintptr var error1, oldExport int32 var v11, v2, v4, v6, v9 TTcl_Size var _ /* borderWidth at bp+512 */ int32 var _ /* dummy at bp+528 */ TTcl_Size var _ /* highlightWidth at bp+520 */ int32 var _ /* savedOptions at bp+0 */ TTk_SavedOptions var _ /* selBorderWidth at bp+516 */ int32 _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = _objPtr, _objPtr1, _objPtr2, _objPtr3, _objPtr4, error1, errorResult, listVarObj, oldExport, oldListObj, v10, v11, v12, v2, v3, v4, v5, v6, v7, v8, v9 oldListObj = libc.UintptrFromInt32(0) errorResult = libc.UintptrFromInt32(0) oldExport = libc.BoolInt32((*TListbox)(unsafe.Pointer(listPtr)).FexportSelection != 0 && !(libtcl9_0.XTcl_IsSafe(tls, (*TListbox)(unsafe.Pointer(listPtr)).Finterp) != 0)) if (*TListbox)(unsafe.Pointer(listPtr)).FlistVarNameObj != libc.UintptrFromInt32(0) { libtcl9_0.XTcl_UntraceVar2(tls, interp, libtcl9_0.XTcl_GetStringFromObj(tls, (*TListbox)(unsafe.Pointer(listPtr)).FlistVarNameObj, libc.UintptrFromInt32(0)), libc.UintptrFromInt32(0), libc.Int32FromInt32(TCL_GLOBAL_ONLY)|libc.Int32FromInt32(TCL_TRACE_WRITES)|libc.Int32FromInt32(TCL_TRACE_UNSETS), __ccgo_fp(_ListboxListVarProc), listPtr) } error1 = 0 for { if !(error1 <= int32(1)) { break } if !(error1 != 0) { /* * First pass: set options to new values. */ if XTk_SetOptions(tls, interp, listPtr, (*TListbox)(unsafe.Pointer(listPtr)).FoptionTable, objc, objv, (*TListbox)(unsafe.Pointer(listPtr)).Ftkwin, bp, libc.UintptrFromInt32(0)) != TCL_OK { goto _1 } } else { /* * Second pass: restore options to old values. */ errorResult = libtcl9_0.XTcl_GetObjResult(tls, interp) (*TTcl_Obj)(unsafe.Pointer(errorResult)).FrefCount++ XTk_RestoreSavedOptions(tls, bp) } /* * A few options need special processing, such as setting the * background from a 3-D border. */ XTk_SetBackgroundFromBorder(tls, (*TListbox)(unsafe.Pointer(listPtr)).Ftkwin, (*TListbox)(unsafe.Pointer(listPtr)).FnormalBorder) XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), (*TListbox)(unsafe.Pointer(listPtr)).Ftkwin, (*TListbox)(unsafe.Pointer(listPtr)).FborderWidthObj, bp+512) if *(*int32)(unsafe.Pointer(bp + 512)) < 0 { *(*int32)(unsafe.Pointer(bp + 512)) = 0 _objPtr = (*TListbox)(unsafe.Pointer(listPtr)).FborderWidthObj v3 = _objPtr v2 = *(*TTcl_Size)(unsafe.Pointer(v3)) *(*TTcl_Size)(unsafe.Pointer(v3))-- if v2 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr) } (*TListbox)(unsafe.Pointer(listPtr)).FborderWidthObj = libtcl9_0.XTcl_NewWideIntObj(tls, int64(libc.Int32FromInt32(0))) (*TTcl_Obj)(unsafe.Pointer((*TListbox)(unsafe.Pointer(listPtr)).FborderWidthObj)).FrefCount++ } XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), (*TListbox)(unsafe.Pointer(listPtr)).Ftkwin, (*TListbox)(unsafe.Pointer(listPtr)).FhighlightWidthObj, bp+520) if *(*int32)(unsafe.Pointer(bp + 520)) < 0 { *(*int32)(unsafe.Pointer(bp + 520)) = 0 _objPtr1 = (*TListbox)(unsafe.Pointer(listPtr)).FhighlightWidthObj v5 = _objPtr1 v4 = *(*TTcl_Size)(unsafe.Pointer(v5)) *(*TTcl_Size)(unsafe.Pointer(v5))-- if v4 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr1) } (*TListbox)(unsafe.Pointer(listPtr)).FhighlightWidthObj = libtcl9_0.XTcl_NewWideIntObj(tls, int64(libc.Int32FromInt32(0))) (*TTcl_Obj)(unsafe.Pointer((*TListbox)(unsafe.Pointer(listPtr)).FhighlightWidthObj)).FrefCount++ } XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), (*TListbox)(unsafe.Pointer(listPtr)).Ftkwin, (*TListbox)(unsafe.Pointer(listPtr)).FselBorderWidthObj, bp+516) if *(*int32)(unsafe.Pointer(bp + 516)) < 0 { *(*int32)(unsafe.Pointer(bp + 516)) = 0 _objPtr2 = (*TListbox)(unsafe.Pointer(listPtr)).FselBorderWidthObj v7 = _objPtr2 v6 = *(*TTcl_Size)(unsafe.Pointer(v7)) *(*TTcl_Size)(unsafe.Pointer(v7))-- if v6 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr2) } (*TListbox)(unsafe.Pointer(listPtr)).FselBorderWidthObj = libtcl9_0.XTcl_NewWideIntObj(tls, int64(libc.Int32FromInt32(0))) (*TTcl_Obj)(unsafe.Pointer((*TListbox)(unsafe.Pointer(listPtr)).FselBorderWidthObj)).FrefCount++ } (*TListbox)(unsafe.Pointer(listPtr)).Finset = *(*int32)(unsafe.Pointer(bp + 520)) + *(*int32)(unsafe.Pointer(bp + 512)) /* * Claim the selection if we've suddenly started exporting it and * there is a selection to export and this interp is unsafe. */ if (*TListbox)(unsafe.Pointer(listPtr)).FexportSelection != 0 && !(oldExport != 0) && !(libtcl9_0.XTcl_IsSafe(tls, (*TListbox)(unsafe.Pointer(listPtr)).Finterp) != 0) && (*TListbox)(unsafe.Pointer(listPtr)).FnumSelected != 0 { XTk_OwnSelection(tls, (*TListbox)(unsafe.Pointer(listPtr)).Ftkwin, libc.Uint64FromInt32(1), __ccgo_fp(_ListboxLostSelection), listPtr) } /* * Verify the current status of the list var. * PREVIOUS STATE | NEW STATE | ACTION * ---------------+------------+---------------------------------- * no listvar | listvar | If listvar does not exist, create it * and copy the internal list obj's * content to the new var. If it does * exist, toss the internal list obj. * * listvar | no listvar | Copy old listvar content to the * internal list obj * * listvar | listvar | no special action * * no listvar | no listvar | no special action */ oldListObj = (*TListbox)(unsafe.Pointer(listPtr)).FlistObj if (*TListbox)(unsafe.Pointer(listPtr)).FlistVarNameObj != libc.UintptrFromInt32(0) { listVarObj = libtcl9_0.XTcl_GetVar2Ex(tls, interp, libtcl9_0.XTcl_GetStringFromObj(tls, (*TListbox)(unsafe.Pointer(listPtr)).FlistVarNameObj, libc.UintptrFromInt32(0)), libc.UintptrFromInt32(0), int32(TCL_GLOBAL_ONLY)) if listVarObj == libc.UintptrFromInt32(0) { if oldListObj != 0 { v8 = oldListObj } else { v8 = libtcl9_0.XTcl_NewObj(tls) } listVarObj = v8 if libtcl9_0.XTcl_SetVar2Ex(tls, interp, libtcl9_0.XTcl_GetStringFromObj(tls, (*TListbox)(unsafe.Pointer(listPtr)).FlistVarNameObj, libc.UintptrFromInt32(0)), libc.UintptrFromInt32(0), listVarObj, libc.Int32FromInt32(TCL_GLOBAL_ONLY)|libc.Int32FromInt32(TCL_LEAVE_ERR_MSG)) == libc.UintptrFromInt32(0) { goto _1 } } /* * Make sure the object is a good list object. */ if libtcl9_0.XTcl_ListObjLength(tls, (*TListbox)(unsafe.Pointer(listPtr)).Finterp, listVarObj, bp+528) != TCL_OK { libtcl9_0.XTcl_AppendResult(tls, (*TListbox)(unsafe.Pointer(listPtr)).Finterp, libc.VaList(bp+544, __ccgo_ts+23874, libc.UintptrFromInt32(0))) goto _1 } (*TListbox)(unsafe.Pointer(listPtr)).FlistObj = listVarObj libtcl9_0.XTcl_TraceVar2(tls, (*TListbox)(unsafe.Pointer(listPtr)).Finterp, libtcl9_0.XTcl_GetStringFromObj(tls, (*TListbox)(unsafe.Pointer(listPtr)).FlistVarNameObj, libc.UintptrFromInt32(0)), libc.UintptrFromInt32(0), libc.Int32FromInt32(TCL_GLOBAL_ONLY)|libc.Int32FromInt32(TCL_TRACE_WRITES)|libc.Int32FromInt32(TCL_TRACE_UNSETS), __ccgo_fp(_ListboxListVarProc), listPtr) } else { if (*TListbox)(unsafe.Pointer(listPtr)).FlistObj == libc.UintptrFromInt32(0) { (*TListbox)(unsafe.Pointer(listPtr)).FlistObj = libtcl9_0.XTcl_NewObj(tls) } } (*TTcl_Obj)(unsafe.Pointer((*TListbox)(unsafe.Pointer(listPtr)).FlistObj)).FrefCount++ if oldListObj != libc.UintptrFromInt32(0) { _objPtr3 = oldListObj v10 = _objPtr3 v9 = *(*TTcl_Size)(unsafe.Pointer(v10)) *(*TTcl_Size)(unsafe.Pointer(v10))-- if v9 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr3) } } break goto _1 _1: ; error1++ } if !(error1 != 0) { XTk_FreeSavedOptions(tls, bp) } /* * Make sure that the list length is correct. */ libtcl9_0.XTcl_ListObjLength(tls, (*TListbox)(unsafe.Pointer(listPtr)).Finterp, (*TListbox)(unsafe.Pointer(listPtr)).FlistObj, listPtr+64) if error1 != 0 { libtcl9_0.XTcl_SetObjResult(tls, interp, errorResult) _objPtr4 = errorResult v12 = _objPtr4 v11 = *(*TTcl_Size)(unsafe.Pointer(v12)) *(*TTcl_Size)(unsafe.Pointer(v12))-- if v11 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr4) } return int32(TCL_ERROR) } _ListboxWorldChanged(tls, listPtr) return TCL_OK } /* *---------------------------------------------------------------------- * * ConfigureListboxItem -- * * This procedure is called to process an objv/objc list, plus the Tk * option database, in order to configure (or reconfigure) a listbox * item. * * Results: * The return value is a standard Tcl result. If TCL_ERROR is returned, * then the interp's result contains an error message. * * Side effects: * Configuration information, such as colors, border width, etc. get set * for a listbox item; old resources get freed, if there were any. * *---------------------------------------------------------------------- */ func _ConfigureListboxItem(tls *libc.TLS, interp uintptr, listPtr uintptr, attrs uintptr, objc TTcl_Size, objv uintptr, index TTcl_Size) (r int32) { bp := tls.Alloc(512) defer tls.Free(512) /* Index of the listbox item being configure */ var _ /* savedOptions at bp+0 */ TTk_SavedOptions if XTk_SetOptions(tls, interp, attrs, (*TListbox)(unsafe.Pointer(listPtr)).FitemAttrOptionTable, objc, objv, (*TListbox)(unsafe.Pointer(listPtr)).Ftkwin, bp, libc.UintptrFromInt32(0)) != TCL_OK { XTk_RestoreSavedOptions(tls, bp) return int32(TCL_ERROR) } XTk_FreeSavedOptions(tls, bp) /* * Redraw this index - ListboxWorldChanged would need to be called if item * attributes were checked in the "world". */ _EventuallyRedrawRange(tls, listPtr, index, index) return TCL_OK } /* *--------------------------------------------------------------------------- * * ListboxWorldChanged -- * * This procedure is called when the world has changed in some way and * the widget needs to recompute all its graphics contexts and determine * its new geometry. * * Results: * None. * * Side effects: * Listbox will be relayed out and redisplayed. * *--------------------------------------------------------------------------- */ func _ListboxWorldChanged(tls *libc.TLS, instanceData uintptr) { bp := tls.Alloc(128) defer tls.Free(128) /* Information about widget. */ var gc TGC var listPtr uintptr var mask uint64 var _ /* gcValues at bp+0 */ TXGCValues _, _, _ = gc, listPtr, mask listPtr = instanceData if (*TListbox)(unsafe.Pointer(listPtr)).Fstate&int32(STATE_NORMAL1) != 0 { (*(*TXGCValues)(unsafe.Pointer(bp))).Fforeground = (*TXColor)(unsafe.Pointer((*TListbox)(unsafe.Pointer(listPtr)).FfgColorPtr)).Fpixel (*(*TXGCValues)(unsafe.Pointer(bp))).Fgraphics_exposures = False mask = libc.Uint64FromInt64(libc.Int64FromInt64(1)<= int32((*TListbox)(unsafe.Pointer(listPtr)).FnElements) { limit = int32((*TListbox)(unsafe.Pointer(listPtr)).FnElements - int64(1)) } v1 = libc.Int32FromInt32(0) right = v1 left = v1 if (*TListbox)(unsafe.Pointer(listPtr)).FxOffset > 0 { left = *(*int32)(unsafe.Pointer(bp + 164)) + int32(1) } if (*TListbox)(unsafe.Pointer(listPtr)).FmaxWidth-(*TListbox)(unsafe.Pointer(listPtr)).FxOffset > (*TTk_FakeWin)(unsafe.Pointer((*TListbox)(unsafe.Pointer(listPtr)).Ftkwin)).Fchanges.Fwidth-int32(2)*((*TListbox)(unsafe.Pointer(listPtr)).Finset+*(*int32)(unsafe.Pointer(bp + 164))) { right = *(*int32)(unsafe.Pointer(bp + 164)) + int32(1) } prevSelected = 0 i = (*TListbox)(unsafe.Pointer(listPtr)).FtopIndex for { if !(i <= limit) { break } width = (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fchanges.Fwidth /* zeroth approx to silence warning */ x = (*TListbox)(unsafe.Pointer(listPtr)).Finset y = (i-(*TListbox)(unsafe.Pointer(listPtr)).FtopIndex)*(*TListbox)(unsafe.Pointer(listPtr)).FlineHeight + (*TListbox)(unsafe.Pointer(listPtr)).Finset gc = (*TListbox)(unsafe.Pointer(listPtr)).FtextGC freeGC = 0 /* * Lookup this item in the item attributes table, to see if it has * special foreground/background colors. */ entry = (*(*func(*libc.TLS, uintptr, uintptr) uintptr)(unsafe.Pointer(&struct{ uintptr }{(*TTcl_HashTable)(unsafe.Pointer((*TListbox)(unsafe.Pointer(listPtr)).FitemAttrTable)).FfindProc})))(tls, (*TListbox)(unsafe.Pointer(listPtr)).FitemAttrTable, uintptr(int64(i))) /* * If the listbox is enabled, items may be drawn differently; they may * be drawn selected, or they may have special foreground or * background colors. */ if (*TListbox)(unsafe.Pointer(listPtr)).Fstate&int32(STATE_NORMAL1) != 0 { if (*(*func(*libc.TLS, uintptr, uintptr) uintptr)(unsafe.Pointer(&struct{ uintptr }{(*TTcl_HashTable)(unsafe.Pointer((*TListbox)(unsafe.Pointer(listPtr)).Fselection)).FfindProc})))(tls, (*TListbox)(unsafe.Pointer(listPtr)).Fselection, uintptr(int64(i))) != 0 { /* * Selected items are drawn differently. */ gc = (*TListbox)(unsafe.Pointer(listPtr)).FselTextGC width = (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fchanges.Fwidth - int32(2)*(*TListbox)(unsafe.Pointer(listPtr)).Finset selectedBg = (*TListbox)(unsafe.Pointer(listPtr)).FselBorder /* * If there is attribute information for this item, adjust the * drawing accordingly. */ if entry != libc.UintptrFromInt32(0) { attrs = (*TTcl_HashEntry)(unsafe.Pointer(entry)).FclientData /* * Default GC has the values from the widget at large. */ if (*TListbox)(unsafe.Pointer(listPtr)).FselFgColorPtr != 0 { (*(*TXGCValues)(unsafe.Pointer(bp + 32))).Fforeground = (*TXColor)(unsafe.Pointer((*TListbox)(unsafe.Pointer(listPtr)).FselFgColorPtr)).Fpixel } else { (*(*TXGCValues)(unsafe.Pointer(bp + 32))).Fforeground = (*TXColor)(unsafe.Pointer((*TListbox)(unsafe.Pointer(listPtr)).FfgColorPtr)).Fpixel } (*(*TXGCValues)(unsafe.Pointer(bp + 32))).Ffont = XTk_FontId(tls, (*TListbox)(unsafe.Pointer(listPtr)).Ftkfont) (*(*TXGCValues)(unsafe.Pointer(bp + 32))).Fgraphics_exposures = False mask = libc.Uint64FromInt64(libc.Int64FromInt64(1)< 0 { bgGC = XTk_GCForColor(tls, (*TListbox)(unsafe.Pointer(listPtr)).FhighlightBgColorPtr, pixmap) if (*TListbox)(unsafe.Pointer(listPtr)).Fflags&int32(GOT_FOCUS3) != 0 { fgGC = XTk_GCForColor(tls, (*TListbox)(unsafe.Pointer(listPtr)).FhighlightColorPtr, pixmap) XTk_DrawHighlightBorder(tls, tkwin, fgGC, bgGC, *(*int32)(unsafe.Pointer(bp + 168)), pixmap) } else { XTk_DrawHighlightBorder(tls, tkwin, bgGC, bgGC, *(*int32)(unsafe.Pointer(bp + 168)), pixmap) } } libx11.XXCopyArea(tls, disp, pixmap, (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fwindow, (*TListbox)(unsafe.Pointer(listPtr)).FtextGC, 0, 0, libc.Uint32FromInt32((*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fchanges.Fwidth), libc.Uint32FromInt32((*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fchanges.Fheight), 0, 0) XTk_FreePixmap(tls, disp, pixmap) } /* *---------------------------------------------------------------------- * * ListboxComputeGeometry -- * * This procedure is invoked to recompute geometry information such as * the sizes of the elements and the overall dimensions desired for the * listbox. * * Results: * None. * * Side effects: * Geometry information is updated and a new requested size is registered * for the widget. Internal border and gridding information is also set. * *---------------------------------------------------------------------- */ func _ListboxComputeGeometry(tls *libc.TLS, listPtr uintptr, fontChanged int32, maxIsStale int32, updateGrid int32) { bp := tls.Alloc(48) defer tls.Free(48) /* Non-zero means call Tk_SetGrid or * Tk_UnsetGrid to update gridding for the * window. */ var height, i, pixelHeight, pixelWidth, result, width int32 var text uintptr var _ /* element at bp+24 */ uintptr var _ /* fm at bp+8 */ TTk_FontMetrics var _ /* selBorderWidth at bp+32 */ int32 var _ /* textLength at bp+0 */ TTcl_Size _, _, _, _, _, _, _ = height, i, pixelHeight, pixelWidth, result, text, width if fontChanged != 0 || maxIsStale != 0 { (*TListbox)(unsafe.Pointer(listPtr)).FxScrollUnit = XTk_TextWidth(tls, (*TListbox)(unsafe.Pointer(listPtr)).Ftkfont, __ccgo_ts+10533, int64(1)) if (*TListbox)(unsafe.Pointer(listPtr)).FxScrollUnit == 0 { (*TListbox)(unsafe.Pointer(listPtr)).FxScrollUnit = int32(1) } (*TListbox)(unsafe.Pointer(listPtr)).FmaxWidth = 0 i = 0 for { if !(i < int32((*TListbox)(unsafe.Pointer(listPtr)).FnElements)) { break } /* * Compute the pixel width of the current element. */ result = libtcl9_0.XTcl_ListObjIndex(tls, (*TListbox)(unsafe.Pointer(listPtr)).Finterp, (*TListbox)(unsafe.Pointer(listPtr)).FlistObj, int64(i), bp+24) if result != TCL_OK { goto _1 } text = libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(bp + 24)), bp) XTk_GetFontMetrics(tls, (*TListbox)(unsafe.Pointer(listPtr)).Ftkfont, bp+8) pixelWidth = XTk_TextWidth(tls, (*TListbox)(unsafe.Pointer(listPtr)).Ftkfont, text, *(*TTcl_Size)(unsafe.Pointer(bp))) if pixelWidth > (*TListbox)(unsafe.Pointer(listPtr)).FmaxWidth { (*TListbox)(unsafe.Pointer(listPtr)).FmaxWidth = pixelWidth } goto _1 _1: ; i++ } } XTk_GetFontMetrics(tls, (*TListbox)(unsafe.Pointer(listPtr)).Ftkfont, bp+8) XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), (*TListbox)(unsafe.Pointer(listPtr)).Ftkwin, (*TListbox)(unsafe.Pointer(listPtr)).FselBorderWidthObj, bp+32) (*TListbox)(unsafe.Pointer(listPtr)).FlineHeight = (*(*TTk_FontMetrics)(unsafe.Pointer(bp + 8))).Flinespace + int32(1) + int32(2)**(*int32)(unsafe.Pointer(bp + 32)) width = (*TListbox)(unsafe.Pointer(listPtr)).Fwidth if width <= 0 { width = ((*TListbox)(unsafe.Pointer(listPtr)).FmaxWidth + (*TListbox)(unsafe.Pointer(listPtr)).FxScrollUnit - int32(1)) / (*TListbox)(unsafe.Pointer(listPtr)).FxScrollUnit if width < int32(1) { width = int32(1) } } pixelWidth = width*(*TListbox)(unsafe.Pointer(listPtr)).FxScrollUnit + int32(2)*(*TListbox)(unsafe.Pointer(listPtr)).Finset + int32(2)**(*int32)(unsafe.Pointer(bp + 32)) height = (*TListbox)(unsafe.Pointer(listPtr)).Fheight if (*TListbox)(unsafe.Pointer(listPtr)).Fheight <= 0 { height = int32((*TListbox)(unsafe.Pointer(listPtr)).FnElements) if height < int32(1) { height = int32(1) } } pixelHeight = height*(*TListbox)(unsafe.Pointer(listPtr)).FlineHeight + int32(2)*(*TListbox)(unsafe.Pointer(listPtr)).Finset XTk_GeometryRequest(tls, (*TListbox)(unsafe.Pointer(listPtr)).Ftkwin, pixelWidth, pixelHeight) XTk_SetInternalBorder(tls, (*TListbox)(unsafe.Pointer(listPtr)).Ftkwin, (*TListbox)(unsafe.Pointer(listPtr)).Finset) if updateGrid != 0 { if (*TListbox)(unsafe.Pointer(listPtr)).FsetGrid != 0 { XTk_SetGrid(tls, (*TListbox)(unsafe.Pointer(listPtr)).Ftkwin, width, height, (*TListbox)(unsafe.Pointer(listPtr)).FxScrollUnit, (*TListbox)(unsafe.Pointer(listPtr)).FlineHeight) } else { XTk_UnsetGrid(tls, (*TListbox)(unsafe.Pointer(listPtr)).Ftkwin) } } } /* *---------------------------------------------------------------------- * * ListboxInsertSubCmd -- * * This procedure is invoked to handle the listbox "insert" subcommand. * * Results: * Standard Tcl result. * * Side effects: * New elements are added to the listbox pointed to by listPtr; a refresh * callback is registered for the listbox. * *---------------------------------------------------------------------- */ func _ListboxInsertSubCmd(tls *libc.TLS, listPtr uintptr, index TTcl_Size, objc TTcl_Size, objv uintptr) (r int32) { bp := tls.Alloc(16) defer tls.Free(16) /* New elements (one per entry). */ var _objPtr, newListObj, stringRep, v3, p4, p5, p6 uintptr var i, v2 TTcl_Size var oldMaxWidth, pixelWidth, result int32 var _ /* length at bp+0 */ TTcl_Size _, _, _, _, _, _, _, _, _, _, _, _ = _objPtr, i, newListObj, oldMaxWidth, pixelWidth, result, stringRep, v2, v3, p4, p5, p6 oldMaxWidth = (*TListbox)(unsafe.Pointer(listPtr)).FmaxWidth i = 0 for { if !(i < objc) { break } /* * Check if any of the new elements are wider than the current widest; * if so, update our notion of "widest." */ stringRep = libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(i)*8)), bp) pixelWidth = XTk_TextWidth(tls, (*TListbox)(unsafe.Pointer(listPtr)).Ftkfont, stringRep, *(*TTcl_Size)(unsafe.Pointer(bp))) if pixelWidth > (*TListbox)(unsafe.Pointer(listPtr)).FmaxWidth { (*TListbox)(unsafe.Pointer(listPtr)).FmaxWidth = pixelWidth } goto _1 _1: ; i++ } /* * Adjust selection and attribute information for every index after the * first index. */ _MigrateHashEntries(tls, (*TListbox)(unsafe.Pointer(listPtr)).Fselection, index, (*TListbox)(unsafe.Pointer(listPtr)).FnElements-int64(1), objc) _MigrateHashEntries(tls, (*TListbox)(unsafe.Pointer(listPtr)).FitemAttrTable, index, (*TListbox)(unsafe.Pointer(listPtr)).FnElements-int64(1), objc) /* * If the object is shared, duplicate it before writing to it. */ if (*TTcl_Obj)(unsafe.Pointer((*TListbox)(unsafe.Pointer(listPtr)).FlistObj)).FrefCount > int64(1) { newListObj = libtcl9_0.XTcl_DuplicateObj(tls, (*TListbox)(unsafe.Pointer(listPtr)).FlistObj) } else { newListObj = (*TListbox)(unsafe.Pointer(listPtr)).FlistObj } result = libtcl9_0.XTcl_ListObjReplace(tls, (*TListbox)(unsafe.Pointer(listPtr)).Finterp, newListObj, index, 0, objc, objv) if result != TCL_OK { return result } /* * Replace the current object and set attached listvar, if any. This may * error if listvar points to a var in a deleted namespace, but we ignore * those errors. If the namespace is recreated, it will auto-sync with the * current value. [Bug 1424513] */ (*TTcl_Obj)(unsafe.Pointer(newListObj)).FrefCount++ _objPtr = (*TListbox)(unsafe.Pointer(listPtr)).FlistObj v3 = _objPtr v2 = *(*TTcl_Size)(unsafe.Pointer(v3)) *(*TTcl_Size)(unsafe.Pointer(v3))-- if v2 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr) } (*TListbox)(unsafe.Pointer(listPtr)).FlistObj = newListObj if (*TListbox)(unsafe.Pointer(listPtr)).FlistVarNameObj != libc.UintptrFromInt32(0) { libtcl9_0.XTcl_SetVar2Ex(tls, (*TListbox)(unsafe.Pointer(listPtr)).Finterp, libtcl9_0.XTcl_GetStringFromObj(tls, (*TListbox)(unsafe.Pointer(listPtr)).FlistVarNameObj, libc.UintptrFromInt32(0)), libc.UintptrFromInt32(0), (*TListbox)(unsafe.Pointer(listPtr)).FlistObj, int32(TCL_GLOBAL_ONLY)) } /* * Get the new list length. */ libtcl9_0.XTcl_ListObjLength(tls, (*TListbox)(unsafe.Pointer(listPtr)).Finterp, (*TListbox)(unsafe.Pointer(listPtr)).FlistObj, listPtr+64) /* * Update the "special" indices (anchor, topIndex, active) to account for * the renumbering that just occurred. Then arrange for the new * information to be displayed. */ if index <= int64((*TListbox)(unsafe.Pointer(listPtr)).FselectAnchor) { p4 = listPtr + 260 *(*int32)(unsafe.Pointer(p4)) = int32(int64(*(*int32)(unsafe.Pointer(p4))) + objc) } if index < int64((*TListbox)(unsafe.Pointer(listPtr)).FtopIndex) { p5 = listPtr + 220 *(*int32)(unsafe.Pointer(p5)) = int32(int64(*(*int32)(unsafe.Pointer(p5))) + objc) } if index <= int64((*TListbox)(unsafe.Pointer(listPtr)).Factive) { p6 = listPtr + 268 *(*int32)(unsafe.Pointer(p6)) = int32(int64(*(*int32)(unsafe.Pointer(p6))) + objc) if (*TListbox)(unsafe.Pointer(listPtr)).Factive >= int32((*TListbox)(unsafe.Pointer(listPtr)).FnElements) && int32((*TListbox)(unsafe.Pointer(listPtr)).FnElements) > 0 { (*TListbox)(unsafe.Pointer(listPtr)).Factive = int32((*TListbox)(unsafe.Pointer(listPtr)).FnElements - int64(1)) } } *(*int32)(unsafe.Pointer(listPtr + 344)) |= int32(UPDATE_V_SCROLLBAR) if (*TListbox)(unsafe.Pointer(listPtr)).FmaxWidth != oldMaxWidth { *(*int32)(unsafe.Pointer(listPtr + 344)) |= int32(UPDATE_H_SCROLLBAR) } _ListboxComputeGeometry(tls, listPtr, 0, 0, 0) _EventuallyRedrawRange(tls, listPtr, index, (*TListbox)(unsafe.Pointer(listPtr)).FnElements-int64(1)) return TCL_OK } /* *---------------------------------------------------------------------- * * ListboxDeleteSubCmd -- * * Process a listbox "delete" subcommand by removing one or more elements * from a listbox widget. * * Results: * Standard Tcl result. * * Side effects: * The listbox will be modified and (eventually) redisplayed. * *---------------------------------------------------------------------- */ func _ListboxDeleteSubCmd(tls *libc.TLS, listPtr uintptr, first int32, last int32) (r int32) { bp := tls.Alloc(16) defer tls.Free(16) /* Index of last element to delete. */ var _objPtr, entry, newListObj, stringRep, v3 uintptr var count, i, pixelWidth, result, widthChanged int32 var v2 TTcl_Size var _ /* element at bp+8 */ uintptr var _ /* length at bp+0 */ TTcl_Size _, _, _, _, _, _, _, _, _, _, _ = _objPtr, count, entry, i, newListObj, pixelWidth, result, stringRep, widthChanged, v2, v3 /* * Adjust the range to fit within the existing elements of the listbox, * and make sure there's something to delete. */ if first < 0 { first = 0 } if last >= int32((*TListbox)(unsafe.Pointer(listPtr)).FnElements) { last = int32((*TListbox)(unsafe.Pointer(listPtr)).FnElements - int64(1)) } count = last + int32(1) - first if count <= 0 { return TCL_OK } /* * Foreach deleted index we must: * a) remove selection information, * b) check the width of the element; if it is equal to the max, set * widthChanged to 1, because it may be the only element with that * width. */ widthChanged = 0 i = first for { if !(i <= last) { break } /* * Remove selection information. */ entry = (*(*func(*libc.TLS, uintptr, uintptr) uintptr)(unsafe.Pointer(&struct{ uintptr }{(*TTcl_HashTable)(unsafe.Pointer((*TListbox)(unsafe.Pointer(listPtr)).Fselection)).FfindProc})))(tls, (*TListbox)(unsafe.Pointer(listPtr)).Fselection, uintptr(int64(i))) if entry != libc.UintptrFromInt32(0) { (*TListbox)(unsafe.Pointer(listPtr)).FnumSelected-- libtcl9_0.XTcl_DeleteHashEntry(tls, entry) } entry = (*(*func(*libc.TLS, uintptr, uintptr) uintptr)(unsafe.Pointer(&struct{ uintptr }{(*TTcl_HashTable)(unsafe.Pointer((*TListbox)(unsafe.Pointer(listPtr)).FitemAttrTable)).FfindProc})))(tls, (*TListbox)(unsafe.Pointer(listPtr)).FitemAttrTable, uintptr(int64(i))) if entry != libc.UintptrFromInt32(0) { libtcl9_0.XTcl_Free(tls, (*TTcl_HashEntry)(unsafe.Pointer(entry)).FclientData) libtcl9_0.XTcl_DeleteHashEntry(tls, entry) } /* * Check width of the element. We only have to check if widthChanged * has not already been set to 1, because we only need one maxWidth * element to disappear for us to have to recompute the width. */ if widthChanged == 0 { libtcl9_0.XTcl_ListObjIndex(tls, (*TListbox)(unsafe.Pointer(listPtr)).Finterp, (*TListbox)(unsafe.Pointer(listPtr)).FlistObj, int64(i), bp+8) stringRep = libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(bp + 8)), bp) pixelWidth = XTk_TextWidth(tls, (*TListbox)(unsafe.Pointer(listPtr)).Ftkfont, stringRep, *(*TTcl_Size)(unsafe.Pointer(bp))) if pixelWidth == (*TListbox)(unsafe.Pointer(listPtr)).FmaxWidth { widthChanged = int32(1) } } goto _1 _1: ; i++ } /* * Adjust selection and attribute info for indices after lastIndex. */ _MigrateHashEntries(tls, (*TListbox)(unsafe.Pointer(listPtr)).Fselection, int64(last+int32(1)), (*TListbox)(unsafe.Pointer(listPtr)).FnElements-int64(1), int64(count*-int32(1))) _MigrateHashEntries(tls, (*TListbox)(unsafe.Pointer(listPtr)).FitemAttrTable, int64(last+int32(1)), (*TListbox)(unsafe.Pointer(listPtr)).FnElements-int64(1), int64(count*-int32(1))) /* * Delete the requested elements. */ if (*TTcl_Obj)(unsafe.Pointer((*TListbox)(unsafe.Pointer(listPtr)).FlistObj)).FrefCount > int64(1) { newListObj = libtcl9_0.XTcl_DuplicateObj(tls, (*TListbox)(unsafe.Pointer(listPtr)).FlistObj) } else { newListObj = (*TListbox)(unsafe.Pointer(listPtr)).FlistObj } result = libtcl9_0.XTcl_ListObjReplace(tls, (*TListbox)(unsafe.Pointer(listPtr)).Finterp, newListObj, int64(first), int64(count), 0, libc.UintptrFromInt32(0)) if result != TCL_OK { return result } /* * Replace the current object and set attached listvar, if any. This may * error if listvar points to a var in a deleted namespace, but we ignore * those errors. If the namespace is recreated, it will auto-sync with the * current value. [Bug 1424513] */ (*TTcl_Obj)(unsafe.Pointer(newListObj)).FrefCount++ _objPtr = (*TListbox)(unsafe.Pointer(listPtr)).FlistObj v3 = _objPtr v2 = *(*TTcl_Size)(unsafe.Pointer(v3)) *(*TTcl_Size)(unsafe.Pointer(v3))-- if v2 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr) } (*TListbox)(unsafe.Pointer(listPtr)).FlistObj = newListObj if (*TListbox)(unsafe.Pointer(listPtr)).FlistVarNameObj != libc.UintptrFromInt32(0) { libtcl9_0.XTcl_SetVar2Ex(tls, (*TListbox)(unsafe.Pointer(listPtr)).Finterp, libtcl9_0.XTcl_GetStringFromObj(tls, (*TListbox)(unsafe.Pointer(listPtr)).FlistVarNameObj, libc.UintptrFromInt32(0)), libc.UintptrFromInt32(0), (*TListbox)(unsafe.Pointer(listPtr)).FlistObj, int32(TCL_GLOBAL_ONLY)) } /* * Get the new list length. */ libtcl9_0.XTcl_ListObjLength(tls, (*TListbox)(unsafe.Pointer(listPtr)).Finterp, (*TListbox)(unsafe.Pointer(listPtr)).FlistObj, listPtr+64) /* * Update the selection and viewing information to reflect the change in * the element numbering, and redisplay to slide information up over the * elements that were deleted. */ if first <= (*TListbox)(unsafe.Pointer(listPtr)).FselectAnchor { *(*int32)(unsafe.Pointer(listPtr + 260)) -= count if (*TListbox)(unsafe.Pointer(listPtr)).FselectAnchor < first { (*TListbox)(unsafe.Pointer(listPtr)).FselectAnchor = first } } if first <= (*TListbox)(unsafe.Pointer(listPtr)).FtopIndex { *(*int32)(unsafe.Pointer(listPtr + 220)) -= count if (*TListbox)(unsafe.Pointer(listPtr)).FtopIndex < first { (*TListbox)(unsafe.Pointer(listPtr)).FtopIndex = first } } if (*TListbox)(unsafe.Pointer(listPtr)).FtopIndex > int32((*TListbox)(unsafe.Pointer(listPtr)).FnElements)-(*TListbox)(unsafe.Pointer(listPtr)).FfullLines { (*TListbox)(unsafe.Pointer(listPtr)).FtopIndex = int32((*TListbox)(unsafe.Pointer(listPtr)).FnElements - int64((*TListbox)(unsafe.Pointer(listPtr)).FfullLines)) if (*TListbox)(unsafe.Pointer(listPtr)).FtopIndex < 0 { (*TListbox)(unsafe.Pointer(listPtr)).FtopIndex = 0 } } if (*TListbox)(unsafe.Pointer(listPtr)).Factive > last { *(*int32)(unsafe.Pointer(listPtr + 268)) -= count } else { if (*TListbox)(unsafe.Pointer(listPtr)).Factive >= first { (*TListbox)(unsafe.Pointer(listPtr)).Factive = first if (*TListbox)(unsafe.Pointer(listPtr)).Factive >= int32((*TListbox)(unsafe.Pointer(listPtr)).FnElements) && int32((*TListbox)(unsafe.Pointer(listPtr)).FnElements) > 0 { (*TListbox)(unsafe.Pointer(listPtr)).Factive = int32((*TListbox)(unsafe.Pointer(listPtr)).FnElements - int64(1)) } } } *(*int32)(unsafe.Pointer(listPtr + 344)) |= int32(UPDATE_V_SCROLLBAR) _ListboxComputeGeometry(tls, listPtr, 0, widthChanged, 0) if widthChanged != 0 { *(*int32)(unsafe.Pointer(listPtr + 344)) |= int32(UPDATE_H_SCROLLBAR) } _EventuallyRedrawRange(tls, listPtr, int64(first), (*TListbox)(unsafe.Pointer(listPtr)).FnElements-int64(1)) return TCL_OK } /* *-------------------------------------------------------------- * * ListboxEventProc -- * * This procedure is invoked by the Tk dispatcher for various events on * listboxes. * * Results: * None. * * Side effects: * When the window gets deleted, internal structures get cleaned up. When * it gets exposed, it is redisplayed. * *-------------------------------------------------------------- */ func _ListboxEventProc(tls *libc.TLS, clientData uintptr, eventPtr uintptr) { /* Information about event. */ var listPtr uintptr var vertSpace int32 _, _ = listPtr, vertSpace listPtr = clientData if (*TXEvent)(unsafe.Pointer(eventPtr)).Ftype1 == int32(Expose) { _EventuallyRedrawRange(tls, listPtr, int64(_NearestListboxElement(tls, listPtr, (*(*TXExposeEvent)(unsafe.Pointer(eventPtr))).Fy)), int64(_NearestListboxElement(tls, listPtr, (*(*TXExposeEvent)(unsafe.Pointer(eventPtr))).Fy+(*(*TXExposeEvent)(unsafe.Pointer(eventPtr))).Fheight))) } else { if (*TXEvent)(unsafe.Pointer(eventPtr)).Ftype1 == int32(DestroyNotify) { if !((*TListbox)(unsafe.Pointer(listPtr)).Fflags&libc.Int32FromInt32(LISTBOX_DELETED) != 0) { *(*int32)(unsafe.Pointer(listPtr + 344)) |= int32(LISTBOX_DELETED) libtcl9_0.XTcl_DeleteCommandFromToken(tls, (*TListbox)(unsafe.Pointer(listPtr)).Finterp, (*TListbox)(unsafe.Pointer(listPtr)).FwidgetCmd) if (*TListbox)(unsafe.Pointer(listPtr)).FsetGrid != 0 { XTk_UnsetGrid(tls, (*TListbox)(unsafe.Pointer(listPtr)).Ftkwin) } if (*TListbox)(unsafe.Pointer(listPtr)).Fflags&int32(REDRAW_PENDING) != 0 { libtcl9_0.XTcl_CancelIdleCall(tls, __ccgo_fp(_DisplayListbox), clientData) } libtcl9_0.XTcl_EventuallyFree(tls, clientData, __ccgo_fp(_DestroyListbox)) } } else { if (*TXEvent)(unsafe.Pointer(eventPtr)).Ftype1 == int32(ConfigureNotify) { vertSpace = (*TTk_FakeWin)(unsafe.Pointer((*TListbox)(unsafe.Pointer(listPtr)).Ftkwin)).Fchanges.Fheight - int32(2)*(*TListbox)(unsafe.Pointer(listPtr)).Finset (*TListbox)(unsafe.Pointer(listPtr)).FfullLines = vertSpace / (*TListbox)(unsafe.Pointer(listPtr)).FlineHeight if (*TListbox)(unsafe.Pointer(listPtr)).FfullLines*(*TListbox)(unsafe.Pointer(listPtr)).FlineHeight < vertSpace { (*TListbox)(unsafe.Pointer(listPtr)).FpartialLine = int32(1) } else { (*TListbox)(unsafe.Pointer(listPtr)).FpartialLine = 0 } *(*int32)(unsafe.Pointer(listPtr + 344)) |= libc.Int32FromInt32(UPDATE_V_SCROLLBAR) | libc.Int32FromInt32(UPDATE_H_SCROLLBAR) _ChangeListboxView(tls, listPtr, (*TListbox)(unsafe.Pointer(listPtr)).FtopIndex) _ChangeListboxOffset(tls, listPtr, (*TListbox)(unsafe.Pointer(listPtr)).FxOffset) /* * Redraw the whole listbox. It's hard to tell what needs to be * redrawn (e.g. if the listbox has shrunk then we may only need to * redraw the borders), so just redraw everything for safety. */ _EventuallyRedrawRange(tls, listPtr, 0, (*TListbox)(unsafe.Pointer(listPtr)).FnElements-int64(1)) } else { if (*TXEvent)(unsafe.Pointer(eventPtr)).Ftype1 == int32(FocusIn) { if (*(*TXFocusChangeEvent)(unsafe.Pointer(eventPtr))).Fdetail != int32(NotifyInferior) { *(*int32)(unsafe.Pointer(listPtr + 344)) |= int32(GOT_FOCUS3) _EventuallyRedrawRange(tls, listPtr, 0, (*TListbox)(unsafe.Pointer(listPtr)).FnElements-int64(1)) } } else { if (*TXEvent)(unsafe.Pointer(eventPtr)).Ftype1 == int32(FocusOut) { if (*(*TXFocusChangeEvent)(unsafe.Pointer(eventPtr))).Fdetail != int32(NotifyInferior) { *(*int32)(unsafe.Pointer(listPtr + 344)) &= ^libc.Int32FromInt32(GOT_FOCUS3) _EventuallyRedrawRange(tls, listPtr, 0, (*TListbox)(unsafe.Pointer(listPtr)).FnElements-int64(1)) } } } } } } } /* *---------------------------------------------------------------------- * * ListboxCmdDeletedProc -- * * This procedure is invoked when a widget command is deleted. If the * widget isn't already in the process of being destroyed, this command * destroys it. * * Results: * None. * * Side effects: * The widget is destroyed. * *---------------------------------------------------------------------- */ func _ListboxCmdDeletedProc(tls *libc.TLS, clientData uintptr) { /* Pointer to widget record for widget. */ var listPtr uintptr _ = listPtr listPtr = clientData /* * This procedure could be invoked either because the window was destroyed * and the command was then deleted (in which case tkwin is NULL) or * because the command was deleted, and then this procedure destroys the * widget. */ if !((*TListbox)(unsafe.Pointer(listPtr)).Fflags&libc.Int32FromInt32(LISTBOX_DELETED) != 0) { XTk_DestroyWindow(tls, (*TListbox)(unsafe.Pointer(listPtr)).Ftkwin) } } /* *-------------------------------------------------------------- * * GetListboxIndex -- * * Parse an index into a listbox and return either its value or an error. * * Results: * A standard Tcl result. If all went well, then *indexPtr is filled in * with the index (into listPtr) corresponding to string. Otherwise an * error message is left in the interp's result. * * Side effects: * None. * *-------------------------------------------------------------- */ func _GetListboxIndex(tls *libc.TLS, interp uintptr, listPtr uintptr, indexObj uintptr, lastOK int32, indexPtr uintptr) (r int32) { bp := tls.Alloc(64) defer tls.Free(64) /* Where to store converted index. */ var rest, start, stringRep uintptr var result int32 var _ /* idx at bp+0 */ TTcl_Size var _ /* index at bp+8 */ TTcl_Size var _ /* y at bp+16 */ int32 _, _, _, _ = rest, result, start, stringRep result = XTkGetIntForIndex(tls, indexObj, (*TListbox)(unsafe.Pointer(listPtr)).FnElements-int64(1), lastOK, bp) if result == TCL_OK { if *(*TTcl_Size)(unsafe.Pointer(bp)) != int64(-libc.Int32FromInt32(1)) && *(*TTcl_Size)(unsafe.Pointer(bp)) > (*TListbox)(unsafe.Pointer(listPtr)).FnElements { *(*TTcl_Size)(unsafe.Pointer(bp)) = (*TListbox)(unsafe.Pointer(listPtr)).FnElements } *(*TTcl_Size)(unsafe.Pointer(indexPtr)) = *(*TTcl_Size)(unsafe.Pointer(bp)) return TCL_OK } /* * First see if the index is one of the named indices. */ result = libtcl9_0.XTcl_GetIndexFromObjStruct(tls, libc.UintptrFromInt32(0), indexObj, uintptr(unsafe.Pointer(&_indexNames)), libc.Int64FromUint64(libc.Uint64FromInt64(8)), __ccgo_ts+195, libc.Int32FromInt32(0)|libc.Int32FromUint64(libc.Uint64FromInt64(8)<= int32((*TListbox)(unsafe.Pointer(listPtr)).FnElements)-(*TListbox)(unsafe.Pointer(listPtr)).FfullLines { index = int32((*TListbox)(unsafe.Pointer(listPtr)).FnElements - int64((*TListbox)(unsafe.Pointer(listPtr)).FfullLines)) } if index < 0 { index = 0 } if (*TListbox)(unsafe.Pointer(listPtr)).FtopIndex != index { (*TListbox)(unsafe.Pointer(listPtr)).FtopIndex = index _EventuallyRedrawRange(tls, listPtr, 0, (*TListbox)(unsafe.Pointer(listPtr)).FnElements-int64(1)) *(*int32)(unsafe.Pointer(listPtr + 344)) |= int32(UPDATE_V_SCROLLBAR) } } /* *---------------------------------------------------------------------- * * ChangListboxOffset -- * * Change the horizontal offset for a listbox. * * Results: * None. * * Side effects: * The listbox may be redrawn to reflect its new horizontal offset. * *---------------------------------------------------------------------- */ func _ChangeListboxOffset(tls *libc.TLS, listPtr uintptr, offset int32) { /* Desired new "xOffset" for listbox. */ var maxOffset int32 _ = maxOffset /* * Make sure that the new offset is within the allowable range, and round * it off to an even multiple of xScrollUnit. * * Add half a scroll unit to do entry/text-like synchronization. [Bug * #225025] */ offset += (*TListbox)(unsafe.Pointer(listPtr)).FxScrollUnit / int32(2) maxOffset = _GetMaxOffset(tls, listPtr) if offset > maxOffset { offset = maxOffset } if offset < 0 { offset = 0 } offset -= offset % (*TListbox)(unsafe.Pointer(listPtr)).FxScrollUnit if offset != (*TListbox)(unsafe.Pointer(listPtr)).FxOffset { (*TListbox)(unsafe.Pointer(listPtr)).FxOffset = offset *(*int32)(unsafe.Pointer(listPtr + 344)) |= int32(UPDATE_H_SCROLLBAR) _EventuallyRedrawRange(tls, listPtr, 0, (*TListbox)(unsafe.Pointer(listPtr)).FnElements-int64(1)) } } /* *---------------------------------------------------------------------- * * ListboxScanTo -- * * Given a point (presumably of the curent mouse location) drag the view * in the window to implement the scan operation. * * Results: * None. * * Side effects: * The view in the window may change. * *---------------------------------------------------------------------- */ func _ListboxScanTo(tls *libc.TLS, listPtr uintptr, x int32, y int32) { /* Y-coordinate to use for scan operation. */ var maxIndex, maxOffset, newOffset, newTopIndex, v1, v2, v3, v4 int32 _, _, _, _, _, _, _, _ = maxIndex, maxOffset, newOffset, newTopIndex, v1, v2, v3, v4 maxIndex = int32((*TListbox)(unsafe.Pointer(listPtr)).FnElements - int64((*TListbox)(unsafe.Pointer(listPtr)).FfullLines)) maxOffset = _GetMaxOffset(tls, listPtr) /* * Compute new top line for screen by amplifying the difference between * the current position and the place where the scan started (the "mark" * position). If we run off the top or bottom of the list, then reset the * mark point so that the current position continues to correspond to the * edge of the window. This means that the picture will start dragging as * soon as the mouse reverses direction (without this reset, might have to * slide mouse a long ways back before the picture starts moving again). */ newTopIndex = (*TListbox)(unsafe.Pointer(listPtr)).FscanMarkYIndex - int32(10)*(y-(*TListbox)(unsafe.Pointer(listPtr)).FscanMarkY)/(*TListbox)(unsafe.Pointer(listPtr)).FlineHeight if newTopIndex > maxIndex { v1 = maxIndex (*TListbox)(unsafe.Pointer(listPtr)).FscanMarkYIndex = v1 newTopIndex = v1 (*TListbox)(unsafe.Pointer(listPtr)).FscanMarkY = y } else { if newTopIndex < 0 { v2 = libc.Int32FromInt32(0) (*TListbox)(unsafe.Pointer(listPtr)).FscanMarkYIndex = v2 newTopIndex = v2 (*TListbox)(unsafe.Pointer(listPtr)).FscanMarkY = y } } _ChangeListboxView(tls, listPtr, newTopIndex) /* * Compute new left edge for display in a similar fashion by amplifying * the difference between the current position and the place where the * scan started. */ newOffset = (*TListbox)(unsafe.Pointer(listPtr)).FscanMarkXOffset - int32(10)*(x-(*TListbox)(unsafe.Pointer(listPtr)).FscanMarkX) if newOffset > maxOffset { v3 = maxOffset (*TListbox)(unsafe.Pointer(listPtr)).FscanMarkXOffset = v3 newOffset = v3 (*TListbox)(unsafe.Pointer(listPtr)).FscanMarkX = x } else { if newOffset < 0 { v4 = libc.Int32FromInt32(0) (*TListbox)(unsafe.Pointer(listPtr)).FscanMarkXOffset = v4 newOffset = v4 (*TListbox)(unsafe.Pointer(listPtr)).FscanMarkX = x } } _ChangeListboxOffset(tls, listPtr, newOffset) } /* *---------------------------------------------------------------------- * * NearestListboxElement -- * * Given a y-coordinate inside a listbox, compute the index of the * element under that y-coordinate (or closest to that y-coordinate). * * Results: * The return value is an index of an element of listPtr. If listPtr has * no elements, then 0 is always returned. * * Side effects: * None. * *---------------------------------------------------------------------- */ func _NearestListboxElement(tls *libc.TLS, listPtr uintptr, y int32) (r int32) { /* Y-coordinate in listPtr's window. */ var index int32 _ = index index = (y - (*TListbox)(unsafe.Pointer(listPtr)).Finset) / (*TListbox)(unsafe.Pointer(listPtr)).FlineHeight if index >= (*TListbox)(unsafe.Pointer(listPtr)).FfullLines+(*TListbox)(unsafe.Pointer(listPtr)).FpartialLine { index = (*TListbox)(unsafe.Pointer(listPtr)).FfullLines + (*TListbox)(unsafe.Pointer(listPtr)).FpartialLine - int32(1) } if index < 0 { index = 0 } index += (*TListbox)(unsafe.Pointer(listPtr)).FtopIndex if index >= int32((*TListbox)(unsafe.Pointer(listPtr)).FnElements) { index = int32((*TListbox)(unsafe.Pointer(listPtr)).FnElements - int64(1)) } return index } /* *---------------------------------------------------------------------- * * ListboxSelect -- * * Select or deselect one or more elements in a listbox.. * * Results: * Standard Tcl result. * * Side effects: * All of the elements in the range between first and last are marked as * either selected or deselected, depending on the "select" argument. Any * items whose state changes are redisplayed. The selection is claimed * from X when the number of selected elements changes from zero to * non-zero. * *---------------------------------------------------------------------- */ func _ListboxSelect(tls *libc.TLS, listPtr uintptr, first int32, last int32, select1 int32) (r int32) { bp := tls.Alloc(16) defer tls.Free(16) /* 1 means select items, 0 means deselect * them. */ var entry uintptr var firstRedisplay, i, oldCount int32 var _ /* isNew at bp+0 */ int32 _, _, _, _ = entry, firstRedisplay, i, oldCount if last < first { i = first first = last last = i } if last < 0 || first >= int32((*TListbox)(unsafe.Pointer(listPtr)).FnElements) { return TCL_OK } if first < 0 { first = 0 } if last >= int32((*TListbox)(unsafe.Pointer(listPtr)).FnElements) { last = int32((*TListbox)(unsafe.Pointer(listPtr)).FnElements - int64(1)) } oldCount = (*TListbox)(unsafe.Pointer(listPtr)).FnumSelected firstRedisplay = -int32(1) /* * For each index in the range, find it in our selection hash table. If * it's not there but should be, add it. If it's there but shouldn't be, * remove it. */ i = first for { if !(i <= last) { break } entry = (*(*func(*libc.TLS, uintptr, uintptr) uintptr)(unsafe.Pointer(&struct{ uintptr }{(*TTcl_HashTable)(unsafe.Pointer((*TListbox)(unsafe.Pointer(listPtr)).Fselection)).FfindProc})))(tls, (*TListbox)(unsafe.Pointer(listPtr)).Fselection, uintptr(int64(i))) if entry != libc.UintptrFromInt32(0) { if !(select1 != 0) { libtcl9_0.XTcl_DeleteHashEntry(tls, entry) (*TListbox)(unsafe.Pointer(listPtr)).FnumSelected-- if firstRedisplay < 0 { firstRedisplay = i } } } else { if select1 != 0 { entry = (*(*func(*libc.TLS, uintptr, uintptr, uintptr) uintptr)(unsafe.Pointer(&struct{ uintptr }{(*TTcl_HashTable)(unsafe.Pointer((*TListbox)(unsafe.Pointer(listPtr)).Fselection)).FcreateProc})))(tls, (*TListbox)(unsafe.Pointer(listPtr)).Fselection, uintptr(int64(i)), bp) (*TTcl_HashEntry)(unsafe.Pointer(entry)).FclientData = libc.UintptrFromInt32(0) (*TListbox)(unsafe.Pointer(listPtr)).FnumSelected++ if firstRedisplay < 0 { firstRedisplay = i } } } goto _1 _1: ; i++ } if firstRedisplay >= 0 { _EventuallyRedrawRange(tls, listPtr, int64(first), int64(last)) } if oldCount == 0 && (*TListbox)(unsafe.Pointer(listPtr)).FnumSelected > 0 && (*TListbox)(unsafe.Pointer(listPtr)).FexportSelection != 0 && !(libtcl9_0.XTcl_IsSafe(tls, (*TListbox)(unsafe.Pointer(listPtr)).Finterp) != 0) { XTk_OwnSelection(tls, (*TListbox)(unsafe.Pointer(listPtr)).Ftkwin, libc.Uint64FromInt32(1), __ccgo_fp(_ListboxLostSelection), listPtr) } return TCL_OK } /* *---------------------------------------------------------------------- * * ListboxFetchSelection -- * * This procedure is called back by Tk when the selection is requested by * someone. It returns part or all of the selection in a buffer provided * by the caller. * * Results: * The return value is the number of non-NULL bytes stored at buffer. * Buffer is filled (or partially filled) with a NULL-terminated string * containing part or all of the selection, as given by offset and * maxBytes. The selection is returned as a Tcl list with one list * element for each element in the listbox. * * Side effects: * None. * *---------------------------------------------------------------------- */ func _ListboxFetchSelection(tls *libc.TLS, clientData uintptr, offset TTcl_Size, buffer uintptr, maxBytes TTcl_Size) (r TTcl_Size) { bp := tls.Alloc(240) defer tls.Free(240) /* Maximum number of bytes to place at buffer, * not including terminating NULL * character. */ var count, i, needNewline int32 var entry, listPtr, stringRep uintptr var length TTcl_Size var _ /* curElement at bp+232 */ uintptr var _ /* selection at bp+0 */ TTcl_DString var _ /* stringLen at bp+224 */ TTcl_Size _, _, _, _, _, _, _ = count, entry, i, length, listPtr, needNewline, stringRep listPtr = clientData if !((*TListbox)(unsafe.Pointer(listPtr)).FexportSelection != 0) || libtcl9_0.XTcl_IsSafe(tls, (*TListbox)(unsafe.Pointer(listPtr)).Finterp) != 0 { return int64(-int32(1)) } /* * Use a dynamic string to accumulate the contents of the selection. */ needNewline = 0 libtcl9_0.XTcl_DStringInit(tls, bp) i = 0 for { if !(i < int32((*TListbox)(unsafe.Pointer(listPtr)).FnElements)) { break } entry = (*(*func(*libc.TLS, uintptr, uintptr) uintptr)(unsafe.Pointer(&struct{ uintptr }{(*TTcl_HashTable)(unsafe.Pointer((*TListbox)(unsafe.Pointer(listPtr)).Fselection)).FfindProc})))(tls, (*TListbox)(unsafe.Pointer(listPtr)).Fselection, uintptr(int64(i))) if entry != libc.UintptrFromInt32(0) { if needNewline != 0 { libtcl9_0.XTcl_DStringAppend(tls, bp, __ccgo_ts+14046, int64(1)) } libtcl9_0.XTcl_ListObjIndex(tls, (*TListbox)(unsafe.Pointer(listPtr)).Finterp, (*TListbox)(unsafe.Pointer(listPtr)).FlistObj, int64(i), bp+232) stringRep = libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(bp + 232)), bp+224) libtcl9_0.XTcl_DStringAppend(tls, bp, stringRep, *(*TTcl_Size)(unsafe.Pointer(bp + 224))) needNewline = int32(1) } goto _1 _1: ; i++ } length = (*TTcl_DString)(unsafe.Pointer(bp)).Flength if length == 0 { return int64(-int32(1)) } /* * Copy the requested portion of the selection to the buffer. */ if length <= offset { count = 0 } else { count = int32(length - offset) if count > int32(maxBytes) { count = int32(maxBytes) } libc.Xmemcpy(tls, buffer, (*TTcl_DString)(unsafe.Pointer(bp)).Fstring1+uintptr(offset), libc.Uint64FromInt32(count)) } *(*uint8)(unsafe.Pointer(buffer + uintptr(count))) = uint8('\000') libtcl9_0.XTcl_DStringFree(tls, bp) return int64(count) } /* *---------------------------------------------------------------------- * * ListboxLostSelection -- * * This procedure is called back by Tk when the selection is grabbed away * from a listbox widget. * * Results: * None. * * Side effects: * The existing selection is unhighlighted, and the window is marked as * not containing a selection. * *---------------------------------------------------------------------- */ func _ListboxLostSelection(tls *libc.TLS, clientData uintptr) { /* Information about listbox widget. */ var listPtr uintptr _ = listPtr listPtr = clientData if (*TListbox)(unsafe.Pointer(listPtr)).FexportSelection != 0 && !(libtcl9_0.XTcl_IsSafe(tls, (*TListbox)(unsafe.Pointer(listPtr)).Finterp) != 0) && (*TListbox)(unsafe.Pointer(listPtr)).FnElements > 0 { _ListboxSelect(tls, listPtr, 0, int32((*TListbox)(unsafe.Pointer(listPtr)).FnElements-int64(1)), 0) _GenerateListboxSelectEvent(tls, listPtr) } } /* *---------------------------------------------------------------------- * * GenerateListboxSelectEvent -- * * Send an event that the listbox selection was updated. This is * equivalent to event generate $listboxWidget <> * * Results: * None * * Side effects: * Any side effect possible, depending on bindings to this event. * *---------------------------------------------------------------------- */ func _GenerateListboxSelectEvent(tls *libc.TLS, listPtr uintptr) { /* Information about widget. */ XTk_SendVirtualEvent(tls, (*TListbox)(unsafe.Pointer(listPtr)).Ftkwin, __ccgo_ts+23989, libc.UintptrFromInt32(0)) } /* *---------------------------------------------------------------------- * * EventuallyRedrawRange -- * * Ensure that a given range of elements is eventually redrawn on the * display (if those elements in fact appear on the display). * * Results: * None. * * Side effects: * Information gets redisplayed. * *---------------------------------------------------------------------- */ func _EventuallyRedrawRange(tls *libc.TLS, listPtr uintptr, dummy3242 TTcl_Size, dummy3244 TTcl_Size) { /* Index of last element in list that needs to * be redrawn. May be less than first; these * just bracket a range. */ /* * We don't have to register a redraw callback if one is already pending, * or if the window doesn't exist, or if the window isn't mapped. */ if (*TListbox)(unsafe.Pointer(listPtr)).Fflags&int32(REDRAW_PENDING) != 0 || (*TListbox)(unsafe.Pointer(listPtr)).Fflags&int32(LISTBOX_DELETED) != 0 || !((*TTk_FakeWin)(unsafe.Pointer((*TListbox)(unsafe.Pointer(listPtr)).Ftkwin)).Fflags&libc.Uint32FromInt32(TK_MAPPED) != 0) { return } *(*int32)(unsafe.Pointer(listPtr + 344)) |= int32(REDRAW_PENDING) libtcl9_0.XTcl_DoWhenIdle(tls, __ccgo_fp(_DisplayListbox), listPtr) } /* *---------------------------------------------------------------------- * * ListboxUpdateVScrollbar -- * * This procedure is invoked whenever information has changed in a * listbox in a way that would invalidate a vertical scrollbar display. * If there is an associated scrollbar, then this command updates it by * invoking a Tcl command. * * Results: * None. * * Side effects: * A Tcl command is invoked, and an additional command may be invoked to * process errors in the command. * *---------------------------------------------------------------------- */ func _ListboxUpdateVScrollbar(tls *libc.TLS, listPtr uintptr) { bp := tls.Alloc(288) defer tls.Free(288) /* Information about widget. */ var first, last float64 var interp uintptr var result int32 var _ /* buf at bp+56 */ TTcl_DString var _ /* firstStr at bp+0 */ [27]uint8 var _ /* lastStr at bp+27 */ [27]uint8 _, _, _, _ = first, interp, last, result if (*TListbox)(unsafe.Pointer(listPtr)).FyScrollCmdObj == libc.UintptrFromInt32(0) { return } if (*TListbox)(unsafe.Pointer(listPtr)).FnElements == 0 { first = float64(0) last = float64(1) } else { first = float64((*TListbox)(unsafe.Pointer(listPtr)).FtopIndex) / float64((*TListbox)(unsafe.Pointer(listPtr)).FnElements) last = float64((*TListbox)(unsafe.Pointer(listPtr)).FtopIndex+(*TListbox)(unsafe.Pointer(listPtr)).FfullLines) / float64((*TListbox)(unsafe.Pointer(listPtr)).FnElements) if last > float64(1) { last = float64(1) } } libtcl9_0.XTcl_PrintDouble(tls, libc.UintptrFromInt32(0), first, bp) libtcl9_0.XTcl_PrintDouble(tls, libc.UintptrFromInt32(0), last, bp+27) /* * We must hold onto the interpreter from the listPtr because the data at * listPtr might be freed as a result of the Tcl_EvalEx. */ interp = (*TListbox)(unsafe.Pointer(listPtr)).Finterp libtcl9_0.XTcl_Preserve(tls, interp) libtcl9_0.XTcl_DStringInit(tls, bp+56) libtcl9_0.XTcl_DStringAppend(tls, bp+56, libtcl9_0.XTcl_GetStringFromObj(tls, (*TListbox)(unsafe.Pointer(listPtr)).FyScrollCmdObj, libc.UintptrFromInt32(0)), int64(-libc.Int32FromInt32(1))) libtcl9_0.XTcl_DStringAppend(tls, bp+56, __ccgo_ts+634, int64(-libc.Int32FromInt32(1))) libtcl9_0.XTcl_DStringAppend(tls, bp+56, bp, int64(-libc.Int32FromInt32(1))) libtcl9_0.XTcl_DStringAppend(tls, bp+56, __ccgo_ts+634, int64(-libc.Int32FromInt32(1))) libtcl9_0.XTcl_DStringAppend(tls, bp+56, bp+27, int64(-libc.Int32FromInt32(1))) result = libtcl9_0.XTcl_EvalEx(tls, interp, (*TTcl_DString)(unsafe.Pointer(bp+56)).Fstring1, int64(-libc.Int32FromInt32(1)), int32(TCL_EVAL_GLOBAL)) libtcl9_0.XTcl_DStringFree(tls, bp+56) if result != TCL_OK { libtcl9_0.XTcl_AppendObjToErrorInfo(tls, interp, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+24003, int64(-int32(1)))) libtcl9_0.XTcl_BackgroundException(tls, interp, result) } libtcl9_0.XTcl_Release(tls, interp) } /* *---------------------------------------------------------------------- * * ListboxUpdateHScrollbar -- * * This procedure is invoked whenever information has changed in a * listbox in a way that would invalidate a horizontal scrollbar display. * If there is an associated horizontal scrollbar, then this command * updates it by invoking a Tcl command. * * Results: * None. * * Side effects: * A Tcl command is invoked, and an additional command may be invoked to * process errors in the command. * *---------------------------------------------------------------------- */ func _ListboxUpdateHScrollbar(tls *libc.TLS, listPtr uintptr) { bp := tls.Alloc(288) defer tls.Free(288) /* Information about widget. */ var first, last float64 var interp uintptr var result, windowWidth int32 var _ /* buf at bp+56 */ TTcl_DString var _ /* firstStr at bp+0 */ [27]uint8 var _ /* lastStr at bp+27 */ [27]uint8 var _ /* selBorderWidth at bp+280 */ int32 _, _, _, _, _ = first, interp, last, result, windowWidth if (*TListbox)(unsafe.Pointer(listPtr)).FxScrollCmdObj == libc.UintptrFromInt32(0) { return } XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), (*TListbox)(unsafe.Pointer(listPtr)).Ftkwin, (*TListbox)(unsafe.Pointer(listPtr)).FselBorderWidthObj, bp+280) windowWidth = (*TTk_FakeWin)(unsafe.Pointer((*TListbox)(unsafe.Pointer(listPtr)).Ftkwin)).Fchanges.Fwidth - int32(2)*((*TListbox)(unsafe.Pointer(listPtr)).Finset+*(*int32)(unsafe.Pointer(bp + 280))) if (*TListbox)(unsafe.Pointer(listPtr)).FmaxWidth == 0 { first = libc.Float64FromInt32(0) last = float64(1) } else { first = float64((*TListbox)(unsafe.Pointer(listPtr)).FxOffset) / float64((*TListbox)(unsafe.Pointer(listPtr)).FmaxWidth) last = float64((*TListbox)(unsafe.Pointer(listPtr)).FxOffset+windowWidth) / float64((*TListbox)(unsafe.Pointer(listPtr)).FmaxWidth) if last > float64(1) { last = float64(1) } } libtcl9_0.XTcl_PrintDouble(tls, libc.UintptrFromInt32(0), first, bp) libtcl9_0.XTcl_PrintDouble(tls, libc.UintptrFromInt32(0), last, bp+27) /* * We must hold onto the interpreter because the data referred to at * listPtr might be freed as a result of the call to Tcl_EvalEx. */ interp = (*TListbox)(unsafe.Pointer(listPtr)).Finterp libtcl9_0.XTcl_Preserve(tls, interp) libtcl9_0.XTcl_DStringInit(tls, bp+56) libtcl9_0.XTcl_DStringAppend(tls, bp+56, libtcl9_0.XTcl_GetStringFromObj(tls, (*TListbox)(unsafe.Pointer(listPtr)).FxScrollCmdObj, libc.UintptrFromInt32(0)), int64(-libc.Int32FromInt32(1))) libtcl9_0.XTcl_DStringAppend(tls, bp+56, __ccgo_ts+634, int64(-libc.Int32FromInt32(1))) libtcl9_0.XTcl_DStringAppend(tls, bp+56, bp, int64(-libc.Int32FromInt32(1))) libtcl9_0.XTcl_DStringAppend(tls, bp+56, __ccgo_ts+634, int64(-libc.Int32FromInt32(1))) libtcl9_0.XTcl_DStringAppend(tls, bp+56, bp+27, int64(-libc.Int32FromInt32(1))) result = libtcl9_0.XTcl_EvalEx(tls, interp, (*TTcl_DString)(unsafe.Pointer(bp+56)).Fstring1, int64(-libc.Int32FromInt32(1)), int32(TCL_EVAL_GLOBAL)) libtcl9_0.XTcl_DStringFree(tls, bp+56) if result != TCL_OK { libtcl9_0.XTcl_AppendObjToErrorInfo(tls, interp, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+24057, int64(-int32(1)))) libtcl9_0.XTcl_BackgroundException(tls, interp, result) } libtcl9_0.XTcl_Release(tls, interp) } /* *---------------------------------------------------------------------- * * ListboxListVarProc -- * * Called whenever the trace on the listbox list var fires. * * Results: * None. * * Side effects: * None. * *---------------------------------------------------------------------- */ func _ListboxListVarProc(tls *libc.TLS, clientData uintptr, interp uintptr, dummy3426 uintptr, dummy3427 uintptr, flags int32) (r uintptr) { bp := tls.Alloc(16) defer tls.Free(16) /* Information about what happened. */ var _objPtr, entry, listPtr, oldListObj, probe, varListObj, v2 uintptr var oldLength, v1 TTcl_Size var _ /* i at bp+0 */ TTcl_Size _, _, _, _, _, _, _, _, _ = _objPtr, entry, listPtr, oldLength, oldListObj, probe, varListObj, v1, v2 listPtr = clientData /* * Bwah hahahaha! Puny mortal, you can't unset a -listvar'd variable! */ if flags&int32(TCL_TRACE_UNSETS) != 0 { if !(libtcl9_0.XTcl_InterpDeleted(tls, interp) != 0) && (*TListbox)(unsafe.Pointer(listPtr)).FlistVarNameObj != 0 { probe = libc.UintptrFromInt32(0) for cond := true; cond; cond = probe != 0 { probe = libtcl9_0.XTcl_VarTraceInfo2(tls, interp, libtcl9_0.XTcl_GetStringFromObj(tls, (*TListbox)(unsafe.Pointer(listPtr)).FlistVarNameObj, libc.UintptrFromInt32(0)), libc.UintptrFromInt32(0), libc.Int32FromInt32(TCL_GLOBAL_ONLY)|libc.Int32FromInt32(TCL_TRACE_WRITES)|libc.Int32FromInt32(TCL_TRACE_UNSETS), __ccgo_fp(_ListboxListVarProc), probe) if probe == listPtr { break } } if probe != 0 { /* * We were able to fetch the unset trace for our * listVarName, which means it is not unset and not * the cause of this unset trace. Instead some outdated * former variable must be, and we should ignore it. */ return libc.UintptrFromInt32(0) } libtcl9_0.XTcl_SetVar2Ex(tls, interp, libtcl9_0.XTcl_GetStringFromObj(tls, (*TListbox)(unsafe.Pointer(listPtr)).FlistVarNameObj, libc.UintptrFromInt32(0)), libc.UintptrFromInt32(0), (*TListbox)(unsafe.Pointer(listPtr)).FlistObj, int32(TCL_GLOBAL_ONLY)) libtcl9_0.XTcl_TraceVar2(tls, interp, libtcl9_0.XTcl_GetStringFromObj(tls, (*TListbox)(unsafe.Pointer(listPtr)).FlistVarNameObj, libc.UintptrFromInt32(0)), libc.UintptrFromInt32(0), libc.Int32FromInt32(TCL_GLOBAL_ONLY)|libc.Int32FromInt32(TCL_TRACE_WRITES)|libc.Int32FromInt32(TCL_TRACE_UNSETS), __ccgo_fp(_ListboxListVarProc), clientData) return libc.UintptrFromInt32(0) } } else { oldListObj = (*TListbox)(unsafe.Pointer(listPtr)).FlistObj varListObj = libtcl9_0.XTcl_GetVar2Ex(tls, (*TListbox)(unsafe.Pointer(listPtr)).Finterp, libtcl9_0.XTcl_GetStringFromObj(tls, (*TListbox)(unsafe.Pointer(listPtr)).FlistVarNameObj, libc.UintptrFromInt32(0)), libc.UintptrFromInt32(0), int32(TCL_GLOBAL_ONLY)) /* * Make sure the new value is a good list; if it's not, disallow the * change - the fact that it is a listvar means that it must always be * a valid list - and return an error message. */ if libtcl9_0.XTcl_ListObjLength(tls, (*TListbox)(unsafe.Pointer(listPtr)).Finterp, varListObj, bp) != TCL_OK { libtcl9_0.XTcl_SetVar2Ex(tls, interp, libtcl9_0.XTcl_GetStringFromObj(tls, (*TListbox)(unsafe.Pointer(listPtr)).FlistVarNameObj, libc.UintptrFromInt32(0)), libc.UintptrFromInt32(0), oldListObj, int32(TCL_GLOBAL_ONLY)) return __ccgo_ts + 24113 } (*TListbox)(unsafe.Pointer(listPtr)).FlistObj = varListObj /* * Incr the obj ref count so it doesn't vanish if the var is unset. */ (*TTcl_Obj)(unsafe.Pointer((*TListbox)(unsafe.Pointer(listPtr)).FlistObj)).FrefCount++ /* * Clean up the ref to our old list obj. */ _objPtr = oldListObj v2 = _objPtr v1 = *(*TTcl_Size)(unsafe.Pointer(v2)) *(*TTcl_Size)(unsafe.Pointer(v2))-- if v1 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr) } } /* * If the list length has decreased, then we should clean up selection and * attributes information for elements past the end of the new list. */ oldLength = (*TListbox)(unsafe.Pointer(listPtr)).FnElements libtcl9_0.XTcl_ListObjLength(tls, (*TListbox)(unsafe.Pointer(listPtr)).Finterp, (*TListbox)(unsafe.Pointer(listPtr)).FlistObj, listPtr+64) if (*TListbox)(unsafe.Pointer(listPtr)).FnElements < oldLength { *(*TTcl_Size)(unsafe.Pointer(bp)) = (*TListbox)(unsafe.Pointer(listPtr)).FnElements for { if !(*(*TTcl_Size)(unsafe.Pointer(bp)) < oldLength) { break } /* * Clean up selection. */ entry = (*(*func(*libc.TLS, uintptr, uintptr) uintptr)(unsafe.Pointer(&struct{ uintptr }{(*TTcl_HashTable)(unsafe.Pointer((*TListbox)(unsafe.Pointer(listPtr)).Fselection)).FfindProc})))(tls, (*TListbox)(unsafe.Pointer(listPtr)).Fselection, uintptr(*(*TTcl_Size)(unsafe.Pointer(bp)))) if entry != libc.UintptrFromInt32(0) { (*TListbox)(unsafe.Pointer(listPtr)).FnumSelected-- libtcl9_0.XTcl_DeleteHashEntry(tls, entry) } /* * Clean up attributes. */ entry = (*(*func(*libc.TLS, uintptr, uintptr) uintptr)(unsafe.Pointer(&struct{ uintptr }{(*TTcl_HashTable)(unsafe.Pointer((*TListbox)(unsafe.Pointer(listPtr)).FitemAttrTable)).FfindProc})))(tls, (*TListbox)(unsafe.Pointer(listPtr)).FitemAttrTable, uintptr(*(*TTcl_Size)(unsafe.Pointer(bp)))) if entry != libc.UintptrFromInt32(0) { libtcl9_0.XTcl_Free(tls, (*TTcl_HashEntry)(unsafe.Pointer(entry)).FclientData) libtcl9_0.XTcl_DeleteHashEntry(tls, entry) } goto _3 _3: ; *(*TTcl_Size)(unsafe.Pointer(bp))++ } } if oldLength != (*TListbox)(unsafe.Pointer(listPtr)).FnElements { *(*int32)(unsafe.Pointer(listPtr + 344)) |= int32(UPDATE_V_SCROLLBAR) if (*TListbox)(unsafe.Pointer(listPtr)).FtopIndex > int32((*TListbox)(unsafe.Pointer(listPtr)).FnElements)-(*TListbox)(unsafe.Pointer(listPtr)).FfullLines { (*TListbox)(unsafe.Pointer(listPtr)).FtopIndex = int32((*TListbox)(unsafe.Pointer(listPtr)).FnElements - int64((*TListbox)(unsafe.Pointer(listPtr)).FfullLines)) if (*TListbox)(unsafe.Pointer(listPtr)).FtopIndex < 0 { (*TListbox)(unsafe.Pointer(listPtr)).FtopIndex = 0 } } } /* * The computed maxWidth may have changed as a result of this operation. * However, we don't want to recompute it every time this trace fires * (imagine the user doing 1000 lappends to the listvar). Therefore, set * the MAXWIDTH_IS_STALE flag, which will cause the width to be recomputed * next time the list is redrawn. */ *(*int32)(unsafe.Pointer(listPtr + 344)) |= int32(MAXWIDTH_IS_STALE) _EventuallyRedrawRange(tls, listPtr, 0, (*TListbox)(unsafe.Pointer(listPtr)).FnElements-int64(1)) return libc.UintptrFromInt32(0) } /* *---------------------------------------------------------------------- * * MigrateHashEntries -- * * Given a hash table with entries keyed by a single integer value, move * all entries in a given range by a fixed amount, so that if in the * original table there was an entry with key n and the offset was i, in * the new table that entry would have key n + i. * * Results: * None. * * Side effects: * Rekeys some hash table entries. * *---------------------------------------------------------------------- */ func _MigrateHashEntries(tls *libc.TLS, table uintptr, first TTcl_Size, last TTcl_Size, offset TTcl_Size) { bp := tls.Alloc(16) defer tls.Free(16) var clientData, entry uintptr var i TTcl_Size var _ /* isNew at bp+0 */ int32 _, _, _ = clientData, entry, i if offset == 0 { return } /* * It's more efficient to do one if/else and nest the for loops inside, * although we could avoid some code duplication if we nested the if/else * inside the for loops. */ if offset > 0 { i = last for { if !(i >= first) { break } entry = (*(*func(*libc.TLS, uintptr, uintptr) uintptr)(unsafe.Pointer(&struct{ uintptr }{(*TTcl_HashTable)(unsafe.Pointer(table)).FfindProc})))(tls, table, uintptr(i)) if entry != libc.UintptrFromInt32(0) { clientData = (*TTcl_HashEntry)(unsafe.Pointer(entry)).FclientData libtcl9_0.XTcl_DeleteHashEntry(tls, entry) entry = (*(*func(*libc.TLS, uintptr, uintptr, uintptr) uintptr)(unsafe.Pointer(&struct{ uintptr }{(*TTcl_HashTable)(unsafe.Pointer(table)).FcreateProc})))(tls, table, uintptr(i+offset), bp) (*TTcl_HashEntry)(unsafe.Pointer(entry)).FclientData = clientData } goto _1 _1: ; i-- } } else { i = first for { if !(i <= last) { break } entry = (*(*func(*libc.TLS, uintptr, uintptr) uintptr)(unsafe.Pointer(&struct{ uintptr }{(*TTcl_HashTable)(unsafe.Pointer(table)).FfindProc})))(tls, table, uintptr(i)) if entry != libc.UintptrFromInt32(0) { clientData = (*TTcl_HashEntry)(unsafe.Pointer(entry)).FclientData libtcl9_0.XTcl_DeleteHashEntry(tls, entry) entry = (*(*func(*libc.TLS, uintptr, uintptr, uintptr) uintptr)(unsafe.Pointer(&struct{ uintptr }{(*TTcl_HashTable)(unsafe.Pointer(table)).FcreateProc})))(tls, table, uintptr(i+offset), bp) (*TTcl_HashEntry)(unsafe.Pointer(entry)).FclientData = clientData } goto _2 _2: ; i++ } } return } // C documentation // // /* // *---------------------------------------------------------------------- // * // * GetMaxOffset -- // * // * Passing in a listbox pointer, returns the maximum offset for the box, // * i.e. the maximum possible horizontal scrolling value (in pixels). // * // * Results: // * Listbox's maxOffset. // * // * Side effects: // * None. // * // *---------------------------------------------------------------------- // */ func _GetMaxOffset(tls *libc.TLS, listPtr uintptr) (r int32) { bp := tls.Alloc(16) defer tls.Free(16) var maxOffset int32 var _ /* selBorderWidth at bp+0 */ int32 _ = maxOffset XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), (*TListbox)(unsafe.Pointer(listPtr)).Ftkwin, (*TListbox)(unsafe.Pointer(listPtr)).FselBorderWidthObj, bp) maxOffset = (*TListbox)(unsafe.Pointer(listPtr)).FmaxWidth - ((*TTk_FakeWin)(unsafe.Pointer((*TListbox)(unsafe.Pointer(listPtr)).Ftkwin)).Fchanges.Fwidth - int32(2)*(*TListbox)(unsafe.Pointer(listPtr)).Finset - int32(2)**(*int32)(unsafe.Pointer(bp))) + (*TListbox)(unsafe.Pointer(listPtr)).FxScrollUnit - int32(1) if maxOffset < 0 { /* * Listbox is larger in width than its largest width item. */ maxOffset = 0 } maxOffset -= maxOffset % (*TListbox)(unsafe.Pointer(listPtr)).FxScrollUnit return maxOffset } const CASCADE_ARROW_HEIGHT = 10 const CASCADE_ARROW_WIDTH = 8 const CASCADE_ENTRY = 0 const CHECK_BUTTON_ENTRY = 1 const COMMAND_ENTRY = 2 const DECORATION_BORDER_WIDTH = 2 const ENTRY_ACTIVE = 0 const ENTRY_DISABLED = 1 const ENTRY_LAST_COLUMN = 4 const ENTRY_NEEDS_REDISPLAY = 2 const ENTRY_NORMAL = 2 const ENTRY_PLATFORM_FLAG1 = 1073741824 const ENTRY_PLATFORM_FLAG2 = 536870912 const ENTRY_PLATFORM_FLAG3 = 268435456 const ENTRY_PLATFORM_FLAG4 = 134217728 const ENTRY_SELECTED = 1 const MAIN_MENU = 1 const MENUBAR = 0 const MENU_DELETION_PENDING = 4 const MENU_HASH_KEY = "tkMenus" const MENU_PLATFORM_FLAG1 = 1073741824 const MENU_PLATFORM_FLAG2 = 536870912 const MENU_PLATFORM_FLAG3 = 268435456 const MENU_WIN_DESTRUCTION_PENDING = 8 const RADIO_BUTTON_ENTRY = 3 const RESIZE_PENDING = 2 const SEPARATOR_ENTRY = 4 const TEAROFF_ENTRY = 5 const TEAROFF_MENU = 2 const UNKNOWN_TYPE = -1 type TTkMenuPlatformData = uintptr type TTkMenuPlatformEntryData = uintptr type drawingParameters = int32 const DRAW_MENU_ENTRY_ARROW = 1 const DRAW_MENU_ENTRY_NOUNDERLINE = 2 type TTkMenuEntry = struct { Ftype1 int32 FmenuPtr uintptr FoptionTable TTk_OptionTable FlabelPtr uintptr FlabelLength TTcl_Size Fstate int32 Funderline int32 FunderlinePtr uintptr FbitmapPtr uintptr FimagePtr uintptr Fimage TTk_Image FselectImagePtr uintptr FselectImage TTk_Image FaccelPtr uintptr FaccelLength TTcl_Size FindicatorOn int32 FborderPtr uintptr FfgPtr uintptr FactiveBorderPtr uintptr FactiveFgPtr uintptr FindicatorFgPtr uintptr FfontPtr uintptr FcolumnBreak int32 FhideMargin int32 FindicatorSpace int32 FlabelWidth int32 Fcompound int32 FcommandPtr uintptr FnamePtr uintptr FonValuePtr uintptr FoffValuePtr uintptr Fwidth int32 Fx int32 Fheight int32 Fy int32 FtextGC TGC FactiveGC TGC FdisabledGC TGC FindicatorGC TGC FentryFlags int32 Findex int32 FentryPtr uintptr FchildMenuRefPtr uintptr FnextCascadePtr uintptr FplatformEntryData TTkMenuPlatformEntryData } type TTkMenu = struct { Ftkwin TTk_Window Fdisplay uintptr Finterp uintptr FwidgetCmd TTcl_Command Fentries uintptr FnumEntries TTcl_Size Factive TTcl_Size FmenuType int32 FmenuTypePtr uintptr FborderPtr uintptr FborderWidthObj uintptr FactiveBorderPtr uintptr FactiveBorderWidthPtr uintptr Frelief int32 FfontPtr uintptr FfgPtr uintptr FdisabledFgPtr uintptr FactiveFgPtr uintptr FindicatorFgPtr uintptr Fgray TPixmap FtextGC TGC FdisabledGC TGC FactiveGC TGC FindicatorGC TGC FdisabledImageGC TGC FtotalWidth int32 FtotalHeight int32 Ftearoff int32 FtitlePtr uintptr FtearoffCommandPtr uintptr FtakeFocusPtr uintptr FcursorPtr uintptr FpostCommandPtr uintptr FpostCommandGeneration int32 FmenuFlags int32 FpostedCascade uintptr FnextInstancePtr uintptr FmainMenuPtr uintptr Freserved1 uintptr FparentTopLevelPtr TTk_Window FmenuRefPtr uintptr FplatformData TTkMenuPlatformData FextensionPtr uintptr FerrorStructPtr uintptr FactiveRelief int32 Fitems TTcl_HashTable Fserial int32 } type TTkMenuTopLevelList = struct { FnextPtr uintptr Ftkwin TTk_Window } type TTkMenuReferences = struct { FmenuPtr uintptr FtopLevelListPtr uintptr FparentEntryPtr uintptr FhashEntryPtr uintptr } type TThreadSpecificData11 = struct { FmenusInitialized int32 FmenuOptionTable TTk_OptionTable FentryOptionTables [6]TTk_OptionTable } var _dataKey11 TTcl_ThreadDataKey /* * The following flag indicates whether the process-wide state for the Menu * module has been initialized. The Mutex protects access to that flag. */ var _menusInitialized int32 var _menuMutex TTcl_Mutex /* * Configuration specs for individual menu entries. If this changes, be sure * to update code in TkpMenuInit that changes the font string entry. */ var _menuEntryTypeStrings = [6]uintptr{ 0: __ccgo_ts + 24135, 1: __ccgo_ts + 17875, 2: __ccgo_ts + 20495, 3: __ccgo_ts + 17960, 4: __ccgo_ts + 24143, 5: libc.UintptrFromInt32(0), } var _tkBasicMenuEntryConfigSpecs = [16]TTk_OptionSpec{ 0: { Ftype1: int32(TK_OPTION_BORDER), FoptionName: __ccgo_ts + 19775, FobjOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 136)), FinternalOffset: int64(-libc.Int32FromInt32(1)), Fflags: int32(TCL_NULL_OK), }, 1: { Ftype1: int32(TK_OPTION_COLOR), FoptionName: __ccgo_ts + 19837, FobjOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 144)), FinternalOffset: int64(-libc.Int32FromInt32(1)), Fflags: int32(TCL_NULL_OK), }, 2: { Ftype1: int32(TK_OPTION_STRING), FoptionName: __ccgo_ts + 24153, FobjOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 96)), FinternalOffset: int64(-libc.Int32FromInt32(1)), Fflags: int32(TCL_NULL_OK), }, 3: { Ftype1: int32(TK_OPTION_BORDER), FoptionName: __ccgo_ts + 19898, FobjOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 120)), FinternalOffset: int64(-libc.Int32FromInt32(1)), Fflags: int32(TCL_NULL_OK), }, 4: { Ftype1: int32(TK_OPTION_BITMAP), FoptionName: __ccgo_ts + 19937, FobjOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 56)), FinternalOffset: int64(-libc.Int32FromInt32(1)), Fflags: int32(TCL_NULL_OK), }, 5: { FoptionName: __ccgo_ts + 24166, FdefValue: __ccgo_ts + 10533, FobjOffset: int64(-libc.Int32FromInt32(1)), FinternalOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 168)), }, 6: { Ftype1: int32(TK_OPTION_STRING), FoptionName: __ccgo_ts + 16356, FobjOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 192)), FinternalOffset: int64(-libc.Int32FromInt32(1)), Fflags: int32(TCL_NULL_OK), }, 7: { Ftype1: int32(TK_OPTION_STRING_TABLE), FoptionName: __ccgo_ts + 19976, FdbName: __ccgo_ts + 19986, FdbClass: __ccgo_ts + 19995, FdefValue: __ccgo_ts + 8223, FobjOffset: int64(-libc.Int32FromInt32(1)), FinternalOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 184)), FclientData: uintptr(unsafe.Pointer(&XtkCompoundStrings)), }, 8: { Ftype1: int32(TK_OPTION_FONT), FoptionName: __ccgo_ts + 20097, FobjOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 160)), FinternalOffset: int64(-libc.Int32FromInt32(1)), Fflags: int32(TCL_NULL_OK), }, 9: { Ftype1: int32(TK_OPTION_COLOR), FoptionName: __ccgo_ts + 20085, FobjOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 128)), FinternalOffset: int64(-libc.Int32FromInt32(1)), Fflags: int32(TCL_NULL_OK), }, 10: { FoptionName: __ccgo_ts + 24179, FdefValue: __ccgo_ts + 10533, FobjOffset: int64(-libc.Int32FromInt32(1)), FinternalOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 172)), }, 11: { Ftype1: int32(TK_OPTION_STRING), FoptionName: __ccgo_ts + 20294, FobjOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 64)), FinternalOffset: int64(-libc.Int32FromInt32(1)), Fflags: int32(TCL_NULL_OK), }, 12: { Ftype1: int32(TK_OPTION_STRING), FoptionName: __ccgo_ts + 24191, FobjOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 24)), FinternalOffset: int64(-libc.Int32FromInt32(1)), }, 13: { Ftype1: int32(TK_OPTION_STRING_TABLE), FoptionName: __ccgo_ts + 2957, FdefValue: __ccgo_ts + 9363, FobjOffset: int64(-libc.Int32FromInt32(1)), FinternalOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 40)), FclientData: uintptr(unsafe.Pointer(&XtkStateStrings)), }, 14: { Ftype1: int32(TK_OPTION_INDEX), FoptionName: __ccgo_ts + 9507, FobjOffset: int64(-libc.Int32FromInt32(1)), FinternalOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 44)), Fflags: int32(TCL_NULL_OK), }, 15: { Ftype1: int32(TK_OPTION_END), }, } var _tkSeparatorEntryConfigSpecs = [2]TTk_OptionSpec{ 0: { Ftype1: int32(TK_OPTION_BORDER), FoptionName: __ccgo_ts + 19898, FobjOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 120)), FinternalOffset: int64(-libc.Int32FromInt32(1)), Fflags: int32(TCL_NULL_OK), }, 1: { Ftype1: int32(TK_OPTION_END), }, } var _tkCheckButtonEntryConfigSpecs = [7]TTk_OptionSpec{ 0: { FoptionName: __ccgo_ts + 20628, FdefValue: __ccgo_ts + 14538, FobjOffset: int64(-libc.Int32FromInt32(1)), FinternalOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 112)), }, 1: { Ftype1: int32(TK_OPTION_STRING), FoptionName: __ccgo_ts + 20696, FdefValue: __ccgo_ts + 10533, FobjOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 216)), FinternalOffset: int64(-libc.Int32FromInt32(1)), }, 2: { Ftype1: int32(TK_OPTION_STRING), FoptionName: __ccgo_ts + 20721, FdefValue: __ccgo_ts + 14538, FobjOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 208)), FinternalOffset: int64(-libc.Int32FromInt32(1)), }, 3: { Ftype1: int32(TK_OPTION_COLOR), FoptionName: __ccgo_ts + 20738, FobjOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 152)), FinternalOffset: int64(-libc.Int32FromInt32(1)), Fflags: int32(TCL_NULL_OK), }, 4: { Ftype1: int32(TK_OPTION_STRING), FoptionName: __ccgo_ts + 20763, FobjOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 80)), FinternalOffset: int64(-libc.Int32FromInt32(1)), Fflags: int32(TCL_NULL_OK), }, 5: { Ftype1: int32(TK_OPTION_STRING), FoptionName: __ccgo_ts + 20886, FobjOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 200)), FinternalOffset: int64(-libc.Int32FromInt32(1)), Fflags: int32(TCL_NULL_OK), }, 6: { Ftype1: int32(TK_OPTION_END), FinternalOffset: int64(-libc.Int32FromInt32(1)), FclientData: uintptr(unsafe.Pointer(&_tkBasicMenuEntryConfigSpecs)), }, } var _tkRadioButtonEntryConfigSpecs = [6]TTk_OptionSpec{ 0: { FoptionName: __ccgo_ts + 20628, FdefValue: __ccgo_ts + 14538, FobjOffset: int64(-libc.Int32FromInt32(1)), FinternalOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 112)), }, 1: { Ftype1: int32(TK_OPTION_COLOR), FoptionName: __ccgo_ts + 20738, FobjOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 152)), FinternalOffset: int64(-libc.Int32FromInt32(1)), Fflags: int32(TCL_NULL_OK), }, 2: { Ftype1: int32(TK_OPTION_STRING), FoptionName: __ccgo_ts + 20763, FobjOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 80)), FinternalOffset: int64(-libc.Int32FromInt32(1)), Fflags: int32(TCL_NULL_OK), }, 3: { Ftype1: int32(TK_OPTION_STRING), FoptionName: __ccgo_ts + 20896, FobjOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 208)), FinternalOffset: int64(-libc.Int32FromInt32(1)), Fflags: int32(TCL_NULL_OK), }, 4: { Ftype1: int32(TK_OPTION_STRING), FoptionName: __ccgo_ts + 20886, FdefValue: __ccgo_ts + 20909, FobjOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 200)), FinternalOffset: int64(-libc.Int32FromInt32(1)), }, 5: { Ftype1: int32(TK_OPTION_END), FinternalOffset: int64(-libc.Int32FromInt32(1)), FclientData: uintptr(unsafe.Pointer(&_tkBasicMenuEntryConfigSpecs)), }, } var _tkCascadeEntryConfigSpecs = [2]TTk_OptionSpec{ 0: { Ftype1: int32(TK_OPTION_STRING), FoptionName: __ccgo_ts + 23078, FobjOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 200)), FinternalOffset: int64(-libc.Int32FromInt32(1)), Fflags: int32(TCL_NULL_OK), }, 1: { Ftype1: int32(TK_OPTION_END), FinternalOffset: int64(-libc.Int32FromInt32(1)), FclientData: uintptr(unsafe.Pointer(&_tkBasicMenuEntryConfigSpecs)), }, } var _tkTearoffEntryConfigSpecs = [3]TTk_OptionSpec{ 0: { Ftype1: int32(TK_OPTION_BORDER), FoptionName: __ccgo_ts + 19898, FobjOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 120)), FinternalOffset: int64(-libc.Int32FromInt32(1)), Fflags: int32(TCL_NULL_OK), }, 1: { Ftype1: int32(TK_OPTION_STRING_TABLE), FoptionName: __ccgo_ts + 2957, FdefValue: __ccgo_ts + 9363, FobjOffset: int64(-libc.Int32FromInt32(1)), FinternalOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 40)), FclientData: uintptr(unsafe.Pointer(&XtkStateStrings)), }, 2: { Ftype1: int32(TK_OPTION_END), }, } var _specsArray = [6]uintptr{ 0: uintptr(unsafe.Pointer(&_tkCascadeEntryConfigSpecs)), 1: uintptr(unsafe.Pointer(&_tkCheckButtonEntryConfigSpecs)), 2: uintptr(unsafe.Pointer(&_tkBasicMenuEntryConfigSpecs)), 3: uintptr(unsafe.Pointer(&_tkRadioButtonEntryConfigSpecs)), 4: uintptr(unsafe.Pointer(&_tkSeparatorEntryConfigSpecs)), 5: uintptr(unsafe.Pointer(&_tkTearoffEntryConfigSpecs)), } /* * Menu type strings for use with Tcl_GetIndexFromObj. */ var _menuTypeStrings = [4]uintptr{ 0: __ccgo_ts + 24198, 1: __ccgo_ts + 9363, 2: __ccgo_ts + 24206, 3: libc.UintptrFromInt32(0), } var _tkMenuConfigSpecs = [22]TTk_OptionSpec{ 0: { Ftype1: int32(TK_OPTION_BORDER), FoptionName: __ccgo_ts + 19775, FdbName: __ccgo_ts + 19793, FdbClass: __ccgo_ts + 19810, FdefValue: __ccgo_ts + 19821, FobjOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 88)), FinternalOffset: int64(-libc.Int32FromInt32(1)), FclientData: __ccgo_ts + 19829, }, 1: { Ftype1: int32(TK_OPTION_PIXELS), FoptionName: __ccgo_ts + 24214, FdbName: __ccgo_ts + 24233, FdbClass: __ccgo_ts + 19964, FdefValue: __ccgo_ts + 14538, FobjOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 96)), FinternalOffset: int64(-libc.Int32FromInt32(1)), }, 2: { Ftype1: int32(TK_OPTION_COLOR), FoptionName: __ccgo_ts + 19837, FdbName: __ccgo_ts + 19855, FdbClass: __ccgo_ts + 19872, FdefValue: __ccgo_ts + 19829, FobjOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 136)), FinternalOffset: int64(-libc.Int32FromInt32(1)), FclientData: __ccgo_ts + 19883, }, 3: { Ftype1: int32(TK_OPTION_RELIEF), FoptionName: __ccgo_ts + 24251, FdbName: __ccgo_ts + 24265, FdbClass: __ccgo_ts + 20354, FdefValue: __ccgo_ts + 12, FobjOffset: int64(-libc.Int32FromInt32(1)), FinternalOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 336)), }, 4: { Ftype1: int32(TK_OPTION_BORDER), FoptionName: __ccgo_ts + 19898, FdbName: __ccgo_ts + 19910, FdbClass: __ccgo_ts + 19872, FdefValue: __ccgo_ts + 19921, FobjOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 72)), FinternalOffset: int64(-libc.Int32FromInt32(1)), FclientData: __ccgo_ts + 19883, }, 5: { Ftype1: int32(TK_OPTION_SYNONYM), FoptionName: __ccgo_ts + 19929, FinternalOffset: int64(-libc.Int32FromInt32(1)), FclientData: __ccgo_ts + 2814, }, 6: { Ftype1: int32(TK_OPTION_SYNONYM), FoptionName: __ccgo_ts + 19933, FinternalOffset: int64(-libc.Int32FromInt32(1)), FclientData: __ccgo_ts + 19898, }, 7: { Ftype1: int32(TK_OPTION_PIXELS), FoptionName: __ccgo_ts + 2814, FdbName: __ccgo_ts + 19952, FdbClass: __ccgo_ts + 19964, FdefValue: __ccgo_ts + 14538, FobjOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 80)), FinternalOffset: int64(-libc.Int32FromInt32(1)), }, 8: { Ftype1: int32(TK_OPTION_CURSOR), FoptionName: __ccgo_ts + 4638, FdbName: __ccgo_ts + 4646, FdbClass: __ccgo_ts + 4653, FdefValue: __ccgo_ts + 24278, FobjOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 240)), FinternalOffset: int64(-libc.Int32FromInt32(1)), Fflags: int32(TCL_NULL_OK), }, 9: { Ftype1: int32(TK_OPTION_COLOR), FoptionName: __ccgo_ts + 20004, FdbName: __ccgo_ts + 20024, FdbClass: __ccgo_ts + 20043, FdefValue: __ccgo_ts + 20062, FobjOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 128)), FinternalOffset: int64(-libc.Int32FromInt32(1)), Fflags: int32(TCL_NULL_OK), FclientData: __ccgo_ts + 195, }, 10: { Ftype1: int32(TK_OPTION_SYNONYM), FoptionName: __ccgo_ts + 20070, FinternalOffset: int64(-libc.Int32FromInt32(1)), FclientData: __ccgo_ts + 20085, }, 11: { Ftype1: int32(TK_OPTION_FONT), FoptionName: __ccgo_ts + 20097, FdbName: __ccgo_ts + 9358, FdbClass: __ccgo_ts + 20103, FdefValue: __ccgo_ts + 24284, FobjOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 112)), FinternalOffset: int64(-libc.Int32FromInt32(1)), }, 12: { Ftype1: int32(TK_OPTION_COLOR), FoptionName: __ccgo_ts + 20085, FdbName: __ccgo_ts + 20074, FdbClass: __ccgo_ts + 19810, FdefValue: __ccgo_ts + 19829, FobjOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 120)), FinternalOffset: int64(-libc.Int32FromInt32(1)), }, 13: { Ftype1: int32(TK_OPTION_STRING), FoptionName: __ccgo_ts + 24295, FdbName: __ccgo_ts + 24308, FdbClass: __ccgo_ts + 1659, FdefValue: __ccgo_ts + 195, FobjOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 248)), FinternalOffset: int64(-libc.Int32FromInt32(1)), Fflags: int32(TCL_NULL_OK), }, 14: { Ftype1: int32(TK_OPTION_RELIEF), FoptionName: __ccgo_ts + 20346, FdbName: __ccgo_ts + 82, FdbClass: __ccgo_ts + 20354, FdefValue: __ccgo_ts + 12, FobjOffset: int64(-libc.Int32FromInt32(1)), FinternalOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 104)), }, 15: { Ftype1: int32(TK_OPTION_COLOR), FoptionName: __ccgo_ts + 20738, FdbName: __ccgo_ts + 20751, FdbClass: __ccgo_ts + 19872, FdefValue: __ccgo_ts + 19829, FobjOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 144)), FinternalOffset: int64(-libc.Int32FromInt32(1)), FclientData: __ccgo_ts + 19829, }, 16: { Ftype1: int32(TK_OPTION_STRING), FoptionName: __ccgo_ts + 20367, FdbName: __ccgo_ts + 20378, FdbClass: __ccgo_ts + 20388, FdefValue: __ccgo_ts + 10533, FobjOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 232)), FinternalOffset: int64(-libc.Int32FromInt32(1)), Fflags: int32(TCL_NULL_OK), }, 17: { FoptionName: __ccgo_ts + 24320, FdbName: __ccgo_ts + 24329, FdbClass: __ccgo_ts + 24337, FdefValue: __ccgo_ts + 10533, FobjOffset: int64(-libc.Int32FromInt32(1)), FinternalOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 208)), }, 18: { Ftype1: int32(TK_OPTION_STRING), FoptionName: __ccgo_ts + 24345, FdbName: __ccgo_ts + 24361, FdbClass: __ccgo_ts + 24376, FobjOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 224)), FinternalOffset: int64(-libc.Int32FromInt32(1)), Fflags: int32(TCL_NULL_OK), }, 19: { Ftype1: int32(TK_OPTION_STRING), FoptionName: __ccgo_ts + 24391, FdbName: __ccgo_ts + 8379, FdbClass: __ccgo_ts + 24398, FdefValue: __ccgo_ts + 195, FobjOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 216)), FinternalOffset: int64(-libc.Int32FromInt32(1)), Fflags: int32(TCL_NULL_OK), }, 20: { Ftype1: int32(TK_OPTION_STRING_TABLE), FoptionName: __ccgo_ts + 4989, FdbName: __ccgo_ts + 24404, FdbClass: __ccgo_ts + 24409, FdefValue: __ccgo_ts + 9363, FobjOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 64)), FinternalOffset: int64(-libc.Int32FromInt32(1)), FclientData: uintptr(unsafe.Pointer(&_menuTypeStrings)), }, 21: { Ftype1: int32(TK_OPTION_END), }, } /* * Command line options. Put here because MenuCmd has to look at them along * with MenuWidgetObjCmd. */ var _menuOptions = [19]uintptr{ 0: __ccgo_ts + 23629, 1: __ccgo_ts + 2651, 2: __ccgo_ts + 4735, 3: __ccgo_ts + 24414, 4: __ccgo_ts + 4740, 5: __ccgo_ts + 2655, 6: __ccgo_ts + 24420, 7: __ccgo_ts + 24430, 8: __ccgo_ts + 6179, 9: __ccgo_ts + 22152, 10: __ccgo_ts + 22158, 11: __ccgo_ts + 20930, 12: __ccgo_ts + 24445, 13: __ccgo_ts + 24450, 14: __ccgo_ts + 24404, 15: __ccgo_ts + 24462, 16: __ccgo_ts + 24469, 17: __ccgo_ts + 24479, 18: libc.UintptrFromInt32(0), } type options = int32 const MENU_ACTIVATE = 0 const MENU_ADD = 1 const MENU_CGET = 2 const MENU_CLONE = 3 const MENU_CONFIGURE = 4 const MENU_DELETE = 5 const MENU_ENTRYCGET = 6 const MENU_ENTRYCONFIGURE = 7 const MENU_ID = 8 const MENU_INDEX = 9 const MENU_INSERT = 10 const MENU_INVOKE = 11 const MENU_POST = 12 const MENU_POSTCASCADE = 13 const MENU_TYPE = 14 const MENU_UNPOST = 15 const MENU_XPOSITION = 16 const MENU_YPOSITION = 17 /* * The structure below is a list of procs that respond to certain window * manager events. One of these includes a font change, which forces the * geometry proc to be called. */ var _menuClass = TTk_ClassProcs{ Fsize: int64(32), } func init() { p := unsafe.Pointer(&_menuClass) *(*uintptr)(unsafe.Add(p, 8)) = __ccgo_fp(_MenuWorldChanged) } /* *-------------------------------------------------------------- * * Tk_MenuObjCmd -- * * This function is invoked to process the "menu" Tcl command. See the * user documentation for details on what it does. * * Results: * A standard Tcl result. * * Side effects: * See the user documentation. * *-------------------------------------------------------------- */ func XTk_MenuObjCmd(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) (r int32) { bp := tls.Alloc(32) defer tls.Free(32) /* Argument strings. */ var _objPtr, _objPtr1, _objPtr2, _objPtr3, _objPtr4, _objPtr5, cascadeListPtr, menuPtr, menuRefPtr, newMenuName, nextCascadePtr, nextPtr, normalPtr, topLevelListPtr, tsdPtr, windowName, windowNamePtr, v10, v12, v14, v2, v4, v6, v8 uintptr var i, v11, v13, v3, v5, v7, v9 TTcl_Size var listtkwin, newWin, tkwin TTk_Window var toplevel int32 var _ /* index at bp+0 */ int32 var _ /* newObjv at bp+8 */ [2]uintptr _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = _objPtr, _objPtr1, _objPtr2, _objPtr3, _objPtr4, _objPtr5, cascadeListPtr, i, listtkwin, menuPtr, menuRefPtr, newMenuName, newWin, nextCascadePtr, nextPtr, normalPtr, tkwin, topLevelListPtr, toplevel, tsdPtr, windowName, windowNamePtr, v10, v11, v12, v13, v14, v2, v3, v4, v5, v6, v7, v8, v9 tkwin = clientData tsdPtr = libtcl9_0.XTcl_GetThreadData(tls, uintptr(unsafe.Pointer(&_dataKey11)), int64(64)) if objc < int32(2) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(1), objv, __ccgo_ts+20960) return int32(TCL_ERROR) } XTkMenuInit(tls) toplevel = int32(1) i = int64(2) for { if !(i < int64(objc-libc.Int32FromInt32(1))) { break } if libtcl9_0.XTcl_GetIndexFromObjStruct(tls, libc.UintptrFromInt32(0), *(*uintptr)(unsafe.Pointer(objv + uintptr(i)*8)), uintptr(unsafe.Pointer(&_typeStringList)), libc.Int64FromUint64(libc.Uint64FromInt64(8)), libc.UintptrFromInt32(0), libc.Int32FromInt32(0)|libc.Int32FromUint64(libc.Uint64FromInt64(4)<= 0 && ((*TTkMenuEntry)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer((*TTkMenu)(unsafe.Pointer(menuPtr)).Fentries + uintptr(*(*TTcl_Size)(unsafe.Pointer(bp + 8)))*8)))).Ftype1 == int32(SEPARATOR_ENTRY) || (*TTkMenuEntry)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer((*TTkMenu)(unsafe.Pointer(menuPtr)).Fentries + uintptr(*(*TTcl_Size)(unsafe.Pointer(bp + 8)))*8)))).Fstate == int32(ENTRY_DISABLED)) { *(*TTcl_Size)(unsafe.Pointer(bp + 8)) = int64(-libc.Int32FromInt32(1)) } result = XTkActivateMenuEntry(tls, menuPtr, *(*TTcl_Size)(unsafe.Pointer(bp + 8))) case int32(MENU_ADD): if objc < int32(3) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(2), objv, __ccgo_ts+24489) goto error } if _MenuAddOrInsert(tls, interp, menuPtr, libc.UintptrFromInt32(0), int64(objc-int32(2)), objv+uintptr(2)*8) != TCL_OK { goto error } case int32(MENU_CGET): if objc != int32(3) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(2), objv, __ccgo_ts+2689) goto error } resultPtr = XTk_GetOptionValue(tls, interp, menuPtr, (*TThreadSpecificData11)(unsafe.Pointer(tsdPtr)).FmenuOptionTable, *(*uintptr)(unsafe.Pointer(objv + 2*8)), (*TTkMenu)(unsafe.Pointer(menuPtr)).Ftkwin) if resultPtr == libc.UintptrFromInt32(0) { goto error } libtcl9_0.XTcl_SetObjResult(tls, interp, resultPtr) case int32(MENU_CLONE): if objc < int32(3) || objc > int32(4) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(2), objv, __ccgo_ts+24514) goto error } if objc == int32(3) { v1 = libc.UintptrFromInt32(0) } else { v1 = *(*uintptr)(unsafe.Pointer(objv + 3*8)) } result = _CloneMenu(tls, menuPtr, *(*uintptr)(unsafe.Pointer(objv + 2*8)), v1) case int32(MENU_CONFIGURE): if objc == int32(2) { resultPtr1 = XTk_GetOptionInfo(tls, interp, menuPtr, (*TThreadSpecificData11)(unsafe.Pointer(tsdPtr)).FmenuOptionTable, libc.UintptrFromInt32(0), (*TTkMenu)(unsafe.Pointer(menuPtr)).Ftkwin) if resultPtr1 == libc.UintptrFromInt32(0) { result = int32(TCL_ERROR) } else { result = TCL_OK libtcl9_0.XTcl_SetObjResult(tls, interp, resultPtr1) } } else { if objc == int32(3) { resultPtr1 = XTk_GetOptionInfo(tls, interp, menuPtr, (*TThreadSpecificData11)(unsafe.Pointer(tsdPtr)).FmenuOptionTable, *(*uintptr)(unsafe.Pointer(objv + 2*8)), (*TTkMenu)(unsafe.Pointer(menuPtr)).Ftkwin) if resultPtr1 == libc.UintptrFromInt32(0) { result = int32(TCL_ERROR) } else { result = TCL_OK libtcl9_0.XTcl_SetObjResult(tls, interp, resultPtr1) } } else { result = _ConfigureMenu(tls, interp, menuPtr, int64(objc-int32(2)), objv+uintptr(2)*8) } } if result != TCL_OK { goto error } case int32(MENU_DELETE): if objc != int32(3) && objc != int32(4) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(2), objv, __ccgo_ts+24537) goto error } /* * If 'first' explicitly refers to past the end of the menu, we don't * do anything. [Bug 220950] */ if libc.BoolInt32(uint32(*(*uint8)(unsafe.Pointer(libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8)), libc.UintptrFromInt32(0)))))-uint32('0') < uint32(10)) != 0 && libtcl9_0.XTcl_GetWideIntFromObj(tls, libc.UintptrFromInt32(0), *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+32) == TCL_OK { *(*TTcl_Size)(unsafe.Pointer(bp + 16)) = *(*TTcl_WideInt)(unsafe.Pointer(bp + 32)) if *(*TTcl_Size)(unsafe.Pointer(bp + 16)) >= (*TTkMenu)(unsafe.Pointer(menuPtr)).FnumEntries { goto done } } else { if _GetMenuIndex(tls, interp, menuPtr, *(*uintptr)(unsafe.Pointer(objv + 2*8)), 0, bp+16) != TCL_OK { goto error } } if objc == int32(3) { *(*TTcl_Size)(unsafe.Pointer(bp + 24)) = *(*TTcl_Size)(unsafe.Pointer(bp + 16)) } else { if _GetMenuIndex(tls, interp, menuPtr, *(*uintptr)(unsafe.Pointer(objv + 3*8)), 0, bp+24) != TCL_OK { goto error } } if (*TTkMenu)(unsafe.Pointer(menuPtr)).Ftearoff != 0 && *(*TTcl_Size)(unsafe.Pointer(bp + 16)) == 0 { /* * Sorry, can't delete the tearoff entry; must reconfigure the * menu. */ *(*TTcl_Size)(unsafe.Pointer(bp + 16)) = int64(1) } if *(*TTcl_Size)(unsafe.Pointer(bp + 16)) < 0 || *(*TTcl_Size)(unsafe.Pointer(bp + 24)) < *(*TTcl_Size)(unsafe.Pointer(bp + 16)) { goto done } _DeleteMenuCloneEntries(tls, menuPtr, int32(*(*TTcl_Size)(unsafe.Pointer(bp + 16))), int32(*(*TTcl_Size)(unsafe.Pointer(bp + 24)))) case int32(MENU_ENTRYCGET): if objc != int32(4) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(2), objv, __ccgo_ts+23749) goto error } if _GetMenuIndex(tls, interp, menuPtr, *(*uintptr)(unsafe.Pointer(objv + 2*8)), 0, bp+40) != TCL_OK { goto error } if *(*TTcl_Size)(unsafe.Pointer(bp + 40)) < 0 { goto done } mePtr = *(*uintptr)(unsafe.Pointer((*TTkMenu)(unsafe.Pointer(menuPtr)).Fentries + uintptr(*(*TTcl_Size)(unsafe.Pointer(bp + 40)))*8)) libtcl9_0.XTcl_Preserve(tls, mePtr) resultPtr2 = XTk_GetOptionValue(tls, interp, mePtr, (*TTkMenuEntry)(unsafe.Pointer(mePtr)).FoptionTable, *(*uintptr)(unsafe.Pointer(objv + 3*8)), (*TTkMenu)(unsafe.Pointer(menuPtr)).Ftkwin) libtcl9_0.XTcl_Release(tls, mePtr) if resultPtr2 == libc.UintptrFromInt32(0) { goto error } libtcl9_0.XTcl_SetObjResult(tls, interp, resultPtr2) case int32(MENU_ENTRYCONFIGURE): if objc < int32(3) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(2), objv, __ccgo_ts+23811) goto error } if _GetMenuIndex(tls, interp, menuPtr, *(*uintptr)(unsafe.Pointer(objv + 2*8)), 0, bp+48) != TCL_OK { goto error } if *(*TTcl_Size)(unsafe.Pointer(bp + 48)) < 0 { goto done } mePtr = *(*uintptr)(unsafe.Pointer((*TTkMenu)(unsafe.Pointer(menuPtr)).Fentries + uintptr(*(*TTcl_Size)(unsafe.Pointer(bp + 48)))*8)) libtcl9_0.XTcl_Preserve(tls, mePtr) if objc == int32(3) { resultPtr3 = XTk_GetOptionInfo(tls, interp, mePtr, (*TTkMenuEntry)(unsafe.Pointer(mePtr)).FoptionTable, libc.UintptrFromInt32(0), (*TTkMenu)(unsafe.Pointer(menuPtr)).Ftkwin) if resultPtr3 == libc.UintptrFromInt32(0) { result = int32(TCL_ERROR) } else { result = TCL_OK libtcl9_0.XTcl_SetObjResult(tls, interp, resultPtr3) } } else { if objc == int32(4) { resultPtr3 = XTk_GetOptionInfo(tls, interp, mePtr, (*TTkMenuEntry)(unsafe.Pointer(mePtr)).FoptionTable, *(*uintptr)(unsafe.Pointer(objv + 3*8)), (*TTkMenu)(unsafe.Pointer(menuPtr)).Ftkwin) if resultPtr3 == libc.UintptrFromInt32(0) { result = int32(TCL_ERROR) } else { result = TCL_OK libtcl9_0.XTcl_SetObjResult(tls, interp, resultPtr3) } } else { result = _ConfigureMenuCloneEntries(tls, menuPtr, int32(*(*TTcl_Size)(unsafe.Pointer(bp + 48))), int64(objc-int32(3)), objv+uintptr(3)*8) } } libtcl9_0.XTcl_Release(tls, mePtr) case int32(MENU_ID): if objc != int32(3) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(2), objv, __ccgo_ts+22152) goto error } if _GetMenuIndex(tls, interp, menuPtr, *(*uintptr)(unsafe.Pointer(objv + 2*8)), 0, bp+56) != TCL_OK { goto error } if *(*TTcl_Size)(unsafe.Pointer(bp + 56)) < 0 { goto done } entryPtr = (*TTkMenuEntry)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer((*TTkMenu)(unsafe.Pointer(menuPtr)).Fentries + uintptr(*(*TTcl_Size)(unsafe.Pointer(bp + 56)))*8)))).FentryPtr if entryPtr != 0 { if (*TTcl_HashTable)(unsafe.Pointer(menuPtr+344)).FkeyType == int32(TCL_ONE_WORD_KEYS) || (*TTcl_HashTable)(unsafe.Pointer(menuPtr+344)).FkeyType == -int32(1) { v2 = *(*uintptr)(unsafe.Pointer(entryPtr + 32)) } else { v2 = entryPtr + 32 } idStr = v2 libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewStringObj(tls, idStr, int64(-libc.Int32FromInt32(1)))) } case int32(MENU_INDEX): if objc != int32(3) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(2), objv, __ccgo_ts+22267) goto error } if _GetMenuIndex(tls, interp, menuPtr, *(*uintptr)(unsafe.Pointer(objv + 2*8)), 0, bp+64) != TCL_OK { goto error } if *(*TTcl_Size)(unsafe.Pointer(bp + 64)) < 0 { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewObj(tls)) } else { if *(*TTcl_Size)(unsafe.Pointer(bp + 64)) == int64(-libc.Int32FromInt32(1)) { v3 = libtcl9_0.XTcl_NewObj(tls) } else { v3 = libtcl9_0.XTcl_NewWideIntObj(tls, *(*TTcl_Size)(unsafe.Pointer(bp + 64))) } libtcl9_0.XTcl_SetObjResult(tls, interp, v3) } case int32(MENU_INSERT): if objc < int32(4) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(2), objv, __ccgo_ts+24550) goto error } if _MenuAddOrInsert(tls, interp, menuPtr, *(*uintptr)(unsafe.Pointer(objv + 2*8)), int64(objc-int32(3)), objv+uintptr(3)*8) != TCL_OK { goto error } case int32(MENU_INVOKE): if objc != int32(3) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(2), objv, __ccgo_ts+22152) goto error } if _GetMenuIndex(tls, interp, menuPtr, *(*uintptr)(unsafe.Pointer(objv + 2*8)), 0, bp+72) != TCL_OK { goto error } if *(*TTcl_Size)(unsafe.Pointer(bp + 72)) < 0 { goto done } result = XTkInvokeMenu(tls, interp, menuPtr, *(*TTcl_Size)(unsafe.Pointer(bp + 72))) case int32(MENU_POST): *(*TTcl_Size)(unsafe.Pointer(bp + 88)) = int64(-libc.Int32FromInt32(1)) if objc != int32(4) && objc != int32(5) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(2), objv, __ccgo_ts+24581) goto error } if libtcl9_0.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+80) != TCL_OK || libtcl9_0.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 3*8)), bp+84) != TCL_OK { goto error } if objc == int32(5) { if _GetMenuIndex(tls, interp, menuPtr, *(*uintptr)(unsafe.Pointer(objv + 4*8)), 0, bp+88) != TCL_OK { goto error } } /* * Tearoff menus are the same as ordinary menus on the Mac and are * posted differently on Windows than non-tearoffs. TkpPostMenu * does not actually map the menu's window on those platforms, and * popup menus have to be handled specially. Also, menubar menus are * not intended to be posted (bug 1567681, 2160206). */ if (*TTkMenu)(unsafe.Pointer(menuPtr)).FmenuType == MENUBAR { libtcl9_0.XTcl_AppendResult(tls, interp, libc.VaList(bp+120, __ccgo_ts+24593, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) } else { if (*TTkMenu)(unsafe.Pointer(menuPtr)).FmenuType != int32(TEAROFF_MENU) { result = XTkpPostMenu(tls, interp, menuPtr, *(*int32)(unsafe.Pointer(bp + 80)), *(*int32)(unsafe.Pointer(bp + 84)), *(*TTcl_Size)(unsafe.Pointer(bp + 88))) } else { result = XTkpPostTearoffMenu(tls, interp, menuPtr, *(*int32)(unsafe.Pointer(bp + 80)), *(*int32)(unsafe.Pointer(bp + 84)), *(*TTcl_Size)(unsafe.Pointer(bp + 88))) } } case int32(MENU_POSTCASCADE): if objc != int32(3) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(2), objv, __ccgo_ts+22152) goto error } if _GetMenuIndex(tls, interp, menuPtr, *(*uintptr)(unsafe.Pointer(objv + 2*8)), 0, bp+96) != TCL_OK { goto error } if *(*TTcl_Size)(unsafe.Pointer(bp + 96)) < 0 || (*TTkMenuEntry)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer((*TTkMenu)(unsafe.Pointer(menuPtr)).Fentries + uintptr(*(*TTcl_Size)(unsafe.Pointer(bp + 96)))*8)))).Ftype1 != CASCADE_ENTRY { result = XTkPostSubmenu(tls, interp, menuPtr, libc.UintptrFromInt32(0)) } else { result = XTkPostSubmenu(tls, interp, menuPtr, *(*uintptr)(unsafe.Pointer((*TTkMenu)(unsafe.Pointer(menuPtr)).Fentries + uintptr(*(*TTcl_Size)(unsafe.Pointer(bp + 96)))*8))) } case int32(MENU_TYPE): if objc != int32(3) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(2), objv, __ccgo_ts+22152) goto error } if _GetMenuIndex(tls, interp, menuPtr, *(*uintptr)(unsafe.Pointer(objv + 2*8)), 0, bp+104) != TCL_OK { goto error } if *(*TTcl_Size)(unsafe.Pointer(bp + 104)) < 0 { goto done } if (*TTkMenuEntry)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer((*TTkMenu)(unsafe.Pointer(menuPtr)).Fentries + uintptr(*(*TTcl_Size)(unsafe.Pointer(bp + 104)))*8)))).Ftype1 == int32(TEAROFF_ENTRY) { typeStr = __ccgo_ts + 24206 } else { typeStr = _menuEntryTypeStrings[(*TTkMenuEntry)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer((*TTkMenu)(unsafe.Pointer(menuPtr)).Fentries + uintptr(*(*TTcl_Size)(unsafe.Pointer(bp + 104)))*8)))).Ftype1] } libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewStringObj(tls, typeStr, int64(-libc.Int32FromInt32(1)))) case int32(MENU_UNPOST): if objc != int32(2) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(2), objv, libc.UintptrFromInt32(0)) goto error } XTk_UnmapWindow(tls, (*TTkMenu)(unsafe.Pointer(menuPtr)).Ftkwin) result = XTkPostSubmenu(tls, interp, menuPtr, libc.UintptrFromInt32(0)) case int32(MENU_XPOSITION): if objc != int32(3) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(2), objv, __ccgo_ts+22152) goto error } result = _MenuDoXPosition(tls, interp, menuPtr, *(*uintptr)(unsafe.Pointer(objv + 2*8))) case int32(MENU_YPOSITION): if objc != int32(3) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(2), objv, __ccgo_ts+22152) goto error } result = _MenuDoYPosition(tls, interp, menuPtr, *(*uintptr)(unsafe.Pointer(objv + 2*8))) break } goto done done: ; libtcl9_0.XTcl_Release(tls, menuPtr) return result goto error error: ; libtcl9_0.XTcl_Release(tls, menuPtr) return int32(TCL_ERROR) } /* *---------------------------------------------------------------------- * * TkInvokeMenu -- * * Given a menu and an index, takes the appropriate action for the entry * associated with that index. * * Results: * Standard Tcl result. * * Side effects: * Commands may get excecuted; variables may get set; sub-menus may get * posted, the passed menu may be destroyed. * *---------------------------------------------------------------------- */ func XTkInvokeMenu(tls *libc.TLS, interp uintptr, menuPtr uintptr, index TTcl_Size) (r int32) { bp := tls.Alloc(224) defer tls.Free(224) /* The zero based index of the item we are * invoking. */ var _objPtr, _objPtr1, _objPtr2, _objPtr3, commandPtr, mePtr, namePtr, valuePtr, valuePtr1, v2, v4, v6, v8 uintptr var result int32 var v1, v3, v5, v7 TTcl_Size var _ /* ds at bp+0 */ TTcl_DString _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = _objPtr, _objPtr1, _objPtr2, _objPtr3, commandPtr, mePtr, namePtr, result, valuePtr, valuePtr1, v1, v2, v3, v4, v5, v6, v7, v8 result = TCL_OK commandPtr = libc.UintptrFromInt32(0) namePtr = libc.UintptrFromInt32(0) if index < 0 { goto done } mePtr = *(*uintptr)(unsafe.Pointer((*TTkMenu)(unsafe.Pointer(menuPtr)).Fentries + uintptr(index)*8)) if (*TTkMenuEntry)(unsafe.Pointer(mePtr)).Fstate == int32(ENTRY_DISABLED) { goto done } if (*TTkMenuEntry)(unsafe.Pointer(mePtr)).FcommandPtr != libc.UintptrFromInt32(0) { commandPtr = (*TTkMenuEntry)(unsafe.Pointer(mePtr)).FcommandPtr (*TTcl_Obj)(unsafe.Pointer(commandPtr)).FrefCount++ } if (*TTkMenuEntry)(unsafe.Pointer(mePtr)).Ftype1 == int32(CHECK_BUTTON_ENTRY) || (*TTkMenuEntry)(unsafe.Pointer(mePtr)).Ftype1 == int32(RADIO_BUTTON_ENTRY) { if (*TTkMenuEntry)(unsafe.Pointer(mePtr)).FnamePtr != libc.UintptrFromInt32(0) { namePtr = (*TTkMenuEntry)(unsafe.Pointer(mePtr)).FnamePtr (*TTcl_Obj)(unsafe.Pointer(namePtr)).FrefCount++ } } if (*TTkMenuEntry)(unsafe.Pointer(mePtr)).Ftype1 == int32(TEAROFF_ENTRY) { libtcl9_0.XTcl_DStringInit(tls, bp) libtcl9_0.XTcl_DStringAppend(tls, bp, __ccgo_ts+24625, int64(-libc.Int32FromInt32(1))) libtcl9_0.XTcl_DStringAppend(tls, bp, (*TTk_FakeWin)(unsafe.Pointer((*TTkMenu)(unsafe.Pointer(menuPtr)).Ftkwin)).FpathName, int64(-libc.Int32FromInt32(1))) result = libtcl9_0.XTcl_EvalEx(tls, interp, (*TTcl_DString)(unsafe.Pointer(bp)).Fstring1, int64(-libc.Int32FromInt32(1)), int32(TCL_EVAL_GLOBAL)) libtcl9_0.XTcl_DStringFree(tls, bp) } else { if (*TTkMenuEntry)(unsafe.Pointer(mePtr)).Ftype1 == int32(CHECK_BUTTON_ENTRY) && namePtr != libc.UintptrFromInt32(0) { if (*TTkMenuEntry)(unsafe.Pointer(mePtr)).FentryFlags&int32(ENTRY_SELECTED) != 0 { valuePtr = (*TTkMenuEntry)(unsafe.Pointer(mePtr)).FoffValuePtr } else { valuePtr = (*TTkMenuEntry)(unsafe.Pointer(mePtr)).FonValuePtr } if valuePtr == libc.UintptrFromInt32(0) { valuePtr = libtcl9_0.XTcl_NewObj(tls) } (*TTcl_Obj)(unsafe.Pointer(valuePtr)).FrefCount++ if libtcl9_0.XTcl_ObjSetVar2(tls, interp, namePtr, libc.UintptrFromInt32(0), valuePtr, libc.Int32FromInt32(TCL_GLOBAL_ONLY)|libc.Int32FromInt32(TCL_LEAVE_ERR_MSG)) == libc.UintptrFromInt32(0) { result = int32(TCL_ERROR) } _objPtr = valuePtr v2 = _objPtr v1 = *(*TTcl_Size)(unsafe.Pointer(v2)) *(*TTcl_Size)(unsafe.Pointer(v2))-- if v1 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr) } } else { if (*TTkMenuEntry)(unsafe.Pointer(mePtr)).Ftype1 == int32(RADIO_BUTTON_ENTRY) && namePtr != libc.UintptrFromInt32(0) { valuePtr1 = (*TTkMenuEntry)(unsafe.Pointer(mePtr)).FonValuePtr if valuePtr1 == libc.UintptrFromInt32(0) { valuePtr1 = libtcl9_0.XTcl_NewObj(tls) } (*TTcl_Obj)(unsafe.Pointer(valuePtr1)).FrefCount++ if libtcl9_0.XTcl_ObjSetVar2(tls, interp, namePtr, libc.UintptrFromInt32(0), valuePtr1, libc.Int32FromInt32(TCL_GLOBAL_ONLY)|libc.Int32FromInt32(TCL_LEAVE_ERR_MSG)) == libc.UintptrFromInt32(0) { result = int32(TCL_ERROR) } _objPtr1 = valuePtr1 v4 = _objPtr1 v3 = *(*TTcl_Size)(unsafe.Pointer(v4)) *(*TTcl_Size)(unsafe.Pointer(v4))-- if v3 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr1) } } } } /* * We check numEntries in addition to whether the menu entry has a command * because that goes to zero if the menu gets deleted (e.g., during * command evaluation). */ if (*TTkMenu)(unsafe.Pointer(menuPtr)).FnumEntries != 0 && result == TCL_OK && commandPtr != libc.UintptrFromInt32(0) { result = libtcl9_0.XTcl_EvalObjEx(tls, interp, commandPtr, int32(TCL_EVAL_GLOBAL)) } if commandPtr != libc.UintptrFromInt32(0) { _objPtr2 = commandPtr v6 = _objPtr2 v5 = *(*TTcl_Size)(unsafe.Pointer(v6)) *(*TTcl_Size)(unsafe.Pointer(v6))-- if v5 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr2) } } if namePtr != libc.UintptrFromInt32(0) { _objPtr3 = namePtr v8 = _objPtr3 v7 = *(*TTcl_Size)(unsafe.Pointer(v8)) *(*TTcl_Size)(unsafe.Pointer(v8))-- if v7 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr3) } } goto done done: ; return result return r } /* *---------------------------------------------------------------------- * * DestroyMenuInstance -- * * This function is invoked by TkDestroyMenu to clean up the internal * structure of a menu at a safe time (when no-one is using it anymore). * Only takes care of one instance of the menu. * * Results: * None. * * Side effects: * Everything associated with the menu is freed up. * *---------------------------------------------------------------------- */ func _DestroyMenuInstance(tls *libc.TLS, menuPtr uintptr) { bp := tls.Alloc(16) defer tls.Free(16) /* Info about menu widget. */ var _objPtr, _objPtr1, cascadePtr, menuInstancePtr, menuNamePtr, nextCascadePtr, parentMainEntryPtr, parentMainMenuPtr, tsdPtr, v3, v5 uintptr var i, v8 int32 var tkwin TTk_Window var v2, v4 TTcl_Size var _ /* newObjv at bp+0 */ [2]uintptr _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = _objPtr, _objPtr1, cascadePtr, i, menuInstancePtr, menuNamePtr, nextCascadePtr, parentMainEntryPtr, parentMainMenuPtr, tkwin, tsdPtr, v2, v3, v4, v5, v8 tsdPtr = libtcl9_0.XTcl_GetThreadData(tls, uintptr(unsafe.Pointer(&_dataKey11)), int64(64)) /* * If the menu has any cascade menu entries pointing to it, the cascade * entries need to be told that the menu is going away. We need to clear * the menu ptr field in the menu reference at this point in the code so * that everything else can forget about this menu properly. We also need * to reset -menu field of all entries that are not main menus back to * this entry name if this is a main menu pointed to by another main * menu. If there is a clone menu that points to this menu, then this menu * is itself a clone, so when this menu goes away, the -menu field of the * pointing entry must be set back to this menu's main menu name so that * later if another menu is created the cascade hierarchy can be * maintained. */ XTkpDestroyMenu(tls, menuPtr) if (*TTkMenu)(unsafe.Pointer(menuPtr)).FmenuRefPtr == libc.UintptrFromInt32(0) { return } cascadePtr = (*TTkMenuReferences1)(unsafe.Pointer((*TTkMenu)(unsafe.Pointer(menuPtr)).FmenuRefPtr)).FparentEntryPtr (*TTkMenuReferences1)(unsafe.Pointer((*TTkMenu)(unsafe.Pointer(menuPtr)).FmenuRefPtr)).FmenuPtr = libc.UintptrFromInt32(0) if XTkFreeMenuReferences(tls, (*TTkMenu)(unsafe.Pointer(menuPtr)).FmenuRefPtr) != 0 { (*TTkMenu)(unsafe.Pointer(menuPtr)).FmenuRefPtr = libc.UintptrFromInt32(0) } for { if !(cascadePtr != libc.UintptrFromInt32(0)) { break } nextCascadePtr = (*TTkMenuEntry)(unsafe.Pointer(cascadePtr)).FnextCascadePtr if (*TTkMenu)(unsafe.Pointer(menuPtr)).FmainMenuPtr != menuPtr { menuNamePtr = libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+23078, int64(-libc.Int32FromInt32(1))) parentMainMenuPtr = (*TTkMenu1)(unsafe.Pointer((*TTkMenuEntry)(unsafe.Pointer(cascadePtr)).FmenuPtr)).FmainMenuPtr parentMainEntryPtr = *(*uintptr)(unsafe.Pointer((*TTkMenu)(unsafe.Pointer(parentMainMenuPtr)).Fentries + uintptr((*TTkMenuEntry)(unsafe.Pointer(cascadePtr)).Findex)*8)) (*(*[2]uintptr)(unsafe.Pointer(bp)))[0] = menuNamePtr (*(*[2]uintptr)(unsafe.Pointer(bp)))[int32(1)] = (*TTkMenuEntry)(unsafe.Pointer(parentMainEntryPtr)).FnamePtr /* * It is possible that the menu info is out of sync, and these * things point to NULL, so verify existence [Bug: 3402] */ if (*(*[2]uintptr)(unsafe.Pointer(bp)))[0] != 0 && (*(*[2]uintptr)(unsafe.Pointer(bp)))[int32(1)] != 0 { (*TTcl_Obj)(unsafe.Pointer((*(*[2]uintptr)(unsafe.Pointer(bp)))[0])).FrefCount++ (*TTcl_Obj)(unsafe.Pointer((*(*[2]uintptr)(unsafe.Pointer(bp)))[int32(1)])).FrefCount++ _ConfigureMenuEntry(tls, cascadePtr, int64(2), bp) _objPtr = (*(*[2]uintptr)(unsafe.Pointer(bp)))[0] v3 = _objPtr v2 = *(*TTcl_Size)(unsafe.Pointer(v3)) *(*TTcl_Size)(unsafe.Pointer(v3))-- if v2 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr) } _objPtr1 = (*(*[2]uintptr)(unsafe.Pointer(bp)))[int32(1)] v5 = _objPtr1 v4 = *(*TTcl_Size)(unsafe.Pointer(v5)) *(*TTcl_Size)(unsafe.Pointer(v5))-- if v4 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr1) } } } else { _ConfigureMenuEntry(tls, cascadePtr, 0, libc.UintptrFromInt32(0)) } goto _1 _1: ; cascadePtr = nextCascadePtr } if (*TTkMenu)(unsafe.Pointer(menuPtr)).FmainMenuPtr != menuPtr { menuInstancePtr = (*TTkMenu)(unsafe.Pointer(menuPtr)).FmainMenuPtr for { if !(menuInstancePtr != libc.UintptrFromInt32(0)) { break } if (*TTkMenu)(unsafe.Pointer(menuInstancePtr)).FnextInstancePtr == menuPtr { (*TTkMenu)(unsafe.Pointer(menuInstancePtr)).FnextInstancePtr = (*TTkMenu1)(unsafe.Pointer((*TTkMenu)(unsafe.Pointer(menuInstancePtr)).FnextInstancePtr)).FnextInstancePtr break } goto _6 _6: ; menuInstancePtr = (*TTkMenu)(unsafe.Pointer(menuInstancePtr)).FnextInstancePtr } } else { if (*TTkMenu)(unsafe.Pointer(menuPtr)).FnextInstancePtr != libc.UintptrFromInt32(0) { libtcl9_0.XTcl_Panic(tls, __ccgo_ts+24642, 0) } } /* * Free up all the stuff that requires special handling, then let * Tk_FreeConfigOptions handle all the standard option-related stuff. */ i = int32((*TTkMenu)(unsafe.Pointer(menuPtr)).FnumEntries) for { i-- v8 = i if !(v8 >= 0) { break } /* * Clean up the hash entry for the menu item ID. * This cannot be postponed until the entry is eventually freed, * because the hash table may already have been deleted by then. */ if (*TTkMenuEntry)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer((*TTkMenu)(unsafe.Pointer(menuPtr)).Fentries + uintptr(i)*8)))).FentryPtr != 0 { libtcl9_0.XTcl_DeleteHashEntry(tls, (*TTkMenuEntry)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer((*TTkMenu)(unsafe.Pointer(menuPtr)).Fentries + uintptr(i)*8)))).FentryPtr) (*TTkMenuEntry)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer((*TTkMenu)(unsafe.Pointer(menuPtr)).Fentries + uintptr(i)*8)))).FentryPtr = libc.UintptrFromInt32(0) } /* * As each menu entry is deleted from the end of the array of entries, * decrement menuPtr->numEntries. Otherwise, the act of deleting menu * entry i will dereference freed memory attempting to queue a redraw * for menu entries (i+1)...numEntries. */ libtcl9_0.XTcl_EventuallyFree(tls, *(*uintptr)(unsafe.Pointer((*TTkMenu)(unsafe.Pointer(menuPtr)).Fentries + uintptr(i)*8)), __ccgo_fp(_DestroyMenuEntry)) (*TTkMenu)(unsafe.Pointer(menuPtr)).FnumEntries = int64(i) goto _7 _7: } (*TTkMenu)(unsafe.Pointer(menuPtr)).Factive = int64(-int32(1)) if (*TTkMenu)(unsafe.Pointer(menuPtr)).Fentries != libc.UintptrFromInt32(0) { libtcl9_0.XTcl_Free(tls, (*TTkMenu)(unsafe.Pointer(menuPtr)).Fentries) (*TTkMenu)(unsafe.Pointer(menuPtr)).Fentries = libc.UintptrFromInt32(0) } libtcl9_0.XTcl_DeleteHashTable(tls, menuPtr+344) XTkMenuFreeDrawOptions(tls, menuPtr) XTk_FreeConfigOptions(tls, menuPtr, (*TThreadSpecificData11)(unsafe.Pointer(tsdPtr)).FmenuOptionTable, (*TTkMenu)(unsafe.Pointer(menuPtr)).Ftkwin) if (*TTkMenu)(unsafe.Pointer(menuPtr)).Ftkwin != libc.UintptrFromInt32(0) { tkwin = (*TTkMenu)(unsafe.Pointer(menuPtr)).Ftkwin (*TTkMenu)(unsafe.Pointer(menuPtr)).Ftkwin = libc.UintptrFromInt32(0) XTk_DestroyWindow(tls, tkwin) } } /* *---------------------------------------------------------------------- * * TkDestroyMenu -- * * This function is invoked to clean up the internal structure of a menu * at a safe time (when no-one is using it anymore). If called on a main * instance, destroys all of the instances. If called on a non-main * instance, just destroys that instance. * * Results: * None. * * Side effects: * Everything associated with the menu is freed up. * *---------------------------------------------------------------------- */ func XTkDestroyMenu(tls *libc.TLS, menuPtr uintptr) { /* Info about menu widget. */ var menuInstancePtr, nextTopLevelPtr, topLevelListPtr uintptr var tkwin TTk_Window _, _, _, _ = menuInstancePtr, nextTopLevelPtr, tkwin, topLevelListPtr if (*TTkMenu)(unsafe.Pointer(menuPtr)).FmenuFlags&int32(MENU_DELETION_PENDING) != 0 { return } libtcl9_0.XTcl_Preserve(tls, menuPtr) /* * Now destroy all non-tearoff instances of this menu if this is a parent * menu. Is this loop safe enough? Are there going to be destroy bindings * on child menus which kill the parent? If not, we have to do a slightly * more complex scheme. */ *(*int32)(unsafe.Pointer(menuPtr + 260)) |= int32(MENU_DELETION_PENDING) if (*TTkMenu)(unsafe.Pointer(menuPtr)).FmenuRefPtr != libc.UintptrFromInt32(0) { /* * If any toplevel widgets have this menu as their menubar, the * geometry of the window may have to be recalculated. */ topLevelListPtr = (*TTkMenuReferences1)(unsafe.Pointer((*TTkMenu)(unsafe.Pointer(menuPtr)).FmenuRefPtr)).FtopLevelListPtr for topLevelListPtr != libc.UintptrFromInt32(0) { nextTopLevelPtr = (*TTkMenuTopLevelList)(unsafe.Pointer(topLevelListPtr)).FnextPtr XTkpSetWindowMenuBar(tls, (*TTkMenuTopLevelList)(unsafe.Pointer(topLevelListPtr)).Ftkwin, libc.UintptrFromInt32(0)) topLevelListPtr = nextTopLevelPtr } } if (*TTkMenu)(unsafe.Pointer(menuPtr)).FmainMenuPtr == menuPtr { for (*TTkMenu)(unsafe.Pointer(menuPtr)).FnextInstancePtr != libc.UintptrFromInt32(0) { menuInstancePtr = (*TTkMenu)(unsafe.Pointer(menuPtr)).FnextInstancePtr (*TTkMenu)(unsafe.Pointer(menuPtr)).FnextInstancePtr = (*TTkMenu)(unsafe.Pointer(menuInstancePtr)).FnextInstancePtr if (*TTkMenu)(unsafe.Pointer(menuInstancePtr)).Ftkwin != libc.UintptrFromInt32(0) { tkwin = (*TTkMenu)(unsafe.Pointer(menuInstancePtr)).Ftkwin /* * Note: it may be desirable to NULL out the tkwin field of * menuInstancePtr here: * menuInstancePtr->tkwin = NULL; */ XTk_DestroyWindow(tls, tkwin) } } } _DestroyMenuInstance(tls, menuPtr) libtcl9_0.XTcl_Release(tls, menuPtr) } /* *---------------------------------------------------------------------- * * UnhookCascadeEntry -- * * This entry is removed from the list of entries that point to the * cascade menu. This is done in preparation for changing the menu that * this entry points to. * * At the end of this function, the menu entry no longer contains a * reference to a 'TkMenuReferences' structure, and therefore no such * structure contains a reference to this menu entry either. * * Results: * None * * Side effects: * The appropriate lists are modified. * *---------------------------------------------------------------------- */ func _UnhookCascadeEntry(tls *libc.TLS, mePtr uintptr) { /* The cascade entry we are removing from the * cascade list. */ var cascadeEntryPtr, menuRefPtr, prevCascadePtr uintptr _, _, _ = cascadeEntryPtr, menuRefPtr, prevCascadePtr menuRefPtr = (*TTkMenuEntry)(unsafe.Pointer(mePtr)).FchildMenuRefPtr if menuRefPtr == libc.UintptrFromInt32(0) { return } cascadeEntryPtr = (*TTkMenuReferences)(unsafe.Pointer(menuRefPtr)).FparentEntryPtr if cascadeEntryPtr == libc.UintptrFromInt32(0) { XTkFreeMenuReferences(tls, menuRefPtr) (*TTkMenuEntry)(unsafe.Pointer(mePtr)).FchildMenuRefPtr = libc.UintptrFromInt32(0) return } /* * Singularly linked list deletion. The two special cases are 1. one * element; 2. The first element is the one we want. */ if cascadeEntryPtr == mePtr { if (*TTkMenuEntry)(unsafe.Pointer(cascadeEntryPtr)).FnextCascadePtr == libc.UintptrFromInt32(0) { /* * This is the last menu entry which points to this menu, so we * need to clear out the list pointer in the cascade itself. */ (*TTkMenuReferences)(unsafe.Pointer(menuRefPtr)).FparentEntryPtr = libc.UintptrFromInt32(0) /* * The original field is set to zero below, after it is freed. */ XTkFreeMenuReferences(tls, menuRefPtr) } else { (*TTkMenuReferences)(unsafe.Pointer(menuRefPtr)).FparentEntryPtr = (*TTkMenuEntry)(unsafe.Pointer(cascadeEntryPtr)).FnextCascadePtr } (*TTkMenuEntry)(unsafe.Pointer(mePtr)).FnextCascadePtr = libc.UintptrFromInt32(0) } else { prevCascadePtr = cascadeEntryPtr cascadeEntryPtr = (*TTkMenuEntry)(unsafe.Pointer(cascadeEntryPtr)).FnextCascadePtr for { if !(cascadeEntryPtr != libc.UintptrFromInt32(0)) { break } if cascadeEntryPtr == mePtr { (*TTkMenuEntry)(unsafe.Pointer(prevCascadePtr)).FnextCascadePtr = (*TTkMenuEntry)(unsafe.Pointer(cascadeEntryPtr)).FnextCascadePtr (*TTkMenuEntry)(unsafe.Pointer(cascadeEntryPtr)).FnextCascadePtr = libc.UintptrFromInt32(0) break } goto _1 _1: ; prevCascadePtr = cascadeEntryPtr cascadeEntryPtr = (*TTkMenuEntry)(unsafe.Pointer(cascadeEntryPtr)).FnextCascadePtr } (*TTkMenuEntry)(unsafe.Pointer(mePtr)).FnextCascadePtr = libc.UintptrFromInt32(0) } (*TTkMenuEntry)(unsafe.Pointer(mePtr)).FchildMenuRefPtr = libc.UintptrFromInt32(0) } /* *---------------------------------------------------------------------- * * DestroyMenuEntry -- * * This function is invoked by Tcl_EventuallyFree or Tcl_Release to clean * up the internal structure of a menu entry at a safe time (when no-one * is using it anymore). * * Results: * None. * * Side effects: * Everything associated with the menu entry is freed. * *---------------------------------------------------------------------- */ func _DestroyMenuEntry(tls *libc.TLS, memPtr uintptr) { /* Pointer to entry to be freed. */ var destroyThis, mePtr, menuPtr, menuRefPtr, varName uintptr _, _, _, _, _ = destroyThis, mePtr, menuPtr, menuRefPtr, varName mePtr = memPtr menuPtr = (*TTkMenuEntry)(unsafe.Pointer(mePtr)).FmenuPtr if (*TTkMenu)(unsafe.Pointer(menuPtr)).FpostedCascade == mePtr { /* * Ignore errors while unposting the menu, since it's possible that * the menu has already been deleted and the unpost will generate an * error. */ XTkPostSubmenu(tls, (*TTkMenu)(unsafe.Pointer(menuPtr)).Finterp, menuPtr, libc.UintptrFromInt32(0)) } /* * Free up all the stuff that requires special handling, then let * Tk_FreeConfigOptions handle all the standard option-related stuff. */ if (*TTkMenuEntry)(unsafe.Pointer(mePtr)).Ftype1 == CASCADE_ENTRY { if (*TTkMenu)(unsafe.Pointer(menuPtr)).FmainMenuPtr != menuPtr { destroyThis = libc.UintptrFromInt32(0) menuRefPtr = (*TTkMenuEntry)(unsafe.Pointer(mePtr)).FchildMenuRefPtr /* * The menu as a whole is a clone. We must delete the clone of the * cascaded menu for the particular entry we are destroying. */ if menuRefPtr != libc.UintptrFromInt32(0) { destroyThis = (*TTkMenuReferences)(unsafe.Pointer(menuRefPtr)).FmenuPtr /* * But only if it is a clone. What can happen is that we are * in the middle of deleting a menu and this menu pointer has * already been reset to point to the original menu. In that * case we have nothing special to do. */ if destroyThis != libc.UintptrFromInt32(0) && (*TTkMenu)(unsafe.Pointer(destroyThis)).FmainMenuPtr == destroyThis { destroyThis = libc.UintptrFromInt32(0) } } _UnhookCascadeEntry(tls, mePtr) menuRefPtr = (*TTkMenuEntry)(unsafe.Pointer(mePtr)).FchildMenuRefPtr if menuRefPtr != libc.UintptrFromInt32(0) { if (*TTkMenuReferences)(unsafe.Pointer(menuRefPtr)).FmenuPtr == destroyThis { (*TTkMenuReferences)(unsafe.Pointer(menuRefPtr)).FmenuPtr = libc.UintptrFromInt32(0) } } if destroyThis != libc.UintptrFromInt32(0) { XTkDestroyMenu(tls, destroyThis) } } else { _UnhookCascadeEntry(tls, mePtr) } } if (*TTkMenuEntry)(unsafe.Pointer(mePtr)).Fimage != libc.UintptrFromInt32(0) { XTk_FreeImage(tls, (*TTkMenuEntry)(unsafe.Pointer(mePtr)).Fimage) } if (*TTkMenuEntry)(unsafe.Pointer(mePtr)).FselectImage != libc.UintptrFromInt32(0) { XTk_FreeImage(tls, (*TTkMenuEntry)(unsafe.Pointer(mePtr)).FselectImage) } if ((*TTkMenuEntry)(unsafe.Pointer(mePtr)).Ftype1 == int32(CHECK_BUTTON_ENTRY) || (*TTkMenuEntry)(unsafe.Pointer(mePtr)).Ftype1 == int32(RADIO_BUTTON_ENTRY)) && (*TTkMenuEntry)(unsafe.Pointer(mePtr)).FnamePtr != libc.UintptrFromInt32(0) { varName = libtcl9_0.XTcl_GetStringFromObj(tls, (*TTkMenuEntry)(unsafe.Pointer(mePtr)).FnamePtr, libc.UintptrFromInt32(0)) libtcl9_0.XTcl_UntraceVar2(tls, (*TTkMenu)(unsafe.Pointer(menuPtr)).Finterp, varName, libc.UintptrFromInt32(0), libc.Int32FromInt32(TCL_GLOBAL_ONLY)|libc.Int32FromInt32(TCL_TRACE_WRITES)|libc.Int32FromInt32(TCL_TRACE_UNSETS), __ccgo_fp(_MenuVarProc), mePtr) } if (*TTkMenuEntry)(unsafe.Pointer(mePtr)).FentryPtr != 0 { libtcl9_0.XTcl_DeleteHashEntry(tls, (*TTkMenuEntry)(unsafe.Pointer(mePtr)).FentryPtr) (*TTkMenuEntry)(unsafe.Pointer(mePtr)).FentryPtr = libc.UintptrFromInt32(0) } XTkpDestroyMenuEntry(tls, mePtr) XTkMenuEntryFreeDrawOptions(tls, mePtr) XTk_FreeConfigOptions(tls, mePtr, (*TTkMenuEntry)(unsafe.Pointer(mePtr)).FoptionTable, (*TTkMenu)(unsafe.Pointer(menuPtr)).Ftkwin) libtcl9_0.XTcl_Free(tls, mePtr) } /* *--------------------------------------------------------------------------- * * MenuWorldChanged -- * * This function is called when the world has changed in some way (such * as the fonts in the system changing) and the widget needs to recompute * all its graphics contexts and determine its new geometry. * * Results: * None. * * Side effects: * Menu will be relayed out and redisplayed. * *--------------------------------------------------------------------------- */ func _MenuWorldChanged(tls *libc.TLS, instanceData uintptr) { /* Information about widget. */ var i TTcl_Size var menuPtr uintptr _, _ = i, menuPtr menuPtr = instanceData XTkMenuConfigureDrawOptions(tls, menuPtr) i = 0 for { if !(i < (*TTkMenu)(unsafe.Pointer(menuPtr)).FnumEntries) { break } XTkMenuConfigureEntryDrawOptions(tls, *(*uintptr)(unsafe.Pointer((*TTkMenu)(unsafe.Pointer(menuPtr)).Fentries + uintptr(i)*8)), int64((*TTkMenuEntry)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer((*TTkMenu)(unsafe.Pointer(menuPtr)).Fentries + uintptr(i)*8)))).Findex)) XTkpConfigureMenuEntry(tls, *(*uintptr)(unsafe.Pointer((*TTkMenu)(unsafe.Pointer(menuPtr)).Fentries + uintptr(i)*8))) goto _1 _1: ; i++ } XTkEventuallyRecomputeMenu(tls, menuPtr) } /* *---------------------------------------------------------------------- * * ConfigureMenu -- * * This function is called to process an argv/argc list, plus the Tk * option database, in order to configure (or reconfigure) a menu widget. * * Results: * The return value is a standard Tcl result. If TCL_ERROR is returned, * then the interp's result contains an error message. * * Side effects: * Configuration information, such as colors, font, etc. get set for * menuPtr; old resources get freed, if there were any. * *---------------------------------------------------------------------- */ func _ConfigureMenu(tls *libc.TLS, interp uintptr, menuPtr uintptr, objc TTcl_Size, objv uintptr) (r int32) { /* Arguments. */ var cleanupPtr, mePtr, menuListPtr, tsdPtr, v6 uintptr var i, result, typeFlag int32 var parent, tkwin TTk_Window var v5 TTcl_Size _, _, _, _, _, _, _, _, _, _, _ = cleanupPtr, i, mePtr, menuListPtr, parent, result, tkwin, tsdPtr, typeFlag, v5, v6 tsdPtr = libtcl9_0.XTcl_GetThreadData(tls, uintptr(unsafe.Pointer(&_dataKey11)), int64(64)) menuListPtr = (*TTkMenu)(unsafe.Pointer(menuPtr)).FmainMenuPtr for { if !(menuListPtr != libc.UintptrFromInt32(0)) { break } (*TTkMenu)(unsafe.Pointer(menuListPtr)).FerrorStructPtr = libtcl9_0.XTcl_Alloc(tls, uint64(512)) result = XTk_SetOptions(tls, interp, menuListPtr, (*TThreadSpecificData11)(unsafe.Pointer(tsdPtr)).FmenuOptionTable, objc, objv, (*TTkMenu)(unsafe.Pointer(menuListPtr)).Ftkwin, (*TTkMenu)(unsafe.Pointer(menuListPtr)).FerrorStructPtr, libc.UintptrFromInt32(0)) if result != TCL_OK { cleanupPtr = (*TTkMenu)(unsafe.Pointer(menuPtr)).FmainMenuPtr for { if !(cleanupPtr != menuListPtr) { break } XTk_RestoreSavedOptions(tls, (*TTkMenu)(unsafe.Pointer(cleanupPtr)).FerrorStructPtr) libtcl9_0.XTcl_Free(tls, (*TTkMenu)(unsafe.Pointer(cleanupPtr)).FerrorStructPtr) (*TTkMenu)(unsafe.Pointer(cleanupPtr)).FerrorStructPtr = libc.UintptrFromInt32(0) goto _2 _2: ; cleanupPtr = (*TTkMenu)(unsafe.Pointer(cleanupPtr)).FnextInstancePtr } if (*TTkMenu)(unsafe.Pointer(menuListPtr)).FerrorStructPtr != libc.UintptrFromInt32(0) { XTk_RestoreSavedOptions(tls, (*TTkMenu)(unsafe.Pointer(menuListPtr)).FerrorStructPtr) libtcl9_0.XTcl_Free(tls, (*TTkMenu)(unsafe.Pointer(menuListPtr)).FerrorStructPtr) (*TTkMenu)(unsafe.Pointer(menuListPtr)).FerrorStructPtr = libc.UintptrFromInt32(0) } return int32(TCL_ERROR) } /* * When a menu is created, the type is in all of the arguments to the * menu command. Let Tk_ConfigureWidget take care of parsing them, and * then set the type after we can look at the type string. Once set, a * menu's type cannot be changed */ if (*TTkMenu)(unsafe.Pointer(menuListPtr)).FmenuType == -int32(1) { libtcl9_0.XTcl_GetIndexFromObjStruct(tls, libc.UintptrFromInt32(0), (*TTkMenu)(unsafe.Pointer(menuListPtr)).FmenuTypePtr, uintptr(unsafe.Pointer(&_menuTypeStrings)), libc.Int64FromUint64(libc.Uint64FromInt64(8)), libc.UintptrFromInt32(0), libc.Int32FromInt32(0)|libc.Int32FromUint64(libc.Uint64FromInt64(4)< 0 && (*TTkMenuEntry)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer((*TTkMenu)(unsafe.Pointer(menuListPtr)).Fentries)))).Ftype1 == int32(TEAROFF_ENTRY) { libtcl9_0.XTcl_EventuallyFree(tls, *(*uintptr)(unsafe.Pointer((*TTkMenu)(unsafe.Pointer(menuListPtr)).Fentries)), __ccgo_fp(_DestroyMenuEntry)) i = 0 for { if !(int64(i) < (*TTkMenu)(unsafe.Pointer(menuListPtr)).FnumEntries-int64(1)) { break } *(*uintptr)(unsafe.Pointer((*TTkMenu)(unsafe.Pointer(menuListPtr)).Fentries + uintptr(i)*8)) = *(*uintptr)(unsafe.Pointer((*TTkMenu)(unsafe.Pointer(menuListPtr)).Fentries + uintptr(i+int32(1))*8)) (*TTkMenuEntry)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer((*TTkMenu)(unsafe.Pointer(menuListPtr)).Fentries + uintptr(i)*8)))).Findex = i goto _4 _4: ; i++ } v6 = menuListPtr + 40 *(*TTcl_Size)(unsafe.Pointer(v6))-- v5 = *(*TTcl_Size)(unsafe.Pointer(v6)) if v5 == 0 { libtcl9_0.XTcl_Free(tls, (*TTkMenu)(unsafe.Pointer(menuListPtr)).Fentries) (*TTkMenu)(unsafe.Pointer(menuListPtr)).Fentries = libc.UintptrFromInt32(0) } } } XTkMenuConfigureDrawOptions(tls, menuListPtr) /* * After reconfiguring a menu, we need to reconfigure all of the * entries in the menu, since some of the things in the children (such * as graphics contexts) may have to change to reflect changes in the * parent. */ i = 0 for { if !(int64(i) < (*TTkMenu)(unsafe.Pointer(menuListPtr)).FnumEntries) { break } mePtr = *(*uintptr)(unsafe.Pointer((*TTkMenu)(unsafe.Pointer(menuListPtr)).Fentries + uintptr(i)*8)) _ConfigureMenuEntry(tls, mePtr, 0, libc.UintptrFromInt32(0)) goto _7 _7: ; i++ } XTkEventuallyRecomputeMenu(tls, menuListPtr) goto _1 _1: ; menuListPtr = (*TTkMenu)(unsafe.Pointer(menuListPtr)).FnextInstancePtr } cleanupPtr = (*TTkMenu)(unsafe.Pointer(menuPtr)).FmainMenuPtr for { if !(cleanupPtr != libc.UintptrFromInt32(0)) { break } XTk_FreeSavedOptions(tls, (*TTkMenu)(unsafe.Pointer(cleanupPtr)).FerrorStructPtr) libtcl9_0.XTcl_Free(tls, (*TTkMenu)(unsafe.Pointer(cleanupPtr)).FerrorStructPtr) (*TTkMenu)(unsafe.Pointer(cleanupPtr)).FerrorStructPtr = libc.UintptrFromInt32(0) goto _8 _8: ; cleanupPtr = (*TTkMenu)(unsafe.Pointer(cleanupPtr)).FnextInstancePtr } return TCL_OK } /* *---------------------------------------------------------------------- * * PostProcessEntry -- * * This is called by ConfigureMenuEntry to do all of the configuration * after Tk_SetOptions is called. This is separate so that error handling * is easier. * * Results: * The return value is a standard Tcl result. If TCL_ERROR is returned, * then the interp's result contains an error message. * * Side effects: * Configuration information such as label and accelerator get set for * mePtr; old resources get freed, if there were any. * *---------------------------------------------------------------------- */ func _PostProcessEntry(tls *libc.TLS, mePtr uintptr) (r int32) { /* The entry we are configuring. */ var alreadyThere, index int32 var cascadeEntryPtr, imageString, menuPtr, menuRefPtr, name, oldHashKey, onValue, selectImageString, value, valuePtr, v1, v3 uintptr var image TTk_Image _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = alreadyThere, cascadeEntryPtr, image, imageString, index, menuPtr, menuRefPtr, name, oldHashKey, onValue, selectImageString, value, valuePtr, v1, v3 menuPtr = (*TTkMenuEntry)(unsafe.Pointer(mePtr)).FmenuPtr index = (*TTkMenuEntry)(unsafe.Pointer(mePtr)).Findex /* * The code below handles special configuration stuff not taken care of by * Tk_ConfigureWidget, such as special processing for defaults, sizing * strings, graphics contexts, etc. */ if (*TTkMenuEntry)(unsafe.Pointer(mePtr)).FlabelPtr == libc.UintptrFromInt32(0) { (*TTkMenuEntry)(unsafe.Pointer(mePtr)).FlabelLength = 0 } else { libtcl9_0.XTcl_GetStringFromObj(tls, (*TTkMenuEntry)(unsafe.Pointer(mePtr)).FlabelPtr, mePtr+32) } if (*TTkMenuEntry)(unsafe.Pointer(mePtr)).FaccelPtr == libc.UintptrFromInt32(0) { (*TTkMenuEntry)(unsafe.Pointer(mePtr)).FaccelLength = 0 } else { libtcl9_0.XTcl_GetStringFromObj(tls, (*TTkMenuEntry)(unsafe.Pointer(mePtr)).FaccelPtr, mePtr+104) } /* * If this is a cascade entry, the platform-specific data of the child * menu has to be updated. Also, the links that point to parents and * cascades have to be updated. */ if (*TTkMenuEntry)(unsafe.Pointer(mePtr)).Ftype1 == CASCADE_ENTRY && (*TTkMenuEntry)(unsafe.Pointer(mePtr)).FnamePtr != libc.UintptrFromInt32(0) { oldHashKey = libc.UintptrFromInt32(0) /* Initialization only needed to * prevent compiler warning. */ /* * This is a cascade entry. If the menu that the cascade entry is * pointing to has changed, we need to remove this entry from the list * of entries pointing to the old menu, and add a cascade reference to * the list of entries pointing to the new menu. * * BUG: We are not recloning for special case #3 yet. */ name = libtcl9_0.XTcl_GetStringFromObj(tls, (*TTkMenuEntry)(unsafe.Pointer(mePtr)).FnamePtr, libc.UintptrFromInt32(0)) if (*TTkMenuEntry)(unsafe.Pointer(mePtr)).FchildMenuRefPtr != libc.UintptrFromInt32(0) { if (*TTcl_HashTable)(unsafe.Pointer(XTkGetMenuHashTable(tls, (*TTkMenu)(unsafe.Pointer(menuPtr)).Finterp))).FkeyType == int32(TCL_ONE_WORD_KEYS) || (*TTcl_HashTable)(unsafe.Pointer(XTkGetMenuHashTable(tls, (*TTkMenu)(unsafe.Pointer(menuPtr)).Finterp))).FkeyType == -int32(1) { v1 = *(*uintptr)(unsafe.Pointer((*TTkMenuReferences1)(unsafe.Pointer((*TTkMenuEntry)(unsafe.Pointer(mePtr)).FchildMenuRefPtr)).FhashEntryPtr + 32)) } else { v1 = (*TTkMenuReferences1)(unsafe.Pointer((*TTkMenuEntry)(unsafe.Pointer(mePtr)).FchildMenuRefPtr)).FhashEntryPtr + 32 } oldHashKey = v1 if libc.Xstrcmp(tls, oldHashKey, name) != 0 { _UnhookCascadeEntry(tls, mePtr) } } if (*TTkMenuEntry)(unsafe.Pointer(mePtr)).FchildMenuRefPtr == libc.UintptrFromInt32(0) || libc.Xstrcmp(tls, oldHashKey, name) != 0 { menuRefPtr = XTkCreateMenuReferences(tls, (*TTkMenu)(unsafe.Pointer(menuPtr)).Finterp, name) (*TTkMenuEntry)(unsafe.Pointer(mePtr)).FchildMenuRefPtr = menuRefPtr if (*TTkMenuReferences)(unsafe.Pointer(menuRefPtr)).FparentEntryPtr == libc.UintptrFromInt32(0) { (*TTkMenuReferences)(unsafe.Pointer(menuRefPtr)).FparentEntryPtr = mePtr } else { alreadyThere = 0 cascadeEntryPtr = (*TTkMenuReferences)(unsafe.Pointer(menuRefPtr)).FparentEntryPtr for { if !(cascadeEntryPtr != libc.UintptrFromInt32(0)) { break } if cascadeEntryPtr == mePtr { alreadyThere = int32(1) break } goto _2 _2: ; cascadeEntryPtr = (*TTkMenuEntry)(unsafe.Pointer(cascadeEntryPtr)).FnextCascadePtr } /* * Put the item at the front of the list. */ if !(alreadyThere != 0) { (*TTkMenuEntry)(unsafe.Pointer(mePtr)).FnextCascadePtr = (*TTkMenuReferences)(unsafe.Pointer(menuRefPtr)).FparentEntryPtr (*TTkMenuReferences)(unsafe.Pointer(menuRefPtr)).FparentEntryPtr = mePtr } } } } if XTkMenuConfigureEntryDrawOptions(tls, mePtr, int64(index)) != TCL_OK { return int32(TCL_ERROR) } /* * Get the images for the entry, if there are any. Allocate the new images * before freeing the old ones, so that the reference counts don't go to * zero and cause image data to be discarded. */ if (*TTkMenuEntry)(unsafe.Pointer(mePtr)).FimagePtr != libc.UintptrFromInt32(0) { imageString = libtcl9_0.XTcl_GetStringFromObj(tls, (*TTkMenuEntry)(unsafe.Pointer(mePtr)).FimagePtr, libc.UintptrFromInt32(0)) image = XTk_GetImage(tls, (*TTkMenu)(unsafe.Pointer(menuPtr)).Finterp, (*TTkMenu)(unsafe.Pointer(menuPtr)).Ftkwin, imageString, __ccgo_fp(XTkMenuImageProc), mePtr) if image == libc.UintptrFromInt32(0) { return int32(TCL_ERROR) } } else { image = libc.UintptrFromInt32(0) } if (*TTkMenuEntry)(unsafe.Pointer(mePtr)).Fimage != libc.UintptrFromInt32(0) { XTk_FreeImage(tls, (*TTkMenuEntry)(unsafe.Pointer(mePtr)).Fimage) } (*TTkMenuEntry)(unsafe.Pointer(mePtr)).Fimage = image if (*TTkMenuEntry)(unsafe.Pointer(mePtr)).FselectImagePtr != libc.UintptrFromInt32(0) { selectImageString = libtcl9_0.XTcl_GetStringFromObj(tls, (*TTkMenuEntry)(unsafe.Pointer(mePtr)).FselectImagePtr, libc.UintptrFromInt32(0)) image = XTk_GetImage(tls, (*TTkMenu)(unsafe.Pointer(menuPtr)).Finterp, (*TTkMenu)(unsafe.Pointer(menuPtr)).Ftkwin, selectImageString, __ccgo_fp(XTkMenuSelectImageProc), mePtr) if image == libc.UintptrFromInt32(0) { return int32(TCL_ERROR) } } else { image = libc.UintptrFromInt32(0) } if (*TTkMenuEntry)(unsafe.Pointer(mePtr)).FselectImage != libc.UintptrFromInt32(0) { XTk_FreeImage(tls, (*TTkMenuEntry)(unsafe.Pointer(mePtr)).FselectImage) } (*TTkMenuEntry)(unsafe.Pointer(mePtr)).FselectImage = image if (*TTkMenuEntry)(unsafe.Pointer(mePtr)).Ftype1 == int32(CHECK_BUTTON_ENTRY) || (*TTkMenuEntry)(unsafe.Pointer(mePtr)).Ftype1 == int32(RADIO_BUTTON_ENTRY) { if (*TTkMenuEntry)(unsafe.Pointer(mePtr)).FnamePtr == libc.UintptrFromInt32(0) { if (*TTkMenuEntry)(unsafe.Pointer(mePtr)).FlabelPtr == libc.UintptrFromInt32(0) { (*TTkMenuEntry)(unsafe.Pointer(mePtr)).FnamePtr = libc.UintptrFromInt32(0) } else { (*TTkMenuEntry)(unsafe.Pointer(mePtr)).FnamePtr = libtcl9_0.XTcl_DuplicateObj(tls, (*TTkMenuEntry)(unsafe.Pointer(mePtr)).FlabelPtr) (*TTcl_Obj)(unsafe.Pointer((*TTkMenuEntry)(unsafe.Pointer(mePtr)).FnamePtr)).FrefCount++ } } if (*TTkMenuEntry)(unsafe.Pointer(mePtr)).FonValuePtr == libc.UintptrFromInt32(0) { if (*TTkMenuEntry)(unsafe.Pointer(mePtr)).FlabelPtr == libc.UintptrFromInt32(0) { (*TTkMenuEntry)(unsafe.Pointer(mePtr)).FonValuePtr = libc.UintptrFromInt32(0) } else { (*TTkMenuEntry)(unsafe.Pointer(mePtr)).FonValuePtr = libtcl9_0.XTcl_DuplicateObj(tls, (*TTkMenuEntry)(unsafe.Pointer(mePtr)).FlabelPtr) (*TTcl_Obj)(unsafe.Pointer((*TTkMenuEntry)(unsafe.Pointer(mePtr)).FonValuePtr)).FrefCount++ } } /* * Select the entry if the associated variable has the appropriate * value, initialize the variable if it doesn't exist, then set a * trace on the variable to monitor future changes to its value. */ if (*TTkMenuEntry)(unsafe.Pointer(mePtr)).FnamePtr != libc.UintptrFromInt32(0) { valuePtr = libtcl9_0.XTcl_ObjGetVar2(tls, (*TTkMenu)(unsafe.Pointer(menuPtr)).Finterp, (*TTkMenuEntry)(unsafe.Pointer(mePtr)).FnamePtr, libc.UintptrFromInt32(0), int32(TCL_GLOBAL_ONLY)) } else { valuePtr = libc.UintptrFromInt32(0) } *(*int32)(unsafe.Pointer(mePtr + 272)) &= ^libc.Int32FromInt32(ENTRY_SELECTED) if valuePtr != libc.UintptrFromInt32(0) { if (*TTkMenuEntry)(unsafe.Pointer(mePtr)).FonValuePtr != libc.UintptrFromInt32(0) { value = libtcl9_0.XTcl_GetStringFromObj(tls, valuePtr, libc.UintptrFromInt32(0)) onValue = libtcl9_0.XTcl_GetStringFromObj(tls, (*TTkMenuEntry)(unsafe.Pointer(mePtr)).FonValuePtr, libc.UintptrFromInt32(0)) if libc.Xstrcmp(tls, value, onValue) == 0 { *(*int32)(unsafe.Pointer(mePtr + 272)) |= int32(ENTRY_SELECTED) } } } else { if (*TTkMenuEntry)(unsafe.Pointer(mePtr)).FnamePtr != libc.UintptrFromInt32(0) { if (*TTkMenuEntry)(unsafe.Pointer(mePtr)).Ftype1 == int32(CHECK_BUTTON_ENTRY) { v3 = (*TTkMenuEntry)(unsafe.Pointer(mePtr)).FoffValuePtr } else { v3 = libtcl9_0.XTcl_NewObj(tls) } libtcl9_0.XTcl_ObjSetVar2(tls, (*TTkMenu)(unsafe.Pointer(menuPtr)).Finterp, (*TTkMenuEntry)(unsafe.Pointer(mePtr)).FnamePtr, libc.UintptrFromInt32(0), v3, int32(TCL_GLOBAL_ONLY)) } } if (*TTkMenuEntry)(unsafe.Pointer(mePtr)).FnamePtr != libc.UintptrFromInt32(0) { name = libtcl9_0.XTcl_GetStringFromObj(tls, (*TTkMenuEntry)(unsafe.Pointer(mePtr)).FnamePtr, libc.UintptrFromInt32(0)) libtcl9_0.XTcl_TraceVar2(tls, (*TTkMenu)(unsafe.Pointer(menuPtr)).Finterp, name, libc.UintptrFromInt32(0), libc.Int32FromInt32(TCL_GLOBAL_ONLY)|libc.Int32FromInt32(TCL_TRACE_WRITES)|libc.Int32FromInt32(TCL_TRACE_UNSETS), __ccgo_fp(_MenuVarProc), mePtr) } } if XTkpConfigureMenuEntry(tls, mePtr) != TCL_OK { return int32(TCL_ERROR) } return TCL_OK } /* *---------------------------------------------------------------------- * * ConfigureMenuEntry -- * * This function is called to process an argv/argc list in order to * configure (or reconfigure) one entry in a menu. * * Results: * The return value is a standard Tcl result. If TCL_ERROR is returned, * then the interp's result contains an error message. * * Side effects: * Configuration information such as label and accelerator get set for * mePtr; old resources get freed, if there were any. * *---------------------------------------------------------------------- */ func _ConfigureMenuEntry(tls *libc.TLS, mePtr uintptr, objc TTcl_Size, objv uintptr) (r int32) { bp := tls.Alloc(512) defer tls.Free(512) /* Arguments. */ var menuPtr, name uintptr var result int32 var _ /* errorStruct at bp+0 */ TTk_SavedOptions _, _, _ = menuPtr, name, result menuPtr = (*TTkMenuEntry)(unsafe.Pointer(mePtr)).FmenuPtr /* * If this entry is a check button or radio button, then remove its old * trace function. */ if (*TTkMenuEntry)(unsafe.Pointer(mePtr)).FnamePtr != libc.UintptrFromInt32(0) && ((*TTkMenuEntry)(unsafe.Pointer(mePtr)).Ftype1 == int32(CHECK_BUTTON_ENTRY) || (*TTkMenuEntry)(unsafe.Pointer(mePtr)).Ftype1 == int32(RADIO_BUTTON_ENTRY)) { name = libtcl9_0.XTcl_GetStringFromObj(tls, (*TTkMenuEntry)(unsafe.Pointer(mePtr)).FnamePtr, libc.UintptrFromInt32(0)) libtcl9_0.XTcl_UntraceVar2(tls, (*TTkMenu)(unsafe.Pointer(menuPtr)).Finterp, name, libc.UintptrFromInt32(0), libc.Int32FromInt32(TCL_GLOBAL_ONLY)|libc.Int32FromInt32(TCL_TRACE_WRITES)|libc.Int32FromInt32(TCL_TRACE_UNSETS), __ccgo_fp(_MenuVarProc), mePtr) } result = TCL_OK if (*TTkMenu)(unsafe.Pointer(menuPtr)).Ftkwin != libc.UintptrFromInt32(0) { if XTk_SetOptions(tls, (*TTkMenu)(unsafe.Pointer(menuPtr)).Finterp, mePtr, (*TTkMenuEntry)(unsafe.Pointer(mePtr)).FoptionTable, objc, objv, (*TTkMenu)(unsafe.Pointer(menuPtr)).Ftkwin, bp, libc.UintptrFromInt32(0)) != TCL_OK { return int32(TCL_ERROR) } result = _PostProcessEntry(tls, mePtr) if result != TCL_OK { XTk_RestoreSavedOptions(tls, bp) _PostProcessEntry(tls, mePtr) } XTk_FreeSavedOptions(tls, bp) } XTkEventuallyRecomputeMenu(tls, menuPtr) return result } /* *---------------------------------------------------------------------- * * ConfigureMenuCloneEntries -- * * Calls ConfigureMenuEntry for each menu in the clone chain. * * Results: * The return value is a standard Tcl result. * * Side effects: * Configuration information such as label and accelerator get set for * mePtr; old resources get freed, if there were any. * *---------------------------------------------------------------------- */ func _ConfigureMenuCloneEntries(tls *libc.TLS, menuPtr uintptr, index int32, objc TTcl_Size, objv uintptr) (r int32) { bp := tls.Alloc(16) defer tls.Free(16) /* Arguments. */ var _objPtr, _objPtr1, _objPtr2, _objPtr3, _objPtr4, cascadeMenuRefPtr, mePtr, menuListPtr, menuObjPtr, newCascadeName, newCloneNamePtr, normalPtr, oldCascadeMenuRefPtr, oldCascadeName, oldCascadePtr, pathNamePtr, v11, v2, v5, v7, v9 uintptr var cascadeEntryChanged int32 var v1, v10, v4, v6, v8 TTcl_Size var _ /* newObjv at bp+0 */ [2]uintptr _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = _objPtr, _objPtr1, _objPtr2, _objPtr3, _objPtr4, cascadeEntryChanged, cascadeMenuRefPtr, mePtr, menuListPtr, menuObjPtr, newCascadeName, newCloneNamePtr, normalPtr, oldCascadeMenuRefPtr, oldCascadeName, oldCascadePtr, pathNamePtr, v1, v10, v11, v2, v4, v5, v6, v7, v8, v9 cascadeEntryChanged = 0 cascadeMenuRefPtr = libc.UintptrFromInt32(0) oldCascadePtr = libc.UintptrFromInt32(0) /* * Cascades are kind of tricky here. This is special case #3 in the * comment at the top of this file. Basically, if a menu is the main * menu of a clone chain, and has an entry with a cascade menu, the clones * of the menu will point to clones of the cascade menu. We have to * destroy the clones of the cascades, clone the new cascade menu, and * configure the entry to point to the new clone. */ mePtr = *(*uintptr)(unsafe.Pointer((*TTkMenu1)(unsafe.Pointer((*TTkMenu)(unsafe.Pointer(menuPtr)).FmainMenuPtr)).Fentries + uintptr(index)*8)) if (*TTkMenuEntry)(unsafe.Pointer(mePtr)).Ftype1 == CASCADE_ENTRY { oldCascadePtr = (*TTkMenuEntry)(unsafe.Pointer(mePtr)).FnamePtr if oldCascadePtr != libc.UintptrFromInt32(0) { (*TTcl_Obj)(unsafe.Pointer(oldCascadePtr)).FrefCount++ } } if _ConfigureMenuEntry(tls, mePtr, objc, objv) != TCL_OK { return int32(TCL_ERROR) } if (*TTkMenuEntry)(unsafe.Pointer(mePtr)).Ftype1 == CASCADE_ENTRY { if (*TTkMenuEntry)(unsafe.Pointer(mePtr)).FnamePtr != libc.UintptrFromInt32(0) { newCascadeName = libtcl9_0.XTcl_GetStringFromObj(tls, (*TTkMenuEntry)(unsafe.Pointer(mePtr)).FnamePtr, libc.UintptrFromInt32(0)) } else { newCascadeName = libc.UintptrFromInt32(0) } if oldCascadePtr == libc.UintptrFromInt32(0) && (*TTkMenuEntry)(unsafe.Pointer(mePtr)).FnamePtr == libc.UintptrFromInt32(0) { cascadeEntryChanged = 0 } else { if oldCascadePtr == libc.UintptrFromInt32(0) && (*TTkMenuEntry)(unsafe.Pointer(mePtr)).FnamePtr != libc.UintptrFromInt32(0) || oldCascadePtr != libc.UintptrFromInt32(0) && (*TTkMenuEntry)(unsafe.Pointer(mePtr)).FnamePtr == libc.UintptrFromInt32(0) { cascadeEntryChanged = int32(1) } else { oldCascadeName = libtcl9_0.XTcl_GetStringFromObj(tls, oldCascadePtr, libc.UintptrFromInt32(0)) cascadeEntryChanged = libc.BoolInt32(libc.Xstrcmp(tls, oldCascadeName, newCascadeName) != 0) } } if oldCascadePtr != libc.UintptrFromInt32(0) { _objPtr = oldCascadePtr v2 = _objPtr v1 = *(*TTcl_Size)(unsafe.Pointer(v2)) *(*TTcl_Size)(unsafe.Pointer(v2))-- if v1 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr) } } } if cascadeEntryChanged != 0 { if (*TTkMenuEntry)(unsafe.Pointer(mePtr)).FnamePtr != libc.UintptrFromInt32(0) { newCascadeName = libtcl9_0.XTcl_GetStringFromObj(tls, (*TTkMenuEntry)(unsafe.Pointer(mePtr)).FnamePtr, libc.UintptrFromInt32(0)) cascadeMenuRefPtr = XTkFindMenuReferences(tls, (*TTkMenu)(unsafe.Pointer(menuPtr)).Finterp, newCascadeName) } } menuListPtr = (*TTkMenu1)(unsafe.Pointer((*TTkMenu)(unsafe.Pointer(menuPtr)).FmainMenuPtr)).FnextInstancePtr for { if !(menuListPtr != libc.UintptrFromInt32(0)) { break } mePtr = *(*uintptr)(unsafe.Pointer((*TTkMenu)(unsafe.Pointer(menuListPtr)).Fentries + uintptr(index)*8)) if cascadeEntryChanged != 0 && (*TTkMenuEntry)(unsafe.Pointer(mePtr)).FnamePtr != libc.UintptrFromInt32(0) { oldCascadeMenuRefPtr = XTkFindMenuReferencesObj(tls, (*TTkMenu)(unsafe.Pointer(menuPtr)).Finterp, (*TTkMenuEntry)(unsafe.Pointer(mePtr)).FnamePtr) if oldCascadeMenuRefPtr != libc.UintptrFromInt32(0) && (*TTkMenuReferences)(unsafe.Pointer(oldCascadeMenuRefPtr)).FmenuPtr != libc.UintptrFromInt32(0) { _RecursivelyDeleteMenu(tls, (*TTkMenuReferences)(unsafe.Pointer(oldCascadeMenuRefPtr)).FmenuPtr) } } if _ConfigureMenuEntry(tls, mePtr, objc, objv) != TCL_OK { return int32(TCL_ERROR) } if cascadeEntryChanged != 0 && (*TTkMenuEntry)(unsafe.Pointer(mePtr)).FnamePtr != libc.UintptrFromInt32(0) { if cascadeMenuRefPtr != 0 && (*TTkMenuReferences)(unsafe.Pointer(cascadeMenuRefPtr)).FmenuPtr != libc.UintptrFromInt32(0) { pathNamePtr = libtcl9_0.XTcl_NewStringObj(tls, (*TTk_FakeWin)(unsafe.Pointer((*TTkMenu)(unsafe.Pointer(menuListPtr)).Ftkwin)).FpathName, int64(-libc.Int32FromInt32(1))) normalPtr = libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+9363, int64(-libc.Int32FromInt32(1))) menuObjPtr = libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+23078, int64(-libc.Int32FromInt32(1))) (*TTcl_Obj)(unsafe.Pointer(pathNamePtr)).FrefCount++ newCloneNamePtr = XTkNewMenuName(tls, (*TTkMenu)(unsafe.Pointer(menuPtr)).Finterp, pathNamePtr, (*TTkMenuReferences)(unsafe.Pointer(cascadeMenuRefPtr)).FmenuPtr) (*TTcl_Obj)(unsafe.Pointer(newCloneNamePtr)).FrefCount++ (*TTcl_Obj)(unsafe.Pointer(normalPtr)).FrefCount++ _CloneMenu(tls, (*TTkMenuReferences)(unsafe.Pointer(cascadeMenuRefPtr)).FmenuPtr, newCloneNamePtr, normalPtr) (*(*[2]uintptr)(unsafe.Pointer(bp)))[0] = menuObjPtr (*(*[2]uintptr)(unsafe.Pointer(bp)))[int32(1)] = newCloneNamePtr (*TTcl_Obj)(unsafe.Pointer(menuObjPtr)).FrefCount++ _ConfigureMenuEntry(tls, mePtr, int64(2), bp) _objPtr1 = newCloneNamePtr v5 = _objPtr1 v4 = *(*TTcl_Size)(unsafe.Pointer(v5)) *(*TTcl_Size)(unsafe.Pointer(v5))-- if v4 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr1) } _objPtr2 = pathNamePtr v7 = _objPtr2 v6 = *(*TTcl_Size)(unsafe.Pointer(v7)) *(*TTcl_Size)(unsafe.Pointer(v7))-- if v6 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr2) } _objPtr3 = normalPtr v9 = _objPtr3 v8 = *(*TTcl_Size)(unsafe.Pointer(v9)) *(*TTcl_Size)(unsafe.Pointer(v9))-- if v8 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr3) } _objPtr4 = menuObjPtr v11 = _objPtr4 v10 = *(*TTcl_Size)(unsafe.Pointer(v11)) *(*TTcl_Size)(unsafe.Pointer(v11))-- if v10 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr4) } } } goto _3 _3: ; menuListPtr = (*TTkMenu)(unsafe.Pointer(menuListPtr)).FnextInstancePtr } return TCL_OK } /* *-------------------------------------------------------------- * * GetMenuIndex -- * * Parse a textual index into a menu and return the numerical index of * the indicated entry. * * Results: * A standard Tcl result. If all went well, then *indexPtr is filled in * with the entry index corresponding to string (ranges from -1 to the * number of entries in the menu minus one). Otherwise an error message * is left in the interp's result. * * Side effects: * None. * *-------------------------------------------------------------- */ func _GetMenuIndex(tls *libc.TLS, interp uintptr, menuPtr uintptr, objPtr uintptr, lastOK int32, indexPtr uintptr) (r int32) { bp := tls.Alloc(48) defer tls.Free(48) /* Where to store converted index. */ var entryPtr, label, labelPtr, mePtr, string1, v4 uintptr var i TTcl_Size var v1, v2 int32 _, _, _, _, _, _, _, _, _ = entryPtr, i, label, labelPtr, mePtr, string1, v1, v2, v4 if XTkGetIntForIndex(tls, objPtr, (*TTkMenu)(unsafe.Pointer(menuPtr)).FnumEntries-int64(1), lastOK, indexPtr) == TCL_OK { /* TCL_INDEX_NONE is only accepted if it does not result from a negative number */ if *(*TTcl_Size)(unsafe.Pointer(indexPtr)) >= 0 || libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(libtcl9_0.XTcl_GetStringFromObj(tls, objPtr, libc.UintptrFromInt32(0))))) != int32('-') { if *(*TTcl_Size)(unsafe.Pointer(indexPtr)) >= (*TTkMenu)(unsafe.Pointer(menuPtr)).FnumEntries { if lastOK != 0 { v1 = 0 } else { v1 = int32(1) } *(*TTcl_Size)(unsafe.Pointer(indexPtr)) = (*TTkMenu)(unsafe.Pointer(menuPtr)).FnumEntries - int64(v1) } return TCL_OK } } string1 = libtcl9_0.XTcl_GetStringFromObj(tls, objPtr, libc.UintptrFromInt32(0)) if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(string1))) == int32('a') && libc.Xstrcmp(tls, string1, __ccgo_ts+16724) == 0 { *(*TTcl_Size)(unsafe.Pointer(indexPtr)) = (*TTkMenu)(unsafe.Pointer(menuPtr)).Factive return TCL_OK } if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(string1))) == int32('l') && libc.Xstrcmp(tls, string1, __ccgo_ts+24701) == 0 { if lastOK != 0 { v2 = 0 } else { v2 = int32(1) } *(*TTcl_Size)(unsafe.Pointer(indexPtr)) = (*TTkMenu)(unsafe.Pointer(menuPtr)).FnumEntries - int64(v2) return TCL_OK } if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(string1))) == 0 { *(*TTcl_Size)(unsafe.Pointer(indexPtr)) = int64(-libc.Int32FromInt32(1)) return TCL_OK } if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(string1))) == int32('n') && libc.Xstrcmp(tls, string1, __ccgo_ts+8223) == 0 { *(*TTcl_Size)(unsafe.Pointer(indexPtr)) = int64(-libc.Int32FromInt32(1)) return TCL_OK } if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(string1))) == int32('@') { if _GetIndexFromCoords(tls, interp, menuPtr, string1, indexPtr) == TCL_OK { return TCL_OK } } entryPtr = (*(*func(*libc.TLS, uintptr, uintptr) uintptr)(unsafe.Pointer(&struct{ uintptr }{(*TTcl_HashTable)(unsafe.Pointer(menuPtr + 344)).FfindProc})))(tls, menuPtr+344, string1) if entryPtr != 0 { mePtr = (*TTcl_HashEntry)(unsafe.Pointer(entryPtr)).FclientData *(*TTcl_Size)(unsafe.Pointer(indexPtr)) = int64((*TTkMenuEntry)(unsafe.Pointer(mePtr)).Findex) return TCL_OK } i = 0 for { if !(i < (*TTkMenu)(unsafe.Pointer(menuPtr)).FnumEntries) { break } labelPtr = (*TTkMenuEntry)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer((*TTkMenu)(unsafe.Pointer(menuPtr)).Fentries + uintptr(i)*8)))).FlabelPtr if labelPtr == libc.UintptrFromInt32(0) { v4 = libc.UintptrFromInt32(0) } else { v4 = libtcl9_0.XTcl_GetStringFromObj(tls, labelPtr, libc.UintptrFromInt32(0)) } label = v4 if label != libc.UintptrFromInt32(0) && libtcl9_0.XTcl_StringCaseMatch(tls, label, string1, 0) != 0 { *(*TTcl_Size)(unsafe.Pointer(indexPtr)) = i return TCL_OK } goto _3 _3: ; i++ } libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+24706, libc.VaList(bp+8, string1))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+8, __ccgo_ts+179, __ccgo_ts+24732, __ccgo_ts+5789, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) } /* *---------------------------------------------------------------------- * * MenuCmdDeletedProc -- * * This function is invoked when a widget command is deleted. If the * widget isn't already in the process of being destroyed, this command * destroys it. * * Results: * None. * * Side effects: * The widget is destroyed. * *---------------------------------------------------------------------- */ func _MenuCmdDeletedProc(tls *libc.TLS, clientData uintptr) { /* Pointer to widget record for widget. */ var menuPtr uintptr var tkwin TTk_Window _, _ = menuPtr, tkwin menuPtr = clientData tkwin = (*TTkMenu)(unsafe.Pointer(menuPtr)).Ftkwin /* * This function could be invoked either because the window was destroyed * and the command was then deleted (in which case tkwin is NULL) or * because the command was deleted, and then this function destroys the * widget. */ if tkwin != libc.UintptrFromInt32(0) { /* * Note: it may be desirable to NULL out the tkwin field of menuPtr * here: * menuPtr->tkwin = NULL; */ XTk_DestroyWindow(tls, tkwin) } } /* *---------------------------------------------------------------------- * * MenuNewEntry -- * * This function allocates and initializes a new menu entry. * * Results: * The return value is a pointer to a new menu entry structure, which has * been malloc-ed, initialized, and entered into the entry array for the * menu. * * Side effects: * Storage gets allocated. * *---------------------------------------------------------------------- */ func _MenuNewEntry(tls *libc.TLS, menuPtr uintptr, index TTcl_Size, type1 int32) (r uintptr) { /* The type of the new entry. */ var i TTcl_Size var mePtr, newEntries, tsdPtr uintptr _, _, _, _ = i, mePtr, newEntries, tsdPtr tsdPtr = libtcl9_0.XTcl_GetThreadData(tls, uintptr(unsafe.Pointer(&_dataKey11)), int64(64)) /* * Create a new array of entries with an empty slot for the new entry. */ newEntries = libtcl9_0.XTcl_Alloc(tls, libc.Uint64FromInt64((*TTkMenu)(unsafe.Pointer(menuPtr)).FnumEntries+libc.Int64FromInt32(1))*uint64(8)) i = 0 for { if !(i < index) { break } *(*uintptr)(unsafe.Pointer(newEntries + uintptr(i)*8)) = *(*uintptr)(unsafe.Pointer((*TTkMenu)(unsafe.Pointer(menuPtr)).Fentries + uintptr(i)*8)) goto _1 _1: ; i++ } for { if !(i < (*TTkMenu)(unsafe.Pointer(menuPtr)).FnumEntries) { break } *(*uintptr)(unsafe.Pointer(newEntries + uintptr(i+int64(1))*8)) = *(*uintptr)(unsafe.Pointer((*TTkMenu)(unsafe.Pointer(menuPtr)).Fentries + uintptr(i)*8)) (*TTkMenuEntry)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(newEntries + uintptr(i+int64(1))*8)))).Findex = int32(i + int64(1)) goto _2 _2: ; i++ } if (*TTkMenu)(unsafe.Pointer(menuPtr)).FnumEntries != 0 { libtcl9_0.XTcl_Free(tls, (*TTkMenu)(unsafe.Pointer(menuPtr)).Fentries) } (*TTkMenu)(unsafe.Pointer(menuPtr)).Fentries = newEntries (*TTkMenu)(unsafe.Pointer(menuPtr)).FnumEntries++ mePtr = libtcl9_0.XTcl_Alloc(tls, uint64(312)) *(*uintptr)(unsafe.Pointer((*TTkMenu)(unsafe.Pointer(menuPtr)).Fentries + uintptr(index)*8)) = mePtr (*TTkMenuEntry)(unsafe.Pointer(mePtr)).Ftype1 = type1 (*TTkMenuEntry)(unsafe.Pointer(mePtr)).FoptionTable = *(*TTk_OptionTable)(unsafe.Pointer(tsdPtr + 16 + uintptr(type1)*8)) (*TTkMenuEntry)(unsafe.Pointer(mePtr)).FmenuPtr = menuPtr (*TTkMenuEntry)(unsafe.Pointer(mePtr)).FlabelPtr = libc.UintptrFromInt32(0) (*TTkMenuEntry)(unsafe.Pointer(mePtr)).FlabelLength = 0 (*TTkMenuEntry)(unsafe.Pointer(mePtr)).Funderline = -libc.Int32FromInt32(1) - libc.Int32FromInt32(0x7fffffff) (*TTkMenuEntry)(unsafe.Pointer(mePtr)).FbitmapPtr = libc.UintptrFromInt32(0) (*TTkMenuEntry)(unsafe.Pointer(mePtr)).FimagePtr = libc.UintptrFromInt32(0) (*TTkMenuEntry)(unsafe.Pointer(mePtr)).Fimage = libc.UintptrFromInt32(0) (*TTkMenuEntry)(unsafe.Pointer(mePtr)).FselectImagePtr = libc.UintptrFromInt32(0) (*TTkMenuEntry)(unsafe.Pointer(mePtr)).FselectImage = libc.UintptrFromInt32(0) (*TTkMenuEntry)(unsafe.Pointer(mePtr)).FaccelPtr = libc.UintptrFromInt32(0) (*TTkMenuEntry)(unsafe.Pointer(mePtr)).FaccelLength = 0 (*TTkMenuEntry)(unsafe.Pointer(mePtr)).Fstate = int32(ENTRY_DISABLED) (*TTkMenuEntry)(unsafe.Pointer(mePtr)).FborderPtr = libc.UintptrFromInt32(0) (*TTkMenuEntry)(unsafe.Pointer(mePtr)).FfgPtr = libc.UintptrFromInt32(0) (*TTkMenuEntry)(unsafe.Pointer(mePtr)).FactiveBorderPtr = libc.UintptrFromInt32(0) (*TTkMenuEntry)(unsafe.Pointer(mePtr)).FactiveFgPtr = libc.UintptrFromInt32(0) (*TTkMenuEntry)(unsafe.Pointer(mePtr)).FfontPtr = libc.UintptrFromInt32(0) (*TTkMenuEntry)(unsafe.Pointer(mePtr)).FindicatorOn = 0 (*TTkMenuEntry)(unsafe.Pointer(mePtr)).FindicatorFgPtr = libc.UintptrFromInt32(0) (*TTkMenuEntry)(unsafe.Pointer(mePtr)).FcolumnBreak = 0 (*TTkMenuEntry)(unsafe.Pointer(mePtr)).FhideMargin = 0 (*TTkMenuEntry)(unsafe.Pointer(mePtr)).FcommandPtr = libc.UintptrFromInt32(0) (*TTkMenuEntry)(unsafe.Pointer(mePtr)).FnamePtr = libc.UintptrFromInt32(0) (*TTkMenuEntry)(unsafe.Pointer(mePtr)).FchildMenuRefPtr = libc.UintptrFromInt32(0) (*TTkMenuEntry)(unsafe.Pointer(mePtr)).FonValuePtr = libc.UintptrFromInt32(0) (*TTkMenuEntry)(unsafe.Pointer(mePtr)).FoffValuePtr = libc.UintptrFromInt32(0) (*TTkMenuEntry)(unsafe.Pointer(mePtr)).FentryFlags = 0 (*TTkMenuEntry)(unsafe.Pointer(mePtr)).Findex = int32(index) (*TTkMenuEntry)(unsafe.Pointer(mePtr)).FnextCascadePtr = libc.UintptrFromInt32(0) if XTk_InitOptions(tls, (*TTkMenu)(unsafe.Pointer(menuPtr)).Finterp, mePtr, (*TTkMenuEntry)(unsafe.Pointer(mePtr)).FoptionTable, (*TTkMenu)(unsafe.Pointer(menuPtr)).Ftkwin) != TCL_OK { libtcl9_0.XTcl_Free(tls, mePtr) return libc.UintptrFromInt32(0) } (*TTkMenuEntry)(unsafe.Pointer(mePtr)).FentryPtr = libc.UintptrFromInt32(0) XTkMenuInitializeEntryDrawingFields(tls, mePtr) if XTkpMenuNewEntry(tls, mePtr) != TCL_OK { XTk_FreeConfigOptions(tls, mePtr, (*TTkMenuEntry)(unsafe.Pointer(mePtr)).FoptionTable, (*TTkMenu)(unsafe.Pointer(menuPtr)).Ftkwin) libtcl9_0.XTcl_Free(tls, mePtr) return libc.UintptrFromInt32(0) } return mePtr } /* *---------------------------------------------------------------------- * * MenuAddOrInsert -- * * This function does all of the work of the "add" and "insert" widget * commands, allowing the code for these to be shared. * * Results: * A standard Tcl return value. * * Side effects: * A new menu entry is created in menuPtr. * *---------------------------------------------------------------------- */ func _MenuAddOrInsert(tls *libc.TLS, interp uintptr, menuPtr uintptr, indexPtr uintptr, objc TTcl_Size, objv uintptr) (r int32) { bp := tls.Alloc(96) defer tls.Free(96) /* Arguments to command: first arg is type of * entry, others are config options. */ var _objPtr, _objPtr1, _objPtr2, _objPtr3, cascadeMenuPtr, entryPtr, errorMenuPtr, idPtr, mePtr, menuListPtr, menuNamePtr, menuRefPtr, newCascadePtr, normalPtr, windowNamePtr, v11, v13, v15, v5, v7, v9 uintptr var i, v10, v12, v14, v4, v8 TTcl_Size var offs, v6 int32 var _ /* idbuf at bp+20 */ [16]uint8 var _ /* index at bp+8 */ TTcl_Size var _ /* isNew at bp+16 */ int32 var _ /* newObjv at bp+40 */ [2]uintptr var _ /* type at bp+0 */ int32 _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = _objPtr, _objPtr1, _objPtr2, _objPtr3, cascadeMenuPtr, entryPtr, errorMenuPtr, i, idPtr, mePtr, menuListPtr, menuNamePtr, menuRefPtr, newCascadePtr, normalPtr, offs, windowNamePtr, v10, v11, v12, v13, v14, v15, v4, v5, v6, v7, v8, v9 idPtr = libc.UintptrFromInt32(0) if indexPtr != libc.UintptrFromInt32(0) { if _GetMenuIndex(tls, interp, menuPtr, indexPtr, int32(1), bp+8) != TCL_OK { return int32(TCL_ERROR) } } else { *(*TTcl_Size)(unsafe.Pointer(bp + 8)) = (*TTkMenu)(unsafe.Pointer(menuPtr)).FnumEntries } if *(*TTcl_Size)(unsafe.Pointer(bp + 8)) < 0 { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+24706, libc.VaList(bp+64, libtcl9_0.XTcl_GetStringFromObj(tls, indexPtr, libc.UintptrFromInt32(0))))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+64, __ccgo_ts+179, __ccgo_ts+24732, __ccgo_ts+5789, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) } if (*TTkMenu)(unsafe.Pointer(menuPtr)).Ftearoff != 0 && *(*TTcl_Size)(unsafe.Pointer(bp + 8)) == 0 { *(*TTcl_Size)(unsafe.Pointer(bp + 8)) = int64(1) } /* * Figure out the type of the new entry. */ if libtcl9_0.XTcl_GetIndexFromObjStruct(tls, interp, *(*uintptr)(unsafe.Pointer(objv)), uintptr(unsafe.Pointer(&_menuEntryTypeStrings)), libc.Int64FromUint64(libc.Uint64FromInt64(8)), __ccgo_ts+24737, libc.Int32FromInt32(0)|libc.Int32FromUint64(libc.Uint64FromInt64(4)<= 0 { mePtr = *(*uintptr)(unsafe.Pointer((*TTkMenu)(unsafe.Pointer(menuPtr)).Fentries + uintptr((*TTkMenu)(unsafe.Pointer(menuPtr)).Factive)*8)) /* * Don't change the state unless it's currently active (state might * already have been changed to disabled). */ if (*TTkMenuEntry)(unsafe.Pointer(mePtr)).Fstate == ENTRY_ACTIVE { (*TTkMenuEntry)(unsafe.Pointer(mePtr)).Fstate = int32(ENTRY_NORMAL) } XTkEventuallyRedrawMenu(tls, menuPtr, *(*uintptr)(unsafe.Pointer((*TTkMenu)(unsafe.Pointer(menuPtr)).Fentries + uintptr((*TTkMenu)(unsafe.Pointer(menuPtr)).Factive)*8))) } (*TTkMenu)(unsafe.Pointer(menuPtr)).Factive = index if index >= 0 { mePtr = *(*uintptr)(unsafe.Pointer((*TTkMenu)(unsafe.Pointer(menuPtr)).Fentries + uintptr(index)*8)) (*TTkMenuEntry)(unsafe.Pointer(mePtr)).Fstate = ENTRY_ACTIVE XTkEventuallyRedrawMenu(tls, menuPtr, mePtr) } return result } /* *---------------------------------------------------------------------- * * TkPostCommand -- * * Execute the postcommand for the given menu. * * Results: * The return value is a standard Tcl result (errors can occur while the * postcommands are being processed). * * Side effects: * Since commands can get executed while this routine is being executed, * the entire world can change. * *---------------------------------------------------------------------- */ func XTkPostCommand(tls *libc.TLS, menuPtr uintptr) (r int32) { var _objPtr, postCommandPtr, v2 uintptr var result int32 var v1 TTcl_Size _, _, _, _, _ = _objPtr, postCommandPtr, result, v1, v2 /* * If there is a command for the menu, execute it. This may change the * size of the menu, so be sure to recompute the menu's geometry if * needed. */ if (*TTkMenu)(unsafe.Pointer(menuPtr)).FpostCommandPtr != libc.UintptrFromInt32(0) { postCommandPtr = (*TTkMenu)(unsafe.Pointer(menuPtr)).FpostCommandPtr (*TTcl_Obj)(unsafe.Pointer(postCommandPtr)).FrefCount++ result = libtcl9_0.XTcl_EvalObjEx(tls, (*TTkMenu)(unsafe.Pointer(menuPtr)).Finterp, postCommandPtr, int32(TCL_EVAL_GLOBAL)) _objPtr = postCommandPtr v2 = _objPtr v1 = *(*TTcl_Size)(unsafe.Pointer(v2)) *(*TTcl_Size)(unsafe.Pointer(v2))-- if v1 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr) } if result != TCL_OK { return result } XTkRecomputeMenu(tls, menuPtr) } return TCL_OK } /* *-------------------------------------------------------------- * * CloneMenu -- * * Creates a child copy of the menu. It will be inserted into the menu's * instance chain. All attributes and entry attributes will be * duplicated. * * Results: * A standard Tcl result. * * Side effects: * Allocates storage. After the menu is created, any configuration done * with this menu or any related one will be reflected in all of them. * *-------------------------------------------------------------- */ func _CloneMenu(tls *libc.TLS, menuPtr uintptr, newMenuNamePtr uintptr, newMenuTypePtr uintptr) (r int32) { bp := tls.Alloc(96) defer tls.Free(96) /* What kind of menu is this, a normal menu a * menubar, or a tearoff? */ var _objPtr, _objPtr1, _objPtr2, _objPtr3, _objPtr4, _objPtr5, _objPtr6, bindingsPtr, cascadeRefPtr, mainMenuPtr, menuRefPtr, newCascadePtr, newMenuPtr, oldCascadePtr, windowName, windowNamePtr, v11, v13, v16, v18, v20, v4, v5, v9 uintptr var i, v10, v12, v15, v17, v19, v3, v8 TTcl_Size var returnResult int32 var v6 bool var _ /* elementPtr at bp+72 */ uintptr var _ /* menuDupCommandArray at bp+8 */ [4]uintptr var _ /* menuType at bp+0 */ int32 var _ /* newElementPtr at bp+80 */ uintptr var _ /* newObjv at bp+40 */ [3]uintptr var _ /* numElements at bp+64 */ TTcl_Size _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = _objPtr, _objPtr1, _objPtr2, _objPtr3, _objPtr4, _objPtr5, _objPtr6, bindingsPtr, cascadeRefPtr, i, mainMenuPtr, menuRefPtr, newCascadePtr, newMenuPtr, oldCascadePtr, returnResult, windowName, windowNamePtr, v10, v11, v12, v13, v15, v16, v17, v18, v19, v20, v3, v4, v5, v6, v8, v9 if newMenuTypePtr == libc.UintptrFromInt32(0) { *(*int32)(unsafe.Pointer(bp)) = int32(MAIN_MENU) } else { if libtcl9_0.XTcl_GetIndexFromObjStruct(tls, (*TTkMenu)(unsafe.Pointer(menuPtr)).Finterp, newMenuTypePtr, uintptr(unsafe.Pointer(&_menuTypeStrings)), libc.Int64FromUint64(libc.Uint64FromInt64(8)), __ccgo_ts+24841, libc.Int32FromInt32(0)|libc.Int32FromUint64(libc.Uint64FromInt64(4)<= (*TTkMenuEntry)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer((*TTkMenu)(unsafe.Pointer(menuPtr)).Fentries + uintptr(i)*8)))).Fx && *(*int32)(unsafe.Pointer(bp + 4)) >= (*TTkMenuEntry)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer((*TTkMenu)(unsafe.Pointer(menuPtr)).Fentries + uintptr(i)*8)))).Fy && *(*int32)(unsafe.Pointer(bp)) < x2 && *(*int32)(unsafe.Pointer(bp + 4)) < (*TTkMenuEntry)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer((*TTkMenu)(unsafe.Pointer(menuPtr)).Fentries + uintptr(i)*8)))).Fy+(*TTkMenuEntry)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer((*TTkMenu)(unsafe.Pointer(menuPtr)).Fentries + uintptr(i)*8)))).Fheight { *(*TTcl_Size)(unsafe.Pointer(indexPtr)) = i break } goto _2 _2: ; i++ } return TCL_OK goto error error: ; libtcl9_0.XTcl_ResetResult(tls, interp) return int64(TCL_ERROR) } /* *---------------------------------------------------------------------- * * RecursivelyDeleteMenu -- * * Deletes a menu and any cascades underneath it. Used for deleting * instances when a menu is no longer being used as a menubar, for * instance. * * Results: * None. * * Side effects: * Destroys the menu and all cascade menus underneath it. * *---------------------------------------------------------------------- */ func _RecursivelyDeleteMenu(tls *libc.TLS, menuPtr uintptr) { /* The menubar instance we are deleting. */ var i TTcl_Size var mePtr uintptr _, _ = i, mePtr /* * It is not 100% clear that this preserve/release pair is required, but * we have added them for safety in this very complex code. */ libtcl9_0.XTcl_Preserve(tls, menuPtr) i = 0 for { if !(i < (*TTkMenu)(unsafe.Pointer(menuPtr)).FnumEntries) { break } mePtr = *(*uintptr)(unsafe.Pointer((*TTkMenu)(unsafe.Pointer(menuPtr)).Fentries + uintptr(i)*8)) if (*TTkMenuEntry)(unsafe.Pointer(mePtr)).Ftype1 == CASCADE_ENTRY && (*TTkMenuEntry)(unsafe.Pointer(mePtr)).FchildMenuRefPtr != libc.UintptrFromInt32(0) && (*TTkMenuReferences1)(unsafe.Pointer((*TTkMenuEntry)(unsafe.Pointer(mePtr)).FchildMenuRefPtr)).FmenuPtr != libc.UintptrFromInt32(0) { _RecursivelyDeleteMenu(tls, (*TTkMenuReferences1)(unsafe.Pointer((*TTkMenuEntry)(unsafe.Pointer(mePtr)).FchildMenuRefPtr)).FmenuPtr) } goto _1 _1: ; i++ } if (*TTkMenu)(unsafe.Pointer(menuPtr)).Ftkwin != libc.UintptrFromInt32(0) { XTk_DestroyWindow(tls, (*TTkMenu)(unsafe.Pointer(menuPtr)).Ftkwin) } libtcl9_0.XTcl_Release(tls, menuPtr) } /* *---------------------------------------------------------------------- * * TkNewMenuName -- * * Makes a new unique name for a cloned menu. Will be a child of oldName. * * Results: * Returns a char * which has been allocated; caller must free. * * Side effects: * Memory is allocated. * *---------------------------------------------------------------------- */ func XTkNewMenuName(tls *libc.TLS, interp uintptr, parentPtr uintptr, menuPtr uintptr) (r uintptr) { /* The menu we are cloning. */ var _objPtr, _objPtr1, _objPtr2, childPtr, destString, intPtr, nameTablePtr, parentName, resultPtr, winPtr, v4, v6, v8 uintptr var doDot, i int32 var v3, v5, v7 TTcl_Size _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = _objPtr, _objPtr1, _objPtr2, childPtr, destString, doDot, i, intPtr, nameTablePtr, parentName, resultPtr, winPtr, v3, v4, v5, v6, v7, v8 resultPtr = libc.UintptrFromInt32(0) nameTablePtr = libc.UintptrFromInt32(0) winPtr = (*TTkMenu)(unsafe.Pointer(menuPtr)).Ftkwin parentName = libtcl9_0.XTcl_GetStringFromObj(tls, parentPtr, libc.UintptrFromInt32(0)) if (*TTkWindow)(unsafe.Pointer(winPtr)).FmainPtr != libc.UintptrFromInt32(0) { nameTablePtr = (*TTkWindow)(unsafe.Pointer(winPtr)).FmainPtr + 24 } doDot = libc.BoolInt32(libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(parentName + uintptr(libc.Xstrlen(tls, parentName)-uint64(1))))) != int32('.')) childPtr = libtcl9_0.XTcl_NewStringObj(tls, (*TTk_FakeWin)(unsafe.Pointer((*TTkMenu)(unsafe.Pointer(menuPtr)).Ftkwin)).FpathName, int64(-libc.Int32FromInt32(1))) destString = libtcl9_0.XTcl_GetStringFromObj(tls, childPtr, libc.UintptrFromInt32(0)) for { if !(libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(destString))) != int32('\000')) { break } if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(destString))) == int32('.') { *(*uint8)(unsafe.Pointer(destString)) = uint8('#') } goto _1 _1: ; destString++ } i = 0 for { if i == 0 { resultPtr = libtcl9_0.XTcl_DuplicateObj(tls, parentPtr) if doDot != 0 { libtcl9_0.XTcl_AppendToObj(tls, resultPtr, __ccgo_ts+18591, int64(-libc.Int32FromInt32(1))) } libtcl9_0.XTcl_AppendObjToObj(tls, resultPtr, childPtr) } else { _objPtr = resultPtr v4 = _objPtr v3 = *(*TTcl_Size)(unsafe.Pointer(v4)) *(*TTcl_Size)(unsafe.Pointer(v4))-- if v3 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr) } resultPtr = libtcl9_0.XTcl_DuplicateObj(tls, parentPtr) if doDot != 0 { libtcl9_0.XTcl_AppendToObj(tls, resultPtr, __ccgo_ts+18591, int64(-libc.Int32FromInt32(1))) } libtcl9_0.XTcl_AppendObjToObj(tls, resultPtr, childPtr) intPtr = libtcl9_0.XTcl_NewWideIntObj(tls, int64(i)) libtcl9_0.XTcl_AppendObjToObj(tls, resultPtr, intPtr) _objPtr1 = intPtr v6 = _objPtr1 v5 = *(*TTcl_Size)(unsafe.Pointer(v6)) *(*TTcl_Size)(unsafe.Pointer(v6))-- if v5 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr1) } } destString = libtcl9_0.XTcl_GetStringFromObj(tls, resultPtr, libc.UintptrFromInt32(0)) if libtcl9_0.XTcl_FindCommand(tls, interp, destString, libc.UintptrFromInt32(0), 0) == libc.UintptrFromInt32(0) && (nameTablePtr == libc.UintptrFromInt32(0) || (*(*func(*libc.TLS, uintptr, uintptr) uintptr)(unsafe.Pointer(&struct{ uintptr }{(*TTcl_HashTable)(unsafe.Pointer(nameTablePtr)).FfindProc})))(tls, nameTablePtr, destString) == libc.UintptrFromInt32(0)) { break } goto _2 _2: ; i++ } _objPtr2 = childPtr v8 = _objPtr2 v7 = *(*TTcl_Size)(unsafe.Pointer(v8)) *(*TTcl_Size)(unsafe.Pointer(v8))-- if v7 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr2) } return resultPtr } /* *---------------------------------------------------------------------- * * Tk_SetWindowMenubar -- * * Associates a menu with a window. Called by ConfigureFrame in in * response to a "-menu .foo" configuration option for a top level. * * Results: * None. * * Side effects: * The old menu clones for the menubar are thrown away, and a handler is * set up to allocate the new ones. * *---------------------------------------------------------------------- */ func XTk_SetWindowMenubar(tls *libc.TLS, interp uintptr, tkwin TTk_Window, oldMenuName uintptr, menuName uintptr) { bp := tls.Alloc(32) defer tls.Free(32) /* The name of the new menubar that the * toplevel needs to be set to. NULL means * that their is no menu now. */ var _objPtr, _objPtr1, _objPtr2, _objPtr3, _objPtr4, cloneMenuPtr, cloneMenuRefPtr, cursorPtr, instancePtr, menuBarPtr, menuPtr, menuRefPtr, menubarPtr, nullPtr, prevTopLevelPtr, topLevelListPtr, windowNamePtr, v11, v3, v5, v7, v9 uintptr var v10, v2, v4, v6, v8 TTcl_Size var _ /* newObjv at bp+0 */ [4]uintptr _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = _objPtr, _objPtr1, _objPtr2, _objPtr3, _objPtr4, cloneMenuPtr, cloneMenuRefPtr, cursorPtr, instancePtr, menuBarPtr, menuPtr, menuRefPtr, menubarPtr, nullPtr, prevTopLevelPtr, topLevelListPtr, windowNamePtr, v10, v11, v2, v3, v4, v5, v6, v7, v8, v9 /* * Destroy the menubar instances of the old menu. Take this window out of * the old menu's top level reference list. */ if oldMenuName != libc.UintptrFromInt32(0) { menuRefPtr = XTkFindMenuReferences(tls, interp, oldMenuName) if menuRefPtr != libc.UintptrFromInt32(0) { /* * Find the menubar instance that is to be removed. Destroy it and * all of the cascades underneath it. */ if (*TTkMenuReferences)(unsafe.Pointer(menuRefPtr)).FmenuPtr != libc.UintptrFromInt32(0) { menuPtr = (*TTkMenuReferences)(unsafe.Pointer(menuRefPtr)).FmenuPtr instancePtr = (*TTkMenu)(unsafe.Pointer(menuPtr)).FmainMenuPtr for { if !(instancePtr != libc.UintptrFromInt32(0)) { break } if (*TTkMenu)(unsafe.Pointer(instancePtr)).FmenuType == MENUBAR && (*TTkMenu)(unsafe.Pointer(instancePtr)).FparentTopLevelPtr == tkwin { _RecursivelyDeleteMenu(tls, instancePtr) break } goto _1 _1: ; instancePtr = (*TTkMenu)(unsafe.Pointer(instancePtr)).FnextInstancePtr } } /* * Now we need to remove this toplevel from the list of toplevels * that reference this menu. */ topLevelListPtr = (*TTkMenuReferences)(unsafe.Pointer(menuRefPtr)).FtopLevelListPtr prevTopLevelPtr = libc.UintptrFromInt32(0) for topLevelListPtr != libc.UintptrFromInt32(0) && (*TTkMenuTopLevelList)(unsafe.Pointer(topLevelListPtr)).Ftkwin != tkwin { prevTopLevelPtr = topLevelListPtr topLevelListPtr = (*TTkMenuTopLevelList)(unsafe.Pointer(topLevelListPtr)).FnextPtr } /* * Now we have found the toplevel reference that matches the * tkwin; remove this reference from the list. */ if topLevelListPtr != libc.UintptrFromInt32(0) { if prevTopLevelPtr == libc.UintptrFromInt32(0) { (*TTkMenuReferences)(unsafe.Pointer(menuRefPtr)).FtopLevelListPtr = (*TTkMenuTopLevelList)(unsafe.Pointer((*TTkMenuReferences)(unsafe.Pointer(menuRefPtr)).FtopLevelListPtr)).FnextPtr } else { (*TTkMenuTopLevelList)(unsafe.Pointer(prevTopLevelPtr)).FnextPtr = (*TTkMenuTopLevelList)(unsafe.Pointer(topLevelListPtr)).FnextPtr } libtcl9_0.XTcl_Free(tls, topLevelListPtr) XTkFreeMenuReferences(tls, menuRefPtr) } } } /* * Now, add the clone references for the new menu. */ if menuName != libc.UintptrFromInt32(0) && libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(menuName))) != 0 { menuBarPtr = libc.UintptrFromInt32(0) menuRefPtr = XTkCreateMenuReferences(tls, interp, menuName) menuPtr = (*TTkMenuReferences)(unsafe.Pointer(menuRefPtr)).FmenuPtr if menuPtr != libc.UintptrFromInt32(0) { windowNamePtr = libtcl9_0.XTcl_NewStringObj(tls, (*TTk_FakeWin)(unsafe.Pointer(tkwin)).FpathName, int64(-int32(1))) menubarPtr = libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+24198, int64(-libc.Int32FromInt32(1))) /* * Clone the menu and all of the cascades underneath it. */ (*TTcl_Obj)(unsafe.Pointer(windowNamePtr)).FrefCount++ cloneMenuPtr = XTkNewMenuName(tls, interp, windowNamePtr, menuPtr) (*TTcl_Obj)(unsafe.Pointer(cloneMenuPtr)).FrefCount++ (*TTcl_Obj)(unsafe.Pointer(menubarPtr)).FrefCount++ _CloneMenu(tls, menuPtr, cloneMenuPtr, menubarPtr) cloneMenuRefPtr = XTkFindMenuReferencesObj(tls, interp, cloneMenuPtr) if cloneMenuRefPtr != libc.UintptrFromInt32(0) && (*TTkMenuReferences)(unsafe.Pointer(cloneMenuRefPtr)).FmenuPtr != libc.UintptrFromInt32(0) { cursorPtr = libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+4638, int64(-libc.Int32FromInt32(1))) nullPtr = libtcl9_0.XTcl_NewObj(tls) (*TTkMenu1)(unsafe.Pointer((*TTkMenuReferences)(unsafe.Pointer(cloneMenuRefPtr)).FmenuPtr)).FparentTopLevelPtr = tkwin menuBarPtr = (*TTkMenuReferences)(unsafe.Pointer(cloneMenuRefPtr)).FmenuPtr (*(*[4]uintptr)(unsafe.Pointer(bp)))[0] = cursorPtr (*(*[4]uintptr)(unsafe.Pointer(bp)))[int32(1)] = nullPtr (*TTcl_Obj)(unsafe.Pointer(cursorPtr)).FrefCount++ (*TTcl_Obj)(unsafe.Pointer(nullPtr)).FrefCount++ _ConfigureMenu(tls, (*TTkMenu)(unsafe.Pointer(menuPtr)).Finterp, (*TTkMenuReferences)(unsafe.Pointer(cloneMenuRefPtr)).FmenuPtr, int64(2), bp) _objPtr = cursorPtr v3 = _objPtr v2 = *(*TTcl_Size)(unsafe.Pointer(v3)) *(*TTcl_Size)(unsafe.Pointer(v3))-- if v2 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr) } _objPtr1 = nullPtr v5 = _objPtr1 v4 = *(*TTcl_Size)(unsafe.Pointer(v5)) *(*TTcl_Size)(unsafe.Pointer(v5))-- if v4 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr1) } } XTkpSetWindowMenuBar(tls, tkwin, menuBarPtr) _objPtr2 = cloneMenuPtr v7 = _objPtr2 v6 = *(*TTcl_Size)(unsafe.Pointer(v7)) *(*TTcl_Size)(unsafe.Pointer(v7))-- if v6 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr2) } _objPtr3 = menubarPtr v9 = _objPtr3 v8 = *(*TTcl_Size)(unsafe.Pointer(v9)) *(*TTcl_Size)(unsafe.Pointer(v9))-- if v8 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr3) } _objPtr4 = windowNamePtr v11 = _objPtr4 v10 = *(*TTcl_Size)(unsafe.Pointer(v11)) *(*TTcl_Size)(unsafe.Pointer(v11))-- if v10 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr4) } } else { XTkpSetWindowMenuBar(tls, tkwin, libc.UintptrFromInt32(0)) } /* * Add this window to the menu's list of windows that refer to this * menu. */ topLevelListPtr = libtcl9_0.XTcl_Alloc(tls, uint64(16)) (*TTkMenuTopLevelList)(unsafe.Pointer(topLevelListPtr)).Ftkwin = tkwin (*TTkMenuTopLevelList)(unsafe.Pointer(topLevelListPtr)).FnextPtr = (*TTkMenuReferences)(unsafe.Pointer(menuRefPtr)).FtopLevelListPtr (*TTkMenuReferences)(unsafe.Pointer(menuRefPtr)).FtopLevelListPtr = topLevelListPtr } else { XTkpSetWindowMenuBar(tls, tkwin, libc.UintptrFromInt32(0)) } XTk_SetMainMenubar(tls, interp, tkwin, menuName) } /* *---------------------------------------------------------------------- * * DestroyMenuHashTable -- * * Called when an interp is deleted and a menu hash table has been set in * it. * * Results: * None. * * Side effects: * The hash table is destroyed. * *---------------------------------------------------------------------- */ func _DestroyMenuHashTable(tls *libc.TLS, clientData uintptr, dummy3416 uintptr) { /* The interpreter we are destroying. */ libtcl9_0.XTcl_DeleteHashTable(tls, clientData) libtcl9_0.XTcl_Free(tls, clientData) } /* *---------------------------------------------------------------------- * * TkGetMenuHashTable -- * * For a given interp, give back the menu hash table that goes with it. * If the hash table does not exist, it is created. * * Results: * Returns a hash table pointer. * * Side effects: * A new hash table is created if there were no table in the interp * originally. * *---------------------------------------------------------------------- */ func XTkGetMenuHashTable(tls *libc.TLS, interp uintptr) (r uintptr) { /* The interp we need the hash table in.*/ var menuTablePtr uintptr _ = menuTablePtr menuTablePtr = libtcl9_0.XTcl_GetAssocData(tls, interp, __ccgo_ts+24863, libc.UintptrFromInt32(0)) if menuTablePtr == libc.UintptrFromInt32(0) { menuTablePtr = libtcl9_0.XTcl_Alloc(tls, uint64(104)) libtcl9_0.XTcl_InitHashTable(tls, menuTablePtr, TCL_STRING_KEYS) libtcl9_0.XTcl_SetAssocData(tls, interp, __ccgo_ts+24863, __ccgo_fp(_DestroyMenuHashTable), menuTablePtr) } return menuTablePtr } /* *---------------------------------------------------------------------- * * TkCreateMenuReferences -- * * Given a pathname, gives back a pointer to a TkMenuReferences * structure. If a reference is not already in the hash table, one is * created. * * Results: * Returns a pointer to a menu reference structure. Should not be freed * by calller; when a field of the reference is cleared, * TkFreeMenuReferences should be called. * * Side effects: * A new hash table entry is created if there were no references to the * menu originally. * *---------------------------------------------------------------------- */ func XTkCreateMenuReferences(tls *libc.TLS, interp uintptr, pathName uintptr) (r uintptr) { bp := tls.Alloc(16) defer tls.Free(16) /* The path of the menu widget. */ var hashEntryPtr, menuRefPtr, menuTablePtr uintptr var _ /* newEntry at bp+0 */ int32 _, _, _ = hashEntryPtr, menuRefPtr, menuTablePtr menuTablePtr = XTkGetMenuHashTable(tls, interp) hashEntryPtr = (*(*func(*libc.TLS, uintptr, uintptr, uintptr) uintptr)(unsafe.Pointer(&struct{ uintptr }{(*TTcl_HashTable)(unsafe.Pointer(menuTablePtr)).FcreateProc})))(tls, menuTablePtr, pathName, bp) if *(*int32)(unsafe.Pointer(bp)) != 0 { menuRefPtr = libtcl9_0.XTcl_Alloc(tls, uint64(32)) (*TTkMenuReferences)(unsafe.Pointer(menuRefPtr)).FmenuPtr = libc.UintptrFromInt32(0) (*TTkMenuReferences)(unsafe.Pointer(menuRefPtr)).FtopLevelListPtr = libc.UintptrFromInt32(0) (*TTkMenuReferences)(unsafe.Pointer(menuRefPtr)).FparentEntryPtr = libc.UintptrFromInt32(0) (*TTkMenuReferences)(unsafe.Pointer(menuRefPtr)).FhashEntryPtr = hashEntryPtr (*TTcl_HashEntry)(unsafe.Pointer(hashEntryPtr)).FclientData = menuRefPtr } else { menuRefPtr = (*TTcl_HashEntry)(unsafe.Pointer(hashEntryPtr)).FclientData } return menuRefPtr } /* *---------------------------------------------------------------------- * * TkFindMenuReferences -- * * Given a pathname, gives back a pointer to the TkMenuReferences * structure. * * Results: * Returns a pointer to a menu reference structure. Should not be freed * by calller; when a field of the reference is cleared, * TkFreeMenuReferences should be called. Returns NULL if no reference * with this pathname exists. * * Side effects: * None. * *---------------------------------------------------------------------- */ func XTkFindMenuReferences(tls *libc.TLS, interp uintptr, pathName uintptr) (r uintptr) { /* The path of the menu widget. */ var hashEntryPtr, menuRefPtr, menuTablePtr uintptr _, _, _ = hashEntryPtr, menuRefPtr, menuTablePtr menuRefPtr = libc.UintptrFromInt32(0) menuTablePtr = XTkGetMenuHashTable(tls, interp) hashEntryPtr = (*(*func(*libc.TLS, uintptr, uintptr) uintptr)(unsafe.Pointer(&struct{ uintptr }{(*TTcl_HashTable)(unsafe.Pointer(menuTablePtr)).FfindProc})))(tls, menuTablePtr, pathName) if hashEntryPtr != libc.UintptrFromInt32(0) { menuRefPtr = (*TTcl_HashEntry)(unsafe.Pointer(hashEntryPtr)).FclientData } return menuRefPtr } /* *---------------------------------------------------------------------- * * TkFindMenuReferencesObj -- * * Given a pathname, gives back a pointer to the TkMenuReferences * structure. * * Results: * Returns a pointer to a menu reference structure. Should not be freed * by calller; when a field of the reference is cleared, * TkFreeMenuReferences should be called. Returns NULL if no reference * with this pathname exists. * * Side effects: * None. * *---------------------------------------------------------------------- */ func XTkFindMenuReferencesObj(tls *libc.TLS, interp uintptr, objPtr uintptr) (r uintptr) { /* The path of the menu widget. */ var pathName uintptr _ = pathName pathName = libtcl9_0.XTcl_GetStringFromObj(tls, objPtr, libc.UintptrFromInt32(0)) return XTkFindMenuReferences(tls, interp, pathName) } /* *---------------------------------------------------------------------- * * TkFreeMenuReferences -- * * This is called after one of the fields in a menu reference is cleared. * It cleans up the ref if it is now empty. * * Results: * Returns 1 if the references structure was freed, and 0 otherwise. * * Side effects: * If this is the last field to be cleared, the menu ref is taken out of * the hash table. * *---------------------------------------------------------------------- */ func XTkFreeMenuReferences(tls *libc.TLS, menuRefPtr uintptr) (r int32) { /* The menu reference to free. */ if (*TTkMenuReferences)(unsafe.Pointer(menuRefPtr)).FmenuPtr == libc.UintptrFromInt32(0) && (*TTkMenuReferences)(unsafe.Pointer(menuRefPtr)).FparentEntryPtr == libc.UintptrFromInt32(0) && (*TTkMenuReferences)(unsafe.Pointer(menuRefPtr)).FtopLevelListPtr == libc.UintptrFromInt32(0) { libtcl9_0.XTcl_DeleteHashEntry(tls, (*TTkMenuReferences)(unsafe.Pointer(menuRefPtr)).FhashEntryPtr) libtcl9_0.XTcl_Free(tls, menuRefPtr) return int32(1) } return 0 } /* *---------------------------------------------------------------------- * * DeleteMenuCloneEntries -- * * For every clone in this clone chain, delete the menu entries given by * the parameters. * * Results: * None. * * Side effects: * The appropriate entries are deleted from all clones of this menu. * *---------------------------------------------------------------------- */ func _DeleteMenuCloneEntries(tls *libc.TLS, menuPtr uintptr, first int32, last int32) { /* The zero-based last entry. */ var i, j, numDeleted TTcl_Size var menuListPtr uintptr _, _, _, _ = i, j, menuListPtr, numDeleted numDeleted = int64(last + int32(1) - first) menuListPtr = (*TTkMenu)(unsafe.Pointer(menuPtr)).FmainMenuPtr for { if !(menuListPtr != libc.UintptrFromInt32(0)) { break } i = int64(last) for { if !(i >= int64(first)) { break } libtcl9_0.XTcl_EventuallyFree(tls, *(*uintptr)(unsafe.Pointer((*TTkMenu)(unsafe.Pointer(menuListPtr)).Fentries + uintptr(i)*8)), __ccgo_fp(_DestroyMenuEntry)) goto _2 _2: ; i-- } i = int64(last + int32(1)) for { if !(i < (*TTkMenu)(unsafe.Pointer(menuListPtr)).FnumEntries) { break } j = i - numDeleted *(*uintptr)(unsafe.Pointer((*TTkMenu)(unsafe.Pointer(menuListPtr)).Fentries + uintptr(j)*8)) = *(*uintptr)(unsafe.Pointer((*TTkMenu)(unsafe.Pointer(menuListPtr)).Fentries + uintptr(i)*8)) (*TTkMenuEntry)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer((*TTkMenu)(unsafe.Pointer(menuListPtr)).Fentries + uintptr(j)*8)))).Findex = int32(j) goto _3 _3: ; i++ } *(*TTcl_Size)(unsafe.Pointer(menuListPtr + 40)) -= numDeleted if (*TTkMenu)(unsafe.Pointer(menuListPtr)).FnumEntries == 0 { libtcl9_0.XTcl_Free(tls, (*TTkMenu)(unsafe.Pointer(menuListPtr)).Fentries) (*TTkMenu)(unsafe.Pointer(menuListPtr)).Fentries = libc.UintptrFromInt32(0) } if int32((*TTkMenu)(unsafe.Pointer(menuListPtr)).Factive) >= first && int32((*TTkMenu)(unsafe.Pointer(menuListPtr)).Factive) <= last { (*TTkMenu)(unsafe.Pointer(menuListPtr)).Factive = int64(-int32(1)) } else { if int32((*TTkMenu)(unsafe.Pointer(menuListPtr)).Factive) > last { *(*TTcl_Size)(unsafe.Pointer(menuListPtr + 48)) -= numDeleted } } XTkEventuallyRecomputeMenu(tls, menuListPtr) goto _1 _1: ; menuListPtr = (*TTkMenu)(unsafe.Pointer(menuListPtr)).FnextInstancePtr } } /* *---------------------------------------------------------------------- * * MenuCleanup -- * * Resets menusInitialized to allow Tk to be finalized and reused without * the DLL being unloaded. * * Results: * None. * * Side effects: * None. * *---------------------------------------------------------------------- */ func _MenuCleanup(tls *libc.TLS, dummy3673 uintptr) { _menusInitialized = 0 } /* *---------------------------------------------------------------------- * * TkMenuInit -- * * Sets up the hash tables and the variables used by the menu package. * * Results: * None. * * Side effects: * lastMenuID gets initialized, and the parent hash and the command hash * are allocated. * *---------------------------------------------------------------------- */ func XTkMenuInit(tls *libc.TLS) { var tsdPtr uintptr _ = tsdPtr tsdPtr = libtcl9_0.XTcl_GetThreadData(tls, uintptr(unsafe.Pointer(&_dataKey11)), int64(64)) if !(_menusInitialized != 0) { libtcl9_0.XTcl_MutexLock(tls, uintptr(unsafe.Pointer(&_menuMutex))) if !(_menusInitialized != 0) { XTkpMenuInit(tls) _menusInitialized = int32(1) } /* * Make sure we cleanup on finalize. */ XTkCreateExitHandler(tls, __ccgo_fp(_MenuCleanup), libc.UintptrFromInt32(0)) libtcl9_0.XTcl_MutexUnlock(tls, uintptr(unsafe.Pointer(&_menuMutex))) } if !((*TThreadSpecificData11)(unsafe.Pointer(tsdPtr)).FmenusInitialized != 0) { XTkpMenuThreadInit(tls) (*TThreadSpecificData11)(unsafe.Pointer(tsdPtr)).FmenuOptionTable = XTk_CreateOptionTable(tls, libc.UintptrFromInt32(0), uintptr(unsafe.Pointer(&_tkMenuConfigSpecs))) *(*TTk_OptionTable)(unsafe.Pointer(tsdPtr + 16 + 5*8)) = XTk_CreateOptionTable(tls, libc.UintptrFromInt32(0), _specsArray[int32(TEAROFF_ENTRY)]) *(*TTk_OptionTable)(unsafe.Pointer(tsdPtr + 16 + 2*8)) = XTk_CreateOptionTable(tls, libc.UintptrFromInt32(0), _specsArray[int32(COMMAND_ENTRY)]) *(*TTk_OptionTable)(unsafe.Pointer(tsdPtr + 16)) = XTk_CreateOptionTable(tls, libc.UintptrFromInt32(0), _specsArray[CASCADE_ENTRY]) *(*TTk_OptionTable)(unsafe.Pointer(tsdPtr + 16 + 4*8)) = XTk_CreateOptionTable(tls, libc.UintptrFromInt32(0), _specsArray[int32(SEPARATOR_ENTRY)]) *(*TTk_OptionTable)(unsafe.Pointer(tsdPtr + 16 + 3*8)) = XTk_CreateOptionTable(tls, libc.UintptrFromInt32(0), _specsArray[int32(RADIO_BUTTON_ENTRY)]) *(*TTk_OptionTable)(unsafe.Pointer(tsdPtr + 16 + 1*8)) = XTk_CreateOptionTable(tls, libc.UintptrFromInt32(0), _specsArray[int32(CHECK_BUTTON_ENTRY)]) (*TThreadSpecificData11)(unsafe.Pointer(tsdPtr)).FmenusInitialized = int32(1) } } type TTkMenu1 = struct { Ftkwin TTk_Window Fdisplay uintptr Finterp uintptr FwidgetCmd TTcl_Command Fentries uintptr FnumEntries TTcl_Size Factive TTcl_Size FmenuType int32 FmenuTypePtr uintptr FborderPtr uintptr FborderWidthObj uintptr FactiveBorderPtr uintptr FactiveBorderWidthPtr uintptr Frelief int32 FfontPtr uintptr FfgPtr uintptr FdisabledFgPtr uintptr FactiveFgPtr uintptr FindicatorFgPtr uintptr Fgray TPixmap FtextGC TGC FdisabledGC TGC FactiveGC TGC FindicatorGC TGC FdisabledImageGC TGC FtotalWidth int32 FtotalHeight int32 Ftearoff int32 FtitlePtr uintptr FtearoffCommandPtr uintptr FtakeFocusPtr uintptr FcursorPtr uintptr FpostCommandPtr uintptr FpostCommandGeneration int32 FmenuFlags int32 FpostedCascade uintptr FnextInstancePtr uintptr FmainMenuPtr uintptr Freserved1 uintptr FparentTopLevelPtr TTk_Window FmenuRefPtr uintptr FplatformData TTkMenuPlatformData FextensionPtr uintptr FerrorStructPtr uintptr FactiveRelief int32 Fitems TTcl_HashTable Fserial int32 } type TTkMenuReferences1 = struct { FmenuPtr uintptr FtopLevelListPtr uintptr FparentEntryPtr uintptr FhashEntryPtr uintptr } const GOT_FOCUS4 = 4 const INDICATOR_HEIGHT = 17 const INDICATOR_WIDTH = 40 const POSTED = 2 type direction = int32 const DIRECTION_ABOVE = 0 const DIRECTION_BELOW = 1 const DIRECTION_FLUSH = 2 const DIRECTION_LEFT = 3 const DIRECTION_RIGHT = 4 const STATE_DISABLED2 = 1 const STATE_NORMAL2 = 2 type TTkMenuButton = struct { Ftkwin TTk_Window Fdisplay uintptr Finterp uintptr FwidgetCmd TTcl_Command FoptionTable TTk_OptionTable FmenuNameObj uintptr FtextObj uintptr Funderline int32 FtextVarNameObj uintptr Fbitmap TPixmap FimageObj uintptr Fimage TTk_Image Fstate state FnormalBorder TTk_3DBorder FactiveBorder TTk_3DBorder FborderWidthObj uintptr Frelief int32 FhighlightWidthObj uintptr FhighlightBgColorPtr uintptr FhighlightColorPtr uintptr Finset int32 Ftkfont TTk_Font FnormalFg uintptr FactiveFg uintptr FdisabledFg uintptr FnormalTextGC TGC FactiveTextGC TGC Fgray TPixmap FdisabledGC TGC FstippleGC TGC FleftBearing int32 FrightBearing int32 FwidthObj uintptr FheightObj uintptr Fwidth int32 Fheight int32 FwrapLengthObj uintptr FpadXObj uintptr FpadYObj uintptr Fanchor TTk_Anchor Fjustify TTk_Justify FtextWidth int32 FtextHeight int32 FtextLayout TTk_TextLayout FindicatorOn int32 FindicatorHeight int32 FindicatorWidth int32 Fcompound int32 Fdirection direction Fcursor TTk_Cursor FtakeFocusObj uintptr Fflags int32 } /* * The structure below defines menubutton class behavior by means of * procedures that can be invoked from generic window code. */ var _menubuttonClass = TTk_ClassProcs{ Fsize: int64(32), } func init() { p := unsafe.Pointer(&_menubuttonClass) *(*uintptr)(unsafe.Add(p, 8)) = __ccgo_fp(XTkMenuButtonWorldChanged) } /* * The following table defines the legal values for the -direction option. It * is used together with the "enum direction" declaration in tkMenubutton.h. */ var _directionStrings = [6]uintptr{ 0: __ccgo_ts + 24871, 1: __ccgo_ts + 24877, 2: __ccgo_ts + 24883, 3: __ccgo_ts + 10966, 4: __ccgo_ts + 10971, 5: libc.UintptrFromInt32(0), } /* * Information used for parsing configuration specs: */ var _optionSpecs4 = [34]TTk_OptionSpec{ 0: { Ftype1: int32(TK_OPTION_BORDER), FoptionName: __ccgo_ts + 19775, FdbName: __ccgo_ts + 19793, FdbClass: __ccgo_ts + 19810, FdefValue: __ccgo_ts + 19821, FobjOffset: int64(-libc.Int32FromInt32(1)), FinternalOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 112)), FclientData: __ccgo_ts + 19829, }, 1: { Ftype1: int32(TK_OPTION_COLOR), FoptionName: __ccgo_ts + 19837, FdbName: __ccgo_ts + 19855, FdbClass: __ccgo_ts + 19872, FdefValue: __ccgo_ts + 19829, FobjOffset: int64(-libc.Int32FromInt32(1)), FinternalOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 184)), FclientData: __ccgo_ts + 19883, }, 2: { Ftype1: int32(TK_OPTION_ANCHOR), FoptionName: __ccgo_ts + 15168, FdbName: __ccgo_ts + 7881, FdbClass: __ccgo_ts + 19891, FdefValue: __ccgo_ts + 10959, FobjOffset: int64(-libc.Int32FromInt32(1)), FinternalOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 296)), }, 3: { Ftype1: int32(TK_OPTION_BORDER), FoptionName: __ccgo_ts + 19898, FdbName: __ccgo_ts + 19910, FdbClass: __ccgo_ts + 19872, FdefValue: __ccgo_ts + 19921, FobjOffset: int64(-libc.Int32FromInt32(1)), FinternalOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 104)), FclientData: __ccgo_ts + 19883, }, 4: { Ftype1: int32(TK_OPTION_SYNONYM), FoptionName: __ccgo_ts + 19929, FinternalOffset: int64(-libc.Int32FromInt32(1)), FclientData: __ccgo_ts + 2814, }, 5: { Ftype1: int32(TK_OPTION_SYNONYM), FoptionName: __ccgo_ts + 19933, FinternalOffset: int64(-libc.Int32FromInt32(1)), FclientData: __ccgo_ts + 19898, }, 6: { Ftype1: int32(TK_OPTION_BITMAP), FoptionName: __ccgo_ts + 19937, FdbName: __ccgo_ts + 4030, FdbClass: __ccgo_ts + 19945, FdefValue: __ccgo_ts + 195, FobjOffset: int64(-libc.Int32FromInt32(1)), FinternalOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 72)), Fflags: int32(TCL_NULL_OK), }, 7: { Ftype1: int32(TK_OPTION_PIXELS), FoptionName: __ccgo_ts + 2814, FdbName: __ccgo_ts + 19952, FdbClass: __ccgo_ts + 19964, FdefValue: __ccgo_ts + 14538, FobjOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 120)), FinternalOffset: int64(-libc.Int32FromInt32(1)), }, 8: { Ftype1: int32(TK_OPTION_CURSOR), FoptionName: __ccgo_ts + 4638, FdbName: __ccgo_ts + 4646, FdbClass: __ccgo_ts + 4653, FdefValue: __ccgo_ts + 195, FobjOffset: int64(-libc.Int32FromInt32(1)), FinternalOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 344)), Fflags: int32(TCL_NULL_OK), }, 9: { Ftype1: int32(TK_OPTION_STRING_TABLE), FoptionName: __ccgo_ts + 24889, FdbName: __ccgo_ts + 24900, FdbClass: __ccgo_ts + 24910, FdefValue: __ccgo_ts + 24877, FobjOffset: int64(-libc.Int32FromInt32(1)), FinternalOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 336)), FclientData: uintptr(unsafe.Pointer(&_directionStrings)), }, 10: { Ftype1: int32(TK_OPTION_COLOR), FoptionName: __ccgo_ts + 20004, FdbName: __ccgo_ts + 20024, FdbClass: __ccgo_ts + 20043, FdefValue: __ccgo_ts + 20062, FobjOffset: int64(-libc.Int32FromInt32(1)), FinternalOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 192)), Fflags: int32(TCL_NULL_OK), FclientData: __ccgo_ts + 195, }, 11: { Ftype1: int32(TK_OPTION_SYNONYM), FoptionName: __ccgo_ts + 20070, FdbName: __ccgo_ts + 20074, FinternalOffset: int64(-libc.Int32FromInt32(1)), FclientData: __ccgo_ts + 20085, }, 12: { Ftype1: int32(TK_OPTION_FONT), FoptionName: __ccgo_ts + 20097, FdbName: __ccgo_ts + 9358, FdbClass: __ccgo_ts + 20103, FdefValue: __ccgo_ts + 20108, FobjOffset: int64(-libc.Int32FromInt32(1)), FinternalOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 168)), }, 13: { Ftype1: int32(TK_OPTION_COLOR), FoptionName: __ccgo_ts + 20085, FdbName: __ccgo_ts + 20074, FdbClass: __ccgo_ts + 19810, FdefValue: __ccgo_ts + 19829, FobjOffset: int64(-libc.Int32FromInt32(1)), FinternalOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 176)), }, 14: { Ftype1: int32(TK_OPTION_STRING), FoptionName: __ccgo_ts + 2870, FdbName: __ccgo_ts + 6172, FdbClass: __ccgo_ts + 20122, FdefValue: __ccgo_ts + 10533, FobjOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 256)), FinternalOffset: int64(-libc.Int32FromInt32(1)), }, 15: { Ftype1: int32(TK_OPTION_COLOR), FoptionName: __ccgo_ts + 20129, FdbName: __ccgo_ts + 20150, FdbClass: __ccgo_ts + 20170, FdefValue: __ccgo_ts + 19921, FobjOffset: int64(-libc.Int32FromInt32(1)), FinternalOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 144)), }, 16: { Ftype1: int32(TK_OPTION_COLOR), FoptionName: __ccgo_ts + 20190, FdbName: __ccgo_ts + 20206, FdbClass: __ccgo_ts + 20221, FdefValue: __ccgo_ts + 19829, FobjOffset: int64(-libc.Int32FromInt32(1)), FinternalOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 152)), }, 17: { Ftype1: int32(TK_OPTION_PIXELS), FoptionName: __ccgo_ts + 20236, FdbName: __ccgo_ts + 20256, FdbClass: __ccgo_ts + 20275, FdefValue: __ccgo_ts + 10533, FobjOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 136)), FinternalOffset: int64(-libc.Int32FromInt32(1)), }, 18: { Ftype1: int32(TK_OPTION_STRING), FoptionName: __ccgo_ts + 20294, FdbName: __ccgo_ts + 17810, FdbClass: __ccgo_ts + 20301, FobjOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 80)), FinternalOffset: int64(-libc.Int32FromInt32(1)), Fflags: int32(TCL_NULL_OK), }, 19: { FoptionName: __ccgo_ts + 20628, FdbName: __ccgo_ts + 20641, FdbClass: __ccgo_ts + 20653, FdefValue: __ccgo_ts + 10533, FobjOffset: int64(-libc.Int32FromInt32(1)), FinternalOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 320)), }, 20: { Ftype1: int32(TK_OPTION_JUSTIFY), FoptionName: __ccgo_ts + 20307, FdbName: __ccgo_ts + 20316, FdbClass: __ccgo_ts + 20324, FdefValue: __ccgo_ts + 10959, FobjOffset: int64(-libc.Int32FromInt32(1)), FinternalOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 300)), }, 21: { Ftype1: int32(TK_OPTION_STRING), FoptionName: __ccgo_ts + 23078, FdbName: __ccgo_ts + 17924, FdbClass: __ccgo_ts + 23084, FdefValue: __ccgo_ts + 195, FobjOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 40)), FinternalOffset: int64(-libc.Int32FromInt32(1)), Fflags: int32(TCL_NULL_OK), }, 22: { Ftype1: int32(TK_OPTION_PIXELS), FoptionName: __ccgo_ts + 12320, FdbName: __ccgo_ts + 20332, FdbClass: __ccgo_ts + 20337, FdefValue: __ccgo_ts + 24920, FobjOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 280)), FinternalOffset: int64(-libc.Int32FromInt32(1)), }, 23: { Ftype1: int32(TK_OPTION_PIXELS), FoptionName: __ccgo_ts + 12326, FdbName: __ccgo_ts + 20341, FdbClass: __ccgo_ts + 20337, FdefValue: __ccgo_ts + 24923, FobjOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 288)), FinternalOffset: int64(-libc.Int32FromInt32(1)), }, 24: { Ftype1: int32(TK_OPTION_RELIEF), FoptionName: __ccgo_ts + 20346, FdbName: __ccgo_ts + 82, FdbClass: __ccgo_ts + 20354, FdefValue: __ccgo_ts, FobjOffset: int64(-libc.Int32FromInt32(1)), FinternalOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 128)), }, 25: { Ftype1: int32(TK_OPTION_STRING_TABLE), FoptionName: __ccgo_ts + 19976, FdbName: __ccgo_ts + 19986, FdbClass: __ccgo_ts + 19995, FdefValue: __ccgo_ts + 8223, FobjOffset: int64(-libc.Int32FromInt32(1)), FinternalOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 332)), FclientData: uintptr(unsafe.Pointer(&XtkCompoundStrings)), }, 26: { Ftype1: int32(TK_OPTION_STRING_TABLE), FoptionName: __ccgo_ts + 2957, FdbName: __ccgo_ts + 16747, FdbClass: __ccgo_ts + 20361, FdefValue: __ccgo_ts + 9363, FobjOffset: int64(-libc.Int32FromInt32(1)), FinternalOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 96)), FclientData: uintptr(unsafe.Pointer(&XtkStateStrings)), }, 27: { Ftype1: int32(TK_OPTION_STRING), FoptionName: __ccgo_ts + 20367, FdbName: __ccgo_ts + 20378, FdbClass: __ccgo_ts + 20388, FdefValue: __ccgo_ts + 10533, FobjOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 352)), FinternalOffset: int64(-libc.Int32FromInt32(1)), Fflags: int32(TCL_NULL_OK), }, 28: { Ftype1: int32(TK_OPTION_STRING), FoptionName: __ccgo_ts + 20398, FdbName: __ccgo_ts + 17996, FdbClass: __ccgo_ts + 20404, FdefValue: __ccgo_ts + 195, FobjOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 48)), FinternalOffset: int64(-libc.Int32FromInt32(1)), }, 29: { Ftype1: int32(TK_OPTION_STRING), FoptionName: __ccgo_ts + 20409, FdbName: __ccgo_ts + 20423, FdbClass: __ccgo_ts + 20436, FdefValue: __ccgo_ts + 195, FobjOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 64)), FinternalOffset: int64(-libc.Int32FromInt32(1)), Fflags: int32(TCL_NULL_OK), }, 30: { Ftype1: int32(TK_OPTION_INDEX), FoptionName: __ccgo_ts + 9507, FdbName: __ccgo_ts + 9388, FdbClass: __ccgo_ts + 20445, FobjOffset: int64(-libc.Int32FromInt32(1)), FinternalOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 56)), Fflags: int32(TCL_NULL_OK), }, 31: { Ftype1: int32(TK_OPTION_STRING), FoptionName: __ccgo_ts + 2987, FdbName: __ccgo_ts + 6446, FdbClass: __ccgo_ts + 20455, FdefValue: __ccgo_ts + 10533, FobjOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 248)), FinternalOffset: int64(-libc.Int32FromInt32(1)), }, 32: { Ftype1: int32(TK_OPTION_PIXELS), FoptionName: __ccgo_ts + 20461, FdbName: __ccgo_ts + 20473, FdbClass: __ccgo_ts + 20484, FdefValue: __ccgo_ts + 10533, FobjOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 272)), FinternalOffset: int64(-libc.Int32FromInt32(1)), }, 33: { Ftype1: int32(TK_OPTION_END), }, } /* * The following tables define the menubutton widget commands and map the * indexes into the string tables into a single enumerated type used to * dispatch the scale widget command. */ var _commandNames2 = [3]uintptr{ 0: __ccgo_ts + 4735, 1: __ccgo_ts + 4740, 2: libc.UintptrFromInt32(0), } const COMMAND_CGET3 = 0 const COMMAND_CONFIGURE3 = 1 /* *-------------------------------------------------------------- * * Tk_MenubuttonObjCmd -- * * This function is invoked to process the "button", "label", * "radiobutton", and "checkbutton" Tcl commands. See the user * documentation for details on what it does. * * Results: * A standard Tcl result. * * Side effects: * See the user documentation. * *-------------------------------------------------------------- */ func XTk_MenubuttonObjCmd(tls *libc.TLS, dummy193 uintptr, interp uintptr, objc int32, objv uintptr) (r int32) { /* Argument objects. */ var mbPtr uintptr var optionTable TTk_OptionTable var tkwin TTk_Window _, _, _ = mbPtr, optionTable, tkwin if objc < int32(2) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(1), objv, __ccgo_ts+20960) return int32(TCL_ERROR) } /* * Create the new window. */ tkwin = XTk_CreateWindowFromPath(tls, interp, XTk_MainWindow(tls, interp), libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8)), libc.UintptrFromInt32(0)), libc.UintptrFromInt32(0)) if tkwin == libc.UintptrFromInt32(0) { return int32(TCL_ERROR) } /* * Create the option table for this widget class. If it has already been * created, the cached pointer will be returned. */ optionTable = XTk_CreateOptionTable(tls, interp, uintptr(unsafe.Pointer(&_optionSpecs4))) XTk_SetClass(tls, tkwin, __ccgo_ts+24926) mbPtr = XTkpCreateMenuButton(tls, tkwin) XTk_SetClassProcs(tls, tkwin, uintptr(unsafe.Pointer(&_menubuttonClass)), mbPtr) /* * Initialize the data structure for the button. */ (*TTkMenuButton)(unsafe.Pointer(mbPtr)).Ftkwin = tkwin (*TTkMenuButton)(unsafe.Pointer(mbPtr)).Fdisplay = (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fdisplay (*TTkMenuButton)(unsafe.Pointer(mbPtr)).Finterp = interp (*TTkMenuButton)(unsafe.Pointer(mbPtr)).FwidgetCmd = libtcl9_0.XTcl_CreateObjCommand(tls, interp, (*TTk_FakeWin)(unsafe.Pointer((*TTkMenuButton)(unsafe.Pointer(mbPtr)).Ftkwin)).FpathName, __ccgo_fp(_MenuButtonWidgetObjCmd), mbPtr, __ccgo_fp(_MenuButtonCmdDeletedProc)) (*TTkMenuButton)(unsafe.Pointer(mbPtr)).FoptionTable = optionTable (*TTkMenuButton)(unsafe.Pointer(mbPtr)).FmenuNameObj = libc.UintptrFromInt32(0) (*TTkMenuButton)(unsafe.Pointer(mbPtr)).FtextObj = libc.UintptrFromInt32(0) (*TTkMenuButton)(unsafe.Pointer(mbPtr)).Funderline = -libc.Int32FromInt32(1) - libc.Int32FromInt32(0x7fffffff) (*TTkMenuButton)(unsafe.Pointer(mbPtr)).FtextVarNameObj = libc.UintptrFromInt32(0) (*TTkMenuButton)(unsafe.Pointer(mbPtr)).Fbitmap = uint64(0) (*TTkMenuButton)(unsafe.Pointer(mbPtr)).FimageObj = libc.UintptrFromInt32(0) (*TTkMenuButton)(unsafe.Pointer(mbPtr)).Fimage = libc.UintptrFromInt32(0) (*TTkMenuButton)(unsafe.Pointer(mbPtr)).Fstate = int32(STATE_NORMAL2) (*TTkMenuButton)(unsafe.Pointer(mbPtr)).FnormalBorder = libc.UintptrFromInt32(0) (*TTkMenuButton)(unsafe.Pointer(mbPtr)).FactiveBorder = libc.UintptrFromInt32(0) (*TTkMenuButton)(unsafe.Pointer(mbPtr)).FborderWidthObj = libc.UintptrFromInt32(0) (*TTkMenuButton)(unsafe.Pointer(mbPtr)).Frelief = TK_RELIEF_FLAT (*TTkMenuButton)(unsafe.Pointer(mbPtr)).FhighlightWidthObj = uintptr(0) (*TTkMenuButton)(unsafe.Pointer(mbPtr)).FhighlightBgColorPtr = libc.UintptrFromInt32(0) (*TTkMenuButton)(unsafe.Pointer(mbPtr)).FhighlightColorPtr = libc.UintptrFromInt32(0) (*TTkMenuButton)(unsafe.Pointer(mbPtr)).Finset = 0 (*TTkMenuButton)(unsafe.Pointer(mbPtr)).Ftkfont = libc.UintptrFromInt32(0) (*TTkMenuButton)(unsafe.Pointer(mbPtr)).FnormalFg = libc.UintptrFromInt32(0) (*TTkMenuButton)(unsafe.Pointer(mbPtr)).FactiveFg = libc.UintptrFromInt32(0) (*TTkMenuButton)(unsafe.Pointer(mbPtr)).FdisabledFg = libc.UintptrFromInt32(0) (*TTkMenuButton)(unsafe.Pointer(mbPtr)).FnormalTextGC = libc.UintptrFromInt32(0) (*TTkMenuButton)(unsafe.Pointer(mbPtr)).FactiveTextGC = libc.UintptrFromInt32(0) (*TTkMenuButton)(unsafe.Pointer(mbPtr)).Fgray = uint64(0) (*TTkMenuButton)(unsafe.Pointer(mbPtr)).FdisabledGC = libc.UintptrFromInt32(0) (*TTkMenuButton)(unsafe.Pointer(mbPtr)).FstippleGC = libc.UintptrFromInt32(0) (*TTkMenuButton)(unsafe.Pointer(mbPtr)).FleftBearing = 0 (*TTkMenuButton)(unsafe.Pointer(mbPtr)).FrightBearing = 0 (*TTkMenuButton)(unsafe.Pointer(mbPtr)).FwidthObj = libc.UintptrFromInt32(0) (*TTkMenuButton)(unsafe.Pointer(mbPtr)).FheightObj = libc.UintptrFromInt32(0) (*TTkMenuButton)(unsafe.Pointer(mbPtr)).Fwidth = 0 (*TTkMenuButton)(unsafe.Pointer(mbPtr)).Fheight = 0 (*TTkMenuButton)(unsafe.Pointer(mbPtr)).FwrapLengthObj = uintptr(0) (*TTkMenuButton)(unsafe.Pointer(mbPtr)).FpadXObj = libc.UintptrFromInt32(0) (*TTkMenuButton)(unsafe.Pointer(mbPtr)).FpadYObj = libc.UintptrFromInt32(0) (*TTkMenuButton)(unsafe.Pointer(mbPtr)).Fanchor = int32(TK_ANCHOR_CENTER) (*TTkMenuButton)(unsafe.Pointer(mbPtr)).Fjustify = int32(TK_JUSTIFY_CENTER) (*TTkMenuButton)(unsafe.Pointer(mbPtr)).FtextLayout = libc.UintptrFromInt32(0) (*TTkMenuButton)(unsafe.Pointer(mbPtr)).FindicatorOn = 0 (*TTkMenuButton)(unsafe.Pointer(mbPtr)).FindicatorWidth = 0 (*TTkMenuButton)(unsafe.Pointer(mbPtr)).FindicatorHeight = 0 (*TTkMenuButton)(unsafe.Pointer(mbPtr)).Fdirection = int32(DIRECTION_FLUSH) (*TTkMenuButton)(unsafe.Pointer(mbPtr)).Fcursor = libc.UintptrFromInt32(0) (*TTkMenuButton)(unsafe.Pointer(mbPtr)).FtakeFocusObj = libc.UintptrFromInt32(0) (*TTkMenuButton)(unsafe.Pointer(mbPtr)).Fflags = 0 (*TTkMenuButton)(unsafe.Pointer(mbPtr)).FborderWidthObj = libc.UintptrFromInt32(0) (*TTkMenuButton)(unsafe.Pointer(mbPtr)).FhighlightWidthObj = libc.UintptrFromInt32(0) (*TTkMenuButton)(unsafe.Pointer(mbPtr)).FpadXObj = libc.UintptrFromInt32(0) (*TTkMenuButton)(unsafe.Pointer(mbPtr)).FpadYObj = libc.UintptrFromInt32(0) (*TTkMenuButton)(unsafe.Pointer(mbPtr)).FwrapLengthObj = libc.UintptrFromInt32(0) XTk_CreateEventHandler(tls, (*TTkMenuButton)(unsafe.Pointer(mbPtr)).Ftkwin, libc.Uint64FromInt64(libc.Int64FromInt64(1)< 0 { goto redraw } } } else { if (*TXEvent)(unsafe.Pointer(eventPtr)).Ftype1 == int32(FocusOut) { if (*(*TXFocusChangeEvent)(unsafe.Pointer(eventPtr))).Fdetail != int32(NotifyInferior) { *(*int32)(unsafe.Pointer(mbPtr + 360)) &= ^libc.Int32FromInt32(GOT_FOCUS4) XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), (*TTkMenuButton)(unsafe.Pointer(mbPtr)).Ftkwin, (*TTkMenuButton)(unsafe.Pointer(mbPtr)).FhighlightWidthObj, bp) if *(*int32)(unsafe.Pointer(bp)) > 0 { goto redraw } } } } } } } return goto redraw redraw: ; if (*TTkMenuButton)(unsafe.Pointer(mbPtr)).Ftkwin != libc.UintptrFromInt32(0) && !((*TTkMenuButton)(unsafe.Pointer(mbPtr)).Fflags&libc.Int32FromInt32(REDRAW_PENDING) != 0) { libtcl9_0.XTcl_DoWhenIdle(tls, __ccgo_fp(XTkpDisplayMenuButton), mbPtr) *(*int32)(unsafe.Pointer(mbPtr + 360)) |= int32(REDRAW_PENDING) } } /* *---------------------------------------------------------------------- * * MenuButtonCmdDeletedProc -- * * This function is invoked when a widget command is deleted. If the * widget isn't already in the process of being destroyed, this command * destroys it. * * Results: * None. * * Side effects: * The widget is destroyed. * *---------------------------------------------------------------------- */ func _MenuButtonCmdDeletedProc(tls *libc.TLS, clientData uintptr) { /* Pointer to widget record for widget. */ var mbPtr uintptr var tkwin TTk_Window _, _ = mbPtr, tkwin mbPtr = clientData tkwin = (*TTkMenuButton)(unsafe.Pointer(mbPtr)).Ftkwin /* * This function could be invoked either because the window was destroyed * and the command was then deleted (in which case tkwin is NULL) or * because the command was deleted, and then this function destroys the * widget. */ if tkwin != libc.UintptrFromInt32(0) { XTk_DestroyWindow(tls, tkwin) } } /* *-------------------------------------------------------------- * * MenuButtonTextVarProc -- * * This function is invoked when someone changes the variable whose * contents are to be displayed in a menu button. * * Results: * NULL is always returned. * * Side effects: * The text displayed in the menu button will change to match the * variable. * *-------------------------------------------------------------- */ func _MenuButtonTextVarProc(tls *libc.TLS, clientData uintptr, interp uintptr, dummy881 uintptr, dummy882 uintptr, flags int32) (r uintptr) { /* Information about what happened. */ var _objPtr, mbPtr, probe, value, v1, v3 uintptr var v2 TTcl_Size _, _, _, _, _, _, _ = _objPtr, mbPtr, probe, value, v1, v2, v3 mbPtr = clientData /* * If the variable is unset, then immediately recreate it unless the whole * interpreter is going away. */ if flags&int32(TCL_TRACE_UNSETS) != 0 { if !(libtcl9_0.XTcl_InterpDeleted(tls, interp) != 0) && (*TTkMenuButton)(unsafe.Pointer(mbPtr)).FtextVarNameObj != 0 { probe = libc.UintptrFromInt32(0) for cond := true; cond; cond = probe != 0 { probe = libtcl9_0.XTcl_VarTraceInfo2(tls, interp, libtcl9_0.XTcl_GetStringFromObj(tls, (*TTkMenuButton)(unsafe.Pointer(mbPtr)).FtextVarNameObj, libc.UintptrFromInt32(0)), libc.UintptrFromInt32(0), libc.Int32FromInt32(TCL_GLOBAL_ONLY)|libc.Int32FromInt32(TCL_TRACE_WRITES)|libc.Int32FromInt32(TCL_TRACE_UNSETS), __ccgo_fp(_MenuButtonTextVarProc), probe) if probe == mbPtr { break } } if probe != 0 { /* * We were able to fetch the unset trace for our * textVarName, which means it is not unset and not * the cause of this unset trace. Instead some outdated * former variable must be, and we should ignore it. */ return libc.UintptrFromInt32(0) } if (*TTkMenuButton)(unsafe.Pointer(mbPtr)).FtextObj != 0 { v1 = libtcl9_0.XTcl_GetStringFromObj(tls, (*TTkMenuButton)(unsafe.Pointer(mbPtr)).FtextObj, libc.UintptrFromInt32(0)) } else { v1 = __ccgo_ts + 195 } libtcl9_0.XTcl_SetVar2(tls, interp, libtcl9_0.XTcl_GetStringFromObj(tls, (*TTkMenuButton)(unsafe.Pointer(mbPtr)).FtextVarNameObj, libc.UintptrFromInt32(0)), libc.UintptrFromInt32(0), v1, int32(TCL_GLOBAL_ONLY)) libtcl9_0.XTcl_TraceVar2(tls, interp, libtcl9_0.XTcl_GetStringFromObj(tls, (*TTkMenuButton)(unsafe.Pointer(mbPtr)).FtextVarNameObj, libc.UintptrFromInt32(0)), libc.UintptrFromInt32(0), libc.Int32FromInt32(TCL_GLOBAL_ONLY)|libc.Int32FromInt32(TCL_TRACE_WRITES)|libc.Int32FromInt32(TCL_TRACE_UNSETS), __ccgo_fp(_MenuButtonTextVarProc), clientData) } return libc.UintptrFromInt32(0) } value = libtcl9_0.XTcl_GetVar2(tls, interp, libtcl9_0.XTcl_GetStringFromObj(tls, (*TTkMenuButton)(unsafe.Pointer(mbPtr)).FtextVarNameObj, libc.UintptrFromInt32(0)), libc.UintptrFromInt32(0), int32(TCL_GLOBAL_ONLY)) if value == libc.UintptrFromInt32(0) { value = __ccgo_ts + 195 } if (*TTkMenuButton)(unsafe.Pointer(mbPtr)).FtextObj != libc.UintptrFromInt32(0) { _objPtr = (*TTkMenuButton)(unsafe.Pointer(mbPtr)).FtextObj v3 = _objPtr v2 = *(*TTcl_Size)(unsafe.Pointer(v3)) *(*TTcl_Size)(unsafe.Pointer(v3))-- if v2 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr) } } (*TTkMenuButton)(unsafe.Pointer(mbPtr)).FtextObj = libtcl9_0.XTcl_NewStringObj(tls, value, int64(-libc.Int32FromInt32(1))) (*TTcl_Obj)(unsafe.Pointer((*TTkMenuButton)(unsafe.Pointer(mbPtr)).FtextObj)).FrefCount++ XTkpComputeMenuButtonGeometry(tls, mbPtr) if (*TTkMenuButton)(unsafe.Pointer(mbPtr)).Ftkwin != libc.UintptrFromInt32(0) && (*TTk_FakeWin)(unsafe.Pointer((*TTkMenuButton)(unsafe.Pointer(mbPtr)).Ftkwin)).Fflags&uint32(TK_MAPPED) != 0 && !((*TTkMenuButton)(unsafe.Pointer(mbPtr)).Fflags&libc.Int32FromInt32(REDRAW_PENDING) != 0) { libtcl9_0.XTcl_DoWhenIdle(tls, __ccgo_fp(XTkpDisplayMenuButton), mbPtr) *(*int32)(unsafe.Pointer(mbPtr + 360)) |= int32(REDRAW_PENDING) } return libc.UintptrFromInt32(0) } /* *---------------------------------------------------------------------- * * MenuButtonImageProc -- * * This function is invoked by the image code whenever the manager for an * image does something that affects the size of contents of an image * displayed in a button. * * Results: * None. * * Side effects: * Arranges for the button to get redisplayed. * *---------------------------------------------------------------------- */ func _MenuButtonImageProc(tls *libc.TLS, clientData uintptr, dummy964 int32, dummy965 int32, dummy966 int32, dummy967 int32, dummy968 int32, dummy969 int32) { /* imgHeight */ var mbPtr uintptr _ = mbPtr mbPtr = clientData if (*TTkMenuButton)(unsafe.Pointer(mbPtr)).Ftkwin != libc.UintptrFromInt32(0) { XTkpComputeMenuButtonGeometry(tls, mbPtr) if (*TTk_FakeWin)(unsafe.Pointer((*TTkMenuButton)(unsafe.Pointer(mbPtr)).Ftkwin)).Fflags&uint32(TK_MAPPED) != 0 && !((*TTkMenuButton)(unsafe.Pointer(mbPtr)).Fflags&libc.Int32FromInt32(REDRAW_PENDING) != 0) { libtcl9_0.XTcl_DoWhenIdle(tls, __ccgo_fp(XTkpDisplayMenuButton), mbPtr) *(*int32)(unsafe.Pointer(mbPtr + 360)) |= int32(REDRAW_PENDING) } } } /* *---------------------------------------------------------------------- * * TkMenuInitializeDrawingFields -- * * Fills in drawing fields of a new menu. Called when new menu is created * by MenuCmd. * * Results: * None. * * Side effects: * menuPtr fields are initialized. * *---------------------------------------------------------------------- */ func XTkMenuInitializeDrawingFields(tls *libc.TLS, menuPtr uintptr) { /* The menu we are initializing. */ var v1 int32 _ = v1 (*TTkMenu)(unsafe.Pointer(menuPtr)).FtextGC = libc.UintptrFromInt32(0) (*TTkMenu)(unsafe.Pointer(menuPtr)).Fgray = uint64(0) (*TTkMenu)(unsafe.Pointer(menuPtr)).FdisabledGC = libc.UintptrFromInt32(0) (*TTkMenu)(unsafe.Pointer(menuPtr)).FactiveGC = libc.UintptrFromInt32(0) (*TTkMenu)(unsafe.Pointer(menuPtr)).FindicatorGC = libc.UintptrFromInt32(0) (*TTkMenu)(unsafe.Pointer(menuPtr)).FdisabledImageGC = libc.UintptrFromInt32(0) v1 = libc.Int32FromInt32(0) (*TTkMenu)(unsafe.Pointer(menuPtr)).FtotalHeight = v1 (*TTkMenu)(unsafe.Pointer(menuPtr)).FtotalWidth = v1 } /* *---------------------------------------------------------------------- * * TkMenuInitializeEntryDrawingFields -- * * Fills in drawing fields of a new menu entry. Called when an entry is * created. * * Results: * None. * * Side effects: * None. * *---------------------------------------------------------------------- */ func XTkMenuInitializeEntryDrawingFields(tls *libc.TLS, mePtr uintptr) { /* The menu we are initializing. */ (*TTkMenuEntry)(unsafe.Pointer(mePtr)).Fwidth = 0 (*TTkMenuEntry)(unsafe.Pointer(mePtr)).Fheight = 0 (*TTkMenuEntry)(unsafe.Pointer(mePtr)).Fx = 0 (*TTkMenuEntry)(unsafe.Pointer(mePtr)).Fy = 0 (*TTkMenuEntry)(unsafe.Pointer(mePtr)).FindicatorSpace = 0 (*TTkMenuEntry)(unsafe.Pointer(mePtr)).FlabelWidth = 0 (*TTkMenuEntry)(unsafe.Pointer(mePtr)).FtextGC = libc.UintptrFromInt32(0) (*TTkMenuEntry)(unsafe.Pointer(mePtr)).FactiveGC = libc.UintptrFromInt32(0) (*TTkMenuEntry)(unsafe.Pointer(mePtr)).FdisabledGC = libc.UintptrFromInt32(0) (*TTkMenuEntry)(unsafe.Pointer(mePtr)).FindicatorGC = libc.UintptrFromInt32(0) } /* *---------------------------------------------------------------------- * * TkMenuFreeDrawOptions -- * * Frees up any structures allocated for the drawing of a menu. Called * when menu is deleted. * * Results: * None. * * Side effects: * Storage is released. * *---------------------------------------------------------------------- */ func XTkMenuFreeDrawOptions(tls *libc.TLS, menuPtr uintptr) { if (*TTkMenu)(unsafe.Pointer(menuPtr)).FtextGC != libc.UintptrFromInt32(0) { XTk_FreeGC(tls, (*TTkMenu)(unsafe.Pointer(menuPtr)).Fdisplay, (*TTkMenu)(unsafe.Pointer(menuPtr)).FtextGC) } if (*TTkMenu)(unsafe.Pointer(menuPtr)).FdisabledImageGC != libc.UintptrFromInt32(0) { XTk_FreeGC(tls, (*TTkMenu)(unsafe.Pointer(menuPtr)).Fdisplay, (*TTkMenu)(unsafe.Pointer(menuPtr)).FdisabledImageGC) } if (*TTkMenu)(unsafe.Pointer(menuPtr)).Fgray != uint64(0) { XTk_FreeBitmap(tls, (*TTkMenu)(unsafe.Pointer(menuPtr)).Fdisplay, (*TTkMenu)(unsafe.Pointer(menuPtr)).Fgray) } if (*TTkMenu)(unsafe.Pointer(menuPtr)).FdisabledGC != libc.UintptrFromInt32(0) { XTk_FreeGC(tls, (*TTkMenu)(unsafe.Pointer(menuPtr)).Fdisplay, (*TTkMenu)(unsafe.Pointer(menuPtr)).FdisabledGC) } if (*TTkMenu)(unsafe.Pointer(menuPtr)).FactiveGC != libc.UintptrFromInt32(0) { XTk_FreeGC(tls, (*TTkMenu)(unsafe.Pointer(menuPtr)).Fdisplay, (*TTkMenu)(unsafe.Pointer(menuPtr)).FactiveGC) } if (*TTkMenu)(unsafe.Pointer(menuPtr)).FindicatorGC != libc.UintptrFromInt32(0) { XTk_FreeGC(tls, (*TTkMenu)(unsafe.Pointer(menuPtr)).Fdisplay, (*TTkMenu)(unsafe.Pointer(menuPtr)).FindicatorGC) } } /* *---------------------------------------------------------------------- * * TkMenuEntryFreeDrawOptions -- * * Frees up drawing structures for a menu entry. Called when menu entry * is freed. * * RESULTS: * None. * * Side effects: * Storage is freed. * *---------------------------------------------------------------------- */ func XTkMenuEntryFreeDrawOptions(tls *libc.TLS, mePtr uintptr) { if (*TTkMenuEntry)(unsafe.Pointer(mePtr)).FtextGC != libc.UintptrFromInt32(0) { XTk_FreeGC(tls, (*TTkMenu1)(unsafe.Pointer((*TTkMenuEntry)(unsafe.Pointer(mePtr)).FmenuPtr)).Fdisplay, (*TTkMenuEntry)(unsafe.Pointer(mePtr)).FtextGC) } if (*TTkMenuEntry)(unsafe.Pointer(mePtr)).FdisabledGC != libc.UintptrFromInt32(0) { XTk_FreeGC(tls, (*TTkMenu1)(unsafe.Pointer((*TTkMenuEntry)(unsafe.Pointer(mePtr)).FmenuPtr)).Fdisplay, (*TTkMenuEntry)(unsafe.Pointer(mePtr)).FdisabledGC) } if (*TTkMenuEntry)(unsafe.Pointer(mePtr)).FactiveGC != libc.UintptrFromInt32(0) { XTk_FreeGC(tls, (*TTkMenu1)(unsafe.Pointer((*TTkMenuEntry)(unsafe.Pointer(mePtr)).FmenuPtr)).Fdisplay, (*TTkMenuEntry)(unsafe.Pointer(mePtr)).FactiveGC) } if (*TTkMenuEntry)(unsafe.Pointer(mePtr)).FindicatorGC != libc.UintptrFromInt32(0) { XTk_FreeGC(tls, (*TTkMenu1)(unsafe.Pointer((*TTkMenuEntry)(unsafe.Pointer(mePtr)).FmenuPtr)).Fdisplay, (*TTkMenuEntry)(unsafe.Pointer(mePtr)).FindicatorGC) } } /* *---------------------------------------------------------------------- * * TkMenuConfigureDrawOptions -- * * Sets the menu's drawing attributes in preparation for drawing the * menu. * * RESULTS: * None. * * Side effects: * Storage is allocated. * *---------------------------------------------------------------------- */ func XTkMenuConfigureDrawOptions(tls *libc.TLS, menuPtr uintptr) { bp := tls.Alloc(128) defer tls.Free(128) /* The menu we are configuring. */ var activeBorder, border TTk_3DBorder var activeFg, disabledFg, fg, indicatorFg uintptr var mask uint64 var newGC TGC var tkfont TTk_Font var _ /* gcValues at bp+0 */ TXGCValues _, _, _, _, _, _, _, _, _ = activeBorder, activeFg, border, disabledFg, fg, indicatorFg, mask, newGC, tkfont /* * A few options need special processing, such as setting the background * from a 3-D border, or filling in complicated defaults that couldn't be * specified to Tk_ConfigureWidget. */ border = XTk_Get3DBorderFromObj(tls, (*TTkMenu)(unsafe.Pointer(menuPtr)).Ftkwin, (*TTkMenu)(unsafe.Pointer(menuPtr)).FborderPtr) XTk_SetBackgroundFromBorder(tls, (*TTkMenu)(unsafe.Pointer(menuPtr)).Ftkwin, border) tkfont = XTk_GetFontFromObj(tls, (*TTkMenu)(unsafe.Pointer(menuPtr)).Ftkwin, (*TTkMenu)(unsafe.Pointer(menuPtr)).FfontPtr) (*(*TXGCValues)(unsafe.Pointer(bp))).Ffont = XTk_FontId(tls, tkfont) fg = XTk_GetColorFromObj(tls, (*TTkMenu)(unsafe.Pointer(menuPtr)).Ftkwin, (*TTkMenu)(unsafe.Pointer(menuPtr)).FfgPtr) (*(*TXGCValues)(unsafe.Pointer(bp))).Fforeground = (*TXColor)(unsafe.Pointer(fg)).Fpixel (*(*TXGCValues)(unsafe.Pointer(bp))).Fbackground = (*TXColor)(unsafe.Pointer(XTk_3DBorderColor(tls, border))).Fpixel newGC = XTk_GetGC(tls, (*TTkMenu)(unsafe.Pointer(menuPtr)).Ftkwin, libc.Uint64FromInt64(libc.Int64FromInt64(1)< 0 && (*TTkMenu)(unsafe.Pointer(menuPtr)).FmenuType != MENUBAR && (*TTkMenuEntry)(unsafe.Pointer(mePtr)).FcolumnBreak != 0 { /* * Paint the area under the last entry in a column. */ mePtr = *(*uintptr)(unsafe.Pointer((*TTkMenu)(unsafe.Pointer(menuPtr)).Fentries + uintptr(index-int64(1))*8)) XTk_Fill3DRectangle(tls, tkwin, (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fwindow, border, (*TTkMenuEntry)(unsafe.Pointer(mePtr)).Fx, (*TTkMenuEntry)(unsafe.Pointer(mePtr)).Fy+(*TTkMenuEntry)(unsafe.Pointer(mePtr)).Fheight, (*TTkMenuEntry)(unsafe.Pointer(mePtr)).Fwidth, (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fchanges.Fheight-(*TTkMenuEntry)(unsafe.Pointer(mePtr)).Fy-(*TTkMenuEntry)(unsafe.Pointer(mePtr)).Fheight-*(*int32)(unsafe.Pointer(bp + 12)), 0, TK_RELIEF_FLAT) } goto _1 _1: ; index++ } if (*TTkMenu)(unsafe.Pointer(menuPtr)).FmenuType != MENUBAR { if (*TTkMenu)(unsafe.Pointer(menuPtr)).FnumEntries == 0 { v2 = *(*int32)(unsafe.Pointer(bp + 12)) y = v2 x = v2 width = (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fchanges.Fwidth - int32(2)**(*int32)(unsafe.Pointer(bp + 12)) height = (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fchanges.Fheight - int32(2)**(*int32)(unsafe.Pointer(bp + 12)) } else { mePtr = *(*uintptr)(unsafe.Pointer((*TTkMenu)(unsafe.Pointer(menuPtr)).Fentries + uintptr((*TTkMenu)(unsafe.Pointer(menuPtr)).FnumEntries-int64(1))*8)) /* * Paint the area under the last entry of the menu. */ XTk_Fill3DRectangle(tls, tkwin, (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fwindow, border, (*TTkMenuEntry)(unsafe.Pointer(mePtr)).Fx, (*TTkMenuEntry)(unsafe.Pointer(mePtr)).Fy+(*TTkMenuEntry)(unsafe.Pointer(mePtr)).Fheight, (*TTkMenuEntry)(unsafe.Pointer(mePtr)).Fwidth, (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fchanges.Fheight-(*TTkMenuEntry)(unsafe.Pointer(mePtr)).Fy-(*TTkMenuEntry)(unsafe.Pointer(mePtr)).Fheight-*(*int32)(unsafe.Pointer(bp + 12)), 0, TK_RELIEF_FLAT) x = (*TTkMenuEntry)(unsafe.Pointer(mePtr)).Fx + (*TTkMenuEntry)(unsafe.Pointer(mePtr)).Fwidth y = (*TTkMenuEntry)(unsafe.Pointer(mePtr)).Fy + (*TTkMenuEntry)(unsafe.Pointer(mePtr)).Fheight width = (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fchanges.Fwidth - x - *(*int32)(unsafe.Pointer(bp + 12)) height = (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fchanges.Fheight - y - *(*int32)(unsafe.Pointer(bp + 12)) } /* * Paint the area at the bottom right of the last entry. * This has zero width except after menu resizing. */ XTk_Fill3DRectangle(tls, tkwin, (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fwindow, border, x, y, width, height, 0, TK_RELIEF_FLAT) } XTk_Draw3DRectangle(tls, (*TTkMenu)(unsafe.Pointer(menuPtr)).Ftkwin, (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fwindow, border, 0, 0, (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fchanges.Fwidth, (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fchanges.Fheight, *(*int32)(unsafe.Pointer(bp + 12)), (*TTkMenu)(unsafe.Pointer(menuPtr)).Frelief) } /* *-------------------------------------------------------------- * * TkMenuEventProc -- * * This function is invoked by the Tk dispatcher for various events on * menus. * * Results: * None. * * Side effects: * When the window gets deleted, internal structures get cleaned up. When * it gets exposed, it is redisplayed. * *-------------------------------------------------------------- */ func XTkMenuEventProc(tls *libc.TLS, clientData uintptr, eventPtr uintptr) { /* Information about event. */ var menuPtr uintptr _ = menuPtr menuPtr = clientData if (*TXEvent)(unsafe.Pointer(eventPtr)).Ftype1 == int32(Expose) && (*(*TXExposeEvent)(unsafe.Pointer(eventPtr))).Fcount == 0 { XTkEventuallyRedrawMenu(tls, menuPtr, libc.UintptrFromInt32(0)) } else { if (*TXEvent)(unsafe.Pointer(eventPtr)).Ftype1 == int32(ConfigureNotify) { XTkEventuallyRecomputeMenu(tls, menuPtr) XTkEventuallyRedrawMenu(tls, menuPtr, libc.UintptrFromInt32(0)) } else { if (*TXEvent)(unsafe.Pointer(eventPtr)).Ftype1 == libc.Int32FromInt32(MappingNotify)+libc.Int32FromInt32(2) { if (*TTkMenu)(unsafe.Pointer(menuPtr)).FmenuType == int32(TEAROFF_MENU) { XTk_SetMainMenubar(tls, (*TTkMenu)(unsafe.Pointer(menuPtr)).Finterp, (*TTkMenu)(unsafe.Pointer(menuPtr)).Ftkwin, libc.UintptrFromInt32(0)) } } else { if (*TXEvent)(unsafe.Pointer(eventPtr)).Ftype1 == int32(DestroyNotify) { if (*TTkMenu)(unsafe.Pointer(menuPtr)).Ftkwin != libc.UintptrFromInt32(0) { if !((*TTkMenu)(unsafe.Pointer(menuPtr)).FmenuFlags&libc.Int32FromInt32(MENU_DELETION_PENDING) != 0) { XTkDestroyMenu(tls, menuPtr) } (*TTkMenu)(unsafe.Pointer(menuPtr)).Ftkwin = libc.UintptrFromInt32(0) } if (*TTkMenu)(unsafe.Pointer(menuPtr)).FmenuFlags&int32(MENU_WIN_DESTRUCTION_PENDING) != 0 { return } *(*int32)(unsafe.Pointer(menuPtr + 260)) |= int32(MENU_WIN_DESTRUCTION_PENDING) if (*TTkMenu)(unsafe.Pointer(menuPtr)).FwidgetCmd != libc.UintptrFromInt32(0) { libtcl9_0.XTcl_DeleteCommandFromToken(tls, (*TTkMenu)(unsafe.Pointer(menuPtr)).Finterp, (*TTkMenu)(unsafe.Pointer(menuPtr)).FwidgetCmd) (*TTkMenu)(unsafe.Pointer(menuPtr)).FwidgetCmd = libc.UintptrFromInt32(0) } if (*TTkMenu)(unsafe.Pointer(menuPtr)).FmenuFlags&int32(REDRAW_PENDING) != 0 { libtcl9_0.XTcl_CancelIdleCall(tls, __ccgo_fp(_DisplayMenu), menuPtr) *(*int32)(unsafe.Pointer(menuPtr + 260)) &= ^libc.Int32FromInt32(REDRAW_PENDING) } if (*TTkMenu)(unsafe.Pointer(menuPtr)).FmenuFlags&int32(RESIZE_PENDING) != 0 { libtcl9_0.XTcl_CancelIdleCall(tls, __ccgo_fp(_ComputeMenuGeometry), menuPtr) *(*int32)(unsafe.Pointer(menuPtr + 260)) &= ^libc.Int32FromInt32(RESIZE_PENDING) } libtcl9_0.XTcl_EventuallyFree(tls, menuPtr, libc.UintptrFromInt32(3)) } } } } } /* *---------------------------------------------------------------------- * * TkMenuImageProc -- * * This function is invoked by the image code whenever the manager for an * image does something that affects the size of contents of an image * displayed in a menu entry. * * Results: * None. * * Side effects: * Arranges for the menu to get redisplayed. * *---------------------------------------------------------------------- */ func XTkMenuImageProc(tls *libc.TLS, clientData uintptr, dummy821 int32, dummy822 int32, dummy823 int32, dummy824 int32, dummy825 int32, dummy826 int32) { var menuPtr uintptr _ = menuPtr menuPtr = (*TTkMenuEntry)(unsafe.Pointer(clientData)).FmenuPtr if (*TTkMenu)(unsafe.Pointer(menuPtr)).Ftkwin != libc.UintptrFromInt32(0) && !((*TTkMenu)(unsafe.Pointer(menuPtr)).FmenuFlags&libc.Int32FromInt32(RESIZE_PENDING) != 0) { *(*int32)(unsafe.Pointer(menuPtr + 260)) |= int32(RESIZE_PENDING) libtcl9_0.XTcl_DoWhenIdle(tls, __ccgo_fp(_ComputeMenuGeometry), menuPtr) } } /* *---------------------------------------------------------------------- * * TkPostTearoffMenu -- * * Posts a tearoff menu on the screen. Adjusts the menu's position so * that it fits on the screen, and maps and raises the menu. * * Results: * Returns a standard Tcl Error. * * Side effects: * The menu is posted. * *---------------------------------------------------------------------- */ func XTkPostTearoffMenu(tls *libc.TLS, interp uintptr, menuPtr uintptr, x int32, y int32) (r int32) { /* The root X,Y coordinates where we are * posting */ return XTkpPostTearoffMenu(tls, interp, menuPtr, x, y, int64(-int32(1))) } /* *-------------------------------------------------------------- * * TkPostSubmenu -- * * This function arranges for a particular submenu (i.e. the menu * corresponding to a given cascade entry) to be posted. * * Results: * A standard Tcl return result. Errors may occur in the Tcl commands * generated to post and unpost submenus. * * Side effects: * If there is already a submenu posted, it is unposted. The new submenu * is then posted. * *-------------------------------------------------------------- */ func XTkPostSubmenu(tls *libc.TLS, interp uintptr, menuPtr uintptr, mePtr uintptr) (r int32) { bp := tls.Alloc(48) defer tls.Free(48) /* Info about submenu that is to be posted. * NULL means make sure that no submenu is * posted. */ var _objPtr, _objPtr1, _objPtr2, _objPtr3, v2, v4, v6, v8 uintptr var result int32 var v1, v3, v5, v7 TTcl_Size var _ /* subary at bp+8 */ [4]uintptr var _ /* x at bp+0 */ int32 var _ /* y at bp+4 */ int32 _, _, _, _, _, _, _, _, _, _, _, _, _ = _objPtr, _objPtr1, _objPtr2, _objPtr3, result, v1, v2, v3, v4, v5, v6, v7, v8 if mePtr == (*TTkMenu)(unsafe.Pointer(menuPtr)).FpostedCascade { return TCL_OK } if (*TTkMenu)(unsafe.Pointer(menuPtr)).FpostedCascade != libc.UintptrFromInt32(0) { /* * Note: when unposting a submenu, we have to redraw the entire parent * menu. This is because of a combination of the following things: * (a) the submenu partially overlaps the parent. * (b) the submenu specifies "save under", which causes the X server * to make a copy of the information under it when it is posted. * When the submenu is unposted, the X server copies this data * back and doesn't generate any Expose events for the parent. * (c) the parent may have redisplayed itself after the submenu was * posted, in which case the saved information is no longer * correct. * The simplest solution is just force a complete redisplay of the * parent. */ (*(*[4]uintptr)(unsafe.Pointer(bp + 8)))[0] = (*TTkMenuEntry)(unsafe.Pointer((*TTkMenu)(unsafe.Pointer(menuPtr)).FpostedCascade)).FnamePtr (*(*[4]uintptr)(unsafe.Pointer(bp + 8)))[int32(1)] = libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+24462, int64(-libc.Int32FromInt32(1))) (*TTcl_Obj)(unsafe.Pointer((*(*[4]uintptr)(unsafe.Pointer(bp + 8)))[int32(1)])).FrefCount++ XTkEventuallyRedrawMenu(tls, menuPtr, libc.UintptrFromInt32(0)) result = libtcl9_0.XTcl_EvalObjv(tls, interp, int64(2), bp+8, 0) _objPtr = (*(*[4]uintptr)(unsafe.Pointer(bp + 8)))[int32(1)] v2 = _objPtr v1 = *(*TTcl_Size)(unsafe.Pointer(v2)) *(*TTcl_Size)(unsafe.Pointer(v2))-- if v1 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr) } (*TTkMenu)(unsafe.Pointer(menuPtr)).FpostedCascade = libc.UintptrFromInt32(0) if result != TCL_OK { return result } } if mePtr != libc.UintptrFromInt32(0) && (*TTkMenuEntry)(unsafe.Pointer(mePtr)).FnamePtr != libc.UintptrFromInt32(0) && (*TTk_FakeWin)(unsafe.Pointer((*TTkMenu)(unsafe.Pointer(menuPtr)).Ftkwin)).Fflags&uint32(TK_MAPPED) != 0 { /* * Position the cascade with its upper left corner slightly below and * to the left of the upper right corner of the menu entry (this is an * attempt to match Motif behavior). * * The menu has to redrawn so that the entry can change relief. * * Set postedCascade early to ensure tear-off submenus work on * Windows. [Bug 873613] */ XTk_GetRootCoords(tls, (*TTkMenu)(unsafe.Pointer(menuPtr)).Ftkwin, bp, bp+4) _AdjustMenuCoords(tls, menuPtr, mePtr, bp, bp+4) (*TTkMenu)(unsafe.Pointer(menuPtr)).FpostedCascade = mePtr (*(*[4]uintptr)(unsafe.Pointer(bp + 8)))[0] = (*TTkMenuEntry)(unsafe.Pointer(mePtr)).FnamePtr (*(*[4]uintptr)(unsafe.Pointer(bp + 8)))[int32(1)] = libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+24445, int64(-libc.Int32FromInt32(1))) (*(*[4]uintptr)(unsafe.Pointer(bp + 8)))[int32(2)] = libtcl9_0.XTcl_NewWideIntObj(tls, int64(*(*int32)(unsafe.Pointer(bp)))) (*(*[4]uintptr)(unsafe.Pointer(bp + 8)))[int32(3)] = libtcl9_0.XTcl_NewWideIntObj(tls, int64(*(*int32)(unsafe.Pointer(bp + 4)))) (*TTcl_Obj)(unsafe.Pointer((*(*[4]uintptr)(unsafe.Pointer(bp + 8)))[int32(1)])).FrefCount++ (*TTcl_Obj)(unsafe.Pointer((*(*[4]uintptr)(unsafe.Pointer(bp + 8)))[int32(2)])).FrefCount++ (*TTcl_Obj)(unsafe.Pointer((*(*[4]uintptr)(unsafe.Pointer(bp + 8)))[int32(3)])).FrefCount++ result = libtcl9_0.XTcl_EvalObjv(tls, interp, int64(4), bp+8, 0) _objPtr1 = (*(*[4]uintptr)(unsafe.Pointer(bp + 8)))[int32(1)] v4 = _objPtr1 v3 = *(*TTcl_Size)(unsafe.Pointer(v4)) *(*TTcl_Size)(unsafe.Pointer(v4))-- if v3 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr1) } _objPtr2 = (*(*[4]uintptr)(unsafe.Pointer(bp + 8)))[int32(2)] v6 = _objPtr2 v5 = *(*TTcl_Size)(unsafe.Pointer(v6)) *(*TTcl_Size)(unsafe.Pointer(v6))-- if v5 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr2) } _objPtr3 = (*(*[4]uintptr)(unsafe.Pointer(bp + 8)))[int32(3)] v8 = _objPtr3 v7 = *(*TTcl_Size)(unsafe.Pointer(v8)) *(*TTcl_Size)(unsafe.Pointer(v8))-- if v7 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr3) } if result != TCL_OK { (*TTkMenu)(unsafe.Pointer(menuPtr)).FpostedCascade = libc.UintptrFromInt32(0) return result } XTkEventuallyRedrawMenu(tls, menuPtr, mePtr) } return TCL_OK } /* *---------------------------------------------------------------------- * * AdjustMenuCoords -- * * Adjusts the given coordinates down and the left to give a Motif look. * * Results: * None. * * Side effects: * The menu is eventually redrawn if necessary. * *---------------------------------------------------------------------- */ func _AdjustMenuCoords(tls *libc.TLS, menuPtr uintptr, mePtr uintptr, xPtr uintptr, yPtr uintptr) { bp := tls.Alloc(16) defer tls.Free(16) var _ /* activeBorderWidth at bp+4 */ int32 var _ /* borderWidth at bp+0 */ int32 if (*TTkMenu)(unsafe.Pointer(menuPtr)).FmenuType == MENUBAR { *(*int32)(unsafe.Pointer(xPtr)) += (*TTkMenuEntry)(unsafe.Pointer(mePtr)).Fx *(*int32)(unsafe.Pointer(yPtr)) += (*TTkMenuEntry)(unsafe.Pointer(mePtr)).Fy + (*TTkMenuEntry)(unsafe.Pointer(mePtr)).Fheight } else { XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), (*TTkMenu)(unsafe.Pointer(menuPtr)).Ftkwin, (*TTkMenu)(unsafe.Pointer(menuPtr)).FborderWidthObj, bp) XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), (*TTkMenu)(unsafe.Pointer(menuPtr)).Ftkwin, (*TTkMenu)(unsafe.Pointer(menuPtr)).FactiveBorderWidthPtr, bp+4) *(*int32)(unsafe.Pointer(xPtr)) += (*TTk_FakeWin)(unsafe.Pointer((*TTkMenu)(unsafe.Pointer(menuPtr)).Ftkwin)).Fchanges.Fwidth - *(*int32)(unsafe.Pointer(bp)) - *(*int32)(unsafe.Pointer(bp + 4)) - int32(2) *(*int32)(unsafe.Pointer(yPtr)) += (*TTkMenuEntry)(unsafe.Pointer(mePtr)).Fy + *(*int32)(unsafe.Pointer(bp + 4)) + int32(2) } } const MESSAGE_DELETED = 8 /* * Local Variables: * mode: c * c-basic-offset: 4 * fill-column: 78 * End: */ /* * default.h -- * * This file defines the defaults for all options for all of * the Tk widgets. * * Copyright © 1991-1994 The Regents of the University of California. * Copyright © 1994 Sun Microsystems, Inc. * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. */ /* * tkUnixDefault.h -- * * This file defines the defaults for all options for all of * the Tk widgets. * * Copyright © 1991-1994 The Regents of the University of California. * Copyright © 1994-1997 Sun Microsystems, Inc. * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. */ /* * The definitions below provide symbolic names for the default colors. * NORMAL_BG - Normal background color. * ACTIVE_BG - Background color when widget is active. * SELECT_BG - Background color for selected text. * TROUGH - Background color for troughs in scales and scrollbars. * INDICATOR - Color for indicator when button is selected. * DISABLED - Foreground color when widget is disabled. * PLACEHOLDER_FG - Foreground color for placeholder text. */ /* * Defaults for labels, buttons, checkbuttons, and radiobuttons: */ /* * Defaults for canvases: */ /* * Defaults for entries: */ /* * Defaults for frames: */ /* * Defaults for labelframes: */ /* * Defaults for listboxes: */ /* * Defaults for individual entries of menus: */ /* * Defaults for menus overall: */ /* * Defaults for menubuttons: */ /* * Defaults for messages: */ /* * Defaults for panedwindows */ /* * Defaults for panedwindow panes */ /* * Defaults for scales: */ /* * Defaults for scrollbars: */ /* * Defaults for texts: */ /* * Defaults for canvas text: */ /* * Defaults for canvas items * (arcs, bitmaps, lines, polygons, rectangles, and ovals): */ /* * Defaults for toplevels (most of the defaults for frames also apply * to toplevels): */ /* * Defaults for busy windows: */ /* * A data structure of the following type is kept for each message widget * managed by this file: */ type TMessage = struct { Ftkwin TTk_Window FoptionTable TTk_OptionTable Fdisplay uintptr Finterp uintptr FwidgetCmd TTcl_Command FstringObj uintptr FtextVarNameObj uintptr Fborder TTk_3DBorder FborderWidthObj uintptr Frelief int32 FhighlightWidthObj uintptr FhighlightBgColorPtr uintptr FhighlightColorPtr uintptr Ftkfont TTk_Font FfgColorPtr uintptr FpadXObj uintptr FpadYObj uintptr FwidthObj uintptr Faspect int32 FmsgWidth int32 FmsgHeight int32 Fanchor TTk_Anchor Fjustify TTk_Justify FtextGC TGC FtextLayout TTk_TextLayout Fcursor TTk_Cursor FtakeFocusObj uintptr Fflags int32 } /* * Flag bits for messages: * * REDRAW_PENDING: Non-zero means a DoWhenIdle handler * has already been queued to redraw * this window. * GOT_FOCUS: Non-zero means this button currently * has the input focus. * MESSAGE_DELETED: The message has been effectively deleted. */ /* * Information used for argv parsing. */ var _optionSpecs5 = [22]TTk_OptionSpec{ 0: { Ftype1: int32(TK_OPTION_ANCHOR), FoptionName: __ccgo_ts + 15168, FdbName: __ccgo_ts + 7881, FdbClass: __ccgo_ts + 19891, FdefValue: __ccgo_ts + 10959, FobjOffset: int64(-libc.Int32FromInt32(1)), FinternalOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 156)), }, 1: { Ftype1: int32(TK_OPTION_INT), FoptionName: __ccgo_ts + 24937, FdbName: __ccgo_ts + 24945, FdbClass: __ccgo_ts + 24952, FdefValue: __ccgo_ts + 24959, FobjOffset: int64(-libc.Int32FromInt32(1)), FinternalOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 144)), }, 2: { Ftype1: int32(TK_OPTION_BORDER), FoptionName: __ccgo_ts + 19898, FdbName: __ccgo_ts + 19910, FdbClass: __ccgo_ts + 19872, FdefValue: __ccgo_ts + 19921, FobjOffset: int64(-libc.Int32FromInt32(1)), FinternalOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 56)), FclientData: __ccgo_ts + 19883, }, 3: { Ftype1: int32(TK_OPTION_SYNONYM), FoptionName: __ccgo_ts + 19929, FinternalOffset: int64(-libc.Int32FromInt32(1)), FclientData: __ccgo_ts + 2814, }, 4: { Ftype1: int32(TK_OPTION_SYNONYM), FoptionName: __ccgo_ts + 19933, FinternalOffset: int64(-libc.Int32FromInt32(1)), FclientData: __ccgo_ts + 19898, }, 5: { Ftype1: int32(TK_OPTION_PIXELS), FoptionName: __ccgo_ts + 2814, FdbName: __ccgo_ts + 19952, FdbClass: __ccgo_ts + 19964, FdefValue: __ccgo_ts + 14538, FobjOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 64)), FinternalOffset: int64(-libc.Int32FromInt32(1)), }, 6: { Ftype1: int32(TK_OPTION_CURSOR), FoptionName: __ccgo_ts + 4638, FdbName: __ccgo_ts + 4646, FdbClass: __ccgo_ts + 4653, FdefValue: __ccgo_ts + 195, FobjOffset: int64(-libc.Int32FromInt32(1)), FinternalOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 184)), Fflags: int32(TCL_NULL_OK), }, 7: { Ftype1: int32(TK_OPTION_SYNONYM), FoptionName: __ccgo_ts + 20070, FinternalOffset: int64(-libc.Int32FromInt32(1)), FclientData: __ccgo_ts + 20085, }, 8: { Ftype1: int32(TK_OPTION_FONT), FoptionName: __ccgo_ts + 20097, FdbName: __ccgo_ts + 9358, FdbClass: __ccgo_ts + 20103, FdefValue: __ccgo_ts + 20108, FobjOffset: int64(-libc.Int32FromInt32(1)), FinternalOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 104)), }, 9: { Ftype1: int32(TK_OPTION_COLOR), FoptionName: __ccgo_ts + 20085, FdbName: __ccgo_ts + 20074, FdbClass: __ccgo_ts + 19810, FdefValue: __ccgo_ts + 19829, FobjOffset: int64(-libc.Int32FromInt32(1)), FinternalOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 112)), }, 10: { Ftype1: int32(TK_OPTION_COLOR), FoptionName: __ccgo_ts + 20129, FdbName: __ccgo_ts + 20150, FdbClass: __ccgo_ts + 20170, FdefValue: __ccgo_ts + 19921, FobjOffset: int64(-libc.Int32FromInt32(1)), FinternalOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 88)), }, 11: { Ftype1: int32(TK_OPTION_COLOR), FoptionName: __ccgo_ts + 20190, FdbName: __ccgo_ts + 20206, FdbClass: __ccgo_ts + 20221, FdefValue: __ccgo_ts + 19829, FobjOffset: int64(-libc.Int32FromInt32(1)), FinternalOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 96)), }, 12: { Ftype1: int32(TK_OPTION_PIXELS), FoptionName: __ccgo_ts + 20236, FdbName: __ccgo_ts + 20256, FdbClass: __ccgo_ts + 20275, FdefValue: __ccgo_ts + 10533, FobjOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 80)), FinternalOffset: int64(-libc.Int32FromInt32(1)), }, 13: { Ftype1: int32(TK_OPTION_JUSTIFY), FoptionName: __ccgo_ts + 20307, FdbName: __ccgo_ts + 20316, FdbClass: __ccgo_ts + 20324, FdefValue: __ccgo_ts + 10966, FobjOffset: int64(-libc.Int32FromInt32(1)), FinternalOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 160)), }, 14: { Ftype1: int32(TK_OPTION_PIXELS), FoptionName: __ccgo_ts + 12320, FdbName: __ccgo_ts + 20332, FdbClass: __ccgo_ts + 20337, FobjOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 120)), FinternalOffset: int64(-libc.Int32FromInt32(1)), Fflags: int32(TCL_NULL_OK), }, 15: { Ftype1: int32(TK_OPTION_PIXELS), FoptionName: __ccgo_ts + 12326, FdbName: __ccgo_ts + 20341, FdbClass: __ccgo_ts + 20337, FobjOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 128)), FinternalOffset: int64(-libc.Int32FromInt32(1)), Fflags: int32(TCL_NULL_OK), }, 16: { Ftype1: int32(TK_OPTION_RELIEF), FoptionName: __ccgo_ts + 20346, FdbName: __ccgo_ts + 82, FdbClass: __ccgo_ts + 20354, FdefValue: __ccgo_ts, FobjOffset: int64(-libc.Int32FromInt32(1)), FinternalOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 72)), }, 17: { Ftype1: int32(TK_OPTION_STRING), FoptionName: __ccgo_ts + 20367, FdbName: __ccgo_ts + 20378, FdbClass: __ccgo_ts + 20388, FdefValue: __ccgo_ts + 10533, FobjOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 192)), FinternalOffset: int64(-libc.Int32FromInt32(1)), Fflags: int32(TCL_NULL_OK), }, 18: { Ftype1: int32(TK_OPTION_STRING), FoptionName: __ccgo_ts + 20398, FdbName: __ccgo_ts + 17996, FdbClass: __ccgo_ts + 20404, FdefValue: __ccgo_ts + 195, FobjOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 40)), FinternalOffset: int64(-libc.Int32FromInt32(1)), }, 19: { Ftype1: int32(TK_OPTION_STRING), FoptionName: __ccgo_ts + 20409, FdbName: __ccgo_ts + 20423, FdbClass: __ccgo_ts + 20436, FdefValue: __ccgo_ts + 195, FobjOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 48)), FinternalOffset: int64(-libc.Int32FromInt32(1)), Fflags: int32(TCL_NULL_OK), }, 20: { Ftype1: int32(TK_OPTION_PIXELS), FoptionName: __ccgo_ts + 2987, FdbName: __ccgo_ts + 6446, FdbClass: __ccgo_ts + 20455, FdefValue: __ccgo_ts + 10533, FobjOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 136)), FinternalOffset: int64(-libc.Int32FromInt32(1)), }, 21: { Ftype1: int32(TK_OPTION_END), }, } /* * The structure below defines message class behavior by means of functions * that can be invoked from generic window code. */ var _messageClass = TTk_ClassProcs{ Fsize: int64(32), } func init() { p := unsafe.Pointer(&_messageClass) *(*uintptr)(unsafe.Add(p, 8)) = __ccgo_fp(_MessageWorldChanged) } /* *-------------------------------------------------------------- * * Tk_MessageObjCmd -- * * This function is invoked to process the "message" Tcl command. See the * user documentation for details on what it does. * * Results: * A standard Tcl result. * * Side effects: * See the user documentation. * *-------------------------------------------------------------- */ func XTk_MessageObjCmd(tls *libc.TLS, dummy212 uintptr, interp uintptr, objc int32, objv uintptr) (r int32) { /* Argument strings. */ var msgPtr uintptr var optionTable TTk_OptionTable var tkwin TTk_Window _, _, _ = msgPtr, optionTable, tkwin if objc < int32(2) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(1), objv, __ccgo_ts+20960) return int32(TCL_ERROR) } tkwin = XTk_CreateWindowFromPath(tls, interp, XTk_MainWindow(tls, interp), libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8)), libc.UintptrFromInt32(0)), libc.UintptrFromInt32(0)) if tkwin == libc.UintptrFromInt32(0) { return int32(TCL_ERROR) } /* * Create the option table for this widget class. If it has already been * created, the cached pointer will be returned. */ optionTable = XTk_CreateOptionTable(tls, interp, uintptr(unsafe.Pointer(&_optionSpecs5))) msgPtr = libtcl9_0.XTcl_Alloc(tls, uint64(208)) libc.Xmemset(tls, msgPtr, 0, uint64(208)) /* * Set values for those fields that don't take a 0 or NULL value. */ (*TMessage)(unsafe.Pointer(msgPtr)).Ftkwin = tkwin (*TMessage)(unsafe.Pointer(msgPtr)).Fdisplay = (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fdisplay (*TMessage)(unsafe.Pointer(msgPtr)).Finterp = interp (*TMessage)(unsafe.Pointer(msgPtr)).FwidgetCmd = libtcl9_0.XTcl_CreateObjCommand(tls, interp, (*TTk_FakeWin)(unsafe.Pointer((*TMessage)(unsafe.Pointer(msgPtr)).Ftkwin)).FpathName, __ccgo_fp(_MessageWidgetObjCmd), msgPtr, __ccgo_fp(_MessageCmdDeletedProc)) (*TMessage)(unsafe.Pointer(msgPtr)).FoptionTable = optionTable (*TMessage)(unsafe.Pointer(msgPtr)).Frelief = TK_RELIEF_FLAT (*TMessage)(unsafe.Pointer(msgPtr)).FtextGC = libc.UintptrFromInt32(0) (*TMessage)(unsafe.Pointer(msgPtr)).Fanchor = int32(TK_ANCHOR_CENTER) (*TMessage)(unsafe.Pointer(msgPtr)).Faspect = int32(150) (*TMessage)(unsafe.Pointer(msgPtr)).Fjustify = int32(TK_JUSTIFY_LEFT) (*TMessage)(unsafe.Pointer(msgPtr)).Fcursor = libc.UintptrFromInt32(0) XTk_SetClass(tls, (*TMessage)(unsafe.Pointer(msgPtr)).Ftkwin, __ccgo_ts+24963) XTk_SetClassProcs(tls, (*TMessage)(unsafe.Pointer(msgPtr)).Ftkwin, uintptr(unsafe.Pointer(&_messageClass)), msgPtr) XTk_CreateEventHandler(tls, (*TMessage)(unsafe.Pointer(msgPtr)).Ftkwin, libc.Uint64FromInt64(libc.Int64FromInt64(1)< 0 { inc = 0 } else { *(*int32)(unsafe.Pointer(bp)) = (*TScreen)(unsafe.Pointer((*struct { Fext_data uintptr Fprivate1 uintptr Ffd int32 Fprivate2 int32 Fproto_major_version int32 Fproto_minor_version int32 Fvendor uintptr Fprivate3 TXID Fprivate4 TXID Fprivate5 TXID Fprivate6 int32 Fresource_alloc uintptr Fbyte_order int32 Fbitmap_unit int32 Fbitmap_pad int32 Fbitmap_bit_order int32 Fnformats int32 Fpixmap_format uintptr Fprivate8 int32 Frelease int32 Fprivate9 uintptr Fprivate10 uintptr Fqlen int32 Flast_request_read uint64 Frequest uint64 Fprivate11 TXPointer Fprivate12 TXPointer Fprivate13 TXPointer Fprivate14 TXPointer Fmax_request_size uint32 Fdb uintptr Fprivate15 uintptr Fdisplay_name uintptr Fdefault_screen int32 Fnscreens int32 Fscreens uintptr Fmotion_buffer uint64 Fprivate16 uint64 Fmin_keycode int32 Fmax_keycode int32 Fprivate17 TXPointer Fprivate18 TXPointer Fprivate19 int32 Fxdefaults uintptr })(unsafe.Pointer((*TTk_FakeWin)(unsafe.Pointer((*TMessage)(unsafe.Pointer(msgPtr)).Ftkwin)).Fdisplay)).Fscreens+uintptr((*TTk_FakeWin)(unsafe.Pointer((*TMessage)(unsafe.Pointer(msgPtr)).Ftkwin)).FscreenNum)*128)).Fwidth / int32(2) inc = *(*int32)(unsafe.Pointer(bp)) / int32(2) } numChars = libtcl9_0.XTcl_GetCharLength(tls, (*TMessage)(unsafe.Pointer(msgPtr)).FstringObj) for { (*TMessage)(unsafe.Pointer(msgPtr)).FtextLayout = XTk_ComputeTextLayout(tls, (*TMessage)(unsafe.Pointer(msgPtr)).Ftkfont, libtcl9_0.XTcl_GetStringFromObj(tls, (*TMessage)(unsafe.Pointer(msgPtr)).FstringObj, libc.UintptrFromInt32(0)), numChars, *(*int32)(unsafe.Pointer(bp)), (*TMessage)(unsafe.Pointer(msgPtr)).Fjustify, 0, bp+4, bp+8) maxWidth = *(*int32)(unsafe.Pointer(bp + 4)) + int32(2)*(inset+*(*int32)(unsafe.Pointer(bp + 20))) height = *(*int32)(unsafe.Pointer(bp + 8)) + int32(2)*(inset+*(*int32)(unsafe.Pointer(bp + 24))) if inc <= int32(2) { break } aspect = int32(100) * maxWidth / height if aspect < lowerBound { *(*int32)(unsafe.Pointer(bp)) += inc } else { if aspect > upperBound { *(*int32)(unsafe.Pointer(bp)) -= inc } else { break } } XTk_FreeTextLayout(tls, (*TMessage)(unsafe.Pointer(msgPtr)).FtextLayout) goto _1 _1: ; inc /= int32(2) } (*TMessage)(unsafe.Pointer(msgPtr)).FmsgWidth = *(*int32)(unsafe.Pointer(bp + 4)) (*TMessage)(unsafe.Pointer(msgPtr)).FmsgHeight = *(*int32)(unsafe.Pointer(bp + 8)) XTk_GeometryRequest(tls, (*TMessage)(unsafe.Pointer(msgPtr)).Ftkwin, maxWidth, height) XTk_SetInternalBorder(tls, (*TMessage)(unsafe.Pointer(msgPtr)).Ftkwin, inset) } /* *-------------------------------------------------------------- * * DisplayMessage -- * * This function redraws the contents of a message window. * * Results: * None. * * Side effects: * Information appears on the screen. * *-------------------------------------------------------------- */ func _DisplayMessage(tls *libc.TLS, clientData uintptr) { bp := tls.Alloc(48) defer tls.Free(48) /* Information about window. */ var bgGC, fgGC TGC var msgPtr uintptr var tkwin TTk_Window var width int32 var _ /* borderWidth at bp+8 */ int32 var _ /* fm at bp+24 */ TTk_FontMetrics var _ /* highlightWidth at bp+12 */ int32 var _ /* padX at bp+16 */ int32 var _ /* padY at bp+20 */ int32 var _ /* x at bp+0 */ int32 var _ /* y at bp+4 */ int32 _, _, _, _, _ = bgGC, fgGC, msgPtr, tkwin, width msgPtr = clientData tkwin = (*TMessage)(unsafe.Pointer(msgPtr)).Ftkwin XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), (*TMessage)(unsafe.Pointer(msgPtr)).Ftkwin, (*TMessage)(unsafe.Pointer(msgPtr)).FborderWidthObj, bp+8) XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), (*TMessage)(unsafe.Pointer(msgPtr)).Ftkwin, (*TMessage)(unsafe.Pointer(msgPtr)).FhighlightWidthObj, bp+12) XTk_GetFontMetrics(tls, (*TMessage)(unsafe.Pointer(msgPtr)).Ftkfont, bp+24) if (*TMessage)(unsafe.Pointer(msgPtr)).FpadXObj != 0 { XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), (*TMessage)(unsafe.Pointer(msgPtr)).Ftkwin, (*TMessage)(unsafe.Pointer(msgPtr)).FpadXObj, bp+16) } else { *(*int32)(unsafe.Pointer(bp + 16)) = (*(*TTk_FontMetrics)(unsafe.Pointer(bp + 24))).Fascent / int32(2) } if (*TMessage)(unsafe.Pointer(msgPtr)).FpadYObj != 0 { XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), (*TMessage)(unsafe.Pointer(msgPtr)).Ftkwin, (*TMessage)(unsafe.Pointer(msgPtr)).FpadYObj, bp+20) } else { *(*int32)(unsafe.Pointer(bp + 20)) = (*(*TTk_FontMetrics)(unsafe.Pointer(bp + 24))).Fascent / int32(4) } width = *(*int32)(unsafe.Pointer(bp + 12)) *(*int32)(unsafe.Pointer(msgPtr + 200)) &= ^libc.Int32FromInt32(REDRAW_PENDING) if (*TMessage)(unsafe.Pointer(msgPtr)).Ftkwin == libc.UintptrFromInt32(0) || !((*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fflags&libc.Uint32FromInt32(TK_MAPPED) != 0) { return } if (*TMessage)(unsafe.Pointer(msgPtr)).Fborder != libc.UintptrFromInt32(0) { width += *(*int32)(unsafe.Pointer(bp + 8)) } if (*TMessage)(unsafe.Pointer(msgPtr)).Frelief == TK_RELIEF_FLAT { width = *(*int32)(unsafe.Pointer(bp + 12)) } XTk_Fill3DRectangle(tls, tkwin, (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fwindow, (*TMessage)(unsafe.Pointer(msgPtr)).Fborder, width, width, (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fchanges.Fwidth-int32(2)*width, (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fchanges.Fheight-int32(2)*width, 0, TK_RELIEF_FLAT) /* * Compute starting y-location for message based on message size and * anchor option. */ XTkComputeAnchor(tls, (*TMessage)(unsafe.Pointer(msgPtr)).Fanchor, tkwin, *(*int32)(unsafe.Pointer(bp + 16)), *(*int32)(unsafe.Pointer(bp + 20)), (*TMessage)(unsafe.Pointer(msgPtr)).FmsgWidth, (*TMessage)(unsafe.Pointer(msgPtr)).FmsgHeight, bp, bp+4) XTk_DrawTextLayout(tls, (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fdisplay, (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fwindow, (*TMessage)(unsafe.Pointer(msgPtr)).FtextGC, (*TMessage)(unsafe.Pointer(msgPtr)).FtextLayout, *(*int32)(unsafe.Pointer(bp)), *(*int32)(unsafe.Pointer(bp + 4)), 0, int64(-int32(1))) if width > *(*int32)(unsafe.Pointer(bp + 12)) { XTk_Draw3DRectangle(tls, tkwin, (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fwindow, (*TMessage)(unsafe.Pointer(msgPtr)).Fborder, *(*int32)(unsafe.Pointer(bp + 12)), *(*int32)(unsafe.Pointer(bp + 12)), (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fchanges.Fwidth-int32(2)**(*int32)(unsafe.Pointer(bp + 12)), (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fchanges.Fheight-int32(2)**(*int32)(unsafe.Pointer(bp + 12)), *(*int32)(unsafe.Pointer(bp + 8)), (*TMessage)(unsafe.Pointer(msgPtr)).Frelief) } if *(*int32)(unsafe.Pointer(bp + 12)) > 0 { bgGC = XTk_GCForColor(tls, (*TMessage)(unsafe.Pointer(msgPtr)).FhighlightBgColorPtr, (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fwindow) if (*TMessage)(unsafe.Pointer(msgPtr)).Fflags&int32(GOT_FOCUS4) != 0 { fgGC = XTk_GCForColor(tls, (*TMessage)(unsafe.Pointer(msgPtr)).FhighlightColorPtr, (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fwindow) XTk_DrawHighlightBorder(tls, tkwin, fgGC, bgGC, *(*int32)(unsafe.Pointer(bp + 12)), (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fwindow) } else { XTk_DrawHighlightBorder(tls, tkwin, bgGC, bgGC, *(*int32)(unsafe.Pointer(bp + 12)), (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fwindow) } } } /* *-------------------------------------------------------------- * * MessageEventProc -- * * This function is invoked by the Tk dispatcher for various events on * messages. * * Results: * None. * * Side effects: * When the window gets deleted, internal structures get cleaned up. * When it gets exposed, it is redisplayed. * *-------------------------------------------------------------- */ func _MessageEventProc(tls *libc.TLS, clientData uintptr, eventPtr uintptr) { bp := tls.Alloc(16) defer tls.Free(16) /* Information about event. */ var msgPtr uintptr var _ /* highlightWidth at bp+0 */ int32 _ = msgPtr msgPtr = clientData if (*TXEvent)(unsafe.Pointer(eventPtr)).Ftype1 == int32(Expose) && (*(*TXExposeEvent)(unsafe.Pointer(eventPtr))).Fcount == 0 || (*TXEvent)(unsafe.Pointer(eventPtr)).Ftype1 == int32(ConfigureNotify) { goto redraw } else { if (*TXEvent)(unsafe.Pointer(eventPtr)).Ftype1 == int32(DestroyNotify) { _DestroyMessage(tls, clientData) } else { if (*TXEvent)(unsafe.Pointer(eventPtr)).Ftype1 == int32(FocusIn) { if (*(*TXFocusChangeEvent)(unsafe.Pointer(eventPtr))).Fdetail != int32(NotifyInferior) { *(*int32)(unsafe.Pointer(msgPtr + 200)) |= int32(GOT_FOCUS4) XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), (*TMessage)(unsafe.Pointer(msgPtr)).Ftkwin, (*TMessage)(unsafe.Pointer(msgPtr)).FhighlightWidthObj, bp) if *(*int32)(unsafe.Pointer(bp)) > 0 { goto redraw } } } else { if (*TXEvent)(unsafe.Pointer(eventPtr)).Ftype1 == int32(FocusOut) { if (*(*TXFocusChangeEvent)(unsafe.Pointer(eventPtr))).Fdetail != int32(NotifyInferior) { *(*int32)(unsafe.Pointer(msgPtr + 200)) &= ^libc.Int32FromInt32(GOT_FOCUS4) XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), (*TMessage)(unsafe.Pointer(msgPtr)).Ftkwin, (*TMessage)(unsafe.Pointer(msgPtr)).FhighlightWidthObj, bp) if *(*int32)(unsafe.Pointer(bp)) > 0 { goto redraw } } } } } } return goto redraw redraw: ; if (*TMessage)(unsafe.Pointer(msgPtr)).Ftkwin != libc.UintptrFromInt32(0) && !((*TMessage)(unsafe.Pointer(msgPtr)).Fflags&libc.Int32FromInt32(REDRAW_PENDING) != 0) { libtcl9_0.XTcl_DoWhenIdle(tls, __ccgo_fp(_DisplayMessage), msgPtr) *(*int32)(unsafe.Pointer(msgPtr + 200)) |= int32(REDRAW_PENDING) } } /* *---------------------------------------------------------------------- * * MessageCmdDeletedProc -- * * This function is invoked when a widget command is deleted. If the * widget isn't already in the process of being destroyed, this command * destroys it. * * Results: * None. * * Side effects: * The widget is destroyed. * *---------------------------------------------------------------------- */ func _MessageCmdDeletedProc(tls *libc.TLS, clientData uintptr) { /* Pointer to widget record for widget. */ var msgPtr uintptr _ = msgPtr msgPtr = clientData /* * This function could be invoked either because the window was destroyed * and the command was then deleted (in which case tkwin is NULL) or * because the command was deleted, and then this function destroys the * widget. */ if !((*TMessage)(unsafe.Pointer(msgPtr)).Fflags&libc.Int32FromInt32(MESSAGE_DELETED) != 0) { XTk_DestroyWindow(tls, (*TMessage)(unsafe.Pointer(msgPtr)).Ftkwin) } } /* *-------------------------------------------------------------- * * MessageTextVarProc -- * * This function is invoked when someone changes the variable whose * contents are to be displayed in a message. * * Results: * NULL is always returned. * * Side effects: * The text displayed in the message will change to match the variable. * *-------------------------------------------------------------- */ func _MessageTextVarProc(tls *libc.TLS, clientData uintptr, interp uintptr, dummy891 uintptr, dummy892 uintptr, flags int32) (r uintptr) { /* Information about what happened. */ var _objPtr, msgPtr, probe, value, v2 uintptr var v1 TTcl_Size _, _, _, _, _, _ = _objPtr, msgPtr, probe, value, v1, v2 msgPtr = clientData /* * If the variable is unset, then immediately recreate it unless the whole * interpreter is going away. */ if flags&int32(TCL_TRACE_UNSETS) != 0 { if !(libtcl9_0.XTcl_InterpDeleted(tls, interp) != 0) && (*TMessage)(unsafe.Pointer(msgPtr)).FtextVarNameObj != 0 { probe = libc.UintptrFromInt32(0) for cond := true; cond; cond = probe != 0 { probe = libtcl9_0.XTcl_VarTraceInfo2(tls, interp, libtcl9_0.XTcl_GetStringFromObj(tls, (*TMessage)(unsafe.Pointer(msgPtr)).FtextVarNameObj, libc.UintptrFromInt32(0)), libc.UintptrFromInt32(0), libc.Int32FromInt32(TCL_GLOBAL_ONLY)|libc.Int32FromInt32(TCL_TRACE_WRITES)|libc.Int32FromInt32(TCL_TRACE_UNSETS), __ccgo_fp(_MessageTextVarProc), probe) if probe == msgPtr { break } } if probe != 0 { /* * We were able to fetch the unset trace for our * textVarName, which means it is not unset and not * the cause of this unset trace. Instead some outdated * former variable must be, and we should ignore it. */ return libc.UintptrFromInt32(0) } libtcl9_0.XTcl_SetVar2(tls, interp, libtcl9_0.XTcl_GetStringFromObj(tls, (*TMessage)(unsafe.Pointer(msgPtr)).FtextVarNameObj, libc.UintptrFromInt32(0)), libc.UintptrFromInt32(0), libtcl9_0.XTcl_GetStringFromObj(tls, (*TMessage)(unsafe.Pointer(msgPtr)).FstringObj, libc.UintptrFromInt32(0)), int32(TCL_GLOBAL_ONLY)) libtcl9_0.XTcl_TraceVar2(tls, interp, libtcl9_0.XTcl_GetStringFromObj(tls, (*TMessage)(unsafe.Pointer(msgPtr)).FtextVarNameObj, libc.UintptrFromInt32(0)), libc.UintptrFromInt32(0), libc.Int32FromInt32(TCL_GLOBAL_ONLY)|libc.Int32FromInt32(TCL_TRACE_WRITES)|libc.Int32FromInt32(TCL_TRACE_UNSETS), __ccgo_fp(_MessageTextVarProc), clientData) } return libc.UintptrFromInt32(0) } value = libtcl9_0.XTcl_GetVar2(tls, interp, libtcl9_0.XTcl_GetStringFromObj(tls, (*TMessage)(unsafe.Pointer(msgPtr)).FtextVarNameObj, libc.UintptrFromInt32(0)), libc.UintptrFromInt32(0), int32(TCL_GLOBAL_ONLY)) if value == libc.UintptrFromInt32(0) { value = __ccgo_ts + 195 } if (*TMessage)(unsafe.Pointer(msgPtr)).FstringObj != libc.UintptrFromInt32(0) { _objPtr = (*TMessage)(unsafe.Pointer(msgPtr)).FstringObj v2 = _objPtr v1 = *(*TTcl_Size)(unsafe.Pointer(v2)) *(*TTcl_Size)(unsafe.Pointer(v2))-- if v1 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr) } } (*TMessage)(unsafe.Pointer(msgPtr)).FstringObj = libtcl9_0.XTcl_NewStringObj(tls, value, int64(-libc.Int32FromInt32(1))) (*TTcl_Obj)(unsafe.Pointer((*TMessage)(unsafe.Pointer(msgPtr)).FstringObj)).FrefCount++ _ComputeMessageGeometry(tls, msgPtr) if (*TMessage)(unsafe.Pointer(msgPtr)).Ftkwin != libc.UintptrFromInt32(0) && (*TTk_FakeWin)(unsafe.Pointer((*TMessage)(unsafe.Pointer(msgPtr)).Ftkwin)).Fflags&uint32(TK_MAPPED) != 0 && !((*TMessage)(unsafe.Pointer(msgPtr)).Fflags&libc.Int32FromInt32(REDRAW_PENDING) != 0) { libtcl9_0.XTcl_DoWhenIdle(tls, __ccgo_fp(_DisplayMessage), msgPtr) *(*int32)(unsafe.Pointer(msgPtr + 200)) |= int32(REDRAW_PENDING) } return libc.UintptrFromInt32(0) } const GEOMETRY = 1 const PROXY_REDRAW_PENDING = 16 const RECOMPUTE_GEOMETRY = 8 const REQUESTED_RELAYOUT1 = 4 const RESIZE_PENDING1 = 32 const WIDGET_DELETED = 2 /* * Local Variables: * mode: c * c-basic-offset: 4 * fill-column: 78 * End: */ /* * default.h -- * * This file defines the defaults for all options for all of * the Tk widgets. * * Copyright © 1991-1994 The Regents of the University of California. * Copyright © 1994 Sun Microsystems, Inc. * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. */ /* * tkUnixDefault.h -- * * This file defines the defaults for all options for all of * the Tk widgets. * * Copyright © 1991-1994 The Regents of the University of California. * Copyright © 1994-1997 Sun Microsystems, Inc. * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. */ /* * The definitions below provide symbolic names for the default colors. * NORMAL_BG - Normal background color. * ACTIVE_BG - Background color when widget is active. * SELECT_BG - Background color for selected text. * TROUGH - Background color for troughs in scales and scrollbars. * INDICATOR - Color for indicator when button is selected. * DISABLED - Foreground color when widget is disabled. * PLACEHOLDER_FG - Foreground color for placeholder text. */ /* * Defaults for labels, buttons, checkbuttons, and radiobuttons: */ /* * Defaults for canvases: */ /* * Defaults for entries: */ /* * Defaults for frames: */ /* * Defaults for labelframes: */ /* * Defaults for listboxes: */ /* * Defaults for individual entries of menus: */ /* * Defaults for menus overall: */ /* * Defaults for menubuttons: */ /* * Defaults for messages: */ /* * Defaults for panedwindows */ /* * Defaults for panedwindow panes */ /* * Defaults for scales: */ /* * Defaults for scrollbars: */ /* * Defaults for texts: */ /* * Defaults for canvas text: */ /* * Defaults for canvas items * (arcs, bitmaps, lines, polygons, rectangles, and ovals): */ /* * Defaults for toplevels (most of the defaults for frames also apply * to toplevels): */ /* * Defaults for busy windows: */ /* * Flag values for "sticky"ness. The 16 combinations subsume the packer's * notion of anchor and fill. * * STICK_NORTH This window sticks to the top of its cavity. * STICK_EAST This window sticks to the right edge of its cavity. * STICK_SOUTH This window sticks to the bottom of its cavity. * STICK_WEST This window sticks to the left edge of its cavity. */ /* * The following table defines the legal values for the -orient option. */ var _orientStrings = [3]uintptr{ 0: __ccgo_ts + 16826, 1: __ccgo_ts + 16837, 2: libc.UintptrFromInt32(0), } type orient = int32 const ORIENT_HORIZONTAL = 0 const ORIENT_VERTICAL = 1 /* * The following table defines the legal values for the -stretch option. */ var _stretchStrings = [6]uintptr{ 0: __ccgo_ts + 24971, 1: __ccgo_ts + 24978, 2: __ccgo_ts + 24701, 3: __ccgo_ts + 24984, 4: __ccgo_ts + 24991, 5: libc.UintptrFromInt32(0), } type stretch = int32 const STRETCH_ALWAYS = 0 const /* Always give extra space to this pane. */ STRETCH_FIRST = 1 const /* Give extra space to pane if it is first. */ STRETCH_LAST = 2 const /* Give extra space to pane if it is last. */ STRETCH_MIDDLE = 3 const /* Give extra space to pane only if it is * neither first nor last. */ STRETCH_NEVER = 4 /* * Codify the stretchiness rule in one place. */ type TOptionTables = struct { FpwOptions TTk_OptionTable FpaneOpts TTk_OptionTable } /* * One structure of the following type is kept for each window * managed by a paned window widget. */ type TPane = struct { Ftkwin TTk_Window FminSizeObj uintptr FpadXObj uintptr FpadYObj uintptr FwidthObj uintptr FheightObj uintptr Fsticky int32 Fx int32 Fy int32 FpaneWidth int32 FpaneHeight int32 Fsashx int32 Fsashy int32 Fmarkx int32 Fmarky int32 Fhandlex int32 Fhandley int32 Fstretch stretch Fhide int32 FcontainerPtr uintptr Fafter TTk_Window Fbefore TTk_Window Fwidth int32 Fheight int32 } /* * A data structure of the following type is kept for each paned window widget * managed by this file: */ type TPanedWindow = struct { Ftkwin TTk_Window Fproxywin TTk_Window Fdisplay uintptr Finterp uintptr FwidgetCmd TTcl_Command FoptionTable TTk_OptionTable FpaneOpts TTk_OptionTable Fbackground TTk_3DBorder FborderWidthObj uintptr Frelief int32 FwidthObj uintptr FheightObj uintptr Forient orient Fcursor TTk_Cursor FresizeOpaque int32 FsashRelief int32 FsashWidthObj uintptr FsashPadObj uintptr FshowHandle int32 FhandleSizeObj uintptr FhandlePadObj uintptr FsashCursor TTk_Cursor Fgc TGC Fproxyx int32 Fproxyy int32 FproxyBackground TTk_3DBorder FproxyBorderWidthObj uintptr FproxyRelief int32 Fpanes uintptr FnumPanes int32 FsizeofPanes int32 Fflags int32 } /* * Sashes are between panes only, so there is one less sash than panes */ var _panedWindowMgrType = TTk_GeomMgr{ Fname: __ccgo_ts + 17948, } func init() { p := unsafe.Pointer(&_panedWindowMgrType) *(*uintptr)(unsafe.Add(p, 8)) = __ccgo_fp(_PanedWindowReqProc) *(*uintptr)(unsafe.Add(p, 16)) = __ccgo_fp(_PanedWindowLostPaneProc) } /* * Information used for objv parsing. */ /* * The following structure contains pointers to functions used for processing * the custom "-sticky" option for panes. */ var _stickyOption = TTk_ObjCustomOption{ Fname: __ccgo_ts + 24997, } func init() { p := unsafe.Pointer(&_stickyOption) *(*uintptr)(unsafe.Add(p, 8)) = __ccgo_fp(_SetSticky) *(*uintptr)(unsafe.Add(p, 16)) = __ccgo_fp(_GetSticky) *(*uintptr)(unsafe.Add(p, 24)) = __ccgo_fp(_RestoreSticky) } var _optionSpecs6 = [21]TTk_OptionSpec{ 0: { Ftype1: int32(TK_OPTION_BORDER), FoptionName: __ccgo_ts + 19898, FdbName: __ccgo_ts + 19910, FdbClass: __ccgo_ts + 19872, FdefValue: __ccgo_ts + 19921, FobjOffset: int64(-libc.Int32FromInt32(1)), FinternalOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 56)), FclientData: __ccgo_ts + 19883, }, 1: { Ftype1: int32(TK_OPTION_SYNONYM), FoptionName: __ccgo_ts + 19929, FinternalOffset: int64(-libc.Int32FromInt32(1)), FclientData: __ccgo_ts + 2814, }, 2: { Ftype1: int32(TK_OPTION_SYNONYM), FoptionName: __ccgo_ts + 19933, FinternalOffset: int64(-libc.Int32FromInt32(1)), FclientData: __ccgo_ts + 19898, }, 3: { Ftype1: int32(TK_OPTION_PIXELS), FoptionName: __ccgo_ts + 2814, FdbName: __ccgo_ts + 19952, FdbClass: __ccgo_ts + 19964, FdefValue: __ccgo_ts + 14538, FobjOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 64)), FinternalOffset: int64(-libc.Int32FromInt32(1)), FtypeMask: int32(GEOMETRY), }, 4: { Ftype1: int32(TK_OPTION_CURSOR), FoptionName: __ccgo_ts + 4638, FdbName: __ccgo_ts + 4646, FdbClass: __ccgo_ts + 4653, FdefValue: __ccgo_ts + 195, FobjOffset: int64(-libc.Int32FromInt32(1)), FinternalOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 104)), Fflags: int32(TCL_NULL_OK), }, 5: { Ftype1: int32(TK_OPTION_PIXELS), FoptionName: __ccgo_ts + 25004, FdbName: __ccgo_ts + 25015, FdbClass: __ccgo_ts + 25025, FdefValue: __ccgo_ts + 25035, FobjOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 152)), FinternalOffset: int64(-libc.Int32FromInt32(1)), FtypeMask: int32(GEOMETRY), }, 6: { Ftype1: int32(TK_OPTION_PIXELS), FoptionName: __ccgo_ts + 25037, FdbName: __ccgo_ts + 25049, FdbClass: __ccgo_ts + 25060, FdefValue: __ccgo_ts + 25035, FobjOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 144)), FinternalOffset: int64(-libc.Int32FromInt32(1)), FtypeMask: int32(GEOMETRY), }, 7: { Ftype1: int32(TK_OPTION_PIXELS), FoptionName: __ccgo_ts + 2870, FdbName: __ccgo_ts + 6172, FdbClass: __ccgo_ts + 20122, FdefValue: __ccgo_ts + 195, FobjOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 88)), FinternalOffset: int64(-libc.Int32FromInt32(1)), Fflags: int32(TCL_NULL_OK), FtypeMask: int32(GEOMETRY), }, 8: { FoptionName: __ccgo_ts + 25071, FdbName: __ccgo_ts + 25085, FdbClass: __ccgo_ts + 25098, FdefValue: __ccgo_ts + 14538, FobjOffset: int64(-libc.Int32FromInt32(1)), FinternalOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 112)), }, 9: { Ftype1: int32(TK_OPTION_STRING_TABLE), FoptionName: __ccgo_ts + 25111, FdbName: __ccgo_ts + 25119, FdbClass: __ccgo_ts + 25126, FdefValue: __ccgo_ts + 16826, FobjOffset: int64(-libc.Int32FromInt32(1)), FinternalOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 96)), FclientData: uintptr(unsafe.Pointer(&_orientStrings)), FtypeMask: int32(GEOMETRY), }, 10: { Ftype1: int32(TK_OPTION_BORDER), FoptionName: __ccgo_ts + 25133, FdbName: __ccgo_ts + 25150, FdbClass: __ccgo_ts + 25166, FobjOffset: int64(-libc.Int32FromInt32(1)), FinternalOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 184)), Fflags: int32(TCL_NULL_OK), FclientData: __ccgo_ts + 19883, }, 11: { Ftype1: int32(TK_OPTION_PIXELS), FoptionName: __ccgo_ts + 25182, FdbName: __ccgo_ts + 25200, FdbClass: __ccgo_ts + 25217, FdefValue: __ccgo_ts + 21412, FobjOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 192)), FinternalOffset: int64(-libc.Int32FromInt32(1)), FtypeMask: int32(GEOMETRY), }, 12: { Ftype1: int32(TK_OPTION_RELIEF), FoptionName: __ccgo_ts + 25234, FdbName: __ccgo_ts + 25247, FdbClass: __ccgo_ts + 20354, FobjOffset: int64(-libc.Int32FromInt32(1)), FinternalOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 200)), Fflags: int32(TCL_NULL_OK), }, 13: { Ftype1: int32(TK_OPTION_RELIEF), FoptionName: __ccgo_ts + 20346, FdbName: __ccgo_ts + 82, FdbClass: __ccgo_ts + 20354, FdefValue: __ccgo_ts, FobjOffset: int64(-libc.Int32FromInt32(1)), FinternalOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 72)), }, 14: { Ftype1: int32(TK_OPTION_CURSOR), FoptionName: __ccgo_ts + 25259, FdbName: __ccgo_ts + 25271, FdbClass: __ccgo_ts + 4653, FdefValue: __ccgo_ts + 195, FobjOffset: int64(-libc.Int32FromInt32(1)), FinternalOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 160)), Fflags: int32(TCL_NULL_OK), }, 15: { Ftype1: int32(TK_OPTION_PIXELS), FoptionName: __ccgo_ts + 25282, FdbName: __ccgo_ts + 25291, FdbClass: __ccgo_ts + 25299, FdefValue: __ccgo_ts + 10533, FobjOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 128)), FinternalOffset: int64(-libc.Int32FromInt32(1)), FtypeMask: int32(GEOMETRY), }, 16: { Ftype1: int32(TK_OPTION_RELIEF), FoptionName: __ccgo_ts + 25307, FdbName: __ccgo_ts + 25319, FdbClass: __ccgo_ts + 20354, FdefValue: __ccgo_ts, FobjOffset: int64(-libc.Int32FromInt32(1)), FinternalOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 116)), }, 17: { Ftype1: int32(TK_OPTION_PIXELS), FoptionName: __ccgo_ts + 25330, FdbName: __ccgo_ts + 25341, FdbClass: __ccgo_ts + 20455, FdefValue: __ccgo_ts + 25351, FobjOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 120)), FinternalOffset: int64(-libc.Int32FromInt32(1)), FtypeMask: int32(GEOMETRY), }, 18: { FoptionName: __ccgo_ts + 25353, FdbName: __ccgo_ts + 25365, FdbClass: __ccgo_ts + 25376, FdefValue: __ccgo_ts + 10533, FobjOffset: int64(-libc.Int32FromInt32(1)), FinternalOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 136)), FtypeMask: int32(GEOMETRY), }, 19: { Ftype1: int32(TK_OPTION_PIXELS), FoptionName: __ccgo_ts + 2987, FdbName: __ccgo_ts + 6446, FdbClass: __ccgo_ts + 20455, FdefValue: __ccgo_ts + 195, FobjOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 80)), FinternalOffset: int64(-libc.Int32FromInt32(1)), Fflags: int32(TCL_NULL_OK), FtypeMask: int32(GEOMETRY), }, 20: { Ftype1: int32(TK_OPTION_END), }, } var _paneOptionSpecs = [11]TTk_OptionSpec{ 0: { Ftype1: int32(TK_OPTION_WINDOW), FoptionName: __ccgo_ts + 15201, FdefValue: __ccgo_ts + 195, FobjOffset: int64(-libc.Int32FromInt32(1)), FinternalOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 112)), Fflags: int32(TCL_NULL_OK), }, 1: { Ftype1: int32(TK_OPTION_WINDOW), FoptionName: __ccgo_ts + 15208, FdefValue: __ccgo_ts + 195, FobjOffset: int64(-libc.Int32FromInt32(1)), FinternalOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 120)), Fflags: int32(TCL_NULL_OK), }, 2: { Ftype1: int32(TK_OPTION_PIXELS), FoptionName: __ccgo_ts + 2870, FdefValue: __ccgo_ts + 195, FobjOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 40)), FinternalOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 132)), Fflags: int32(TCL_NULL_OK), }, 3: { FoptionName: __ccgo_ts + 25387, FdbName: __ccgo_ts + 8369, FdbClass: __ccgo_ts + 25393, FdefValue: __ccgo_ts + 10533, FobjOffset: int64(-libc.Int32FromInt32(1)), FinternalOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 96)), FtypeMask: int32(GEOMETRY), }, 4: { Ftype1: int32(TK_OPTION_PIXELS), FoptionName: __ccgo_ts + 12368, FdefValue: __ccgo_ts + 10533, FobjOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 8)), FinternalOffset: int64(-libc.Int32FromInt32(1)), }, 5: { Ftype1: int32(TK_OPTION_PIXELS), FoptionName: __ccgo_ts + 12320, FdefValue: __ccgo_ts + 10533, FobjOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 16)), FinternalOffset: int64(-libc.Int32FromInt32(1)), }, 6: { Ftype1: int32(TK_OPTION_PIXELS), FoptionName: __ccgo_ts + 12326, FdefValue: __ccgo_ts + 10533, FobjOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 24)), FinternalOffset: int64(-libc.Int32FromInt32(1)), }, 7: { Ftype1: int32(TK_OPTION_CUSTOM), FoptionName: __ccgo_ts + 12332, FdefValue: __ccgo_ts + 25398, FobjOffset: int64(-libc.Int32FromInt32(1)), FinternalOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 48)), FclientData: uintptr(unsafe.Pointer(&_stickyOption)), }, 8: { Ftype1: int32(TK_OPTION_STRING_TABLE), FoptionName: __ccgo_ts + 25403, FdbName: __ccgo_ts + 25412, FdbClass: __ccgo_ts + 25420, FdefValue: __ccgo_ts + 24701, FobjOffset: int64(-libc.Int32FromInt32(1)), FinternalOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 92)), FclientData: uintptr(unsafe.Pointer(&_stretchStrings)), }, 9: { Ftype1: int32(TK_OPTION_PIXELS), FoptionName: __ccgo_ts + 2987, FdefValue: __ccgo_ts + 195, FobjOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 32)), FinternalOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 128)), Fflags: int32(TCL_NULL_OK), }, 10: { Ftype1: int32(TK_OPTION_END), }, } /* *-------------------------------------------------------------- * * Tk_PanedWindowObjCmd -- * * This function is invoked to process the "panedwindow" Tcl command. It * creates a new "panedwindow" widget. * * Results: * A standard Tcl result. * * Side effects: * A new widget is created and configured. * *-------------------------------------------------------------- */ func XTk_PanedWindowObjCmd(tls *libc.TLS, dummy378 uintptr, interp uintptr, objc int32, objv uintptr) (r int32) { bp := tls.Alloc(112) defer tls.Free(112) /* Argument objects. */ var parent, tkwin TTk_Window var pwOpts, pwPtr uintptr var _ /* atts at bp+0 */ TXSetWindowAttributes _, _, _, _ = parent, pwOpts, pwPtr, tkwin if objc < int32(2) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(1), objv, __ccgo_ts+20960) return int32(TCL_ERROR) } tkwin = XTk_CreateWindowFromPath(tls, interp, XTk_MainWindow(tls, interp), libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8)), libc.UintptrFromInt32(0)), libc.UintptrFromInt32(0)) if tkwin == libc.UintptrFromInt32(0) { return int32(TCL_ERROR) } pwOpts = libtcl9_0.XTcl_GetAssocData(tls, interp, __ccgo_ts+25428, libc.UintptrFromInt32(0)) if pwOpts == libc.UintptrFromInt32(0) { /* * The first time this function is invoked, the option tables will be * NULL. We then create the option tables from the templates and store * a pointer to the tables as the command's clientData so we'll have * easy access to it in the future. */ pwOpts = libtcl9_0.XTcl_Alloc(tls, uint64(16)) /* * Set up an exit handler to free the optionTables struct. */ libtcl9_0.XTcl_SetAssocData(tls, interp, __ccgo_ts+25428, __ccgo_fp(_DestroyOptionTables), pwOpts) /* * Create the paned window option tables. */ (*TOptionTables)(unsafe.Pointer(pwOpts)).FpwOptions = XTk_CreateOptionTable(tls, interp, uintptr(unsafe.Pointer(&_optionSpecs6))) (*TOptionTables)(unsafe.Pointer(pwOpts)).FpaneOpts = XTk_CreateOptionTable(tls, interp, uintptr(unsafe.Pointer(&_paneOptionSpecs))) } XTk_SetClass(tls, tkwin, __ccgo_ts+25452) /* * Allocate and initialize the widget record. */ pwPtr = libtcl9_0.XTcl_Alloc(tls, uint64(232)) libc.Xmemset(tls, pwPtr, 0, libc.Uint64FromInt64(232)) (*TPanedWindow)(unsafe.Pointer(pwPtr)).Ftkwin = tkwin (*TPanedWindow)(unsafe.Pointer(pwPtr)).Fdisplay = (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fdisplay (*TPanedWindow)(unsafe.Pointer(pwPtr)).Finterp = interp (*TPanedWindow)(unsafe.Pointer(pwPtr)).FwidgetCmd = libtcl9_0.XTcl_CreateObjCommand(tls, interp, (*TTk_FakeWin)(unsafe.Pointer((*TPanedWindow)(unsafe.Pointer(pwPtr)).Ftkwin)).FpathName, __ccgo_fp(_PanedWindowWidgetObjCmd), pwPtr, __ccgo_fp(_PanedWindowCmdDeletedProc)) (*TPanedWindow)(unsafe.Pointer(pwPtr)).FoptionTable = (*TOptionTables)(unsafe.Pointer(pwOpts)).FpwOptions (*TPanedWindow)(unsafe.Pointer(pwPtr)).FpaneOpts = (*TOptionTables)(unsafe.Pointer(pwOpts)).FpaneOpts (*TPanedWindow)(unsafe.Pointer(pwPtr)).Frelief = int32(TK_RELIEF_RAISED) (*TPanedWindow)(unsafe.Pointer(pwPtr)).Fgc = libc.UintptrFromInt32(0) (*TPanedWindow)(unsafe.Pointer(pwPtr)).Fcursor = libc.UintptrFromInt32(0) (*TPanedWindow)(unsafe.Pointer(pwPtr)).FsashCursor = libc.UintptrFromInt32(0) /* * Keep a hold of the associated tkwin until we destroy the widget, * otherwise Tk might free it while we still need it. */ libtcl9_0.XTcl_Preserve(tls, (*TPanedWindow)(unsafe.Pointer(pwPtr)).Ftkwin) if XTk_InitOptions(tls, interp, pwPtr, (*TOptionTables)(unsafe.Pointer(pwOpts)).FpwOptions, tkwin) != TCL_OK { XTk_DestroyWindow(tls, (*TPanedWindow)(unsafe.Pointer(pwPtr)).Ftkwin) return int32(TCL_ERROR) } XTk_CreateEventHandler(tls, (*TPanedWindow)(unsafe.Pointer(pwPtr)).Ftkwin, libc.Uint64FromInt64(libc.Int64FromInt64(1)< 0 { (*TPane)(unsafe.Pointer(panePtr)).FpaneWidth = (*TPane)(unsafe.Pointer(panePtr)).Fwidth } else { (*TPane)(unsafe.Pointer(panePtr)).FpaneWidth = (*TTk_FakeWin)(unsafe.Pointer(tkwin)).FreqWidth + doubleBw } if (*TPane)(unsafe.Pointer(panePtr)).Fheight > 0 { (*TPane)(unsafe.Pointer(panePtr)).FpaneHeight = (*TPane)(unsafe.Pointer(panePtr)).Fheight } else { (*TPane)(unsafe.Pointer(panePtr)).FpaneHeight = (*TTk_FakeWin)(unsafe.Pointer(tkwin)).FreqHeight + doubleBw } XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), (*TPane)(unsafe.Pointer(panePtr)).Ftkwin, (*TPane)(unsafe.Pointer(panePtr)).FminSizeObj, bp+140) if *(*int32)(unsafe.Pointer(bp + 140)) < 0 { _objPtr1 = (*TPane)(unsafe.Pointer(panePtr)).FminSizeObj v12 = _objPtr1 v11 = *(*TTcl_Size)(unsafe.Pointer(v12)) *(*TTcl_Size)(unsafe.Pointer(v12))-- if v11 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr1) } (*TPane)(unsafe.Pointer(panePtr)).FminSizeObj = libtcl9_0.XTcl_NewWideIntObj(tls, int64(libc.Int32FromInt32(0))) (*TTcl_Obj)(unsafe.Pointer((*TPane)(unsafe.Pointer(panePtr)).FminSizeObj)).FrefCount++ } /* * Set up the geometry management callbacks for this pane. */ XTk_CreateEventHandler(tls, (*TPane)(unsafe.Pointer(panePtr)).Ftkwin, libc.Uint64FromInt64(libc.Int64FromInt64(1)<numPanes == 0 since in this case * pwPtr->panes is NULL, and the memcpy would have undefined behavior. */ if (*TPanedWindow)(unsafe.Pointer(pwPtr)).FnumPanes != 0 { libc.Xmemcpy(tls, newPanes, (*TPanedWindow)(unsafe.Pointer(pwPtr)).Fpanes, uint64(8)*libc.Uint64FromInt32((*TPanedWindow)(unsafe.Pointer(pwPtr)).FnumPanes)) } libc.Xmemcpy(tls, newPanes+uintptr((*TPanedWindow)(unsafe.Pointer(pwPtr)).FnumPanes)*8, inserts, uint64(8)*libc.Uint64FromInt32(numNewPanes)) } else { /* * If some of the existing panes were moved, the old panes array * will be partially populated, with some valid and some invalid * entries. Walk through it, copying valid entries to the new panes * array as we go; when we get to the insert location for the new * panes, copy the inserts array over, then finish off the old panes * array. */ i = 0 j = libc.Int32FromInt32(0) for { if !(i < index) { break } if *(*uintptr)(unsafe.Pointer((*TPanedWindow)(unsafe.Pointer(pwPtr)).Fpanes + uintptr(i)*8)) != libc.UintptrFromInt32(0) { *(*uintptr)(unsafe.Pointer(newPanes + uintptr(j)*8)) = *(*uintptr)(unsafe.Pointer((*TPanedWindow)(unsafe.Pointer(pwPtr)).Fpanes + uintptr(i)*8)) j++ } goto _14 _14: ; i++ } libc.Xmemcpy(tls, newPanes+uintptr(j)*8, inserts, uint64(8)*libc.Uint64FromInt32(insertIndex)) j += firstOptionArg - int32(2) i = index for { if !(i < (*TPanedWindow)(unsafe.Pointer(pwPtr)).FnumPanes) { break } if *(*uintptr)(unsafe.Pointer((*TPanedWindow)(unsafe.Pointer(pwPtr)).Fpanes + uintptr(i)*8)) != libc.UintptrFromInt32(0) { *(*uintptr)(unsafe.Pointer(newPanes + uintptr(j)*8)) = *(*uintptr)(unsafe.Pointer((*TPanedWindow)(unsafe.Pointer(pwPtr)).Fpanes + uintptr(i)*8)) j++ } goto _15 _15: ; i++ } } /* * Make the new panes array the paned window's pane array, and clean up. */ libtcl9_0.XTcl_Free(tls, (*TPanedWindow)(unsafe.Pointer(pwPtr)).Fpanes) libtcl9_0.XTcl_Free(tls, inserts) (*TPanedWindow)(unsafe.Pointer(pwPtr)).Fpanes = newPanes /* * Set the paned window's pane count to the new value. */ *(*int32)(unsafe.Pointer(pwPtr + 216)) += numNewPanes XTk_FreeConfigOptions(tls, bp, (*TPanedWindow)(unsafe.Pointer(pwPtr)).FpaneOpts, (*TPanedWindow)(unsafe.Pointer(pwPtr)).Ftkwin) _ComputeGeometry(tls, pwPtr) return TCL_OK } /* *---------------------------------------------------------------------- * * PanedWindowSashCommand -- * * Implementation of the panedwindow sash subcommand. See the user * documentation for details on what it does. * * Results: * Standard Tcl result. * * Side effects: * Depends on the arguments. * *---------------------------------------------------------------------- */ func _PanedWindowSashCommand(tls *libc.TLS, pwPtr uintptr, interp uintptr, objc int32, objv uintptr) (r int32) { bp := tls.Alloc(80) defer tls.Free(80) /* Argument objects. */ var diff int32 var panePtr uintptr var _ /* coords at bp+16 */ [2]uintptr var _ /* index at bp+0 */ int32 var _ /* sash at bp+4 */ int32 var _ /* x at bp+8 */ int32 var _ /* y at bp+12 */ int32 _, _ = diff, panePtr if objc < int32(3) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(2), objv, __ccgo_ts+4953) return int32(TCL_ERROR) } if libtcl9_0.XTcl_GetIndexFromObjStruct(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), uintptr(unsafe.Pointer(&_sashOptionStrings)), libc.Int64FromUint64(libc.Uint64FromInt64(8)), __ccgo_ts+2689, libc.Int32FromInt32(0)|libc.Int32FromUint64(libc.Uint64FromInt64(4)<= 0 && *(*int32)(unsafe.Pointer(bp + 4)) < (*TPanedWindow)(unsafe.Pointer(pwPtr)).FnumPanes-int32(1)) { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+25722, int64(-libc.Int32FromInt32(1)))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+40, __ccgo_ts+179, __ccgo_ts+182, __ccgo_ts+25741, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) } panePtr = *(*uintptr)(unsafe.Pointer((*TPanedWindow)(unsafe.Pointer(pwPtr)).Fpanes + uintptr(*(*int32)(unsafe.Pointer(bp + 4)))*8)) (*(*[2]uintptr)(unsafe.Pointer(bp + 16)))[0] = libtcl9_0.XTcl_NewWideIntObj(tls, int64((*TPane)(unsafe.Pointer(panePtr)).Fsashx)) (*(*[2]uintptr)(unsafe.Pointer(bp + 16)))[int32(1)] = libtcl9_0.XTcl_NewWideIntObj(tls, int64((*TPane)(unsafe.Pointer(panePtr)).Fsashy)) libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewListObj(tls, int64(2), bp+16)) case 2: if objc != int32(6) && objc != int32(4) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(3), objv, __ccgo_ts+25752) return int32(TCL_ERROR) } if libtcl9_0.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 3*8)), bp+4) != TCL_OK { return int32(TCL_ERROR) } if !(*(*int32)(unsafe.Pointer(bp + 4)) >= 0 && *(*int32)(unsafe.Pointer(bp + 4)) < (*TPanedWindow)(unsafe.Pointer(pwPtr)).FnumPanes-int32(1)) { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+25722, int64(-libc.Int32FromInt32(1)))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+40, __ccgo_ts+179, __ccgo_ts+182, __ccgo_ts+25741, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) } if objc == int32(6) { if libtcl9_0.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 4*8)), bp+8) != TCL_OK { return int32(TCL_ERROR) } if libtcl9_0.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 5*8)), bp+12) != TCL_OK { return int32(TCL_ERROR) } (*TPane)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer((*TPanedWindow)(unsafe.Pointer(pwPtr)).Fpanes + uintptr(*(*int32)(unsafe.Pointer(bp + 4)))*8)))).Fmarkx = *(*int32)(unsafe.Pointer(bp + 8)) (*TPane)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer((*TPanedWindow)(unsafe.Pointer(pwPtr)).Fpanes + uintptr(*(*int32)(unsafe.Pointer(bp + 4)))*8)))).Fmarky = *(*int32)(unsafe.Pointer(bp + 12)) } else { (*(*[2]uintptr)(unsafe.Pointer(bp + 16)))[0] = libtcl9_0.XTcl_NewWideIntObj(tls, int64((*TPane)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer((*TPanedWindow)(unsafe.Pointer(pwPtr)).Fpanes + uintptr(*(*int32)(unsafe.Pointer(bp + 4)))*8)))).Fmarkx)) (*(*[2]uintptr)(unsafe.Pointer(bp + 16)))[int32(1)] = libtcl9_0.XTcl_NewWideIntObj(tls, int64((*TPane)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer((*TPanedWindow)(unsafe.Pointer(pwPtr)).Fpanes + uintptr(*(*int32)(unsafe.Pointer(bp + 4)))*8)))).Fmarky)) libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewListObj(tls, int64(2), bp+16)) } case 1: fallthrough case 3: if objc != int32(6) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(3), objv, __ccgo_ts+25764) return int32(TCL_ERROR) } if libtcl9_0.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 3*8)), bp+4) != TCL_OK { return int32(TCL_ERROR) } if !(*(*int32)(unsafe.Pointer(bp + 4)) >= 0 && *(*int32)(unsafe.Pointer(bp + 4)) < (*TPanedWindow)(unsafe.Pointer(pwPtr)).FnumPanes-int32(1)) { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+25722, int64(-libc.Int32FromInt32(1)))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+40, __ccgo_ts+179, __ccgo_ts+182, __ccgo_ts+25741, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) } if libtcl9_0.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 4*8)), bp+8) != TCL_OK { return int32(TCL_ERROR) } if libtcl9_0.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 5*8)), bp+12) != TCL_OK { return int32(TCL_ERROR) } panePtr = *(*uintptr)(unsafe.Pointer((*TPanedWindow)(unsafe.Pointer(pwPtr)).Fpanes + uintptr(*(*int32)(unsafe.Pointer(bp + 4)))*8)) if (*TPanedWindow)(unsafe.Pointer(pwPtr)).Forient == int32(ORIENT_HORIZONTAL) { if *(*int32)(unsafe.Pointer(bp)) == 3 { diff = *(*int32)(unsafe.Pointer(bp + 8)) - (*TPane)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer((*TPanedWindow)(unsafe.Pointer(pwPtr)).Fpanes + uintptr(*(*int32)(unsafe.Pointer(bp + 4)))*8)))).Fsashx } else { diff = *(*int32)(unsafe.Pointer(bp + 8)) - (*TPane)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer((*TPanedWindow)(unsafe.Pointer(pwPtr)).Fpanes + uintptr(*(*int32)(unsafe.Pointer(bp + 4)))*8)))).Fmarkx } } else { if *(*int32)(unsafe.Pointer(bp)) == 3 { diff = *(*int32)(unsafe.Pointer(bp + 12)) - (*TPane)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer((*TPanedWindow)(unsafe.Pointer(pwPtr)).Fpanes + uintptr(*(*int32)(unsafe.Pointer(bp + 4)))*8)))).Fsashy } else { diff = *(*int32)(unsafe.Pointer(bp + 12)) - (*TPane)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer((*TPanedWindow)(unsafe.Pointer(pwPtr)).Fpanes + uintptr(*(*int32)(unsafe.Pointer(bp + 4)))*8)))).Fmarky } } _MoveSash(tls, pwPtr, *(*int32)(unsafe.Pointer(bp + 4)), diff) _ComputeGeometry(tls, pwPtr) } return TCL_OK } var _sashOptionStrings = [5]uintptr{ 0: __ccgo_ts + 25716, 1: __ccgo_ts + 22299, 2: __ccgo_ts + 2046, 3: __ccgo_ts + 15808, 4: libc.UintptrFromInt32(0), } /* *---------------------------------------------------------------------- * * ConfigurePanedWindow -- * * This function is called to process an argv/argc list in conjunction * with the Tk option database to configure (or reconfigure) a paned * window widget. * * Results: * The return value is a standard Tcl result. If TCL_ERROR is returned, * then the interp's result contains an error message. * * Side effects: * Configuration information, such as colors, border width, etc. get set * for pwPtr; old resources get freed, if there were any. * *---------------------------------------------------------------------- */ func _ConfigurePanedWindow(tls *libc.TLS, interp uintptr, pwPtr uintptr, objc int32, objv uintptr) (r int32) { bp := tls.Alloc(528) defer tls.Free(528) /* Argument values. */ var _ /* savedOptions at bp+0 */ TTk_SavedOptions var _ /* typemask at bp+512 */ int32 *(*int32)(unsafe.Pointer(bp + 512)) = 0 if XTk_SetOptions(tls, interp, pwPtr, (*TPanedWindow)(unsafe.Pointer(pwPtr)).FoptionTable, int64(objc), objv, (*TPanedWindow)(unsafe.Pointer(pwPtr)).Ftkwin, bp, bp+512) != TCL_OK { XTk_RestoreSavedOptions(tls, bp) return int32(TCL_ERROR) } XTk_FreeSavedOptions(tls, bp) _PanedWindowWorldChanged(tls, pwPtr) /* * If an option that affects geometry has changed, make a re-layout * request. */ if *(*int32)(unsafe.Pointer(bp + 512))&int32(GEOMETRY) != 0 { _ComputeGeometry(tls, pwPtr) } return TCL_OK } /* *---------------------------------------------------------------------- * * PanedWindowWorldChanged -- * * This function is invoked anytime a paned window's world has changed in * some way that causes the widget to have to recompute graphics contexts * and geometry. * * Results: * None. * * Side effects: * Paned window will be relayed out and redisplayed. * *---------------------------------------------------------------------- */ func _PanedWindowWorldChanged(tls *libc.TLS, instanceData uintptr) { bp := tls.Alloc(144) defer tls.Free(144) /* Information about the paned window. */ var newGC TGC var pwPtr uintptr var _ /* borderWidth at bp+128 */ int32 var _ /* gcValues at bp+0 */ TXGCValues var _ /* height at bp+136 */ int32 var _ /* width at bp+132 */ int32 _, _ = newGC, pwPtr pwPtr = instanceData *(*int32)(unsafe.Pointer(bp + 132)) = -int32(1) *(*int32)(unsafe.Pointer(bp + 136)) = -int32(1) /* * Allocated a graphics context for drawing the paned window widget * elements (background, sashes, etc.) and set the window background. */ (*(*TXGCValues)(unsafe.Pointer(bp))).Fbackground = (*TXColor)(unsafe.Pointer(XTk_3DBorderColor(tls, (*TPanedWindow)(unsafe.Pointer(pwPtr)).Fbackground))).Fpixel newGC = XTk_GetGC(tls, (*TPanedWindow)(unsafe.Pointer(pwPtr)).Ftkwin, libc.Uint64FromInt64(libc.Int64FromInt64(1)< 0 && *(*int32)(unsafe.Pointer(bp + 136)) > 0 { XTk_GeometryRequest(tls, (*TPanedWindow)(unsafe.Pointer(pwPtr)).Ftkwin, *(*int32)(unsafe.Pointer(bp + 132)), *(*int32)(unsafe.Pointer(bp + 136))) } /* * Arrange for the window to be redrawn, if neccessary. */ if (*TTk_FakeWin)(unsafe.Pointer((*TPanedWindow)(unsafe.Pointer(pwPtr)).Ftkwin)).Fflags&uint32(TK_MAPPED) != 0 && !((*TPanedWindow)(unsafe.Pointer(pwPtr)).Fflags&libc.Int32FromInt32(REDRAW_PENDING) != 0) { libtcl9_0.XTcl_DoWhenIdle(tls, __ccgo_fp(_DisplayPanedWindow), pwPtr) *(*int32)(unsafe.Pointer(pwPtr + 224)) |= int32(REDRAW_PENDING) } } /* *-------------------------------------------------------------- * * PanedWindowEventProc -- * * This function is invoked by the Tk dispatcher for various events on * paned windows. * * Results: * None. * * Side effects: * When the window gets deleted, internal structures get cleaned up. When * it gets exposed, it is redisplayed. * *-------------------------------------------------------------- */ func _PanedWindowEventProc(tls *libc.TLS, clientData uintptr, eventPtr uintptr) { /* Information about event. */ var i int32 var pwPtr uintptr _, _ = i, pwPtr pwPtr = clientData if (*TXEvent)(unsafe.Pointer(eventPtr)).Ftype1 == int32(Expose) { if (*TPanedWindow)(unsafe.Pointer(pwPtr)).Ftkwin != libc.UintptrFromInt32(0) && !((*TPanedWindow)(unsafe.Pointer(pwPtr)).Fflags&libc.Int32FromInt32(REDRAW_PENDING) != 0) { libtcl9_0.XTcl_DoWhenIdle(tls, __ccgo_fp(_DisplayPanedWindow), pwPtr) *(*int32)(unsafe.Pointer(pwPtr + 224)) |= int32(REDRAW_PENDING) } } else { if (*TXEvent)(unsafe.Pointer(eventPtr)).Ftype1 == int32(ConfigureNotify) { *(*int32)(unsafe.Pointer(pwPtr + 224)) |= int32(REQUESTED_RELAYOUT1) if (*TPanedWindow)(unsafe.Pointer(pwPtr)).Ftkwin != libc.UintptrFromInt32(0) && !((*TPanedWindow)(unsafe.Pointer(pwPtr)).Fflags&libc.Int32FromInt32(REDRAW_PENDING) != 0) { libtcl9_0.XTcl_DoWhenIdle(tls, __ccgo_fp(_DisplayPanedWindow), pwPtr) *(*int32)(unsafe.Pointer(pwPtr + 224)) |= int32(REDRAW_PENDING) } } else { if (*TXEvent)(unsafe.Pointer(eventPtr)).Ftype1 == int32(DestroyNotify) { _DestroyPanedWindow(tls, pwPtr) } else { if (*TXEvent)(unsafe.Pointer(eventPtr)).Ftype1 == int32(UnmapNotify) { i = 0 for { if !(i < (*TPanedWindow)(unsafe.Pointer(pwPtr)).FnumPanes) { break } if !((*TPane)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer((*TPanedWindow)(unsafe.Pointer(pwPtr)).Fpanes + uintptr(i)*8)))).Fhide != 0) { XTk_UnmapWindow(tls, (*TPane)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer((*TPanedWindow)(unsafe.Pointer(pwPtr)).Fpanes + uintptr(i)*8)))).Ftkwin) } goto _1 _1: ; i++ } } else { if (*TXEvent)(unsafe.Pointer(eventPtr)).Ftype1 == int32(MapNotify) { i = 0 for { if !(i < (*TPanedWindow)(unsafe.Pointer(pwPtr)).FnumPanes) { break } if !((*TPane)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer((*TPanedWindow)(unsafe.Pointer(pwPtr)).Fpanes + uintptr(i)*8)))).Fhide != 0) { XTk_MapWindow(tls, (*TPane)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer((*TPanedWindow)(unsafe.Pointer(pwPtr)).Fpanes + uintptr(i)*8)))).Ftkwin) } goto _2 _2: ; i++ } } } } } } } /* *---------------------------------------------------------------------- * * PanedWindowCmdDeletedProc -- * * This function is invoked when a widget command is deleted. If the * widget isn't already in the process of being destroyed, this command * destroys it. * * Results: * None. * * Side effects: * The widget is destroyed. * *---------------------------------------------------------------------- */ func _PanedWindowCmdDeletedProc(tls *libc.TLS, clientData uintptr) { /* Pointer to widget record for widget. */ var pwPtr uintptr _ = pwPtr pwPtr = clientData /* * This function could be invoked either because the window was destroyed * and the command was then deleted or because the command was deleted, * and then this function destroys the widget. The WIDGET_DELETED flag * distinguishes these cases. */ if !((*TPanedWindow)(unsafe.Pointer(pwPtr)).Fflags&libc.Int32FromInt32(WIDGET_DELETED) != 0) { XTk_DestroyWindow(tls, (*TPanedWindow)(unsafe.Pointer(pwPtr)).Fproxywin) XTk_DestroyWindow(tls, (*TPanedWindow)(unsafe.Pointer(pwPtr)).Ftkwin) } } /* *-------------------------------------------------------------- * * DisplayPanedWindow -- * * This function redraws the contents of a paned window widget. It is * invoked as a do-when-idle handler, so it only runs when there's * nothing else for the application to do. * * Results: * None. * * Side effects: * Information appears on the screen. * *-------------------------------------------------------------- */ func _DisplayPanedWindow(tls *libc.TLS, clientData uintptr) { bp := tls.Alloc(32) defer tls.Free(32) /* Information about window. */ var horizontal, i, sashHeight int32 var panePtr, pwPtr uintptr var pixmap TPixmap var tkwin TTk_Window var _ /* borderWidth at bp+12 */ int32 var _ /* first at bp+4 */ int32 var _ /* handleSize at bp+16 */ int32 var _ /* last at bp+8 */ int32 var _ /* sashWidth at bp+0 */ int32 _, _, _, _, _, _, _ = horizontal, i, panePtr, pixmap, pwPtr, sashHeight, tkwin pwPtr = clientData tkwin = (*TPanedWindow)(unsafe.Pointer(pwPtr)).Ftkwin horizontal = libc.BoolInt32((*TPanedWindow)(unsafe.Pointer(pwPtr)).Forient == int32(ORIENT_HORIZONTAL)) *(*int32)(unsafe.Pointer(pwPtr + 224)) &= ^libc.Int32FromInt32(REDRAW_PENDING) if (*TPanedWindow)(unsafe.Pointer(pwPtr)).Ftkwin == libc.UintptrFromInt32(0) || !((*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fflags&libc.Uint32FromInt32(TK_MAPPED) != 0) { return } if (*TPanedWindow)(unsafe.Pointer(pwPtr)).Fflags&int32(REQUESTED_RELAYOUT1) != 0 { _ArrangePanes(tls, clientData) } /* * Create a pixmap for double-buffering, if necessary. */ pixmap = XTk_GetPixmap(tls, (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fdisplay, (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fwindow, (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fchanges.Fwidth, (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fchanges.Fheight, (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fdepth) /* * Redraw the widget's background and border. */ XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), tkwin, (*TPanedWindow)(unsafe.Pointer(pwPtr)).FborderWidthObj, bp+12) XTk_Fill3DRectangle(tls, tkwin, pixmap, (*TPanedWindow)(unsafe.Pointer(pwPtr)).Fbackground, 0, 0, (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fchanges.Fwidth, (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fchanges.Fheight, *(*int32)(unsafe.Pointer(bp + 12)), (*TPanedWindow)(unsafe.Pointer(pwPtr)).Frelief) /* * Set up boilerplate geometry values for sashes (width, height, common * coordinates). */ XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), tkwin, (*TPanedWindow)(unsafe.Pointer(pwPtr)).FsashWidthObj, bp) if horizontal != 0 { sashHeight = (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fchanges.Fheight - int32(2)*(*TTk_FakeWin)(unsafe.Pointer(tkwin)).FinternalBorderLeft } else { sashHeight = *(*int32)(unsafe.Pointer(bp)) *(*int32)(unsafe.Pointer(bp)) = (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fchanges.Fwidth - int32(2)*(*TTk_FakeWin)(unsafe.Pointer(tkwin)).FinternalBorderLeft } /* * Draw the sashes. */ _GetFirstLastVisiblePane(tls, pwPtr, bp+4, bp+8) i = 0 for { if !(i < (*TPanedWindow)(unsafe.Pointer(pwPtr)).FnumPanes-int32(1)) { break } panePtr = *(*uintptr)(unsafe.Pointer((*TPanedWindow)(unsafe.Pointer(pwPtr)).Fpanes + uintptr(i)*8)) if (*TPane)(unsafe.Pointer(panePtr)).Fhide != 0 || i == *(*int32)(unsafe.Pointer(bp + 8)) { goto _1 } if *(*int32)(unsafe.Pointer(bp)) > 0 && sashHeight > 0 { XTk_Fill3DRectangle(tls, tkwin, pixmap, (*TPanedWindow)(unsafe.Pointer(pwPtr)).Fbackground, (*TPane)(unsafe.Pointer(panePtr)).Fsashx, (*TPane)(unsafe.Pointer(panePtr)).Fsashy, *(*int32)(unsafe.Pointer(bp)), sashHeight, int32(1), (*TPanedWindow)(unsafe.Pointer(pwPtr)).FsashRelief) } if (*TPanedWindow)(unsafe.Pointer(pwPtr)).FshowHandle != 0 { XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), tkwin, (*TPanedWindow)(unsafe.Pointer(pwPtr)).FhandleSizeObj, bp+16) XTk_Fill3DRectangle(tls, tkwin, pixmap, (*TPanedWindow)(unsafe.Pointer(pwPtr)).Fbackground, (*TPane)(unsafe.Pointer(panePtr)).Fhandlex, (*TPane)(unsafe.Pointer(panePtr)).Fhandley, *(*int32)(unsafe.Pointer(bp + 16)), *(*int32)(unsafe.Pointer(bp + 16)), int32(1), int32(TK_RELIEF_RAISED)) } goto _1 _1: ; i++ } /* * Copy the information from the off-screen pixmap onto the screen, then * delete the pixmap. */ libx11.XXCopyArea(tls, (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fdisplay, pixmap, (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fwindow, (*TPanedWindow)(unsafe.Pointer(pwPtr)).Fgc, 0, 0, libc.Uint32FromInt32((*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fchanges.Fwidth), libc.Uint32FromInt32((*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fchanges.Fheight), 0, 0) XTk_FreePixmap(tls, (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fdisplay, pixmap) } /* *---------------------------------------------------------------------- * * DestroyPanedWindow -- * * This function is invoked by PanedWindowEventProc to free the internal * structure of a paned window. * * Results: * None. * * Side effects: * Everything associated with the paned window is freed up. * *---------------------------------------------------------------------- */ func _DestroyPanedWindow(tls *libc.TLS, pwPtr uintptr) { /* Info about paned window widget. */ var i int32 _ = i /* * First mark the widget as in the process of being deleted, so that any * code that causes calls to other paned window functions will abort. */ *(*int32)(unsafe.Pointer(pwPtr + 224)) |= int32(WIDGET_DELETED) /* * Cancel idle callbacks for redrawing the widget and for rearranging the * panes. */ if (*TPanedWindow)(unsafe.Pointer(pwPtr)).Fflags&int32(REDRAW_PENDING) != 0 { libtcl9_0.XTcl_CancelIdleCall(tls, __ccgo_fp(_DisplayPanedWindow), pwPtr) } if (*TPanedWindow)(unsafe.Pointer(pwPtr)).Fflags&int32(RESIZE_PENDING1) != 0 { libtcl9_0.XTcl_CancelIdleCall(tls, __ccgo_fp(_ArrangePanes), pwPtr) } /* * Clean up the pane list; foreach pane: * o Cancel the pane's structure notification callback * o Cancel geometry management for the pane. * o Free memory for the pane */ i = 0 for { if !(i < (*TPanedWindow)(unsafe.Pointer(pwPtr)).FnumPanes) { break } XTk_DeleteEventHandler(tls, (*TPane)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer((*TPanedWindow)(unsafe.Pointer(pwPtr)).Fpanes + uintptr(i)*8)))).Ftkwin, libc.Uint64FromInt64(libc.Int64FromInt64(1)< *(*int32)(unsafe.Pointer(bp + 20)) { sashOffset = (*(*int32)(unsafe.Pointer(bp + 32))-*(*int32)(unsafe.Pointer(bp + 20)))/int32(2) + *(*int32)(unsafe.Pointer(bp + 36)) *(*int32)(unsafe.Pointer(bp + 20)) = int32(2)**(*int32)(unsafe.Pointer(bp + 36)) + *(*int32)(unsafe.Pointer(bp + 32)) } else { handleOffset = (*(*int32)(unsafe.Pointer(bp + 20))-*(*int32)(unsafe.Pointer(bp + 32)))/int32(2) + *(*int32)(unsafe.Pointer(bp + 36)) *(*int32)(unsafe.Pointer(bp + 20)) = int32(2)**(*int32)(unsafe.Pointer(bp + 36)) + *(*int32)(unsafe.Pointer(bp + 20)) } v6 = libc.Int32FromInt32(0) sashCount = v6 i = v6 for { if !(i < (*TPanedWindow)(unsafe.Pointer(pwPtr)).FnumPanes) { break } panePtr = *(*uintptr)(unsafe.Pointer((*TPanedWindow)(unsafe.Pointer(pwPtr)).Fpanes + uintptr(i)*8)) if (*TPane)(unsafe.Pointer(panePtr)).Fhide != 0 { goto _5 } /* * Compute the total size needed by all the panes and the left-over, * or shortage of space available. */ XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), (*TPane)(unsafe.Pointer(panePtr)).Ftkwin, (*TPane)(unsafe.Pointer(panePtr)).FpadXObj, bp+44) XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), (*TPane)(unsafe.Pointer(panePtr)).Ftkwin, (*TPane)(unsafe.Pointer(panePtr)).FpadYObj, bp+48) if horizontal != 0 { if (*TPane)(unsafe.Pointer(panePtr)).Fwidth > 0 { paneSize = (*TPane)(unsafe.Pointer(panePtr)).Fwidth } else { paneSize = (*TPane)(unsafe.Pointer(panePtr)).FpaneWidth } stretchReserve -= paneSize + int32(2)**(*int32)(unsafe.Pointer(bp + 44)) } else { if (*TPane)(unsafe.Pointer(panePtr)).Fheight > 0 { paneSize = (*TPane)(unsafe.Pointer(panePtr)).Fheight } else { paneSize = (*TPane)(unsafe.Pointer(panePtr)).FpaneHeight } stretchReserve -= paneSize + int32(2)**(*int32)(unsafe.Pointer(bp + 48)) } XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), (*TPane)(unsafe.Pointer(panePtr)).Ftkwin, (*TPane)(unsafe.Pointer(panePtr)).FminSizeObj, bp+52) if ((*TPane)(unsafe.Pointer(panePtr)).Fstretch == int32(STRETCH_ALWAYS) || (*TPane)(unsafe.Pointer(panePtr)).Fstretch == int32(STRETCH_FIRST) && i == *(*int32)(unsafe.Pointer(bp + 24)) || (*TPane)(unsafe.Pointer(panePtr)).Fstretch == int32(STRETCH_LAST) && i == *(*int32)(unsafe.Pointer(bp + 28)) || (*TPane)(unsafe.Pointer(panePtr)).Fstretch == int32(STRETCH_MIDDLE) && i != *(*int32)(unsafe.Pointer(bp + 24)) && i != *(*int32)(unsafe.Pointer(bp + 28))) && (*TTk_FakeWin)(unsafe.Pointer((*TPanedWindow)(unsafe.Pointer(pwPtr)).Ftkwin)).Fflags&uint32(TK_MAPPED) != 0 { paneDynSize += paneSize paneDynMinSize += *(*int32)(unsafe.Pointer(bp + 52)) } if i != *(*int32)(unsafe.Pointer(bp + 28)) { stretchReserve -= *(*int32)(unsafe.Pointer(bp + 20)) sashCount++ } goto _5 _5: ; i++ } /* * Second pass; adjust/arrange panes. */ i = 0 for { if !(i < (*TPanedWindow)(unsafe.Pointer(pwPtr)).FnumPanes) { break } panePtr = *(*uintptr)(unsafe.Pointer((*TPanedWindow)(unsafe.Pointer(pwPtr)).Fpanes + uintptr(i)*8)) if (*TPane)(unsafe.Pointer(panePtr)).Fhide != 0 { XTk_UnmaintainGeometry(tls, (*TPane)(unsafe.Pointer(panePtr)).Ftkwin, (*TPanedWindow)(unsafe.Pointer(pwPtr)).Ftkwin) XTk_UnmapWindow(tls, (*TPane)(unsafe.Pointer(panePtr)).Ftkwin) goto _7 } /* * Compute the size of this pane. The algorithm (assuming a * horizontal paned window) is: * * 1. Get "base" dimensions. If a width or height is specified for * this pane, use those values; else use the ReqWidth/ReqHeight. * 2. Using base dimensions, pane dimensions, and sticky values, * determine the x and y, and actual width and height of the * widget. */ doubleBw = int32(2) * (*TXWindowChanges)(unsafe.Pointer((*TPane)(unsafe.Pointer(panePtr)).Ftkwin+112)).Fborder_width if (*TPane)(unsafe.Pointer(panePtr)).Fwidth > 0 { v8 = (*TPane)(unsafe.Pointer(panePtr)).Fwidth } else { v8 = (*TTk_FakeWin)(unsafe.Pointer((*TPane)(unsafe.Pointer(panePtr)).Ftkwin)).FreqWidth + doubleBw } *(*int32)(unsafe.Pointer(bp)) = v8 if (*TPane)(unsafe.Pointer(panePtr)).Fheight > 0 { v9 = (*TPane)(unsafe.Pointer(panePtr)).Fheight } else { v9 = (*TTk_FakeWin)(unsafe.Pointer((*TPane)(unsafe.Pointer(panePtr)).Ftkwin)).FreqHeight + doubleBw } *(*int32)(unsafe.Pointer(bp + 4)) = v9 XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), (*TPane)(unsafe.Pointer(panePtr)).Ftkwin, (*TPane)(unsafe.Pointer(panePtr)).FminSizeObj, bp+16) /* * Calculate pane width and height. */ if horizontal != 0 { if (*TPane)(unsafe.Pointer(panePtr)).Fwidth > 0 { paneSize = (*TPane)(unsafe.Pointer(panePtr)).Fwidth } else { paneSize = (*TPane)(unsafe.Pointer(panePtr)).FpaneWidth } pwSize = pwWidth } else { if (*TPane)(unsafe.Pointer(panePtr)).Fheight > 0 { paneSize = (*TPane)(unsafe.Pointer(panePtr)).Fheight } else { paneSize = (*TPane)(unsafe.Pointer(panePtr)).FpaneHeight } pwSize = pwHeight } if (*TPane)(unsafe.Pointer(panePtr)).Fstretch == int32(STRETCH_ALWAYS) || (*TPane)(unsafe.Pointer(panePtr)).Fstretch == int32(STRETCH_FIRST) && i == *(*int32)(unsafe.Pointer(bp + 24)) || (*TPane)(unsafe.Pointer(panePtr)).Fstretch == int32(STRETCH_LAST) && i == *(*int32)(unsafe.Pointer(bp + 28)) || (*TPane)(unsafe.Pointer(panePtr)).Fstretch == int32(STRETCH_MIDDLE) && i != *(*int32)(unsafe.Pointer(bp + 24)) && i != *(*int32)(unsafe.Pointer(bp + 28)) { if paneDynSize > 0 { frac = float64(paneSize) / float64(paneDynSize) } else { frac = float64(paneSize) / float64(pwSize) } paneDynSize -= paneSize paneDynMinSize -= *(*int32)(unsafe.Pointer(bp + 16)) stretchAmount = int32(float64(frac * float64(stretchReserve))) if paneSize+stretchAmount >= *(*int32)(unsafe.Pointer(bp + 16)) { stretchReserve -= stretchAmount paneSize += stretchAmount } else { stretchReserve += paneSize - *(*int32)(unsafe.Pointer(bp + 16)) paneSize = *(*int32)(unsafe.Pointer(bp + 16)) } if i == *(*int32)(unsafe.Pointer(bp + 28)) && stretchReserve > 0 { paneSize += stretchReserve stretchReserve = 0 } } else { if paneDynSize-paneDynMinSize+stretchReserve < 0 { if paneSize+paneDynSize-paneDynMinSize+stretchReserve <= *(*int32)(unsafe.Pointer(bp + 16)) { stretchReserve += paneSize - *(*int32)(unsafe.Pointer(bp + 16)) paneSize = *(*int32)(unsafe.Pointer(bp + 16)) } else { paneSize += paneDynSize - paneDynMinSize + stretchReserve stretchReserve = paneDynMinSize - paneDynSize } } } XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), (*TPane)(unsafe.Pointer(panePtr)).Ftkwin, (*TPane)(unsafe.Pointer(panePtr)).FpadXObj, bp+56) XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), (*TPane)(unsafe.Pointer(panePtr)).Ftkwin, (*TPane)(unsafe.Pointer(panePtr)).FpadYObj, bp+60) if horizontal != 0 { paneWidth = paneSize paneHeight = pwHeight - int32(2)**(*int32)(unsafe.Pointer(bp + 60)) } else { paneWidth = pwWidth - int32(2)**(*int32)(unsafe.Pointer(bp + 56)) paneHeight = paneSize } /* * Adjust for area reserved for sashes. */ if sashCount != 0 { sashReserve = *(*int32)(unsafe.Pointer(bp + 20)) * sashCount if horizontal != 0 { sxReserve = sashReserve syReserve = 0 } else { sxReserve = 0 syReserve = sashReserve } } else { v10 = libc.Int32FromInt32(0) syReserve = v10 sxReserve = v10 } if pwWidth-sxReserve < x+paneWidth-internalBW { paneWidth = pwWidth - sxReserve - x + internalBW } if pwHeight-syReserve < y+paneHeight-internalBW { paneHeight = pwHeight - syReserve - y + internalBW } if *(*int32)(unsafe.Pointer(bp)) > paneWidth { *(*int32)(unsafe.Pointer(bp)) = paneWidth } if *(*int32)(unsafe.Pointer(bp + 4)) > paneHeight { *(*int32)(unsafe.Pointer(bp + 4)) = paneHeight } (*TPane)(unsafe.Pointer(panePtr)).Fx = x (*TPane)(unsafe.Pointer(panePtr)).Fy = y /* * Compute the location of the sash at the right or bottom of the * parcel and the location of the next parcel. */ XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), (*TPanedWindow)(unsafe.Pointer(pwPtr)).Ftkwin, (*TPanedWindow)(unsafe.Pointer(pwPtr)).FhandlePadObj, bp+40) if horizontal != 0 { x += paneWidth + int32(2)**(*int32)(unsafe.Pointer(bp + 56)) if x < internalBW { x = internalBW } (*TPane)(unsafe.Pointer(panePtr)).Fsashx = x + sashOffset (*TPane)(unsafe.Pointer(panePtr)).Fsashy = y (*TPane)(unsafe.Pointer(panePtr)).Fhandlex = x + handleOffset (*TPane)(unsafe.Pointer(panePtr)).Fhandley = y + *(*int32)(unsafe.Pointer(bp + 40)) x += *(*int32)(unsafe.Pointer(bp + 20)) } else { y += paneHeight + int32(2)**(*int32)(unsafe.Pointer(bp + 60)) if y < internalBW { y = internalBW } (*TPane)(unsafe.Pointer(panePtr)).Fsashx = x (*TPane)(unsafe.Pointer(panePtr)).Fsashy = y + sashOffset (*TPane)(unsafe.Pointer(panePtr)).Fhandlex = x + *(*int32)(unsafe.Pointer(bp + 40)) (*TPane)(unsafe.Pointer(panePtr)).Fhandley = y + handleOffset y += *(*int32)(unsafe.Pointer(bp + 20)) } /* * Compute the actual dimensions of the pane in the pane. */ *(*int32)(unsafe.Pointer(bp + 8)) = (*TPane)(unsafe.Pointer(panePtr)).Fx *(*int32)(unsafe.Pointer(bp + 12)) = (*TPane)(unsafe.Pointer(panePtr)).Fy _AdjustForSticky1(tls, (*TPane)(unsafe.Pointer(panePtr)).Fsticky, paneWidth, paneHeight, bp+8, bp+12, bp, bp+4) *(*int32)(unsafe.Pointer(bp + 8)) += *(*int32)(unsafe.Pointer(bp + 56)) *(*int32)(unsafe.Pointer(bp + 12)) += *(*int32)(unsafe.Pointer(bp + 60)) /* * Now put the window in the proper spot. */ if v12 = *(*int32)(unsafe.Pointer(bp)) <= 0 || *(*int32)(unsafe.Pointer(bp + 4)) <= 0; !v12 { if horizontal != 0 { v11 = libc.BoolInt32(*(*int32)(unsafe.Pointer(bp + 8))-internalBW > pwWidth) } else { v11 = libc.BoolInt32(*(*int32)(unsafe.Pointer(bp + 12))-internalBW > pwHeight) } } if v12 || v11 != 0 { XTk_UnmaintainGeometry(tls, (*TPane)(unsafe.Pointer(panePtr)).Ftkwin, (*TPanedWindow)(unsafe.Pointer(pwPtr)).Ftkwin) XTk_UnmapWindow(tls, (*TPane)(unsafe.Pointer(panePtr)).Ftkwin) } else { XTk_MaintainGeometry(tls, (*TPane)(unsafe.Pointer(panePtr)).Ftkwin, (*TPanedWindow)(unsafe.Pointer(pwPtr)).Ftkwin, *(*int32)(unsafe.Pointer(bp + 8)), *(*int32)(unsafe.Pointer(bp + 12)), *(*int32)(unsafe.Pointer(bp)), *(*int32)(unsafe.Pointer(bp + 4))) } sashCount-- goto _7 _7: ; i++ } libtcl9_0.XTcl_Release(tls, pwPtr) } /* *---------------------------------------------------------------------- * * Unlink -- * * Remove a pane from a paned window. * * Results: * None. * * Side effects: * The paned window will be scheduled for re-arranging and redrawing. * *---------------------------------------------------------------------- */ func _Unlink2(tls *libc.TLS, panePtr uintptr) { /* Window to unlink. */ var containerPtr uintptr var i, j int32 _, _, _ = containerPtr, i, j containerPtr = (*TPane)(unsafe.Pointer(panePtr)).FcontainerPtr if containerPtr == libc.UintptrFromInt32(0) { return } /* * Find the specified pane in the panedwindow's list of panes, then * remove it from that list. */ i = 0 for { if !(i < (*TPanedWindow)(unsafe.Pointer(containerPtr)).FnumPanes) { break } if *(*uintptr)(unsafe.Pointer((*TPanedWindow)(unsafe.Pointer(containerPtr)).Fpanes + uintptr(i)*8)) == panePtr { j = i for { if !(j < (*TPanedWindow)(unsafe.Pointer(containerPtr)).FnumPanes-int32(1)) { break } *(*uintptr)(unsafe.Pointer((*TPanedWindow)(unsafe.Pointer(containerPtr)).Fpanes + uintptr(j)*8)) = *(*uintptr)(unsafe.Pointer((*TPanedWindow)(unsafe.Pointer(containerPtr)).Fpanes + uintptr(j+int32(1))*8)) goto _2 _2: ; j++ } break } goto _1 _1: ; i++ } /* * Clean out any -after or -before references to this pane */ i = 0 for { if !(i < (*TPanedWindow)(unsafe.Pointer(containerPtr)).FnumPanes) { break } if (*TPane)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer((*TPanedWindow)(unsafe.Pointer(containerPtr)).Fpanes + uintptr(i)*8)))).Fbefore == (*TPane)(unsafe.Pointer(panePtr)).Ftkwin { (*TPane)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer((*TPanedWindow)(unsafe.Pointer(containerPtr)).Fpanes + uintptr(i)*8)))).Fbefore = libc.UintptrFromInt32(0) } if (*TPane)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer((*TPanedWindow)(unsafe.Pointer(containerPtr)).Fpanes + uintptr(i)*8)))).Fafter == (*TPane)(unsafe.Pointer(panePtr)).Ftkwin { (*TPane)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer((*TPanedWindow)(unsafe.Pointer(containerPtr)).Fpanes + uintptr(i)*8)))).Fafter = libc.UintptrFromInt32(0) } goto _3 _3: ; i++ } *(*int32)(unsafe.Pointer(containerPtr + 224)) |= int32(REQUESTED_RELAYOUT1) if !((*TPanedWindow)(unsafe.Pointer(containerPtr)).Fflags&libc.Int32FromInt32(REDRAW_PENDING) != 0) { *(*int32)(unsafe.Pointer(containerPtr + 224)) |= int32(REDRAW_PENDING) libtcl9_0.XTcl_DoWhenIdle(tls, __ccgo_fp(_DisplayPanedWindow), containerPtr) } /* * Set the pane's containerPtr to NULL, so that we can tell that the pane * is no longer attached to any panedwindow. */ (*TPane)(unsafe.Pointer(panePtr)).FcontainerPtr = libc.UintptrFromInt32(0) (*TPanedWindow)(unsafe.Pointer(containerPtr)).FnumPanes-- } /* *---------------------------------------------------------------------- * * GetPane -- * * Given a token to a Tk window, find the pane that corresponds to that * token in a given paned window. * * Results: * Pointer to the pane structure, or NULL if the window is not managed * by this paned window. * * Side effects: * None. * *---------------------------------------------------------------------- */ func _GetPane(tls *libc.TLS, pwPtr uintptr, tkwin TTk_Window) (r uintptr) { /* Window to search for. */ var i int32 _ = i i = 0 for { if !(i < (*TPanedWindow)(unsafe.Pointer(pwPtr)).FnumPanes) { break } if (*TPane)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer((*TPanedWindow)(unsafe.Pointer(pwPtr)).Fpanes + uintptr(i)*8)))).Ftkwin == tkwin { return *(*uintptr)(unsafe.Pointer((*TPanedWindow)(unsafe.Pointer(pwPtr)).Fpanes + uintptr(i)*8)) } goto _1 _1: ; i++ } return libc.UintptrFromInt32(0) } /* *---------------------------------------------------------------------- * * GetFirstLastVisiblePane -- * * Given panedwindow, find the index of the first and last visible panes * of that paned window. * * Results: * Index of the first and last visible panes. * * Side effects: * None. * *---------------------------------------------------------------------- */ func _GetFirstLastVisiblePane(tls *libc.TLS, pwPtr uintptr, firstPtr uintptr, lastPtr uintptr) { /* Returned index for last. */ var i int32 _ = i i = 0 *(*int32)(unsafe.Pointer(lastPtr)) = 0 *(*int32)(unsafe.Pointer(firstPtr)) = -libc.Int32FromInt32(1) for { if !(i < (*TPanedWindow)(unsafe.Pointer(pwPtr)).FnumPanes) { break } if (*TPane)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer((*TPanedWindow)(unsafe.Pointer(pwPtr)).Fpanes + uintptr(i)*8)))).Fhide == 0 { if *(*int32)(unsafe.Pointer(firstPtr)) < 0 { *(*int32)(unsafe.Pointer(firstPtr)) = i } *(*int32)(unsafe.Pointer(lastPtr)) = i } goto _1 _1: ; i++ } } /* *-------------------------------------------------------------- * * PaneStructureProc -- * * This function is invoked whenever StructureNotify events occur for a * window that's managed by a paned window. This function's only purpose * is to clean up when windows are deleted. * * Results: * None. * * Side effects: * The paned window pane structure associated with the window * is freed, and the pane is disassociated from the paned * window which managed it. * *-------------------------------------------------------------- */ func _PaneStructureProc(tls *libc.TLS, clientData uintptr, eventPtr uintptr) { /* Describes what just happened. */ var panePtr, pwPtr uintptr _, _ = panePtr, pwPtr panePtr = clientData pwPtr = (*TPane)(unsafe.Pointer(panePtr)).FcontainerPtr if (*TXEvent)(unsafe.Pointer(eventPtr)).Ftype1 == int32(DestroyNotify) { _Unlink2(tls, panePtr) (*TPane)(unsafe.Pointer(panePtr)).Ftkwin = libc.UintptrFromInt32(0) libtcl9_0.XTcl_Free(tls, panePtr) _ComputeGeometry(tls, pwPtr) } } /* *---------------------------------------------------------------------- * * ComputeGeometry -- * * Compute geometry for the paned window, including coordinates of all * panes and each sash. * * Results: * None. * * Side effects: * Recomputes geometry information for a paned window. * *---------------------------------------------------------------------- */ func _ComputeGeometry(tls *libc.TLS, pwPtr uintptr) { bp := tls.Alloc(48) defer tls.Free(48) /* Pointer to the Paned Window structure. */ var dim, doubleBw, handleOffset, horizontal, i, internalBw, reqHeight, reqWidth, sashOffset, x, y, v1, v2, v3, v4, v6, v7, v8, v9 int32 var panePtr uintptr var _ /* handlePad at bp+32 */ int32 var _ /* handleSize at bp+4 */ int32 var _ /* height at bp+16 */ int32 var _ /* minSize at bp+28 */ int32 var _ /* padX at bp+20 */ int32 var _ /* padY at bp+24 */ int32 var _ /* sashPad at bp+8 */ int32 var _ /* sashWidth at bp+0 */ int32 var _ /* width at bp+12 */ int32 _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = dim, doubleBw, handleOffset, horizontal, i, internalBw, panePtr, reqHeight, reqWidth, sashOffset, x, y, v1, v2, v3, v4, v6, v7, v8, v9 horizontal = libc.BoolInt32((*TPanedWindow)(unsafe.Pointer(pwPtr)).Forient == int32(ORIENT_HORIZONTAL)) *(*int32)(unsafe.Pointer(bp + 12)) = -int32(1) *(*int32)(unsafe.Pointer(bp + 16)) = -int32(1) *(*int32)(unsafe.Pointer(pwPtr + 224)) |= int32(REQUESTED_RELAYOUT1) v2 = (*TTk_FakeWin)(unsafe.Pointer((*TPanedWindow)(unsafe.Pointer(pwPtr)).Ftkwin)).FinternalBorderLeft internalBw = v2 v1 = v2 y = v1 x = v1 v3 = libc.Int32FromInt32(0) reqHeight = v3 reqWidth = v3 /* * Sashes and handles share space on the display. To simplify processing * below, precompute the x and y offsets of the handles and sashes within * the space occupied by their combination; later, just add those offsets * blindly (avoiding the extra showHandle, etc, checks). */ XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), (*TPanedWindow)(unsafe.Pointer(pwPtr)).Ftkwin, (*TPanedWindow)(unsafe.Pointer(pwPtr)).FsashPadObj, bp+8) v4 = *(*int32)(unsafe.Pointer(bp + 8)) handleOffset = v4 sashOffset = v4 XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), (*TPanedWindow)(unsafe.Pointer(pwPtr)).Ftkwin, (*TPanedWindow)(unsafe.Pointer(pwPtr)).FhandleSizeObj, bp+4) XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), (*TPanedWindow)(unsafe.Pointer(pwPtr)).Ftkwin, (*TPanedWindow)(unsafe.Pointer(pwPtr)).FsashWidthObj, bp) if (*TPanedWindow)(unsafe.Pointer(pwPtr)).FshowHandle != 0 && *(*int32)(unsafe.Pointer(bp + 4)) > *(*int32)(unsafe.Pointer(bp)) { sashOffset = (*(*int32)(unsafe.Pointer(bp + 4))-*(*int32)(unsafe.Pointer(bp)))/int32(2) + *(*int32)(unsafe.Pointer(bp + 8)) *(*int32)(unsafe.Pointer(bp)) = int32(2)**(*int32)(unsafe.Pointer(bp + 8)) + *(*int32)(unsafe.Pointer(bp + 4)) } else { handleOffset = (*(*int32)(unsafe.Pointer(bp))-*(*int32)(unsafe.Pointer(bp + 4)))/int32(2) + *(*int32)(unsafe.Pointer(bp + 8)) *(*int32)(unsafe.Pointer(bp)) = int32(2)**(*int32)(unsafe.Pointer(bp + 8)) + *(*int32)(unsafe.Pointer(bp)) } i = 0 for { if !(i < (*TPanedWindow)(unsafe.Pointer(pwPtr)).FnumPanes) { break } panePtr = *(*uintptr)(unsafe.Pointer((*TPanedWindow)(unsafe.Pointer(pwPtr)).Fpanes + uintptr(i)*8)) if (*TPane)(unsafe.Pointer(panePtr)).Fhide != 0 { goto _5 } /* * First set the coordinates for the top left corner of the pane's * parcel. */ (*TPane)(unsafe.Pointer(panePtr)).Fx = x (*TPane)(unsafe.Pointer(panePtr)).Fy = y /* * Make sure the pane's paned dimension is at least minsize. This * check may be redundant, since the only way to change a pane's size * is by moving a sash, and that code checks the minsize. */ XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), (*TPane)(unsafe.Pointer(panePtr)).Ftkwin, (*TPane)(unsafe.Pointer(panePtr)).FminSizeObj, bp+28) if horizontal != 0 { if (*TPane)(unsafe.Pointer(panePtr)).FpaneWidth < *(*int32)(unsafe.Pointer(bp + 28)) { (*TPane)(unsafe.Pointer(panePtr)).FpaneWidth = *(*int32)(unsafe.Pointer(bp + 28)) } } else { if (*TPane)(unsafe.Pointer(panePtr)).FpaneHeight < *(*int32)(unsafe.Pointer(bp + 28)) { (*TPane)(unsafe.Pointer(panePtr)).FpaneHeight = *(*int32)(unsafe.Pointer(bp + 28)) } } /* * Compute the location of the sash at the right or bottom of the * parcel. */ XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), (*TPane)(unsafe.Pointer(panePtr)).Ftkwin, (*TPane)(unsafe.Pointer(panePtr)).FpadXObj, bp+20) XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), (*TPane)(unsafe.Pointer(panePtr)).Ftkwin, (*TPane)(unsafe.Pointer(panePtr)).FpadYObj, bp+24) XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), (*TPanedWindow)(unsafe.Pointer(pwPtr)).Ftkwin, (*TPanedWindow)(unsafe.Pointer(pwPtr)).FhandlePadObj, bp+32) if horizontal != 0 { x += (*TPane)(unsafe.Pointer(panePtr)).FpaneWidth + int32(2)**(*int32)(unsafe.Pointer(bp + 20)) (*TPane)(unsafe.Pointer(panePtr)).Fsashx = x + sashOffset (*TPane)(unsafe.Pointer(panePtr)).Fsashy = y (*TPane)(unsafe.Pointer(panePtr)).Fhandlex = x + handleOffset (*TPane)(unsafe.Pointer(panePtr)).Fhandley = y + *(*int32)(unsafe.Pointer(bp + 32)) x += *(*int32)(unsafe.Pointer(bp)) } else { y += (*TPane)(unsafe.Pointer(panePtr)).FpaneHeight + int32(2)**(*int32)(unsafe.Pointer(bp + 24)) (*TPane)(unsafe.Pointer(panePtr)).Fsashx = x (*TPane)(unsafe.Pointer(panePtr)).Fsashy = y + sashOffset (*TPane)(unsafe.Pointer(panePtr)).Fhandlex = x + *(*int32)(unsafe.Pointer(bp + 32)) (*TPane)(unsafe.Pointer(panePtr)).Fhandley = y + handleOffset y += *(*int32)(unsafe.Pointer(bp)) } /* * Find the maximum height/width of the panes, for computing the * requested height/width of the paned window. */ if horizontal != 0 { /* * If the pane has an explicit height set, use that; otherwise, * use the pane's requested height. */ if (*TPane)(unsafe.Pointer(panePtr)).Fheight > 0 { dim = (*TPane)(unsafe.Pointer(panePtr)).Fheight } else { doubleBw = int32(2) * (*TXWindowChanges)(unsafe.Pointer((*TPane)(unsafe.Pointer(panePtr)).Ftkwin+112)).Fborder_width dim = (*TTk_FakeWin)(unsafe.Pointer((*TPane)(unsafe.Pointer(panePtr)).Ftkwin)).FreqHeight + doubleBw } dim += int32(2) * *(*int32)(unsafe.Pointer(bp + 24)) if dim > reqHeight { reqHeight = dim } } else { /* * If the pane has an explicit width set use that; otherwise, use * the pane's requested width. */ if (*TPane)(unsafe.Pointer(panePtr)).Fwidth > 0 { dim = (*TPane)(unsafe.Pointer(panePtr)).Fwidth } else { doubleBw = int32(2) * (*TXWindowChanges)(unsafe.Pointer((*TPane)(unsafe.Pointer(panePtr)).Ftkwin+112)).Fborder_width dim = (*TTk_FakeWin)(unsafe.Pointer((*TPane)(unsafe.Pointer(panePtr)).Ftkwin)).FreqWidth + doubleBw } dim += int32(2) * *(*int32)(unsafe.Pointer(bp + 20)) if dim > reqWidth { reqWidth = dim } } goto _5 _5: ; i++ } /* * The loop above should have left x (or y) equal to the sum of the widths * (or heights) of the widgets, plus the size of one sash and the sash * padding for each widget, plus the width of the left (or top) border of * the paned window. * * The requested width (or height) is therefore x (or y) minus the size of * one sash and padding, plus the width of the right (or bottom) border of * the paned window. * * The height (or width) is equal to the maximum height (or width) of the * panes, plus the width of the border of the top and bottom (or left and * right) of the paned window. * * If the panedwindow has an explicit width/height set use that; * otherwise, use the requested width/height. */ if (*TPanedWindow)(unsafe.Pointer(pwPtr)).FwidthObj != 0 { XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), (*TPanedWindow)(unsafe.Pointer(pwPtr)).Ftkwin, (*TPanedWindow)(unsafe.Pointer(pwPtr)).FwidthObj, bp+12) } if (*TPanedWindow)(unsafe.Pointer(pwPtr)).FheightObj != 0 { XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), (*TPanedWindow)(unsafe.Pointer(pwPtr)).Ftkwin, (*TPanedWindow)(unsafe.Pointer(pwPtr)).FheightObj, bp+16) } if horizontal != 0 { if *(*int32)(unsafe.Pointer(bp + 12)) > 0 { v6 = *(*int32)(unsafe.Pointer(bp + 12)) } else { v6 = x - *(*int32)(unsafe.Pointer(bp)) + internalBw } reqWidth = v6 if *(*int32)(unsafe.Pointer(bp + 16)) > 0 { v7 = *(*int32)(unsafe.Pointer(bp + 16)) } else { v7 = reqHeight + int32(2)*internalBw } reqHeight = v7 } else { if *(*int32)(unsafe.Pointer(bp + 12)) > 0 { v8 = *(*int32)(unsafe.Pointer(bp + 12)) } else { v8 = reqWidth + int32(2)*internalBw } reqWidth = v8 if *(*int32)(unsafe.Pointer(bp + 16)) > 0 { v9 = *(*int32)(unsafe.Pointer(bp + 16)) } else { v9 = y - *(*int32)(unsafe.Pointer(bp)) + internalBw } reqHeight = v9 } XTk_GeometryRequest(tls, (*TPanedWindow)(unsafe.Pointer(pwPtr)).Ftkwin, reqWidth, reqHeight) if (*TTk_FakeWin)(unsafe.Pointer((*TPanedWindow)(unsafe.Pointer(pwPtr)).Ftkwin)).Fflags&uint32(TK_MAPPED) != 0 && !((*TPanedWindow)(unsafe.Pointer(pwPtr)).Fflags&libc.Int32FromInt32(REDRAW_PENDING) != 0) { *(*int32)(unsafe.Pointer(pwPtr + 224)) |= int32(REDRAW_PENDING) libtcl9_0.XTcl_DoWhenIdle(tls, __ccgo_fp(_DisplayPanedWindow), pwPtr) } } /* *---------------------------------------------------------------------- * * DestroyOptionTables -- * * This function is registered as an exit callback when the paned window * command is first called. It cleans up the OptionTables structure * allocated by that command. * * Results: * None. * * Side effects: * Frees memory. * *---------------------------------------------------------------------- */ func _DestroyOptionTables(tls *libc.TLS, clientData uintptr, dummy2414 uintptr) { /* Pointer to the calling interp */ libtcl9_0.XTcl_Free(tls, clientData) } /* *---------------------------------------------------------------------- * * GetSticky - * * Converts an internal boolean combination of "sticky" bits into a Tcl * string obj containing zero or more of n, s, e, or w. * * Results: * Tcl_Obj containing the string representation of the sticky value. * * Side effects: * Creates a new Tcl_Obj. * *---------------------------------------------------------------------- */ func _GetSticky(tls *libc.TLS, dummy2438 uintptr, dummy2439 TTk_Window, recordPtr uintptr, internalOffset TTcl_Size) (r uintptr) { bp := tls.Alloc(16) defer tls.Free(16) /* Offset within *recordPtr containing the * sticky value. */ var p, v1, v2, v3, v4 uintptr var sticky int32 var _ /* buffer at bp+0 */ [5]uint8 _, _, _, _, _, _ = p, sticky, v1, v2, v3, v4 sticky = *(*int32)(unsafe.Pointer(recordPtr + uintptr(internalOffset))) p = bp if sticky&int32(STICK_NORTH) != 0 { v1 = p p++ *(*uint8)(unsafe.Pointer(v1)) = uint8('n') } if sticky&int32(STICK_EAST) != 0 { v2 = p p++ *(*uint8)(unsafe.Pointer(v2)) = uint8('e') } if sticky&int32(STICK_SOUTH) != 0 { v3 = p p++ *(*uint8)(unsafe.Pointer(v3)) = uint8('s') } if sticky&int32(STICK_WEST) != 0 { v4 = p p++ *(*uint8)(unsafe.Pointer(v4)) = uint8('w') } *(*uint8)(unsafe.Pointer(p)) = uint8('\000') return libtcl9_0.XTcl_NewStringObj(tls, bp, int64(-libc.Int32FromInt32(1))) } /* *---------------------------------------------------------------------- * * SetSticky -- * * Converts a Tcl_Obj representing a widgets stickyness into an integer * value. * * Results: * Standard Tcl result. * * Side effects: * May store the integer value into the internal representation pointer. * May change the pointer to the Tcl_Obj to NULL to indicate that the * specified string was empty and that is acceptable. * *---------------------------------------------------------------------- */ func _SetSticky(tls *libc.TLS, dummy2486 uintptr, interp uintptr, dummy2488 TTk_Window, value uintptr, recordPtr uintptr, internalOffset TTcl_Size, oldInternalPtr uintptr, flags int32) (r int32) { bp := tls.Alloc(48) defer tls.Free(48) /* Flags for the option, set Tk_SetOptions. */ var c, v1 uint8 var internalPtr, string1, v2 uintptr var sticky int32 _, _, _, _, _, _ = c, internalPtr, sticky, string1, v1, v2 sticky = 0 internalPtr = _ComputeSlotAddress(tls, recordPtr, internalOffset) if flags&int32(TCL_NULL_OK) != 0 && _ObjectIsEmpty1(tls, *(*uintptr)(unsafe.Pointer(value))) != 0 { *(*uintptr)(unsafe.Pointer(value)) = libc.UintptrFromInt32(0) } else { /* * Convert the sticky specifier into an integer value. */ string1 = libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(value)), libc.UintptrFromInt32(0)) for { v2 = string1 string1++ v1 = *(*uint8)(unsafe.Pointer(v2)) c = v1 if !(libc.Int32FromUint8(v1) != int32('\000')) { break } switch libc.Int32FromUint8(c) { case int32('n'): fallthrough case int32('N'): sticky |= int32(STICK_NORTH) case int32('e'): fallthrough case int32('E'): sticky |= int32(STICK_EAST) case int32('s'): fallthrough case int32('S'): sticky |= int32(STICK_SOUTH) case int32('w'): fallthrough case int32('W'): sticky |= int32(STICK_WEST) case int32(' '): fallthrough case int32(','): fallthrough case int32('\t'): fallthrough case int32('\r'): fallthrough case int32('\n'): default: libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+25774, libc.VaList(bp+8, libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(value)), libc.UintptrFromInt32(0))))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+8, __ccgo_ts+179, __ccgo_ts+182, __ccgo_ts+13542, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) } } } if internalPtr != libc.UintptrFromInt32(0) { *(*int32)(unsafe.Pointer(oldInternalPtr)) = *(*int32)(unsafe.Pointer(internalPtr)) *(*int32)(unsafe.Pointer(internalPtr)) = sticky } return TCL_OK } /* *---------------------------------------------------------------------- * * RestoreSticky -- * * Restore a sticky option value from a saved value. * * Results: * None. * * Side effects: * Restores the old value. * *---------------------------------------------------------------------- */ func _RestoreSticky(tls *libc.TLS, dummy2566 uintptr, dummy2567 TTk_Window, internalPtr uintptr, oldInternalPtr uintptr) { /* Pointer to old value. */ *(*int32)(unsafe.Pointer(internalPtr)) = *(*int32)(unsafe.Pointer(oldInternalPtr)) } /* *---------------------------------------------------------------------- * * AdjustForSticky -- * * Given the x,y coords of the top-left corner of a pane, the dimensions * of that pane, and the dimensions of a pane, compute the x,y coords * and actual dimensions of the pane based on the pane's sticky value. * * Results: * No direct return; sets the x, y, paneWidth and paneHeight to correct * values. * * Side effects: * None. * *---------------------------------------------------------------------- */ func _AdjustForSticky1(tls *libc.TLS, sticky int32, cavityWidth int32, cavityHeight int32, xPtr uintptr, yPtr uintptr, paneWidthPtr uintptr, paneHeightPtr uintptr) { /* Pane height. */ var diffx, diffy, v1, v2 int32 _, _, _, _ = diffx, diffy, v1, v2 diffx = 0 /* Cavity width - pane width. */ diffy = 0 /* Cavity hight - pane height. */ if cavityWidth > *(*int32)(unsafe.Pointer(paneWidthPtr)) { diffx = cavityWidth - *(*int32)(unsafe.Pointer(paneWidthPtr)) } if cavityHeight > *(*int32)(unsafe.Pointer(paneHeightPtr)) { diffy = cavityHeight - *(*int32)(unsafe.Pointer(paneHeightPtr)) } if sticky&int32(STICK_EAST) != 0 && sticky&int32(STICK_WEST) != 0 { *(*int32)(unsafe.Pointer(paneWidthPtr)) += diffx } if sticky&int32(STICK_NORTH) != 0 && sticky&int32(STICK_SOUTH) != 0 { *(*int32)(unsafe.Pointer(paneHeightPtr)) += diffy } if !(sticky&libc.Int32FromInt32(STICK_WEST) != 0) { if sticky&int32(STICK_EAST) != 0 { v1 = diffx } else { v1 = diffx / int32(2) } *(*int32)(unsafe.Pointer(xPtr)) += v1 } if !(sticky&libc.Int32FromInt32(STICK_NORTH) != 0) { if sticky&int32(STICK_SOUTH) != 0 { v2 = diffy } else { v2 = diffy / int32(2) } *(*int32)(unsafe.Pointer(yPtr)) += v2 } } /* *---------------------------------------------------------------------- * * MoveSash -- * * Move the sash given by index the amount given. * * Results: * None. * * Side effects: * Recomputes the sizes of the panes in a panedwindow. * *---------------------------------------------------------------------- */ func _MoveSash(tls *libc.TLS, pwPtr uintptr, sash int32, diff int32) { bp := tls.Alloc(32) defer tls.Free(32) var expandPane, horizontal, i, nextSash, paneSize, reduceFirst, reduceIncr, reduceLast, sashOffset, stretchReserve, v2, v3, v8, v9 int32 var panePtr, p5, p6 uintptr var _ /* handleSize at bp+0 */ int32 var _ /* minSize at bp+20 */ int32 var _ /* minSize at bp+24 */ int32 var _ /* padX at bp+12 */ int32 var _ /* padY at bp+16 */ int32 var _ /* sashPad at bp+4 */ int32 var _ /* sashWidth at bp+8 */ int32 _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = expandPane, horizontal, i, nextSash, panePtr, paneSize, reduceFirst, reduceIncr, reduceLast, sashOffset, stretchReserve, v2, v3, v8, v9, p5, p6 stretchReserve = 0 nextSash = sash + int32(1) horizontal = libc.BoolInt32((*TPanedWindow)(unsafe.Pointer(pwPtr)).Forient == int32(ORIENT_HORIZONTAL)) if diff == 0 { return } /* * Update the pane sizes with their real sizes. */ XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), (*TPanedWindow)(unsafe.Pointer(pwPtr)).Ftkwin, (*TPanedWindow)(unsafe.Pointer(pwPtr)).FhandleSizeObj, bp) XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), (*TPanedWindow)(unsafe.Pointer(pwPtr)).Ftkwin, (*TPanedWindow)(unsafe.Pointer(pwPtr)).FsashPadObj, bp+4) XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), (*TPanedWindow)(unsafe.Pointer(pwPtr)).Ftkwin, (*TPanedWindow)(unsafe.Pointer(pwPtr)).FsashWidthObj, bp+8) if (*TPanedWindow)(unsafe.Pointer(pwPtr)).FshowHandle != 0 && *(*int32)(unsafe.Pointer(bp)) > *(*int32)(unsafe.Pointer(bp + 8)) { sashOffset = (*(*int32)(unsafe.Pointer(bp))-*(*int32)(unsafe.Pointer(bp + 8)))/int32(2) + *(*int32)(unsafe.Pointer(bp + 4)) } else { sashOffset = *(*int32)(unsafe.Pointer(bp + 4)) } i = 0 for { if !(i < (*TPanedWindow)(unsafe.Pointer(pwPtr)).FnumPanes) { break } panePtr = *(*uintptr)(unsafe.Pointer((*TPanedWindow)(unsafe.Pointer(pwPtr)).Fpanes + uintptr(i)*8)) if (*TPane)(unsafe.Pointer(panePtr)).Fhide != 0 { goto _1 } XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), (*TPane)(unsafe.Pointer(panePtr)).Ftkwin, (*TPane)(unsafe.Pointer(panePtr)).FpadXObj, bp+12) XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), (*TPane)(unsafe.Pointer(panePtr)).Ftkwin, (*TPane)(unsafe.Pointer(panePtr)).FpadYObj, bp+16) if horizontal != 0 { v2 = (*TPane)(unsafe.Pointer(panePtr)).Fsashx - sashOffset - (*TPane)(unsafe.Pointer(panePtr)).Fx - libc.Int32FromInt32(2)**(*int32)(unsafe.Pointer(bp + 12)) (*TPane)(unsafe.Pointer(panePtr)).Fwidth = v2 (*TPane)(unsafe.Pointer(panePtr)).FpaneWidth = v2 } else { v3 = (*TPane)(unsafe.Pointer(panePtr)).Fsashy - sashOffset - (*TPane)(unsafe.Pointer(panePtr)).Fy - libc.Int32FromInt32(2)**(*int32)(unsafe.Pointer(bp + 16)) (*TPane)(unsafe.Pointer(panePtr)).Fheight = v3 (*TPane)(unsafe.Pointer(panePtr)).FpaneHeight = v3 } goto _1 _1: ; i++ } /* * There must be a next sash since it is only possible to enter this * routine when moving an actual sash which implies there exists a visible * pane to either side of the sash. */ for nextSash < (*TPanedWindow)(unsafe.Pointer(pwPtr)).FnumPanes-int32(1) && (*TPane)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer((*TPanedWindow)(unsafe.Pointer(pwPtr)).Fpanes + uintptr(nextSash)*8)))).Fhide != 0 { nextSash++ } /* * Consolidate +/-diff variables to reduce duplicate code. */ if diff > 0 { expandPane = sash reduceFirst = nextSash reduceLast = (*TPanedWindow)(unsafe.Pointer(pwPtr)).FnumPanes reduceIncr = int32(1) } else { diff = libc.Xabs(tls, diff) expandPane = nextSash reduceFirst = sash reduceLast = -int32(1) reduceIncr = -int32(1) } /* * Calculate how much room we have to stretch in and adjust diff value * accordingly. */ i = reduceFirst for { if !(i != reduceLast) { break } panePtr = *(*uintptr)(unsafe.Pointer((*TPanedWindow)(unsafe.Pointer(pwPtr)).Fpanes + uintptr(i)*8)) if (*TPane)(unsafe.Pointer(panePtr)).Fhide != 0 { goto _4 } XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), (*TPane)(unsafe.Pointer(panePtr)).Ftkwin, (*TPane)(unsafe.Pointer(panePtr)).FminSizeObj, bp+20) if horizontal != 0 { stretchReserve += (*TPane)(unsafe.Pointer(panePtr)).Fwidth - *(*int32)(unsafe.Pointer(bp + 20)) } else { stretchReserve += (*TPane)(unsafe.Pointer(panePtr)).Fheight - *(*int32)(unsafe.Pointer(bp + 20)) } goto _4 _4: ; i += reduceIncr } if stretchReserve <= 0 { return } if diff > stretchReserve { diff = stretchReserve } /* * Expand pane by diff amount. */ panePtr = *(*uintptr)(unsafe.Pointer((*TPanedWindow)(unsafe.Pointer(pwPtr)).Fpanes + uintptr(expandPane)*8)) if horizontal != 0 { p5 = panePtr + 128 *(*int32)(unsafe.Pointer(p5)) += diff (*TPane)(unsafe.Pointer(panePtr)).FpaneWidth = *(*int32)(unsafe.Pointer(p5)) } else { p6 = panePtr + 132 *(*int32)(unsafe.Pointer(p6)) += diff (*TPane)(unsafe.Pointer(panePtr)).FpaneHeight = *(*int32)(unsafe.Pointer(p6)) } /* * Reduce panes, respecting minsize, until diff amount has been used. */ i = reduceFirst for { if !(i != reduceLast) { break } panePtr = *(*uintptr)(unsafe.Pointer((*TPanedWindow)(unsafe.Pointer(pwPtr)).Fpanes + uintptr(i)*8)) if (*TPane)(unsafe.Pointer(panePtr)).Fhide != 0 { goto _7 } if horizontal != 0 { paneSize = (*TPane)(unsafe.Pointer(panePtr)).Fwidth } else { paneSize = (*TPane)(unsafe.Pointer(panePtr)).Fheight } XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), (*TPane)(unsafe.Pointer(panePtr)).Ftkwin, (*TPane)(unsafe.Pointer(panePtr)).FminSizeObj, bp+24) if diff > paneSize-*(*int32)(unsafe.Pointer(bp + 24)) { diff -= paneSize - *(*int32)(unsafe.Pointer(bp + 24)) paneSize = *(*int32)(unsafe.Pointer(bp + 24)) } else { paneSize -= diff i = reduceLast - reduceIncr } if horizontal != 0 { v8 = paneSize (*TPane)(unsafe.Pointer(panePtr)).Fwidth = v8 (*TPane)(unsafe.Pointer(panePtr)).FpaneWidth = v8 } else { v9 = paneSize (*TPane)(unsafe.Pointer(panePtr)).Fheight = v9 (*TPane)(unsafe.Pointer(panePtr)).FpaneHeight = v9 } goto _7 _7: ; i += reduceIncr } } /* *---------------------------------------------------------------------- * * ProxyWindowEventProc -- * * This function is invoked by the Tk dispatcher for various events on * paned window proxy windows. * * Results: * None. * * Side effects: * When the window gets deleted, internal structures get cleaned up. When * it gets exposed, it is redisplayed. * *-------------------------------------------------------------- */ func _ProxyWindowEventProc(tls *libc.TLS, clientData uintptr, eventPtr uintptr) { /* Information about event. */ var pwPtr uintptr _ = pwPtr pwPtr = clientData if (*TXEvent)(unsafe.Pointer(eventPtr)).Ftype1 == int32(Expose) { if (*TPanedWindow)(unsafe.Pointer(pwPtr)).Fproxywin != libc.UintptrFromInt32(0) && !((*TPanedWindow)(unsafe.Pointer(pwPtr)).Fflags&libc.Int32FromInt32(PROXY_REDRAW_PENDING) != 0) { libtcl9_0.XTcl_DoWhenIdle(tls, __ccgo_fp(_DisplayProxyWindow), pwPtr) *(*int32)(unsafe.Pointer(pwPtr + 224)) |= int32(PROXY_REDRAW_PENDING) } } } /* *-------------------------------------------------------------- * * DisplayProxyWindow -- * * This function redraws a paned window proxy window. It is invoked as a * do-when-idle handler, so it only runs when there's nothing else for * the application to do. * * Results: * None. * * Side effects: * Information appears on the screen. * *-------------------------------------------------------------- */ func _DisplayProxyWindow(tls *libc.TLS, clientData uintptr) { bp := tls.Alloc(16) defer tls.Free(16) /* Information about window. */ var pixmap TPixmap var pwPtr uintptr var tkwin TTk_Window var v1 TTk_3DBorder var v2 int32 var _ /* proxyBorderWidth at bp+0 */ int32 _, _, _, _, _ = pixmap, pwPtr, tkwin, v1, v2 pwPtr = clientData tkwin = (*TPanedWindow)(unsafe.Pointer(pwPtr)).Fproxywin *(*int32)(unsafe.Pointer(pwPtr + 224)) &= ^libc.Int32FromInt32(PROXY_REDRAW_PENDING) if tkwin == libc.UintptrFromInt32(0) || !((*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fflags&libc.Uint32FromInt32(TK_MAPPED) != 0) { return } /* * Create a pixmap for double-buffering, if necessary. */ pixmap = XTk_GetPixmap(tls, (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fdisplay, (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fwindow, (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fchanges.Fwidth, (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fchanges.Fheight, (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fdepth) /* * Redraw the widget's background and border. */ XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), tkwin, (*TPanedWindow)(unsafe.Pointer(pwPtr)).FproxyBorderWidthObj, bp) if (*TPanedWindow)(unsafe.Pointer(pwPtr)).FproxyBackground != 0 { v1 = (*TPanedWindow)(unsafe.Pointer(pwPtr)).FproxyBackground } else { v1 = (*TPanedWindow)(unsafe.Pointer(pwPtr)).Fbackground } if (*TPanedWindow)(unsafe.Pointer(pwPtr)).FproxyRelief != -int32(1) { v2 = (*TPanedWindow)(unsafe.Pointer(pwPtr)).FproxyRelief } else { v2 = (*TPanedWindow)(unsafe.Pointer(pwPtr)).FsashRelief } XTk_Fill3DRectangle(tls, tkwin, pixmap, v1, 0, 0, (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fchanges.Fwidth, (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fchanges.Fheight, *(*int32)(unsafe.Pointer(bp)), v2) /* * Copy the pixmap to the display. */ libx11.XXCopyArea(tls, (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fdisplay, pixmap, (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fwindow, (*TPanedWindow)(unsafe.Pointer(pwPtr)).Fgc, 0, 0, libc.Uint32FromInt32((*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fchanges.Fwidth), libc.Uint32FromInt32((*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fchanges.Fheight), 0, 0) XTk_FreePixmap(tls, (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fdisplay, pixmap) } /* *---------------------------------------------------------------------- * * PanedWindowProxyCommand -- * * Handles the panedwindow proxy subcommand. See the user documentation * for details. * * Results: * Standard Tcl result. * * Side effects: * May map or unmap the proxy sash. * *---------------------------------------------------------------------- */ func _PanedWindowProxyCommand(tls *libc.TLS, pwPtr uintptr, interp uintptr, objc int32, objv uintptr) (r int32) { bp := tls.Alloc(32) defer tls.Free(32) /* Argument objects. */ var internalBW, pwHeight, pwWidth, sashHeight int32 var _ /* coords at bp+16 */ [2]uintptr var _ /* index at bp+0 */ int32 var _ /* sashWidth at bp+12 */ int32 var _ /* x at bp+4 */ int32 var _ /* y at bp+8 */ int32 _, _, _, _ = internalBW, pwHeight, pwWidth, sashHeight if objc < int32(3) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(2), objv, __ccgo_ts+4953) return int32(TCL_ERROR) } if libtcl9_0.XTcl_GetIndexFromObjStruct(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), uintptr(unsafe.Pointer(&_optionStrings17)), libc.Int64FromUint64(libc.Uint64FromInt64(8)), __ccgo_ts+2689, libc.Int32FromInt32(0)|libc.Int32FromUint64(libc.Uint64FromInt64(4)< pwWidth { *(*int32)(unsafe.Pointer(bp + 4)) = pwWidth } *(*int32)(unsafe.Pointer(bp + 8)) = (*TTk_FakeWin)(unsafe.Pointer((*TPanedWindow)(unsafe.Pointer(pwPtr)).Ftkwin)).FinternalBorderLeft sashHeight = (*TTk_FakeWin)(unsafe.Pointer((*TPanedWindow)(unsafe.Pointer(pwPtr)).Ftkwin)).Fchanges.Fheight - int32(2)*(*TTk_FakeWin)(unsafe.Pointer((*TPanedWindow)(unsafe.Pointer(pwPtr)).Ftkwin)).FinternalBorderLeft } else { if *(*int32)(unsafe.Pointer(bp + 8)) < 0 { *(*int32)(unsafe.Pointer(bp + 8)) = 0 } pwHeight = (*TTk_FakeWin)(unsafe.Pointer((*TPanedWindow)(unsafe.Pointer(pwPtr)).Ftkwin)).Fchanges.Fheight - int32(2)*internalBW if *(*int32)(unsafe.Pointer(bp + 8)) > pwHeight { *(*int32)(unsafe.Pointer(bp + 8)) = pwHeight } *(*int32)(unsafe.Pointer(bp + 4)) = (*TTk_FakeWin)(unsafe.Pointer((*TPanedWindow)(unsafe.Pointer(pwPtr)).Ftkwin)).FinternalBorderLeft sashHeight = *(*int32)(unsafe.Pointer(bp + 12)) *(*int32)(unsafe.Pointer(bp + 12)) = (*TTk_FakeWin)(unsafe.Pointer((*TPanedWindow)(unsafe.Pointer(pwPtr)).Ftkwin)).Fchanges.Fwidth - int32(2)*(*TTk_FakeWin)(unsafe.Pointer((*TPanedWindow)(unsafe.Pointer(pwPtr)).Ftkwin)).FinternalBorderLeft } if *(*int32)(unsafe.Pointer(bp + 12)) < int32(1) { *(*int32)(unsafe.Pointer(bp + 12)) = int32(1) } if sashHeight < int32(1) { sashHeight = int32(1) } /* * Stash the proxy coordinates for future "proxy coord" calls. */ (*TPanedWindow)(unsafe.Pointer(pwPtr)).Fproxyx = *(*int32)(unsafe.Pointer(bp + 4)) (*TPanedWindow)(unsafe.Pointer(pwPtr)).Fproxyy = *(*int32)(unsafe.Pointer(bp + 8)) /* * Make sure the proxy window is higher in the stacking order than the * panes, so that it will be visible when drawn. It would be more * correct to push the proxy window just high enough to appear above * the highest pane, but it's much easier to just force it all the * way to the top of the stacking order. */ XTk_RestackWindow(tls, (*TPanedWindow)(unsafe.Pointer(pwPtr)).Fproxywin, Above, libc.UintptrFromInt32(0)) /* * Let Tk_MaintainGeometry take care of placing the window at the * right coordinates. */ XTk_MaintainGeometry(tls, (*TPanedWindow)(unsafe.Pointer(pwPtr)).Fproxywin, (*TPanedWindow)(unsafe.Pointer(pwPtr)).Ftkwin, *(*int32)(unsafe.Pointer(bp + 4)), *(*int32)(unsafe.Pointer(bp + 8)), *(*int32)(unsafe.Pointer(bp + 12)), sashHeight) break } return TCL_OK } var _optionStrings17 = [4]uintptr{ 0: __ccgo_ts + 25716, 1: __ccgo_ts + 4750, 2: __ccgo_ts + 15808, 3: libc.UintptrFromInt32(0), } /* *---------------------------------------------------------------------- * * ObjectIsEmpty -- * * This function tests whether the string value of an object is empty. * * Results: * The return value is 1 if the string value of objPtr has length zero, * and 0 otherwise. * * Side effects: * May cause object shimmering, since this function can force a * conversion to a string object. * *---------------------------------------------------------------------- */ func _ObjectIsEmpty1(tls *libc.TLS, objPtr uintptr) (r int32) { /* Object to test. May be NULL. */ if objPtr == libc.UintptrFromInt32(0) { return int32(1) } if (*TTcl_Obj)(unsafe.Pointer(objPtr)).Fbytes == libc.UintptrFromInt32(0) { libtcl9_0.XTcl_GetStringFromObj(tls, objPtr, libc.UintptrFromInt32(0)) } return libc.BoolInt32((*TTcl_Obj)(unsafe.Pointer(objPtr)).Flength == 0) } /* *---------------------------------------------------------------------- * * ComputeInternalPointer -- * * Given a pointer to the start of a record and the offset of a slot * within that record, compute the address of that slot. * * Results: * If offset is non-negative, returns the computed address; else, returns * NULL. * * Side effects: * None. * *---------------------------------------------------------------------- */ func _ComputeSlotAddress(tls *libc.TLS, recordPtr uintptr, offset TTcl_Size) (r uintptr) { /* Offset of a slot within that record; may be TCL_INDEX_NONE. */ if offset != int64(-libc.Int32FromInt32(1)) { return recordPtr + uintptr(offset) } else { return libc.UintptrFromInt32(0) } return r } /* *---------------------------------------------------------------------- * * PanedWindowIdentifyCoords -- * * Given a pair of x,y coordinates, identify the panedwindow component at * that point, if any. * * Results: * Standard Tcl result. * * Side effects: * Modifies the interpreter's result to contain either an empty list, or * a two element list of the form {sash n} or {handle n} to indicate that * the point lies within the n'th sash or handle. * *---------------------------------------------------------------------- */ func _PanedWindowIdentifyCoords(tls *libc.TLS, pwPtr uintptr, interp uintptr, x int32, y int32) (r int32) { bp := tls.Alloc(48) defer tls.Free(48) /* Coordinates of the point to identify. */ var bpad, found, i, isHandle, lpad, rpad, sashHeight, thisx, thisy, tpad, v1, v2, v3, v4 int32 var v6 uintptr var _ /* first at bp+4 */ int32 var _ /* handleSize at bp+12 */ int32 var _ /* last at bp+8 */ int32 var _ /* list at bp+24 */ [2]uintptr var _ /* sashPad at bp+16 */ int32 var _ /* sashWidth at bp+0 */ int32 _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = bpad, found, i, isHandle, lpad, rpad, sashHeight, thisx, thisy, tpad, v1, v2, v3, v4, v6 XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), (*TPanedWindow)(unsafe.Pointer(pwPtr)).Ftkwin, (*TPanedWindow)(unsafe.Pointer(pwPtr)).FhandleSizeObj, bp+12) XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), (*TPanedWindow)(unsafe.Pointer(pwPtr)).Ftkwin, (*TPanedWindow)(unsafe.Pointer(pwPtr)).FsashPadObj, bp+16) XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), (*TPanedWindow)(unsafe.Pointer(pwPtr)).Ftkwin, (*TPanedWindow)(unsafe.Pointer(pwPtr)).FsashWidthObj, bp) if (*TPanedWindow)(unsafe.Pointer(pwPtr)).Forient == int32(ORIENT_HORIZONTAL) { if (*TTk_FakeWin)(unsafe.Pointer((*TPanedWindow)(unsafe.Pointer(pwPtr)).Ftkwin)).Fflags&uint32(TK_MAPPED) != 0 { sashHeight = (*TTk_FakeWin)(unsafe.Pointer((*TPanedWindow)(unsafe.Pointer(pwPtr)).Ftkwin)).Fchanges.Fheight } else { sashHeight = (*TTk_FakeWin)(unsafe.Pointer((*TPanedWindow)(unsafe.Pointer(pwPtr)).Ftkwin)).FreqHeight } sashHeight -= int32(2) * (*TTk_FakeWin)(unsafe.Pointer((*TPanedWindow)(unsafe.Pointer(pwPtr)).Ftkwin)).FinternalBorderLeft if (*TPanedWindow)(unsafe.Pointer(pwPtr)).FshowHandle != 0 && *(*int32)(unsafe.Pointer(bp + 12)) > *(*int32)(unsafe.Pointer(bp)) { lpad = (*(*int32)(unsafe.Pointer(bp + 12)) - *(*int32)(unsafe.Pointer(bp))) / int32(2) rpad = *(*int32)(unsafe.Pointer(bp + 12)) - lpad lpad += *(*int32)(unsafe.Pointer(bp + 16)) rpad += *(*int32)(unsafe.Pointer(bp + 16)) *(*int32)(unsafe.Pointer(bp)) = *(*int32)(unsafe.Pointer(bp + 12)) } else { v1 = *(*int32)(unsafe.Pointer(bp + 16)) rpad = v1 lpad = v1 } v2 = libc.Int32FromInt32(0) bpad = v2 tpad = v2 } else { if (*TPanedWindow)(unsafe.Pointer(pwPtr)).FshowHandle != 0 && *(*int32)(unsafe.Pointer(bp + 12)) > *(*int32)(unsafe.Pointer(bp)) { sashHeight = *(*int32)(unsafe.Pointer(bp + 12)) tpad = (*(*int32)(unsafe.Pointer(bp + 12)) - *(*int32)(unsafe.Pointer(bp))) / int32(2) bpad = *(*int32)(unsafe.Pointer(bp + 12)) - tpad tpad += *(*int32)(unsafe.Pointer(bp + 16)) bpad += *(*int32)(unsafe.Pointer(bp + 16)) } else { sashHeight = *(*int32)(unsafe.Pointer(bp)) v3 = *(*int32)(unsafe.Pointer(bp + 16)) bpad = v3 tpad = v3 } if (*TTk_FakeWin)(unsafe.Pointer((*TPanedWindow)(unsafe.Pointer(pwPtr)).Ftkwin)).Fflags&uint32(TK_MAPPED) != 0 { *(*int32)(unsafe.Pointer(bp)) = (*TTk_FakeWin)(unsafe.Pointer((*TPanedWindow)(unsafe.Pointer(pwPtr)).Ftkwin)).Fchanges.Fwidth } else { *(*int32)(unsafe.Pointer(bp)) = (*TTk_FakeWin)(unsafe.Pointer((*TPanedWindow)(unsafe.Pointer(pwPtr)).Ftkwin)).FreqWidth } *(*int32)(unsafe.Pointer(bp)) -= int32(2) * (*TTk_FakeWin)(unsafe.Pointer((*TPanedWindow)(unsafe.Pointer(pwPtr)).Ftkwin)).FinternalBorderLeft v4 = libc.Int32FromInt32(0) rpad = v4 lpad = v4 } _GetFirstLastVisiblePane(tls, pwPtr, bp+4, bp+8) isHandle = 0 found = -int32(1) i = 0 for { if !(i < (*TPanedWindow)(unsafe.Pointer(pwPtr)).FnumPanes-int32(1)) { break } if (*TPane)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer((*TPanedWindow)(unsafe.Pointer(pwPtr)).Fpanes + uintptr(i)*8)))).Fhide != 0 || i == *(*int32)(unsafe.Pointer(bp + 8)) { goto _5 } thisx = (*TPane)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer((*TPanedWindow)(unsafe.Pointer(pwPtr)).Fpanes + uintptr(i)*8)))).Fsashx thisy = (*TPane)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer((*TPanedWindow)(unsafe.Pointer(pwPtr)).Fpanes + uintptr(i)*8)))).Fsashy if thisx-lpad <= x && x <= thisx+rpad+*(*int32)(unsafe.Pointer(bp)) && (thisy-tpad <= y && y <= thisy+bpad+sashHeight) { found = i /* * Determine if the point is over the handle or the sash. */ if (*TPanedWindow)(unsafe.Pointer(pwPtr)).FshowHandle != 0 { thisx = (*TPane)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer((*TPanedWindow)(unsafe.Pointer(pwPtr)).Fpanes + uintptr(i)*8)))).Fhandlex thisy = (*TPane)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer((*TPanedWindow)(unsafe.Pointer(pwPtr)).Fpanes + uintptr(i)*8)))).Fhandley if (*TPanedWindow)(unsafe.Pointer(pwPtr)).Forient == int32(ORIENT_HORIZONTAL) { if thisy <= y && y <= thisy+*(*int32)(unsafe.Pointer(bp + 12)) { isHandle = int32(1) } } else { if thisx <= x && x <= thisx+*(*int32)(unsafe.Pointer(bp + 12)) { isHandle = int32(1) } } } break } goto _5 _5: ; i++ } /* * Set results. Note that the empty string is the default (this function * is called inside the implementation of a command). */ if found != -int32(1) { (*(*[2]uintptr)(unsafe.Pointer(bp + 24)))[0] = libtcl9_0.XTcl_NewWideIntObj(tls, int64(found)) if isHandle != 0 { v6 = __ccgo_ts + 16289 } else { v6 = __ccgo_ts + 25499 } (*(*[2]uintptr)(unsafe.Pointer(bp + 24)))[int32(1)] = libtcl9_0.XTcl_NewStringObj(tls, v6, int64(-libc.Int32FromInt32(1))) libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewListObj(tls, int64(2), bp+24)) } return TCL_OK } const ACTIVE = 8 const GOT_FOCUS5 = 128 const INVOKE_COMMAND = 16 const NEVER_SET = 64 const OTHER = 0 const REDRAW_ALL = 3 const REDRAW_OTHER = 2 const REDRAW_PENDING1 = 4 const REDRAW_SLIDER = 1 const SCALE_DELETED = 256 const SETTING_VAR = 32 const SLIDER = 2 const SPACING = 2 const TICK_VALUES_DISPLAY_ACCURACY = 0.2 const TROUGH1 = 1 const TROUGH2 = 3 type TTkScale = struct { Ftkwin TTk_Window Fdisplay uintptr Finterp uintptr FwidgetCmd TTcl_Command FoptionTable TTk_OptionTable Forient orient FwidthObj uintptr FlengthObj uintptr Fvalue float64 FvarNamePtr uintptr FfromValue float64 FtoValue float64 FtickInterval float64 Fresolution float64 Fdigits int32 FvalueFormat [16]uint8 FtickFormat [16]uint8 FbigIncrement float64 FcommandObj uintptr FrepeatDelay int32 FrepeatInterval int32 FlabelObj uintptr Fstate state FborderWidthObj uintptr FbgBorder TTk_3DBorder FactiveBorder TTk_3DBorder FsliderRelief int32 FtroughColorPtr uintptr FtroughGC TGC FcopyGC TGC Ftkfont TTk_Font FtextColorPtr uintptr FtextGC TGC Frelief int32 FhighlightWidthObj uintptr FhighlightBorder TTk_3DBorder FhighlightColorPtr uintptr Finset int32 FsliderLengthObj uintptr FshowValue int32 FhorizLabelY int32 FhorizValueY int32 FhorizTroughY int32 FhorizTickY int32 FvertTickRightX int32 FvertValueRightX int32 FvertTroughX int32 FvertLabelX int32 FfontHeight int32 Fcursor TTk_Cursor FtakeFocusPtr uintptr Fflags int32 } /* * default.h -- * * This file defines the defaults for all options for all of * the Tk widgets. * * Copyright © 1991-1994 The Regents of the University of California. * Copyright © 1994 Sun Microsystems, Inc. * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. */ /* * tkUnixDefault.h -- * * This file defines the defaults for all options for all of * the Tk widgets. * * Copyright © 1991-1994 The Regents of the University of California. * Copyright © 1994-1997 Sun Microsystems, Inc. * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. */ /* * The definitions below provide symbolic names for the default colors. * NORMAL_BG - Normal background color. * ACTIVE_BG - Background color when widget is active. * SELECT_BG - Background color for selected text. * TROUGH - Background color for troughs in scales and scrollbars. * INDICATOR - Color for indicator when button is selected. * DISABLED - Foreground color when widget is disabled. * PLACEHOLDER_FG - Foreground color for placeholder text. */ /* * Defaults for labels, buttons, checkbuttons, and radiobuttons: */ /* * Defaults for canvases: */ /* * Defaults for entries: */ /* * Defaults for frames: */ /* * Defaults for labelframes: */ /* * Defaults for listboxes: */ /* * Defaults for individual entries of menus: */ /* * Defaults for menus overall: */ /* * Defaults for menubuttons: */ /* * Defaults for messages: */ /* * Defaults for panedwindows */ /* * Defaults for panedwindow panes */ /* * Defaults for scales: */ /* * Defaults for scrollbars: */ /* * Defaults for texts: */ /* * Defaults for canvas text: */ /* * Defaults for canvas items * (arcs, bitmaps, lines, polygons, rectangles, and ovals): */ /* * Defaults for toplevels (most of the defaults for frames also apply * to toplevels): */ /* * Defaults for busy windows: */ /* * The following table defines the legal values for the -orient option. It is * used together with the "enum orient" declaration in tkScale.h. */ var _orientStrings1 = [3]uintptr{ 0: __ccgo_ts + 16826, 1: __ccgo_ts + 16837, 2: libc.UintptrFromInt32(0), } var _optionSpecs7 = [34]TTk_OptionSpec{ 0: { Ftype1: int32(TK_OPTION_BORDER), FoptionName: __ccgo_ts + 19775, FdbName: __ccgo_ts + 19793, FdbClass: __ccgo_ts + 19810, FdefValue: __ccgo_ts + 19821, FobjOffset: int64(-libc.Int32FromInt32(1)), FinternalOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 208)), FclientData: __ccgo_ts + 19829, }, 1: { Ftype1: int32(TK_OPTION_BORDER), FoptionName: __ccgo_ts + 19898, FdbName: __ccgo_ts + 19910, FdbClass: __ccgo_ts + 19872, FdefValue: __ccgo_ts + 19921, FobjOffset: int64(-libc.Int32FromInt32(1)), FinternalOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 200)), FclientData: __ccgo_ts + 19883, }, 2: { Ftype1: int32(TK_OPTION_DOUBLE), FoptionName: __ccgo_ts + 25860, FdbName: __ccgo_ts + 25874, FdbClass: __ccgo_ts + 25887, FdefValue: __ccgo_ts + 14146, FobjOffset: int64(-libc.Int32FromInt32(1)), FinternalOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 152)), }, 3: { Ftype1: int32(TK_OPTION_SYNONYM), FoptionName: __ccgo_ts + 19929, FinternalOffset: int64(-libc.Int32FromInt32(1)), FclientData: __ccgo_ts + 2814, }, 4: { Ftype1: int32(TK_OPTION_SYNONYM), FoptionName: __ccgo_ts + 19933, FinternalOffset: int64(-libc.Int32FromInt32(1)), FclientData: __ccgo_ts + 19898, }, 5: { Ftype1: int32(TK_OPTION_PIXELS), FoptionName: __ccgo_ts + 2814, FdbName: __ccgo_ts + 19952, FdbClass: __ccgo_ts + 19964, FdefValue: __ccgo_ts + 14538, FobjOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 192)), FinternalOffset: int64(-libc.Int32FromInt32(1)), }, 6: { Ftype1: int32(TK_OPTION_STRING), FoptionName: __ccgo_ts + 16356, FdbName: __ccgo_ts + 20495, FdbClass: __ccgo_ts + 1659, FdefValue: __ccgo_ts + 195, FobjOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 160)), FinternalOffset: int64(-libc.Int32FromInt32(1)), Fflags: int32(TCL_NULL_OK), }, 7: { Ftype1: int32(TK_OPTION_CURSOR), FoptionName: __ccgo_ts + 4638, FdbName: __ccgo_ts + 4646, FdbClass: __ccgo_ts + 4653, FdefValue: __ccgo_ts + 195, FobjOffset: int64(-libc.Int32FromInt32(1)), FinternalOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 360)), Fflags: int32(TCL_NULL_OK), }, 8: { Ftype1: int32(TK_OPTION_INT), FoptionName: __ccgo_ts + 25900, FdbName: __ccgo_ts + 25908, FdbClass: __ccgo_ts + 25915, FdefValue: __ccgo_ts + 10533, FobjOffset: int64(-libc.Int32FromInt32(1)), FinternalOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 112)), }, 9: { Ftype1: int32(TK_OPTION_SYNONYM), FoptionName: __ccgo_ts + 20070, FdbName: __ccgo_ts + 20074, FinternalOffset: int64(-libc.Int32FromInt32(1)), FclientData: __ccgo_ts + 20085, }, 10: { Ftype1: int32(TK_OPTION_FONT), FoptionName: __ccgo_ts + 20097, FdbName: __ccgo_ts + 9358, FdbClass: __ccgo_ts + 20103, FdefValue: __ccgo_ts + 20108, FobjOffset: int64(-libc.Int32FromInt32(1)), FinternalOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 248)), }, 11: { Ftype1: int32(TK_OPTION_COLOR), FoptionName: __ccgo_ts + 20085, FdbName: __ccgo_ts + 20074, FdbClass: __ccgo_ts + 19810, FdefValue: __ccgo_ts + 19829, FobjOffset: int64(-libc.Int32FromInt32(1)), FinternalOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 256)), FclientData: __ccgo_ts + 19829, }, 12: { Ftype1: int32(TK_OPTION_DOUBLE), FoptionName: __ccgo_ts + 22037, FdbName: __ccgo_ts + 22043, FdbClass: __ccgo_ts + 22048, FdefValue: __ccgo_ts + 14146, FobjOffset: int64(-libc.Int32FromInt32(1)), FinternalOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 80)), }, 13: { Ftype1: int32(TK_OPTION_BORDER), FoptionName: __ccgo_ts + 20129, FdbName: __ccgo_ts + 20150, FdbClass: __ccgo_ts + 20170, FdefValue: __ccgo_ts + 19921, FobjOffset: int64(-libc.Int32FromInt32(1)), FinternalOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 288)), FclientData: __ccgo_ts + 19883, }, 14: { Ftype1: int32(TK_OPTION_COLOR), FoptionName: __ccgo_ts + 20190, FdbName: __ccgo_ts + 20206, FdbClass: __ccgo_ts + 20221, FdefValue: __ccgo_ts + 19829, FobjOffset: int64(-libc.Int32FromInt32(1)), FinternalOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 296)), }, 15: { Ftype1: int32(TK_OPTION_PIXELS), FoptionName: __ccgo_ts + 20236, FdbName: __ccgo_ts + 20256, FdbClass: __ccgo_ts + 20275, FdefValue: __ccgo_ts + 14538, FobjOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 280)), FinternalOffset: int64(-libc.Int32FromInt32(1)), }, 16: { Ftype1: int32(TK_OPTION_STRING), FoptionName: __ccgo_ts + 24191, FdbName: __ccgo_ts + 17899, FdbClass: __ccgo_ts + 19745, FdefValue: __ccgo_ts + 195, FobjOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 176)), FinternalOffset: int64(-libc.Int32FromInt32(1)), Fflags: int32(TCL_NULL_OK), }, 17: { Ftype1: int32(TK_OPTION_PIXELS), FoptionName: __ccgo_ts + 25922, FdbName: __ccgo_ts + 25930, FdbClass: __ccgo_ts + 25937, FdefValue: __ccgo_ts + 22092, FobjOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 56)), FinternalOffset: int64(-libc.Int32FromInt32(1)), }, 18: { Ftype1: int32(TK_OPTION_STRING_TABLE), FoptionName: __ccgo_ts + 25111, FdbName: __ccgo_ts + 25119, FdbClass: __ccgo_ts + 25126, FdefValue: __ccgo_ts + 16837, FobjOffset: int64(-libc.Int32FromInt32(1)), FinternalOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 40)), FclientData: uintptr(unsafe.Pointer(&_orientStrings1)), }, 19: { Ftype1: int32(TK_OPTION_RELIEF), FoptionName: __ccgo_ts + 20346, FdbName: __ccgo_ts + 82, FdbClass: __ccgo_ts + 20354, FdefValue: __ccgo_ts, FobjOffset: int64(-libc.Int32FromInt32(1)), FinternalOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 272)), }, 20: { Ftype1: int32(TK_OPTION_INT), FoptionName: __ccgo_ts + 20545, FdbName: __ccgo_ts + 20558, FdbClass: __ccgo_ts + 20570, FdefValue: __ccgo_ts + 21333, FobjOffset: int64(-libc.Int32FromInt32(1)), FinternalOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 168)), }, 21: { Ftype1: int32(TK_OPTION_INT), FoptionName: __ccgo_ts + 20582, FdbName: __ccgo_ts + 20598, FdbClass: __ccgo_ts + 20613, FdefValue: __ccgo_ts + 22092, FobjOffset: int64(-libc.Int32FromInt32(1)), FinternalOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 172)), }, 22: { Ftype1: int32(TK_OPTION_DOUBLE), FoptionName: __ccgo_ts + 25944, FdbName: __ccgo_ts + 25956, FdbClass: __ccgo_ts + 25967, FdefValue: __ccgo_ts + 22084, FobjOffset: int64(-libc.Int32FromInt32(1)), FinternalOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 104)), }, 23: { FoptionName: __ccgo_ts + 25978, FdbName: __ccgo_ts + 25989, FdbClass: __ccgo_ts + 25999, FdefValue: __ccgo_ts + 14538, FobjOffset: int64(-libc.Int32FromInt32(1)), FinternalOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 320)), }, 24: { Ftype1: int32(TK_OPTION_PIXELS), FoptionName: __ccgo_ts + 26009, FdbName: __ccgo_ts + 26023, FdbClass: __ccgo_ts + 26036, FdefValue: __ccgo_ts + 26049, FobjOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 312)), FinternalOffset: int64(-libc.Int32FromInt32(1)), }, 25: { Ftype1: int32(TK_OPTION_RELIEF), FoptionName: __ccgo_ts + 26052, FdbName: __ccgo_ts + 26066, FdbClass: __ccgo_ts + 26079, FdefValue: __ccgo_ts + 12, FobjOffset: int64(-libc.Int32FromInt32(1)), FinternalOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 216)), }, 26: { Ftype1: int32(TK_OPTION_STRING_TABLE), FoptionName: __ccgo_ts + 2957, FdbName: __ccgo_ts + 16747, FdbClass: __ccgo_ts + 20361, FdefValue: __ccgo_ts + 9363, FobjOffset: int64(-libc.Int32FromInt32(1)), FinternalOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 184)), FclientData: uintptr(unsafe.Pointer(&XtkStateStrings)), }, 27: { Ftype1: int32(TK_OPTION_STRING), FoptionName: __ccgo_ts + 20367, FdbName: __ccgo_ts + 20378, FdbClass: __ccgo_ts + 20388, FobjOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 368)), FinternalOffset: int64(-libc.Int32FromInt32(1)), Fflags: int32(TCL_NULL_OK), }, 28: { Ftype1: int32(TK_OPTION_DOUBLE), FoptionName: __ccgo_ts + 26092, FdbName: __ccgo_ts + 26106, FdbClass: __ccgo_ts + 26119, FdefValue: __ccgo_ts + 14146, FobjOffset: int64(-libc.Int32FromInt32(1)), FinternalOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 96)), }, 29: { Ftype1: int32(TK_OPTION_DOUBLE), FoptionName: __ccgo_ts + 22096, FdbName: __ccgo_ts + 22100, FdbClass: __ccgo_ts + 22103, FdefValue: __ccgo_ts + 26132, FobjOffset: int64(-libc.Int32FromInt32(1)), FinternalOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 88)), }, 30: { Ftype1: int32(TK_OPTION_COLOR), FoptionName: __ccgo_ts + 26138, FdbName: __ccgo_ts + 26151, FdbClass: __ccgo_ts + 19872, FdefValue: __ccgo_ts + 21572, FobjOffset: int64(-libc.Int32FromInt32(1)), FinternalOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 224)), FclientData: __ccgo_ts + 19883, }, 31: { Ftype1: int32(TK_OPTION_STRING), FoptionName: __ccgo_ts + 20886, FdbName: __ccgo_ts + 5913, FdbClass: __ccgo_ts + 20436, FdefValue: __ccgo_ts + 195, FobjOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 72)), FinternalOffset: int64(-libc.Int32FromInt32(1)), Fflags: int32(TCL_NULL_OK), }, 32: { Ftype1: int32(TK_OPTION_PIXELS), FoptionName: __ccgo_ts + 2987, FdbName: __ccgo_ts + 6446, FdbClass: __ccgo_ts + 20455, FdefValue: __ccgo_ts + 26163, FobjOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 48)), FinternalOffset: int64(-libc.Int32FromInt32(1)), }, 33: { Ftype1: int32(TK_OPTION_END), FinternalOffset: int64(-libc.Int32FromInt32(1)), }, } /* * The following tables define the scale widget commands and map the indexes * into the string tables into a single enumerated type used to dispatch the * scale widget command. */ var _commandNames3 = [7]uintptr{ 0: __ccgo_ts + 4735, 1: __ccgo_ts + 4740, 2: __ccgo_ts + 26166, 3: __ccgo_ts + 4949, 4: __ccgo_ts + 22197, 5: __ccgo_ts + 11726, 6: libc.UintptrFromInt32(0), } const COMMAND_COORDS = 2 const COMMAND_GET2 = 3 const COMMAND_IDENTIFY = 4 const COMMAND_SET = 5 /* * The structure below defines scale class behavior by means of procedures * that can be invoked from generic window code. */ var _scaleClass = TTk_ClassProcs{ Fsize: int64(32), } func init() { p := unsafe.Pointer(&_scaleClass) *(*uintptr)(unsafe.Add(p, 8)) = __ccgo_fp(_ScaleWorldChanged) } /* *-------------------------------------------------------------- * * ScaleDigit, ScaleMax, ScaleMin, ScaleRound -- * * Simple math helper functions, designed to be automatically inlined by * the compiler most of the time. * *-------------------------------------------------------------- */ func _ScaleDigit(tls *libc.TLS, value float64) (r int32) { return int32(libc.Xfloor(tls, libc.Xlog10(tls, libc.Xfabs(tls, value)))) } func _ScaleMax(tls *libc.TLS, a float64, b float64) (r float64) { var v1 float64 _ = v1 if a > b { v1 = a } else { v1 = b } return v1 } func _ScaleMin(tls *libc.TLS, a float64, b float64) (r float64) { var v1 float64 _ = v1 if a < b { v1 = a } else { v1 = b } return v1 } func _ScaleRound(tls *libc.TLS, value float64) (r int32) { return int32(libc.Xfloor(tls, value+float64(0.5))) } /* *-------------------------------------------------------------- * * Tk_ScaleObjCmd -- * * This procedure is invoked to process the "scale" Tcl command. See the * user documentation for details on what it does. * * Results: * A standard Tcl result. * * Side effects: * See the user documentation. * *-------------------------------------------------------------- */ func XTk_ScaleObjCmd(tls *libc.TLS, dummy240 uintptr, interp uintptr, objc int32, objv uintptr) (r int32) { /* Argument values. */ var optionTable TTk_OptionTable var scalePtr uintptr var tkwin TTk_Window _, _, _ = optionTable, scalePtr, tkwin if objc < int32(2) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(1), objv, __ccgo_ts+20960) return int32(TCL_ERROR) } tkwin = XTk_CreateWindowFromPath(tls, interp, XTk_MainWindow(tls, interp), libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8)), libc.UintptrFromInt32(0)), libc.UintptrFromInt32(0)) if tkwin == libc.UintptrFromInt32(0) { return int32(TCL_ERROR) } /* * Create the option table for this widget class. If it has already been * created, the cached pointer will be returned. */ optionTable = XTk_CreateOptionTable(tls, interp, uintptr(unsafe.Pointer(&_optionSpecs7))) XTk_SetClass(tls, tkwin, __ccgo_ts+26173) scalePtr = XTkpCreateScale(tls, tkwin) /* * Initialize fields that won't be initialized by ConfigureScale, or which * ConfigureScale expects to have reasonable values (e.g. resource * pointers). */ (*TTkScale)(unsafe.Pointer(scalePtr)).Ftkwin = tkwin (*TTkScale)(unsafe.Pointer(scalePtr)).Fdisplay = (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fdisplay (*TTkScale)(unsafe.Pointer(scalePtr)).Finterp = interp (*TTkScale)(unsafe.Pointer(scalePtr)).FwidgetCmd = libtcl9_0.XTcl_CreateObjCommand(tls, interp, (*TTk_FakeWin)(unsafe.Pointer((*TTkScale)(unsafe.Pointer(scalePtr)).Ftkwin)).FpathName, __ccgo_fp(_ScaleWidgetObjCmd), scalePtr, __ccgo_fp(_ScaleCmdDeletedProc)) (*TTkScale)(unsafe.Pointer(scalePtr)).FoptionTable = optionTable (*TTkScale)(unsafe.Pointer(scalePtr)).Forient = int32(ORIENT_VERTICAL) (*TTkScale)(unsafe.Pointer(scalePtr)).FwidthObj = libc.UintptrFromInt32(0) (*TTkScale)(unsafe.Pointer(scalePtr)).FlengthObj = libc.UintptrFromInt32(0) (*TTkScale)(unsafe.Pointer(scalePtr)).Fvalue = float64(0) (*TTkScale)(unsafe.Pointer(scalePtr)).FvarNamePtr = libc.UintptrFromInt32(0) (*TTkScale)(unsafe.Pointer(scalePtr)).FfromValue = float64(0) (*TTkScale)(unsafe.Pointer(scalePtr)).FtoValue = float64(0) (*TTkScale)(unsafe.Pointer(scalePtr)).FtickInterval = float64(0) (*TTkScale)(unsafe.Pointer(scalePtr)).Fresolution = float64(1) (*TTkScale)(unsafe.Pointer(scalePtr)).Fdigits = 0 (*TTkScale)(unsafe.Pointer(scalePtr)).FbigIncrement = float64(0) (*TTkScale)(unsafe.Pointer(scalePtr)).FcommandObj = libc.UintptrFromInt32(0) (*TTkScale)(unsafe.Pointer(scalePtr)).FrepeatDelay = 0 (*TTkScale)(unsafe.Pointer(scalePtr)).FrepeatInterval = 0 (*TTkScale)(unsafe.Pointer(scalePtr)).FlabelObj = libc.UintptrFromInt32(0) (*TTkScale)(unsafe.Pointer(scalePtr)).Fstate = int32(STATE_NORMAL2) (*TTkScale)(unsafe.Pointer(scalePtr)).FborderWidthObj = libc.UintptrFromInt32(0) (*TTkScale)(unsafe.Pointer(scalePtr)).FbgBorder = libc.UintptrFromInt32(0) (*TTkScale)(unsafe.Pointer(scalePtr)).FactiveBorder = libc.UintptrFromInt32(0) (*TTkScale)(unsafe.Pointer(scalePtr)).FsliderRelief = int32(TK_RELIEF_RAISED) (*TTkScale)(unsafe.Pointer(scalePtr)).FtroughColorPtr = libc.UintptrFromInt32(0) (*TTkScale)(unsafe.Pointer(scalePtr)).FtroughGC = libc.UintptrFromInt32(0) (*TTkScale)(unsafe.Pointer(scalePtr)).FcopyGC = libc.UintptrFromInt32(0) (*TTkScale)(unsafe.Pointer(scalePtr)).Ftkfont = libc.UintptrFromInt32(0) (*TTkScale)(unsafe.Pointer(scalePtr)).FtextColorPtr = libc.UintptrFromInt32(0) (*TTkScale)(unsafe.Pointer(scalePtr)).FtextGC = libc.UintptrFromInt32(0) (*TTkScale)(unsafe.Pointer(scalePtr)).Frelief = TK_RELIEF_FLAT (*TTkScale)(unsafe.Pointer(scalePtr)).FhighlightWidthObj = libc.UintptrFromInt32(0) (*TTkScale)(unsafe.Pointer(scalePtr)).FhighlightBorder = libc.UintptrFromInt32(0) (*TTkScale)(unsafe.Pointer(scalePtr)).FhighlightColorPtr = libc.UintptrFromInt32(0) (*TTkScale)(unsafe.Pointer(scalePtr)).Finset = 0 (*TTkScale)(unsafe.Pointer(scalePtr)).FsliderLengthObj = libc.UintptrFromInt32(0) (*TTkScale)(unsafe.Pointer(scalePtr)).FshowValue = 0 (*TTkScale)(unsafe.Pointer(scalePtr)).FhorizLabelY = 0 (*TTkScale)(unsafe.Pointer(scalePtr)).FhorizValueY = 0 (*TTkScale)(unsafe.Pointer(scalePtr)).FhorizTroughY = 0 (*TTkScale)(unsafe.Pointer(scalePtr)).FhorizTickY = 0 (*TTkScale)(unsafe.Pointer(scalePtr)).FvertTickRightX = 0 (*TTkScale)(unsafe.Pointer(scalePtr)).FvertValueRightX = 0 (*TTkScale)(unsafe.Pointer(scalePtr)).FvertTroughX = 0 (*TTkScale)(unsafe.Pointer(scalePtr)).FvertLabelX = 0 (*TTkScale)(unsafe.Pointer(scalePtr)).FfontHeight = 0 (*TTkScale)(unsafe.Pointer(scalePtr)).Fcursor = libc.UintptrFromInt32(0) (*TTkScale)(unsafe.Pointer(scalePtr)).FtakeFocusPtr = libc.UintptrFromInt32(0) (*TTkScale)(unsafe.Pointer(scalePtr)).Fflags = libc.Int32FromInt32(1) << libc.Int32FromInt32(6) XTk_SetClassProcs(tls, (*TTkScale)(unsafe.Pointer(scalePtr)).Ftkwin, uintptr(unsafe.Pointer(&_scaleClass)), scalePtr) XTk_CreateEventHandler(tls, (*TTkScale)(unsafe.Pointer(scalePtr)).Ftkwin, libc.Uint64FromInt64(libc.Int64FromInt64(1)< maxValue { maxValue = x } if maxValue == libc.Float64FromInt32(0) { maxValue = libc.Float64FromInt32(1) } mostSigDigit = _ScaleDigit(tls, maxValue) if forTicks != 0 { /* * Display only enough digits to ensure adjacent ticks have different * values. */ if (*TTkScale)(unsafe.Pointer(scalePtr)).FtickInterval != libc.Float64FromInt32(0) { leastSigDigit = _ScaleDigit(tls, (*TTkScale)(unsafe.Pointer(scalePtr)).FtickInterval) /* * Now add more digits until max error is less than * TICK_VALUES_DISPLAY_ACCURACY intervals */ for _MaxTickRoundingError(tls, scalePtr, libc.Xpow(tls, libc.Float64FromInt32(10), float64(leastSigDigit))) > libc.Xfabs(tls, float64(float64(TICK_VALUES_DISPLAY_ACCURACY)*(*TTkScale)(unsafe.Pointer(scalePtr)).FtickInterval)) { leastSigDigit-- } numDigits = int32(1) + mostSigDigit - leastSigDigit } else { numDigits = int32(1) } } else { /* * If the number of significant digits wasn't specified explicitly, * compute it. It's the difference between the most significant digit * needed to represent any number on the scale and the most * significant digit of the smallest difference between numbers on the * scale. In other words, display enough digits so that at least one * digit will be different between any two adjacent positions of the * scale. */ numDigits = (*TTkScale)(unsafe.Pointer(scalePtr)).Fdigits if numDigits > int32(TCL_MAX_PREC) { numDigits = 0 } if numDigits <= 0 { if (*TTkScale)(unsafe.Pointer(scalePtr)).Fresolution > libc.Float64FromInt32(0) { /* * A resolution was specified for the scale, so just use it. */ leastSigDigit = _ScaleDigit(tls, (*TTkScale)(unsafe.Pointer(scalePtr)).Fresolution) } else { x = libc.Xfabs(tls, (*TTkScale)(unsafe.Pointer(scalePtr)).FfromValue-(*TTkScale)(unsafe.Pointer(scalePtr)).FtoValue) XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), (*TTkScale)(unsafe.Pointer(scalePtr)).Ftkwin, (*TTkScale)(unsafe.Pointer(scalePtr)).FlengthObj, bp) if *(*int32)(unsafe.Pointer(bp)) > 0 { x /= float64(*(*int32)(unsafe.Pointer(bp))) } if x > libc.Float64FromInt32(0) { leastSigDigit = _ScaleDigit(tls, x) } else { leastSigDigit = 0 } } numDigits = mostSigDigit - leastSigDigit + int32(1) if numDigits < int32(1) { numDigits = int32(1) } } } /* * Compute the number of characters required using "e" format and "f" * format, and then choose whichever one takes fewer characters. */ eDigits = numDigits + int32(4) if numDigits > int32(1) { eDigits++ /* Decimal point. */ } afterDecimal = numDigits - mostSigDigit - int32(1) if afterDecimal < 0 { afterDecimal = 0 } if mostSigDigit >= 0 { v1 = mostSigDigit + afterDecimal } else { v1 = afterDecimal } fDigits = v1 if afterDecimal > 0 { fDigits++ /* Decimal point. */ } if mostSigDigit < 0 { fDigits++ /* Zero to left of decimal point. */ } if forTicks != 0 { if fDigits <= eDigits { libc.X__builtin_snprintf(tls, scalePtr+132, uint64(16), __ccgo_ts+22905, libc.VaList(bp+16, afterDecimal)) } else { libc.X__builtin_snprintf(tls, scalePtr+132, uint64(16), __ccgo_ts+22912, libc.VaList(bp+16, numDigits-int32(1))) } } else { if fDigits <= eDigits { libc.X__builtin_snprintf(tls, scalePtr+116, uint64(16), __ccgo_ts+22905, libc.VaList(bp+16, afterDecimal)) } else { libc.X__builtin_snprintf(tls, scalePtr+116, uint64(16), __ccgo_ts+22912, libc.VaList(bp+16, numDigits-int32(1))) } } } /* *---------------------------------------------------------------------- * * ComputeScaleGeometry -- * * This procedure is called to compute various geometrical information * for a scale, such as where various things get displayed. It's called * when the window is reconfigured. * * Results: * None. * * Side effects: * Display-related numbers get changed in *scalePtr. The geometry manager * gets told about the window's preferred size. * *---------------------------------------------------------------------- */ func _ComputeScaleGeometry(tls *libc.TLS, scalePtr uintptr) { bp := tls.Alloc(80) defer tls.Free(80) /* Information about widget. */ var extraSpace, tickPixels, tmp, valuePixels, x, y int32 var label uintptr var _ /* borderWidth at bp+48 */ int32 var _ /* fm at bp+28 */ TTk_FontMetrics var _ /* labelLength at bp+56 */ TTcl_Size var _ /* length at bp+40 */ int32 var _ /* valueString at bp+0 */ [27]uint8 var _ /* width at bp+44 */ int32 _, _, _, _, _, _, _ = extraSpace, label, tickPixels, tmp, valuePixels, x, y XTk_GetFontMetrics(tls, (*TTkScale)(unsafe.Pointer(scalePtr)).Ftkfont, bp+28) (*TTkScale)(unsafe.Pointer(scalePtr)).FfontHeight = (*(*TTk_FontMetrics)(unsafe.Pointer(bp + 28))).Flinespace + int32(SPACING) /* * Horizontal scales are simpler than vertical ones because all sizes are * the same (the height of a line of text); handle them first and then * quit. */ if (*TTkScale)(unsafe.Pointer(scalePtr)).Forient == int32(ORIENT_HORIZONTAL) { y = (*TTkScale)(unsafe.Pointer(scalePtr)).Finset extraSpace = 0 if (*TTkScale)(unsafe.Pointer(scalePtr)).FlabelObj != libc.UintptrFromInt32(0) { (*TTkScale)(unsafe.Pointer(scalePtr)).FhorizLabelY = y + int32(SPACING) y += (*TTkScale)(unsafe.Pointer(scalePtr)).FfontHeight extraSpace = int32(SPACING) } if (*TTkScale)(unsafe.Pointer(scalePtr)).FshowValue != 0 { (*TTkScale)(unsafe.Pointer(scalePtr)).FhorizValueY = y + int32(SPACING) y += (*TTkScale)(unsafe.Pointer(scalePtr)).FfontHeight extraSpace = int32(SPACING) } else { (*TTkScale)(unsafe.Pointer(scalePtr)).FhorizValueY = y } y += extraSpace (*TTkScale)(unsafe.Pointer(scalePtr)).FhorizTroughY = y XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), (*TTkScale)(unsafe.Pointer(scalePtr)).Ftkwin, (*TTkScale)(unsafe.Pointer(scalePtr)).FlengthObj, bp+40) XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), (*TTkScale)(unsafe.Pointer(scalePtr)).Ftkwin, (*TTkScale)(unsafe.Pointer(scalePtr)).FwidthObj, bp+44) XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), (*TTkScale)(unsafe.Pointer(scalePtr)).Ftkwin, (*TTkScale)(unsafe.Pointer(scalePtr)).FborderWidthObj, bp+48) y += *(*int32)(unsafe.Pointer(bp + 44)) + int32(2)**(*int32)(unsafe.Pointer(bp + 48)) if (*TTkScale)(unsafe.Pointer(scalePtr)).FtickInterval != libc.Float64FromInt32(0) { (*TTkScale)(unsafe.Pointer(scalePtr)).FhorizTickY = y + int32(SPACING) y += (*TTkScale)(unsafe.Pointer(scalePtr)).FfontHeight + int32(SPACING) } XTk_GeometryRequest(tls, (*TTkScale)(unsafe.Pointer(scalePtr)).Ftkwin, *(*int32)(unsafe.Pointer(bp + 40))+int32(2)*(*TTkScale)(unsafe.Pointer(scalePtr)).Finset, y+(*TTkScale)(unsafe.Pointer(scalePtr)).Finset) XTk_SetInternalBorder(tls, (*TTkScale)(unsafe.Pointer(scalePtr)).Ftkwin, (*TTkScale)(unsafe.Pointer(scalePtr)).Finset) return } /* * Vertical scale: compute the amount of space needed to display the * scales value by formatting strings for the two end points; use * whichever length is longer. */ if libc.X__builtin_snprintf(tls, bp, libc.Uint64FromInt32(libc.Int32FromInt32(TCL_MAX_PREC)+libc.Int32FromInt32(10)), scalePtr+116, libc.VaList(bp+72, (*TTkScale)(unsafe.Pointer(scalePtr)).FfromValue)) < 0 { (*(*[27]uint8)(unsafe.Pointer(bp)))[libc.Int32FromInt32(TCL_MAX_PREC)+libc.Int32FromInt32(10)-libc.Int32FromInt32(1)] = uint8('\000') } valuePixels = XTk_TextWidth(tls, (*TTkScale)(unsafe.Pointer(scalePtr)).Ftkfont, bp, int64(-int32(1))) if libc.X__builtin_snprintf(tls, bp, libc.Uint64FromInt32(libc.Int32FromInt32(TCL_MAX_PREC)+libc.Int32FromInt32(10)), scalePtr+116, libc.VaList(bp+72, (*TTkScale)(unsafe.Pointer(scalePtr)).FtoValue)) < 0 { (*(*[27]uint8)(unsafe.Pointer(bp)))[libc.Int32FromInt32(TCL_MAX_PREC)+libc.Int32FromInt32(10)-libc.Int32FromInt32(1)] = uint8('\000') } tmp = XTk_TextWidth(tls, (*TTkScale)(unsafe.Pointer(scalePtr)).Ftkfont, bp, int64(-int32(1))) if valuePixels < tmp { valuePixels = tmp } /* * Now do the same thing for the tick values */ if libc.X__builtin_snprintf(tls, bp, libc.Uint64FromInt32(libc.Int32FromInt32(TCL_MAX_PREC)+libc.Int32FromInt32(10)), scalePtr+132, libc.VaList(bp+72, (*TTkScale)(unsafe.Pointer(scalePtr)).FfromValue)) < 0 { (*(*[27]uint8)(unsafe.Pointer(bp)))[libc.Int32FromInt32(TCL_MAX_PREC)+libc.Int32FromInt32(10)-libc.Int32FromInt32(1)] = uint8('\000') } tickPixels = XTk_TextWidth(tls, (*TTkScale)(unsafe.Pointer(scalePtr)).Ftkfont, bp, int64(-int32(1))) if libc.X__builtin_snprintf(tls, bp, libc.Uint64FromInt32(libc.Int32FromInt32(TCL_MAX_PREC)+libc.Int32FromInt32(10)), scalePtr+132, libc.VaList(bp+72, (*TTkScale)(unsafe.Pointer(scalePtr)).FtoValue)) < 0 { (*(*[27]uint8)(unsafe.Pointer(bp)))[libc.Int32FromInt32(TCL_MAX_PREC)+libc.Int32FromInt32(10)-libc.Int32FromInt32(1)] = uint8('\000') } tmp = XTk_TextWidth(tls, (*TTkScale)(unsafe.Pointer(scalePtr)).Ftkfont, bp, int64(-int32(1))) if tickPixels < tmp { tickPixels = tmp } /* * Assign x-locations to the elements of the scale, working from left to * right. */ x = (*TTkScale)(unsafe.Pointer(scalePtr)).Finset if (*TTkScale)(unsafe.Pointer(scalePtr)).FtickInterval != libc.Float64FromInt32(0) && (*TTkScale)(unsafe.Pointer(scalePtr)).FshowValue != 0 { (*TTkScale)(unsafe.Pointer(scalePtr)).FvertTickRightX = x + int32(SPACING) + tickPixels (*TTkScale)(unsafe.Pointer(scalePtr)).FvertValueRightX = (*TTkScale)(unsafe.Pointer(scalePtr)).FvertTickRightX + valuePixels + (*(*TTk_FontMetrics)(unsafe.Pointer(bp + 28))).Fascent/int32(2) x = (*TTkScale)(unsafe.Pointer(scalePtr)).FvertValueRightX + int32(SPACING) } else { if (*TTkScale)(unsafe.Pointer(scalePtr)).FtickInterval != libc.Float64FromInt32(0) { (*TTkScale)(unsafe.Pointer(scalePtr)).FvertTickRightX = x + int32(SPACING) + tickPixels (*TTkScale)(unsafe.Pointer(scalePtr)).FvertValueRightX = (*TTkScale)(unsafe.Pointer(scalePtr)).FvertTickRightX x = (*TTkScale)(unsafe.Pointer(scalePtr)).FvertTickRightX + int32(SPACING) } else { if (*TTkScale)(unsafe.Pointer(scalePtr)).FshowValue != 0 { (*TTkScale)(unsafe.Pointer(scalePtr)).FvertTickRightX = x (*TTkScale)(unsafe.Pointer(scalePtr)).FvertValueRightX = x + int32(SPACING) + valuePixels x = (*TTkScale)(unsafe.Pointer(scalePtr)).FvertValueRightX + int32(SPACING) } else { (*TTkScale)(unsafe.Pointer(scalePtr)).FvertTickRightX = x (*TTkScale)(unsafe.Pointer(scalePtr)).FvertValueRightX = x } } } (*TTkScale)(unsafe.Pointer(scalePtr)).FvertTroughX = x XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), (*TTkScale)(unsafe.Pointer(scalePtr)).Ftkwin, (*TTkScale)(unsafe.Pointer(scalePtr)).FborderWidthObj, bp+48) XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), (*TTkScale)(unsafe.Pointer(scalePtr)).Ftkwin, (*TTkScale)(unsafe.Pointer(scalePtr)).FwidthObj, bp+44) x += int32(2)**(*int32)(unsafe.Pointer(bp + 48)) + *(*int32)(unsafe.Pointer(bp + 44)) if (*TTkScale)(unsafe.Pointer(scalePtr)).FlabelObj == libc.UintptrFromInt32(0) { (*TTkScale)(unsafe.Pointer(scalePtr)).FvertLabelX = 0 } else { label = libtcl9_0.XTcl_GetStringFromObj(tls, (*TTkScale)(unsafe.Pointer(scalePtr)).FlabelObj, bp+56) (*TTkScale)(unsafe.Pointer(scalePtr)).FvertLabelX = x + (*(*TTk_FontMetrics)(unsafe.Pointer(bp + 28))).Fascent/int32(2) x = (*TTkScale)(unsafe.Pointer(scalePtr)).FvertLabelX + (*(*TTk_FontMetrics)(unsafe.Pointer(bp + 28))).Fascent/int32(2) + XTk_TextWidth(tls, (*TTkScale)(unsafe.Pointer(scalePtr)).Ftkfont, label, *(*TTcl_Size)(unsafe.Pointer(bp + 56))) } XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), (*TTkScale)(unsafe.Pointer(scalePtr)).Ftkwin, (*TTkScale)(unsafe.Pointer(scalePtr)).FlengthObj, bp+40) XTk_GeometryRequest(tls, (*TTkScale)(unsafe.Pointer(scalePtr)).Ftkwin, x+(*TTkScale)(unsafe.Pointer(scalePtr)).Finset, *(*int32)(unsafe.Pointer(bp + 40))+int32(2)*(*TTkScale)(unsafe.Pointer(scalePtr)).Finset) XTk_SetInternalBorder(tls, (*TTkScale)(unsafe.Pointer(scalePtr)).Ftkwin, (*TTkScale)(unsafe.Pointer(scalePtr)).Finset) } /* *-------------------------------------------------------------- * * ScaleEventProc -- * * This procedure is invoked by the Tk dispatcher for various events on * scales. * * Results: * None. * * Side effects: * When the window gets deleted, internal structures get cleaned up. * When it gets exposed, it is redisplayed. * *-------------------------------------------------------------- */ func _ScaleEventProc(tls *libc.TLS, clientData uintptr, eventPtr uintptr) { bp := tls.Alloc(16) defer tls.Free(16) /* Information about event. */ var scalePtr uintptr var _ /* highlightWidth at bp+0 */ int32 _ = scalePtr scalePtr = clientData if (*TXEvent)(unsafe.Pointer(eventPtr)).Ftype1 == int32(Expose) && (*(*TXExposeEvent)(unsafe.Pointer(eventPtr))).Fcount == 0 { XTkEventuallyRedrawScale(tls, scalePtr, libc.Int32FromInt32(1)< 0 { XTkEventuallyRedrawScale(tls, scalePtr, libc.Int32FromInt32(1)< 0 { XTkEventuallyRedrawScale(tls, scalePtr, libc.Int32FromInt32(1)<= (*TTkScale)(unsafe.Pointer(scalePtr)).Fresolution/libc.Float64FromInt32(2) { rounded = float64((tick + float64(1)) * (*TTkScale)(unsafe.Pointer(scalePtr)).Fresolution) } } return rounded } /* *---------------------------------------------------------------------- * * ScaleVarProc -- * * This procedure is invoked by Tcl whenever someone modifies a variable * associated with a scale widget. * * Results: * NULL is always returned. * * Side effects: * The value displayed in the scale will change to match the variable's * new value. If the variable has a bogus value then it is reset to the * value of the scale. * *---------------------------------------------------------------------- */ func _ScaleVarProc(tls *libc.TLS, clientData uintptr, interp uintptr, dummy1355 uintptr, dummy1356 uintptr, flags int32) (r uintptr) { bp := tls.Alloc(16) defer tls.Free(16) /* Information about what happened. */ var probe, resultStr, scalePtr, valuePtr uintptr var result int32 var _ /* value at bp+0 */ float64 _, _, _, _, _ = probe, result, resultStr, scalePtr, valuePtr scalePtr = clientData /* * If the variable is unset, then immediately recreate it unless the whole * interpreter is going away. */ if flags&int32(TCL_TRACE_UNSETS) != 0 { if !(libtcl9_0.XTcl_InterpDeleted(tls, interp) != 0) && (*TTkScale)(unsafe.Pointer(scalePtr)).FvarNamePtr != 0 { probe = libc.UintptrFromInt32(0) for cond := true; cond; cond = probe != 0 { probe = libtcl9_0.XTcl_VarTraceInfo2(tls, interp, libtcl9_0.XTcl_GetStringFromObj(tls, (*TTkScale)(unsafe.Pointer(scalePtr)).FvarNamePtr, libc.UintptrFromInt32(0)), libc.UintptrFromInt32(0), libc.Int32FromInt32(TCL_GLOBAL_ONLY)|libc.Int32FromInt32(TCL_TRACE_WRITES)|libc.Int32FromInt32(TCL_TRACE_UNSETS), __ccgo_fp(_ScaleVarProc), probe) if probe == scalePtr { break } } if probe != 0 { /* * We were able to fetch the unset trace for our * varNamePtr, which means it is not unset and not * the cause of this unset trace. Instead some outdated * former variable must be, and we should ignore it. */ return libc.UintptrFromInt32(0) } libtcl9_0.XTcl_TraceVar2(tls, interp, libtcl9_0.XTcl_GetStringFromObj(tls, (*TTkScale)(unsafe.Pointer(scalePtr)).FvarNamePtr, libc.UintptrFromInt32(0)), libc.UintptrFromInt32(0), libc.Int32FromInt32(TCL_GLOBAL_ONLY)|libc.Int32FromInt32(TCL_TRACE_WRITES)|libc.Int32FromInt32(TCL_TRACE_UNSETS), __ccgo_fp(_ScaleVarProc), clientData) *(*int32)(unsafe.Pointer(scalePtr + 376)) |= libc.Int32FromInt32(1) << libc.Int32FromInt32(6) XTkScaleSetValue(tls, scalePtr, (*TTkScale)(unsafe.Pointer(scalePtr)).Fvalue, int32(1), 0) } return libc.UintptrFromInt32(0) } /* * If we came here because we updated the variable (in TkScaleSetValue), * then ignore the trace. Otherwise update the scale with the value of the * variable. */ if (*TTkScale)(unsafe.Pointer(scalePtr)).Fflags&(libc.Int32FromInt32(1)< (*TTkScale)(unsafe.Pointer(scalePtr)).FtoValue)^libc.BoolInt32((*TTkScale)(unsafe.Pointer(scalePtr)).FtoValue < (*TTkScale)(unsafe.Pointer(scalePtr)).FfromValue) != 0 { value = (*TTkScale)(unsafe.Pointer(scalePtr)).FtoValue } if (*TTkScale)(unsafe.Pointer(scalePtr)).Fflags&(libc.Int32FromInt32(1)< libc.Float64FromInt32(1) { value = libc.Float64FromInt32(1) } value = (*TTkScale)(unsafe.Pointer(scalePtr)).FfromValue + float64(value*((*TTkScale)(unsafe.Pointer(scalePtr)).FtoValue-(*TTkScale)(unsafe.Pointer(scalePtr)).FfromValue)) return XTkRoundValueToResolution(tls, scalePtr, value) } /* *---------------------------------------------------------------------- * * TkScaleValueToPixel -- * * Given a reading of the scale, return the x-coordinate or y-coordinate * corresponding to that reading, depending on whether the scale is * vertical or horizontal, respectively. * * Results: * An integer value giving the pixel location corresponding to reading. * The value is restricted to lie within the defined range for the scale. * * Side effects: * None. * *---------------------------------------------------------------------- */ func XTkScaleValueToPixel(tls *libc.TLS, scalePtr uintptr, value float64) (r int32) { bp := tls.Alloc(16) defer tls.Free(16) /* Reading of the widget. */ var pixelRange, y, v1 int32 var valueRange float64 var _ /* borderWidth at bp+0 */ int32 var _ /* sliderLength at bp+4 */ int32 _, _, _, _ = pixelRange, valueRange, y, v1 XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), (*TTkScale)(unsafe.Pointer(scalePtr)).Ftkwin, (*TTkScale)(unsafe.Pointer(scalePtr)).FborderWidthObj, bp) XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), (*TTkScale)(unsafe.Pointer(scalePtr)).Ftkwin, (*TTkScale)(unsafe.Pointer(scalePtr)).FsliderLengthObj, bp+4) valueRange = (*TTkScale)(unsafe.Pointer(scalePtr)).FtoValue - (*TTkScale)(unsafe.Pointer(scalePtr)).FfromValue if (*TTkScale)(unsafe.Pointer(scalePtr)).Forient == int32(ORIENT_VERTICAL) { v1 = (*TTk_FakeWin)(unsafe.Pointer((*TTkScale)(unsafe.Pointer(scalePtr)).Ftkwin)).Fchanges.Fheight } else { v1 = (*TTk_FakeWin)(unsafe.Pointer((*TTkScale)(unsafe.Pointer(scalePtr)).Ftkwin)).Fchanges.Fwidth } pixelRange = v1 - *(*int32)(unsafe.Pointer(bp + 4)) - int32(2)*(*TTkScale)(unsafe.Pointer(scalePtr)).Finset - int32(2)**(*int32)(unsafe.Pointer(bp)) if valueRange == libc.Float64FromInt32(0) { y = 0 } else { y = _ScaleRound(tls, float64((value-(*TTkScale)(unsafe.Pointer(scalePtr)).FfromValue)*float64(pixelRange))/valueRange) if y < 0 { y = 0 } else { if y > pixelRange { y = pixelRange } } } y += *(*int32)(unsafe.Pointer(bp + 4))/int32(2) + (*TTkScale)(unsafe.Pointer(scalePtr)).Finset + *(*int32)(unsafe.Pointer(bp)) return y } const BOTTOM_ARROW = 5 const BOTTOM_GAP = 4 const GOT_FOCUS6 = 4 const OUTSIDE = 0 const REDRAW_PENDING2 = 1 const SLIDER1 = 3 const TOP_ARROW = 1 const TOP_GAP = 2 type TTkScrollbar = struct { Ftkwin TTk_Window Fdisplay uintptr Finterp uintptr FwidgetCmd TTcl_Command Fvertical int32 FwidthObj uintptr FcommandObj uintptr FrepeatDelay int32 FrepeatInterval int32 Fjump int32 FborderWidthObj uintptr FbgBorder TTk_3DBorder FactiveBorder TTk_3DBorder FtroughColorPtr uintptr Frelief int32 FhighlightWidthObj uintptr FhighlightBgColorPtr uintptr FhighlightColorPtr uintptr Finset int32 FelementBorderWidthObj uintptr FarrowLength int32 FsliderFirst int32 FsliderLast int32 FactiveField int32 FactiveRelief int32 FfirstFraction float64 FlastFraction float64 Fcursor TTk_Cursor FtakeFocusObj uintptr Fflags int32 } /* * default.h -- * * This file defines the defaults for all options for all of * the Tk widgets. * * Copyright © 1991-1994 The Regents of the University of California. * Copyright © 1994 Sun Microsystems, Inc. * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. */ /* * tkUnixDefault.h -- * * This file defines the defaults for all options for all of * the Tk widgets. * * Copyright © 1991-1994 The Regents of the University of California. * Copyright © 1994-1997 Sun Microsystems, Inc. * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. */ /* * The definitions below provide symbolic names for the default colors. * NORMAL_BG - Normal background color. * ACTIVE_BG - Background color when widget is active. * SELECT_BG - Background color for selected text. * TROUGH - Background color for troughs in scales and scrollbars. * INDICATOR - Color for indicator when button is selected. * DISABLED - Foreground color when widget is disabled. * PLACEHOLDER_FG - Foreground color for placeholder text. */ /* * Defaults for labels, buttons, checkbuttons, and radiobuttons: */ /* * Defaults for canvases: */ /* * Defaults for entries: */ /* * Defaults for frames: */ /* * Defaults for labelframes: */ /* * Defaults for listboxes: */ /* * Defaults for individual entries of menus: */ /* * Defaults for menus overall: */ /* * Defaults for menubuttons: */ /* * Defaults for messages: */ /* * Defaults for panedwindows */ /* * Defaults for panedwindow panes */ /* * Defaults for scales: */ /* * Defaults for scrollbars: */ /* * Defaults for texts: */ /* * Defaults for canvas text: */ /* * Defaults for canvas items * (arcs, bitmaps, lines, polygons, rectangles, and ovals): */ /* * Defaults for toplevels (most of the defaults for frames also apply * to toplevels): */ /* * Defaults for busy windows: */ /* * Custom option for handling "-orient" */ var _orientOption = TTk_CustomOption{} func init() { p := unsafe.Pointer(&_orientOption) *(*uintptr)(unsafe.Add(p, 0)) = __ccgo_fp(XTkOrientParseProc) *(*uintptr)(unsafe.Add(p, 8)) = __ccgo_fp(XTkOrientPrintProc) } /* * Information used for argv parsing. */ var _configSpecs = [24]TTk_ConfigSpec{ 0: { Ftype1: int32(TK_CONFIG_BORDER), FargvName: __ccgo_ts + 19775, FdbName: __ccgo_ts + 19793, FdbClass: __ccgo_ts + 19810, FdefValue: __ccgo_ts + 19821, Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 88)), FspecFlags: libc.Int32FromInt32(1) << libc.Int32FromInt32(1), }, 1: { Ftype1: int32(TK_CONFIG_BORDER), FargvName: __ccgo_ts + 19775, FdbName: __ccgo_ts + 19793, FdbClass: __ccgo_ts + 19810, FdefValue: __ccgo_ts + 19829, Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 88)), FspecFlags: libc.Int32FromInt32(1) << libc.Int32FromInt32(2), }, 2: { Ftype1: int32(TK_CONFIG_RELIEF), FargvName: __ccgo_ts + 24251, FdbName: __ccgo_ts + 24265, FdbClass: __ccgo_ts + 20354, FdefValue: __ccgo_ts + 12, Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 168)), }, 3: { Ftype1: int32(TK_CONFIG_BORDER), FargvName: __ccgo_ts + 19898, FdbName: __ccgo_ts + 19910, FdbClass: __ccgo_ts + 19872, FdefValue: __ccgo_ts + 19921, Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 80)), FspecFlags: libc.Int32FromInt32(1) << libc.Int32FromInt32(1), }, 4: { Ftype1: int32(TK_CONFIG_BORDER), FargvName: __ccgo_ts + 19898, FdbName: __ccgo_ts + 19910, FdbClass: __ccgo_ts + 19872, FdefValue: __ccgo_ts + 19883, Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 80)), FspecFlags: libc.Int32FromInt32(1) << libc.Int32FromInt32(2), }, 5: { Ftype1: int32(TK_CONFIG_SYNONYM), FargvName: __ccgo_ts + 19929, FdbName: __ccgo_ts + 19952, }, 6: { Ftype1: int32(TK_CONFIG_SYNONYM), FargvName: __ccgo_ts + 19933, FdbName: __ccgo_ts + 19910, }, 7: { Ftype1: int32(TK_CONFIG_PIXELS), FargvName: __ccgo_ts + 2814, FdbName: __ccgo_ts + 19952, FdbClass: __ccgo_ts + 19964, FdefValue: __ccgo_ts + 14538, Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 72)), FspecFlags: int32(TK_CONFIG_OBJS), }, 8: { Ftype1: int32(TK_CONFIG_STRING), FargvName: __ccgo_ts + 16356, FdbName: __ccgo_ts + 20495, FdbClass: __ccgo_ts + 1659, FdefValue: __ccgo_ts + 195, Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 48)), FspecFlags: libc.Int32FromInt32(TK_CONFIG_OBJS) | libc.Int32FromInt32(TCL_NULL_OK), }, 9: { Ftype1: int32(TK_CONFIG_ACTIVE_CURSOR), FargvName: __ccgo_ts + 4638, FdbName: __ccgo_ts + 4646, FdbClass: __ccgo_ts + 4653, FdefValue: __ccgo_ts + 195, Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 192)), FspecFlags: int32(TCL_NULL_OK), }, 10: { Ftype1: int32(TK_CONFIG_PIXELS), FargvName: __ccgo_ts + 26304, FdbName: __ccgo_ts + 26324, FdbClass: __ccgo_ts + 19964, Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 144)), FspecFlags: libc.Int32FromInt32(TK_CONFIG_OBJS) | libc.Int32FromInt32(TCL_NULL_OK), }, 11: { Ftype1: int32(TK_CONFIG_COLOR), FargvName: __ccgo_ts + 20129, FdbName: __ccgo_ts + 20150, FdbClass: __ccgo_ts + 20170, FdefValue: __ccgo_ts + 19921, Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 120)), }, 12: { Ftype1: int32(TK_CONFIG_COLOR), FargvName: __ccgo_ts + 20190, FdbName: __ccgo_ts + 20206, FdbClass: __ccgo_ts + 20221, FdefValue: __ccgo_ts + 19829, Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 128)), }, 13: { Ftype1: int32(TK_CONFIG_PIXELS), FargvName: __ccgo_ts + 20236, FdbName: __ccgo_ts + 20256, FdbClass: __ccgo_ts + 20275, FdefValue: __ccgo_ts + 10533, Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 112)), FspecFlags: int32(TK_CONFIG_OBJS), }, 14: { FargvName: __ccgo_ts + 26343, FdbName: __ccgo_ts + 26349, FdbClass: __ccgo_ts + 26354, FdefValue: __ccgo_ts + 10533, Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 64)), }, 15: { Ftype1: int32(TK_CONFIG_CUSTOM), FargvName: __ccgo_ts + 25111, FdbName: __ccgo_ts + 25119, FdbClass: __ccgo_ts + 25126, FdefValue: __ccgo_ts + 16837, Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 32)), FcustomPtr: uintptr(unsafe.Pointer(&_orientOption)), }, 16: { Ftype1: int32(TK_CONFIG_RELIEF), FargvName: __ccgo_ts + 20346, FdbName: __ccgo_ts + 82, FdbClass: __ccgo_ts + 20354, FdefValue: __ccgo_ts + 31, Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 104)), }, 17: { Ftype1: int32(TK_CONFIG_INT), FargvName: __ccgo_ts + 20545, FdbName: __ccgo_ts + 20558, FdbClass: __ccgo_ts + 20570, FdefValue: __ccgo_ts + 21333, Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 56)), }, 18: { Ftype1: int32(TK_CONFIG_INT), FargvName: __ccgo_ts + 20582, FdbName: __ccgo_ts + 20598, FdbClass: __ccgo_ts + 20613, FdefValue: __ccgo_ts + 22092, Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 60)), }, 19: { Ftype1: int32(TK_CONFIG_STRING), FargvName: __ccgo_ts + 20367, FdbName: __ccgo_ts + 20378, FdbClass: __ccgo_ts + 20388, Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 200)), FspecFlags: libc.Int32FromInt32(TK_CONFIG_OBJS) | libc.Int32FromInt32(TCL_NULL_OK), }, 20: { Ftype1: int32(TK_CONFIG_COLOR), FargvName: __ccgo_ts + 26138, FdbName: __ccgo_ts + 26151, FdbClass: __ccgo_ts + 19872, FdefValue: __ccgo_ts + 21572, Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 96)), FspecFlags: libc.Int32FromInt32(1) << libc.Int32FromInt32(1), }, 21: { Ftype1: int32(TK_CONFIG_COLOR), FargvName: __ccgo_ts + 26138, FdbName: __ccgo_ts + 26151, FdbClass: __ccgo_ts + 19872, FdefValue: __ccgo_ts + 19883, Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 96)), FspecFlags: libc.Int32FromInt32(1) << libc.Int32FromInt32(2), }, 22: { Ftype1: int32(TK_CONFIG_PIXELS), FargvName: __ccgo_ts + 2987, FdbName: __ccgo_ts + 6446, FdbClass: __ccgo_ts + 20455, FdefValue: uintptr(unsafe.Pointer(&XtkDefScrollbarWidth)), Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 40)), FspecFlags: int32(TK_CONFIG_OBJS), }, 23: { Ftype1: int32(TK_CONFIG_END), }, } /* *-------------------------------------------------------------- * * Tk_ScrollbarObjCmd -- * * This function is invoked to process the "scrollbar" Tcl command. See * the user documentation for details on what it does. * * Results: * A standard Tcl result. * * Side effects: * See the user documentation. * *-------------------------------------------------------------- */ func XTk_ScrollbarObjCmd(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) (r int32) { /* Argument strings. */ var newWin, tkwin TTk_Window var scrollPtr uintptr _, _, _ = newWin, scrollPtr, tkwin tkwin = clientData if objc < int32(2) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(1), objv, __ccgo_ts+20960) return int32(TCL_ERROR) } newWin = XTk_CreateWindowFromPath(tls, interp, tkwin, libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8)), libc.UintptrFromInt32(0)), libc.UintptrFromInt32(0)) if newWin == libc.UintptrFromInt32(0) { return int32(TCL_ERROR) } XTk_SetClass(tls, newWin, __ccgo_ts+26359) scrollPtr = XTkpCreateScrollbar(tls, newWin) XTk_SetClassProcs(tls, newWin, uintptr(unsafe.Pointer(&XtkpScrollbarProcs)), scrollPtr) /* * Initialize fields that won't be initialized by ConfigureScrollbar, or * which ConfigureScrollbar expects to have reasonable values (e.g. * resource pointers). */ (*TTkScrollbar)(unsafe.Pointer(scrollPtr)).Ftkwin = newWin (*TTkScrollbar)(unsafe.Pointer(scrollPtr)).Fdisplay = (*TTk_FakeWin)(unsafe.Pointer(newWin)).Fdisplay (*TTkScrollbar)(unsafe.Pointer(scrollPtr)).Finterp = interp (*TTkScrollbar)(unsafe.Pointer(scrollPtr)).FwidgetCmd = libtcl9_0.XTcl_CreateObjCommand(tls, interp, (*TTk_FakeWin)(unsafe.Pointer((*TTkScrollbar)(unsafe.Pointer(scrollPtr)).Ftkwin)).FpathName, __ccgo_fp(_ScrollbarWidgetObjCmd), scrollPtr, __ccgo_fp(_ScrollbarCmdDeletedProc)) (*TTkScrollbar)(unsafe.Pointer(scrollPtr)).Fvertical = 0 (*TTkScrollbar)(unsafe.Pointer(scrollPtr)).FwidthObj = uintptr(0) (*TTkScrollbar)(unsafe.Pointer(scrollPtr)).FcommandObj = libc.UintptrFromInt32(0) (*TTkScrollbar)(unsafe.Pointer(scrollPtr)).FrepeatDelay = 0 (*TTkScrollbar)(unsafe.Pointer(scrollPtr)).FrepeatInterval = 0 (*TTkScrollbar)(unsafe.Pointer(scrollPtr)).FborderWidthObj = libc.UintptrFromInt32(0) (*TTkScrollbar)(unsafe.Pointer(scrollPtr)).FbgBorder = libc.UintptrFromInt32(0) (*TTkScrollbar)(unsafe.Pointer(scrollPtr)).FactiveBorder = libc.UintptrFromInt32(0) (*TTkScrollbar)(unsafe.Pointer(scrollPtr)).FtroughColorPtr = libc.UintptrFromInt32(0) (*TTkScrollbar)(unsafe.Pointer(scrollPtr)).Frelief = TK_RELIEF_FLAT (*TTkScrollbar)(unsafe.Pointer(scrollPtr)).FhighlightWidthObj = libc.UintptrFromInt32(0) (*TTkScrollbar)(unsafe.Pointer(scrollPtr)).FhighlightBgColorPtr = libc.UintptrFromInt32(0) (*TTkScrollbar)(unsafe.Pointer(scrollPtr)).FhighlightColorPtr = libc.UintptrFromInt32(0) (*TTkScrollbar)(unsafe.Pointer(scrollPtr)).Finset = 0 (*TTkScrollbar)(unsafe.Pointer(scrollPtr)).FelementBorderWidthObj = libc.UintptrFromInt32(0) (*TTkScrollbar)(unsafe.Pointer(scrollPtr)).FarrowLength = 0 (*TTkScrollbar)(unsafe.Pointer(scrollPtr)).FsliderFirst = 0 (*TTkScrollbar)(unsafe.Pointer(scrollPtr)).FsliderLast = 0 (*TTkScrollbar)(unsafe.Pointer(scrollPtr)).FactiveField = 0 (*TTkScrollbar)(unsafe.Pointer(scrollPtr)).FactiveRelief = int32(TK_RELIEF_RAISED) (*TTkScrollbar)(unsafe.Pointer(scrollPtr)).FfirstFraction = float64(0) (*TTkScrollbar)(unsafe.Pointer(scrollPtr)).FlastFraction = float64(0) (*TTkScrollbar)(unsafe.Pointer(scrollPtr)).Fcursor = libc.UintptrFromInt32(0) (*TTkScrollbar)(unsafe.Pointer(scrollPtr)).FtakeFocusObj = libc.UintptrFromInt32(0) (*TTkScrollbar)(unsafe.Pointer(scrollPtr)).Fflags = 0 if _ConfigureScrollbar(tls, interp, scrollPtr, int64(objc-int32(2)), objv+uintptr(2)*8, 0) != TCL_OK { XTk_DestroyWindow(tls, (*TTkScrollbar)(unsafe.Pointer(scrollPtr)).Ftkwin) return int32(TCL_ERROR) } libtcl9_0.XTcl_SetObjResult(tls, interp, XTk_NewWindowObj(tls, (*TTkScrollbar)(unsafe.Pointer(scrollPtr)).Ftkwin)) return TCL_OK } /* *-------------------------------------------------------------- * * ScrollbarWidgetObjCmd -- * * This function is invoked to process the Tcl command that corresponds * to a widget managed by this module. See the user documentation for * details on what it does. * * Results: * A standard Tcl result. * * Side effects: * See the user documentation. * *-------------------------------------------------------------- */ func _ScrollbarWidgetObjCmd(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) (r int32) { bp := tls.Alloc(96) defer tls.Free(96) /* Argument strings. */ var c, length, oldActiveField, pixels, pos, result int32 var fraction, fraction1 float64 var scrollPtr, zone, zone1 uintptr var _ /* cmdIndex at bp+0 */ int32 var _ /* first at bp+72 */ float64 var _ /* last at bp+80 */ float64 var _ /* len at bp+8 */ TTcl_Size var _ /* resObjs at bp+32 */ [4]uintptr var _ /* x at bp+24 */ int32 var _ /* x at bp+64 */ int32 var _ /* xDelta at bp+16 */ int32 var _ /* y at bp+28 */ int32 var _ /* y at bp+68 */ int32 var _ /* yDelta at bp+20 */ int32 _, _, _, _, _, _, _, _, _, _, _ = c, fraction, fraction1, length, oldActiveField, pixels, pos, result, scrollPtr, zone, zone1 scrollPtr = clientData result = TCL_OK if objc < int32(2) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(1), objv, __ccgo_ts+4953) return int32(TCL_ERROR) } /* * Parse the command by looking up the second argument in the list of * valid subcommand names */ result = libtcl9_0.XTcl_GetIndexFromObjStruct(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 1*8)), uintptr(unsafe.Pointer(&_commandNames4)), libc.Int64FromUint64(libc.Uint64FromInt64(8)), __ccgo_ts+2689, libc.Int32FromInt32(0)|libc.Int32FromUint64(libc.Uint64FromInt64(4)< float64(1) { fraction1 = float64(1) } } libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewDoubleObj(tls, fraction1)) case 5: if objc != int32(2) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(1), objv, __ccgo_ts+4949) goto error } (*(*[4]uintptr)(unsafe.Pointer(bp + 32)))[0] = libtcl9_0.XTcl_NewDoubleObj(tls, (*TTkScrollbar)(unsafe.Pointer(scrollPtr)).FfirstFraction) (*(*[4]uintptr)(unsafe.Pointer(bp + 32)))[int32(1)] = libtcl9_0.XTcl_NewDoubleObj(tls, (*TTkScrollbar)(unsafe.Pointer(scrollPtr)).FlastFraction) libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewListObj(tls, int64(2), bp+32)) case 6: zone1 = __ccgo_ts + 195 if objc != int32(4) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(1), objv, __ccgo_ts+26204) goto error } if libtcl9_0.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+64) != TCL_OK || libtcl9_0.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 3*8)), bp+68) != TCL_OK { goto error } switch XTkpScrollbarPosition(tls, scrollPtr, *(*int32)(unsafe.Pointer(bp + 64)), *(*int32)(unsafe.Pointer(bp + 68))) { case int32(TOP_ARROW): zone1 = __ccgo_ts + 26384 case int32(TOP_GAP): zone1 = __ccgo_ts + 26217 case int32(SLIDER1): zone1 = __ccgo_ts + 26225 case int32(BOTTOM_GAP): zone1 = __ccgo_ts + 26232 case int32(BOTTOM_ARROW): zone1 = __ccgo_ts + 26391 break } libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewStringObj(tls, zone1, int64(-libc.Int32FromInt32(1)))) case 7: if objc == int32(4) { if libtcl9_0.XTcl_GetDoubleFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+72) != TCL_OK { goto error } if libtcl9_0.XTcl_GetDoubleFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 3*8)), bp+80) != TCL_OK { goto error } if *(*float64)(unsafe.Pointer(bp + 72)) < libc.Float64FromInt32(0) { (*TTkScrollbar)(unsafe.Pointer(scrollPtr)).FfirstFraction = libc.Float64FromInt32(0) } else { if *(*float64)(unsafe.Pointer(bp + 72)) > float64(1) { (*TTkScrollbar)(unsafe.Pointer(scrollPtr)).FfirstFraction = float64(1) } else { (*TTkScrollbar)(unsafe.Pointer(scrollPtr)).FfirstFraction = *(*float64)(unsafe.Pointer(bp + 72)) } } if *(*float64)(unsafe.Pointer(bp + 80)) < (*TTkScrollbar)(unsafe.Pointer(scrollPtr)).FfirstFraction { (*TTkScrollbar)(unsafe.Pointer(scrollPtr)).FlastFraction = (*TTkScrollbar)(unsafe.Pointer(scrollPtr)).FfirstFraction } else { if *(*float64)(unsafe.Pointer(bp + 80)) > float64(1) { (*TTkScrollbar)(unsafe.Pointer(scrollPtr)).FlastFraction = float64(1) } else { (*TTkScrollbar)(unsafe.Pointer(scrollPtr)).FlastFraction = *(*float64)(unsafe.Pointer(bp + 80)) } } } else { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(1), objv, __ccgo_ts+26448) goto error } XTkpComputeScrollbarGeometry(tls, scrollPtr) XTkScrollbarEventuallyRedraw(tls, scrollPtr) break } goto done done: ; libtcl9_0.XTcl_Release(tls, scrollPtr) return result goto error error: ; libtcl9_0.XTcl_Release(tls, scrollPtr) return int32(TCL_ERROR) } var _commandNames4 = [9]uintptr{ 0: __ccgo_ts + 23629, 1: __ccgo_ts + 4735, 2: __ccgo_ts + 4740, 3: __ccgo_ts + 26369, 4: __ccgo_ts + 26375, 5: __ccgo_ts + 4949, 6: __ccgo_ts + 22197, 7: __ccgo_ts + 11726, 8: libc.UintptrFromInt32(0), } /* *---------------------------------------------------------------------- * * ConfigureScrollbar -- * * This function is called to process an argv/argc list, plus the Tk * option database, in order to configure (or reconfigure) a scrollbar * widget. * * Results: * The return value is a standard Tcl result. If TCL_ERROR is returned, * then the interp's result contains an error message. * * Side effects: * Configuration information, such as colors, border width, etc. get set * for scrollPtr; old resources get freed, if there were any. * *---------------------------------------------------------------------- */ func _ConfigureScrollbar(tls *libc.TLS, interp uintptr, scrollPtr uintptr, objc TTcl_Size, objv uintptr, flags int32) (r int32) { bp := tls.Alloc(16) defer tls.Free(16) /* Flags to pass to Tk_ConfigureWidget. */ var _objPtr, _objPtr1, _objPtr2, _objPtr3, v2, v4, v6, v8 uintptr var v1, v3, v5, v7 TTcl_Size var _ /* borderWidth at bp+4 */ int32 var _ /* elementBorderWidth at bp+12 */ int32 var _ /* highlightWidth at bp+8 */ int32 var _ /* width at bp+0 */ int32 _, _, _, _, _, _, _, _, _, _, _, _ = _objPtr, _objPtr1, _objPtr2, _objPtr3, v1, v2, v3, v4, v5, v6, v7, v8 if XTk_ConfigureWidget(tls, interp, (*TTkScrollbar)(unsafe.Pointer(scrollPtr)).Ftkwin, uintptr(unsafe.Pointer(&_configSpecs)), objc, objv, scrollPtr, flags) != TCL_OK { return int32(TCL_ERROR) } /* * A few options need special processing, such as setting the background * from a 3-D border. */ XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), (*TTkScrollbar)(unsafe.Pointer(scrollPtr)).Ftkwin, (*TTkScrollbar)(unsafe.Pointer(scrollPtr)).FborderWidthObj, bp+4) if *(*int32)(unsafe.Pointer(bp + 4)) < 0 { _objPtr = (*TTkScrollbar)(unsafe.Pointer(scrollPtr)).FborderWidthObj v2 = _objPtr v1 = *(*TTcl_Size)(unsafe.Pointer(v2)) *(*TTcl_Size)(unsafe.Pointer(v2))-- if v1 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr) } (*TTkScrollbar)(unsafe.Pointer(scrollPtr)).FborderWidthObj = libtcl9_0.XTcl_NewWideIntObj(tls, int64(libc.Int32FromInt32(0))) (*TTcl_Obj)(unsafe.Pointer((*TTkScrollbar)(unsafe.Pointer(scrollPtr)).FborderWidthObj)).FrefCount++ } XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), (*TTkScrollbar)(unsafe.Pointer(scrollPtr)).Ftkwin, (*TTkScrollbar)(unsafe.Pointer(scrollPtr)).FhighlightWidthObj, bp+8) if *(*int32)(unsafe.Pointer(bp + 8)) < 0 { _objPtr1 = (*TTkScrollbar)(unsafe.Pointer(scrollPtr)).FhighlightWidthObj v4 = _objPtr1 v3 = *(*TTcl_Size)(unsafe.Pointer(v4)) *(*TTcl_Size)(unsafe.Pointer(v4))-- if v3 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr1) } (*TTkScrollbar)(unsafe.Pointer(scrollPtr)).FhighlightWidthObj = libtcl9_0.XTcl_NewWideIntObj(tls, int64(libc.Int32FromInt32(0))) (*TTcl_Obj)(unsafe.Pointer((*TTkScrollbar)(unsafe.Pointer(scrollPtr)).FhighlightWidthObj)).FrefCount++ } XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), (*TTkScrollbar)(unsafe.Pointer(scrollPtr)).Ftkwin, (*TTkScrollbar)(unsafe.Pointer(scrollPtr)).FwidthObj, bp) if *(*int32)(unsafe.Pointer(bp)) < 0 { _objPtr2 = (*TTkScrollbar)(unsafe.Pointer(scrollPtr)).FwidthObj v6 = _objPtr2 v5 = *(*TTcl_Size)(unsafe.Pointer(v6)) *(*TTcl_Size)(unsafe.Pointer(v6))-- if v5 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr2) } (*TTkScrollbar)(unsafe.Pointer(scrollPtr)).FwidthObj = libtcl9_0.XTcl_NewWideIntObj(tls, int64(libc.Int32FromInt32(0))) (*TTcl_Obj)(unsafe.Pointer((*TTkScrollbar)(unsafe.Pointer(scrollPtr)).FwidthObj)).FrefCount++ } if (*TTkScrollbar)(unsafe.Pointer(scrollPtr)).FelementBorderWidthObj != 0 { XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), (*TTkScrollbar)(unsafe.Pointer(scrollPtr)).Ftkwin, (*TTkScrollbar)(unsafe.Pointer(scrollPtr)).FelementBorderWidthObj, bp+12) if *(*int32)(unsafe.Pointer(bp + 12)) < 0 { _objPtr3 = (*TTkScrollbar)(unsafe.Pointer(scrollPtr)).FelementBorderWidthObj v8 = _objPtr3 v7 = *(*TTcl_Size)(unsafe.Pointer(v8)) *(*TTcl_Size)(unsafe.Pointer(v8))-- if v7 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr3) } (*TTkScrollbar)(unsafe.Pointer(scrollPtr)).FelementBorderWidthObj = libc.UintptrFromInt32(0) } } /* * Configure platform specific options. */ XTkpConfigureScrollbar(tls, scrollPtr) /* * Register the desired geometry for the window (leave enough space for * the two arrows plus a minimum-size slider, plus border around the whole * window, if any). Then arrange for the window to be redisplayed. */ XTkpComputeScrollbarGeometry(tls, scrollPtr) XTkScrollbarEventuallyRedraw(tls, scrollPtr) return TCL_OK } /* *-------------------------------------------------------------- * * TkScrollbarEventProc -- * * This function is invoked by the Tk dispatcher for various events on * scrollbars. * * Results: * None. * * Side effects: * When the window gets deleted, internal structures get cleaned up. * When it gets exposed, it is redisplayed. * *-------------------------------------------------------------- */ func XTkScrollbarEventProc(tls *libc.TLS, clientData uintptr, eventPtr uintptr) { bp := tls.Alloc(16) defer tls.Free(16) /* Information about event. */ var scrollPtr uintptr var _ /* highlightWidth at bp+0 */ int32 _ = scrollPtr scrollPtr = clientData if (*TXEvent)(unsafe.Pointer(eventPtr)).Ftype1 == int32(Expose) && (*(*TXExposeEvent)(unsafe.Pointer(eventPtr))).Fcount == 0 { XTkScrollbarEventuallyRedraw(tls, scrollPtr) } else { if (*TXEvent)(unsafe.Pointer(eventPtr)).Ftype1 == int32(DestroyNotify) { XTkpDestroyScrollbar(tls, scrollPtr) if (*TTkScrollbar)(unsafe.Pointer(scrollPtr)).Ftkwin != libc.UintptrFromInt32(0) { (*TTkScrollbar)(unsafe.Pointer(scrollPtr)).Ftkwin = libc.UintptrFromInt32(0) libtcl9_0.XTcl_DeleteCommandFromToken(tls, (*TTkScrollbar)(unsafe.Pointer(scrollPtr)).Finterp, (*TTkScrollbar)(unsafe.Pointer(scrollPtr)).FwidgetCmd) } if (*TTkScrollbar)(unsafe.Pointer(scrollPtr)).Fflags&int32(REDRAW_PENDING2) != 0 { libtcl9_0.XTcl_CancelIdleCall(tls, __ccgo_fp(XTkpDisplayScrollbar), scrollPtr) } /* * Free up all the stuff that requires special handling, then let * Tk_FreeOptions handle all the standard option-related stuff. */ XTk_FreeOptions(tls, uintptr(unsafe.Pointer(&_configSpecs)), scrollPtr, (*TTkScrollbar)(unsafe.Pointer(scrollPtr)).Fdisplay, 0) libtcl9_0.XTcl_EventuallyFree(tls, scrollPtr, libc.UintptrFromInt32(3)) } else { if (*TXEvent)(unsafe.Pointer(eventPtr)).Ftype1 == int32(ConfigureNotify) { XTkpComputeScrollbarGeometry(tls, scrollPtr) XTkScrollbarEventuallyRedraw(tls, scrollPtr) } else { if (*TXEvent)(unsafe.Pointer(eventPtr)).Ftype1 == int32(FocusIn) { if (*(*TXFocusChangeEvent)(unsafe.Pointer(eventPtr))).Fdetail != int32(NotifyInferior) { *(*int32)(unsafe.Pointer(scrollPtr + 208)) |= int32(GOT_FOCUS6) XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), (*TTkScrollbar)(unsafe.Pointer(scrollPtr)).Ftkwin, (*TTkScrollbar)(unsafe.Pointer(scrollPtr)).FhighlightWidthObj, bp) if *(*int32)(unsafe.Pointer(bp)) > 0 { XTkScrollbarEventuallyRedraw(tls, scrollPtr) } } } else { if (*TXEvent)(unsafe.Pointer(eventPtr)).Ftype1 == int32(FocusOut) { if (*(*TXFocusChangeEvent)(unsafe.Pointer(eventPtr))).Fdetail != int32(NotifyInferior) { *(*int32)(unsafe.Pointer(scrollPtr + 208)) &= ^libc.Int32FromInt32(GOT_FOCUS6) XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), (*TTkScrollbar)(unsafe.Pointer(scrollPtr)).Ftkwin, (*TTkScrollbar)(unsafe.Pointer(scrollPtr)).FhighlightWidthObj, bp) if *(*int32)(unsafe.Pointer(bp)) > 0 { XTkScrollbarEventuallyRedraw(tls, scrollPtr) } } } else { if (*TXEvent)(unsafe.Pointer(eventPtr)).Ftype1 == int32(MapNotify) { XTkScrollbarEventuallyRedraw(tls, scrollPtr) } } } } } } } /* *---------------------------------------------------------------------- * * ScrollbarCmdDeletedProc -- * * This function is invoked when a widget command is deleted. If the * widget isn't already in the process of being destroyed, this command * destroys it. * * Results: * None. * * Side effects: * The widget is destroyed. * *---------------------------------------------------------------------- */ func _ScrollbarCmdDeletedProc(tls *libc.TLS, clientData uintptr) { /* Pointer to widget record for widget. */ var scrollPtr uintptr var tkwin TTk_Window _, _ = scrollPtr, tkwin scrollPtr = clientData tkwin = (*TTkScrollbar)(unsafe.Pointer(scrollPtr)).Ftkwin /* * This function could be invoked either because the window was destroyed * and the command was then deleted (in which case tkwin is NULL) or * because the command was deleted, and then this function destroys the * widget. */ if tkwin != libc.UintptrFromInt32(0) { (*TTkScrollbar)(unsafe.Pointer(scrollPtr)).Ftkwin = libc.UintptrFromInt32(0) XTk_DestroyWindow(tls, tkwin) } } /* *-------------------------------------------------------------- * * TkScrollbarEventuallyRedraw -- * * Arrange for one or more of the fields of a scrollbar to be redrawn. * * Results: * None. * * Side effects: * None. * *-------------------------------------------------------------- */ func XTkScrollbarEventuallyRedraw(tls *libc.TLS, scrollPtr uintptr) { /* Information about widget. */ if (*TTkScrollbar)(unsafe.Pointer(scrollPtr)).Ftkwin == libc.UintptrFromInt32(0) || !((*TTk_FakeWin)(unsafe.Pointer((*TTkScrollbar)(unsafe.Pointer(scrollPtr)).Ftkwin)).Fflags&libc.Uint32FromInt32(TK_MAPPED) != 0) { return } if !((*TTkScrollbar)(unsafe.Pointer(scrollPtr)).Fflags&libc.Int32FromInt32(REDRAW_PENDING2) != 0) { libtcl9_0.XTcl_DoWhenIdle(tls, __ccgo_fp(XTkpDisplayScrollbar), scrollPtr) *(*int32)(unsafe.Pointer(scrollPtr + 208)) |= int32(REDRAW_PENDING2) } } const BBOX_NOT_EMPTY = 512 const COPY_PIXEL = 0 const CURSOR_ON1 = 16 const FORCE_REDRAW = 8 const GOT_FOCUS7 = 8 const IS_BIG_ENDIAN = 0 const LEFT_GRABBED_ITEM = 64 const NUM_STATIC = 3 const OVERDRAW_PIXELS = 32 const REDRAW_BORDERS = 2 const REPICK_IN_PROGRESS = 256 const REPICK_NEEDED = 4 const SEARCH_TYPE_ALL = 2 const SEARCH_TYPE_EMPTY = 0 const SEARCH_TYPE_EXPR = 4 const SEARCH_TYPE_ID = 1 const SEARCH_TYPE_TAG = 3 const UPDATE_SCROLLBARS = 32 type TTagSearchExpr = struct { Fnext uintptr Fuid TTk_Uid Fuids uintptr Fallocated int32 Flength int32 Findex int32 Fmatch int32 } type TTagSearchExpr_s = TTagSearchExpr type TTkCanvas = struct { Ftkwin TTk_Window Fdisplay uintptr Finterp uintptr FwidgetCmd TTcl_Command FfirstItemPtr uintptr FlastItemPtr uintptr FborderWidthObj uintptr FbgBorder TTk_3DBorder Frelief int32 FhighlightWidthObj uintptr FhighlightBgColorPtr uintptr FhighlightColorPtr uintptr Finset int32 FpixmapGC TGC FwidthObj uintptr FheightObj uintptr FredrawX1 int32 FredrawY1 int32 FredrawX2 int32 FredrawY2 int32 Fconfine int32 FtextInfo TTk_CanvasTextInfo FinsertOnTime int32 FinsertOffTime int32 FinsertBlinkHandler TTcl_TimerToken FxOrigin int32 FyOrigin int32 FdrawableXOrigin int32 FdrawableYOrigin int32 FbindingTable TTk_BindingTable FcurrentItemPtr uintptr FnewCurrentPtr uintptr FcloseEnough float64 FpickEvent TXEvent Fstate uint32 FxScrollCmdObj uintptr FyScrollCmdObj uintptr FscrollX1 int32 FscrollY1 int32 FscrollX2 int32 FscrollY2 int32 FregionObj uintptr FxScrollIncrementObj uintptr FyScrollIncrementObj uintptr FscanX int32 FscanXOrigin int32 FscanY int32 FscanYOrigin int32 FhotPtr uintptr FhotPrevPtr uintptr Fcursor TTk_Cursor FtakeFocusObj uintptr FpixelsPerMM float64 Fflags int32 FnextId TTcl_Size FpsInfo TTk_PostscriptInfo FidTable TTcl_HashTable Freserved1 uintptr Fcanvas_state TTk_State Freserved2 uintptr Freserved3 uintptr Ftsoffset TTk_TSOffset FbindTagExprs uintptr } /* * Convenience macro. */ /* * default.h -- * * This file defines the defaults for all options for all of * the Tk widgets. * * Copyright © 1991-1994 The Regents of the University of California. * Copyright © 1994 Sun Microsystems, Inc. * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. */ /* * tkUnixDefault.h -- * * This file defines the defaults for all options for all of * the Tk widgets. * * Copyright © 1991-1994 The Regents of the University of California. * Copyright © 1994-1997 Sun Microsystems, Inc. * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. */ /* * The definitions below provide symbolic names for the default colors. * NORMAL_BG - Normal background color. * ACTIVE_BG - Background color when widget is active. * SELECT_BG - Background color for selected text. * TROUGH - Background color for troughs in scales and scrollbars. * INDICATOR - Color for indicator when button is selected. * DISABLED - Foreground color when widget is disabled. * PLACEHOLDER_FG - Foreground color for placeholder text. */ /* * Defaults for labels, buttons, checkbuttons, and radiobuttons: */ /* * Defaults for canvases: */ /* * Defaults for entries: */ /* * Defaults for frames: */ /* * Defaults for labelframes: */ /* * Defaults for listboxes: */ /* * Defaults for individual entries of menus: */ /* * Defaults for menus overall: */ /* * Defaults for menubuttons: */ /* * Defaults for messages: */ /* * Defaults for panedwindows */ /* * Defaults for panedwindow panes */ /* * Defaults for scales: */ /* * Defaults for scrollbars: */ /* * Defaults for texts: */ /* * Defaults for canvas text: */ /* * Defaults for canvas items * (arcs, bitmaps, lines, polygons, rectangles, and ovals): */ /* * Defaults for toplevels (most of the defaults for frames also apply * to toplevels): */ /* * Defaults for busy windows: */ /* * tkPort.h -- * * This header file handles porting issues that occur because of * differences between systems. It reads in platform specific * portability files. * * Copyright © 1995 Sun Microsystems, Inc. * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. */ /* * See tkCanvas.h for key data structures used to implement canvases. */ /* * The structure defined below is used to keep track of a tag search in * progress. No field should be accessed by anyone other than TagSearchScan, * TagSearchFirst, TagSearchNext, TagSearchScanExpr, TagSearchEvalExpr, * TagSearchExprInit, TagSearchExprDestroy, TagSearchDestroy. * ( * Not quite accurate: the TagSearch structure is also accessed from: * CanvasWidgetCmd, FindItems, RelinkItems * The only instances of the structure are owned by: * CanvasWidgetCmd * CanvasWidgetCmd is the only function that calls: * FindItems, RelinkItems * CanvasWidgetCmd, FindItems, RelinkItems, are the only functions that call * TagSearch* * ) */ type TTagSearch = struct { FcanvasPtr uintptr FcurrentPtr uintptr FlastPtr uintptr FsearchOver int32 Ftype1 int32 Fid TTcl_Size Fstring1 uintptr FstringIndex int32 FstringLength int32 Frewritebuffer uintptr FrewritebufferAllocated uint32 Fexpr uintptr } /* * Values for the TagSearch type field. */ /* * Custom option for handling "-state" and "-offset" */ var _stateOption = TTk_CustomOption{} func init() { p := unsafe.Pointer(&_stateOption) *(*uintptr)(unsafe.Add(p, 0)) = __ccgo_fp(XTkStateParseProc) *(*uintptr)(unsafe.Add(p, 8)) = __ccgo_fp(XTkStatePrintProc) } var _offsetOption = TTk_CustomOption{ FclientData: uintptr(int64(libc.Int32FromInt32(TK_OFFSET_RELATIVE))), } func init() { p := unsafe.Pointer(&_offsetOption) *(*uintptr)(unsafe.Add(p, 0)) = __ccgo_fp(XTkOffsetParseProc) *(*uintptr)(unsafe.Add(p, 8)) = __ccgo_fp(XTkOffsetPrintProc) } /* * Information used for argv parsing. */ var _configSpecs1 = [35]TTk_ConfigSpec{ 0: { Ftype1: int32(TK_CONFIG_BORDER), FargvName: __ccgo_ts + 19898, FdbName: __ccgo_ts + 19910, FdbClass: __ccgo_ts + 19872, FdefValue: __ccgo_ts + 19921, Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 56)), FspecFlags: libc.Int32FromInt32(1) << libc.Int32FromInt32(1), }, 1: { Ftype1: int32(TK_CONFIG_BORDER), FargvName: __ccgo_ts + 19898, FdbName: __ccgo_ts + 19910, FdbClass: __ccgo_ts + 19872, FdefValue: __ccgo_ts + 19883, Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 56)), FspecFlags: libc.Int32FromInt32(1) << libc.Int32FromInt32(2), }, 2: { Ftype1: int32(TK_CONFIG_SYNONYM), FargvName: __ccgo_ts + 19929, FdbName: __ccgo_ts + 19952, }, 3: { Ftype1: int32(TK_CONFIG_SYNONYM), FargvName: __ccgo_ts + 19933, FdbName: __ccgo_ts + 19910, }, 4: { Ftype1: int32(TK_CONFIG_PIXELS), FargvName: __ccgo_ts + 2814, FdbName: __ccgo_ts + 19952, FdbClass: __ccgo_ts + 19964, FdefValue: __ccgo_ts + 10533, Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 48)), FspecFlags: int32(TK_CONFIG_OBJS), }, 5: { Ftype1: int32(TK_CONFIG_DOUBLE), FargvName: __ccgo_ts + 26479, FdbName: __ccgo_ts + 26492, FdbClass: __ccgo_ts + 26504, FdefValue: __ccgo_ts + 14538, Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 328)), }, 6: { FargvName: __ccgo_ts + 26516, FdbName: __ccgo_ts + 26525, FdbClass: __ccgo_ts + 26533, FdefValue: __ccgo_ts + 14538, Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 144)), }, 7: { Ftype1: int32(TK_CONFIG_ACTIVE_CURSOR), FargvName: __ccgo_ts + 4638, FdbName: __ccgo_ts + 4646, FdbClass: __ccgo_ts + 4653, FdefValue: __ccgo_ts + 195, Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 624)), FspecFlags: int32(TCL_NULL_OK), }, 8: { Ftype1: int32(TK_CONFIG_PIXELS), FargvName: __ccgo_ts + 2870, FdbName: __ccgo_ts + 6172, FdbClass: __ccgo_ts + 20122, FdefValue: __ccgo_ts + 26541, Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 120)), FspecFlags: int32(TK_CONFIG_OBJS), }, 9: { Ftype1: int32(TK_CONFIG_COLOR), FargvName: __ccgo_ts + 20129, FdbName: __ccgo_ts + 20150, FdbClass: __ccgo_ts + 20170, FdefValue: __ccgo_ts + 19921, Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 80)), }, 10: { Ftype1: int32(TK_CONFIG_COLOR), FargvName: __ccgo_ts + 20190, FdbName: __ccgo_ts + 20206, FdbClass: __ccgo_ts + 20221, FdefValue: __ccgo_ts + 19829, Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 88)), }, 11: { Ftype1: int32(TK_CONFIG_PIXELS), FargvName: __ccgo_ts + 20236, FdbName: __ccgo_ts + 20256, FdbClass: __ccgo_ts + 20275, FdefValue: __ccgo_ts + 14538, Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 72)), FspecFlags: int32(TK_CONFIG_OBJS), }, 12: { Ftype1: int32(TK_CONFIG_BORDER), FargvName: __ccgo_ts + 21224, FdbName: __ccgo_ts + 21242, FdbClass: __ccgo_ts + 19810, FdefValue: __ccgo_ts + 19829, Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 152 + 64)), }, 13: { Ftype1: int32(TK_CONFIG_PIXELS), FargvName: __ccgo_ts + 21259, FdbName: __ccgo_ts + 21278, FdbClass: __ccgo_ts + 19964, FdefValue: __ccgo_ts + 10533, Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 152 + 96)), FspecFlags: libc.Int32FromInt32(TK_CONFIG_OBJS) | libc.Int32FromInt32(1)<= (*TTk_Item)(unsafe.Pointer(itemPtr)).Fx2 || (*TTk_Item)(unsafe.Pointer(itemPtr)).Fy1 >= (*TTk_Item)(unsafe.Pointer(itemPtr)).Fy2 { goto _39 } if !(gotAny != 0) { x11 = (*TTk_Item)(unsafe.Pointer(itemPtr)).Fx1 y11 = (*TTk_Item)(unsafe.Pointer(itemPtr)).Fy1 x21 = (*TTk_Item)(unsafe.Pointer(itemPtr)).Fx2 y21 = (*TTk_Item)(unsafe.Pointer(itemPtr)).Fy2 gotAny = int32(1) } else { if (*TTk_Item)(unsafe.Pointer(itemPtr)).Fx1 < x11 { x11 = (*TTk_Item)(unsafe.Pointer(itemPtr)).Fx1 } if (*TTk_Item)(unsafe.Pointer(itemPtr)).Fy1 < y11 { y11 = (*TTk_Item)(unsafe.Pointer(itemPtr)).Fy1 } if (*TTk_Item)(unsafe.Pointer(itemPtr)).Fx2 > x21 { x21 = (*TTk_Item)(unsafe.Pointer(itemPtr)).Fx2 } if (*TTk_Item)(unsafe.Pointer(itemPtr)).Fy2 > y21 { y21 = (*TTk_Item)(unsafe.Pointer(itemPtr)).Fy2 } } goto _39 _39: ; itemPtr = _TagSearchNext(tls, *(*uintptr)(unsafe.Pointer(bp))) } goto _37 _37: ; i++ } if gotAny != 0 { (*(*[4]uintptr)(unsafe.Pointer(bp + 16)))[0] = libtcl9_0.XTcl_NewWideIntObj(tls, int64(x11)) (*(*[4]uintptr)(unsafe.Pointer(bp + 16)))[int32(1)] = libtcl9_0.XTcl_NewWideIntObj(tls, int64(y11)) (*(*[4]uintptr)(unsafe.Pointer(bp + 16)))[int32(2)] = libtcl9_0.XTcl_NewWideIntObj(tls, int64(x21)) (*(*[4]uintptr)(unsafe.Pointer(bp + 16)))[int32(3)] = libtcl9_0.XTcl_NewWideIntObj(tls, int64(y21)) libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewListObj(tls, int64(4), bp+16)) } goto _36 _3: ; if objc < int32(3) || objc > int32(5) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(2), objv, __ccgo_ts+26841) result = int32(TCL_ERROR) goto done } /* * Figure out what object to use for the binding (individual item vs. * tag). */ object = libc.UintptrFromInt32(0) result = _TagSearchScan(tls, canvasPtr, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp) if result != TCL_OK { goto done } if (*TTagSearch)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp)))).Ftype1 == int32(SEARCH_TYPE_ID) { entryPtr = (*(*func(*libc.TLS, uintptr, uintptr) uintptr)(unsafe.Pointer(&struct{ uintptr }{(*TTcl_HashTable)(unsafe.Pointer(canvasPtr + 672)).FfindProc})))(tls, canvasPtr+672, uintptr((*TTagSearch)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp)))).Fid)) if entryPtr != libc.UintptrFromInt32(0) { itemPtr = (*TTcl_HashEntry)(unsafe.Pointer(entryPtr)).FclientData object = itemPtr } if object == uintptr(0) { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+26870, libc.VaList(bp+336, libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8)), libc.UintptrFromInt32(0))))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+336, __ccgo_ts+179, __ccgo_ts+3058, __ccgo_ts+26894, libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8)), libc.UintptrFromInt32(0)), libc.UintptrFromInt32(0))) result = int32(TCL_ERROR) goto done } } else { object = (*TTagSearchExpr)(unsafe.Pointer((*TTagSearch)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp)))).Fexpr)).Fuid } /* * Make a binding table if the canvas doesn't already have one. */ if (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FbindingTable == libc.UintptrFromInt32(0) { (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FbindingTable = XTk_CreateBindingTable(tls, interp) } if objc == int32(5) { append1 = 0 argv4 = libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 4*8)), libc.UintptrFromInt32(0)) if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(argv4))) == 0 { result = XTk_DeleteBinding(tls, interp, (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FbindingTable, object, libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 3*8)), libc.UintptrFromInt32(0))) goto done } if (*TTagSearch)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp)))).Ftype1 == int32(SEARCH_TYPE_EXPR) { lastPtr = canvasPtr + 824 for { v40 = *(*uintptr)(unsafe.Pointer(lastPtr)) expr = v40 if !(v40 != libc.UintptrFromInt32(0)) { break } if (*TTagSearchExpr)(unsafe.Pointer(expr)).Fuid == (*TTagSearchExpr)(unsafe.Pointer((*TTagSearch)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp)))).Fexpr)).Fuid { break } lastPtr = expr } if !(expr != 0) { /* * Transfer ownership of expr to bindTagExprs list. */ *(*uintptr)(unsafe.Pointer(lastPtr)) = (*TTagSearch)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp)))).Fexpr (*TTagSearchExpr)(unsafe.Pointer((*TTagSearch)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp)))).Fexpr)).Fnext = libc.UintptrFromInt32(0) /* * Flag in TagSearch that expr has changed ownership so * that TagSearchDestroy doesn't try to free it. */ (*TTagSearch)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp)))).Fexpr = libc.UintptrFromInt32(0) } } if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(argv4))) == int32('+') { argv4++ append1 = int32(1) } mask = uint32(XTk_CreateBinding(tls, interp, (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FbindingTable, object, libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 3*8)), libc.UintptrFromInt32(0)), argv4, append1)) if mask == uint32(0) { result = int32(TCL_ERROR) goto done } if libc.Int64FromUint32(mask) & ^(libc.Int64FromInt64(1)< int32(4) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(2), objv, __ccgo_ts+27021) result = int32(TCL_ERROR) goto done } if XTk_GetPixelsFromObj(tls, interp, (*TTkCanvas)(unsafe.Pointer(canvasPtr)).Ftkwin, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+48) != TCL_OK { result = int32(TCL_ERROR) goto done } if objc == int32(4) { if XTk_CanvasGetCoordFromObj(tls, interp, canvasPtr, *(*uintptr)(unsafe.Pointer(objv + 3*8)), bp+56) != TCL_OK { result = int32(TCL_ERROR) goto done } } else { *(*float64)(unsafe.Pointer(bp + 56)) = float64(0) } *(*int32)(unsafe.Pointer(bp + 48)) += (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FxOrigin libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewDoubleObj(tls, _GridAlign(tls, float64(*(*int32)(unsafe.Pointer(bp + 48))), *(*float64)(unsafe.Pointer(bp + 56))))) goto _36 _5: ; if objc < int32(3) || objc > int32(4) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(2), objv, __ccgo_ts+27043) result = int32(TCL_ERROR) goto done } if XTk_GetPixelsFromObj(tls, interp, (*TTkCanvas)(unsafe.Pointer(canvasPtr)).Ftkwin, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+64) != TCL_OK { result = int32(TCL_ERROR) goto done } if objc == int32(4) { if XTk_CanvasGetCoordFromObj(tls, interp, canvasPtr, *(*uintptr)(unsafe.Pointer(objv + 3*8)), bp+72) != TCL_OK { result = int32(TCL_ERROR) goto done } } else { *(*float64)(unsafe.Pointer(bp + 72)) = float64(0) } *(*int32)(unsafe.Pointer(bp + 64)) += (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FyOrigin libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewDoubleObj(tls, _GridAlign(tls, float64(*(*int32)(unsafe.Pointer(bp + 64))), *(*float64)(unsafe.Pointer(bp + 72))))) goto _36 _6: ; if objc != int32(3) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(2), objv, __ccgo_ts+2689) result = int32(TCL_ERROR) goto done } result = XTk_ConfigureValue(tls, interp, (*TTkCanvas)(unsafe.Pointer(canvasPtr)).Ftkwin, uintptr(unsafe.Pointer(&_configSpecs1)), canvasPtr, libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8)), libc.UintptrFromInt32(0)), 0) goto _36 _7: ; if objc == int32(2) { result = XTk_ConfigureInfo(tls, interp, (*TTkCanvas)(unsafe.Pointer(canvasPtr)).Ftkwin, uintptr(unsafe.Pointer(&_configSpecs1)), canvasPtr, libc.UintptrFromInt32(0), 0) } else { if objc == int32(3) { result = XTk_ConfigureInfo(tls, interp, (*TTkCanvas)(unsafe.Pointer(canvasPtr)).Ftkwin, uintptr(unsafe.Pointer(&_configSpecs1)), canvasPtr, libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8)), libc.UintptrFromInt32(0)), 0) } else { result = _ConfigureCanvas(tls, interp, canvasPtr, int64(objc-int32(2)), objv+uintptr(2)*8, int32(TK_CONFIG_ARGV_ONLY)) } } goto _36 _8: ; if objc < int32(3) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(2), objv, __ccgo_ts+27065) result = int32(TCL_ERROR) goto done } v41 = _TagSearchScan(tls, canvasPtr, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp) result = v41 if v41 != TCL_OK { goto done } itemPtr = _TagSearchFirst(tls, *(*uintptr)(unsafe.Pointer(bp))) if itemPtr != libc.UintptrFromInt32(0) { if objc != int32(3) { _EventuallyRedrawItem(tls, canvasPtr, itemPtr) } result = _ItemCoords(tls, canvasPtr, itemPtr, int64(objc-int32(3)), objv+uintptr(3)*8) if objc != int32(3) { _EventuallyRedrawItem(tls, canvasPtr, itemPtr) } } goto _36 _9: ; if objc != int32(6) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(2), objv, __ccgo_ts+27087) result = int32(TCL_ERROR) goto done } if XTk_CanvasGetCoordFromObj(tls, interp, canvasPtr, *(*uintptr)(unsafe.Pointer(objv + 4*8)), bp+80) != TCL_OK || XTk_CanvasGetCoordFromObj(tls, interp, canvasPtr, *(*uintptr)(unsafe.Pointer(objv + 5*8)), bp+80) != TCL_OK { result = int32(TCL_ERROR) goto done } /* * Make a temporary object here that we can reuse for all the * modifications in the loop. */ tmpObj = libtcl9_0.XTcl_NewListObj(tls, int64(2), objv+uintptr(4)*8) v42 = _TagSearchScan(tls, canvasPtr, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp) result = v42 if v42 != TCL_OK { goto doneImove } itemPtr = _TagSearchFirst(tls, *(*uintptr)(unsafe.Pointer(bp))) for { if !(itemPtr != libc.UintptrFromInt32(0)) { break } /* * The TK_MOVABLE_POINTS flag should only be set for types that * support the same semantics of index, dChars and insert methods * as lines and canvases. */ if itemPtr == libc.UintptrFromInt32(0) || !((*TTk_ItemType1)(unsafe.Pointer((*TTk_Item)(unsafe.Pointer(itemPtr)).FtypePtr)).Fflags&libc.Int32FromInt32(TK_MOVABLE_POINTS) != 0) { goto _43 } result = _ItemIndex(tls, canvasPtr, itemPtr, *(*uintptr)(unsafe.Pointer(objv + 3*8)), bp+88) if result != TCL_OK { break } /* * Redraw both item's old and new areas: it's possible that a * replace could result in a new area larger than the old area. * Except if the dCharsProc or insertProc sets the * TK_ITEM_DONT_REDRAW flag, nothing more needs to be done. */ x12 = (*TTk_Item)(unsafe.Pointer(itemPtr)).Fx1 y12 = (*TTk_Item)(unsafe.Pointer(itemPtr)).Fy1 x22 = (*TTk_Item)(unsafe.Pointer(itemPtr)).Fx2 y22 = (*TTk_Item)(unsafe.Pointer(itemPtr)).Fy2 *(*int32)(unsafe.Pointer(itemPtr + 112)) &= ^libc.Int32FromInt32(TK_ITEM_DONT_REDRAW) _ItemDelChars(tls, canvasPtr, itemPtr, int32(*(*TTcl_Size)(unsafe.Pointer(bp + 88))), int32(*(*TTcl_Size)(unsafe.Pointer(bp + 88)))) dontRedraw1 = (*TTk_Item)(unsafe.Pointer(itemPtr)).Fredraw_flags & int32(TK_ITEM_DONT_REDRAW) *(*int32)(unsafe.Pointer(itemPtr + 112)) &= ^libc.Int32FromInt32(TK_ITEM_DONT_REDRAW) _ItemInsert(tls, canvasPtr, itemPtr, int32(*(*TTcl_Size)(unsafe.Pointer(bp + 88))), tmpObj) dontRedraw2 = (*TTk_Item)(unsafe.Pointer(itemPtr)).Fredraw_flags & int32(TK_ITEM_DONT_REDRAW) if !(dontRedraw1 != 0 && dontRedraw2 != 0) { XTk_CanvasEventuallyRedraw(tls, canvasPtr, x12, y12, x22, y22) _EventuallyRedrawItem(tls, canvasPtr, itemPtr) } *(*int32)(unsafe.Pointer(itemPtr + 112)) &= ^libc.Int32FromInt32(TK_ITEM_DONT_REDRAW) goto _43 _43: ; itemPtr = _TagSearchNext(tls, *(*uintptr)(unsafe.Pointer(bp))) } goto doneImove doneImove: ; _objPtr = tmpObj v45 = _objPtr v44 = *(*TTcl_Size)(unsafe.Pointer(v45)) *(*TTcl_Size)(unsafe.Pointer(v45))-- if v44 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr) } goto _36 _10: ; matchPtr = libc.UintptrFromInt32(0) *(*int32)(unsafe.Pointer(bp + 96)) = 0 if objc < int32(3) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(2), objv, __ccgo_ts+27105) result = int32(TCL_ERROR) goto done } arg = libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+104) c = libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(arg))) /* * Lock because the list of types is a global resource that could be * updated by another thread. That's fairly unlikely, but not * impossible. */ libtcl9_0.XTcl_MutexLock(tls, uintptr(unsafe.Pointer(&_typeListMutex))) typePtr = _typeList for { if !(typePtr != libc.UintptrFromInt32(0)) { break } if c == libc.Int32FromUint8(*(*uint8)(unsafe.Pointer((*TTk_ItemType)(unsafe.Pointer(typePtr)).Fname))) && !(libc.Xstrncmp(tls, arg, (*TTk_ItemType)(unsafe.Pointer(typePtr)).Fname, libc.Uint64FromInt64(*(*TTcl_Size)(unsafe.Pointer(bp + 104)))) != 0) { if matchPtr != libc.UintptrFromInt32(0) { libtcl9_0.XTcl_MutexUnlock(tls, uintptr(unsafe.Pointer(&_typeListMutex))) goto badType } matchPtr = typePtr } goto _46 _46: ; typePtr = (*TTk_ItemType)(unsafe.Pointer(typePtr)).FnextPtr } /* * Can unlock now because we no longer look at the fields of the * matched item type that are potentially modified by other threads. */ libtcl9_0.XTcl_MutexUnlock(tls, uintptr(unsafe.Pointer(&_typeListMutex))) if !(matchPtr == libc.UintptrFromInt32(0)) { goto _47 } goto badType badType: ; libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+27127, libc.VaList(bp+336, arg))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+336, __ccgo_ts+179, __ccgo_ts+3058, __ccgo_ts+27163, arg, libc.UintptrFromInt32(0))) result = int32(TCL_ERROR) goto done _47: ; if objc < int32(4) { /* * Allow more specific error return. */ libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(3), objv, __ccgo_ts+27180) result = int32(TCL_ERROR) goto done } typePtr = matchPtr itemPtr = libtcl9_0.XTcl_Alloc(tls, libc.Uint64FromInt64((*TTk_ItemType)(unsafe.Pointer(typePtr)).FitemSize)) v49 = canvasPtr + 656 v48 = *(*TTcl_Size)(unsafe.Pointer(v49)) *(*TTcl_Size)(unsafe.Pointer(v49))++ (*TTk_Item)(unsafe.Pointer(itemPtr)).Fid = v48 (*TTk_Item)(unsafe.Pointer(itemPtr)).FtagPtr = itemPtr + 16 (*TTk_Item)(unsafe.Pointer(itemPtr)).FtagSpace = int64(TK_TAG_SPACE) (*TTk_Item)(unsafe.Pointer(itemPtr)).FnumTags = 0 (*TTk_Item)(unsafe.Pointer(itemPtr)).FtypePtr = typePtr (*TTk_Item)(unsafe.Pointer(itemPtr)).Fstate = int32(TK_STATE_NULL) (*TTk_Item)(unsafe.Pointer(itemPtr)).Fredraw_flags = 0 if _ItemCreate(tls, canvasPtr, itemPtr, int64(objc), objv) != TCL_OK { libtcl9_0.XTcl_Free(tls, itemPtr) result = int32(TCL_ERROR) goto done } (*TTk_Item)(unsafe.Pointer(itemPtr)).FnextPtr = libc.UintptrFromInt32(0) entryPtr1 = (*(*func(*libc.TLS, uintptr, uintptr, uintptr) uintptr)(unsafe.Pointer(&struct{ uintptr }{(*TTcl_HashTable)(unsafe.Pointer(canvasPtr + 672)).FcreateProc})))(tls, canvasPtr+672, uintptr((*TTk_Item)(unsafe.Pointer(itemPtr)).Fid), bp+96) (*TTcl_HashEntry)(unsafe.Pointer(entryPtr1)).FclientData = itemPtr (*TTk_Item)(unsafe.Pointer(itemPtr)).FprevPtr = (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FlastItemPtr (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FhotPtr = itemPtr (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FhotPrevPtr = (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FlastItemPtr if (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FlastItemPtr == libc.UintptrFromInt32(0) { (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FfirstItemPtr = itemPtr } else { (*TTk_Item)(unsafe.Pointer((*TTkCanvas)(unsafe.Pointer(canvasPtr)).FlastItemPtr)).FnextPtr = itemPtr } (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FlastItemPtr = itemPtr *(*int32)(unsafe.Pointer(itemPtr + 112)) |= int32(FORCE_REDRAW) _EventuallyRedrawItem(tls, canvasPtr, itemPtr) *(*int32)(unsafe.Pointer(canvasPtr + 648)) |= int32(REPICK_NEEDED) libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewWideIntObj(tls, (*TTk_Item)(unsafe.Pointer(itemPtr)).Fid)) goto _36 _11: ; if objc != int32(4) && objc != int32(5) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(2), objv, __ccgo_ts+27197) result = int32(TCL_ERROR) goto done } v50 = _TagSearchScan(tls, canvasPtr, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp) result = v50 if v50 != TCL_OK { goto done } itemPtr = _TagSearchFirst(tls, *(*uintptr)(unsafe.Pointer(bp))) for { if !(itemPtr != libc.UintptrFromInt32(0)) { break } if (*TTk_ItemType1)(unsafe.Pointer((*TTk_Item)(unsafe.Pointer(itemPtr)).FtypePtr)).FindexProc == libc.UintptrFromInt32(0) || (*TTk_ItemType1)(unsafe.Pointer((*TTk_Item)(unsafe.Pointer(itemPtr)).FtypePtr)).FdCharsProc == libc.UintptrFromInt32(0) { goto _51 } result = _ItemIndex(tls, canvasPtr, itemPtr, *(*uintptr)(unsafe.Pointer(objv + 3*8)), bp+112) if result != TCL_OK { goto done } if objc == int32(5) { result = _ItemIndex(tls, canvasPtr, itemPtr, *(*uintptr)(unsafe.Pointer(objv + 4*8)), bp+120) if result != TCL_OK { goto done } } else { *(*TTcl_Size)(unsafe.Pointer(bp + 120)) = *(*TTcl_Size)(unsafe.Pointer(bp + 112)) } /* * Redraw both item's old and new areas: it's possible that a * delete could result in a new area larger than the old area. * Except if the dCharsProc sets the TK_ITEM_DONT_REDRAW flag, * nothing more needs to be done. */ x13 = (*TTk_Item)(unsafe.Pointer(itemPtr)).Fx1 y13 = (*TTk_Item)(unsafe.Pointer(itemPtr)).Fy1 x23 = (*TTk_Item)(unsafe.Pointer(itemPtr)).Fx2 y23 = (*TTk_Item)(unsafe.Pointer(itemPtr)).Fy2 *(*int32)(unsafe.Pointer(itemPtr + 112)) &= ^libc.Int32FromInt32(TK_ITEM_DONT_REDRAW) _ItemDelChars(tls, canvasPtr, itemPtr, int32(*(*TTcl_Size)(unsafe.Pointer(bp + 112))), int32(*(*TTcl_Size)(unsafe.Pointer(bp + 120)))) if !((*TTk_Item)(unsafe.Pointer(itemPtr)).Fredraw_flags&libc.Int32FromInt32(TK_ITEM_DONT_REDRAW) != 0) { XTk_CanvasEventuallyRedraw(tls, canvasPtr, x13, y13, x23, y23) _EventuallyRedrawItem(tls, canvasPtr, itemPtr) } *(*int32)(unsafe.Pointer(itemPtr + 112)) &= ^libc.Int32FromInt32(TK_ITEM_DONT_REDRAW) goto _51 _51: ; itemPtr = _TagSearchNext(tls, *(*uintptr)(unsafe.Pointer(bp))) } goto _36 _12: ; i1 = int64(2) for { if !(i1 < int64(objc)) { break } v53 = _TagSearchScan(tls, canvasPtr, *(*uintptr)(unsafe.Pointer(objv + uintptr(i1)*8)), bp) result = v53 if v53 != TCL_OK { goto done } itemPtr = _TagSearchFirst(tls, *(*uintptr)(unsafe.Pointer(bp))) for { if !(itemPtr != libc.UintptrFromInt32(0)) { break } _EventuallyRedrawItem(tls, canvasPtr, itemPtr) if (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FbindingTable != libc.UintptrFromInt32(0) { XTk_DeleteAllBindings(tls, (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FbindingTable, itemPtr) } _ItemDelete(tls, canvasPtr, itemPtr) if (*TTk_Item)(unsafe.Pointer(itemPtr)).FtagPtr != itemPtr+16 { libtcl9_0.XTcl_Free(tls, (*TTk_Item)(unsafe.Pointer(itemPtr)).FtagPtr) } entryPtr2 = (*(*func(*libc.TLS, uintptr, uintptr) uintptr)(unsafe.Pointer(&struct{ uintptr }{(*TTcl_HashTable)(unsafe.Pointer(canvasPtr + 672)).FfindProc})))(tls, canvasPtr+672, uintptr((*TTk_Item)(unsafe.Pointer(itemPtr)).Fid)) libtcl9_0.XTcl_DeleteHashEntry(tls, entryPtr2) if (*TTk_Item)(unsafe.Pointer(itemPtr)).FnextPtr != libc.UintptrFromInt32(0) { (*TTk_Item1)(unsafe.Pointer((*TTk_Item)(unsafe.Pointer(itemPtr)).FnextPtr)).FprevPtr = (*TTk_Item)(unsafe.Pointer(itemPtr)).FprevPtr } if (*TTk_Item)(unsafe.Pointer(itemPtr)).FprevPtr != libc.UintptrFromInt32(0) { (*TTk_Item1)(unsafe.Pointer((*TTk_Item)(unsafe.Pointer(itemPtr)).FprevPtr)).FnextPtr = (*TTk_Item)(unsafe.Pointer(itemPtr)).FnextPtr } if (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FfirstItemPtr == itemPtr { (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FfirstItemPtr = (*TTk_Item)(unsafe.Pointer(itemPtr)).FnextPtr if (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FfirstItemPtr == libc.UintptrFromInt32(0) { (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FlastItemPtr = libc.UintptrFromInt32(0) } } if (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FlastItemPtr == itemPtr { (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FlastItemPtr = (*TTk_Item)(unsafe.Pointer(itemPtr)).FprevPtr } libtcl9_0.XTcl_Free(tls, itemPtr) if itemPtr == (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FcurrentItemPtr { (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FcurrentItemPtr = libc.UintptrFromInt32(0) *(*int32)(unsafe.Pointer(canvasPtr + 648)) |= int32(REPICK_NEEDED) } if itemPtr == (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FnewCurrentPtr { (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FnewCurrentPtr = libc.UintptrFromInt32(0) *(*int32)(unsafe.Pointer(canvasPtr + 648)) |= int32(REPICK_NEEDED) } if itemPtr == (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FtextInfo.FfocusItemPtr { (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FtextInfo.FfocusItemPtr = libc.UintptrFromInt32(0) } if itemPtr == (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FtextInfo.FselItemPtr { (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FtextInfo.FselItemPtr = libc.UintptrFromInt32(0) } if itemPtr == (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FhotPtr || itemPtr == (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FhotPrevPtr { (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FhotPtr = libc.UintptrFromInt32(0) } goto _54 _54: ; itemPtr = _TagSearchNext(tls, *(*uintptr)(unsafe.Pointer(bp))) } goto _52 _52: ; i1++ } goto _36 _13: ; if objc != int32(3) && objc != int32(4) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(2), objv, __ccgo_ts+27218) result = int32(TCL_ERROR) goto done } if objc == int32(4) { tag = XTk_GetUid(tls, libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 3*8)), libc.UintptrFromInt32(0))) } else { tag = XTk_GetUid(tls, libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8)), libc.UintptrFromInt32(0))) } v55 = _TagSearchScan(tls, canvasPtr, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp) result = v55 if v55 != TCL_OK { goto done } itemPtr = _TagSearchFirst(tls, *(*uintptr)(unsafe.Pointer(bp))) for { if !(itemPtr != libc.UintptrFromInt32(0)) { break } i2 = (*TTk_Item)(unsafe.Pointer(itemPtr)).FnumTags - int64(1) for { if !(i2 != int64(-libc.Int32FromInt32(1))) { break } if *(*TTk_Uid)(unsafe.Pointer((*TTk_Item)(unsafe.Pointer(itemPtr)).FtagPtr + uintptr(i2)*8)) == tag { /* * Don't shuffle the tags sequence: memmove the tags. */ libc.Xmemmove(tls, (*TTk_Item)(unsafe.Pointer(itemPtr)).FtagPtr+uintptr(i2)*8, (*TTk_Item)(unsafe.Pointer(itemPtr)).FtagPtr+uintptr(i2)*8+uintptr(1)*8, libc.Uint64FromInt64((*TTk_Item)(unsafe.Pointer(itemPtr)).FnumTags-(i2+libc.Int64FromInt32(1)))*uint64(8)) (*TTk_Item)(unsafe.Pointer(itemPtr)).FnumTags-- /* * There must be no break here: all tags with the same name must * be deleted. */ } goto _57 _57: ; i2-- } goto _56 _56: ; itemPtr = _TagSearchNext(tls, *(*uintptr)(unsafe.Pointer(bp))) } goto _36 _14: ; if objc < int32(3) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(2), objv, __ccgo_ts+27240) result = int32(TCL_ERROR) goto done } result = _FindItems(tls, interp, canvasPtr, int64(objc), objv, libc.UintptrFromInt32(0), int64(libc.Int32FromInt32(2)), bp) goto _36 _15: ; if objc > int32(3) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(2), objv, __ccgo_ts+27264) result = int32(TCL_ERROR) goto done } itemPtr = (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FtextInfo.FfocusItemPtr if objc == int32(2) { if itemPtr != libc.UintptrFromInt32(0) { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewWideIntObj(tls, (*TTk_Item)(unsafe.Pointer(itemPtr)).Fid)) } goto done } if (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FtextInfo.FgotFocus != 0 { _EventuallyRedrawItem(tls, canvasPtr, itemPtr) } if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8)), libc.UintptrFromInt32(0))))) == 0 { (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FtextInfo.FfocusItemPtr = libc.UintptrFromInt32(0) goto done } v58 = _TagSearchScan(tls, canvasPtr, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp) result = v58 if v58 != TCL_OK { goto done } itemPtr = _TagSearchFirst(tls, *(*uintptr)(unsafe.Pointer(bp))) for { if !(itemPtr != libc.UintptrFromInt32(0)) { break } if (*TTk_ItemType1)(unsafe.Pointer((*TTk_Item)(unsafe.Pointer(itemPtr)).FtypePtr)).FicursorProc != libc.UintptrFromInt32(0) { break } goto _59 _59: ; itemPtr = _TagSearchNext(tls, *(*uintptr)(unsafe.Pointer(bp))) } if itemPtr == libc.UintptrFromInt32(0) { goto done } (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FtextInfo.FfocusItemPtr = itemPtr if (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FtextInfo.FgotFocus != 0 { _EventuallyRedrawItem(tls, canvasPtr, itemPtr) } goto _36 _16: ; if objc != int32(3) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(2), objv, __ccgo_ts+27274) result = int32(TCL_ERROR) goto done } v60 = _TagSearchScan(tls, canvasPtr, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp) result = v60 if v60 != TCL_OK { goto done } itemPtr = _TagSearchFirst(tls, *(*uintptr)(unsafe.Pointer(bp))) if itemPtr != libc.UintptrFromInt32(0) { resultObj = libtcl9_0.XTcl_NewObj(tls) i3 = 0 for { if !(i3 < int32((*TTk_Item)(unsafe.Pointer(itemPtr)).FnumTags)) { break } libtcl9_0.XTcl_ListObjAppendElement(tls, libc.UintptrFromInt32(0), resultObj, libtcl9_0.XTcl_NewStringObj(tls, *(*TTk_Uid)(unsafe.Pointer((*TTk_Item)(unsafe.Pointer(itemPtr)).FtagPtr + uintptr(i3)*8)), int64(-libc.Int32FromInt32(1)))) goto _61 _61: ; i3++ } libtcl9_0.XTcl_SetObjResult(tls, interp, resultObj) } goto _36 _17: ; if objc != int32(4) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(2), objv, __ccgo_ts+27282) result = int32(TCL_ERROR) goto done } v62 = _TagSearchScan(tls, canvasPtr, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp) result = v62 if v62 != TCL_OK { goto done } itemPtr = _TagSearchFirst(tls, *(*uintptr)(unsafe.Pointer(bp))) for { if !(itemPtr != libc.UintptrFromInt32(0)) { break } if (*TTk_ItemType1)(unsafe.Pointer((*TTk_Item)(unsafe.Pointer(itemPtr)).FtypePtr)).FindexProc == libc.UintptrFromInt32(0) || (*TTk_ItemType1)(unsafe.Pointer((*TTk_Item)(unsafe.Pointer(itemPtr)).FtypePtr)).FicursorProc == libc.UintptrFromInt32(0) { goto done } result = _ItemIndex(tls, canvasPtr, itemPtr, *(*uintptr)(unsafe.Pointer(objv + 3*8)), bp+128) if result != TCL_OK { goto done } _ItemCursor(tls, canvasPtr, itemPtr, int32(*(*TTcl_Size)(unsafe.Pointer(bp + 128)))) if itemPtr == (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FtextInfo.FfocusItemPtr && (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FtextInfo.FcursorOn != 0 { _EventuallyRedrawItem(tls, canvasPtr, itemPtr) } goto _63 _63: ; itemPtr = _TagSearchNext(tls, *(*uintptr)(unsafe.Pointer(bp))) } goto _36 _18: ; if objc != int32(4) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(2), objv, __ccgo_ts+27296) result = int32(TCL_ERROR) goto done } v64 = _TagSearchScan(tls, canvasPtr, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp) result = v64 if v64 != TCL_OK { goto done } itemPtr = _TagSearchFirst(tls, *(*uintptr)(unsafe.Pointer(bp))) for { if !(itemPtr != libc.UintptrFromInt32(0)) { break } if (*TTk_ItemType1)(unsafe.Pointer((*TTk_Item)(unsafe.Pointer(itemPtr)).FtypePtr)).FindexProc != libc.UintptrFromInt32(0) { break } goto _65 _65: ; itemPtr = _TagSearchNext(tls, *(*uintptr)(unsafe.Pointer(bp))) } if itemPtr == libc.UintptrFromInt32(0) { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+27311, libc.VaList(bp+336, libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8)), libc.UintptrFromInt32(0))))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+336, __ccgo_ts+179, __ccgo_ts+27003, __ccgo_ts+27345, libc.UintptrFromInt32(0))) result = int32(TCL_ERROR) goto done } result = _ItemIndex(tls, canvasPtr, itemPtr, *(*uintptr)(unsafe.Pointer(objv + 3*8)), bp+136) if result != TCL_OK { goto done } libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewWideIntObj(tls, *(*TTcl_Size)(unsafe.Pointer(bp + 136)))) goto _36 _19: ; if objc != int32(5) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(2), objv, __ccgo_ts+27360) result = int32(TCL_ERROR) goto done } v66 = _TagSearchScan(tls, canvasPtr, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp) result = v66 if v66 != TCL_OK { goto done } itemPtr = _TagSearchFirst(tls, *(*uintptr)(unsafe.Pointer(bp))) for { if !(itemPtr != libc.UintptrFromInt32(0)) { break } if (*TTk_ItemType1)(unsafe.Pointer((*TTk_Item)(unsafe.Pointer(itemPtr)).FtypePtr)).FindexProc == libc.UintptrFromInt32(0) || (*TTk_ItemType1)(unsafe.Pointer((*TTk_Item)(unsafe.Pointer(itemPtr)).FtypePtr)).FinsertProc == libc.UintptrFromInt32(0) { goto _67 } result = _ItemIndex(tls, canvasPtr, itemPtr, *(*uintptr)(unsafe.Pointer(objv + 3*8)), bp+144) if result != TCL_OK { goto done } /* * Redraw both item's old and new areas: it's possible that an * insertion could result in a new area either larger or smaller * than the old area. Except if the insertProc sets the * TK_ITEM_DONT_REDRAW flag, nothing more needs to be done. */ x14 = (*TTk_Item)(unsafe.Pointer(itemPtr)).Fx1 y14 = (*TTk_Item)(unsafe.Pointer(itemPtr)).Fy1 x24 = (*TTk_Item)(unsafe.Pointer(itemPtr)).Fx2 y24 = (*TTk_Item)(unsafe.Pointer(itemPtr)).Fy2 *(*int32)(unsafe.Pointer(itemPtr + 112)) &= ^libc.Int32FromInt32(TK_ITEM_DONT_REDRAW) _ItemInsert(tls, canvasPtr, itemPtr, int32(*(*TTcl_Size)(unsafe.Pointer(bp + 144))), *(*uintptr)(unsafe.Pointer(objv + 4*8))) if !((*TTk_Item)(unsafe.Pointer(itemPtr)).Fredraw_flags&libc.Int32FromInt32(TK_ITEM_DONT_REDRAW) != 0) { XTk_CanvasEventuallyRedraw(tls, canvasPtr, x14, y14, x24, y24) _EventuallyRedrawItem(tls, canvasPtr, itemPtr) } *(*int32)(unsafe.Pointer(itemPtr + 112)) &= ^libc.Int32FromInt32(TK_ITEM_DONT_REDRAW) goto _67 _67: ; itemPtr = _TagSearchNext(tls, *(*uintptr)(unsafe.Pointer(bp))) } goto _36 _20: ; if objc != int32(4) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(2), objv, __ccgo_ts+27386) result = int32(TCL_ERROR) goto done } v68 = _TagSearchScan(tls, canvasPtr, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp) result = v68 if v68 != TCL_OK { goto done } itemPtr = _TagSearchFirst(tls, *(*uintptr)(unsafe.Pointer(bp))) if itemPtr != libc.UintptrFromInt32(0) { result = _ItemConfigValue(tls, canvasPtr, itemPtr, *(*uintptr)(unsafe.Pointer(objv + 3*8))) } goto _36 _21: ; if objc < int32(3) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(2), objv, __ccgo_ts+27401) result = int32(TCL_ERROR) goto done } v69 = _TagSearchScan(tls, canvasPtr, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp) result = v69 if v69 != TCL_OK { goto done } itemPtr = _TagSearchFirst(tls, *(*uintptr)(unsafe.Pointer(bp))) for { if !(itemPtr != libc.UintptrFromInt32(0)) { break } if objc == int32(3) { result = _ItemConfigInfo(tls, canvasPtr, itemPtr, libc.UintptrFromInt32(0)) } else { if objc == int32(4) { result = _ItemConfigInfo(tls, canvasPtr, itemPtr, *(*uintptr)(unsafe.Pointer(objv + 3*8))) } else { _EventuallyRedrawItem(tls, canvasPtr, itemPtr) result = _ItemConfigure(tls, canvasPtr, itemPtr, int64(objc-int32(3)), objv+uintptr(3)*8) _EventuallyRedrawItem(tls, canvasPtr, itemPtr) *(*int32)(unsafe.Pointer(canvasPtr + 648)) |= int32(REPICK_NEEDED) } } if result != TCL_OK || objc < int32(5) { break } goto _70 _70: ; itemPtr = _TagSearchNext(tls, *(*uintptr)(unsafe.Pointer(bp))) } goto _36 _22: ; if objc != int32(3) && objc != int32(4) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(2), objv, __ccgo_ts+27429) result = int32(TCL_ERROR) goto done } /* * First find the item just after which we'll insert the named items. */ if objc == int32(3) { itemPtr = libc.UintptrFromInt32(0) } else { v71 = _TagSearchScan(tls, canvasPtr, *(*uintptr)(unsafe.Pointer(objv + 3*8)), bp) result = v71 if v71 != TCL_OK { goto done } itemPtr = _TagSearchFirst(tls, *(*uintptr)(unsafe.Pointer(bp))) if itemPtr == libc.UintptrFromInt32(0) { goto done } itemPtr = (*TTk_Item)(unsafe.Pointer(itemPtr)).FprevPtr } result = _RelinkItems(tls, canvasPtr, *(*uintptr)(unsafe.Pointer(objv + 2*8)), itemPtr, bp) goto _36 _23: ; if objc != int32(5) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(2), objv, __ccgo_ts+27449) result = int32(TCL_ERROR) goto done } if XTk_CanvasGetCoordFromObj(tls, interp, canvasPtr, *(*uintptr)(unsafe.Pointer(objv + 3*8)), bp+152) != TCL_OK || XTk_CanvasGetCoordFromObj(tls, interp, canvasPtr, *(*uintptr)(unsafe.Pointer(objv + 4*8)), bp+160) != TCL_OK { result = int32(TCL_ERROR) goto done } v72 = _TagSearchScan(tls, canvasPtr, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp) result = v72 if v72 != TCL_OK { goto done } itemPtr = _TagSearchFirst(tls, *(*uintptr)(unsafe.Pointer(bp))) for { if !(itemPtr != libc.UintptrFromInt32(0)) { break } _EventuallyRedrawItem(tls, canvasPtr, itemPtr) _ItemTranslate(tls, canvasPtr, itemPtr, *(*float64)(unsafe.Pointer(bp + 152)), *(*float64)(unsafe.Pointer(bp + 160))) _EventuallyRedrawItem(tls, canvasPtr, itemPtr) *(*int32)(unsafe.Pointer(canvasPtr + 648)) |= int32(REPICK_NEEDED) goto _73 _73: ; itemPtr = _TagSearchNext(tls, *(*uintptr)(unsafe.Pointer(bp))) } goto _36 _24: ; oldX = libc.Float64FromInt32(0) oldY = libc.Float64FromInt32(0) if objc != int32(5) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(2), objv, __ccgo_ts+27473) result = int32(TCL_ERROR) goto done } xBlank = 0 if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 3*8)), libc.UintptrFromInt32(0))))) == int32('\000') { xBlank = int32(1) } else { if XTk_CanvasGetCoordFromObj(tls, interp, canvasPtr, *(*uintptr)(unsafe.Pointer(objv + 3*8)), bp+168) != TCL_OK { result = int32(TCL_ERROR) goto done } } yBlank = 0 if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 4*8)), libc.UintptrFromInt32(0))))) == int32('\000') { yBlank = int32(1) } else { if XTk_CanvasGetCoordFromObj(tls, interp, canvasPtr, *(*uintptr)(unsafe.Pointer(objv + 4*8)), bp+176) != TCL_OK { result = int32(TCL_ERROR) goto done } } v74 = _TagSearchScan(tls, canvasPtr, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp) result = v74 if v74 != TCL_OK { goto done } itemPtr = _TagSearchFirst(tls, *(*uintptr)(unsafe.Pointer(bp))) if itemPtr != libc.UintptrFromInt32(0) { oldX = float64((*TTk_Item)(unsafe.Pointer(itemPtr)).Fx1) oldY = float64((*TTk_Item)(unsafe.Pointer(itemPtr)).Fy1) /* * Calculate the displacement. */ if xBlank != 0 { xAmount1 = libc.Float64FromInt32(0) } else { xAmount1 = *(*float64)(unsafe.Pointer(bp + 168)) - oldX } if yBlank != 0 { yAmount1 = libc.Float64FromInt32(0) } else { yAmount1 = *(*float64)(unsafe.Pointer(bp + 176)) - oldY } /* * Move the object(s). */ v75 = _TagSearchScan(tls, canvasPtr, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp) result = v75 if v75 != TCL_OK { goto done } itemPtr = _TagSearchFirst(tls, *(*uintptr)(unsafe.Pointer(bp))) for { if !(itemPtr != libc.UintptrFromInt32(0)) { break } _EventuallyRedrawItem(tls, canvasPtr, itemPtr) _ItemTranslate(tls, canvasPtr, itemPtr, xAmount1, yAmount1) _EventuallyRedrawItem(tls, canvasPtr, itemPtr) *(*int32)(unsafe.Pointer(canvasPtr + 648)) |= int32(REPICK_NEEDED) goto _76 _76: ; itemPtr = _TagSearchNext(tls, *(*uintptr)(unsafe.Pointer(bp))) } } goto _36 _25: ; result = XTkCanvPostscriptObjCmd(tls, canvasPtr, interp, int64(objc), objv) goto _36 _26: ; if objc != int32(3) && objc != int32(4) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(2), objv, __ccgo_ts+27485) result = int32(TCL_ERROR) goto done } /* * First find the item just after which we'll insert the named items. */ if objc == int32(3) { prevPtr = (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FlastItemPtr } else { prevPtr = libc.UintptrFromInt32(0) v77 = _TagSearchScan(tls, canvasPtr, *(*uintptr)(unsafe.Pointer(objv + 3*8)), bp) result = v77 if v77 != TCL_OK { goto done } itemPtr = _TagSearchFirst(tls, *(*uintptr)(unsafe.Pointer(bp))) for { if !(itemPtr != libc.UintptrFromInt32(0)) { break } prevPtr = itemPtr goto _78 _78: ; itemPtr = _TagSearchNext(tls, *(*uintptr)(unsafe.Pointer(bp))) } if prevPtr == libc.UintptrFromInt32(0) { goto done } } result = _RelinkItems(tls, canvasPtr, *(*uintptr)(unsafe.Pointer(objv + 2*8)), prevPtr, bp) goto _36 _27: ; if objc != int32(6) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(2), objv, __ccgo_ts+27505) result = int32(TCL_ERROR) goto done } v79 = _TagSearchScan(tls, canvasPtr, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp) result = v79 if v79 != TCL_OK { goto done } itemPtr = _TagSearchFirst(tls, *(*uintptr)(unsafe.Pointer(bp))) for { if !(itemPtr != libc.UintptrFromInt32(0)) { break } if (*TTk_ItemType1)(unsafe.Pointer((*TTk_Item)(unsafe.Pointer(itemPtr)).FtypePtr)).FindexProc == libc.UintptrFromInt32(0) || (*TTk_ItemType1)(unsafe.Pointer((*TTk_Item)(unsafe.Pointer(itemPtr)).FtypePtr)).FdCharsProc == libc.UintptrFromInt32(0) || (*TTk_ItemType1)(unsafe.Pointer((*TTk_Item)(unsafe.Pointer(itemPtr)).FtypePtr)).FinsertProc == libc.UintptrFromInt32(0) { goto _80 } result = _ItemIndex(tls, canvasPtr, itemPtr, *(*uintptr)(unsafe.Pointer(objv + 3*8)), bp+184) if result != TCL_OK { goto done } result = _ItemIndex(tls, canvasPtr, itemPtr, *(*uintptr)(unsafe.Pointer(objv + 4*8)), bp+192) if result != TCL_OK { goto done } /* * Redraw both item's old and new areas: it's possible that a * replace could result in a new area larger than the old area. * Except if the dCharsProc or insertProc sets the * TK_ITEM_DONT_REDRAW flag, nothing more needs to be done. */ x15 = (*TTk_Item)(unsafe.Pointer(itemPtr)).Fx1 y15 = (*TTk_Item)(unsafe.Pointer(itemPtr)).Fy1 x25 = (*TTk_Item)(unsafe.Pointer(itemPtr)).Fx2 y25 = (*TTk_Item)(unsafe.Pointer(itemPtr)).Fy2 *(*int32)(unsafe.Pointer(itemPtr + 112)) &= ^libc.Int32FromInt32(TK_ITEM_DONT_REDRAW) _ItemDelChars(tls, canvasPtr, itemPtr, int32(*(*TTcl_Size)(unsafe.Pointer(bp + 184))), int32(*(*TTcl_Size)(unsafe.Pointer(bp + 192)))) dontRedraw11 = (*TTk_Item)(unsafe.Pointer(itemPtr)).Fredraw_flags & int32(TK_ITEM_DONT_REDRAW) *(*int32)(unsafe.Pointer(itemPtr + 112)) &= ^libc.Int32FromInt32(TK_ITEM_DONT_REDRAW) _ItemInsert(tls, canvasPtr, itemPtr, int32(*(*TTcl_Size)(unsafe.Pointer(bp + 184))), *(*uintptr)(unsafe.Pointer(objv + 5*8))) dontRedraw21 = (*TTk_Item)(unsafe.Pointer(itemPtr)).Fredraw_flags & int32(TK_ITEM_DONT_REDRAW) if !(dontRedraw11 != 0 && dontRedraw21 != 0) { XTk_CanvasEventuallyRedraw(tls, canvasPtr, x15, y15, x25, y25) _EventuallyRedrawItem(tls, canvasPtr, itemPtr) } *(*int32)(unsafe.Pointer(itemPtr + 112)) &= ^libc.Int32FromInt32(TK_ITEM_DONT_REDRAW) goto _80 _80: ; itemPtr = _TagSearchNext(tls, *(*uintptr)(unsafe.Pointer(bp))) } goto _36 _28: ; canvas = canvasPtr if objc != int32(6) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(2), objv, __ccgo_ts+27531) result = int32(TCL_ERROR) goto done } if XTk_CanvasGetCoordFromObj(tls, interp, canvas, *(*uintptr)(unsafe.Pointer(objv + 3*8)), bp+200) != TCL_OK || XTk_CanvasGetCoordFromObj(tls, interp, canvas, *(*uintptr)(unsafe.Pointer(objv + 4*8)), bp+208) != TCL_OK || libtcl9_0.XTcl_GetDoubleFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 5*8)), bp+216) != TCL_OK { result = int32(TCL_ERROR) goto done } *(*float64)(unsafe.Pointer(bp + 216)) = float64(*(*float64)(unsafe.Pointer(bp + 216))*float64(3.1415927)) / float64(180) v81 = _TagSearchScan(tls, canvasPtr, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp) result = v81 if v81 != TCL_OK { goto done } itemPtr = _TagSearchFirst(tls, *(*uintptr)(unsafe.Pointer(bp))) for { if !(itemPtr != libc.UintptrFromInt32(0)) { break } _EventuallyRedrawItem(tls, canvasPtr, itemPtr) _ItemRotate(tls, canvasPtr, itemPtr, *(*float64)(unsafe.Pointer(bp + 200)), *(*float64)(unsafe.Pointer(bp + 208)), *(*float64)(unsafe.Pointer(bp + 216))) _EventuallyRedrawItem(tls, canvasPtr, itemPtr) *(*int32)(unsafe.Pointer(canvasPtr + 648)) |= int32(REPICK_NEEDED) goto _82 _82: ; itemPtr = _TagSearchNext(tls, *(*uintptr)(unsafe.Pointer(bp))) } goto _36 _29: ; if objc != int32(7) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(2), objv, __ccgo_ts+27549) result = int32(TCL_ERROR) goto done } if XTk_CanvasGetCoordFromObj(tls, interp, canvasPtr, *(*uintptr)(unsafe.Pointer(objv + 3*8)), bp+224) != TCL_OK || XTk_CanvasGetCoordFromObj(tls, interp, canvasPtr, *(*uintptr)(unsafe.Pointer(objv + 4*8)), bp+232) != TCL_OK || libtcl9_0.XTcl_GetDoubleFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 5*8)), bp+240) != TCL_OK || libtcl9_0.XTcl_GetDoubleFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 6*8)), bp+248) != TCL_OK { result = int32(TCL_ERROR) goto done } if *(*float64)(unsafe.Pointer(bp + 240)) == float64(0) || *(*float64)(unsafe.Pointer(bp + 248)) == float64(0) { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+27587, int64(-libc.Int32FromInt32(1)))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+336, __ccgo_ts+179, __ccgo_ts+27003, __ccgo_ts+27615, libc.UintptrFromInt32(0))) result = int32(TCL_ERROR) goto done } v83 = _TagSearchScan(tls, canvasPtr, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp) result = v83 if v83 != TCL_OK { goto done } itemPtr = _TagSearchFirst(tls, *(*uintptr)(unsafe.Pointer(bp))) for { if !(itemPtr != libc.UintptrFromInt32(0)) { break } _EventuallyRedrawItem(tls, canvasPtr, itemPtr) _ItemScale(tls, canvasPtr, itemPtr, *(*float64)(unsafe.Pointer(bp + 224)), *(*float64)(unsafe.Pointer(bp + 232)), *(*float64)(unsafe.Pointer(bp + 240)), *(*float64)(unsafe.Pointer(bp + 248))) _EventuallyRedrawItem(tls, canvasPtr, itemPtr) *(*int32)(unsafe.Pointer(canvasPtr + 648)) |= int32(REPICK_NEEDED) goto _84 _84: ; itemPtr = _TagSearchNext(tls, *(*uintptr)(unsafe.Pointer(bp))) } goto _36 _30: ; *(*int32)(unsafe.Pointer(bp + 264)) = int32(10) if objc < int32(5) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(2), objv, __ccgo_ts+27625) result = int32(TCL_ERROR) } else { if libtcl9_0.XTcl_GetIndexFromObjStruct(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), uintptr(unsafe.Pointer(&_optionStrings18)), libc.Int64FromUint64(libc.Uint64FromInt64(8)), __ccgo_ts+22351, libc.Int32FromInt32(0)|libc.Int32FromUint64(libc.Uint64FromInt64(4)<= int32(4) { v86 = _TagSearchScan(tls, canvasPtr, *(*uintptr)(unsafe.Pointer(objv + 3*8)), bp) result = v86 if v86 != TCL_OK { goto done } itemPtr = _TagSearchFirst(tls, *(*uintptr)(unsafe.Pointer(bp))) for { if !(itemPtr != libc.UintptrFromInt32(0)) { break } if (*TTk_ItemType1)(unsafe.Pointer((*TTk_Item)(unsafe.Pointer(itemPtr)).FtypePtr)).FindexProc != libc.UintptrFromInt32(0) && (*TTk_ItemType1)(unsafe.Pointer((*TTk_Item)(unsafe.Pointer(itemPtr)).FtypePtr)).FselectionProc != libc.UintptrFromInt32(0) { break } goto _87 _87: ; itemPtr = _TagSearchNext(tls, *(*uintptr)(unsafe.Pointer(bp))) } if itemPtr == libc.UintptrFromInt32(0) { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+27691, libc.VaList(bp+336, libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 3*8)), libc.UintptrFromInt32(0))))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+336, __ccgo_ts+179, __ccgo_ts+27003, __ccgo_ts+27740, libc.UintptrFromInt32(0))) result = int32(TCL_ERROR) goto done } } if objc == int32(5) { result = _ItemIndex(tls, canvasPtr, itemPtr, *(*uintptr)(unsafe.Pointer(objv + 4*8)), bp+272) if result != TCL_OK { goto done } } if libtcl9_0.XTcl_GetIndexFromObjStruct(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), uintptr(unsafe.Pointer(&_optionStrings19)), libc.Int64FromUint64(libc.Uint64FromInt64(8)), __ccgo_ts+27756, libc.Int32FromInt32(0)|libc.Int32FromUint64(libc.Uint64FromInt64(4)< 0 { newX1 = (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FxOrigin + *(*int32)(unsafe.Pointer(bp + 284))**(*int32)(unsafe.Pointer(bp + 296)) } else { newX1 = int32(float64((*TTkCanvas)(unsafe.Pointer(canvasPtr)).FxOrigin) + float64(float64(float64(*(*int32)(unsafe.Pointer(bp + 284)))*libc.Float64FromFloat64(0.1))*float64((*TTk_FakeWin)(unsafe.Pointer((*TTkCanvas)(unsafe.Pointer(canvasPtr)).Ftkwin)).Fchanges.Fwidth-libc.Int32FromInt32(2)*(*TTkCanvas)(unsafe.Pointer(canvasPtr)).Finset))) } default: result = int32(TCL_ERROR) goto done } _CanvasSetOrigin(tls, canvasPtr, newX1, (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FyOrigin) goto _36 _34: ; newY1 = 0 if objc == int32(2) { libtcl9_0.XTcl_SetObjResult(tls, interp, _ScrollFractions(tls, (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FyOrigin+(*TTkCanvas)(unsafe.Pointer(canvasPtr)).Finset, (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FyOrigin+(*TTk_FakeWin)(unsafe.Pointer((*TTkCanvas)(unsafe.Pointer(canvasPtr)).Ftkwin)).Fchanges.Fheight-(*TTkCanvas)(unsafe.Pointer(canvasPtr)).Finset, (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FscrollY1, (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FscrollY2)) goto _36 } type11 = XTk_GetScrollInfoObj(tls, interp, int64(objc), objv, bp+304, bp+300) switch type11 { case int32(TK_SCROLL_MOVETO): newY1 = (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FscrollY1 - (*TTkCanvas)(unsafe.Pointer(canvasPtr)).Finset + int32(float64(*(*float64)(unsafe.Pointer(bp + 304))*float64((*TTkCanvas)(unsafe.Pointer(canvasPtr)).FscrollY2-(*TTkCanvas)(unsafe.Pointer(canvasPtr)).FscrollY1))+libc.Float64FromFloat64(0.5)) case int32(TK_SCROLL_PAGES): newY1 = int32(float64((*TTkCanvas)(unsafe.Pointer(canvasPtr)).FyOrigin) + float64(float64(float64(*(*int32)(unsafe.Pointer(bp + 300)))*libc.Float64FromFloat64(0.9))*float64((*TTk_FakeWin)(unsafe.Pointer((*TTkCanvas)(unsafe.Pointer(canvasPtr)).Ftkwin)).Fchanges.Fheight-libc.Int32FromInt32(2)*(*TTkCanvas)(unsafe.Pointer(canvasPtr)).Finset))) case int32(TK_SCROLL_UNITS): XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), (*TTkCanvas)(unsafe.Pointer(canvasPtr)).Ftkwin, (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FyScrollIncrementObj, bp+312) if *(*int32)(unsafe.Pointer(bp + 312)) > 0 { newY1 = (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FyOrigin + *(*int32)(unsafe.Pointer(bp + 300))**(*int32)(unsafe.Pointer(bp + 312)) } else { newY1 = int32(float64((*TTkCanvas)(unsafe.Pointer(canvasPtr)).FyOrigin) + float64(float64(float64(*(*int32)(unsafe.Pointer(bp + 300)))*libc.Float64FromFloat64(0.1))*float64((*TTk_FakeWin)(unsafe.Pointer((*TTkCanvas)(unsafe.Pointer(canvasPtr)).Ftkwin)).Fchanges.Fheight-libc.Int32FromInt32(2)*(*TTkCanvas)(unsafe.Pointer(canvasPtr)).Finset))) } default: result = int32(TCL_ERROR) goto done } _CanvasSetOrigin(tls, canvasPtr, (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FxOrigin, newY1) goto _36 _35: ; *(*int32)(unsafe.Pointer(bp + 316)) = int32(1) *(*int32)(unsafe.Pointer(bp + 320)) = int32(1) if objc < int32(3) || objc > int32(5) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(2), objv, __ccgo_ts+27774) result = int32(TCL_ERROR) goto done } v89 = XTk_FindPhoto(tls, interp, libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8)), libc.UintptrFromInt32(0))) photohandle = v89 if v89 == uintptr(0) { result = int32(TCL_ERROR) goto done } /* * If we are given a subsample or a zoom then grab them. */ if objc >= int32(4) && libtcl9_0.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 3*8)), bp+316) != TCL_OK { result = int32(TCL_ERROR) goto done } if objc >= int32(5) && libtcl9_0.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 4*8)), bp+320) != TCL_OK { result = int32(TCL_ERROR) goto done } /* * Set the image size to zero, which allows the DrawCanvas() function * to expand the image automatically when it copies the pixmap into it. */ if XTk_PhotoSetSize(tls, interp, photohandle, 0, 0) != TCL_OK { result = int32(TCL_ERROR) goto done } result = _DrawCanvas(tls, interp, clientData, photohandle, *(*int32)(unsafe.Pointer(bp + 316)), *(*int32)(unsafe.Pointer(bp + 320))) _36: ; goto done done: ; _TagSearchDestroy(tls, *(*uintptr)(unsafe.Pointer(bp))) libtcl9_0.XTcl_Release(tls, canvasPtr) return result } var _canvasOptionStrings = [36]uintptr{ 0: __ccgo_ts + 26707, 1: __ccgo_ts + 12095, 2: __ccgo_ts + 17761, 3: __ccgo_ts + 26714, 4: __ccgo_ts + 26722, 5: __ccgo_ts + 4735, 6: __ccgo_ts + 4740, 7: __ccgo_ts + 26166, 8: __ccgo_ts + 10004, 9: __ccgo_ts + 26730, 10: __ccgo_ts + 2655, 11: __ccgo_ts + 26737, 12: __ccgo_ts + 26742, 13: __ccgo_ts + 17799, 14: __ccgo_ts + 26747, 15: __ccgo_ts + 22144, 16: __ccgo_ts + 17810, 17: __ccgo_ts + 26755, 18: __ccgo_ts + 22152, 19: __ccgo_ts + 22158, 20: __ccgo_ts + 23651, 21: __ccgo_ts + 23660, 22: __ccgo_ts + 17816, 23: __ccgo_ts + 26761, 24: __ccgo_ts + 17015, 25: __ccgo_ts + 26766, 26: __ccgo_ts + 17822, 27: __ccgo_ts + 26777, 28: __ccgo_ts + 26784, 29: __ccgo_ts + 17972, 30: __ccgo_ts + 22165, 31: __ccgo_ts + 20946, 32: __ccgo_ts + 24404, 33: __ccgo_ts + 22170, 34: __ccgo_ts + 23686, 35: libc.UintptrFromInt32(0), } var _optionStrings18 = [3]uintptr{ 0: __ccgo_ts + 22299, 1: __ccgo_ts + 2046, 2: libc.UintptrFromInt32(0), } var _optionStrings19 = [6]uintptr{ 0: __ccgo_ts + 22176, 1: __ccgo_ts + 4943, 2: __ccgo_ts + 22043, 3: __ccgo_ts + 27663, 4: __ccgo_ts + 22100, 5: libc.UintptrFromInt32(0), } /* *---------------------------------------------------------------------- * * DestroyCanvas -- * * This function is invoked by Tcl_EventuallyFree or Tcl_Release to clean * up the internal structure of a canvas at a safe time (when no-one is * using it anymore). * * Results: * None. * * Side effects: * Everything associated with the canvas is freed up. * *---------------------------------------------------------------------- */ func _DestroyCanvas(tls *libc.TLS, memPtr uintptr) { /* Info about canvas widget. */ var canvasPtr, expr, itemPtr, next uintptr _, _, _, _ = canvasPtr, expr, itemPtr, next canvasPtr = memPtr /* * Free up all of the items in the canvas. */ itemPtr = (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FfirstItemPtr for { if !(itemPtr != libc.UintptrFromInt32(0)) { break } (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FfirstItemPtr = (*TTk_Item)(unsafe.Pointer(itemPtr)).FnextPtr _ItemDelete(tls, canvasPtr, itemPtr) if (*TTk_Item)(unsafe.Pointer(itemPtr)).FtagPtr != itemPtr+16 { libtcl9_0.XTcl_Free(tls, (*TTk_Item)(unsafe.Pointer(itemPtr)).FtagPtr) } libtcl9_0.XTcl_Free(tls, itemPtr) goto _1 _1: ; itemPtr = (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FfirstItemPtr } /* * Free up all the stuff that requires special handling, then let * Tk_FreeOptions handle all the standard option-related stuff. */ libtcl9_0.XTcl_DeleteHashTable(tls, canvasPtr+672) if (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FpixmapGC != libc.UintptrFromInt32(0) { XTk_FreeGC(tls, (*TTkCanvas)(unsafe.Pointer(canvasPtr)).Fdisplay, (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FpixmapGC) } expr = (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FbindTagExprs for expr != 0 { next = (*TTagSearchExpr)(unsafe.Pointer(expr)).Fnext _TagSearchExprDestroy(tls, expr) expr = next } libtcl9_0.XTcl_DeleteTimerHandler(tls, (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FinsertBlinkHandler) if (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FbindingTable != libc.UintptrFromInt32(0) { XTk_DeleteBindingTable(tls, (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FbindingTable) } XTk_FreeOptions(tls, uintptr(unsafe.Pointer(&_configSpecs1)), canvasPtr, (*TTkCanvas)(unsafe.Pointer(canvasPtr)).Fdisplay, 0) (*TTkCanvas)(unsafe.Pointer(canvasPtr)).Ftkwin = libc.UintptrFromInt32(0) libtcl9_0.XTcl_Free(tls, canvasPtr) } /* *---------------------------------------------------------------------- * * ConfigureCanvas -- * * This function is called to process an objv/objc list, plus the Tk * option database, in order to configure (or reconfigure) a canvas * widget. * * Results: * The return value is a standard Tcl result. If TCL_ERROR is returned, * then the interp's result contains an error message. * * Side effects: * Configuration information, such as colors, border width, etc. get set * for canvasPtr; old resources get freed, if there were any. * *---------------------------------------------------------------------- */ func _ConfigureCanvas(tls *libc.TLS, interp uintptr, canvasPtr uintptr, objc TTcl_Size, objv uintptr, flags int32) (r int32) { bp := tls.Alloc(208) defer tls.Free(208) /* Flags to pass to Tk_ConfigureWidget. */ var _objPtr, _objPtr1, _objPtr2, _objPtr3, _objPtr4, _objPtr5, _objPtr6, _objPtr7, _objPtr8, _objPtr9, itemPtr, v10, v12, v14, v16, v18, v2, v23, v4, v6, v8 uintptr var newGC TGC var old_canvas_state TTk_State var result int32 var v1, v11, v13, v15, v17, v22, v3, v5, v7, v9 TTcl_Size var _ /* argc2 at bp+152 */ TTcl_Size var _ /* argv2 at bp+160 */ uintptr var _ /* borderWidth at bp+136 */ int32 var _ /* gcValues at bp+0 */ TXGCValues var _ /* height at bp+132 */ int32 var _ /* highlightWidth at bp+140 */ int32 var _ /* width at bp+128 */ int32 var _ /* xScrollIncrement at bp+144 */ int32 var _ /* yScrollIncrement at bp+148 */ int32 _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = _objPtr, _objPtr1, _objPtr2, _objPtr3, _objPtr4, _objPtr5, _objPtr6, _objPtr7, _objPtr8, _objPtr9, itemPtr, newGC, old_canvas_state, result, v1, v10, v11, v12, v13, v14, v15, v16, v17, v18, v2, v22, v23, v3, v4, v5, v6, v7, v8, v9 old_canvas_state = (*TTkCanvas)(unsafe.Pointer(canvasPtr)).Fcanvas_state if XTk_ConfigureWidget(tls, interp, (*TTkCanvas)(unsafe.Pointer(canvasPtr)).Ftkwin, uintptr(unsafe.Pointer(&_configSpecs1)), objc, objv, canvasPtr, flags) != TCL_OK { return int32(TCL_ERROR) } /* * A few options need special processing, such as setting the background * from a 3-D border and creating a GC for copying bits to the screen. */ XTk_SetBackgroundFromBorder(tls, (*TTkCanvas)(unsafe.Pointer(canvasPtr)).Ftkwin, (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FbgBorder) XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), (*TTkCanvas)(unsafe.Pointer(canvasPtr)).Ftkwin, (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FborderWidthObj, bp+136) XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), (*TTkCanvas)(unsafe.Pointer(canvasPtr)).Ftkwin, (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FheightObj, bp+132) XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), (*TTkCanvas)(unsafe.Pointer(canvasPtr)).Ftkwin, (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FhighlightWidthObj, bp+140) XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), (*TTkCanvas)(unsafe.Pointer(canvasPtr)).Ftkwin, (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FtextInfo.Freserved1, canvasPtr+152+76) XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), (*TTkCanvas)(unsafe.Pointer(canvasPtr)).Ftkwin, (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FtextInfo.Freserved2, canvasPtr+152+72) XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), (*TTkCanvas)(unsafe.Pointer(canvasPtr)).Ftkwin, (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FtextInfo.Freserved3, canvasPtr+152+8) XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), (*TTkCanvas)(unsafe.Pointer(canvasPtr)).Ftkwin, (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FwidthObj, bp+128) XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), (*TTkCanvas)(unsafe.Pointer(canvasPtr)).Ftkwin, (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FxScrollIncrementObj, bp+144) XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), (*TTkCanvas)(unsafe.Pointer(canvasPtr)).Ftkwin, (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FyScrollIncrementObj, bp+148) if *(*int32)(unsafe.Pointer(bp + 136)) < 0 { *(*int32)(unsafe.Pointer(bp + 136)) = 0 _objPtr = (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FborderWidthObj v2 = _objPtr v1 = *(*TTcl_Size)(unsafe.Pointer(v2)) *(*TTcl_Size)(unsafe.Pointer(v2))-- if v1 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr) } (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FborderWidthObj = libtcl9_0.XTcl_NewWideIntObj(tls, int64(libc.Int32FromInt32(0))) (*TTcl_Obj)(unsafe.Pointer((*TTkCanvas)(unsafe.Pointer(canvasPtr)).FborderWidthObj)).FrefCount++ } if *(*int32)(unsafe.Pointer(bp + 132)) < 0 { *(*int32)(unsafe.Pointer(bp + 132)) = 0 _objPtr1 = (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FheightObj v4 = _objPtr1 v3 = *(*TTcl_Size)(unsafe.Pointer(v4)) *(*TTcl_Size)(unsafe.Pointer(v4))-- if v3 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr1) } (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FheightObj = libtcl9_0.XTcl_NewWideIntObj(tls, int64(libc.Int32FromInt32(0))) (*TTcl_Obj)(unsafe.Pointer((*TTkCanvas)(unsafe.Pointer(canvasPtr)).FheightObj)).FrefCount++ } if *(*int32)(unsafe.Pointer(bp + 140)) < 0 { *(*int32)(unsafe.Pointer(bp + 140)) = 0 _objPtr2 = (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FhighlightWidthObj v6 = _objPtr2 v5 = *(*TTcl_Size)(unsafe.Pointer(v6)) *(*TTcl_Size)(unsafe.Pointer(v6))-- if v5 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr2) } (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FhighlightWidthObj = libtcl9_0.XTcl_NewWideIntObj(tls, int64(libc.Int32FromInt32(0))) (*TTcl_Obj)(unsafe.Pointer((*TTkCanvas)(unsafe.Pointer(canvasPtr)).FhighlightWidthObj)).FrefCount++ } if *(*int32)(unsafe.Pointer(bp + 128)) < 0 { *(*int32)(unsafe.Pointer(bp + 128)) = 0 _objPtr3 = (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FwidthObj v8 = _objPtr3 v7 = *(*TTcl_Size)(unsafe.Pointer(v8)) *(*TTcl_Size)(unsafe.Pointer(v8))-- if v7 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr3) } (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FwidthObj = libtcl9_0.XTcl_NewWideIntObj(tls, int64(libc.Int32FromInt32(0))) (*TTcl_Obj)(unsafe.Pointer((*TTkCanvas)(unsafe.Pointer(canvasPtr)).FwidthObj)).FrefCount++ } if *(*int32)(unsafe.Pointer(bp + 144)) < 0 { *(*int32)(unsafe.Pointer(bp + 144)) = 0 _objPtr4 = (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FxScrollIncrementObj v10 = _objPtr4 v9 = *(*TTcl_Size)(unsafe.Pointer(v10)) *(*TTcl_Size)(unsafe.Pointer(v10))-- if v9 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr4) } (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FxScrollIncrementObj = libtcl9_0.XTcl_NewWideIntObj(tls, int64(libc.Int32FromInt32(0))) (*TTcl_Obj)(unsafe.Pointer((*TTkCanvas)(unsafe.Pointer(canvasPtr)).FxScrollIncrementObj)).FrefCount++ } if *(*int32)(unsafe.Pointer(bp + 148)) < 0 { *(*int32)(unsafe.Pointer(bp + 148)) = 0 _objPtr5 = (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FyScrollIncrementObj v12 = _objPtr5 v11 = *(*TTcl_Size)(unsafe.Pointer(v12)) *(*TTcl_Size)(unsafe.Pointer(v12))-- if v11 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr5) } (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FyScrollIncrementObj = libtcl9_0.XTcl_NewWideIntObj(tls, int64(libc.Int32FromInt32(0))) (*TTcl_Obj)(unsafe.Pointer((*TTkCanvas)(unsafe.Pointer(canvasPtr)).FyScrollIncrementObj)).FrefCount++ } (*TTkCanvas)(unsafe.Pointer(canvasPtr)).Finset = *(*int32)(unsafe.Pointer(bp + 136)) + *(*int32)(unsafe.Pointer(bp + 140)) if (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FtextInfo.FinsertBorderWidth < 0 { (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FtextInfo.FinsertBorderWidth = 0 _objPtr6 = (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FtextInfo.Freserved1 v14 = _objPtr6 v13 = *(*TTcl_Size)(unsafe.Pointer(v14)) *(*TTcl_Size)(unsafe.Pointer(v14))-- if v13 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr6) } (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FtextInfo.Freserved1 = libtcl9_0.XTcl_NewWideIntObj(tls, int64(libc.Int32FromInt32(0))) (*TTcl_Obj)(unsafe.Pointer((*TTkCanvas)(unsafe.Pointer(canvasPtr)).FtextInfo.Freserved1)).FrefCount++ } if (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FtextInfo.FinsertWidth < 0 { (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FtextInfo.FinsertWidth = 0 _objPtr7 = (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FtextInfo.Freserved2 v16 = _objPtr7 v15 = *(*TTcl_Size)(unsafe.Pointer(v16)) *(*TTcl_Size)(unsafe.Pointer(v16))-- if v15 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr7) } (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FtextInfo.Freserved2 = libtcl9_0.XTcl_NewWideIntObj(tls, int64(libc.Int32FromInt32(0))) (*TTcl_Obj)(unsafe.Pointer((*TTkCanvas)(unsafe.Pointer(canvasPtr)).FtextInfo.Freserved2)).FrefCount++ } if (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FtextInfo.FselBorderWidth < 0 { (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FtextInfo.FselBorderWidth = 0 _objPtr8 = (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FtextInfo.Freserved3 v18 = _objPtr8 v17 = *(*TTcl_Size)(unsafe.Pointer(v18)) *(*TTcl_Size)(unsafe.Pointer(v18))-- if v17 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr8) } (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FtextInfo.Freserved3 = libtcl9_0.XTcl_NewWideIntObj(tls, int64(libc.Int32FromInt32(0))) (*TTcl_Obj)(unsafe.Pointer((*TTkCanvas)(unsafe.Pointer(canvasPtr)).FtextInfo.Freserved3)).FrefCount++ } (*(*TXGCValues)(unsafe.Pointer(bp))).Ffunction = int32(GXcopy) (*(*TXGCValues)(unsafe.Pointer(bp))).Fgraphics_exposures = False (*(*TXGCValues)(unsafe.Pointer(bp))).Fforeground = (*TXColor)(unsafe.Pointer(XTk_3DBorderColor(tls, (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FbgBorder))).Fpixel newGC = XTk_GetGC(tls, (*TTkCanvas)(unsafe.Pointer(canvasPtr)).Ftkwin, libc.Uint64FromInt64(libc.Int64FromInt64(1)< int32(8) { *(*int32)(unsafe.Pointer(shift)) += *(*int32)(unsafe.Pointer(bits)) - int32(8) *(*int32)(unsafe.Pointer(bits)) = int32(8) } } } /* *---------------------------------------------------------------------- * * DrawCanvas -- * * This function draws the contents of a canvas into the given Photo image. * This function is called from the widget "image" subcommand. * The canvas does not need to be mapped (one of it's ancestors must be) * in order for this function to work. * * Results: * None. * * Side effects: * Canvas contents from within the -scrollregion or widget size are rendered * into the Photo. Any errors are left in the result. * *---------------------------------------------------------------------- */ func _DrawCanvas(tls *libc.TLS, interp uintptr, clientData uintptr, photohandle TTk_PhotoHandle, subsample int32, zoom int32) (r int32) { bp := tls.Alloc(224) defer tls.Free(224) var bitsPerPixel, bytesPerPixel, cHeight, cWidth, canvasX1, canvasX2, canvasY1, canvasY2, pixel_offset, pixmapX1, pixmapX2, pixmapY1, pixmapY2, pmHeight, pmWidth, result, x, y, v11, v12 int32 var canvasPtr, displayPtr, itemPtr, visualPtr, ximagePtr, v2, v8 uintptr var pixel uint32 var pixmap, v6 TPixmap var tkwin, v1, v4 TTk_Window var wid, v3 TWindow var xgc TGC var _ /* bbits at bp+188 */ int32 var _ /* blockPtr at bp+0 */ TTk_PhotoImageBlock var _ /* bshift at bp+176 */ int32 var _ /* gbits at bp+184 */ int32 var _ /* gshift at bp+172 */ int32 var _ /* rbits at bp+180 */ int32 var _ /* rshift at bp+168 */ int32 var _ /* xgcValues at bp+40 */ TXGCValues _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = bitsPerPixel, bytesPerPixel, cHeight, cWidth, canvasPtr, canvasX1, canvasX2, canvasY1, canvasY2, displayPtr, itemPtr, pixel, pixel_offset, pixmap, pixmapX1, pixmapX2, pixmapY1, pixmapY2, pmHeight, pmWidth, result, tkwin, visualPtr, wid, x, xgc, ximagePtr, y, v1, v11, v12, v2, v3, v4, v6, v8 canvasPtr = clientData *(*TTk_PhotoImageBlock)(unsafe.Pointer(bp)) = TTk_PhotoImageBlock{} pixmap = uint64(0) ximagePtr = libc.UintptrFromInt32(0) xgc = uintptr(0) result = TCL_OK v1 = (*TTkCanvas)(unsafe.Pointer(canvasPtr)).Ftkwin tkwin = v1 if v1 == libc.UintptrFromInt32(0) { libtcl9_0.XTcl_AppendResult(tls, interp, libc.VaList(bp+200, __ccgo_ts+27839, libc.UintptrFromInt32(0))) result = int32(TCL_ERROR) goto done } /* * If this canvas is unmapped, then we won't have a window id, so we will * try the ancestors of the canvas until we find a window that has a * valid window id. The Tk_GetPixmap() call requires a valid window id. */ for cond := true; cond; cond = wid == uint64(0) { v2 = (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fdisplay displayPtr = v2 if v2 == libc.UintptrFromInt32(0) { libtcl9_0.XTcl_AppendResult(tls, interp, libc.VaList(bp+200, __ccgo_ts+27861, libc.UintptrFromInt32(0))) result = int32(TCL_ERROR) goto done } v3 = (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fwindow wid = v3 if v3 != uint64(0) { continue } v4 = (*TTk_FakeWin)(unsafe.Pointer(tkwin)).FparentPtr tkwin = v4 if v4 == libc.UintptrFromInt32(0) { libtcl9_0.XTcl_AppendResult(tls, interp, libc.VaList(bp+200, __ccgo_ts+27897, libc.UintptrFromInt32(0))) result = int32(TCL_ERROR) goto done } } bitsPerPixel = (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fdepth visualPtr = (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fvisual if subsample == 0 { libtcl9_0.XTcl_AppendResult(tls, interp, libc.VaList(bp+200, __ccgo_ts+27973, libc.UintptrFromInt32(0))) result = int32(TCL_ERROR) goto done } /* * Scan through the item list, registering the bounding box for all items * that didn't do that for the final coordinates yet. This can be * determined by the FORCE_REDRAW flag. */ itemPtr = (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FfirstItemPtr for { if !(itemPtr != libc.UintptrFromInt32(0)) { break } if (*TTk_Item)(unsafe.Pointer(itemPtr)).Fredraw_flags&int32(FORCE_REDRAW) != 0 { *(*int32)(unsafe.Pointer(itemPtr + 112)) &= ^libc.Int32FromInt32(FORCE_REDRAW) _EventuallyRedrawItem(tls, canvasPtr, itemPtr) *(*int32)(unsafe.Pointer(itemPtr + 112)) &= ^libc.Int32FromInt32(FORCE_REDRAW) } goto _5 _5: ; itemPtr = (*TTk_Item)(unsafe.Pointer(itemPtr)).FnextPtr } /* * The DisplayCanvas() function works out the region that needs redrawing, * but we don't do this. We grab the whole scrollregion or canvas window * area. If we have a defined -scrollregion we use that as the drawing * region, otherwise use the canvas window height and width with an origin * of 0,0. */ if (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FscrollX1 != 0 || (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FscrollY1 != 0 || (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FscrollX2 != 0 || (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FscrollY2 != 0 { canvasX1 = (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FscrollX1 canvasY1 = (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FscrollY1 canvasX2 = (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FscrollX2 canvasY2 = (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FscrollY2 cWidth = canvasX2 - canvasX1 + int32(1) cHeight = canvasY2 - canvasY1 + int32(1) } else { cWidth = (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fchanges.Fwidth cHeight = (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fchanges.Fheight canvasX1 = 0 canvasY1 = 0 canvasX2 = canvasX1 + cWidth - int32(1) canvasY2 = canvasY1 + cHeight - int32(1) } /* * Allocate a pixmap to draw into. We add OVERDRAW_PIXELS in the same way * that DisplayCanvas() does to avoid problems on some systems when objects * are being drawn too close to the edge. */ pixmapX1 = canvasX1 - int32(OVERDRAW_PIXELS) pixmapY1 = canvasY1 - int32(OVERDRAW_PIXELS) pixmapX2 = canvasX2 + int32(OVERDRAW_PIXELS) pixmapY2 = canvasY2 + int32(OVERDRAW_PIXELS) pmWidth = pixmapX2 - pixmapX1 + int32(1) pmHeight = pixmapY2 - pixmapY1 + int32(1) v6 = XTk_GetPixmap(tls, displayPtr, (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fwindow, pmWidth, pmHeight, bitsPerPixel) pixmap = v6 if v6 == uint64(0) { libtcl9_0.XTcl_AppendResult(tls, interp, libc.VaList(bp+200, __ccgo_ts+27998, libc.UintptrFromInt32(0))) result = int32(TCL_ERROR) goto done } /* * Before we can draw the canvas objects into the pixmap it's background * should be filled with canvas background colour. */ (*(*TXGCValues)(unsafe.Pointer(bp + 40))).Ffunction = int32(GXcopy) (*(*TXGCValues)(unsafe.Pointer(bp + 40))).Fforeground = (*TXColor)(unsafe.Pointer(XTk_3DBorderColor(tls, (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FbgBorder))).Fpixel xgc = libx11.XXCreateGC(tls, displayPtr, pixmap, libc.Uint64FromInt64(libc.Int64FromInt64(1)<= pixmapX2 || (*TTk_Item)(unsafe.Pointer(itemPtr)).Fy1 >= pixmapY2 || (*TTk_Item)(unsafe.Pointer(itemPtr)).Fx2 < pixmapX1 || (*TTk_Item)(unsafe.Pointer(itemPtr)).Fy2 < pixmapY1 { if !(_AlwaysRedraw(tls, itemPtr) != 0) { goto _7 } } if (*TTk_Item)(unsafe.Pointer(itemPtr)).Fstate == int32(TK_STATE_HIDDEN) || (*TTk_Item)(unsafe.Pointer(itemPtr)).Fstate == int32(TK_STATE_NULL) && (*TTkCanvas)(unsafe.Pointer(canvasPtr)).Fcanvas_state == int32(TK_STATE_HIDDEN) { goto _7 } _ItemDisplay(tls, canvasPtr, itemPtr, pixmap, pixmapX1, pixmapY1, pmWidth, pmHeight) goto _7 _7: ; itemPtr = (*TTk_Item)(unsafe.Pointer(itemPtr)).FnextPtr } /* * Copy the Pixmap into an ZPixmap format XImage so we can copy it across * to the photo image. This seems to be the only way to get Pixmap image * data out of an image. Note we have to account for the OVERDRAW_PIXELS * border width. */ v8 = libx11.XXGetImage(tls, displayPtr, pixmap, -pixmapX1, -pixmapY1, libc.Uint32FromInt32(cWidth), libc.Uint32FromInt32(cHeight), libc.Uint64FromInt64(^libc.Int64FromInt64(0)), int32(ZPixmap)) ximagePtr = v8 if v8 == libc.UintptrFromInt32(0) { libtcl9_0.XTcl_AppendResult(tls, interp, libc.VaList(bp+200, __ccgo_ts+28030, libc.UintptrFromInt32(0))) result = int32(TCL_ERROR) goto done } /* * Fill in the PhotoImageBlock structure abd allocate a block of memory * for the converted image data. Note we allocate an alpha channel even * though we don't use one, because this layout helps Tk_PhotoPutBlock() * use memcpy() instead of the slow pixel or line copy. */ (*(*TTk_PhotoImageBlock)(unsafe.Pointer(bp))).Fwidth = cWidth (*(*TTk_PhotoImageBlock)(unsafe.Pointer(bp))).Fheight = cHeight (*(*TTk_PhotoImageBlock)(unsafe.Pointer(bp))).FpixelSize = int32(4) (*(*TTk_PhotoImageBlock)(unsafe.Pointer(bp))).Fpitch = (*(*TTk_PhotoImageBlock)(unsafe.Pointer(bp))).FpixelSize * (*(*TTk_PhotoImageBlock)(unsafe.Pointer(bp))).Fwidth *(*int32)(unsafe.Pointer(bp + 24)) = 0 *(*int32)(unsafe.Pointer(bp + 24 + 1*4)) = int32(1) *(*int32)(unsafe.Pointer(bp + 24 + 2*4)) = int32(2) *(*int32)(unsafe.Pointer(bp + 24 + 3*4)) = int32(3) (*(*TTk_PhotoImageBlock)(unsafe.Pointer(bp))).FpixelPtr = libtcl9_0.XTcl_Alloc(tls, libc.Uint64FromInt32((*(*TTk_PhotoImageBlock)(unsafe.Pointer(bp))).FpixelSize*(*(*TTk_PhotoImageBlock)(unsafe.Pointer(bp))).Fheight*(*(*TTk_PhotoImageBlock)(unsafe.Pointer(bp))).Fwidth)) /* * Now convert the image data pixel by pixel from XImage to 32bit RGBA * format suitable for Tk_PhotoPutBlock(). */ _DecomposeMaskToShiftAndBits(tls, uint32((*TVisual)(unsafe.Pointer(visualPtr)).Fred_mask), bp+168, bp+180) _DecomposeMaskToShiftAndBits(tls, uint32((*TVisual)(unsafe.Pointer(visualPtr)).Fgreen_mask), bp+172, bp+184) _DecomposeMaskToShiftAndBits(tls, uint32((*TVisual)(unsafe.Pointer(visualPtr)).Fblue_mask), bp+176, bp+188) /* Ok, had to use ximagePtr->bits_per_pixel here and in the switch (...) * below to get this to work on Windows. X11 correctly sets the bitmap *_pad and bitmap_unit fields to 32, but on Windows they are 0 and 8 * respectively! */ bytesPerPixel = (*TXImage)(unsafe.Pointer(ximagePtr)).Fbits_per_pixel / int32(8) y = 0 for { if !(y < (*(*TTk_PhotoImageBlock)(unsafe.Pointer(bp))).Fheight) { break } x = 0 for { if !(x < (*(*TTk_PhotoImageBlock)(unsafe.Pointer(bp))).Fwidth) { break } pixel = uint32(0) pixel_offset = (*(*TTk_PhotoImageBlock)(unsafe.Pointer(bp))).Fpitch*y + (*(*TTk_PhotoImageBlock)(unsafe.Pointer(bp))).FpixelSize*x switch (*TXImage)(unsafe.Pointer(ximagePtr)).Fbits_per_pixel { /* * Get an 8 bit pixel from the XImage. */ case int32(8): pixel = uint32(*(*uint8)(unsafe.Pointer((*TXImage)(unsafe.Pointer(ximagePtr)).Fdata + uintptr(bytesPerPixel*x) + uintptr((*TXImage)(unsafe.Pointer(ximagePtr)).Fbytes_per_line*y)))) break /* * Get a 16 bit pixel from the XImage, and correct the * byte order as necessary. */ fallthrough case int32(16): pixel = uint32(*(*uint16)(unsafe.Pointer((*TXImage)(unsafe.Pointer(ximagePtr)).Fdata + uintptr(bytesPerPixel*x) + uintptr((*TXImage)(unsafe.Pointer(ximagePtr)).Fbytes_per_line*y)))) if libc.Bool(libc.Bool(IS_BIG_ENDIAN != 0) && (*TXImage)(unsafe.Pointer(ximagePtr)).Fbyte_order == LSBFirst) || libc.Bool(!(libc.Int32FromInt32(IS_BIG_ENDIAN) != 0)) && (*TXImage)(unsafe.Pointer(ximagePtr)).Fbyte_order == int32(MSBFirst) { pixel = libc.Uint32FromInt32(libc.Int32FromUint16(uint16(pixel))>>libc.Int32FromInt32(8) | libc.Int32FromUint16(uint16(pixel))<>int32(24)&uint32(0x000000FF) | pixel<>int32(8)&uint32(0x0000FF00) | pixel<> *(*int32)(unsafe.Pointer(bp + 168))) *(*uint8)(unsafe.Pointer((*(*TTk_PhotoImageBlock)(unsafe.Pointer(bp))).FpixelPtr + uintptr(pixel_offset+*(*int32)(unsafe.Pointer(bp + 24 + 1*4))))) = uint8(uint64(pixel) & (*TVisual)(unsafe.Pointer(visualPtr)).Fgreen_mask >> *(*int32)(unsafe.Pointer(bp + 172))) *(*uint8)(unsafe.Pointer((*(*TTk_PhotoImageBlock)(unsafe.Pointer(bp))).FpixelPtr + uintptr(pixel_offset+*(*int32)(unsafe.Pointer(bp + 24 + 2*4))))) = uint8(uint64(pixel) & (*TVisual)(unsafe.Pointer(visualPtr)).Fblue_mask >> *(*int32)(unsafe.Pointer(bp + 176))) *(*uint8)(unsafe.Pointer((*(*TTk_PhotoImageBlock)(unsafe.Pointer(bp))).FpixelPtr + uintptr(pixel_offset+*(*int32)(unsafe.Pointer(bp + 24 + 3*4))))) = uint8(0xFF) } goto _10 _10: ; x++ } goto _9 _9: ; y++ } /* * Now put the copied pixmap into the photo. * If either zoom or subsample are not 1, we use the zoom function. */ if subsample != int32(1) || zoom != int32(1) { v11 = XTk_PhotoPutZoomedBlock(tls, interp, photohandle, bp, 0, 0, cWidth*zoom/subsample, cHeight*zoom/subsample, zoom, zoom, subsample, subsample, int32(TK_PHOTO_COMPOSITE_SET)) result = v11 if v11 != TCL_OK { goto done } } else { v12 = XTk_PhotoPutBlock(tls, interp, photohandle, bp, 0, 0, cWidth, cHeight, int32(TK_PHOTO_COMPOSITE_SET)) result = v12 if v12 != TCL_OK { goto done } } /* * Clean up anything we have allocated and exit. */ goto done done: ; if (*(*TTk_PhotoImageBlock)(unsafe.Pointer(bp))).FpixelPtr != 0 { libtcl9_0.XTcl_Free(tls, (*(*TTk_PhotoImageBlock)(unsafe.Pointer(bp))).FpixelPtr) } if pixmap != 0 { XTk_FreePixmap(tls, (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fdisplay, pixmap) } if ximagePtr != 0 { (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*TXImage)(unsafe.Pointer(ximagePtr)).Ff.Fdestroy_image})))(tls, ximagePtr) } if xgc != 0 { libx11.XXFreeGC(tls, displayPtr, xgc) } return result } /* *---------------------------------------------------------------------- * * DisplayCanvas -- * * This function redraws the contents of a canvas window. It is invoked * as a do-when-idle handler, so it only runs when there's nothing else * for the application to do. * * Results: * None. * * Side effects: * Information appears on the screen. * *---------------------------------------------------------------------- */ func _DisplayCanvas(tls *libc.TLS, clientData uintptr) { bp := tls.Alloc(16) defer tls.Free(16) /* Information about widget. */ var bgGC, fgGC TGC var canvasPtr, itemPtr uintptr var height, screenX1, screenX2, screenY1, screenY2, width, v3, v4 int32 var pixmap TPixmap var tkwin TTk_Window var _ /* borderWidth at bp+0 */ int32 var _ /* highlightWidth at bp+4 */ int32 _, _, _, _, _, _, _, _, _, _, _, _, _, _ = bgGC, canvasPtr, fgGC, height, itemPtr, pixmap, screenX1, screenX2, screenY1, screenY2, tkwin, width, v3, v4 canvasPtr = clientData tkwin = (*TTkCanvas)(unsafe.Pointer(canvasPtr)).Ftkwin if (*TTkCanvas)(unsafe.Pointer(canvasPtr)).Ftkwin == libc.UintptrFromInt32(0) { return } if !((*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fflags&libc.Uint32FromInt32(TK_MAPPED) != 0) { goto done } /* * Choose a new current item if that is needed (this could cause event * handlers to be invoked). */ for (*TTkCanvas)(unsafe.Pointer(canvasPtr)).Fflags&int32(REPICK_NEEDED) != 0 { libtcl9_0.XTcl_Preserve(tls, canvasPtr) *(*int32)(unsafe.Pointer(canvasPtr + 648)) &= ^libc.Int32FromInt32(REPICK_NEEDED) _PickCurrentItem(tls, canvasPtr, canvasPtr+336) tkwin = (*TTkCanvas)(unsafe.Pointer(canvasPtr)).Ftkwin libtcl9_0.XTcl_Release(tls, canvasPtr) if tkwin == libc.UintptrFromInt32(0) { return } } /* * Scan through the item list, registering the bounding box for all items * that didn't do that for the final coordinates yet. This can be * determined by the FORCE_REDRAW flag. */ itemPtr = (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FfirstItemPtr for { if !(itemPtr != libc.UintptrFromInt32(0)) { break } if (*TTk_Item)(unsafe.Pointer(itemPtr)).Fredraw_flags&int32(FORCE_REDRAW) != 0 { *(*int32)(unsafe.Pointer(itemPtr + 112)) &= ^libc.Int32FromInt32(FORCE_REDRAW) _EventuallyRedrawItem(tls, canvasPtr, itemPtr) *(*int32)(unsafe.Pointer(itemPtr + 112)) &= ^libc.Int32FromInt32(FORCE_REDRAW) } goto _1 _1: ; itemPtr = (*TTk_Item)(unsafe.Pointer(itemPtr)).FnextPtr } /* * Compute the intersection between the area that needs redrawing and the * area that's visible on the screen. */ if (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FredrawX1 < (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FredrawX2 && (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FredrawY1 < (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FredrawY2 { screenX1 = (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FxOrigin + (*TTkCanvas)(unsafe.Pointer(canvasPtr)).Finset screenY1 = (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FyOrigin + (*TTkCanvas)(unsafe.Pointer(canvasPtr)).Finset screenX2 = (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FxOrigin + (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fchanges.Fwidth - (*TTkCanvas)(unsafe.Pointer(canvasPtr)).Finset screenY2 = (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FyOrigin + (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fchanges.Fheight - (*TTkCanvas)(unsafe.Pointer(canvasPtr)).Finset if (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FredrawX1 > screenX1 { screenX1 = (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FredrawX1 } if (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FredrawY1 > screenY1 { screenY1 = (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FredrawY1 } if (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FredrawX2 < screenX2 { screenX2 = (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FredrawX2 } if (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FredrawY2 < screenY2 { screenY2 = (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FredrawY2 } if screenX1 >= screenX2 || screenY1 >= screenY2 { goto borders } width = screenX2 - screenX1 height = screenY2 - screenY1 /* * Redrawing is done in a temporary pixmap that is allocated here and * freed at the end of the function. All drawing is done to the * pixmap, and the pixmap is copied to the screen at the end of the * function. The temporary pixmap serves two purposes: * * 1. It provides a smoother visual effect (no clearing and gradual * redraw will be visible to users). * 2. It allows us to redraw only the objects that overlap the redraw * area. Otherwise incorrect results could occur from redrawing * things that stick outside of the redraw area (we'd have to * redraw everything in order to make the overlaps look right). * * Some tricky points about the pixmap: * * 1. We only allocate a large enough pixmap to hold the area that has * to be redisplayed. This saves time in in the X server for large * objects that cover much more than the area being redisplayed: * only the area of the pixmap will actually have to be redrawn. * 2. Some X servers (e.g. the one for DECstations) have troubles with * with characters that overlap an edge of the pixmap (on the DEC * servers, as of 8/18/92, such characters are drawn one pixel too * far to the right). To handle this problem, make the pixmap a bit * larger than is absolutely needed so that for normal-sized fonts * the characters that overlap the edge of the pixmap will be * outside the area we care about. */ (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FdrawableXOrigin = screenX1 - int32(30) (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FdrawableYOrigin = screenY1 - int32(30) pixmap = XTk_GetPixmap(tls, (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fdisplay, (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fwindow, screenX2+int32(30)-(*TTkCanvas)(unsafe.Pointer(canvasPtr)).FdrawableXOrigin, screenY2+int32(30)-(*TTkCanvas)(unsafe.Pointer(canvasPtr)).FdrawableYOrigin, (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fdepth) /* * Clear the area to be redrawn. */ libx11.XXFillRectangle(tls, (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fdisplay, pixmap, (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FpixmapGC, screenX1-(*TTkCanvas)(unsafe.Pointer(canvasPtr)).FdrawableXOrigin, screenY1-(*TTkCanvas)(unsafe.Pointer(canvasPtr)).FdrawableYOrigin, libc.Uint32FromInt32(width), libc.Uint32FromInt32(height)) /* * Scan through the item list, redrawing those items that need it. An * item must be redraw if either (a) it intersects the smaller * on-screen area or (b) it intersects the full canvas area and its * type requests that it be redrawn always (e.g. so subwindows can be * unmapped when they move off-screen). */ itemPtr = (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FfirstItemPtr for { if !(itemPtr != libc.UintptrFromInt32(0)) { break } if (*TTk_Item)(unsafe.Pointer(itemPtr)).Fx1 >= screenX2 || (*TTk_Item)(unsafe.Pointer(itemPtr)).Fy1 >= screenY2 || (*TTk_Item)(unsafe.Pointer(itemPtr)).Fx2 < screenX1 || (*TTk_Item)(unsafe.Pointer(itemPtr)).Fy2 < screenY1 { if !(_AlwaysRedraw(tls, itemPtr) != 0) || (*TTk_Item)(unsafe.Pointer(itemPtr)).Fx1 >= (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FredrawX2 || (*TTk_Item)(unsafe.Pointer(itemPtr)).Fy1 >= (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FredrawY2 || (*TTk_Item)(unsafe.Pointer(itemPtr)).Fx2 < (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FredrawX1 || (*TTk_Item)(unsafe.Pointer(itemPtr)).Fy2 < (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FredrawY1 { goto _2 } } if (*TTk_Item)(unsafe.Pointer(itemPtr)).Fstate == int32(TK_STATE_HIDDEN) || (*TTk_Item)(unsafe.Pointer(itemPtr)).Fstate == int32(TK_STATE_NULL) && (*TTkCanvas)(unsafe.Pointer(canvasPtr)).Fcanvas_state == int32(TK_STATE_HIDDEN) { goto _2 } _ItemDisplay(tls, canvasPtr, itemPtr, pixmap, screenX1, screenY1, width, height) goto _2 _2: ; itemPtr = (*TTk_Item)(unsafe.Pointer(itemPtr)).FnextPtr } /* * Copy from the temporary pixmap to the screen, then free up the * temporary pixmap. */ libx11.XXCopyArea(tls, (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fdisplay, pixmap, (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fwindow, (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FpixmapGC, screenX1-(*TTkCanvas)(unsafe.Pointer(canvasPtr)).FdrawableXOrigin, screenY1-(*TTkCanvas)(unsafe.Pointer(canvasPtr)).FdrawableYOrigin, libc.Uint32FromInt32(width), libc.Uint32FromInt32(height), screenX1-(*TTkCanvas)(unsafe.Pointer(canvasPtr)).FxOrigin, screenY1-(*TTkCanvas)(unsafe.Pointer(canvasPtr)).FyOrigin) XTk_FreePixmap(tls, (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fdisplay, pixmap) } /* * Draw the window borders, if needed. */ goto borders borders: ; XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), (*TTkCanvas)(unsafe.Pointer(canvasPtr)).Ftkwin, (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FborderWidthObj, bp) XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), (*TTkCanvas)(unsafe.Pointer(canvasPtr)).Ftkwin, (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FhighlightWidthObj, bp+4) if (*TTkCanvas)(unsafe.Pointer(canvasPtr)).Fflags&int32(REDRAW_BORDERS) != 0 { *(*int32)(unsafe.Pointer(canvasPtr + 648)) &= ^libc.Int32FromInt32(REDRAW_BORDERS) if *(*int32)(unsafe.Pointer(bp)) > 0 { XTk_Draw3DRectangle(tls, tkwin, (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fwindow, (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FbgBorder, *(*int32)(unsafe.Pointer(bp + 4)), *(*int32)(unsafe.Pointer(bp + 4)), (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fchanges.Fwidth-int32(2)**(*int32)(unsafe.Pointer(bp + 4)), (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fchanges.Fheight-int32(2)**(*int32)(unsafe.Pointer(bp + 4)), *(*int32)(unsafe.Pointer(bp)), (*TTkCanvas)(unsafe.Pointer(canvasPtr)).Frelief) } if *(*int32)(unsafe.Pointer(bp + 4)) > 0 { bgGC = XTk_GCForColor(tls, (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FhighlightBgColorPtr, (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fwindow) if (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FtextInfo.FgotFocus != 0 { fgGC = XTk_GCForColor(tls, (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FhighlightColorPtr, (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fwindow) XTk_DrawHighlightBorder(tls, tkwin, fgGC, bgGC, *(*int32)(unsafe.Pointer(bp + 4)), (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fwindow) } else { XTk_DrawHighlightBorder(tls, tkwin, bgGC, bgGC, *(*int32)(unsafe.Pointer(bp + 4)), (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fwindow) } } } goto done done: ; *(*int32)(unsafe.Pointer(canvasPtr + 648)) &= ^(libc.Int32FromInt32(REDRAW_PENDING2) | libc.Int32FromInt32(BBOX_NOT_EMPTY)) v3 = libc.Int32FromInt32(0) (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FredrawX2 = v3 (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FredrawX1 = v3 v4 = libc.Int32FromInt32(0) (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FredrawY2 = v4 (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FredrawY1 = v4 if (*TTkCanvas)(unsafe.Pointer(canvasPtr)).Fflags&int32(UPDATE_SCROLLBARS) != 0 { _CanvasUpdateScrollbars(tls, canvasPtr) } } /* *---------------------------------------------------------------------- * * CanvasEventProc -- * * This function is invoked by the Tk dispatcher for various events on * canvases. * * Results: * None. * * Side effects: * When the window gets deleted, internal structures get cleaned up. When * it gets exposed, it is redisplayed. * *---------------------------------------------------------------------- */ func _CanvasEventProc(tls *libc.TLS, clientData uintptr, eventPtr uintptr) { /* Information about event. */ var canvasPtr, itemPtr uintptr var x, y int32 _, _, _, _ = canvasPtr, itemPtr, x, y canvasPtr = clientData if (*TXEvent)(unsafe.Pointer(eventPtr)).Ftype1 == int32(Expose) { x = (*(*TXExposeEvent)(unsafe.Pointer(eventPtr))).Fx + (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FxOrigin y = (*(*TXExposeEvent)(unsafe.Pointer(eventPtr))).Fy + (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FyOrigin XTk_CanvasEventuallyRedraw(tls, canvasPtr, x, y, x+(*(*TXExposeEvent)(unsafe.Pointer(eventPtr))).Fwidth, y+(*(*TXExposeEvent)(unsafe.Pointer(eventPtr))).Fheight) if (*(*TXExposeEvent)(unsafe.Pointer(eventPtr))).Fx < (*TTkCanvas)(unsafe.Pointer(canvasPtr)).Finset || (*(*TXExposeEvent)(unsafe.Pointer(eventPtr))).Fy < (*TTkCanvas)(unsafe.Pointer(canvasPtr)).Finset || (*(*TXExposeEvent)(unsafe.Pointer(eventPtr))).Fx+(*(*TXExposeEvent)(unsafe.Pointer(eventPtr))).Fwidth > (*TTk_FakeWin)(unsafe.Pointer((*TTkCanvas)(unsafe.Pointer(canvasPtr)).Ftkwin)).Fchanges.Fwidth-(*TTkCanvas)(unsafe.Pointer(canvasPtr)).Finset || (*(*TXExposeEvent)(unsafe.Pointer(eventPtr))).Fy+(*(*TXExposeEvent)(unsafe.Pointer(eventPtr))).Fheight > (*TTk_FakeWin)(unsafe.Pointer((*TTkCanvas)(unsafe.Pointer(canvasPtr)).Ftkwin)).Fchanges.Fheight-(*TTkCanvas)(unsafe.Pointer(canvasPtr)).Finset { *(*int32)(unsafe.Pointer(canvasPtr + 648)) |= int32(REDRAW_BORDERS) } } else { if (*TXEvent)(unsafe.Pointer(eventPtr)).Ftype1 == int32(DestroyNotify) { if (*TTkCanvas)(unsafe.Pointer(canvasPtr)).Ftkwin != libc.UintptrFromInt32(0) { (*TTkCanvas)(unsafe.Pointer(canvasPtr)).Ftkwin = libc.UintptrFromInt32(0) libtcl9_0.XTcl_DeleteCommandFromToken(tls, (*TTkCanvas)(unsafe.Pointer(canvasPtr)).Finterp, (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FwidgetCmd) } if (*TTkCanvas)(unsafe.Pointer(canvasPtr)).Fflags&int32(REDRAW_PENDING2) != 0 { libtcl9_0.XTcl_CancelIdleCall(tls, __ccgo_fp(_DisplayCanvas), canvasPtr) } libtcl9_0.XTcl_EventuallyFree(tls, canvasPtr, __ccgo_fp(_DestroyCanvas)) } else { if (*TXEvent)(unsafe.Pointer(eventPtr)).Ftype1 == int32(ConfigureNotify) { *(*int32)(unsafe.Pointer(canvasPtr + 648)) |= int32(UPDATE_SCROLLBARS) /* * The call below is needed in order to recenter the canvas if it's * confined and its scroll region is smaller than the window. */ _CanvasSetOrigin(tls, canvasPtr, (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FxOrigin, (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FyOrigin) XTk_CanvasEventuallyRedraw(tls, canvasPtr, (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FxOrigin, (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FyOrigin, (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FxOrigin+(*TTk_FakeWin)(unsafe.Pointer((*TTkCanvas)(unsafe.Pointer(canvasPtr)).Ftkwin)).Fchanges.Fwidth, (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FyOrigin+(*TTk_FakeWin)(unsafe.Pointer((*TTkCanvas)(unsafe.Pointer(canvasPtr)).Ftkwin)).Fchanges.Fheight) *(*int32)(unsafe.Pointer(canvasPtr + 648)) |= int32(REDRAW_BORDERS) } else { if (*TXEvent)(unsafe.Pointer(eventPtr)).Ftype1 == int32(FocusIn) { if (*(*TXFocusChangeEvent)(unsafe.Pointer(eventPtr))).Fdetail != int32(NotifyInferior) { _CanvasFocusProc(tls, canvasPtr, int32(1)) } } else { if (*TXEvent)(unsafe.Pointer(eventPtr)).Ftype1 == int32(FocusOut) { if (*(*TXFocusChangeEvent)(unsafe.Pointer(eventPtr))).Fdetail != int32(NotifyInferior) { _CanvasFocusProc(tls, canvasPtr, 0) } } else { if (*TXEvent)(unsafe.Pointer(eventPtr)).Ftype1 == int32(UnmapNotify) { /* * Special hack: if the canvas is unmapped, then must notify all items * with flag TK_ALWAYS_REDRAW set, so that they know that they are no * longer displayed. */ itemPtr = (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FfirstItemPtr for { if !(itemPtr != libc.UintptrFromInt32(0)) { break } if _AlwaysRedraw(tls, itemPtr) != 0 { _ItemDisplay(tls, canvasPtr, itemPtr, uint64(0), 0, 0, 0, 0) } goto _1 _1: ; itemPtr = (*TTk_Item)(unsafe.Pointer(itemPtr)).FnextPtr } } } } } } } } /* *---------------------------------------------------------------------- * * CanvasCmdDeletedProc -- * * This function is invoked when a widget command is deleted. If the * widget isn't already in the process of being destroyed, this command * destroys it. * * Results: * None. * * Side effects: * The widget is destroyed. * *---------------------------------------------------------------------- */ func _CanvasCmdDeletedProc(tls *libc.TLS, clientData uintptr) { /* Pointer to widget record for widget. */ var canvasPtr uintptr var tkwin TTk_Window _, _ = canvasPtr, tkwin canvasPtr = clientData tkwin = (*TTkCanvas)(unsafe.Pointer(canvasPtr)).Ftkwin /* * This function could be invoked either because the window was destroyed * and the command was then deleted (in which case tkwin is NULL) or * because the command was deleted, and then this function destroys the * widget. */ if tkwin != libc.UintptrFromInt32(0) { (*TTkCanvas)(unsafe.Pointer(canvasPtr)).Ftkwin = libc.UintptrFromInt32(0) XTk_DestroyWindow(tls, tkwin) } } /* *---------------------------------------------------------------------- * * Tk_CanvasEventuallyRedraw -- * * Arrange for part or all of a canvas widget to redrawn at some * convenient time in the future. * * Results: * None. * * Side effects: * The screen will eventually be refreshed. * *---------------------------------------------------------------------- */ func XTk_CanvasEventuallyRedraw(tls *libc.TLS, canvas TTk_Canvas, x1 int32, y1 int32, x2 int32, y2 int32) { /* Lower right corner of area to redraw. * Pixels on edge are not redrawn. */ var canvasPtr uintptr _ = canvasPtr canvasPtr = canvas /* * If tkwin is NULL, the canvas has been destroyed, so we can't really * redraw it. */ if (*TTkCanvas)(unsafe.Pointer(canvasPtr)).Ftkwin == libc.UintptrFromInt32(0) { return } if x1 >= x2 || y1 >= y2 || x2 < (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FxOrigin || y2 < (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FyOrigin || x1 >= (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FxOrigin+(*TTk_FakeWin)(unsafe.Pointer((*TTkCanvas)(unsafe.Pointer(canvasPtr)).Ftkwin)).Fchanges.Fwidth || y1 >= (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FyOrigin+(*TTk_FakeWin)(unsafe.Pointer((*TTkCanvas)(unsafe.Pointer(canvasPtr)).Ftkwin)).Fchanges.Fheight { return } if (*TTkCanvas)(unsafe.Pointer(canvasPtr)).Fflags&int32(BBOX_NOT_EMPTY) != 0 { if x1 <= (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FredrawX1 { (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FredrawX1 = x1 } if y1 <= (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FredrawY1 { (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FredrawY1 = y1 } if x2 >= (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FredrawX2 { (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FredrawX2 = x2 } if y2 >= (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FredrawY2 { (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FredrawY2 = y2 } } else { (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FredrawX1 = x1 (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FredrawY1 = y1 (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FredrawX2 = x2 (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FredrawY2 = y2 *(*int32)(unsafe.Pointer(canvasPtr + 648)) |= int32(BBOX_NOT_EMPTY) } if !((*TTkCanvas)(unsafe.Pointer(canvasPtr)).Fflags&libc.Int32FromInt32(REDRAW_PENDING2) != 0) { libtcl9_0.XTcl_DoWhenIdle(tls, __ccgo_fp(_DisplayCanvas), canvasPtr) *(*int32)(unsafe.Pointer(canvasPtr + 648)) |= int32(REDRAW_PENDING2) } } /* *---------------------------------------------------------------------- * * EventuallyRedrawItem -- * * Arrange for part or all of a canvas widget to redrawn at some * convenient time in the future. * * Results: * None. * * Side effects: * The screen will eventually be refreshed. * *---------------------------------------------------------------------- */ func _EventuallyRedrawItem(tls *libc.TLS, canvasPtr uintptr, itemPtr uintptr) { /* Item to be redrawn. May be NULL, in which * case nothing happens. */ if itemPtr == libc.UintptrFromInt32(0) || (*TTkCanvas)(unsafe.Pointer(canvasPtr)).Ftkwin == libc.UintptrFromInt32(0) { return } if (*TTk_Item)(unsafe.Pointer(itemPtr)).Fx1 >= (*TTk_Item)(unsafe.Pointer(itemPtr)).Fx2 || (*TTk_Item)(unsafe.Pointer(itemPtr)).Fy1 >= (*TTk_Item)(unsafe.Pointer(itemPtr)).Fy2 || (*TTk_Item)(unsafe.Pointer(itemPtr)).Fx2 < (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FxOrigin || (*TTk_Item)(unsafe.Pointer(itemPtr)).Fy2 < (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FyOrigin || (*TTk_Item)(unsafe.Pointer(itemPtr)).Fx1 >= (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FxOrigin+(*TTk_FakeWin)(unsafe.Pointer((*TTkCanvas)(unsafe.Pointer(canvasPtr)).Ftkwin)).Fchanges.Fwidth || (*TTk_Item)(unsafe.Pointer(itemPtr)).Fy1 >= (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FyOrigin+(*TTk_FakeWin)(unsafe.Pointer((*TTkCanvas)(unsafe.Pointer(canvasPtr)).Ftkwin)).Fchanges.Fheight { if !(_AlwaysRedraw(tls, itemPtr) != 0) { return } } if !((*TTk_Item)(unsafe.Pointer(itemPtr)).Fredraw_flags&libc.Int32FromInt32(FORCE_REDRAW) != 0) { if (*TTkCanvas)(unsafe.Pointer(canvasPtr)).Fflags&int32(BBOX_NOT_EMPTY) != 0 { if (*TTk_Item)(unsafe.Pointer(itemPtr)).Fx1 <= (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FredrawX1 { (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FredrawX1 = (*TTk_Item)(unsafe.Pointer(itemPtr)).Fx1 } if (*TTk_Item)(unsafe.Pointer(itemPtr)).Fy1 <= (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FredrawY1 { (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FredrawY1 = (*TTk_Item)(unsafe.Pointer(itemPtr)).Fy1 } if (*TTk_Item)(unsafe.Pointer(itemPtr)).Fx2 >= (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FredrawX2 { (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FredrawX2 = (*TTk_Item)(unsafe.Pointer(itemPtr)).Fx2 } if (*TTk_Item)(unsafe.Pointer(itemPtr)).Fy2 >= (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FredrawY2 { (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FredrawY2 = (*TTk_Item)(unsafe.Pointer(itemPtr)).Fy2 } } else { (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FredrawX1 = (*TTk_Item)(unsafe.Pointer(itemPtr)).Fx1 (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FredrawY1 = (*TTk_Item)(unsafe.Pointer(itemPtr)).Fy1 (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FredrawX2 = (*TTk_Item)(unsafe.Pointer(itemPtr)).Fx2 (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FredrawY2 = (*TTk_Item)(unsafe.Pointer(itemPtr)).Fy2 *(*int32)(unsafe.Pointer(canvasPtr + 648)) |= int32(BBOX_NOT_EMPTY) } *(*int32)(unsafe.Pointer(itemPtr + 112)) |= int32(FORCE_REDRAW) } if !((*TTkCanvas)(unsafe.Pointer(canvasPtr)).Fflags&libc.Int32FromInt32(REDRAW_PENDING2) != 0) { libtcl9_0.XTcl_DoWhenIdle(tls, __ccgo_fp(_DisplayCanvas), canvasPtr) *(*int32)(unsafe.Pointer(canvasPtr + 648)) |= int32(REDRAW_PENDING2) } } /* *---------------------------------------------------------------------- * * Tk_CreateItemType -- * * This function may be invoked to add a new kind of canvas element to * the core item types supported by Tk. * * Results: * None. * * Side effects: * From now on, the new item type will be useable in canvas widgets * (e.g. typePtr->name can be used as the item type in "create" widget * commands). If there was already a type with the same name as in * typePtr, it is replaced with the new type. * *---------------------------------------------------------------------- */ func XTk_CreateItemType(tls *libc.TLS, typePtr uintptr) { /* Information about item type; storage must * be statically allocated (must live * forever). */ var prevPtr, typePtr2 uintptr _, _ = prevPtr, typePtr2 if _typeList == libc.UintptrFromInt32(0) { _InitCanvas(tls) } /* * If there's already an item type with the given name, remove it. */ libtcl9_0.XTcl_MutexLock(tls, uintptr(unsafe.Pointer(&_typeListMutex))) typePtr2 = _typeList prevPtr = libc.UintptrFromInt32(0) for { if !(typePtr2 != libc.UintptrFromInt32(0)) { break } if libc.Xstrcmp(tls, (*TTk_ItemType)(unsafe.Pointer(typePtr2)).Fname, (*TTk_ItemType)(unsafe.Pointer(typePtr)).Fname) == 0 { if prevPtr == libc.UintptrFromInt32(0) { _typeList = (*TTk_ItemType)(unsafe.Pointer(typePtr2)).FnextPtr } else { (*TTk_ItemType)(unsafe.Pointer(prevPtr)).FnextPtr = (*TTk_ItemType)(unsafe.Pointer(typePtr2)).FnextPtr } break } goto _1 _1: ; prevPtr = typePtr2 typePtr2 = (*TTk_ItemType)(unsafe.Pointer(typePtr2)).FnextPtr } (*TTk_ItemType)(unsafe.Pointer(typePtr)).FnextPtr = _typeList _typeList = typePtr libtcl9_0.XTcl_MutexUnlock(tls, uintptr(unsafe.Pointer(&_typeListMutex))) } /* *---------------------------------------------------------------------- * * Tk_GetItemTypes -- * * This function returns a pointer to the list of all item types. Note * that this is inherently thread-unsafe, but since item types are only * ever registered very rarely this is unlikely to be a problem in * practice. * * Results: * The return value is a pointer to the first in the list of item types * currently supported by canvases. * * Side effects: * None. * *---------------------------------------------------------------------- */ func XTk_GetItemTypes(tls *libc.TLS) (r uintptr) { if _typeList == libc.UintptrFromInt32(0) { _InitCanvas(tls) } return _typeList } /* *---------------------------------------------------------------------- * * InitCanvas -- * * This function is invoked to perform once-only-ever initialization for * the module, such as setting up the type table. * * Results: * None. * * Side effects: * None. * *---------------------------------------------------------------------- */ func _InitCanvas(tls *libc.TLS) { libtcl9_0.XTcl_MutexLock(tls, uintptr(unsafe.Pointer(&_typeListMutex))) if _typeList != libc.UintptrFromInt32(0) { libtcl9_0.XTcl_MutexUnlock(tls, uintptr(unsafe.Pointer(&_typeListMutex))) return } _typeList = uintptr(unsafe.Pointer(&XtkRectangleType)) XtkRectangleType.FnextPtr = uintptr(unsafe.Pointer(&XtkTextType)) XtkTextType.FnextPtr = uintptr(unsafe.Pointer(&XtkLineType)) XtkLineType.FnextPtr = uintptr(unsafe.Pointer(&XtkPolygonType)) XtkPolygonType.FnextPtr = uintptr(unsafe.Pointer(&XtkImageType)) XtkImageType.FnextPtr = uintptr(unsafe.Pointer(&XtkOvalType)) XtkOvalType.FnextPtr = uintptr(unsafe.Pointer(&XtkBitmapType)) XtkBitmapType.FnextPtr = uintptr(unsafe.Pointer(&XtkArcType)) XtkArcType.FnextPtr = uintptr(unsafe.Pointer(&XtkWindowType)) XtkWindowType.FnextPtr = libc.UintptrFromInt32(0) libtcl9_0.XTcl_MutexUnlock(tls, uintptr(unsafe.Pointer(&_typeListMutex))) } /* *---------------------------------------------------------------------- * * GetStaticUids -- * * This function is invoked to return a structure filled with the Uids * used when doing tag searching. If it was never before called in the * current thread, it initializes the structure for that thread (uids are * only ever local to one thread [Bug 1114977]). * * Results: * None. * * Side effects: * None. * *---------------------------------------------------------------------- */ func _GetStaticUids(tls *libc.TLS) (r uintptr) { var searchUids uintptr _ = searchUids searchUids = libtcl9_0.XTcl_GetThreadData(tls, uintptr(unsafe.Pointer(&_dataKey12)), int64(80)) if (*TSearchUids)(unsafe.Pointer(searchUids)).FallUid == libc.UintptrFromInt32(0) { (*TSearchUids)(unsafe.Pointer(searchUids)).FallUid = XTk_GetUid(tls, __ccgo_ts+5202) (*TSearchUids)(unsafe.Pointer(searchUids)).FcurrentUid = XTk_GetUid(tls, __ccgo_ts+3279) (*TSearchUids)(unsafe.Pointer(searchUids)).FandUid = XTk_GetUid(tls, __ccgo_ts+28062) (*TSearchUids)(unsafe.Pointer(searchUids)).ForUid = XTk_GetUid(tls, __ccgo_ts+28065) (*TSearchUids)(unsafe.Pointer(searchUids)).FxorUid = XTk_GetUid(tls, __ccgo_ts+28068) (*TSearchUids)(unsafe.Pointer(searchUids)).FparenUid = XTk_GetUid(tls, __ccgo_ts+10779) (*TSearchUids)(unsafe.Pointer(searchUids)).FendparenUid = XTk_GetUid(tls, __ccgo_ts+28070) (*TSearchUids)(unsafe.Pointer(searchUids)).FnegparenUid = XTk_GetUid(tls, __ccgo_ts+28072) (*TSearchUids)(unsafe.Pointer(searchUids)).FtagvalUid = XTk_GetUid(tls, __ccgo_ts+28075) (*TSearchUids)(unsafe.Pointer(searchUids)).FnegtagvalUid = XTk_GetUid(tls, __ccgo_ts+28078) } return searchUids } /* *-------------------------------------------------------------- * * TagSearchExprInit -- * * This function allocates and initializes one TagSearchExpr struct. * * Results: * * Side effects: * *-------------------------------------------------------------- */ func _TagSearchExprInit(tls *libc.TLS, exprPtrPtr uintptr) { var expr uintptr _ = expr expr = *(*uintptr)(unsafe.Pointer(exprPtrPtr)) if expr == libc.UintptrFromInt32(0) { expr = libtcl9_0.XTcl_Alloc(tls, uint64(40)) (*TTagSearchExpr)(unsafe.Pointer(expr)).Fallocated = 0 (*TTagSearchExpr)(unsafe.Pointer(expr)).Fuids = libc.UintptrFromInt32(0) (*TTagSearchExpr)(unsafe.Pointer(expr)).Fnext = libc.UintptrFromInt32(0) } (*TTagSearchExpr)(unsafe.Pointer(expr)).Fuid = libc.UintptrFromInt32(0) (*TTagSearchExpr)(unsafe.Pointer(expr)).Findex = 0 (*TTagSearchExpr)(unsafe.Pointer(expr)).Flength = 0 *(*uintptr)(unsafe.Pointer(exprPtrPtr)) = expr } /* *-------------------------------------------------------------- * * TagSearchExprDestroy -- * * This function destroys one TagSearchExpr structure. * * Results: * * Side effects: * *-------------------------------------------------------------- */ func _TagSearchExprDestroy(tls *libc.TLS, expr uintptr) { if expr != libc.UintptrFromInt32(0) { if (*TTagSearchExpr)(unsafe.Pointer(expr)).Fuids != 0 { libtcl9_0.XTcl_Free(tls, (*TTagSearchExpr)(unsafe.Pointer(expr)).Fuids) } libtcl9_0.XTcl_Free(tls, expr) } } /* *-------------------------------------------------------------- * * TagSearchScan -- * * This function is called to initiate an enumeration of all items in a * given canvas that contain a tag that matches the tagOrId expression. * * Results: * The return value indicates if the tagOrId expression was successfully * scanned (syntax). The information at *searchPtr is initialized such * that a call to TagSearchFirst, followed by successive calls to * TagSearchNext will return items that match tag. * * Side effects: * SearchPtr is linked into a list of searches in progress on canvasPtr, * so that elements can safely be deleted while the search is in * progress. * *-------------------------------------------------------------- */ func _TagSearchScan(tls *libc.TLS, canvasPtr uintptr, tagObj uintptr, searchPtrPtr uintptr) (r int32) { bp := tls.Alloc(16) defer tls.Free(16) /* Record describing tag search; will be * initialized here. */ var i int32 var searchPtr, tag, v1 uintptr var _ /* end at bp+0 */ uintptr _, _, _, _ = i, searchPtr, tag, v1 tag = libtcl9_0.XTcl_GetStringFromObj(tls, tagObj, libc.UintptrFromInt32(0)) /* * Initialize the search. */ if *(*uintptr)(unsafe.Pointer(searchPtrPtr)) != libc.UintptrFromInt32(0) { searchPtr = *(*uintptr)(unsafe.Pointer(searchPtrPtr)) } else { /* * Allocate primary search struct on first call. */ v1 = libtcl9_0.XTcl_Alloc(tls, uint64(80)) searchPtr = v1 *(*uintptr)(unsafe.Pointer(searchPtrPtr)) = v1 (*TTagSearch)(unsafe.Pointer(searchPtr)).Fexpr = libc.UintptrFromInt32(0) /* * Allocate buffer for rewritten tags (after de-escaping). */ (*TTagSearch)(unsafe.Pointer(searchPtr)).FrewritebufferAllocated = uint32(100) (*TTagSearch)(unsafe.Pointer(searchPtr)).Frewritebuffer = libtcl9_0.XTcl_Alloc(tls, uint64((*TTagSearch)(unsafe.Pointer(searchPtr)).FrewritebufferAllocated)) } _TagSearchExprInit(tls, searchPtr+72) /* * How long is the tagOrId? */ (*TTagSearch)(unsafe.Pointer(searchPtr)).FstringLength = libc.Int32FromUint64(libc.Xstrlen(tls, tag)) /* * Make sure there is enough buffer to hold rewritten tags. */ if libc.Uint32FromInt32((*TTagSearch)(unsafe.Pointer(searchPtr)).FstringLength) >= (*TTagSearch)(unsafe.Pointer(searchPtr)).FrewritebufferAllocated { (*TTagSearch)(unsafe.Pointer(searchPtr)).FrewritebufferAllocated = libc.Uint32FromInt32((*TTagSearch)(unsafe.Pointer(searchPtr)).FstringLength + int32(100)) (*TTagSearch)(unsafe.Pointer(searchPtr)).Frewritebuffer = libtcl9_0.XTcl_Realloc(tls, (*TTagSearch)(unsafe.Pointer(searchPtr)).Frewritebuffer, uint64((*TTagSearch)(unsafe.Pointer(searchPtr)).FrewritebufferAllocated)) } /* * Initialize search. */ (*TTagSearch)(unsafe.Pointer(searchPtr)).FcanvasPtr = canvasPtr (*TTagSearch)(unsafe.Pointer(searchPtr)).FsearchOver = 0 (*TTagSearch)(unsafe.Pointer(searchPtr)).Ftype1 = SEARCH_TYPE_EMPTY /* * Find the first matching item in one of several ways. If the tag is a * number then it selects the single item with the matching identifier. * In this case see if the item being requested is the hot item, in which * case the search can be skipped. */ if (*TTagSearch)(unsafe.Pointer(searchPtr)).FstringLength != 0 && libc.BoolInt32(uint32(*(*uint8)(unsafe.Pointer(tag)))-uint32('0') < uint32(10)) != 0 { (*TTagSearch)(unsafe.Pointer(searchPtr)).Fid = libc.Int64FromUint64(libc.Xstrtoul(tls, tag, bp, 0)) if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp))))) == 0 { (*TTagSearch)(unsafe.Pointer(searchPtr)).Ftype1 = int32(SEARCH_TYPE_ID) return TCL_OK } } /* * For all other tags and tag expressions convert to a UID. This UID is * kept forever, but this should be thought of as a cache rather than as a * memory leak. */ (*TTagSearchExpr)(unsafe.Pointer((*TTagSearch)(unsafe.Pointer(searchPtr)).Fexpr)).Fuid = XTk_GetUid(tls, tag) /* * Short circuit impossible searches for null tags. */ if (*TTagSearch)(unsafe.Pointer(searchPtr)).FstringLength == 0 { return TCL_OK } /* * Pre-scan tag for at least one unquoted "&&" "||" "^" "!"; if not found * then use string as simple tag. */ i = 0 for { if !(i < (*TTagSearch)(unsafe.Pointer(searchPtr)).FstringLength) { break } if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(tag + uintptr(i)))) == int32('"') { i++ for { if !(i < (*TTagSearch)(unsafe.Pointer(searchPtr)).FstringLength) { break } if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(tag + uintptr(i)))) == int32('\\') { i++ goto _3 } if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(tag + uintptr(i)))) == int32('"') { break } goto _3 _3: ; i++ } } else { if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(tag + uintptr(i)))) == int32('&') && libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(tag + uintptr(i+int32(1))))) == int32('&') || libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(tag + uintptr(i)))) == int32('|') && libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(tag + uintptr(i+int32(1))))) == int32('|') || libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(tag + uintptr(i)))) == int32('^') || libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(tag + uintptr(i)))) == int32('!') { (*TTagSearch)(unsafe.Pointer(searchPtr)).Ftype1 = int32(SEARCH_TYPE_EXPR) break } } goto _2 _2: ; i++ } (*TTagSearch)(unsafe.Pointer(searchPtr)).Fstring1 = tag (*TTagSearch)(unsafe.Pointer(searchPtr)).FstringIndex = 0 if (*TTagSearch)(unsafe.Pointer(searchPtr)).Ftype1 == int32(SEARCH_TYPE_EXPR) { /* * An operator was found in the prescan, so now compile the tag * expression into array of Tk_Uid flagging any syntax errors found. */ if _TagSearchScanExpr(tls, (*TTkCanvas)(unsafe.Pointer(canvasPtr)).Finterp, searchPtr, (*TTagSearch)(unsafe.Pointer(searchPtr)).Fexpr) != TCL_OK { /* * Syntax error in tag expression. The result message was set by * TagSearchScanExpr. */ return int32(TCL_ERROR) } (*TTagSearchExpr)(unsafe.Pointer((*TTagSearch)(unsafe.Pointer(searchPtr)).Fexpr)).Flength = (*TTagSearchExpr)(unsafe.Pointer((*TTagSearch)(unsafe.Pointer(searchPtr)).Fexpr)).Findex } else { if (*TTagSearchExpr)(unsafe.Pointer((*TTagSearch)(unsafe.Pointer(searchPtr)).Fexpr)).Fuid == (*TSearchUids)(unsafe.Pointer(_GetStaticUids(tls))).FallUid { /* * All items match. */ (*TTagSearch)(unsafe.Pointer(searchPtr)).Ftype1 = int32(SEARCH_TYPE_ALL) } else { /* * Optimized single-tag search */ (*TTagSearch)(unsafe.Pointer(searchPtr)).Ftype1 = int32(SEARCH_TYPE_TAG) } } return TCL_OK } /* *-------------------------------------------------------------- * * TagSearchDestroy -- * * This function destroys any dynamic structures that may have been * allocated by TagSearchScan. * * Results: * None * * Side effects: * Deallocates memory. * *-------------------------------------------------------------- */ func _TagSearchDestroy(tls *libc.TLS, searchPtr uintptr) { /* Record describing tag search. */ if searchPtr != 0 { _TagSearchExprDestroy(tls, (*TTagSearch)(unsafe.Pointer(searchPtr)).Fexpr) libtcl9_0.XTcl_Free(tls, (*TTagSearch)(unsafe.Pointer(searchPtr)).Frewritebuffer) libtcl9_0.XTcl_Free(tls, searchPtr) } } /* *-------------------------------------------------------------- * * TagSearchScanExpr -- * * This recursive function is called to scan a tag expression and compile * it into an array of Tk_Uids. * * Results: * The return value indicates if the tagOrId expression was successfully * scanned (syntax). The information at *searchPtr is initialized such * that a call to TagSearchFirst, followed by successive calls to * TagSearchNext will return items that match tag. * * Side effects: * *-------------------------------------------------------------- */ func _TagSearchScanExpr(tls *libc.TLS, interp uintptr, searchPtr uintptr, expr uintptr) (r int32) { bp := tls.Alloc(48) defer tls.Free(48) /* Compiled expression result. */ var c uint8 var found_endquote, found_tag, looking_for_tag, negate_result, v1, v11, v13, v17, v19, v21, v27, v29, v3, v31, v33, v35, v37, v39, v5, v7, v9 int32 var searchUids, tag, v10, v12, v14, v15, v16, v18, v2, v20, v22, v23, v24, v25, v26, v28, v30, v32, v34, v36, v38, v4, v40, v6, v8 uintptr _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = c, found_endquote, found_tag, looking_for_tag, negate_result, searchUids, tag, v1, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v2, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v3, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v4, v40, v5, v6, v7, v8, v9 /* Collection of uids for basic search * expression terms. */ searchUids = _GetStaticUids(tls) negate_result = 0 found_tag = 0 looking_for_tag = int32(1) for (*TTagSearch)(unsafe.Pointer(searchPtr)).FstringIndex < (*TTagSearch)(unsafe.Pointer(searchPtr)).FstringLength { v2 = searchPtr + 48 v1 = *(*int32)(unsafe.Pointer(v2)) *(*int32)(unsafe.Pointer(v2))++ c = *(*uint8)(unsafe.Pointer((*TTagSearch)(unsafe.Pointer(searchPtr)).Fstring1 + uintptr(v1))) /* * Need two slots free at this point, not one. [Bug 2931374] */ if (*TTagSearchExpr)(unsafe.Pointer(expr)).Findex >= (*TTagSearchExpr)(unsafe.Pointer(expr)).Fallocated-int32(1) { *(*int32)(unsafe.Pointer(expr + 24)) += int32(15) if (*TTagSearchExpr)(unsafe.Pointer(expr)).Fuids != 0 { (*TTagSearchExpr)(unsafe.Pointer(expr)).Fuids = libtcl9_0.XTcl_Realloc(tls, (*TTagSearchExpr)(unsafe.Pointer(expr)).Fuids, libc.Uint64FromInt32((*TTagSearchExpr)(unsafe.Pointer(expr)).Fallocated)*uint64(8)) } else { (*TTagSearchExpr)(unsafe.Pointer(expr)).Fuids = libtcl9_0.XTcl_Alloc(tls, libc.Uint64FromInt32((*TTagSearchExpr)(unsafe.Pointer(expr)).Fallocated)*uint64(8)) } } if looking_for_tag != 0 { switch libc.Int32FromUint8(c) { case int32(' '): /* Ignore unquoted whitespace */ fallthrough case int32('\t'): fallthrough case int32('\n'): fallthrough case int32('\r'): case int32('!'): /* Negate next tag or subexpr */ if looking_for_tag > int32(1) { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+28080, int64(-libc.Int32FromInt32(1)))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+8, __ccgo_ts+179, __ccgo_ts+27003, __ccgo_ts+28118, __ccgo_ts+28125, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) } looking_for_tag++ negate_result = int32(1) case int32('('): /* Scan (negated) subexpr recursively */ if negate_result != 0 { v4 = expr + 32 v3 = *(*int32)(unsafe.Pointer(v4)) *(*int32)(unsafe.Pointer(v4))++ *(*TTk_Uid)(unsafe.Pointer((*TTagSearchExpr)(unsafe.Pointer(expr)).Fuids + uintptr(v3)*8)) = (*TSearchUids)(unsafe.Pointer(searchUids)).FnegparenUid negate_result = 0 } else { v6 = expr + 32 v5 = *(*int32)(unsafe.Pointer(v6)) *(*int32)(unsafe.Pointer(v6))++ *(*TTk_Uid)(unsafe.Pointer((*TTagSearchExpr)(unsafe.Pointer(expr)).Fuids + uintptr(v5)*8)) = (*TSearchUids)(unsafe.Pointer(searchUids)).FparenUid } if _TagSearchScanExpr(tls, interp, searchPtr, expr) != TCL_OK { /* * Result string should be already set by nested call to * tag_expr_scan() */ return int32(TCL_ERROR) } looking_for_tag = 0 found_tag = int32(1) case int32('"'): /* Quoted tag string */ if negate_result != 0 { v8 = expr + 32 v7 = *(*int32)(unsafe.Pointer(v8)) *(*int32)(unsafe.Pointer(v8))++ *(*TTk_Uid)(unsafe.Pointer((*TTagSearchExpr)(unsafe.Pointer(expr)).Fuids + uintptr(v7)*8)) = (*TSearchUids)(unsafe.Pointer(searchUids)).FnegtagvalUid negate_result = 0 } else { v10 = expr + 32 v9 = *(*int32)(unsafe.Pointer(v10)) *(*int32)(unsafe.Pointer(v10))++ *(*TTk_Uid)(unsafe.Pointer((*TTagSearchExpr)(unsafe.Pointer(expr)).Fuids + uintptr(v9)*8)) = (*TSearchUids)(unsafe.Pointer(searchUids)).FtagvalUid } tag = (*TTagSearch)(unsafe.Pointer(searchPtr)).Frewritebuffer found_endquote = 0 for (*TTagSearch)(unsafe.Pointer(searchPtr)).FstringIndex < (*TTagSearch)(unsafe.Pointer(searchPtr)).FstringLength { v12 = searchPtr + 48 v11 = *(*int32)(unsafe.Pointer(v12)) *(*int32)(unsafe.Pointer(v12))++ c = *(*uint8)(unsafe.Pointer((*TTagSearch)(unsafe.Pointer(searchPtr)).Fstring1 + uintptr(v11))) if libc.Int32FromUint8(c) == int32('\\') { v14 = searchPtr + 48 v13 = *(*int32)(unsafe.Pointer(v14)) *(*int32)(unsafe.Pointer(v14))++ c = *(*uint8)(unsafe.Pointer((*TTagSearch)(unsafe.Pointer(searchPtr)).Fstring1 + uintptr(v13))) } if libc.Int32FromUint8(c) == int32('"') { found_endquote = int32(1) break } v15 = tag tag++ *(*uint8)(unsafe.Pointer(v15)) = c } if !(found_endquote != 0) { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+28136, int64(-libc.Int32FromInt32(1)))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+8, __ccgo_ts+179, __ccgo_ts+27003, __ccgo_ts+28118, __ccgo_ts+28178, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) } if !(int64(tag)-int64((*TTagSearch)(unsafe.Pointer(searchPtr)).Frewritebuffer) != 0) { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+28187, int64(-libc.Int32FromInt32(1)))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+8, __ccgo_ts+179, __ccgo_ts+27003, __ccgo_ts+28118, __ccgo_ts+28235, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) } v16 = tag tag++ *(*uint8)(unsafe.Pointer(v16)) = uint8('\000') v18 = expr + 32 v17 = *(*int32)(unsafe.Pointer(v18)) *(*int32)(unsafe.Pointer(v18))++ *(*TTk_Uid)(unsafe.Pointer((*TTagSearchExpr)(unsafe.Pointer(expr)).Fuids + uintptr(v17)*8)) = XTk_GetUid(tls, (*TTagSearch)(unsafe.Pointer(searchPtr)).Frewritebuffer) looking_for_tag = 0 found_tag = int32(1) case int32('&'): /* Illegal chars when looking for tag */ fallthrough case int32('|'): fallthrough case int32('^'): fallthrough case int32(')'): libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+28241, int64(-libc.Int32FromInt32(1)))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+8, __ccgo_ts+179, __ccgo_ts+27003, __ccgo_ts+28118, __ccgo_ts+28286, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) default: /* Unquoted tag string */ if negate_result != 0 { v20 = expr + 32 v19 = *(*int32)(unsafe.Pointer(v20)) *(*int32)(unsafe.Pointer(v20))++ *(*TTk_Uid)(unsafe.Pointer((*TTagSearchExpr)(unsafe.Pointer(expr)).Fuids + uintptr(v19)*8)) = (*TSearchUids)(unsafe.Pointer(searchUids)).FnegtagvalUid negate_result = 0 } else { v22 = expr + 32 v21 = *(*int32)(unsafe.Pointer(v22)) *(*int32)(unsafe.Pointer(v22))++ *(*TTk_Uid)(unsafe.Pointer((*TTagSearchExpr)(unsafe.Pointer(expr)).Fuids + uintptr(v21)*8)) = (*TSearchUids)(unsafe.Pointer(searchUids)).FtagvalUid } tag = (*TTagSearch)(unsafe.Pointer(searchPtr)).Frewritebuffer v23 = tag tag++ *(*uint8)(unsafe.Pointer(v23)) = c /* * Copy rest of tag, including any embedded whitespace. */ for (*TTagSearch)(unsafe.Pointer(searchPtr)).FstringIndex < (*TTagSearch)(unsafe.Pointer(searchPtr)).FstringLength { c = *(*uint8)(unsafe.Pointer((*TTagSearch)(unsafe.Pointer(searchPtr)).Fstring1 + uintptr((*TTagSearch)(unsafe.Pointer(searchPtr)).FstringIndex))) if libc.Int32FromUint8(c) == int32('!') || libc.Int32FromUint8(c) == int32('&') || libc.Int32FromUint8(c) == int32('|') || libc.Int32FromUint8(c) == int32('^') || libc.Int32FromUint8(c) == int32('(') || libc.Int32FromUint8(c) == int32(')') || libc.Int32FromUint8(c) == int32('"') { break } v24 = tag tag++ *(*uint8)(unsafe.Pointer(v24)) = c (*TTagSearch)(unsafe.Pointer(searchPtr)).FstringIndex++ } /* * Remove trailing whitespace. */ for int32(1) != 0 { tag-- v25 = tag c = *(*uint8)(unsafe.Pointer(v25)) /* * There must have been one non-whitespace char, so this * will terminate. */ if libc.Int32FromUint8(c) != int32(' ') && libc.Int32FromUint8(c) != int32('\t') && libc.Int32FromUint8(c) != int32('\n') && libc.Int32FromUint8(c) != int32('\r') { break } } tag++ v26 = tag *(*uint8)(unsafe.Pointer(v26)) = uint8('\000') v28 = expr + 32 v27 = *(*int32)(unsafe.Pointer(v28)) *(*int32)(unsafe.Pointer(v28))++ *(*TTk_Uid)(unsafe.Pointer((*TTagSearchExpr)(unsafe.Pointer(expr)).Fuids + uintptr(v27)*8)) = XTk_GetUid(tls, (*TTagSearch)(unsafe.Pointer(searchPtr)).Frewritebuffer) looking_for_tag = 0 found_tag = int32(1) } } else { /* ! looking_for_tag */ switch libc.Int32FromUint8(c) { case int32(' '): /* Ignore whitespace */ fallthrough case int32('\t'): fallthrough case int32('\n'): fallthrough case int32('\r'): case int32('&'): /* AND operator */ v30 = searchPtr + 48 v29 = *(*int32)(unsafe.Pointer(v30)) *(*int32)(unsafe.Pointer(v30))++ c = *(*uint8)(unsafe.Pointer((*TTagSearch)(unsafe.Pointer(searchPtr)).Fstring1 + uintptr(v29))) if libc.Int32FromUint8(c) != int32('&') { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+28297, int64(-libc.Int32FromInt32(1)))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+8, __ccgo_ts+179, __ccgo_ts+27003, __ccgo_ts+28118, __ccgo_ts+28336, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) } v32 = expr + 32 v31 = *(*int32)(unsafe.Pointer(v32)) *(*int32)(unsafe.Pointer(v32))++ *(*TTk_Uid)(unsafe.Pointer((*TTagSearchExpr)(unsafe.Pointer(expr)).Fuids + uintptr(v31)*8)) = (*TSearchUids)(unsafe.Pointer(searchUids)).FandUid looking_for_tag = int32(1) case int32('|'): /* OR operator */ v34 = searchPtr + 48 v33 = *(*int32)(unsafe.Pointer(v34)) *(*int32)(unsafe.Pointer(v34))++ c = *(*uint8)(unsafe.Pointer((*TTagSearch)(unsafe.Pointer(searchPtr)).Fstring1 + uintptr(v33))) if libc.Int32FromUint8(c) != int32('|') { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+28350, int64(-libc.Int32FromInt32(1)))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+8, __ccgo_ts+179, __ccgo_ts+27003, __ccgo_ts+28118, __ccgo_ts+28336, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) } v36 = expr + 32 v35 = *(*int32)(unsafe.Pointer(v36)) *(*int32)(unsafe.Pointer(v36))++ *(*TTk_Uid)(unsafe.Pointer((*TTagSearchExpr)(unsafe.Pointer(expr)).Fuids + uintptr(v35)*8)) = (*TSearchUids)(unsafe.Pointer(searchUids)).ForUid looking_for_tag = int32(1) case int32('^'): /* XOR operator */ v38 = expr + 32 v37 = *(*int32)(unsafe.Pointer(v38)) *(*int32)(unsafe.Pointer(v38))++ *(*TTk_Uid)(unsafe.Pointer((*TTagSearchExpr)(unsafe.Pointer(expr)).Fuids + uintptr(v37)*8)) = (*TSearchUids)(unsafe.Pointer(searchUids)).FxorUid looking_for_tag = int32(1) case int32(')'): /* End subexpression */ v40 = expr + 32 v39 = *(*int32)(unsafe.Pointer(v40)) *(*int32)(unsafe.Pointer(v40))++ *(*TTk_Uid)(unsafe.Pointer((*TTagSearchExpr)(unsafe.Pointer(expr)).Fuids + uintptr(v39)*8)) = (*TSearchUids)(unsafe.Pointer(searchUids)).FendparenUid goto breakwhile default: /* syntax error */ libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+28389, int64(-libc.Int32FromInt32(1)))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+8, __ccgo_ts+179, __ccgo_ts+27003, __ccgo_ts+28118, __ccgo_ts+28439, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) } } } goto breakwhile breakwhile: ; if found_tag != 0 && !(looking_for_tag != 0) { return TCL_OK } libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+28446, int64(-libc.Int32FromInt32(1)))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+8, __ccgo_ts+179, __ccgo_ts+27003, __ccgo_ts+28118, __ccgo_ts+28483, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) } /* *-------------------------------------------------------------- * * TagSearchEvalExpr -- * * This recursive function is called to eval a tag expression. * * Results: * The return value indicates if the tagOrId expression successfully * matched the tags of the current item. * * Side effects: * *-------------------------------------------------------------- */ func _TagSearchEvalExpr(tls *libc.TLS, expr uintptr, itemPtr uintptr) (r int32) { /* Item being test for match */ var count, looking_for_tag, negate_result, parendepth, result, v1, v3, v6, v9 int32 var searchUids, tagPtr, v10, v2, v4, v7 uintptr var uid TTk_Uid _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = count, looking_for_tag, negate_result, parendepth, result, searchUids, tagPtr, uid, v1, v10, v2, v3, v4, v6, v7, v9 /* Collection of uids for basic search * expression terms. */ searchUids = _GetStaticUids(tls) result = 0 /* Just to keep the compiler quiet. */ negate_result = 0 looking_for_tag = int32(1) for (*TTagSearchExpr)(unsafe.Pointer(expr)).Findex < (*TTagSearchExpr)(unsafe.Pointer(expr)).Flength { v2 = expr + 32 v1 = *(*int32)(unsafe.Pointer(v2)) *(*int32)(unsafe.Pointer(v2))++ uid = *(*TTk_Uid)(unsafe.Pointer((*TTagSearchExpr)(unsafe.Pointer(expr)).Fuids + uintptr(v1)*8)) if looking_for_tag != 0 { if uid == (*TSearchUids)(unsafe.Pointer(searchUids)).FtagvalUid { /* * assert(expr->index < expr->length); */ v4 = expr + 32 v3 = *(*int32)(unsafe.Pointer(v4)) *(*int32)(unsafe.Pointer(v4))++ uid = *(*TTk_Uid)(unsafe.Pointer((*TTagSearchExpr)(unsafe.Pointer(expr)).Fuids + uintptr(v3)*8)) result = 0 /* * set result 1 if tag is found in item's tags */ tagPtr = (*TTk_Item)(unsafe.Pointer(itemPtr)).FtagPtr count = int32((*TTk_Item)(unsafe.Pointer(itemPtr)).FnumTags) for { if !(count > 0) { break } if *(*TTk_Uid)(unsafe.Pointer(tagPtr)) == uid { result = int32(1) break } goto _5 _5: ; tagPtr += 8 count-- } } else { if uid == (*TSearchUids)(unsafe.Pointer(searchUids)).FnegtagvalUid { negate_result = libc.BoolInt32(!(negate_result != 0)) /* * assert(expr->index < expr->length); */ v7 = expr + 32 v6 = *(*int32)(unsafe.Pointer(v7)) *(*int32)(unsafe.Pointer(v7))++ uid = *(*TTk_Uid)(unsafe.Pointer((*TTagSearchExpr)(unsafe.Pointer(expr)).Fuids + uintptr(v6)*8)) result = 0 /* * set result 1 if tag is found in item's tags. */ tagPtr = (*TTk_Item)(unsafe.Pointer(itemPtr)).FtagPtr count = int32((*TTk_Item)(unsafe.Pointer(itemPtr)).FnumTags) for { if !(count > 0) { break } if *(*TTk_Uid)(unsafe.Pointer(tagPtr)) == uid { result = int32(1) break } goto _8 _8: ; tagPtr += 8 count-- } } else { if uid == (*TSearchUids)(unsafe.Pointer(searchUids)).FparenUid { /* * Evaluate subexpressions with recursion. */ result = _TagSearchEvalExpr(tls, expr, itemPtr) } else { if uid == (*TSearchUids)(unsafe.Pointer(searchUids)).FnegparenUid { negate_result = libc.BoolInt32(!(negate_result != 0)) /* * Evaluate subexpressions with recursion. */ result = _TagSearchEvalExpr(tls, expr, itemPtr) } } } } if negate_result != 0 { result = libc.BoolInt32(!(result != 0)) negate_result = 0 } looking_for_tag = 0 } else { /* ! looking_for_tag */ if uid == (*TSearchUids)(unsafe.Pointer(searchUids)).FandUid && !(result != 0) || uid == (*TSearchUids)(unsafe.Pointer(searchUids)).ForUid && result != 0 { /* * Short circuit expression evaluation. * * if result before && is 0, or result before || is 1, then * the expression is decided and no further evaluation is * needed. */ parendepth = 0 for (*TTagSearchExpr)(unsafe.Pointer(expr)).Findex < (*TTagSearchExpr)(unsafe.Pointer(expr)).Flength { v10 = expr + 32 v9 = *(*int32)(unsafe.Pointer(v10)) *(*int32)(unsafe.Pointer(v10))++ uid = *(*TTk_Uid)(unsafe.Pointer((*TTagSearchExpr)(unsafe.Pointer(expr)).Fuids + uintptr(v9)*8)) if uid == (*TSearchUids)(unsafe.Pointer(searchUids)).FtagvalUid || uid == (*TSearchUids)(unsafe.Pointer(searchUids)).FnegtagvalUid { (*TTagSearchExpr)(unsafe.Pointer(expr)).Findex++ continue } if uid == (*TSearchUids)(unsafe.Pointer(searchUids)).FparenUid || uid == (*TSearchUids)(unsafe.Pointer(searchUids)).FnegparenUid { parendepth++ continue } if uid == (*TSearchUids)(unsafe.Pointer(searchUids)).FendparenUid { parendepth-- if parendepth < 0 { break } } } return result } else { if uid == (*TSearchUids)(unsafe.Pointer(searchUids)).FxorUid { /* * If the previous result was 1 then negate the next result. */ negate_result = result } else { if uid == (*TSearchUids)(unsafe.Pointer(searchUids)).FendparenUid { return result } } } looking_for_tag = int32(1) } } /* * assert(!looking_for_tag); */ return result } /* *-------------------------------------------------------------- * * TagSearchFirst -- * * This function is called to get the first item item that matches a * preestablished search predicate that was set by TagSearchScan. * * Results: * The return value is a pointer to the first item, or NULL if there is * no such item. The information at *searchPtr is updated such that * successive calls to TagSearchNext will return successive items. * * Side effects: * SearchPtr is linked into a list of searches in progress on canvasPtr, * so that elements can safely be deleted while the search is in * progress. * *-------------------------------------------------------------- */ func _TagSearchFirst(tls *libc.TLS, searchPtr uintptr) (r uintptr) { /* Record describing tag search */ var count int32 var entryPtr, itemPtr, lastPtr, tagPtr, v1 uintptr var uid TTk_Uid _, _, _, _, _, _, _ = count, entryPtr, itemPtr, lastPtr, tagPtr, uid, v1 /* * Short circuit impossible searches for null tags. */ if (*TTagSearch)(unsafe.Pointer(searchPtr)).FstringLength == 0 { return libc.UintptrFromInt32(0) } /* * Find the first matching item in one of several ways. If the tag is a * number then it selects the single item with the matching identifier. * In this case see if the item being requested is the hot item, in which * case the search can be skipped. */ if (*TTagSearch)(unsafe.Pointer(searchPtr)).Ftype1 == int32(SEARCH_TYPE_ID) { itemPtr = (*TTkCanvas)(unsafe.Pointer((*TTagSearch)(unsafe.Pointer(searchPtr)).FcanvasPtr)).FhotPtr lastPtr = (*TTkCanvas)(unsafe.Pointer((*TTagSearch)(unsafe.Pointer(searchPtr)).FcanvasPtr)).FhotPrevPtr if itemPtr == libc.UintptrFromInt32(0) || (*TTk_Item)(unsafe.Pointer(itemPtr)).Fid != (*TTagSearch)(unsafe.Pointer(searchPtr)).Fid || lastPtr == libc.UintptrFromInt32(0) || (*TTk_Item)(unsafe.Pointer(lastPtr)).FnextPtr != itemPtr { entryPtr = (*(*func(*libc.TLS, uintptr, uintptr) uintptr)(unsafe.Pointer(&struct{ uintptr }{(*TTcl_HashTable)(unsafe.Pointer((*TTagSearch)(unsafe.Pointer(searchPtr)).FcanvasPtr + 672)).FfindProc})))(tls, (*TTagSearch)(unsafe.Pointer(searchPtr)).FcanvasPtr+672, uintptr((*TTagSearch)(unsafe.Pointer(searchPtr)).Fid)) if entryPtr != libc.UintptrFromInt32(0) { itemPtr = (*TTcl_HashEntry)(unsafe.Pointer(entryPtr)).FclientData lastPtr = (*TTk_Item)(unsafe.Pointer(itemPtr)).FprevPtr } else { v1 = libc.UintptrFromInt32(0) itemPtr = v1 lastPtr = v1 } } (*TTagSearch)(unsafe.Pointer(searchPtr)).FlastPtr = lastPtr (*TTagSearch)(unsafe.Pointer(searchPtr)).FsearchOver = int32(1) (*TTkCanvas)(unsafe.Pointer((*TTagSearch)(unsafe.Pointer(searchPtr)).FcanvasPtr)).FhotPtr = itemPtr (*TTkCanvas)(unsafe.Pointer((*TTagSearch)(unsafe.Pointer(searchPtr)).FcanvasPtr)).FhotPrevPtr = lastPtr return itemPtr } if (*TTagSearch)(unsafe.Pointer(searchPtr)).Ftype1 == int32(SEARCH_TYPE_ALL) { /* * All items match. */ (*TTagSearch)(unsafe.Pointer(searchPtr)).FlastPtr = libc.UintptrFromInt32(0) (*TTagSearch)(unsafe.Pointer(searchPtr)).FcurrentPtr = (*TTkCanvas)(unsafe.Pointer((*TTagSearch)(unsafe.Pointer(searchPtr)).FcanvasPtr)).FfirstItemPtr return (*TTkCanvas)(unsafe.Pointer((*TTagSearch)(unsafe.Pointer(searchPtr)).FcanvasPtr)).FfirstItemPtr } if (*TTagSearch)(unsafe.Pointer(searchPtr)).Ftype1 == int32(SEARCH_TYPE_TAG) { /* * Optimized single-tag search */ uid = (*TTagSearchExpr)(unsafe.Pointer((*TTagSearch)(unsafe.Pointer(searchPtr)).Fexpr)).Fuid lastPtr = libc.UintptrFromInt32(0) itemPtr = (*TTkCanvas)(unsafe.Pointer((*TTagSearch)(unsafe.Pointer(searchPtr)).FcanvasPtr)).FfirstItemPtr for { if !(itemPtr != libc.UintptrFromInt32(0)) { break } tagPtr = (*TTk_Item)(unsafe.Pointer(itemPtr)).FtagPtr count = int32((*TTk_Item)(unsafe.Pointer(itemPtr)).FnumTags) for { if !(count > 0) { break } if *(*TTk_Uid)(unsafe.Pointer(tagPtr)) == uid { (*TTagSearch)(unsafe.Pointer(searchPtr)).FlastPtr = lastPtr (*TTagSearch)(unsafe.Pointer(searchPtr)).FcurrentPtr = itemPtr return itemPtr } goto _3 _3: ; tagPtr += 8 count-- } goto _2 _2: ; lastPtr = itemPtr itemPtr = (*TTk_Item)(unsafe.Pointer(itemPtr)).FnextPtr } } else { /* * None of the above. Search for an item matching the tag expression. */ lastPtr = libc.UintptrFromInt32(0) itemPtr = (*TTkCanvas)(unsafe.Pointer((*TTagSearch)(unsafe.Pointer(searchPtr)).FcanvasPtr)).FfirstItemPtr for { if !(itemPtr != libc.UintptrFromInt32(0)) { break } (*TTagSearchExpr)(unsafe.Pointer((*TTagSearch)(unsafe.Pointer(searchPtr)).Fexpr)).Findex = 0 if _TagSearchEvalExpr(tls, (*TTagSearch)(unsafe.Pointer(searchPtr)).Fexpr, itemPtr) != 0 { (*TTagSearch)(unsafe.Pointer(searchPtr)).FlastPtr = lastPtr (*TTagSearch)(unsafe.Pointer(searchPtr)).FcurrentPtr = itemPtr return itemPtr } goto _4 _4: ; lastPtr = itemPtr itemPtr = (*TTk_Item)(unsafe.Pointer(itemPtr)).FnextPtr } } (*TTagSearch)(unsafe.Pointer(searchPtr)).FlastPtr = lastPtr (*TTagSearch)(unsafe.Pointer(searchPtr)).FsearchOver = int32(1) return libc.UintptrFromInt32(0) } /* *-------------------------------------------------------------- * * TagSearchNext -- * * This function returns successive items that match a given tag; it * should be called only after TagSearchFirst has been used to begin a * search. * * Results: * The return value is a pointer to the next item that matches the tag * expr specified to TagSearchScan, or NULL if no such item exists. * *SearchPtr is updated so that the next call to this function will * return the next item. * * Side effects: * None. * *-------------------------------------------------------------- */ func _TagSearchNext(tls *libc.TLS, searchPtr uintptr) (r uintptr) { /* Record describing search in progress. */ var count int32 var itemPtr, lastPtr, tagPtr uintptr var uid TTk_Uid _, _, _, _, _ = count, itemPtr, lastPtr, tagPtr, uid /* * Find next item in list (this may not actually be a suitable one to * return), and return if there are no items left. */ lastPtr = (*TTagSearch)(unsafe.Pointer(searchPtr)).FlastPtr if lastPtr == libc.UintptrFromInt32(0) { itemPtr = (*TTkCanvas)(unsafe.Pointer((*TTagSearch)(unsafe.Pointer(searchPtr)).FcanvasPtr)).FfirstItemPtr } else { itemPtr = (*TTk_Item)(unsafe.Pointer(lastPtr)).FnextPtr } if itemPtr == libc.UintptrFromInt32(0) || (*TTagSearch)(unsafe.Pointer(searchPtr)).FsearchOver != 0 { (*TTagSearch)(unsafe.Pointer(searchPtr)).FsearchOver = int32(1) return libc.UintptrFromInt32(0) } if itemPtr != (*TTagSearch)(unsafe.Pointer(searchPtr)).FcurrentPtr { /* * The structure of the list has changed. Probably the previously- * returned item was removed from the list. In this case, don't * advance lastPtr; just return its new successor (i.e. do nothing * here). */ } else { lastPtr = itemPtr itemPtr = (*TTk_Item)(unsafe.Pointer(lastPtr)).FnextPtr } if (*TTagSearch)(unsafe.Pointer(searchPtr)).Ftype1 == int32(SEARCH_TYPE_ALL) { /* * All items match. */ (*TTagSearch)(unsafe.Pointer(searchPtr)).FlastPtr = lastPtr (*TTagSearch)(unsafe.Pointer(searchPtr)).FcurrentPtr = itemPtr return itemPtr } if (*TTagSearch)(unsafe.Pointer(searchPtr)).Ftype1 == int32(SEARCH_TYPE_TAG) { /* * Optimized single-tag search */ uid = (*TTagSearchExpr)(unsafe.Pointer((*TTagSearch)(unsafe.Pointer(searchPtr)).Fexpr)).Fuid for { if !(itemPtr != libc.UintptrFromInt32(0)) { break } tagPtr = (*TTk_Item)(unsafe.Pointer(itemPtr)).FtagPtr count = int32((*TTk_Item)(unsafe.Pointer(itemPtr)).FnumTags) for { if !(count > 0) { break } if *(*TTk_Uid)(unsafe.Pointer(tagPtr)) == uid { (*TTagSearch)(unsafe.Pointer(searchPtr)).FlastPtr = lastPtr (*TTagSearch)(unsafe.Pointer(searchPtr)).FcurrentPtr = itemPtr return itemPtr } goto _2 _2: ; tagPtr += 8 count-- } goto _1 _1: ; lastPtr = itemPtr itemPtr = (*TTk_Item)(unsafe.Pointer(itemPtr)).FnextPtr } (*TTagSearch)(unsafe.Pointer(searchPtr)).FlastPtr = lastPtr (*TTagSearch)(unsafe.Pointer(searchPtr)).FsearchOver = int32(1) return libc.UintptrFromInt32(0) } /* * Else.... evaluate tag expression */ for { if !(itemPtr != libc.UintptrFromInt32(0)) { break } (*TTagSearchExpr)(unsafe.Pointer((*TTagSearch)(unsafe.Pointer(searchPtr)).Fexpr)).Findex = 0 if _TagSearchEvalExpr(tls, (*TTagSearch)(unsafe.Pointer(searchPtr)).Fexpr, itemPtr) != 0 { (*TTagSearch)(unsafe.Pointer(searchPtr)).FlastPtr = lastPtr (*TTagSearch)(unsafe.Pointer(searchPtr)).FcurrentPtr = itemPtr return itemPtr } goto _3 _3: ; lastPtr = itemPtr itemPtr = (*TTk_Item)(unsafe.Pointer(itemPtr)).FnextPtr } (*TTagSearch)(unsafe.Pointer(searchPtr)).FlastPtr = lastPtr (*TTagSearch)(unsafe.Pointer(searchPtr)).FsearchOver = int32(1) return libc.UintptrFromInt32(0) } /* *-------------------------------------------------------------- * * DoItem -- * * This is a utility function called by FindItems. It either adds * itemPtr's id to the list being constructed, or it adds a new tag to * itemPtr, depending on the value of tag. * * Results: * None. * * Side effects: * If tag is NULL then itemPtr's id is added as an element to the * supplied object; otherwise tag is added to itemPtr's list of tags. * *-------------------------------------------------------------- */ func _DoItem(tls *libc.TLS, accumObj uintptr, itemPtr uintptr, tag TTk_Uid) { /* Tag to add to those already present for * item, or NULL. */ var count int32 var newTagPtr, tagPtr uintptr _, _, _ = count, newTagPtr, tagPtr /* * Handle the "add-to-result" case and return, if appropriate. */ if tag == libc.UintptrFromInt32(0) { libtcl9_0.XTcl_ListObjAppendElement(tls, libc.UintptrFromInt32(0), accumObj, libtcl9_0.XTcl_NewWideIntObj(tls, (*TTk_Item)(unsafe.Pointer(itemPtr)).Fid)) return } tagPtr = (*TTk_Item)(unsafe.Pointer(itemPtr)).FtagPtr count = int32((*TTk_Item)(unsafe.Pointer(itemPtr)).FnumTags) for { if !(count > 0) { break } if tag == *(*TTk_Uid)(unsafe.Pointer(tagPtr)) { return } goto _1 _1: ; tagPtr += 8 count-- } /* * Grow the tag space if there's no more room left in the current block. */ if (*TTk_Item)(unsafe.Pointer(itemPtr)).FtagSpace == (*TTk_Item)(unsafe.Pointer(itemPtr)).FnumTags { *(*TTcl_Size)(unsafe.Pointer(itemPtr + 48)) += int64(5) newTagPtr = libtcl9_0.XTcl_Alloc(tls, libc.Uint64FromInt64((*TTk_Item)(unsafe.Pointer(itemPtr)).FtagSpace)*uint64(8)) libc.Xmemcpy(tls, newTagPtr, (*TTk_Item)(unsafe.Pointer(itemPtr)).FtagPtr, libc.Uint64FromInt64((*TTk_Item)(unsafe.Pointer(itemPtr)).FnumTags)*uint64(8)) if (*TTk_Item)(unsafe.Pointer(itemPtr)).FtagPtr != itemPtr+16 { libtcl9_0.XTcl_Free(tls, (*TTk_Item)(unsafe.Pointer(itemPtr)).FtagPtr) } (*TTk_Item)(unsafe.Pointer(itemPtr)).FtagPtr = newTagPtr tagPtr = (*TTk_Item)(unsafe.Pointer(itemPtr)).FtagPtr + uintptr((*TTk_Item)(unsafe.Pointer(itemPtr)).FnumTags)*8 } /* * Add in the new tag. */ *(*TTk_Uid)(unsafe.Pointer(tagPtr)) = tag (*TTk_Item)(unsafe.Pointer(itemPtr)).FnumTags++ } /* *-------------------------------------------------------------- * * FindItems -- * * This function does all the work of implementing the "find" and * "addtag" options of the canvas widget command, which locate items that * have certain features (location, tags, position in display list, etc.) * * Results: * A standard Tcl return value. If newTag is NULL, then a list of ids * from all the items that match objc/objv is returned in the interp's * result. If newTag is NULL, then the normal the interp's result is an * empty string. If an error occurs, then the interp's result will hold * an error message. * * Side effects: * If newTag is non-NULL, then all the items that match the information * in objc/objv have that tag added to their lists of tags. * *-------------------------------------------------------------- */ func _FindItems(tls *libc.TLS, interp uintptr, canvasPtr uintptr, objc TTcl_Size, objv uintptr, newTag uintptr, first TTcl_Size, searchPtrPtr uintptr) (r int32) { bp := tls.Alloc(48) defer tls.Free(48) var _objPtr, closestPtr, itemPtr, lastPtr, resultObj, startPtr, v17 uintptr var closestDist, newDist float64 var result, x1, x2, y1, y2, v12, v13, v14, v9 int32 var uid TTk_Uid var v16 TTcl_Size var _ /* coords at bp+8 */ [2]float64 var _ /* halo at bp+24 */ float64 var _ /* index at bp+0 */ int32 _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = _objPtr, closestDist, closestPtr, itemPtr, lastPtr, newDist, result, resultObj, startPtr, uid, x1, x2, y1, y2, v12, v13, v14, v16, v17, v9 if newTag != libc.UintptrFromInt32(0) { uid = XTk_GetUid(tls, libtcl9_0.XTcl_GetStringFromObj(tls, newTag, libc.UintptrFromInt32(0))) } else { uid = libc.UintptrFromInt32(0) } if libtcl9_0.XTcl_GetIndexFromObjStruct(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(first)*8)), uintptr(unsafe.Pointer(&_optionStrings20)), libc.Int64FromUint64(libc.Uint64FromInt64(8)), __ccgo_ts+28527, libc.Int32FromInt32(0)|libc.Int32FromUint64(libc.Uint64FromInt64(4)< first+int64(5) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, first+int64(1), objv, __ccgo_ts+28542) return int32(TCL_ERROR) } if XTk_CanvasGetCoordFromObj(tls, interp, canvasPtr, *(*uintptr)(unsafe.Pointer(objv + uintptr(first+int64(1))*8)), bp+8) != TCL_OK || XTk_CanvasGetCoordFromObj(tls, interp, canvasPtr, *(*uintptr)(unsafe.Pointer(objv + uintptr(first+int64(2))*8)), bp+8+1*8) != TCL_OK { return int32(TCL_ERROR) } if objc > first+int64(3) { if XTk_CanvasGetCoordFromObj(tls, interp, canvasPtr, *(*uintptr)(unsafe.Pointer(objv + uintptr(first+int64(3))*8)), bp+24) != TCL_OK { return int32(TCL_ERROR) } if *(*float64)(unsafe.Pointer(bp + 24)) < float64(0) { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+28561, libc.VaList(bp+40, *(*float64)(unsafe.Pointer(bp + 24))))) return int32(TCL_ERROR) } } else { *(*float64)(unsafe.Pointer(bp + 24)) = float64(0) } /* * Find the item at which to start the search. */ startPtr = (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FfirstItemPtr if objc == first+int64(5) { v13 = _TagSearchScan(tls, canvasPtr, *(*uintptr)(unsafe.Pointer(objv + uintptr(first+int64(4))*8)), searchPtrPtr) result = v13 if v13 != TCL_OK { return int32(TCL_ERROR) } itemPtr = _TagSearchFirst(tls, *(*uintptr)(unsafe.Pointer(searchPtrPtr))) if itemPtr != libc.UintptrFromInt32(0) { startPtr = itemPtr } } /* * The code below is optimized so that it can eliminate most items * without having to call their item-specific functions. This is done * by keeping a bounding box (x1, y1, x2, y2) that an item's bbox must * overlap if the item is to have any chance of being closer than the * closest so far. */ itemPtr = startPtr for itemPtr != 0 && ((*TTk_Item)(unsafe.Pointer(itemPtr)).Fstate == int32(TK_STATE_HIDDEN) || (*TTk_Item)(unsafe.Pointer(itemPtr)).Fstate == int32(TK_STATE_NULL) && (*TTkCanvas)(unsafe.Pointer(canvasPtr)).Fcanvas_state == int32(TK_STATE_HIDDEN)) { itemPtr = (*TTk_Item)(unsafe.Pointer(itemPtr)).FnextPtr } if itemPtr == libc.UintptrFromInt32(0) { return TCL_OK } closestDist = _ItemPoint(tls, canvasPtr, itemPtr, bp+8, *(*float64)(unsafe.Pointer(bp + 24))) for int32(1) != 0 { /* * Update the bounding box using itemPtr, which is the new closest * item. */ x1 = int32((*(*[2]float64)(unsafe.Pointer(bp + 8)))[0] - closestDist - *(*float64)(unsafe.Pointer(bp + 24)) - libc.Float64FromInt32(1)) y1 = int32((*(*[2]float64)(unsafe.Pointer(bp + 8)))[int32(1)] - closestDist - *(*float64)(unsafe.Pointer(bp + 24)) - libc.Float64FromInt32(1)) x2 = int32((*(*[2]float64)(unsafe.Pointer(bp + 8)))[0] + closestDist + *(*float64)(unsafe.Pointer(bp + 24)) + libc.Float64FromInt32(1)) y2 = int32((*(*[2]float64)(unsafe.Pointer(bp + 8)))[int32(1)] + closestDist + *(*float64)(unsafe.Pointer(bp + 24)) + libc.Float64FromInt32(1)) closestPtr = itemPtr /* * Search for an item that beats the current closest one. Work * circularly through the canvas's item list until getting back to * the starting item. */ for int32(1) != 0 { itemPtr = (*TTk_Item)(unsafe.Pointer(itemPtr)).FnextPtr if itemPtr == libc.UintptrFromInt32(0) { itemPtr = (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FfirstItemPtr } if itemPtr == startPtr { resultObj = libtcl9_0.XTcl_NewObj(tls) _DoItem(tls, resultObj, closestPtr, uid) libtcl9_0.XTcl_SetObjResult(tls, interp, resultObj) return TCL_OK } if (*TTk_Item)(unsafe.Pointer(itemPtr)).Fstate == int32(TK_STATE_HIDDEN) || (*TTk_Item)(unsafe.Pointer(itemPtr)).Fstate == int32(TK_STATE_NULL) && (*TTkCanvas)(unsafe.Pointer(canvasPtr)).Fcanvas_state == int32(TK_STATE_HIDDEN) { continue } if (*TTk_Item)(unsafe.Pointer(itemPtr)).Fx1 >= x2 || (*TTk_Item)(unsafe.Pointer(itemPtr)).Fx2 <= x1 || (*TTk_Item)(unsafe.Pointer(itemPtr)).Fy1 >= y2 || (*TTk_Item)(unsafe.Pointer(itemPtr)).Fy2 <= y1 { continue } newDist = _ItemPoint(tls, canvasPtr, itemPtr, bp+8, *(*float64)(unsafe.Pointer(bp + 24))) if newDist <= closestDist { closestDist = newDist break } } } goto _8 _5: ; if objc != first+int64(5) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, first+int64(1), objv, __ccgo_ts+28597) return int32(TCL_ERROR) } return _FindArea(tls, interp, canvasPtr, objv+uintptr(first)*8+uintptr(1)*8, uid, int32(1)) _6: ; if objc != first+int64(5) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, first+int64(1), objv, __ccgo_ts+28597) return int32(TCL_ERROR) } return _FindArea(tls, interp, canvasPtr, objv+uintptr(first)*8+uintptr(1)*8, uid, 0) _7: ; if objc != first+int64(2) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, first+int64(1), objv, __ccgo_ts+27274) return int32(TCL_ERROR) } resultObj = libtcl9_0.XTcl_NewObj(tls) v14 = _TagSearchScan(tls, canvasPtr, *(*uintptr)(unsafe.Pointer(objv + uintptr(first+int64(1))*8)), searchPtrPtr) result = v14 if v14 != TCL_OK { goto badWithTagSearch } itemPtr = _TagSearchFirst(tls, *(*uintptr)(unsafe.Pointer(searchPtrPtr))) for { if !(itemPtr != libc.UintptrFromInt32(0)) { break } _DoItem(tls, resultObj, itemPtr, uid) goto _15 _15: ; itemPtr = _TagSearchNext(tls, *(*uintptr)(unsafe.Pointer(searchPtrPtr))) } libtcl9_0.XTcl_SetObjResult(tls, interp, resultObj) return TCL_OK goto badWithTagSearch badWithTagSearch: ; _objPtr = resultObj v17 = _objPtr v16 = *(*TTcl_Size)(unsafe.Pointer(v17)) *(*TTcl_Size)(unsafe.Pointer(v17))-- if v16 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr) } return int32(TCL_ERROR) _8: ; return TCL_OK } var _optionStrings20 = [8]uintptr{ 0: __ccgo_ts + 24871, 1: __ccgo_ts + 5202, 2: __ccgo_ts + 24877, 3: __ccgo_ts + 28490, 4: __ccgo_ts + 28498, 5: __ccgo_ts + 28507, 6: __ccgo_ts + 28519, 7: libc.UintptrFromInt32(0), } /* *-------------------------------------------------------------- * * FindArea -- * * This function implements area searches for the "find" and "addtag" * options. * * Results: * A standard Tcl return value. If newTag is NULL, then a list of ids * from all the items overlapping or enclosed by the rectangle given by * objc is returned in the interp's result. If newTag is NULL, then the * normal the interp's result is an empty string. If an error occurs, * then the interp's result will hold an error message. * * Side effects: * If uid is non-NULL, then all the items overlapping or enclosed by the * area in objv have that tag added to their lists of tags. * *-------------------------------------------------------------- */ func _FindArea(tls *libc.TLS, interp uintptr, canvasPtr uintptr, objv uintptr, uid TTk_Uid, enclosed int32) (r int32) { bp := tls.Alloc(32) defer tls.Free(32) /* 0 means overlapping or enclosed items are * OK, 1 means only enclosed items are OK. */ var itemPtr, resultObj uintptr var tmp float64 var x1, x2, y1, y2 int32 var _ /* rect at bp+0 */ [4]float64 _, _, _, _, _, _, _ = itemPtr, resultObj, tmp, x1, x2, y1, y2 if XTk_CanvasGetCoordFromObj(tls, interp, canvasPtr, *(*uintptr)(unsafe.Pointer(objv)), bp) != TCL_OK || XTk_CanvasGetCoordFromObj(tls, interp, canvasPtr, *(*uintptr)(unsafe.Pointer(objv + 1*8)), bp+1*8) != TCL_OK || XTk_CanvasGetCoordFromObj(tls, interp, canvasPtr, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+2*8) != TCL_OK || XTk_CanvasGetCoordFromObj(tls, interp, canvasPtr, *(*uintptr)(unsafe.Pointer(objv + 3*8)), bp+3*8) != TCL_OK { return int32(TCL_ERROR) } if (*(*[4]float64)(unsafe.Pointer(bp)))[0] > (*(*[4]float64)(unsafe.Pointer(bp)))[int32(2)] { tmp = (*(*[4]float64)(unsafe.Pointer(bp)))[0] (*(*[4]float64)(unsafe.Pointer(bp)))[0] = (*(*[4]float64)(unsafe.Pointer(bp)))[int32(2)] (*(*[4]float64)(unsafe.Pointer(bp)))[int32(2)] = tmp } if (*(*[4]float64)(unsafe.Pointer(bp)))[int32(1)] > (*(*[4]float64)(unsafe.Pointer(bp)))[int32(3)] { tmp = (*(*[4]float64)(unsafe.Pointer(bp)))[int32(1)] (*(*[4]float64)(unsafe.Pointer(bp)))[int32(1)] = (*(*[4]float64)(unsafe.Pointer(bp)))[int32(3)] (*(*[4]float64)(unsafe.Pointer(bp)))[int32(3)] = tmp } /* * Use an integer bounding box for a quick test, to avoid calling * item-specific code except for items that are close. */ x1 = int32((*(*[4]float64)(unsafe.Pointer(bp)))[0] - libc.Float64FromFloat64(1)) y1 = int32((*(*[4]float64)(unsafe.Pointer(bp)))[int32(1)] - libc.Float64FromFloat64(1)) x2 = int32((*(*[4]float64)(unsafe.Pointer(bp)))[int32(2)] + libc.Float64FromFloat64(1)) y2 = int32((*(*[4]float64)(unsafe.Pointer(bp)))[int32(3)] + libc.Float64FromFloat64(1)) resultObj = libtcl9_0.XTcl_NewObj(tls) itemPtr = (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FfirstItemPtr for { if !(itemPtr != libc.UintptrFromInt32(0)) { break } if (*TTk_Item)(unsafe.Pointer(itemPtr)).Fstate == int32(TK_STATE_HIDDEN) || (*TTk_Item)(unsafe.Pointer(itemPtr)).Fstate == int32(TK_STATE_NULL) && (*TTkCanvas)(unsafe.Pointer(canvasPtr)).Fcanvas_state == int32(TK_STATE_HIDDEN) { goto _1 } if (*TTk_Item)(unsafe.Pointer(itemPtr)).Fx1 >= x2 || (*TTk_Item)(unsafe.Pointer(itemPtr)).Fx2 <= x1 || (*TTk_Item)(unsafe.Pointer(itemPtr)).Fy1 >= y2 || (*TTk_Item)(unsafe.Pointer(itemPtr)).Fy2 <= y1 { goto _1 } if _ItemOverlap(tls, canvasPtr, itemPtr, bp) >= enclosed { _DoItem(tls, resultObj, itemPtr, uid) } goto _1 _1: ; itemPtr = (*TTk_Item)(unsafe.Pointer(itemPtr)).FnextPtr } libtcl9_0.XTcl_SetObjResult(tls, interp, resultObj) return TCL_OK } /* *-------------------------------------------------------------- * * RelinkItems -- * * Move one or more items to a different place in the display order for a * canvas. * * Results: * None. * * Side effects: * The items identified by "tag" are moved so that they are all together * in the display list and immediately after prevPtr. The order of the * moved items relative to each other is not changed. * *-------------------------------------------------------------- */ func _RelinkItems(tls *libc.TLS, canvasPtr uintptr, tag uintptr, prevPtr uintptr, searchPtrPtr uintptr) (r int32) { /* From CanvasWidgetCmd local vars */ var firstMovePtr, itemPtr, lastMovePtr, v1 uintptr var result, v2 int32 _, _, _, _, _, _ = firstMovePtr, itemPtr, lastMovePtr, result, v1, v2 /* * Find all of the items to be moved and remove them from the list, making * an auxiliary list running from firstMovePtr to lastMovePtr. Record * their areas for redisplay. */ v1 = libc.UintptrFromInt32(0) lastMovePtr = v1 firstMovePtr = v1 v2 = _TagSearchScan(tls, canvasPtr, tag, searchPtrPtr) result = v2 if v2 != TCL_OK { return int32(TCL_ERROR) } itemPtr = _TagSearchFirst(tls, *(*uintptr)(unsafe.Pointer(searchPtrPtr))) for { if !(itemPtr != libc.UintptrFromInt32(0)) { break } if itemPtr == prevPtr { /* * Item after which insertion is to occur is being moved! Switch * to insert after its predecessor. */ prevPtr = (*TTk_Item)(unsafe.Pointer(prevPtr)).FprevPtr } if (*TTk_Item)(unsafe.Pointer(itemPtr)).FprevPtr == libc.UintptrFromInt32(0) { if (*TTk_Item)(unsafe.Pointer(itemPtr)).FnextPtr != libc.UintptrFromInt32(0) { (*TTk_Item1)(unsafe.Pointer((*TTk_Item)(unsafe.Pointer(itemPtr)).FnextPtr)).FprevPtr = libc.UintptrFromInt32(0) } (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FfirstItemPtr = (*TTk_Item)(unsafe.Pointer(itemPtr)).FnextPtr } else { if (*TTk_Item)(unsafe.Pointer(itemPtr)).FnextPtr != libc.UintptrFromInt32(0) { (*TTk_Item1)(unsafe.Pointer((*TTk_Item)(unsafe.Pointer(itemPtr)).FnextPtr)).FprevPtr = (*TTk_Item)(unsafe.Pointer(itemPtr)).FprevPtr } (*TTk_Item1)(unsafe.Pointer((*TTk_Item)(unsafe.Pointer(itemPtr)).FprevPtr)).FnextPtr = (*TTk_Item)(unsafe.Pointer(itemPtr)).FnextPtr } if (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FlastItemPtr == itemPtr { (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FlastItemPtr = (*TTk_Item)(unsafe.Pointer(itemPtr)).FprevPtr } if firstMovePtr == libc.UintptrFromInt32(0) { (*TTk_Item)(unsafe.Pointer(itemPtr)).FprevPtr = libc.UintptrFromInt32(0) firstMovePtr = itemPtr } else { (*TTk_Item)(unsafe.Pointer(itemPtr)).FprevPtr = lastMovePtr (*TTk_Item)(unsafe.Pointer(lastMovePtr)).FnextPtr = itemPtr } lastMovePtr = itemPtr _EventuallyRedrawItem(tls, canvasPtr, itemPtr) *(*int32)(unsafe.Pointer(canvasPtr + 648)) |= int32(REPICK_NEEDED) goto _3 _3: ; itemPtr = _TagSearchNext(tls, *(*uintptr)(unsafe.Pointer(searchPtrPtr))) } /* * Insert the list of to-be-moved items back into the canvas's at the * desired position. */ if firstMovePtr == libc.UintptrFromInt32(0) { return TCL_OK } if prevPtr == libc.UintptrFromInt32(0) { if (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FfirstItemPtr != libc.UintptrFromInt32(0) { (*TTk_Item)(unsafe.Pointer((*TTkCanvas)(unsafe.Pointer(canvasPtr)).FfirstItemPtr)).FprevPtr = lastMovePtr } (*TTk_Item)(unsafe.Pointer(lastMovePtr)).FnextPtr = (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FfirstItemPtr (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FfirstItemPtr = firstMovePtr } else { if (*TTk_Item)(unsafe.Pointer(prevPtr)).FnextPtr != libc.UintptrFromInt32(0) { (*TTk_Item1)(unsafe.Pointer((*TTk_Item)(unsafe.Pointer(prevPtr)).FnextPtr)).FprevPtr = lastMovePtr } (*TTk_Item)(unsafe.Pointer(lastMovePtr)).FnextPtr = (*TTk_Item)(unsafe.Pointer(prevPtr)).FnextPtr if firstMovePtr != libc.UintptrFromInt32(0) { (*TTk_Item)(unsafe.Pointer(firstMovePtr)).FprevPtr = prevPtr } (*TTk_Item)(unsafe.Pointer(prevPtr)).FnextPtr = firstMovePtr } if (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FlastItemPtr == prevPtr { (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FlastItemPtr = lastMovePtr } return TCL_OK } /* *-------------------------------------------------------------- * * CanvasBindProc -- * * This function is invoked by the Tk dispatcher to handle events * associated with bindings on items. * * Results: * None. * * Side effects: * Depends on the command invoked as part of the binding (if there was * any). * *-------------------------------------------------------------- */ func _CanvasBindProc(tls *libc.TLS, clientData uintptr, eventPtr uintptr) { /* Pointer to X event that just happened. */ var canvasPtr uintptr var mask uint32 _, _ = canvasPtr, mask canvasPtr = clientData libtcl9_0.XTcl_Preserve(tls, canvasPtr) /* * This code below keeps track of the current modifier state in * canvasPtr>state. This information is used to defer repicks of the * current item while buttons are down. */ switch (*TXEvent)(unsafe.Pointer(eventPtr)).Ftype1 { case int32(ButtonPress): fallthrough case int32(ButtonRelease): mask = XTk_GetButtonMask(tls, (*(*TXButtonEvent)(unsafe.Pointer(eventPtr))).Fbutton) /* * For button press events, repick the current item using the button * state before the event, then process the event. For button release * events, first process the event, then repick the current item using * the button state *after* the event (the button has logically gone * up before we change the current item). */ if (*TXEvent)(unsafe.Pointer(eventPtr)).Ftype1 == int32(ButtonPress) { /* * On a button press, first repick the current item using the * button state before the event, the process the event. */ (*TTkCanvas)(unsafe.Pointer(canvasPtr)).Fstate = (*(*TXButtonEvent)(unsafe.Pointer(eventPtr))).Fstate _PickCurrentItem(tls, canvasPtr, eventPtr) *(*uint32)(unsafe.Pointer(canvasPtr + 528)) ^= mask _CanvasDoEvent(tls, canvasPtr, eventPtr) } else { /* * Button release: first process the event, with the button still * considered to be down. Then repick the current item under the * assumption that the button is no longer down. */ (*TTkCanvas)(unsafe.Pointer(canvasPtr)).Fstate = (*(*TXButtonEvent)(unsafe.Pointer(eventPtr))).Fstate _CanvasDoEvent(tls, canvasPtr, eventPtr) (*(*TXButtonEvent)(unsafe.Pointer(eventPtr))).Fstate ^= mask (*TTkCanvas)(unsafe.Pointer(canvasPtr)).Fstate = (*(*TXButtonEvent)(unsafe.Pointer(eventPtr))).Fstate _PickCurrentItem(tls, canvasPtr, eventPtr) (*(*TXButtonEvent)(unsafe.Pointer(eventPtr))).Fstate ^= mask } case int32(EnterNotify): fallthrough case int32(LeaveNotify): (*TTkCanvas)(unsafe.Pointer(canvasPtr)).Fstate = (*(*TXCrossingEvent)(unsafe.Pointer(eventPtr))).Fstate _PickCurrentItem(tls, canvasPtr, eventPtr) case int32(MotionNotify): (*TTkCanvas)(unsafe.Pointer(canvasPtr)).Fstate = (*(*TXMotionEvent)(unsafe.Pointer(eventPtr))).Fstate _PickCurrentItem(tls, canvasPtr, eventPtr) /* fallthrough */ fallthrough default: _CanvasDoEvent(tls, canvasPtr, eventPtr) } libtcl9_0.XTcl_Release(tls, canvasPtr) } /* *-------------------------------------------------------------- * * PickCurrentItem -- * * Find the topmost item in a canvas that contains a given location and * mark the the current item. If the current item has changed, generate a * fake exit event on the old current item, a fake enter event on the new * current item item and force a redraw of the two items. Canvas items * that are hidden or disabled are ignored. * * Results: * None. * * Side effects: * The current item for canvasPtr may change. If it does, then the * commands associated with item entry and exit could do just about * anything. A binding script could delete the canvas, so callers should * protect themselves with Tcl_Preserve and Tcl_Release. * *-------------------------------------------------------------- */ func _PickCurrentItem(tls *libc.TLS, canvasPtr uintptr, eventPtr uintptr) { bp := tls.Alloc(400) defer tls.Free(400) /* Event describing location of mouse cursor. * Must be EnterWindow, LeaveWindow, * ButtonRelease, or MotionNotify. */ var buttonDown uint32 var i TTcl_Size var itemPtr, prevItemPtr, searchUids uintptr var _ /* coords at bp+0 */ [2]float64 var _ /* event at bp+16 */ TXEvent var _ /* event at bp+208 */ TXEvent _, _, _, _, _ = buttonDown, i, itemPtr, prevItemPtr, searchUids searchUids = _GetStaticUids(tls) /* * Check whether or not a button is down. If so, we'll log entry and exit * into and out of the current item, but not entry into any other item. * This implements a form of grabbing equivalent to what the X server does * for windows. */ buttonDown = (*TTkCanvas)(unsafe.Pointer(canvasPtr)).Fstate & libc.Uint32FromInt32(libc.Int32FromInt32(1)< that deletes the current item. */ if itemPtr == (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FcurrentItemPtr && !(buttonDown != 0) { i = (*TTk_Item)(unsafe.Pointer(itemPtr)).FnumTags - int64(1) for { if !(i != int64(-libc.Int32FromInt32(1))) { break } if *(*TTk_Uid)(unsafe.Pointer((*TTk_Item)(unsafe.Pointer(itemPtr)).FtagPtr + uintptr(i)*8)) == (*TSearchUids)(unsafe.Pointer(searchUids)).FcurrentUid { /* then */ libc.Xmemmove(tls, (*TTk_Item)(unsafe.Pointer(itemPtr)).FtagPtr+uintptr(i)*8, (*TTk_Item)(unsafe.Pointer(itemPtr)).FtagPtr+uintptr(i)*8+uintptr(1)*8, libc.Uint64FromInt64((*TTk_Item)(unsafe.Pointer(itemPtr)).FnumTags-(i+libc.Int64FromInt32(1)))*uint64(8)) (*TTk_Item)(unsafe.Pointer(itemPtr)).FnumTags-- break } goto _1 _1: ; i-- } } /* * Note: during CanvasDoEvent above, it's possible that * canvasPtr->newCurrentPtr got reset to NULL because the item was * deleted. */ } if (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FnewCurrentPtr != (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FcurrentItemPtr && buttonDown != 0 { *(*int32)(unsafe.Pointer(canvasPtr + 648)) |= int32(LEFT_GRABBED_ITEM) return } /* * Special note: it's possible that canvasPtr->newCurrentPtr == * canvasPtr->currentItemPtr here. This can happen, for example, if * LEFT_GRABBED_ITEM was set. */ prevItemPtr = (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FcurrentItemPtr *(*int32)(unsafe.Pointer(canvasPtr + 648)) &= ^libc.Int32FromInt32(LEFT_GRABBED_ITEM) (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FcurrentItemPtr = (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FnewCurrentPtr if prevItemPtr != libc.UintptrFromInt32(0) && prevItemPtr != (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FcurrentItemPtr && (*TTk_Item)(unsafe.Pointer(prevItemPtr)).Fredraw_flags&int32(TK_ITEM_STATE_DEPENDANT) != 0 { _EventuallyRedrawItem(tls, canvasPtr, prevItemPtr) _ItemConfigure(tls, canvasPtr, prevItemPtr, 0, libc.UintptrFromInt32(0)) } if (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FcurrentItemPtr != libc.UintptrFromInt32(0) { _DoItem(tls, libc.UintptrFromInt32(0), (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FcurrentItemPtr, (*TSearchUids)(unsafe.Pointer(searchUids)).FcurrentUid) if (*TTk_Item)(unsafe.Pointer((*TTkCanvas)(unsafe.Pointer(canvasPtr)).FcurrentItemPtr)).Fredraw_flags&int32(TK_ITEM_STATE_DEPENDANT) != 0 && prevItemPtr != (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FcurrentItemPtr { _ItemConfigure(tls, canvasPtr, (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FcurrentItemPtr, 0, libc.UintptrFromInt32(0)) _EventuallyRedrawItem(tls, canvasPtr, (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FcurrentItemPtr) } *(*TXEvent)(unsafe.Pointer(bp + 208)) = (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FpickEvent (*(*TXEvent)(unsafe.Pointer(bp + 208))).Ftype1 = int32(EnterNotify) (*(*TXCrossingEvent)(unsafe.Pointer(&*(*TXEvent)(unsafe.Pointer(bp + 208))))).Fdetail = NotifyAncestor _CanvasDoEvent(tls, canvasPtr, bp+208) } } /* *---------------------------------------------------------------------- * * CanvasFindClosest -- * * Given x and y coordinates, find the topmost canvas item that is * "close" to the coordinates. Canvas items that are hidden or disabled * are ignored. * * Results: * The return value is a pointer to the topmost item that is close to * (x,y), or NULL if no item is close. * * Side effects: * None. * *---------------------------------------------------------------------- */ func _CanvasFindClosest(tls *libc.TLS, canvasPtr uintptr, coords uintptr) (r uintptr) { /* Desired x,y position in canvas, not screen, * coordinates.) */ var bestPtr, itemPtr uintptr var x1, x2, y1, y2 int32 _, _, _, _, _, _ = bestPtr, itemPtr, x1, x2, y1, y2 x1 = int32(*(*float64)(unsafe.Pointer(coords)) - (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FcloseEnough) y1 = int32(*(*float64)(unsafe.Pointer(coords + 1*8)) - (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FcloseEnough) x2 = int32(*(*float64)(unsafe.Pointer(coords)) + (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FcloseEnough) y2 = int32(*(*float64)(unsafe.Pointer(coords + 1*8)) + (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FcloseEnough) bestPtr = libc.UintptrFromInt32(0) itemPtr = (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FfirstItemPtr for { if !(itemPtr != libc.UintptrFromInt32(0)) { break } if (*TTk_Item)(unsafe.Pointer(itemPtr)).Fstate == int32(TK_STATE_HIDDEN) || (*TTk_Item)(unsafe.Pointer(itemPtr)).Fstate == int32(TK_STATE_DISABLED) || (*TTk_Item)(unsafe.Pointer(itemPtr)).Fstate == int32(TK_STATE_NULL) && ((*TTkCanvas)(unsafe.Pointer(canvasPtr)).Fcanvas_state == int32(TK_STATE_HIDDEN) || (*TTkCanvas)(unsafe.Pointer(canvasPtr)).Fcanvas_state == int32(TK_STATE_DISABLED)) { goto _1 } if (*TTk_Item)(unsafe.Pointer(itemPtr)).Fx1 > x2 || (*TTk_Item)(unsafe.Pointer(itemPtr)).Fx2 < x1 || (*TTk_Item)(unsafe.Pointer(itemPtr)).Fy1 > y2 || (*TTk_Item)(unsafe.Pointer(itemPtr)).Fy2 < y1 { goto _1 } if _ItemPoint(tls, canvasPtr, itemPtr, coords, libc.Float64FromInt32(0)) <= (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FcloseEnough { bestPtr = itemPtr } goto _1 _1: ; itemPtr = (*TTk_Item)(unsafe.Pointer(itemPtr)).FnextPtr } return bestPtr } /* *-------------------------------------------------------------- * * CanvasDoEvent -- * * This function is called to invoke binding processing for a new event * that is associated with the current item for a canvas. * * Results: * None. * * Side effects: * Depends on the bindings for the canvas. A binding script could delete * the canvas, so callers should protect themselves with Tcl_Preserve and * Tcl_Release. * *-------------------------------------------------------------- */ func _CanvasDoEvent(tls *libc.TLS, canvasPtr uintptr, eventPtr uintptr) { bp := tls.Alloc(32) defer tls.Free(32) /* Real or simulated X event that is to be * processed. */ var expr, itemPtr, objectPtr, searchUids uintptr var i, numExprs, numObjects, v2 TTcl_Size var _ /* staticObjects at bp+0 */ [3]uintptr _, _, _, _, _, _, _, _ = expr, i, itemPtr, numExprs, numObjects, objectPtr, searchUids, v2 searchUids = _GetStaticUids(tls) if (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FbindingTable == libc.UintptrFromInt32(0) { return } itemPtr = (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FcurrentItemPtr if (*TXEvent)(unsafe.Pointer(eventPtr)).Ftype1 == int32(KeyPress) || (*TXEvent)(unsafe.Pointer(eventPtr)).Ftype1 == int32(KeyRelease) { itemPtr = (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FtextInfo.FfocusItemPtr } if itemPtr == libc.UintptrFromInt32(0) { return } /* * Set up an array with all the relevant objects for processing this * event. The relevant objects are: * (a) the event's item, * (b) the tags associated with the event's item, * (c) the expressions that are true for the event's item's tags, and * (d) the tag "all". * * If there are a lot of tags then malloc an array to hold all of the * objects. */ /* * Flag and count all expressions that match item's tags. */ numExprs = 0 expr = (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FbindTagExprs for expr != 0 { (*TTagSearchExpr)(unsafe.Pointer(expr)).Findex = 0 (*TTagSearchExpr)(unsafe.Pointer(expr)).Fmatch = _TagSearchEvalExpr(tls, expr, itemPtr) if (*TTagSearchExpr)(unsafe.Pointer(expr)).Fmatch != 0 { numExprs++ } expr = (*TTagSearchExpr)(unsafe.Pointer(expr)).Fnext } numObjects = (*TTk_Item)(unsafe.Pointer(itemPtr)).FnumTags + numExprs + int64(2) if numObjects <= int64(NUM_STATIC) { objectPtr = bp } else { objectPtr = libtcl9_0.XTcl_Alloc(tls, libc.Uint64FromInt64(numObjects)*uint64(8)) } *(*uintptr)(unsafe.Pointer(objectPtr)) = (*TSearchUids)(unsafe.Pointer(searchUids)).FallUid i = (*TTk_Item)(unsafe.Pointer(itemPtr)).FnumTags - int64(1) for { if !(i != int64(-libc.Int32FromInt32(1))) { break } *(*uintptr)(unsafe.Pointer(objectPtr + uintptr(i+int64(1))*8)) = *(*TTk_Uid)(unsafe.Pointer((*TTk_Item)(unsafe.Pointer(itemPtr)).FtagPtr + uintptr(i)*8)) goto _1 _1: ; i-- } *(*uintptr)(unsafe.Pointer(objectPtr + uintptr((*TTk_Item)(unsafe.Pointer(itemPtr)).FnumTags+int64(1))*8)) = itemPtr /* * Copy uids of matching expressions into object array */ i = (*TTk_Item)(unsafe.Pointer(itemPtr)).FnumTags + int64(2) expr = (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FbindTagExprs for expr != 0 { if (*TTagSearchExpr)(unsafe.Pointer(expr)).Fmatch != 0 { v2 = i i++ *(*uintptr)(unsafe.Pointer(objectPtr + uintptr(v2)*8)) = (*TTagSearchExpr)(unsafe.Pointer(expr)).Fuid } expr = (*TTagSearchExpr)(unsafe.Pointer(expr)).Fnext } /* * Invoke the binding system, then free up the object array if it was * malloc-ed. */ if (*TTkCanvas)(unsafe.Pointer(canvasPtr)).Ftkwin != libc.UintptrFromInt32(0) { XTk_BindEvent(tls, (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FbindingTable, eventPtr, (*TTkCanvas)(unsafe.Pointer(canvasPtr)).Ftkwin, numObjects, objectPtr) } if objectPtr != bp { libtcl9_0.XTcl_Free(tls, objectPtr) } } /* *---------------------------------------------------------------------- * * CanvasBlinkProc -- * * This function is called as a timer handler to blink the insertion * cursor off and on. * * Results: * None. * * Side effects: * The cursor gets turned on or off, redisplay gets invoked, and this * function reschedules itself. * *---------------------------------------------------------------------- */ func _CanvasBlinkProc(tls *libc.TLS, clientData uintptr) { /* Pointer to record describing entry. */ var canvasPtr uintptr _ = canvasPtr canvasPtr = clientData if !((*TTkCanvas)(unsafe.Pointer(canvasPtr)).FtextInfo.FgotFocus != 0) || (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FinsertOffTime == 0 { return } if (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FtextInfo.FcursorOn != 0 { (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FtextInfo.FcursorOn = 0 (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FinsertBlinkHandler = libtcl9_0.XTcl_CreateTimerHandler(tls, (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FinsertOffTime, __ccgo_fp(_CanvasBlinkProc), canvasPtr) } else { (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FtextInfo.FcursorOn = int32(1) (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FinsertBlinkHandler = libtcl9_0.XTcl_CreateTimerHandler(tls, (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FinsertOnTime, __ccgo_fp(_CanvasBlinkProc), canvasPtr) } _EventuallyRedrawItem(tls, canvasPtr, (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FtextInfo.FfocusItemPtr) } /* *---------------------------------------------------------------------- * * CanvasFocusProc -- * * This function is called whenever a canvas gets or loses the input * focus. It's also called whenever the window is reconfigured while it * has the focus. * * Results: * None. * * Side effects: * The cursor gets turned on or off. * *---------------------------------------------------------------------- */ func _CanvasFocusProc(tls *libc.TLS, canvasPtr uintptr, gotFocus int32) { bp := tls.Alloc(16) defer tls.Free(16) /* 1 means window is getting focus, 0 means * it's losing it. */ var _ /* highlightWidth at bp+0 */ int32 libtcl9_0.XTcl_DeleteTimerHandler(tls, (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FinsertBlinkHandler) if gotFocus != 0 { (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FtextInfo.FgotFocus = int32(1) (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FtextInfo.FcursorOn = int32(1) if (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FinsertOffTime != 0 { (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FinsertBlinkHandler = libtcl9_0.XTcl_CreateTimerHandler(tls, (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FinsertOffTime, __ccgo_fp(_CanvasBlinkProc), canvasPtr) } } else { (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FtextInfo.FgotFocus = 0 (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FtextInfo.FcursorOn = 0 (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FinsertBlinkHandler = libc.UintptrFromInt32(0) } _EventuallyRedrawItem(tls, canvasPtr, (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FtextInfo.FfocusItemPtr) XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), (*TTkCanvas)(unsafe.Pointer(canvasPtr)).Ftkwin, (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FhighlightWidthObj, bp) if *(*int32)(unsafe.Pointer(bp)) > 0 { *(*int32)(unsafe.Pointer(canvasPtr + 648)) |= int32(REDRAW_BORDERS) if !((*TTkCanvas)(unsafe.Pointer(canvasPtr)).Fflags&libc.Int32FromInt32(REDRAW_PENDING2) != 0) { libtcl9_0.XTcl_DoWhenIdle(tls, __ccgo_fp(_DisplayCanvas), canvasPtr) *(*int32)(unsafe.Pointer(canvasPtr + 648)) |= int32(REDRAW_PENDING2) } } } /* *---------------------------------------------------------------------- * * CanvasSelectTo -- * * Modify the selection by moving its un-anchored end. This could make * the selection either larger or smaller. * * Results: * None. * * Side effects: * The selection changes. * *---------------------------------------------------------------------- */ func _CanvasSelectTo(tls *libc.TLS, canvasPtr uintptr, itemPtr uintptr, index TTcl_Size) { /* Index of element that is to become the * "other" end of the selection. */ var oldFirst, oldLast TTcl_Size var oldSelPtr uintptr var v1 int64 _, _, _, _ = oldFirst, oldLast, oldSelPtr, v1 oldFirst = (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FtextInfo.FselectFirst oldLast = (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FtextInfo.FselectLast oldSelPtr = (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FtextInfo.FselItemPtr /* * Grab the selection if we don't own it already. */ if (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FtextInfo.FselItemPtr == libc.UintptrFromInt32(0) { XTk_OwnSelection(tls, (*TTkCanvas)(unsafe.Pointer(canvasPtr)).Ftkwin, libc.Uint64FromInt32(1), __ccgo_fp(_CanvasLostSelection), canvasPtr) } else { if (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FtextInfo.FselItemPtr != itemPtr { _EventuallyRedrawItem(tls, canvasPtr, (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FtextInfo.FselItemPtr) } } (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FtextInfo.FselItemPtr = itemPtr if (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FtextInfo.FanchorItemPtr != itemPtr { (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FtextInfo.FanchorItemPtr = itemPtr (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FtextInfo.FselectAnchor = index } if (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FtextInfo.FselectAnchor <= index { (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FtextInfo.FselectFirst = (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FtextInfo.FselectAnchor (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FtextInfo.FselectLast = index } else { if int32(index) < 0 { v1 = int64(-libc.Int32FromInt32(1)) } else { v1 = index } (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FtextInfo.FselectFirst = v1 (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FtextInfo.FselectLast = (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FtextInfo.FselectAnchor - int64(1) } if (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FtextInfo.FselectFirst != oldFirst || (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FtextInfo.FselectLast != oldLast || itemPtr != oldSelPtr { _EventuallyRedrawItem(tls, canvasPtr, itemPtr) } } /* *-------------------------------------------------------------- * * CanvasFetchSelection -- * * This function is invoked by Tk to return part or all of the selection, * when the selection is in a canvas widget. This function always returns * the selection as a STRING. * * Results: * The return value is the number of non-NULL bytes stored at buffer. * Buffer is filled (or partially filled) with a NULL-terminated string * containing part or all of the selection, as given by offset and * maxBytes. * * Side effects: * None. * *-------------------------------------------------------------- */ func _CanvasFetchSelection(tls *libc.TLS, clientData uintptr, offset TTcl_Size, buffer uintptr, maxBytes TTcl_Size) (r TTcl_Size) { /* Maximum number of bytes to place at buffer, * not including terminating NULL * character. */ var canvasPtr uintptr _ = canvasPtr canvasPtr = clientData return _ItemSelection(tls, canvasPtr, (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FtextInfo.FselItemPtr, int32(offset), buffer, maxBytes) } /* *---------------------------------------------------------------------- * * CanvasLostSelection -- * * This function is called back by Tk when the selection is grabbed away * from a canvas widget. * * Results: * None. * * Side effects: * The existing selection is unhighlighted, and the window is marked as * not containing a selection. * *---------------------------------------------------------------------- */ func _CanvasLostSelection(tls *libc.TLS, clientData uintptr) { /* Information about entry widget. */ var canvasPtr uintptr _ = canvasPtr canvasPtr = clientData _EventuallyRedrawItem(tls, canvasPtr, (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FtextInfo.FselItemPtr) (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FtextInfo.FselItemPtr = libc.UintptrFromInt32(0) } /* *-------------------------------------------------------------- * * GridAlign -- * * Given a coordinate and a grid spacing, this function computes the * location of the nearest grid line to the coordinate. * * Results: * The return value is the location of the grid line nearest to coord. * * Side effects: * None. * *-------------------------------------------------------------- */ func _GridAlign(tls *libc.TLS, coord float64, spacing float64) (r float64) { /* Spacing between grid lines. If <= 0 then no * alignment is done. */ if spacing <= float64(0) { return coord } if coord < libc.Float64FromInt32(0) { return float64(float64(-int32(-coord/spacing+libc.Float64FromFloat64(0.5))) * spacing) } return float64(float64(int32(coord/spacing+libc.Float64FromFloat64(0.5))) * spacing) } /* *---------------------------------------------------------------------- * * ScrollFractions -- * * Given the range that's visible in the window and the "100% range" for * what's in the canvas, return a list of two doubles representing the * scroll fractions. This function is used for both x and y scrolling. * * Results: * A List Tcl_Obj with two real numbers (Double Tcl_Objs) containing the * scroll fractions (between 0 and 1) corresponding to the other * arguments. * * Side effects: * None. * *---------------------------------------------------------------------- */ func _ScrollFractions(tls *libc.TLS, screen1 int32, screen2 int32, object1 int32, object2 int32) (r uintptr) { bp := tls.Alloc(16) defer tls.Free(16) /* Highest coordinate in the object. */ var f1, f2, range1 float64 var _ /* buffer at bp+0 */ [2]uintptr _, _, _ = f1, f2, range1 range1 = float64(object2 - object1) if range1 <= libc.Float64FromInt32(0) { f1 = libc.Float64FromInt32(0) f2 = float64(1) } else { f1 = float64(screen1-object1) / range1 if f1 < libc.Float64FromInt32(0) { f1 = float64(0) } f2 = float64(screen2-object1) / range1 if f2 > float64(1) { f2 = float64(1) } if f2 < f1 { f2 = f1 } } (*(*[2]uintptr)(unsafe.Pointer(bp)))[0] = libtcl9_0.XTcl_NewDoubleObj(tls, f1) (*(*[2]uintptr)(unsafe.Pointer(bp)))[int32(1)] = libtcl9_0.XTcl_NewDoubleObj(tls, f2) return libtcl9_0.XTcl_NewListObj(tls, int64(2), bp) } /* *-------------------------------------------------------------- * * CanvasUpdateScrollbars -- * * This function is invoked whenever a canvas has changed in a way that * requires scrollbars to be redisplayed (e.g. the view in the canvas has * changed). * * Results: * None. * * Side effects: * If there are scrollbars associated with the canvas, then their * scrolling commands are invoked to cause them to redisplay. If errors * occur, additional Tcl commands may be invoked to process the errors. * *-------------------------------------------------------------- */ func _CanvasUpdateScrollbars(tls *libc.TLS, canvasPtr uintptr) { bp := tls.Alloc(224) defer tls.Free(224) /* Information about canvas. */ var _objPtr, _objPtr1, _objPtr2, _objPtr3, fractions, fractions1, interp, xScrollCmdObj, yScrollCmdObj, v2, v4, v6, v8 uintptr var height, inset, result, scrollX1, scrollX2, scrollY1, scrollY2, width, xOrigin, yOrigin int32 var v1, v3, v5, v7 TTcl_Size var _ /* buf at bp+0 */ TTcl_DString _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = _objPtr, _objPtr1, _objPtr2, _objPtr3, fractions, fractions1, height, inset, interp, result, scrollX1, scrollX2, scrollY1, scrollY2, width, xOrigin, xScrollCmdObj, yOrigin, yScrollCmdObj, v1, v2, v3, v4, v5, v6, v7, v8 /* * Preserve the relevant values from the canvasPtr, because it might be * deleted as part of either of the two calls to Tcl_EvalEx below. */ interp = (*TTkCanvas)(unsafe.Pointer(canvasPtr)).Finterp libtcl9_0.XTcl_Preserve(tls, interp) xScrollCmdObj = (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FxScrollCmdObj if xScrollCmdObj != libc.UintptrFromInt32(0) { (*TTcl_Obj)(unsafe.Pointer(xScrollCmdObj)).FrefCount++ } yScrollCmdObj = (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FyScrollCmdObj if yScrollCmdObj != libc.UintptrFromInt32(0) { (*TTcl_Obj)(unsafe.Pointer(yScrollCmdObj)).FrefCount++ } xOrigin = (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FxOrigin yOrigin = (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FyOrigin inset = (*TTkCanvas)(unsafe.Pointer(canvasPtr)).Finset width = (*TTk_FakeWin)(unsafe.Pointer((*TTkCanvas)(unsafe.Pointer(canvasPtr)).Ftkwin)).Fchanges.Fwidth height = (*TTk_FakeWin)(unsafe.Pointer((*TTkCanvas)(unsafe.Pointer(canvasPtr)).Ftkwin)).Fchanges.Fheight scrollX1 = (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FscrollX1 scrollX2 = (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FscrollX2 scrollY1 = (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FscrollY1 scrollY2 = (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FscrollY2 *(*int32)(unsafe.Pointer(canvasPtr + 648)) &= ^libc.Int32FromInt32(UPDATE_SCROLLBARS) if (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FxScrollCmdObj != libc.UintptrFromInt32(0) { fractions = _ScrollFractions(tls, xOrigin+inset, xOrigin+width-inset, scrollX1, scrollX2) libtcl9_0.XTcl_DStringInit(tls, bp) libtcl9_0.XTcl_DStringAppend(tls, bp, libtcl9_0.XTcl_GetStringFromObj(tls, xScrollCmdObj, libc.UintptrFromInt32(0)), int64(-libc.Int32FromInt32(1))) libtcl9_0.XTcl_DStringAppend(tls, bp, __ccgo_ts+634, int64(-libc.Int32FromInt32(1))) libtcl9_0.XTcl_DStringAppend(tls, bp, libtcl9_0.XTcl_GetStringFromObj(tls, fractions, libc.UintptrFromInt32(0)), int64(-libc.Int32FromInt32(1))) result = libtcl9_0.XTcl_EvalEx(tls, interp, (*TTcl_DString)(unsafe.Pointer(bp)).Fstring1, int64(-libc.Int32FromInt32(1)), int32(TCL_EVAL_GLOBAL)) libtcl9_0.XTcl_DStringFree(tls, bp) _objPtr = fractions v2 = _objPtr v1 = *(*TTcl_Size)(unsafe.Pointer(v2)) *(*TTcl_Size)(unsafe.Pointer(v2))-- if v1 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr) } if result != TCL_OK { libtcl9_0.XTcl_BackgroundException(tls, interp, result) } libtcl9_0.XTcl_ResetResult(tls, interp) _objPtr1 = xScrollCmdObj v4 = _objPtr1 v3 = *(*TTcl_Size)(unsafe.Pointer(v4)) *(*TTcl_Size)(unsafe.Pointer(v4))-- if v3 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr1) } } if yScrollCmdObj != libc.UintptrFromInt32(0) { fractions1 = _ScrollFractions(tls, yOrigin+inset, yOrigin+height-inset, scrollY1, scrollY2) libtcl9_0.XTcl_DStringInit(tls, bp) libtcl9_0.XTcl_DStringAppend(tls, bp, libtcl9_0.XTcl_GetStringFromObj(tls, yScrollCmdObj, libc.UintptrFromInt32(0)), int64(-libc.Int32FromInt32(1))) libtcl9_0.XTcl_DStringAppend(tls, bp, __ccgo_ts+634, int64(-libc.Int32FromInt32(1))) libtcl9_0.XTcl_DStringAppend(tls, bp, libtcl9_0.XTcl_GetStringFromObj(tls, fractions1, libc.UintptrFromInt32(0)), int64(-libc.Int32FromInt32(1))) result = libtcl9_0.XTcl_EvalEx(tls, interp, (*TTcl_DString)(unsafe.Pointer(bp)).Fstring1, int64(-libc.Int32FromInt32(1)), int32(TCL_EVAL_GLOBAL)) libtcl9_0.XTcl_DStringFree(tls, bp) _objPtr2 = fractions1 v6 = _objPtr2 v5 = *(*TTcl_Size)(unsafe.Pointer(v6)) *(*TTcl_Size)(unsafe.Pointer(v6))-- if v5 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr2) } if result != TCL_OK { libtcl9_0.XTcl_BackgroundException(tls, interp, result) } libtcl9_0.XTcl_ResetResult(tls, interp) _objPtr3 = yScrollCmdObj v8 = _objPtr3 v7 = *(*TTcl_Size)(unsafe.Pointer(v8)) *(*TTcl_Size)(unsafe.Pointer(v8))-- if v7 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr3) } } libtcl9_0.XTcl_Release(tls, interp) } /* *-------------------------------------------------------------- * * CanvasSetOrigin -- * * This function is invoked to change the mapping between canvas * coordinates and screen coordinates in the canvas window. * * Results: * None. * * Side effects: * The canvas will be redisplayed to reflect the change in view. In * addition, scrollbars will be updated if there are any. * *-------------------------------------------------------------- */ func _CanvasSetOrigin(tls *libc.TLS, canvasPtr uintptr, xOrigin int32, yOrigin int32) { bp := tls.Alloc(16) defer tls.Free(16) /* New Y origin for canvas (canvas y-coord * corresponding to top edge of canvas * window). */ var bottom, delta, left, right, top, v1, v2, v3, v4 int32 var _ /* xScrollIncrement at bp+0 */ int32 var _ /* yScrollIncrement at bp+4 */ int32 _, _, _, _, _, _, _, _, _ = bottom, delta, left, right, top, v1, v2, v3, v4 /* * If scroll increments have been set, round the window origin to the * nearest multiple of the increments. Remember, the origin is the place * just inside the borders, not the upper left corner. */ XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), (*TTkCanvas)(unsafe.Pointer(canvasPtr)).Ftkwin, (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FxScrollIncrementObj, bp) XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), (*TTkCanvas)(unsafe.Pointer(canvasPtr)).Ftkwin, (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FyScrollIncrementObj, bp+4) if *(*int32)(unsafe.Pointer(bp)) > 0 { if xOrigin >= 0 { xOrigin += *(*int32)(unsafe.Pointer(bp)) / int32(2) xOrigin -= (xOrigin + (*TTkCanvas)(unsafe.Pointer(canvasPtr)).Finset) % *(*int32)(unsafe.Pointer(bp)) } else { xOrigin = -xOrigin + *(*int32)(unsafe.Pointer(bp))/int32(2) xOrigin = -(xOrigin - (xOrigin-(*TTkCanvas)(unsafe.Pointer(canvasPtr)).Finset)%*(*int32)(unsafe.Pointer(bp))) } } if *(*int32)(unsafe.Pointer(bp + 4)) > 0 { if yOrigin >= 0 { yOrigin += *(*int32)(unsafe.Pointer(bp + 4)) / int32(2) yOrigin -= (yOrigin + (*TTkCanvas)(unsafe.Pointer(canvasPtr)).Finset) % *(*int32)(unsafe.Pointer(bp + 4)) } else { yOrigin = -yOrigin + *(*int32)(unsafe.Pointer(bp + 4))/int32(2) yOrigin = -(yOrigin - (yOrigin-(*TTkCanvas)(unsafe.Pointer(canvasPtr)).Finset)%*(*int32)(unsafe.Pointer(bp + 4))) } } /* * Adjust the origin if necessary to keep as much as possible of the * canvas in the view. The variables left, right, etc. keep track of how * much extra space there is on each side of the view before it will stick * out past the scroll region. If one side sticks out past the edge of the * scroll region, adjust the view to bring that side back to the edge of * the scrollregion (but don't move it so much that the other side sticks * out now). If scroll increments are in effect, be sure to adjust only by * full increments. */ if (*TTkCanvas)(unsafe.Pointer(canvasPtr)).Fconfine != 0 && (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FregionObj != libc.UintptrFromInt32(0) { left = xOrigin + (*TTkCanvas)(unsafe.Pointer(canvasPtr)).Finset - (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FscrollX1 right = (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FscrollX2 - (xOrigin + (*TTk_FakeWin)(unsafe.Pointer((*TTkCanvas)(unsafe.Pointer(canvasPtr)).Ftkwin)).Fchanges.Fwidth - (*TTkCanvas)(unsafe.Pointer(canvasPtr)).Finset) top = yOrigin + (*TTkCanvas)(unsafe.Pointer(canvasPtr)).Finset - (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FscrollY1 bottom = (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FscrollY2 - (yOrigin + (*TTk_FakeWin)(unsafe.Pointer((*TTkCanvas)(unsafe.Pointer(canvasPtr)).Ftkwin)).Fchanges.Fheight - (*TTkCanvas)(unsafe.Pointer(canvasPtr)).Finset) if left < 0 && right > 0 { if right > -left { v1 = -left } else { v1 = right } delta = v1 if *(*int32)(unsafe.Pointer(bp)) > 0 { delta -= delta % *(*int32)(unsafe.Pointer(bp)) } xOrigin += delta } else { if right < 0 && left > 0 { if left > -right { v2 = -right } else { v2 = left } delta = v2 if *(*int32)(unsafe.Pointer(bp)) > 0 { delta -= delta % *(*int32)(unsafe.Pointer(bp)) } xOrigin -= delta } } if top < 0 && bottom > 0 { if bottom > -top { v3 = -top } else { v3 = bottom } delta = v3 if *(*int32)(unsafe.Pointer(bp + 4)) > 0 { delta -= delta % *(*int32)(unsafe.Pointer(bp + 4)) } yOrigin += delta } else { if bottom < 0 && top > 0 { if top > -bottom { v4 = -bottom } else { v4 = top } delta = v4 if *(*int32)(unsafe.Pointer(bp + 4)) > 0 { delta -= delta % *(*int32)(unsafe.Pointer(bp + 4)) } yOrigin -= delta } } } if xOrigin == (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FxOrigin && yOrigin == (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FyOrigin { return } /* * Tricky point: must redisplay not only everything that's visible in the * window's final configuration, but also everything that was visible in * the initial configuration. This is needed because some item types, like * windows, need to know when they move off-screen so they can explicitly * undisplay themselves. */ XTk_CanvasEventuallyRedraw(tls, canvasPtr, (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FxOrigin, (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FyOrigin, (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FxOrigin+(*TTk_FakeWin)(unsafe.Pointer((*TTkCanvas)(unsafe.Pointer(canvasPtr)).Ftkwin)).Fchanges.Fwidth, (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FyOrigin+(*TTk_FakeWin)(unsafe.Pointer((*TTkCanvas)(unsafe.Pointer(canvasPtr)).Ftkwin)).Fchanges.Fheight) (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FxOrigin = xOrigin (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FyOrigin = yOrigin *(*int32)(unsafe.Pointer(canvasPtr + 648)) |= int32(UPDATE_SCROLLBARS) XTk_CanvasEventuallyRedraw(tls, canvasPtr, (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FxOrigin, (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FyOrigin, (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FxOrigin+(*TTk_FakeWin)(unsafe.Pointer((*TTkCanvas)(unsafe.Pointer(canvasPtr)).Ftkwin)).Fchanges.Fwidth, (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FyOrigin+(*TTk_FakeWin)(unsafe.Pointer((*TTkCanvas)(unsafe.Pointer(canvasPtr)).Ftkwin)).Fchanges.Fheight) } /* *-------------------------------------------------------------- * * Tk_CanvasPsColor -- * * This function is called by individual canvas items when they want to * set a color value for output. Given information about an X color, this * function will generate Postscript commands to set up an appropriate * color in Postscript. * * Results: * Returns a standard Tcl return value. If an error occurs then an error * message will be left in interp->result. If no error occurs, then * additional Postscript will be appended to interp->result. * * Side effects: * None. * *-------------------------------------------------------------- */ func XTk_CanvasPsColor(tls *libc.TLS, interp uintptr, canvas TTk_Canvas, colorPtr uintptr) (r int32) { /* Information about color. */ return XTk_PostscriptColor(tls, interp, (*TTkCanvas)(unsafe.Pointer(canvas)).FpsInfo, colorPtr) } /* *-------------------------------------------------------------- * * Tk_CanvasPsFont -- * * This function is called by individual canvas items when they want to * output text. Given information about an X font, this function will * generate Postscript commands to set up an appropriate font in * Postscript. * * Results: * Returns a standard Tcl return value. If an error occurs then an error * message will be left in interp->result. If no error occurs, then * additional Postscript will be appended to the interp->result. * * Side effects: * The Postscript font name is entered into psInfoPtr->fontTable if it * wasn't already there. * *-------------------------------------------------------------- */ func XTk_CanvasPsFont(tls *libc.TLS, interp uintptr, canvas TTk_Canvas, tkfont TTk_Font) (r int32) { /* Information about font in which text is to * be printed. */ return XTk_PostscriptFont(tls, interp, (*TTkCanvas)(unsafe.Pointer(canvas)).FpsInfo, tkfont) } /* *-------------------------------------------------------------- * * Tk_CanvasPsBitmap -- * * This function is called to output the contents of a sub-region of a * bitmap in proper image data format for Postscript (i.e. data between * angle brackets, one bit per pixel). * * Results: * Returns a standard Tcl return value. If an error occurs then an error * message will be left in interp->result. If no error occurs, then * additional Postscript will be appended to interp->result. * * Side effects: * None. * *-------------------------------------------------------------- */ func XTk_CanvasPsBitmap(tls *libc.TLS, interp uintptr, canvas TTk_Canvas, bitmap TPixmap, startX int32, startY int32, width int32, height int32) (r int32) { /* Size of rectangular region. */ return XTk_PostscriptBitmap(tls, interp, (*TTkCanvas)(unsafe.Pointer(canvas)).Ftkwin, (*TTkCanvas)(unsafe.Pointer(canvas)).FpsInfo, bitmap, startX, startY, width, height) } /* *-------------------------------------------------------------- * * Tk_CanvasPsStipple -- * * This function is called by individual canvas items when they have * created a path that they'd like to be filled with a stipple pattern. * Given information about an X bitmap, this function will generate * Postscript commands to fill the current clip region using a stipple * pattern defined by the bitmap. * * Results: * Returns a standard Tcl return value. If an error occurs then an error * message will be left in interp->result. If no error occurs, then * additional Postscript will be appended to interp->result. * * Side effects: * None. * *-------------------------------------------------------------- */ func XTk_CanvasPsStipple(tls *libc.TLS, interp uintptr, canvas TTk_Canvas, bitmap TPixmap) (r int32) { /* Bitmap to use for stippling. */ return XTk_PostscriptStipple(tls, interp, (*TTkCanvas)(unsafe.Pointer(canvas)).Ftkwin, (*TTkCanvas)(unsafe.Pointer(canvas)).FpsInfo, bitmap) } /* *-------------------------------------------------------------- * * Tk_CanvasPsY -- * * Given a y-coordinate in canvas coordinates, this function returns a * y-coordinate to use for Postscript output. * * Results: * Returns the Postscript coordinate that corresponds to "y". * * Side effects: * None. * *-------------------------------------------------------------- */ func XTk_CanvasPsY(tls *libc.TLS, canvas TTk_Canvas, y float64) (r float64) { /* Y-coordinate in canvas coords. */ return XTk_PostscriptY(tls, y, (*TTkCanvas)(unsafe.Pointer(canvas)).FpsInfo) } /* *-------------------------------------------------------------- * * Tk_CanvasPsPath -- * * Given an array of points for a path, generate Postscript commands to * create the path. * * Results: * Postscript commands get appended to what's in interp->result. * * Side effects: * None. * *-------------------------------------------------------------- */ func XTk_CanvasPsPath(tls *libc.TLS, interp uintptr, canvas TTk_Canvas, coordPtr uintptr, numPoints TTcl_Size) { /* Number of points at *coordPtr. */ XTk_PostscriptPath(tls, interp, (*TTkCanvas)(unsafe.Pointer(canvas)).FpsInfo, coordPtr, numPoints) } type TTk_Item1 = struct { Fid TTcl_Size FnextPtr uintptr FstaticTagSpace [3]TTk_Uid FtagPtr uintptr FtagSpace TTcl_Size FnumTags TTcl_Size FtypePtr uintptr Fx1 int32 Fy1 int32 Fx2 int32 Fy2 int32 FprevPtr uintptr Fstate TTk_State Freserved1 uintptr Fredraw_flags int32 } type TTk_ItemType1 = struct { Fname uintptr FitemSize TTcl_Size FcreateProc uintptr FconfigSpecs uintptr FconfigProc uintptr FcoordProc uintptr FdeleteProc uintptr FdisplayProc uintptr Fflags int32 FpointProc uintptr FareaProc uintptr FpostscriptProc uintptr FscaleProc uintptr FtranslateProc uintptr FindexProc uintptr FicursorProc uintptr FselectionProc uintptr FinsertProc uintptr FdCharsProc uintptr FnextPtr uintptr FrotateProc uintptr Freserved2 int32 Freserved3 uintptr Freserved4 uintptr } const CHORD_OUTLINE_PTS = 7 const DBL_DECIMAL_DIG = 17 const DBL_DIG = 15 const DBL_EPSILON = 2.220446049250313e-16 const DBL_HAS_SUBNORM = 1 const DBL_MANT_DIG = 53 const DBL_MAX = 0 const DBL_MAX_10_EXP = 308 const DBL_MAX_EXP = 1024 const DBL_MIN = 0 const DBL_MIN_10_EXP = -307 const DBL_MIN_EXP = -1021 const DBL_TRUE_MIN = 0 const DECIMAL_DIG = 17 const FLT_DECIMAL_DIG = 9 const FLT_DIG = 6 const FLT_EPSILON = 0 const FLT_EVAL_METHOD = 0 const FLT_HAS_SUBNORM = 1 const FLT_MANT_DIG = 24 const FLT_MAX = 0 const FLT_MAX_10_EXP = 38 const FLT_MAX_EXP = 128 const FLT_MIN = 0 const FLT_MIN_10_EXP = -37 const FLT_MIN_EXP = -125 const FLT_RADIX = 2 const FLT_ROUNDS = 0 const FLT_TRUE_MIN = 0 const LDBL_DECIMAL_DIG = 17 const LDBL_DIG = 15 const LDBL_EPSILON = 0 const LDBL_HAS_SUBNORM = 1 const LDBL_MANT_DIG = 53 const LDBL_MAX = 0 const LDBL_MAX_10_EXP = 308 const LDBL_MAX_EXP = 1024 const LDBL_MIN = 0 const LDBL_MIN_10_EXP = -307 const LDBL_MIN_EXP = -1021 const LDBL_TRUE_MIN = 0 const M_PI3 = 3.141592653589793 const PIE_OUTLINE1_PTS = 6 const PIE_OUTLINE2_PTS = 7 /* * The structure below defines the record for each arc item. */ type TStyle1 = int32 const PIESLICE_STYLE = 0 const CHORD_STYLE = 1 const ARC_STYLE = 2 type TArcItem = struct { Fheader TTk_Item Foutline TTk_Outline Fbbox [4]float64 Fstart float64 Fextent float64 FoutlinePtr uintptr FnumOutlinePoints int32 Ftsoffset TTk_TSOffset FfillColor uintptr FactiveFillColor uintptr FdisabledFillColor uintptr FfillStipple TPixmap FactiveFillStipple TPixmap FdisabledFillStipple TPixmap Fstyle TStyle1 FfillGC TGC Fcenter1 [2]float64 Fcenter2 [2]float64 Fheight float64 FstartPoint [2]float64 FendPoint [2]float64 } var _stateOption1 = TTk_CustomOption{ FclientData: uintptr(int64(libc.Int32FromInt32(2))), } func init() { p := unsafe.Pointer(&_stateOption1) *(*uintptr)(unsafe.Add(p, 0)) = __ccgo_fp(XTkStateParseProc) *(*uintptr)(unsafe.Add(p, 8)) = __ccgo_fp(XTkStatePrintProc) } var _styleOption = TTk_CustomOption{} func init() { p := unsafe.Pointer(&_styleOption) *(*uintptr)(unsafe.Add(p, 0)) = __ccgo_fp(_StyleParseProc) *(*uintptr)(unsafe.Add(p, 8)) = __ccgo_fp(_StylePrintProc) } var _tagsOption = TTk_CustomOption{} func init() { p := unsafe.Pointer(&_tagsOption) *(*uintptr)(unsafe.Add(p, 0)) = __ccgo_fp(XTk_CanvasTagsParseProc) *(*uintptr)(unsafe.Add(p, 8)) = __ccgo_fp(XTk_CanvasTagsPrintProc) } var _dashOption = TTk_CustomOption{} func init() { p := unsafe.Pointer(&_dashOption) *(*uintptr)(unsafe.Add(p, 0)) = __ccgo_fp(XTkCanvasDashParseProc) *(*uintptr)(unsafe.Add(p, 8)) = __ccgo_fp(XTkCanvasDashPrintProc) } var _offsetOption1 = TTk_CustomOption{ FclientData: uintptr(int64(libc.Int32FromInt32(TK_OFFSET_RELATIVE))), } func init() { p := unsafe.Pointer(&_offsetOption1) *(*uintptr)(unsafe.Add(p, 0)) = __ccgo_fp(XTkOffsetParseProc) *(*uintptr)(unsafe.Add(p, 8)) = __ccgo_fp(XTkOffsetPrintProc) } var _pixelOption = TTk_CustomOption{} func init() { p := unsafe.Pointer(&_pixelOption) *(*uintptr)(unsafe.Add(p, 0)) = __ccgo_fp(XTkPixelParseProc) *(*uintptr)(unsafe.Add(p, 8)) = __ccgo_fp(XTkPixelPrintProc) } var _configSpecs2 = [28]TTk_ConfigSpec{ 0: { Ftype1: int32(TK_CONFIG_CUSTOM), FargvName: __ccgo_ts + 28613, Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 120 + 56)), FspecFlags: int32(TCL_NULL_OK), FcustomPtr: uintptr(unsafe.Pointer(&_dashOption)), }, 1: { Ftype1: int32(TK_CONFIG_COLOR), FargvName: __ccgo_ts + 28625, Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 376)), FspecFlags: int32(TCL_NULL_OK), }, 2: { Ftype1: int32(TK_CONFIG_COLOR), FargvName: __ccgo_ts + 28637, Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 120 + 136)), FspecFlags: int32(TCL_NULL_OK), }, 3: { Ftype1: int32(TK_CONFIG_BITMAP), FargvName: __ccgo_ts + 28652, Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 120 + 160)), FspecFlags: int32(TCL_NULL_OK), }, 4: { Ftype1: int32(TK_CONFIG_BITMAP), FargvName: __ccgo_ts + 28674, Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 400)), FspecFlags: int32(TCL_NULL_OK), }, 5: { Ftype1: int32(TK_CONFIG_CUSTOM), FargvName: __ccgo_ts + 28689, FdefValue: __ccgo_ts + 14146, Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 120 + 16)), FspecFlags: libc.Int32FromInt32(1) << libc.Int32FromInt32(3), FcustomPtr: uintptr(unsafe.Pointer(&_pixelOption)), }, 6: { Ftype1: int32(TK_CONFIG_CUSTOM), FargvName: __ccgo_ts + 28702, Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 120 + 40)), FspecFlags: int32(TCL_NULL_OK), FcustomPtr: uintptr(unsafe.Pointer(&_dashOption)), }, 7: { Ftype1: int32(TK_CONFIG_PIXELS), FargvName: __ccgo_ts + 28708, FdefValue: __ccgo_ts + 10533, Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 120 + 88)), FspecFlags: int32(TK_CONFIG_OBJS), }, 8: { Ftype1: int32(TK_CONFIG_CUSTOM), FargvName: __ccgo_ts + 28720, Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 120 + 72)), FspecFlags: int32(TCL_NULL_OK), FcustomPtr: uintptr(unsafe.Pointer(&_dashOption)), }, 9: { Ftype1: int32(TK_CONFIG_COLOR), FargvName: __ccgo_ts + 28734, Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 384)), FspecFlags: int32(TCL_NULL_OK), }, 10: { Ftype1: int32(TK_CONFIG_COLOR), FargvName: __ccgo_ts + 28748, Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 120 + 144)), FspecFlags: int32(TCL_NULL_OK), }, 11: { Ftype1: int32(TK_CONFIG_BITMAP), FargvName: __ccgo_ts + 28765, Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 120 + 168)), FspecFlags: int32(TCL_NULL_OK), }, 12: { Ftype1: int32(TK_CONFIG_BITMAP), FargvName: __ccgo_ts + 28789, Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 408)), FspecFlags: int32(TCL_NULL_OK), }, 13: { Ftype1: int32(TK_CONFIG_CUSTOM), FargvName: __ccgo_ts + 28806, FdefValue: __ccgo_ts + 14146, Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 120 + 24)), FspecFlags: libc.Int32FromInt32(1) << libc.Int32FromInt32(3), FcustomPtr: uintptr(unsafe.Pointer(&_pixelOption)), }, 14: { Ftype1: int32(TK_CONFIG_DOUBLE), FargvName: __ccgo_ts + 28821, FdefValue: __ccgo_ts + 28829, Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 336)), FspecFlags: libc.Int32FromInt32(1) << libc.Int32FromInt32(3), }, 15: { Ftype1: int32(TK_CONFIG_COLOR), FargvName: __ccgo_ts + 15184, Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 368)), FspecFlags: int32(TCL_NULL_OK), }, 16: { Ftype1: int32(TK_CONFIG_DOUBLE), FargvName: __ccgo_ts + 2870, Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 464)), FspecFlags: libc.Int32FromInt32(1) << libc.Int32FromInt32(3), }, 17: { Ftype1: int32(TK_CONFIG_CUSTOM), FargvName: __ccgo_ts + 26544, FdefValue: __ccgo_ts + 26566, Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 356)), FspecFlags: libc.Int32FromInt32(1) << libc.Int32FromInt32(3), FcustomPtr: uintptr(unsafe.Pointer(&_offsetOption1)), }, 18: { Ftype1: int32(TK_CONFIG_COLOR), FargvName: __ccgo_ts + 28832, FdefValue: __ccgo_ts + 19829, Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 120 + 128)), FspecFlags: int32(TCL_NULL_OK), }, 19: { Ftype1: int32(TK_CONFIG_CUSTOM), FargvName: __ccgo_ts + 28841, FdefValue: __ccgo_ts + 26566, Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 120 + 112)), FspecFlags: libc.Int32FromInt32(1) << libc.Int32FromInt32(3), FcustomPtr: uintptr(unsafe.Pointer(&_offsetOption1)), }, 20: { Ftype1: int32(TK_CONFIG_BITMAP), FargvName: __ccgo_ts + 28856, Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 120 + 152)), FspecFlags: int32(TCL_NULL_OK), }, 21: { Ftype1: int32(TK_CONFIG_DOUBLE), FargvName: __ccgo_ts + 28872, FdefValue: __ccgo_ts + 10533, Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 328)), FspecFlags: libc.Int32FromInt32(1) << libc.Int32FromInt32(3), }, 22: { Ftype1: int32(TK_CONFIG_CUSTOM), FargvName: __ccgo_ts + 2957, Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 96)), FspecFlags: int32(TCL_NULL_OK), FcustomPtr: uintptr(unsafe.Pointer(&_stateOption1)), }, 23: { Ftype1: int32(TK_CONFIG_BITMAP), FargvName: __ccgo_ts + 28879, Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 392)), FspecFlags: int32(TCL_NULL_OK), }, 24: { Ftype1: int32(TK_CONFIG_CUSTOM), FargvName: __ccgo_ts + 28888, Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 416)), FspecFlags: libc.Int32FromInt32(1) << libc.Int32FromInt32(3), FcustomPtr: uintptr(unsafe.Pointer(&_styleOption)), }, 25: { Ftype1: int32(TK_CONFIG_CUSTOM), FargvName: __ccgo_ts + 28895, FspecFlags: int32(TCL_NULL_OK), FcustomPtr: uintptr(unsafe.Pointer(&_tagsOption)), }, 26: { Ftype1: int32(TK_CONFIG_CUSTOM), FargvName: __ccgo_ts + 2987, FdefValue: __ccgo_ts + 22084, Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 120 + 8)), FspecFlags: libc.Int32FromInt32(1) << libc.Int32FromInt32(3), FcustomPtr: uintptr(unsafe.Pointer(&_pixelOption)), }, 27: { Ftype1: int32(TK_CONFIG_END), }, } func init() { p := unsafe.Pointer(&XtkArcType) *(*uintptr)(unsafe.Add(p, 16)) = __ccgo_fp(_CreateArc) *(*uintptr)(unsafe.Add(p, 32)) = __ccgo_fp(_ConfigureArc) *(*uintptr)(unsafe.Add(p, 40)) = __ccgo_fp(_ArcCoords) *(*uintptr)(unsafe.Add(p, 48)) = __ccgo_fp(_DeleteArc) *(*uintptr)(unsafe.Add(p, 56)) = __ccgo_fp(_DisplayArc) *(*uintptr)(unsafe.Add(p, 72)) = __ccgo_fp(_ArcToPoint) *(*uintptr)(unsafe.Add(p, 80)) = __ccgo_fp(_ArcToArea) *(*uintptr)(unsafe.Add(p, 88)) = __ccgo_fp(_ArcToPostscript) *(*uintptr)(unsafe.Add(p, 96)) = __ccgo_fp(_ScaleArc) *(*uintptr)(unsafe.Add(p, 104)) = __ccgo_fp(_TranslateArc) *(*uintptr)(unsafe.Add(p, 160)) = __ccgo_fp(_RotateArc) } /* *-------------------------------------------------------------- * * CreateArc -- * * This function is invoked to create a new arc item in a canvas. * * Results: * A standard Tcl return value. If an error occurred in creating the * item, then an error message is left in the interp's result; in this * case itemPtr is left uninitialized, so it can be safely freed by the * caller. * * Side effects: * A new arc item is created. * *-------------------------------------------------------------- */ func _CreateArc(tls *libc.TLS, interp uintptr, canvas TTk_Canvas, itemPtr uintptr, objc TTcl_Size, objv uintptr) (r int32) { /* Arguments describing arc. */ var arcPtr, arg uintptr var i TTcl_Size _, _, _ = arcPtr, arg, i arcPtr = itemPtr if objc == 0 { libtcl9_0.XTcl_Panic(tls, __ccgo_ts+28901, 0) } /* * Carry out initialization that is needed in order to clean up after * errors during the the remainder of this function. */ XTk_CreateOutline(tls, arcPtr+120) (*TArcItem)(unsafe.Pointer(arcPtr)).Fstart = libc.Float64FromInt32(0) (*TArcItem)(unsafe.Pointer(arcPtr)).Fextent = libc.Float64FromInt32(90) (*TArcItem)(unsafe.Pointer(arcPtr)).FoutlinePtr = libc.UintptrFromInt32(0) (*TArcItem)(unsafe.Pointer(arcPtr)).FnumOutlinePoints = 0 (*TArcItem)(unsafe.Pointer(arcPtr)).Ftsoffset.Fflags = 0 (*TArcItem)(unsafe.Pointer(arcPtr)).Ftsoffset.Fxoffset = 0 (*TArcItem)(unsafe.Pointer(arcPtr)).Ftsoffset.Fyoffset = 0 (*TArcItem)(unsafe.Pointer(arcPtr)).FfillColor = libc.UintptrFromInt32(0) (*TArcItem)(unsafe.Pointer(arcPtr)).FactiveFillColor = libc.UintptrFromInt32(0) (*TArcItem)(unsafe.Pointer(arcPtr)).FdisabledFillColor = libc.UintptrFromInt32(0) (*TArcItem)(unsafe.Pointer(arcPtr)).FfillStipple = uint64(0) (*TArcItem)(unsafe.Pointer(arcPtr)).FactiveFillStipple = uint64(0) (*TArcItem)(unsafe.Pointer(arcPtr)).FdisabledFillStipple = uint64(0) (*TArcItem)(unsafe.Pointer(arcPtr)).Fstyle = int32(PIESLICE_STYLE) (*TArcItem)(unsafe.Pointer(arcPtr)).FfillGC = libc.UintptrFromInt32(0) (*TArcItem)(unsafe.Pointer(arcPtr)).Fheight = libc.Float64FromInt32(0) /* * Process the arguments to fill in the item record. */ i = int64(1) for { if !(i < objc) { break } arg = libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(i)*8)), libc.UintptrFromInt32(0)) if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(arg))) == int32('-') && libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(arg + 1))) >= int32('a') && libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(arg + 1))) <= int32('z') { break } goto _1 _1: ; i++ } if _ArcCoords(tls, interp, canvas, itemPtr, i, objv) != TCL_OK { goto error } if _ConfigureArc(tls, interp, canvas, itemPtr, objc-i, objv+uintptr(i)*8, 0) == TCL_OK { return TCL_OK } goto error error: ; _DeleteArc(tls, canvas, itemPtr, (*TTk_FakeWin)(unsafe.Pointer(XTk_CanvasTkwin(tls, canvas))).Fdisplay) return int32(TCL_ERROR) } /* *-------------------------------------------------------------- * * ArcCoords -- * * This function is invoked to process the "coords" widget command on * arcs. See the user documentation for details on what it does. * * Results: * Returns TCL_OK or TCL_ERROR, and sets the interp's result. * * Side effects: * The coordinates for the given item may be changed. * *-------------------------------------------------------------- */ func _ArcCoords(tls *libc.TLS, interp uintptr, canvas TTk_Canvas, itemPtr uintptr, _objc TTcl_Size, _objv uintptr) (r int32) { bp := tls.Alloc(96) defer tls.Free(96) *(*TTcl_Size)(unsafe.Pointer(bp)) = _objc *(*uintptr)(unsafe.Pointer(bp + 8)) = _objv /* Array of coordinates: x1, y1, x2, y2, ... */ var arcPtr uintptr var _ /* objs at bp+16 */ [4]uintptr _ = arcPtr arcPtr = itemPtr if *(*TTcl_Size)(unsafe.Pointer(bp)) == 0 { (*(*[4]uintptr)(unsafe.Pointer(bp + 16)))[0] = libtcl9_0.XTcl_NewDoubleObj(tls, *(*float64)(unsafe.Pointer(arcPtr + 296))) (*(*[4]uintptr)(unsafe.Pointer(bp + 16)))[int32(1)] = libtcl9_0.XTcl_NewDoubleObj(tls, *(*float64)(unsafe.Pointer(arcPtr + 296 + 1*8))) (*(*[4]uintptr)(unsafe.Pointer(bp + 16)))[int32(2)] = libtcl9_0.XTcl_NewDoubleObj(tls, *(*float64)(unsafe.Pointer(arcPtr + 296 + 2*8))) (*(*[4]uintptr)(unsafe.Pointer(bp + 16)))[int32(3)] = libtcl9_0.XTcl_NewDoubleObj(tls, *(*float64)(unsafe.Pointer(arcPtr + 296 + 3*8))) libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewListObj(tls, int64(4), bp+16)) } else { if *(*TTcl_Size)(unsafe.Pointer(bp)) == int64(1) || *(*TTcl_Size)(unsafe.Pointer(bp)) == int64(4) { if *(*TTcl_Size)(unsafe.Pointer(bp)) == int64(1) { if libtcl9_0.XTcl_ListObjGetElements(tls, interp, *(*uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 8)))), bp, bp+8) != TCL_OK { return int32(TCL_ERROR) } else { if *(*TTcl_Size)(unsafe.Pointer(bp)) != int64(4) { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+28932, libc.VaList(bp+56, *(*TTcl_Size)(unsafe.Pointer(bp))))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+56, __ccgo_ts+179, __ccgo_ts+27003, __ccgo_ts+28973, __ccgo_ts+754, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) } } } if XTk_CanvasGetCoordFromObj(tls, interp, canvas, *(*uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 8)))), arcPtr+296) != TCL_OK || XTk_CanvasGetCoordFromObj(tls, interp, canvas, *(*uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 8)) + 1*8)), arcPtr+296+1*8) != TCL_OK || XTk_CanvasGetCoordFromObj(tls, interp, canvas, *(*uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 8)) + 2*8)), arcPtr+296+2*8) != TCL_OK || XTk_CanvasGetCoordFromObj(tls, interp, canvas, *(*uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 8)) + 3*8)), arcPtr+296+3*8) != TCL_OK { return int32(TCL_ERROR) } /* * Store bbox as start and end points so they can be used if either * radius or height is specified. */ *(*float64)(unsafe.Pointer(arcPtr + 472)) = *(*float64)(unsafe.Pointer(arcPtr + 296)) *(*float64)(unsafe.Pointer(arcPtr + 472 + 1*8)) = *(*float64)(unsafe.Pointer(arcPtr + 296 + 1*8)) *(*float64)(unsafe.Pointer(arcPtr + 488)) = *(*float64)(unsafe.Pointer(arcPtr + 296 + 2*8)) *(*float64)(unsafe.Pointer(arcPtr + 488 + 1*8)) = *(*float64)(unsafe.Pointer(arcPtr + 296 + 3*8)) _ComputeArcBbox(tls, canvas, arcPtr) } else { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+28980, libc.VaList(bp+56, *(*TTcl_Size)(unsafe.Pointer(bp))))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+56, __ccgo_ts+179, __ccgo_ts+27003, __ccgo_ts+28973, __ccgo_ts+754, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) } } return TCL_OK } /* *-------------------------------------------------------------- * * ConfigureArc -- * * This function is invoked to configure various aspects of a arc item, * such as its outline and fill colors. * * Results: * A standard Tcl result code. If an error occurs, then an error message * is left in the interp's result. * * Side effects: * Configuration information, such as colors and stipple patterns, may be * set for itemPtr. * *-------------------------------------------------------------- */ func _ConfigureArc(tls *libc.TLS, interp uintptr, canvas TTk_Canvas, itemPtr uintptr, objc TTcl_Size, objv uintptr, flags int32) (r int32) { bp := tls.Alloc(128) defer tls.Free(128) /* Flags to pass to Tk_ConfigureWidget. */ var arcPtr, color, tsoffset uintptr var i int32 var mask uint64 var newGC TGC var state TTk_State var stipple TPixmap var tkwin TTk_Window var _ /* gcValues at bp+0 */ TXGCValues _, _, _, _, _, _, _, _, _ = arcPtr, color, i, mask, newGC, state, stipple, tkwin, tsoffset arcPtr = itemPtr tkwin = XTk_CanvasTkwin(tls, canvas) if TCL_OK != XTk_ConfigureWidget(tls, interp, tkwin, uintptr(unsafe.Pointer(&_configSpecs2)), objc, objv, arcPtr, flags) { return int32(TCL_ERROR) } state = (*TTk_Item)(unsafe.Pointer(itemPtr)).Fstate /* * A few of the options require additional processing, such as style and * graphics contexts. */ if (*TArcItem)(unsafe.Pointer(arcPtr)).Foutline.FactiveWidth > (*TArcItem)(unsafe.Pointer(arcPtr)).Foutline.Fwidth || (*TArcItem)(unsafe.Pointer(arcPtr)).Foutline.FactiveDash.Fnumber != 0 || (*TArcItem)(unsafe.Pointer(arcPtr)).Foutline.FactiveColor != libc.UintptrFromInt32(0) || (*TArcItem)(unsafe.Pointer(arcPtr)).Foutline.FactiveStipple != uint64(0) || (*TArcItem)(unsafe.Pointer(arcPtr)).FactiveFillColor != libc.UintptrFromInt32(0) || (*TArcItem)(unsafe.Pointer(arcPtr)).FactiveFillStipple != uint64(0) { *(*int32)(unsafe.Pointer(itemPtr + 112)) |= int32(TK_ITEM_STATE_DEPENDANT) } else { *(*int32)(unsafe.Pointer(itemPtr + 112)) &= ^libc.Int32FromInt32(TK_ITEM_STATE_DEPENDANT) } /* * Override the start and extent if the height is given. */ _ComputeArcParametersFromHeight(tls, arcPtr) _ComputeArcBbox(tls, canvas, arcPtr) i = int32((*TArcItem)(unsafe.Pointer(arcPtr)).Fstart / libc.Float64FromFloat64(360)) *(*float64)(unsafe.Pointer(arcPtr + 328)) -= float64(float64(i) * float64(360)) if (*TArcItem)(unsafe.Pointer(arcPtr)).Fstart < libc.Float64FromInt32(0) { *(*float64)(unsafe.Pointer(arcPtr + 328)) += float64(360) } i = int32((*TArcItem)(unsafe.Pointer(arcPtr)).Fextent / libc.Float64FromFloat64(360)) *(*float64)(unsafe.Pointer(arcPtr + 336)) -= float64(float64(i) * float64(360)) tsoffset = arcPtr + 120 + 112 flags = (*TTk_TSOffset)(unsafe.Pointer(tsoffset)).Fflags if flags&int32(TK_OFFSET_LEFT) != 0 { (*TTk_TSOffset)(unsafe.Pointer(tsoffset)).Fxoffset = int32(*(*float64)(unsafe.Pointer(arcPtr + 296)) + libc.Float64FromFloat64(0.5)) } else { if flags&int32(TK_OFFSET_CENTER) != 0 { (*TTk_TSOffset)(unsafe.Pointer(tsoffset)).Fxoffset = int32((*(*float64)(unsafe.Pointer(arcPtr + 296)) + *(*float64)(unsafe.Pointer(arcPtr + 296 + 2*8)) + libc.Float64FromInt32(1)) / libc.Float64FromInt32(2)) } else { if flags&int32(TK_OFFSET_RIGHT) != 0 { (*TTk_TSOffset)(unsafe.Pointer(tsoffset)).Fxoffset = int32(*(*float64)(unsafe.Pointer(arcPtr + 296 + 2*8)) + libc.Float64FromFloat64(0.5)) } } } if flags&int32(TK_OFFSET_TOP) != 0 { (*TTk_TSOffset)(unsafe.Pointer(tsoffset)).Fyoffset = int32(*(*float64)(unsafe.Pointer(arcPtr + 296 + 1*8)) + libc.Float64FromFloat64(0.5)) } else { if flags&int32(TK_OFFSET_MIDDLE) != 0 { (*TTk_TSOffset)(unsafe.Pointer(tsoffset)).Fyoffset = int32((*(*float64)(unsafe.Pointer(arcPtr + 296 + 1*8)) + *(*float64)(unsafe.Pointer(arcPtr + 296 + 3*8)) + libc.Float64FromInt32(1)) / libc.Float64FromInt32(2)) } else { if flags&int32(TK_OFFSET_BOTTOM) != 0 { (*TTk_TSOffset)(unsafe.Pointer(tsoffset)).Fyoffset = int32(*(*float64)(unsafe.Pointer(arcPtr + 296 + 2*8)) + libc.Float64FromFloat64(0.5)) } } } mask = libc.Uint64FromInt32(XTk_ConfigOutlineGC(tls, bp, canvas, itemPtr, arcPtr+120)) if mask != 0 { (*(*TXGCValues)(unsafe.Pointer(bp))).Fcap_style = int32(CapButt) mask |= libc.Uint64FromInt64(libc.Int64FromInt64(1) << libc.Int32FromInt32(6)) newGC = XTk_GetGC(tls, tkwin, mask, bp) } else { newGC = libc.UintptrFromInt32(0) } if (*TArcItem)(unsafe.Pointer(arcPtr)).Foutline.Fgc != libc.UintptrFromInt32(0) { XTk_FreeGC(tls, (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fdisplay, (*TArcItem)(unsafe.Pointer(arcPtr)).Foutline.Fgc) } (*TArcItem)(unsafe.Pointer(arcPtr)).Foutline.Fgc = newGC if state == int32(TK_STATE_NULL) { state = (*TTkCanvas)(unsafe.Pointer(canvas)).Fcanvas_state } if state == int32(TK_STATE_HIDDEN) { _ComputeArcBbox(tls, canvas, arcPtr) return TCL_OK } color = (*TArcItem)(unsafe.Pointer(arcPtr)).FfillColor stipple = (*TArcItem)(unsafe.Pointer(arcPtr)).FfillStipple if (*TTkCanvas)(unsafe.Pointer(canvas)).FcurrentItemPtr == itemPtr { if (*TArcItem)(unsafe.Pointer(arcPtr)).FactiveFillColor != libc.UintptrFromInt32(0) { color = (*TArcItem)(unsafe.Pointer(arcPtr)).FactiveFillColor } if (*TArcItem)(unsafe.Pointer(arcPtr)).FactiveFillStipple != uint64(0) { stipple = (*TArcItem)(unsafe.Pointer(arcPtr)).FactiveFillStipple } } else { if state == int32(TK_STATE_DISABLED) { if (*TArcItem)(unsafe.Pointer(arcPtr)).FdisabledFillColor != libc.UintptrFromInt32(0) { color = (*TArcItem)(unsafe.Pointer(arcPtr)).FdisabledFillColor } if (*TArcItem)(unsafe.Pointer(arcPtr)).FdisabledFillStipple != uint64(0) { stipple = (*TArcItem)(unsafe.Pointer(arcPtr)).FdisabledFillStipple } } } if (*TArcItem)(unsafe.Pointer(arcPtr)).Fstyle == int32(ARC_STYLE) { newGC = libc.UintptrFromInt32(0) } else { if color == libc.UintptrFromInt32(0) { newGC = libc.UintptrFromInt32(0) } else { (*(*TXGCValues)(unsafe.Pointer(bp))).Fforeground = (*TXColor)(unsafe.Pointer(color)).Fpixel if (*TArcItem)(unsafe.Pointer(arcPtr)).Fstyle == int32(CHORD_STYLE) { (*(*TXGCValues)(unsafe.Pointer(bp))).Farc_mode = ArcChord } else { (*(*TXGCValues)(unsafe.Pointer(bp))).Farc_mode = int32(ArcPieSlice) } mask = libc.Uint64FromInt64(libc.Int64FromInt64(1)< 180. */ if libc.Xfabs(tls, float64(libc.Float64FromInt32(2)*(*TArcItem)(unsafe.Pointer(arcPtr)).Fheight)) > chordLen { if (*TArcItem)(unsafe.Pointer(arcPtr)).Fextent > libc.Float64FromInt32(0) { v3 = libc.Float64FromInt32(360) - (*TArcItem)(unsafe.Pointer(arcPtr)).Fextent } else { v3 = -(libc.Float64FromInt32(360) + (*TArcItem)(unsafe.Pointer(arcPtr)).Fextent) } (*TArcItem)(unsafe.Pointer(arcPtr)).Fextent = v3 } /* * Create the bounding box. */ *(*float64)(unsafe.Pointer(arcPtr + 296)) = arcCen[0] - radius *(*float64)(unsafe.Pointer(arcPtr + 296 + 1*8)) = arcCen[int32(1)] - radius *(*float64)(unsafe.Pointer(arcPtr + 296 + 2*8)) = arcCen[0] + radius *(*float64)(unsafe.Pointer(arcPtr + 296 + 3*8)) = arcCen[int32(1)] + radius /* * Set the height to 0 so that itemcget -height returns 0. */ (*TArcItem)(unsafe.Pointer(arcPtr)).Fheight = libc.Float64FromInt32(0) } /* *-------------------------------------------------------------- * * DeleteArc -- * * This function is called to clean up the data structure associated with * an arc item. * * Results: * None. * * Side effects: * Resources associated with itemPtr are released. * *-------------------------------------------------------------- */ func _DeleteArc(tls *libc.TLS, dummy710 TTk_Canvas, itemPtr uintptr, display uintptr) { /* Display containing window for canvas. */ var arcPtr uintptr _ = arcPtr arcPtr = itemPtr XTk_DeleteOutline(tls, display, arcPtr+120) if (*TArcItem)(unsafe.Pointer(arcPtr)).FnumOutlinePoints != 0 { libtcl9_0.XTcl_Free(tls, (*TArcItem)(unsafe.Pointer(arcPtr)).FoutlinePtr) } if (*TArcItem)(unsafe.Pointer(arcPtr)).FfillColor != libc.UintptrFromInt32(0) { XTk_FreeColor(tls, (*TArcItem)(unsafe.Pointer(arcPtr)).FfillColor) } if (*TArcItem)(unsafe.Pointer(arcPtr)).FactiveFillColor != libc.UintptrFromInt32(0) { XTk_FreeColor(tls, (*TArcItem)(unsafe.Pointer(arcPtr)).FactiveFillColor) } if (*TArcItem)(unsafe.Pointer(arcPtr)).FdisabledFillColor != libc.UintptrFromInt32(0) { XTk_FreeColor(tls, (*TArcItem)(unsafe.Pointer(arcPtr)).FdisabledFillColor) } if (*TArcItem)(unsafe.Pointer(arcPtr)).FfillStipple != uint64(0) { XTk_FreeBitmap(tls, display, (*TArcItem)(unsafe.Pointer(arcPtr)).FfillStipple) } if (*TArcItem)(unsafe.Pointer(arcPtr)).FactiveFillStipple != uint64(0) { XTk_FreeBitmap(tls, display, (*TArcItem)(unsafe.Pointer(arcPtr)).FactiveFillStipple) } if (*TArcItem)(unsafe.Pointer(arcPtr)).FdisabledFillStipple != uint64(0) { XTk_FreeBitmap(tls, display, (*TArcItem)(unsafe.Pointer(arcPtr)).FdisabledFillStipple) } if (*TArcItem)(unsafe.Pointer(arcPtr)).FfillGC != libc.UintptrFromInt32(0) { XTk_FreeGC(tls, display, (*TArcItem)(unsafe.Pointer(arcPtr)).FfillGC) } } /* *-------------------------------------------------------------- * * ComputeArcBbox -- * * This function is invoked to compute the bounding box of all the pixels * that may be drawn as part of an arc. * * Results: * None. * * Side effects: * The fields x1, y1, x2, and y2 are updated in the header for itemPtr. * *-------------------------------------------------------------- */ func _ComputeArcBbox(tls *libc.TLS, canvas TTk_Canvas, arcPtr uintptr) { bp := tls.Alloc(32) defer tls.Free(32) /* Item whose bbox is to be recomputed. */ var state TTk_State var tmp, width float64 var v1, v2, v3, v4, v5 int32 var _ /* center at bp+0 */ [2]float64 var _ /* point at bp+16 */ [2]float64 _, _, _, _, _, _, _, _ = state, tmp, width, v1, v2, v3, v4, v5 state = (*TArcItem)(unsafe.Pointer(arcPtr)).Fheader.Fstate if state == int32(TK_STATE_NULL) { state = (*TTkCanvas)(unsafe.Pointer(canvas)).Fcanvas_state } width = (*TArcItem)(unsafe.Pointer(arcPtr)).Foutline.Fwidth if width < float64(1) { width = float64(1) } if state == int32(TK_STATE_HIDDEN) { v3 = -libc.Int32FromInt32(1) (*TArcItem)(unsafe.Pointer(arcPtr)).Fheader.Fy2 = v3 v2 = v3 (*TArcItem)(unsafe.Pointer(arcPtr)).Fheader.Fy1 = v2 v1 = v2 (*TArcItem)(unsafe.Pointer(arcPtr)).Fheader.Fx2 = v1 (*TArcItem)(unsafe.Pointer(arcPtr)).Fheader.Fx1 = v1 return } else { if (*TTkCanvas)(unsafe.Pointer(canvas)).FcurrentItemPtr == arcPtr { if (*TArcItem)(unsafe.Pointer(arcPtr)).Foutline.FactiveWidth > width { width = (*TArcItem)(unsafe.Pointer(arcPtr)).Foutline.FactiveWidth } } else { if state == int32(TK_STATE_DISABLED) { if (*TArcItem)(unsafe.Pointer(arcPtr)).Foutline.FdisabledWidth > libc.Float64FromInt32(0) { width = (*TArcItem)(unsafe.Pointer(arcPtr)).Foutline.FdisabledWidth } } } } /* * Make sure that the first coordinates are the lowest ones. */ if *(*float64)(unsafe.Pointer(arcPtr + 296 + 1*8)) > *(*float64)(unsafe.Pointer(arcPtr + 296 + 3*8)) { tmp = *(*float64)(unsafe.Pointer(arcPtr + 296 + 3*8)) *(*float64)(unsafe.Pointer(arcPtr + 296 + 3*8)) = *(*float64)(unsafe.Pointer(arcPtr + 296 + 1*8)) *(*float64)(unsafe.Pointer(arcPtr + 296 + 1*8)) = tmp } if *(*float64)(unsafe.Pointer(arcPtr + 296)) > *(*float64)(unsafe.Pointer(arcPtr + 296 + 2*8)) { tmp = *(*float64)(unsafe.Pointer(arcPtr + 296 + 2*8)) *(*float64)(unsafe.Pointer(arcPtr + 296 + 2*8)) = *(*float64)(unsafe.Pointer(arcPtr + 296)) *(*float64)(unsafe.Pointer(arcPtr + 296)) = tmp } _ComputeArcOutline(tls, canvas, arcPtr) /* * To compute the bounding box, start with the bbox formed by the two * endpoints of the arc. Then add in the center of the arc's oval (if * relevant) and the 3-o'clock, 6-o'clock, 9-o'clock, and 12-o'clock * positions, if they are relevant. */ v4 = int32(*(*float64)(unsafe.Pointer(arcPtr + 432))) (*TArcItem)(unsafe.Pointer(arcPtr)).Fheader.Fx2 = v4 (*TArcItem)(unsafe.Pointer(arcPtr)).Fheader.Fx1 = v4 v5 = int32(*(*float64)(unsafe.Pointer(arcPtr + 432 + 1*8))) (*TArcItem)(unsafe.Pointer(arcPtr)).Fheader.Fy2 = v5 (*TArcItem)(unsafe.Pointer(arcPtr)).Fheader.Fy1 = v5 XTkIncludePoint(tls, arcPtr, arcPtr+448) (*(*[2]float64)(unsafe.Pointer(bp)))[0] = (*(*float64)(unsafe.Pointer(arcPtr + 296)) + *(*float64)(unsafe.Pointer(arcPtr + 296 + 2*8))) / libc.Float64FromInt32(2) (*(*[2]float64)(unsafe.Pointer(bp)))[int32(1)] = (*(*float64)(unsafe.Pointer(arcPtr + 296 + 1*8)) + *(*float64)(unsafe.Pointer(arcPtr + 296 + 3*8))) / libc.Float64FromInt32(2) if (*TArcItem)(unsafe.Pointer(arcPtr)).Fstyle == int32(PIESLICE_STYLE) { XTkIncludePoint(tls, arcPtr, bp) } tmp = -(*TArcItem)(unsafe.Pointer(arcPtr)).Fstart if tmp < libc.Float64FromInt32(0) { tmp += float64(360) } if tmp < (*TArcItem)(unsafe.Pointer(arcPtr)).Fextent || tmp-libc.Float64FromInt32(360) > (*TArcItem)(unsafe.Pointer(arcPtr)).Fextent { (*(*[2]float64)(unsafe.Pointer(bp + 16)))[0] = *(*float64)(unsafe.Pointer(arcPtr + 296 + 2*8)) (*(*[2]float64)(unsafe.Pointer(bp + 16)))[int32(1)] = (*(*[2]float64)(unsafe.Pointer(bp)))[int32(1)] XTkIncludePoint(tls, arcPtr, bp+16) } tmp = float64(90) - (*TArcItem)(unsafe.Pointer(arcPtr)).Fstart if tmp < libc.Float64FromInt32(0) { tmp += float64(360) } if tmp < (*TArcItem)(unsafe.Pointer(arcPtr)).Fextent || tmp-libc.Float64FromInt32(360) > (*TArcItem)(unsafe.Pointer(arcPtr)).Fextent { (*(*[2]float64)(unsafe.Pointer(bp + 16)))[0] = (*(*[2]float64)(unsafe.Pointer(bp)))[0] (*(*[2]float64)(unsafe.Pointer(bp + 16)))[int32(1)] = *(*float64)(unsafe.Pointer(arcPtr + 296 + 1*8)) XTkIncludePoint(tls, arcPtr, bp+16) } tmp = float64(180) - (*TArcItem)(unsafe.Pointer(arcPtr)).Fstart if tmp < libc.Float64FromInt32(0) { tmp += float64(360) } if tmp < (*TArcItem)(unsafe.Pointer(arcPtr)).Fextent || tmp-libc.Float64FromInt32(360) > (*TArcItem)(unsafe.Pointer(arcPtr)).Fextent { (*(*[2]float64)(unsafe.Pointer(bp + 16)))[0] = *(*float64)(unsafe.Pointer(arcPtr + 296)) (*(*[2]float64)(unsafe.Pointer(bp + 16)))[int32(1)] = (*(*[2]float64)(unsafe.Pointer(bp)))[int32(1)] XTkIncludePoint(tls, arcPtr, bp+16) } tmp = float64(270) - (*TArcItem)(unsafe.Pointer(arcPtr)).Fstart if tmp < libc.Float64FromInt32(0) { tmp += float64(360) } if tmp < (*TArcItem)(unsafe.Pointer(arcPtr)).Fextent || tmp-libc.Float64FromInt32(360) > (*TArcItem)(unsafe.Pointer(arcPtr)).Fextent { (*(*[2]float64)(unsafe.Pointer(bp + 16)))[0] = (*(*[2]float64)(unsafe.Pointer(bp)))[0] (*(*[2]float64)(unsafe.Pointer(bp + 16)))[int32(1)] = *(*float64)(unsafe.Pointer(arcPtr + 296 + 3*8)) XTkIncludePoint(tls, arcPtr, bp+16) } /* * Lastly, expand by the width of the arc (if the arc's outline is being * drawn) and add one extra pixel just for safety. */ if (*TArcItem)(unsafe.Pointer(arcPtr)).Foutline.Fgc == libc.UintptrFromInt32(0) { tmp = libc.Float64FromInt32(1) } else { tmp = float64(int32((width+libc.Float64FromFloat64(1))/libc.Float64FromFloat64(2) + libc.Float64FromInt32(1))) } (*TArcItem)(unsafe.Pointer(arcPtr)).Fheader.Fx1 -= int32(tmp) (*TArcItem)(unsafe.Pointer(arcPtr)).Fheader.Fy1 -= int32(tmp) (*TArcItem)(unsafe.Pointer(arcPtr)).Fheader.Fx2 += int32(tmp) (*TArcItem)(unsafe.Pointer(arcPtr)).Fheader.Fy2 += int32(tmp) } /* *-------------------------------------------------------------- * * DisplayArc -- * * This function is invoked to draw an arc item in a given drawable. * * Results: * None. * * Side effects: * ItemPtr is drawn in drawable using the transformation information in * canvas. * *-------------------------------------------------------------- */ func _DisplayArc(tls *libc.TLS, canvas TTk_Canvas, itemPtr uintptr, display uintptr, drawable TDrawable, dummy902 int32, dummy903 int32, dummy904 int32, dummy905 int32) { bp := tls.Alloc(32) defer tls.Free(32) var arcPtr, tsoffset uintptr var dashnumber, extent, flags, start int32 var lineWidth float64 var state TTk_State var stipple TPixmap var _ /* cx at bp+16 */ int16 var _ /* cy at bp+18 */ int16 var _ /* h at bp+12 */ int32 var _ /* w at bp+8 */ int32 var _ /* x1 at bp+0 */ int16 var _ /* x2 at bp+4 */ int16 var _ /* y1 at bp+2 */ int16 var _ /* y2 at bp+6 */ int16 _, _, _, _, _, _, _, _, _ = arcPtr, dashnumber, extent, flags, lineWidth, start, state, stipple, tsoffset arcPtr = itemPtr state = (*TTk_Item)(unsafe.Pointer(itemPtr)).Fstate if state == int32(TK_STATE_NULL) { state = (*TTkCanvas)(unsafe.Pointer(canvas)).Fcanvas_state } lineWidth = (*TArcItem)(unsafe.Pointer(arcPtr)).Foutline.Fwidth if lineWidth < float64(1) { lineWidth = float64(1) } dashnumber = (*TArcItem)(unsafe.Pointer(arcPtr)).Foutline.Fdash.Fnumber stipple = (*TArcItem)(unsafe.Pointer(arcPtr)).FfillStipple if (*TTkCanvas)(unsafe.Pointer(canvas)).FcurrentItemPtr == itemPtr { if (*TArcItem)(unsafe.Pointer(arcPtr)).Foutline.FactiveWidth > lineWidth { lineWidth = (*TArcItem)(unsafe.Pointer(arcPtr)).Foutline.FactiveWidth } if (*TArcItem)(unsafe.Pointer(arcPtr)).Foutline.FactiveDash.Fnumber != 0 { dashnumber = (*TArcItem)(unsafe.Pointer(arcPtr)).Foutline.FactiveDash.Fnumber } if (*TArcItem)(unsafe.Pointer(arcPtr)).FactiveFillStipple != uint64(0) { stipple = (*TArcItem)(unsafe.Pointer(arcPtr)).FactiveFillStipple } } else { if state == int32(TK_STATE_DISABLED) { if (*TArcItem)(unsafe.Pointer(arcPtr)).Foutline.FdisabledWidth > libc.Float64FromInt32(0) { lineWidth = (*TArcItem)(unsafe.Pointer(arcPtr)).Foutline.FdisabledWidth } if (*TArcItem)(unsafe.Pointer(arcPtr)).Foutline.FdisabledDash.Fnumber != 0 { dashnumber = (*TArcItem)(unsafe.Pointer(arcPtr)).Foutline.FdisabledDash.Fnumber } if (*TArcItem)(unsafe.Pointer(arcPtr)).FdisabledFillStipple != uint64(0) { stipple = (*TArcItem)(unsafe.Pointer(arcPtr)).FdisabledFillStipple } } } /* * Compute the screen coordinates of the bounding box for the item, plus * integer values for the angles. */ XTk_CanvasDrawableCoords(tls, canvas, *(*float64)(unsafe.Pointer(arcPtr + 296)), *(*float64)(unsafe.Pointer(arcPtr + 296 + 1*8)), bp, bp+2) XTk_CanvasDrawableCoords(tls, canvas, *(*float64)(unsafe.Pointer(arcPtr + 296 + 2*8)), *(*float64)(unsafe.Pointer(arcPtr + 296 + 3*8)), bp+4, bp+6) if int32(*(*int16)(unsafe.Pointer(bp + 4))) <= int32(*(*int16)(unsafe.Pointer(bp))) { *(*int16)(unsafe.Pointer(bp + 4)) = int16(int32(*(*int16)(unsafe.Pointer(bp))) + int32(1)) } if int32(*(*int16)(unsafe.Pointer(bp + 6))) <= int32(*(*int16)(unsafe.Pointer(bp + 2))) { *(*int16)(unsafe.Pointer(bp + 6)) = int16(int32(*(*int16)(unsafe.Pointer(bp + 2))) + int32(1)) } start = int32(float64(libc.Float64FromInt32(64)*(*TArcItem)(unsafe.Pointer(arcPtr)).Fstart) + libc.Float64FromFloat64(0.5)) extent = int32(float64(libc.Float64FromInt32(64)*(*TArcItem)(unsafe.Pointer(arcPtr)).Fextent) + libc.Float64FromFloat64(0.5)) /* * Display filled arc first (if wanted), then outline. If the extent is * zero then don't invoke XFillArc or XDrawArc, since this causes some * window servers to crash and should be a no-op anyway. */ if (*TArcItem)(unsafe.Pointer(arcPtr)).FfillGC != libc.UintptrFromInt32(0) && extent != 0 { if stipple != uint64(0) { *(*int32)(unsafe.Pointer(bp + 8)) = 0 *(*int32)(unsafe.Pointer(bp + 12)) = 0 tsoffset = arcPtr + 356 flags = (*TTk_TSOffset)(unsafe.Pointer(tsoffset)).Fflags if flags&(libc.Int32FromInt32(TK_OFFSET_CENTER)|libc.Int32FromInt32(TK_OFFSET_MIDDLE)) != 0 { XTk_SizeOfBitmap(tls, display, stipple, bp+8, bp+12) if flags&int32(TK_OFFSET_CENTER) != 0 { *(*int32)(unsafe.Pointer(bp + 8)) /= int32(2) } else { *(*int32)(unsafe.Pointer(bp + 8)) = 0 } if flags&int32(TK_OFFSET_MIDDLE) != 0 { *(*int32)(unsafe.Pointer(bp + 12)) /= int32(2) } else { *(*int32)(unsafe.Pointer(bp + 12)) = 0 } } *(*int32)(unsafe.Pointer(tsoffset + 4)) -= *(*int32)(unsafe.Pointer(bp + 8)) *(*int32)(unsafe.Pointer(tsoffset + 8)) -= *(*int32)(unsafe.Pointer(bp + 12)) XTk_CanvasSetOffset(tls, canvas, (*TArcItem)(unsafe.Pointer(arcPtr)).FfillGC, tsoffset) if tsoffset != 0 { *(*int32)(unsafe.Pointer(tsoffset + 4)) += *(*int32)(unsafe.Pointer(bp + 8)) *(*int32)(unsafe.Pointer(tsoffset + 8)) += *(*int32)(unsafe.Pointer(bp + 12)) } } libx11.XXFillArc(tls, display, drawable, (*TArcItem)(unsafe.Pointer(arcPtr)).FfillGC, int32(*(*int16)(unsafe.Pointer(bp))), int32(*(*int16)(unsafe.Pointer(bp + 2))), libc.Uint32FromInt32(int32(*(*int16)(unsafe.Pointer(bp + 4)))-int32(*(*int16)(unsafe.Pointer(bp)))), libc.Uint32FromInt32(int32(*(*int16)(unsafe.Pointer(bp + 6)))-int32(*(*int16)(unsafe.Pointer(bp + 2)))), start, extent) if stipple != uint64(0) { libx11.XXSetTSOrigin(tls, display, (*TArcItem)(unsafe.Pointer(arcPtr)).FfillGC, 0, 0) } } if (*TArcItem)(unsafe.Pointer(arcPtr)).Foutline.Fgc != libc.UintptrFromInt32(0) { XTk_ChangeOutlineGC(tls, canvas, itemPtr, arcPtr+120) if extent != 0 { libx11.XXDrawArc(tls, display, drawable, (*TArcItem)(unsafe.Pointer(arcPtr)).Foutline.Fgc, int32(*(*int16)(unsafe.Pointer(bp))), int32(*(*int16)(unsafe.Pointer(bp + 2))), libc.Uint32FromInt32(int32(*(*int16)(unsafe.Pointer(bp + 4)))-int32(*(*int16)(unsafe.Pointer(bp)))), libc.Uint32FromInt32(int32(*(*int16)(unsafe.Pointer(bp + 6)))-int32(*(*int16)(unsafe.Pointer(bp + 2)))), start, extent) } /* * If the outline width is very thin, don't use polygons to draw the * linear parts of the outline (this often results in nothing being * displayed); just draw lines instead. The same is done if the * outline is dashed, because then polygons don't work. */ if lineWidth < float64(1.5) || dashnumber != 0 { XTk_CanvasDrawableCoords(tls, canvas, *(*float64)(unsafe.Pointer(arcPtr + 432)), *(*float64)(unsafe.Pointer(arcPtr + 432 + 1*8)), bp, bp+2) XTk_CanvasDrawableCoords(tls, canvas, *(*float64)(unsafe.Pointer(arcPtr + 448)), *(*float64)(unsafe.Pointer(arcPtr + 448 + 1*8)), bp+4, bp+6) if (*TArcItem)(unsafe.Pointer(arcPtr)).Fstyle == int32(CHORD_STYLE) { libx11.XXDrawLine(tls, display, drawable, (*TArcItem)(unsafe.Pointer(arcPtr)).Foutline.Fgc, int32(*(*int16)(unsafe.Pointer(bp))), int32(*(*int16)(unsafe.Pointer(bp + 2))), int32(*(*int16)(unsafe.Pointer(bp + 4))), int32(*(*int16)(unsafe.Pointer(bp + 6)))) } else { if (*TArcItem)(unsafe.Pointer(arcPtr)).Fstyle == int32(PIESLICE_STYLE) { XTk_CanvasDrawableCoords(tls, canvas, (*(*float64)(unsafe.Pointer(arcPtr + 296))+*(*float64)(unsafe.Pointer(arcPtr + 296 + 2*8)))/float64(2), (*(*float64)(unsafe.Pointer(arcPtr + 296 + 1*8))+*(*float64)(unsafe.Pointer(arcPtr + 296 + 3*8)))/float64(2), bp+16, bp+18) libx11.XXDrawLine(tls, display, drawable, (*TArcItem)(unsafe.Pointer(arcPtr)).Foutline.Fgc, int32(*(*int16)(unsafe.Pointer(bp + 16))), int32(*(*int16)(unsafe.Pointer(bp + 18))), int32(*(*int16)(unsafe.Pointer(bp))), int32(*(*int16)(unsafe.Pointer(bp + 2)))) libx11.XXDrawLine(tls, display, drawable, (*TArcItem)(unsafe.Pointer(arcPtr)).Foutline.Fgc, int32(*(*int16)(unsafe.Pointer(bp + 16))), int32(*(*int16)(unsafe.Pointer(bp + 18))), int32(*(*int16)(unsafe.Pointer(bp + 4))), int32(*(*int16)(unsafe.Pointer(bp + 6)))) } } } else { if (*TArcItem)(unsafe.Pointer(arcPtr)).Fstyle == int32(CHORD_STYLE) { XTkFillPolygon(tls, canvas, (*TArcItem)(unsafe.Pointer(arcPtr)).FoutlinePtr, int32(CHORD_OUTLINE_PTS), display, drawable, (*TArcItem)(unsafe.Pointer(arcPtr)).Foutline.Fgc, libc.UintptrFromInt32(0)) } else { if (*TArcItem)(unsafe.Pointer(arcPtr)).Fstyle == int32(PIESLICE_STYLE) { XTkFillPolygon(tls, canvas, (*TArcItem)(unsafe.Pointer(arcPtr)).FoutlinePtr, int32(PIE_OUTLINE1_PTS), display, drawable, (*TArcItem)(unsafe.Pointer(arcPtr)).Foutline.Fgc, libc.UintptrFromInt32(0)) XTkFillPolygon(tls, canvas, (*TArcItem)(unsafe.Pointer(arcPtr)).FoutlinePtr+uintptr(libc.Int32FromInt32(2)*libc.Int32FromInt32(PIE_OUTLINE1_PTS))*8, int32(PIE_OUTLINE2_PTS), display, drawable, (*TArcItem)(unsafe.Pointer(arcPtr)).Foutline.Fgc, libc.UintptrFromInt32(0)) } } } XTk_ResetOutlineGC(tls, canvas, itemPtr, arcPtr+120) } } /* *-------------------------------------------------------------- * * ArcToPoint -- * * Computes the distance from a given point to a given arc, in canvas * units. * * Results: * The return value is 0 if the point whose x and y coordinates are * coordPtr[0] and coordPtr[1] is inside the arc. If the point isn't * inside the arc then the return value is the distance from the point to * the arc. If itemPtr is filled, then anywhere in the interior is * considered "inside"; if itemPtr isn't filled, then "inside" means only * the area occupied by the outline. * * Side effects: * None. * *-------------------------------------------------------------- */ func _ArcToPoint(tls *libc.TLS, canvas TTk_Canvas, itemPtr uintptr, pointPtr uintptr) (r float64) { bp := tls.Alloc(80) defer tls.Free(80) /* Pointer to x and y coordinates. */ var angleInRange, filled int32 var arcPtr uintptr var diff, dist, newDist, pointAngle, polyDist, t1, t2, width, v1, v2 float64 var state TTk_State var _ /* poly at bp+16 */ [8]float64 var _ /* vertex at bp+0 */ [2]float64 _, _, _, _, _, _, _, _, _, _, _, _, _, _ = angleInRange, arcPtr, diff, dist, filled, newDist, pointAngle, polyDist, state, t1, t2, width, v1, v2 arcPtr = itemPtr state = (*TTk_Item)(unsafe.Pointer(itemPtr)).Fstate if state == int32(TK_STATE_NULL) { state = (*TTkCanvas)(unsafe.Pointer(canvas)).Fcanvas_state } width = (*TArcItem)(unsafe.Pointer(arcPtr)).Foutline.Fwidth if (*TTkCanvas)(unsafe.Pointer(canvas)).FcurrentItemPtr == itemPtr { if (*TArcItem)(unsafe.Pointer(arcPtr)).Foutline.FactiveWidth > width { width = (*TArcItem)(unsafe.Pointer(arcPtr)).Foutline.FactiveWidth } } else { if state == int32(TK_STATE_DISABLED) { if (*TArcItem)(unsafe.Pointer(arcPtr)).Foutline.FdisabledWidth > libc.Float64FromInt32(0) { width = (*TArcItem)(unsafe.Pointer(arcPtr)).Foutline.FdisabledWidth } } } /* * See if the point is within the angular range of the arc. Remember, X * angles are backwards from the way we'd normally think of them. Also, * compensate for any eccentricity of the oval. */ (*(*[2]float64)(unsafe.Pointer(bp)))[0] = (*(*float64)(unsafe.Pointer(arcPtr + 296)) + *(*float64)(unsafe.Pointer(arcPtr + 296 + 2*8))) / float64(2) (*(*[2]float64)(unsafe.Pointer(bp)))[int32(1)] = (*(*float64)(unsafe.Pointer(arcPtr + 296 + 1*8)) + *(*float64)(unsafe.Pointer(arcPtr + 296 + 3*8))) / float64(2) t1 = *(*float64)(unsafe.Pointer(arcPtr + 296 + 3*8)) - *(*float64)(unsafe.Pointer(arcPtr + 296 + 1*8)) if t1 != float64(0) { t1 = (*(*float64)(unsafe.Pointer(pointPtr + 1*8)) - (*(*[2]float64)(unsafe.Pointer(bp)))[int32(1)]) / t1 } t2 = *(*float64)(unsafe.Pointer(arcPtr + 296 + 2*8)) - *(*float64)(unsafe.Pointer(arcPtr + 296)) if t2 != float64(0) { t2 = (*(*float64)(unsafe.Pointer(pointPtr)) - (*(*[2]float64)(unsafe.Pointer(bp)))[0]) / t2 } if t1 == float64(0) && t2 == float64(0) { pointAngle = libc.Float64FromInt32(0) } else { pointAngle = float64(-libc.Xatan2(tls, t1, t2)*libc.Float64FromInt32(180)) / float64(3.141592653589793) } diff = pointAngle - (*TArcItem)(unsafe.Pointer(arcPtr)).Fstart diff -= float64(float64(int32(diff/libc.Float64FromFloat64(360))) * float64(360)) if diff < libc.Float64FromInt32(0) { diff += float64(360) } angleInRange = libc.BoolInt32(diff <= (*TArcItem)(unsafe.Pointer(arcPtr)).Fextent || (*TArcItem)(unsafe.Pointer(arcPtr)).Fextent < libc.Float64FromInt32(0) && diff-float64(360) >= (*TArcItem)(unsafe.Pointer(arcPtr)).Fextent) /* * Now perform different tests depending on what kind of arc we're dealing * with. */ if (*TArcItem)(unsafe.Pointer(arcPtr)).Fstyle == int32(ARC_STYLE) { if angleInRange != 0 { return XTkOvalToPoint(tls, arcPtr+296, width, 0, pointPtr) } dist = libc.X__builtin_hypot(tls, *(*float64)(unsafe.Pointer(pointPtr))-*(*float64)(unsafe.Pointer(arcPtr + 432)), *(*float64)(unsafe.Pointer(pointPtr + 1*8))-*(*float64)(unsafe.Pointer(arcPtr + 432 + 1*8))) newDist = libc.X__builtin_hypot(tls, *(*float64)(unsafe.Pointer(pointPtr))-*(*float64)(unsafe.Pointer(arcPtr + 448)), *(*float64)(unsafe.Pointer(pointPtr + 1*8))-*(*float64)(unsafe.Pointer(arcPtr + 448 + 1*8))) if newDist < dist { return newDist } return dist } if (*TArcItem)(unsafe.Pointer(arcPtr)).FfillGC != libc.UintptrFromInt32(0) || (*TArcItem)(unsafe.Pointer(arcPtr)).Foutline.Fgc == libc.UintptrFromInt32(0) { filled = int32(1) } else { filled = 0 } if (*TArcItem)(unsafe.Pointer(arcPtr)).Foutline.Fgc == libc.UintptrFromInt32(0) { width = float64(0) } if (*TArcItem)(unsafe.Pointer(arcPtr)).Fstyle == int32(PIESLICE_STYLE) { if width > float64(1) { dist = XTkPolygonToPoint(tls, (*TArcItem)(unsafe.Pointer(arcPtr)).FoutlinePtr, int32(PIE_OUTLINE1_PTS), pointPtr) newDist = XTkPolygonToPoint(tls, (*TArcItem)(unsafe.Pointer(arcPtr)).FoutlinePtr+uintptr(libc.Int32FromInt32(2)*libc.Int32FromInt32(PIE_OUTLINE1_PTS))*8, int32(PIE_OUTLINE2_PTS), pointPtr) } else { dist = XTkLineToPoint(tls, bp, arcPtr+432, pointPtr) newDist = XTkLineToPoint(tls, bp, arcPtr+448, pointPtr) } if newDist < dist { dist = newDist } if angleInRange != 0 { newDist = XTkOvalToPoint(tls, arcPtr+296, width, filled, pointPtr) if newDist < dist { dist = newDist } } return dist } /* * This is a chord-style arc. We have to deal specially with the * triangular piece that represents the difference between a chord-style * arc and a pie-slice arc (for small angles this piece is excluded here * where it would be included for pie slices; for large angles the piece * is included here but would be excluded for pie slices). */ if width > float64(1) { dist = XTkPolygonToPoint(tls, (*TArcItem)(unsafe.Pointer(arcPtr)).FoutlinePtr, int32(CHORD_OUTLINE_PTS), pointPtr) } else { dist = XTkLineToPoint(tls, arcPtr+432, arcPtr+448, pointPtr) } v1 = (*(*[2]float64)(unsafe.Pointer(bp)))[0] (*(*[8]float64)(unsafe.Pointer(bp + 16)))[int32(6)] = v1 (*(*[8]float64)(unsafe.Pointer(bp + 16)))[0] = v1 v2 = (*(*[2]float64)(unsafe.Pointer(bp)))[int32(1)] (*(*[8]float64)(unsafe.Pointer(bp + 16)))[int32(7)] = v2 (*(*[8]float64)(unsafe.Pointer(bp + 16)))[int32(1)] = v2 (*(*[8]float64)(unsafe.Pointer(bp + 16)))[int32(2)] = *(*float64)(unsafe.Pointer(arcPtr + 432)) (*(*[8]float64)(unsafe.Pointer(bp + 16)))[int32(3)] = *(*float64)(unsafe.Pointer(arcPtr + 432 + 1*8)) (*(*[8]float64)(unsafe.Pointer(bp + 16)))[int32(4)] = *(*float64)(unsafe.Pointer(arcPtr + 448)) (*(*[8]float64)(unsafe.Pointer(bp + 16)))[int32(5)] = *(*float64)(unsafe.Pointer(arcPtr + 448 + 1*8)) polyDist = XTkPolygonToPoint(tls, bp+16, int32(4), pointPtr) if angleInRange != 0 { if (*TArcItem)(unsafe.Pointer(arcPtr)).Fextent < -libc.Float64FromFloat64(180) || (*TArcItem)(unsafe.Pointer(arcPtr)).Fextent > float64(180) || polyDist > float64(0) { newDist = XTkOvalToPoint(tls, arcPtr+296, width, filled, pointPtr) if newDist < dist { dist = newDist } } } else { if (*TArcItem)(unsafe.Pointer(arcPtr)).Fextent < -libc.Float64FromFloat64(180) || (*TArcItem)(unsafe.Pointer(arcPtr)).Fextent > float64(180) { if filled != 0 && polyDist < dist { dist = polyDist } } } return dist } /* *-------------------------------------------------------------- * * ArcToArea -- * * This function is called to determine whether an item lies entirely * inside, entirely outside, or overlapping a given area. * * Results: * -1 is returned if the item is entirely outside the area given by * rectPtr, 0 if it overlaps, and 1 if it is entirely inside the given * area. * * Side effects: * None. * *-------------------------------------------------------------- */ func _ArcToArea(tls *libc.TLS, canvas TTk_Canvas, itemPtr uintptr, rectPtr uintptr) (r int32) { bp := tls.Alloc(176) defer tls.Free(176) /* Pointer to array of four coordinates (x1, * y1, x2, y2) describing rectangular area. */ var angle, rx, ry, tmp, width float64 var arcPtr, pointPtr uintptr var filled, inside, newInside, numPoints int32 var state TTk_State var tRect [4]float64 var _ /* center at bp+0 */ [2]float64 var _ /* points at bp+16 */ [20]float64 _, _, _, _, _, _, _, _, _, _, _, _, _ = angle, arcPtr, filled, inside, newInside, numPoints, pointPtr, rx, ry, state, tRect, tmp, width arcPtr = itemPtr state = (*TTk_Item)(unsafe.Pointer(itemPtr)).Fstate if state == int32(TK_STATE_NULL) { state = (*TTkCanvas)(unsafe.Pointer(canvas)).Fcanvas_state } width = (*TArcItem)(unsafe.Pointer(arcPtr)).Foutline.Fwidth if (*TTkCanvas)(unsafe.Pointer(canvas)).FcurrentItemPtr == itemPtr { if (*TArcItem)(unsafe.Pointer(arcPtr)).Foutline.FactiveWidth > width { width = (*TArcItem)(unsafe.Pointer(arcPtr)).Foutline.FactiveWidth } } else { if state == int32(TK_STATE_DISABLED) { if (*TArcItem)(unsafe.Pointer(arcPtr)).Foutline.FdisabledWidth > libc.Float64FromInt32(0) { width = (*TArcItem)(unsafe.Pointer(arcPtr)).Foutline.FdisabledWidth } } } if (*TArcItem)(unsafe.Pointer(arcPtr)).FfillGC != libc.UintptrFromInt32(0) || (*TArcItem)(unsafe.Pointer(arcPtr)).Foutline.Fgc == libc.UintptrFromInt32(0) { filled = int32(1) } else { filled = 0 } if (*TArcItem)(unsafe.Pointer(arcPtr)).Foutline.Fgc == libc.UintptrFromInt32(0) { width = float64(0) } /* * Transform both the arc and the rectangle so that the arc's oval is * centered on the origin. */ (*(*[2]float64)(unsafe.Pointer(bp)))[0] = (*(*float64)(unsafe.Pointer(arcPtr + 296)) + *(*float64)(unsafe.Pointer(arcPtr + 296 + 2*8))) / float64(2) (*(*[2]float64)(unsafe.Pointer(bp)))[int32(1)] = (*(*float64)(unsafe.Pointer(arcPtr + 296 + 1*8)) + *(*float64)(unsafe.Pointer(arcPtr + 296 + 3*8))) / float64(2) tRect[0] = *(*float64)(unsafe.Pointer(rectPtr)) - (*(*[2]float64)(unsafe.Pointer(bp)))[0] tRect[int32(1)] = *(*float64)(unsafe.Pointer(rectPtr + 1*8)) - (*(*[2]float64)(unsafe.Pointer(bp)))[int32(1)] tRect[int32(2)] = *(*float64)(unsafe.Pointer(rectPtr + 2*8)) - (*(*[2]float64)(unsafe.Pointer(bp)))[0] tRect[int32(3)] = *(*float64)(unsafe.Pointer(rectPtr + 3*8)) - (*(*[2]float64)(unsafe.Pointer(bp)))[int32(1)] rx = *(*float64)(unsafe.Pointer(arcPtr + 296 + 2*8)) - (*(*[2]float64)(unsafe.Pointer(bp)))[0] + width/float64(2) ry = *(*float64)(unsafe.Pointer(arcPtr + 296 + 3*8)) - (*(*[2]float64)(unsafe.Pointer(bp)))[int32(1)] + width/float64(2) /* * Find the extreme points of the arc and see whether these are all inside * the rectangle (in which case we're done), partly in and partly out (in * which case we're done), or all outside (in which case we have more work * to do). The extreme points include the following, which are checked in * order: * * 1. The outside points of the arc, corresponding to start and extent. * 2. The center of the arc (but only in pie-slice mode). * 3. The 12, 3, 6, and 9-o'clock positions (but only if the arc includes * those angles). */ pointPtr = bp + 16 angle = float64(-(*TArcItem)(unsafe.Pointer(arcPtr)).Fstart * (libc.Float64FromFloat64(3.141592653589793) / libc.Float64FromFloat64(180))) *(*float64)(unsafe.Pointer(pointPtr)) = float64(rx * libc.Xcos(tls, angle)) *(*float64)(unsafe.Pointer(pointPtr + 1*8)) = float64(ry * libc.Xsin(tls, angle)) angle += float64(-(*TArcItem)(unsafe.Pointer(arcPtr)).Fextent * (libc.Float64FromFloat64(3.141592653589793) / libc.Float64FromFloat64(180))) *(*float64)(unsafe.Pointer(pointPtr + 2*8)) = float64(rx * libc.Xcos(tls, angle)) *(*float64)(unsafe.Pointer(pointPtr + 3*8)) = float64(ry * libc.Xsin(tls, angle)) numPoints = int32(2) pointPtr += uintptr(4) * 8 if (*TArcItem)(unsafe.Pointer(arcPtr)).Fstyle == int32(PIESLICE_STYLE) && (*TArcItem)(unsafe.Pointer(arcPtr)).Fextent < float64(180) { *(*float64)(unsafe.Pointer(pointPtr)) = float64(0) *(*float64)(unsafe.Pointer(pointPtr + 1*8)) = float64(0) numPoints++ pointPtr += uintptr(2) * 8 } tmp = -(*TArcItem)(unsafe.Pointer(arcPtr)).Fstart if tmp < libc.Float64FromInt32(0) { tmp += float64(360) } if tmp < (*TArcItem)(unsafe.Pointer(arcPtr)).Fextent || tmp-libc.Float64FromInt32(360) > (*TArcItem)(unsafe.Pointer(arcPtr)).Fextent { *(*float64)(unsafe.Pointer(pointPtr)) = rx *(*float64)(unsafe.Pointer(pointPtr + 1*8)) = float64(0) numPoints++ pointPtr += uintptr(2) * 8 } tmp = float64(90) - (*TArcItem)(unsafe.Pointer(arcPtr)).Fstart if tmp < libc.Float64FromInt32(0) { tmp += float64(360) } if tmp < (*TArcItem)(unsafe.Pointer(arcPtr)).Fextent || tmp-libc.Float64FromInt32(360) > (*TArcItem)(unsafe.Pointer(arcPtr)).Fextent { *(*float64)(unsafe.Pointer(pointPtr)) = float64(0) *(*float64)(unsafe.Pointer(pointPtr + 1*8)) = -ry numPoints++ pointPtr += uintptr(2) * 8 } tmp = float64(180) - (*TArcItem)(unsafe.Pointer(arcPtr)).Fstart if tmp < libc.Float64FromInt32(0) { tmp += float64(360) } if tmp < (*TArcItem)(unsafe.Pointer(arcPtr)).Fextent || tmp-libc.Float64FromInt32(360) > (*TArcItem)(unsafe.Pointer(arcPtr)).Fextent { *(*float64)(unsafe.Pointer(pointPtr)) = -rx *(*float64)(unsafe.Pointer(pointPtr + 1*8)) = float64(0) numPoints++ pointPtr += uintptr(2) * 8 } tmp = float64(270) - (*TArcItem)(unsafe.Pointer(arcPtr)).Fstart if tmp < libc.Float64FromInt32(0) { tmp += float64(360) } if tmp < (*TArcItem)(unsafe.Pointer(arcPtr)).Fextent || tmp-libc.Float64FromInt32(360) > (*TArcItem)(unsafe.Pointer(arcPtr)).Fextent { *(*float64)(unsafe.Pointer(pointPtr)) = float64(0) *(*float64)(unsafe.Pointer(pointPtr + 1*8)) = ry numPoints++ } /* * Now that we've located the extreme points, loop through them all to see * which are inside the rectangle. */ inside = libc.BoolInt32((*(*[20]float64)(unsafe.Pointer(bp + 16)))[0] > tRect[0] && (*(*[20]float64)(unsafe.Pointer(bp + 16)))[0] < tRect[int32(2)] && (*(*[20]float64)(unsafe.Pointer(bp + 16)))[int32(1)] > tRect[int32(1)] && (*(*[20]float64)(unsafe.Pointer(bp + 16)))[int32(1)] < tRect[int32(3)]) pointPtr = bp + 16 + uintptr(2)*8 for { if !(numPoints > int32(1)) { break } newInside = libc.BoolInt32(*(*float64)(unsafe.Pointer(pointPtr)) > tRect[0] && *(*float64)(unsafe.Pointer(pointPtr)) < tRect[int32(2)] && *(*float64)(unsafe.Pointer(pointPtr + 1*8)) > tRect[int32(1)] && *(*float64)(unsafe.Pointer(pointPtr + 1*8)) < tRect[int32(3)]) if newInside != inside { return 0 } goto _1 _1: ; pointPtr += uintptr(2) * 8 numPoints-- } if inside != 0 { return int32(1) } /* * So far, oval appears to be outside rectangle, but can't yet tell for * sure. Next, test each of the four sides of the rectangle against the * bounding region for the arc. If any intersections are found, then * return "overlapping". First, test against the polygon(s) forming the * sides of a chord or pie-slice. */ if (*TArcItem)(unsafe.Pointer(arcPtr)).Fstyle == int32(PIESLICE_STYLE) { if width >= float64(1) { if XTkPolygonToArea(tls, (*TArcItem)(unsafe.Pointer(arcPtr)).FoutlinePtr, int32(PIE_OUTLINE1_PTS), rectPtr) != -int32(1) { return 0 } if XTkPolygonToArea(tls, (*TArcItem)(unsafe.Pointer(arcPtr)).FoutlinePtr+uintptr(libc.Int32FromInt32(2)*libc.Int32FromInt32(PIE_OUTLINE1_PTS))*8, int32(PIE_OUTLINE2_PTS), rectPtr) != -int32(1) { return 0 } } else { if XTkLineToArea(tls, bp, arcPtr+432, rectPtr) != -int32(1) || XTkLineToArea(tls, bp, arcPtr+448, rectPtr) != -int32(1) { return 0 } } } else { if (*TArcItem)(unsafe.Pointer(arcPtr)).Fstyle == int32(CHORD_STYLE) { if width >= float64(1) { if XTkPolygonToArea(tls, (*TArcItem)(unsafe.Pointer(arcPtr)).FoutlinePtr, int32(CHORD_OUTLINE_PTS), rectPtr) != -int32(1) { return 0 } } else { if XTkLineToArea(tls, arcPtr+432, arcPtr+448, rectPtr) != -int32(1) { return 0 } } } } /* * Next check for overlap between each of the four sides and the outer * perimiter of the arc. If the arc isn't filled, then also check the * inner perimeter of the arc. */ if _HorizLineToArc(tls, tRect[0], tRect[int32(2)], tRect[int32(1)], rx, ry, (*TArcItem)(unsafe.Pointer(arcPtr)).Fstart, (*TArcItem)(unsafe.Pointer(arcPtr)).Fextent) != 0 || _HorizLineToArc(tls, tRect[0], tRect[int32(2)], tRect[int32(3)], rx, ry, (*TArcItem)(unsafe.Pointer(arcPtr)).Fstart, (*TArcItem)(unsafe.Pointer(arcPtr)).Fextent) != 0 || _VertLineToArc(tls, tRect[0], tRect[int32(1)], tRect[int32(3)], rx, ry, (*TArcItem)(unsafe.Pointer(arcPtr)).Fstart, (*TArcItem)(unsafe.Pointer(arcPtr)).Fextent) != 0 || _VertLineToArc(tls, tRect[int32(2)], tRect[int32(1)], tRect[int32(3)], rx, ry, (*TArcItem)(unsafe.Pointer(arcPtr)).Fstart, (*TArcItem)(unsafe.Pointer(arcPtr)).Fextent) != 0 { return 0 } if width > float64(1) && !(filled != 0) { rx -= width ry -= width if _HorizLineToArc(tls, tRect[0], tRect[int32(2)], tRect[int32(1)], rx, ry, (*TArcItem)(unsafe.Pointer(arcPtr)).Fstart, (*TArcItem)(unsafe.Pointer(arcPtr)).Fextent) != 0 || _HorizLineToArc(tls, tRect[0], tRect[int32(2)], tRect[int32(3)], rx, ry, (*TArcItem)(unsafe.Pointer(arcPtr)).Fstart, (*TArcItem)(unsafe.Pointer(arcPtr)).Fextent) != 0 || _VertLineToArc(tls, tRect[0], tRect[int32(1)], tRect[int32(3)], rx, ry, (*TArcItem)(unsafe.Pointer(arcPtr)).Fstart, (*TArcItem)(unsafe.Pointer(arcPtr)).Fextent) != 0 || _VertLineToArc(tls, tRect[int32(2)], tRect[int32(1)], tRect[int32(3)], rx, ry, (*TArcItem)(unsafe.Pointer(arcPtr)).Fstart, (*TArcItem)(unsafe.Pointer(arcPtr)).Fextent) != 0 { return 0 } } /* * The arc still appears to be totally disjoint from the rectangle, but * it's also possible that the rectangle is totally inside the arc. Do one * last check, which is to check one point of the rectangle to see if it's * inside the arc. If it is, we've got overlap. If it isn't, the arc's * really outside the rectangle. */ if _ArcToPoint(tls, canvas, itemPtr, rectPtr) == float64(0) { return 0 } return -int32(1) } /* *-------------------------------------------------------------- * * ScaleArc -- * * This function is invoked to rescale an arc item. * * Results: * None. * * Side effects: * The arc referred to by itemPtr is rescaled so that the following * transformation is applied to all point coordinates: * x' = originX + scaleX*(x-originX) * y' = originY + scaleY*(y-originY) * *-------------------------------------------------------------- */ func _ScaleArc(tls *libc.TLS, canvas TTk_Canvas, itemPtr uintptr, originX float64, originY float64, scaleX float64, scaleY float64) { /* Amount to scale in Y direction. */ var arcPtr uintptr _ = arcPtr arcPtr = itemPtr *(*float64)(unsafe.Pointer(arcPtr + 296)) = originX + float64(scaleX*(*(*float64)(unsafe.Pointer(arcPtr + 296))-originX)) *(*float64)(unsafe.Pointer(arcPtr + 296 + 1*8)) = originY + float64(scaleY*(*(*float64)(unsafe.Pointer(arcPtr + 296 + 1*8))-originY)) *(*float64)(unsafe.Pointer(arcPtr + 296 + 2*8)) = originX + float64(scaleX*(*(*float64)(unsafe.Pointer(arcPtr + 296 + 2*8))-originX)) *(*float64)(unsafe.Pointer(arcPtr + 296 + 3*8)) = originY + float64(scaleY*(*(*float64)(unsafe.Pointer(arcPtr + 296 + 3*8))-originY)) _ComputeArcBbox(tls, canvas, arcPtr) } /* *-------------------------------------------------------------- * * RotateArc -- * * This function is called to rotate an arc by a given amount. * * Results: * None. * * Side effects: * The position of the arc is rotated by angleRad radians about (originX, * originY), and the bounding box is updated in the generic part of the * item structure. * *-------------------------------------------------------------- */ func _RotateArc(tls *libc.TLS, canvas TTk_Canvas, itemPtr uintptr, originX float64, originY float64, angleRad float64) { bp := tls.Alloc(16) defer tls.Free(16) var arcPtr uintptr var oldX, oldY, v1, v2 float64 var _ /* newX at bp+0 */ float64 var _ /* newY at bp+8 */ float64 _, _, _, _, _ = arcPtr, oldX, oldY, v1, v2 arcPtr = itemPtr /* * Compute the centre of the box, then rotate that about the origin. */ v1 = (*(*float64)(unsafe.Pointer(arcPtr + 296)) + *(*float64)(unsafe.Pointer(arcPtr + 296 + 2*8))) / libc.Float64FromFloat64(2) oldX = v1 *(*float64)(unsafe.Pointer(bp)) = v1 v2 = (*(*float64)(unsafe.Pointer(arcPtr + 296 + 1*8)) + *(*float64)(unsafe.Pointer(arcPtr + 296 + 3*8))) / libc.Float64FromFloat64(2) oldY = v2 *(*float64)(unsafe.Pointer(bp + 8)) = v2 XTkRotatePoint(tls, originX, originY, libc.Xsin(tls, angleRad), libc.Xcos(tls, angleRad), bp, bp+8) /* * Apply the translation to the box. */ *(*float64)(unsafe.Pointer(arcPtr + 296)) += *(*float64)(unsafe.Pointer(bp)) - oldX *(*float64)(unsafe.Pointer(arcPtr + 296 + 1*8)) += *(*float64)(unsafe.Pointer(bp + 8)) - oldY *(*float64)(unsafe.Pointer(arcPtr + 296 + 2*8)) += *(*float64)(unsafe.Pointer(bp)) - oldX *(*float64)(unsafe.Pointer(arcPtr + 296 + 3*8)) += *(*float64)(unsafe.Pointer(bp + 8)) - oldY /* * TODO: update the arc endpoints? */ _ComputeArcBbox(tls, canvas, arcPtr) } /* *-------------------------------------------------------------- * * TranslateArc -- * * This function is called to move an arc by a given amount. * * Results: * None. * * Side effects: * The position of the arc is offset by (xDelta, yDelta), and the * bounding box is updated in the generic part of the item structure. * *-------------------------------------------------------------- */ func _TranslateArc(tls *libc.TLS, canvas TTk_Canvas, itemPtr uintptr, deltaX float64, deltaY float64) { var arcPtr uintptr _ = arcPtr arcPtr = itemPtr *(*float64)(unsafe.Pointer(arcPtr + 296)) += deltaX *(*float64)(unsafe.Pointer(arcPtr + 296 + 1*8)) += deltaY *(*float64)(unsafe.Pointer(arcPtr + 296 + 2*8)) += deltaX *(*float64)(unsafe.Pointer(arcPtr + 296 + 3*8)) += deltaY _ComputeArcBbox(tls, canvas, arcPtr) } /* *-------------------------------------------------------------- * * ComputeArcOutline -- * * This function creates a polygon describing everything in the outline * for an arc except what's in the curved part. For a "pie slice" arc * this is a V-shaped chunk, and for a "chord" arc this is a linear chunk * (with cutaway corners). For "arc" arcs, this stuff isn't relevant. * * Results: * None. * * Side effects: * The information at arcPtr->outlinePtr gets modified, and storage for * arcPtr->outlinePtr may be allocated or freed. * *-------------------------------------------------------------- */ func _ComputeArcOutline(tls *libc.TLS, canvas TTk_Canvas, arcPtr uintptr) { bp := tls.Alloc(16) defer tls.Free(16) /* Information about arc. */ var angle, boxHeight, boxWidth, cos1, cos2, halfWidth, sin1, sin2, width, v1, v2 float64 var corner1, corner2 [2]float64 var outlinePtr uintptr var state TTk_State var _ /* vertex at bp+0 */ [2]float64 _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = angle, boxHeight, boxWidth, corner1, corner2, cos1, cos2, halfWidth, outlinePtr, sin1, sin2, state, width, v1, v2 state = (*TArcItem)(unsafe.Pointer(arcPtr)).Fheader.Fstate /* * Make sure that the outlinePtr array is large enough to hold either a * chord or pie-slice outline. */ if (*TArcItem)(unsafe.Pointer(arcPtr)).FnumOutlinePoints == 0 { (*TArcItem)(unsafe.Pointer(arcPtr)).FoutlinePtr = libtcl9_0.XTcl_Alloc(tls, libc.Uint64FromInt32(26)*libc.Uint64FromInt64(8)) (*TArcItem)(unsafe.Pointer(arcPtr)).FnumOutlinePoints = int32(22) } outlinePtr = (*TArcItem)(unsafe.Pointer(arcPtr)).FoutlinePtr if state == int32(TK_STATE_NULL) { state = (*TTkCanvas)(unsafe.Pointer(canvas)).Fcanvas_state } /* * First compute the two points that lie at the centers of the ends of the * curved arc segment, which are marked with X's in the figure below: * * * * * * * * * * * * * * * * * * * * * * * * * X * * X * * The code is tricky because the arc can be ovular in shape. It computes * the position for a unit circle, and then scales to fit the shape of the * arc's bounding box. * * Also, watch out because angles go counter-clockwise like you might * expect, but the y-coordinate system is inverted. To handle this, just * negate the angles in all the computations. */ boxWidth = *(*float64)(unsafe.Pointer(arcPtr + 296 + 2*8)) - *(*float64)(unsafe.Pointer(arcPtr + 296)) boxHeight = *(*float64)(unsafe.Pointer(arcPtr + 296 + 3*8)) - *(*float64)(unsafe.Pointer(arcPtr + 296 + 1*8)) angle = float64(-(*TArcItem)(unsafe.Pointer(arcPtr)).Fstart*float64(3.141592653589793)) / float64(180) sin1 = libc.Xsin(tls, angle) cos1 = libc.Xcos(tls, angle) angle -= float64((*TArcItem)(unsafe.Pointer(arcPtr)).Fextent*float64(3.141592653589793)) / float64(180) sin2 = libc.Xsin(tls, angle) cos2 = libc.Xcos(tls, angle) (*(*[2]float64)(unsafe.Pointer(bp)))[0] = (*(*float64)(unsafe.Pointer(arcPtr + 296)) + *(*float64)(unsafe.Pointer(arcPtr + 296 + 2*8))) / float64(2) (*(*[2]float64)(unsafe.Pointer(bp)))[int32(1)] = (*(*float64)(unsafe.Pointer(arcPtr + 296 + 1*8)) + *(*float64)(unsafe.Pointer(arcPtr + 296 + 3*8))) / float64(2) *(*float64)(unsafe.Pointer(arcPtr + 432)) = (*(*[2]float64)(unsafe.Pointer(bp)))[0] + float64(cos1*boxWidth)/float64(2) *(*float64)(unsafe.Pointer(arcPtr + 432 + 1*8)) = (*(*[2]float64)(unsafe.Pointer(bp)))[int32(1)] + float64(sin1*boxHeight)/float64(2) *(*float64)(unsafe.Pointer(arcPtr + 448)) = (*(*[2]float64)(unsafe.Pointer(bp)))[0] + float64(cos2*boxWidth)/float64(2) *(*float64)(unsafe.Pointer(arcPtr + 448 + 1*8)) = (*(*[2]float64)(unsafe.Pointer(bp)))[int32(1)] + float64(sin2*boxHeight)/float64(2) /* * Next compute the "outermost corners" of the arc, which are marked with * X's in the figure below: * * * * * * * * * * * * * * * * * * * X * * X * * * * * The code below is tricky because it has to handle eccentricity in the * shape of the oval. The key in the code below is to realize that the * slope of the line from arcPtr->center1 to corner1 is (boxWidth*sin1) * divided by (boxHeight*cos1), and similarly for arcPtr->center2 and * corner2. These formulas can be computed from the formula for the oval. */ width = (*TArcItem)(unsafe.Pointer(arcPtr)).Foutline.Fwidth if (*TTkCanvas)(unsafe.Pointer(canvas)).FcurrentItemPtr == arcPtr { if (*TArcItem)(unsafe.Pointer(arcPtr)).Foutline.FactiveWidth > (*TArcItem)(unsafe.Pointer(arcPtr)).Foutline.Fwidth { width = (*TArcItem)(unsafe.Pointer(arcPtr)).Foutline.FactiveWidth } } else { if state == int32(TK_STATE_DISABLED) { if (*TArcItem)(unsafe.Pointer(arcPtr)).Foutline.FdisabledWidth > (*TArcItem)(unsafe.Pointer(arcPtr)).Foutline.Fwidth { width = (*TArcItem)(unsafe.Pointer(arcPtr)).Foutline.FdisabledWidth } } } halfWidth = width / float64(2) if float64(boxWidth*sin1) == float64(0) && float64(boxHeight*cos1) == float64(0) { angle = float64(0) } else { angle = libc.Xatan2(tls, float64(boxWidth*sin1), float64(boxHeight*cos1)) } corner1[0] = *(*float64)(unsafe.Pointer(arcPtr + 432)) + float64(libc.Xcos(tls, angle)*halfWidth) corner1[int32(1)] = *(*float64)(unsafe.Pointer(arcPtr + 432 + 1*8)) + float64(libc.Xsin(tls, angle)*halfWidth) if float64(boxWidth*sin2) == float64(0) && float64(boxHeight*cos2) == float64(0) { angle = float64(0) } else { angle = libc.Xatan2(tls, float64(boxWidth*sin2), float64(boxHeight*cos2)) } corner2[0] = *(*float64)(unsafe.Pointer(arcPtr + 448)) + float64(libc.Xcos(tls, angle)*halfWidth) corner2[int32(1)] = *(*float64)(unsafe.Pointer(arcPtr + 448 + 1*8)) + float64(libc.Xsin(tls, angle)*halfWidth) /* * For a chord outline, generate a six-sided polygon with three points for * each end of the chord. The first and third points for each end are butt * points generated on either side of the center point. The second point * is the corner point. */ if (*TArcItem)(unsafe.Pointer(arcPtr)).Fstyle == int32(CHORD_STYLE) { v1 = corner1[0] *(*float64)(unsafe.Pointer(outlinePtr + 12*8)) = v1 *(*float64)(unsafe.Pointer(outlinePtr)) = v1 v2 = corner1[int32(1)] *(*float64)(unsafe.Pointer(outlinePtr + 13*8)) = v2 *(*float64)(unsafe.Pointer(outlinePtr + 1*8)) = v2 XTkGetButtPoints(tls, arcPtr+448, arcPtr+432, width, 0, outlinePtr+uintptr(10)*8, outlinePtr+uintptr(2)*8) *(*float64)(unsafe.Pointer(outlinePtr + 4*8)) = *(*float64)(unsafe.Pointer(arcPtr + 448)) + *(*float64)(unsafe.Pointer(outlinePtr + 2*8)) - *(*float64)(unsafe.Pointer(arcPtr + 432)) *(*float64)(unsafe.Pointer(outlinePtr + 5*8)) = *(*float64)(unsafe.Pointer(arcPtr + 448 + 1*8)) + *(*float64)(unsafe.Pointer(outlinePtr + 3*8)) - *(*float64)(unsafe.Pointer(arcPtr + 432 + 1*8)) *(*float64)(unsafe.Pointer(outlinePtr + 6*8)) = corner2[0] *(*float64)(unsafe.Pointer(outlinePtr + 7*8)) = corner2[int32(1)] *(*float64)(unsafe.Pointer(outlinePtr + 8*8)) = *(*float64)(unsafe.Pointer(arcPtr + 448)) + *(*float64)(unsafe.Pointer(outlinePtr + 10*8)) - *(*float64)(unsafe.Pointer(arcPtr + 432)) *(*float64)(unsafe.Pointer(outlinePtr + 9*8)) = *(*float64)(unsafe.Pointer(arcPtr + 448 + 1*8)) + *(*float64)(unsafe.Pointer(outlinePtr + 11*8)) - *(*float64)(unsafe.Pointer(arcPtr + 432 + 1*8)) } else { if (*TArcItem)(unsafe.Pointer(arcPtr)).Fstyle == int32(PIESLICE_STYLE) { /* * For pie slices, generate two polygons, one for each side of the pie * slice. The first arm has a shape like this, where the center of the * oval is X, arcPtr->center1 is at Y, and corner1 is at Z: * * _____________________ * | * | * X Y Z * | / * |_____________________/ */ XTkGetButtPoints(tls, arcPtr+432, bp, width, 0, outlinePtr, outlinePtr+uintptr(2)*8) *(*float64)(unsafe.Pointer(outlinePtr + 4*8)) = *(*float64)(unsafe.Pointer(arcPtr + 432)) + *(*float64)(unsafe.Pointer(outlinePtr + 2*8)) - (*(*[2]float64)(unsafe.Pointer(bp)))[0] *(*float64)(unsafe.Pointer(outlinePtr + 5*8)) = *(*float64)(unsafe.Pointer(arcPtr + 432 + 1*8)) + *(*float64)(unsafe.Pointer(outlinePtr + 3*8)) - (*(*[2]float64)(unsafe.Pointer(bp)))[int32(1)] *(*float64)(unsafe.Pointer(outlinePtr + 6*8)) = corner1[0] *(*float64)(unsafe.Pointer(outlinePtr + 7*8)) = corner1[int32(1)] *(*float64)(unsafe.Pointer(outlinePtr + 8*8)) = *(*float64)(unsafe.Pointer(arcPtr + 432)) + *(*float64)(unsafe.Pointer(outlinePtr)) - (*(*[2]float64)(unsafe.Pointer(bp)))[0] *(*float64)(unsafe.Pointer(outlinePtr + 9*8)) = *(*float64)(unsafe.Pointer(arcPtr + 432 + 1*8)) + *(*float64)(unsafe.Pointer(outlinePtr + 1*8)) - (*(*[2]float64)(unsafe.Pointer(bp)))[int32(1)] *(*float64)(unsafe.Pointer(outlinePtr + 10*8)) = *(*float64)(unsafe.Pointer(outlinePtr)) *(*float64)(unsafe.Pointer(outlinePtr + 11*8)) = *(*float64)(unsafe.Pointer(outlinePtr + 1*8)) /* * The second arm has a shape like this: * * ______________________ * / * / * Z Y X / * \ / * \______________________/ * * Similar to above X is the center of the oval/circle, Y is * arcPtr->center2, and Z is corner2. The extra jog out to the left of * X is needed in or to produce a butted joint with the first arm; the * corner to the right of X is one of the first two points of the * first arm, depending on extent. */ XTkGetButtPoints(tls, arcPtr+448, bp, width, 0, outlinePtr+uintptr(12)*8, outlinePtr+uintptr(16)*8) if (*TArcItem)(unsafe.Pointer(arcPtr)).Fextent > libc.Float64FromInt32(180) || (*TArcItem)(unsafe.Pointer(arcPtr)).Fextent < libc.Float64FromInt32(0) && (*TArcItem)(unsafe.Pointer(arcPtr)).Fextent > float64(-libc.Int32FromInt32(180)) { *(*float64)(unsafe.Pointer(outlinePtr + 14*8)) = *(*float64)(unsafe.Pointer(outlinePtr)) *(*float64)(unsafe.Pointer(outlinePtr + 15*8)) = *(*float64)(unsafe.Pointer(outlinePtr + 1*8)) } else { *(*float64)(unsafe.Pointer(outlinePtr + 14*8)) = *(*float64)(unsafe.Pointer(outlinePtr + 2*8)) *(*float64)(unsafe.Pointer(outlinePtr + 15*8)) = *(*float64)(unsafe.Pointer(outlinePtr + 3*8)) } *(*float64)(unsafe.Pointer(outlinePtr + 18*8)) = *(*float64)(unsafe.Pointer(arcPtr + 448)) + *(*float64)(unsafe.Pointer(outlinePtr + 16*8)) - (*(*[2]float64)(unsafe.Pointer(bp)))[0] *(*float64)(unsafe.Pointer(outlinePtr + 19*8)) = *(*float64)(unsafe.Pointer(arcPtr + 448 + 1*8)) + *(*float64)(unsafe.Pointer(outlinePtr + 17*8)) - (*(*[2]float64)(unsafe.Pointer(bp)))[int32(1)] *(*float64)(unsafe.Pointer(outlinePtr + 20*8)) = corner2[0] *(*float64)(unsafe.Pointer(outlinePtr + 21*8)) = corner2[int32(1)] *(*float64)(unsafe.Pointer(outlinePtr + 22*8)) = *(*float64)(unsafe.Pointer(arcPtr + 448)) + *(*float64)(unsafe.Pointer(outlinePtr + 12*8)) - (*(*[2]float64)(unsafe.Pointer(bp)))[0] *(*float64)(unsafe.Pointer(outlinePtr + 23*8)) = *(*float64)(unsafe.Pointer(arcPtr + 448 + 1*8)) + *(*float64)(unsafe.Pointer(outlinePtr + 13*8)) - (*(*[2]float64)(unsafe.Pointer(bp)))[int32(1)] *(*float64)(unsafe.Pointer(outlinePtr + 24*8)) = *(*float64)(unsafe.Pointer(outlinePtr + 12*8)) *(*float64)(unsafe.Pointer(outlinePtr + 25*8)) = *(*float64)(unsafe.Pointer(outlinePtr + 13*8)) } } } /* *-------------------------------------------------------------- * * HorizLineToArc -- * * Determines whether a horizontal line segment intersects a given arc. * * Results: * The return value is 1 if the given line intersects the infinitely-thin * arc section defined by rx, ry, start, and extent, and 0 otherwise. * Only the perimeter of the arc is checked: interior areas (e.g. chord * or pie-slice) are not checked. * * Side effects: * None. * *-------------------------------------------------------------- */ func _HorizLineToArc(tls *libc.TLS, x1 float64, x2 float64, y float64, rx float64, ry float64, start float64, extent float64) (r int32) { /* Angles that define extent of arc, in the * standard fashion for this module. */ var tmp, tx, ty, x float64 _, _, _, _ = tmp, tx, ty, x /* Coordinates of intersection point in * transformed coordinate system. */ /* * Compute the x-coordinate of one possible intersection point between the * arc and the line. Use a transformed coordinate system where the oval is * a unit circle centered at the origin. Then scale back to get actual * x-coordinate. */ ty = y / ry tmp = libc.Float64FromInt32(1) - float64(ty*ty) if tmp < libc.Float64FromInt32(0) { return 0 } tx = libc.Xsqrt(tls, tmp) x = float64(tx * rx) /* * Test both intersection points. */ if x >= x1 && x <= x2 && _AngleInRange(tls, tx, ty, start, extent) != 0 { return int32(1) } if -x >= x1 && -x <= x2 && _AngleInRange(tls, -tx, ty, start, extent) != 0 { return int32(1) } return 0 } /* *-------------------------------------------------------------- * * VertLineToArc -- * * Determines whether a vertical line segment intersects a given arc. * * Results: * The return value is 1 if the given line intersects the infinitely-thin * arc section defined by rx, ry, start, and extent, and 0 otherwise. * Only the perimeter of the arc is checked: interior areas (e.g. chord * or pie-slice) are not checked. * * Side effects: * None. * *-------------------------------------------------------------- */ func _VertLineToArc(tls *libc.TLS, x float64, y1 float64, y2 float64, rx float64, ry float64, start float64, extent float64) (r int32) { /* Angles that define extent of arc, in the * standard fashion for this module. */ var tmp, tx, ty, y float64 _, _, _, _ = tmp, tx, ty, y /* Coordinates of intersection point in * transformed coordinate system. */ /* * Compute the y-coordinate of one possible intersection point between the * arc and the line. Use a transformed coordinate system where the oval is * a unit circle centered at the origin. Then scale back to get actual * y-coordinate. */ tx = x / rx tmp = libc.Float64FromInt32(1) - float64(tx*tx) if tmp < libc.Float64FromInt32(0) { return 0 } ty = libc.Xsqrt(tls, tmp) y = float64(ty * ry) /* * Test both intersection points. */ if y > y1 && y < y2 && _AngleInRange(tls, tx, ty, start, extent) != 0 { return int32(1) } if -y > y1 && -y < y2 && _AngleInRange(tls, tx, -ty, start, extent) != 0 { return int32(1) } return 0 } /* *-------------------------------------------------------------- * * AngleInRange -- * * Determine whether the angle from the origin to a given point is within * a given range. * * Results: * The return value is 1 if the angle from (0,0) to (x,y) is in the range * given by start and extent, where angles are interpreted in the * standard way for ovals (meaning backwards from normal interpretation). * Otherwise the return value is 0. * * Side effects: * None. * *-------------------------------------------------------------- */ func _AngleInRange(tls *libc.TLS, x float64, y float64, start float64, extent float64) (r int32) { /* Size of arc in degrees >=-360, <=360. */ var diff float64 _ = diff if x == float64(0) && y == float64(0) { return int32(1) } diff = -libc.Xatan2(tls, y, x) diff = float64(diff*(libc.Float64FromFloat64(180)/libc.Float64FromFloat64(3.141592653589793))) - start for diff > float64(360) { diff -= float64(360) } for diff < float64(0) { diff += float64(360) } if extent >= libc.Float64FromInt32(0) { return libc.BoolInt32(diff <= extent) } return libc.BoolInt32(diff-float64(360) >= extent) } /* *-------------------------------------------------------------- * * ArcToPostscript -- * * This function is called to generate Postscript for arc items. * * Results: * The return value is a standard Tcl result. If an error occurs in * generating Postscript then an error message is left in the interp's * result, replacing whatever used to be there. If no error occurs, then * Postscript for the item is appended to the result. * * Side effects: * None. * *-------------------------------------------------------------- */ func _ArcToPostscript(tls *libc.TLS, interp uintptr, canvas TTk_Canvas, itemPtr uintptr, dummy2001 int32) (r int32) { bp := tls.Alloc(48) defer tls.Free(48) /* 1 means this is a prepass to collect font * information; 0 means final Postscript is * being created. */ var _objPtr, arcPtr, color, fillColor, psObj, v2 uintptr var ang1, ang2, y1, y2 float64 var fillStipple, stipple TPixmap var interpState TTcl_InterpState var state TTk_State var v1 TTcl_Size _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = _objPtr, ang1, ang2, arcPtr, color, fillColor, fillStipple, interpState, psObj, state, stipple, y1, y2, v1, v2 arcPtr = itemPtr state = (*TTk_Item)(unsafe.Pointer(itemPtr)).Fstate y1 = XTk_CanvasPsY(tls, canvas, *(*float64)(unsafe.Pointer(arcPtr + 296 + 1*8))) y2 = XTk_CanvasPsY(tls, canvas, *(*float64)(unsafe.Pointer(arcPtr + 296 + 3*8))) ang1 = (*TArcItem)(unsafe.Pointer(arcPtr)).Fstart ang2 = ang1 + (*TArcItem)(unsafe.Pointer(arcPtr)).Fextent if ang2 < ang1 { ang1 = ang2 ang2 = (*TArcItem)(unsafe.Pointer(arcPtr)).Fstart } if state == int32(TK_STATE_NULL) { state = (*TTkCanvas)(unsafe.Pointer(canvas)).Fcanvas_state } color = (*TArcItem)(unsafe.Pointer(arcPtr)).Foutline.Fcolor stipple = (*TArcItem)(unsafe.Pointer(arcPtr)).Foutline.Fstipple fillColor = (*TArcItem)(unsafe.Pointer(arcPtr)).FfillColor fillStipple = (*TArcItem)(unsafe.Pointer(arcPtr)).FfillStipple if (*TTkCanvas)(unsafe.Pointer(canvas)).FcurrentItemPtr == itemPtr { if (*TArcItem)(unsafe.Pointer(arcPtr)).Foutline.FactiveColor != libc.UintptrFromInt32(0) { color = (*TArcItem)(unsafe.Pointer(arcPtr)).Foutline.FactiveColor } if (*TArcItem)(unsafe.Pointer(arcPtr)).Foutline.FactiveStipple != uint64(0) { stipple = (*TArcItem)(unsafe.Pointer(arcPtr)).Foutline.FactiveStipple } if (*TArcItem)(unsafe.Pointer(arcPtr)).FactiveFillColor != libc.UintptrFromInt32(0) { fillColor = (*TArcItem)(unsafe.Pointer(arcPtr)).FactiveFillColor } if (*TArcItem)(unsafe.Pointer(arcPtr)).FactiveFillStipple != uint64(0) { fillStipple = (*TArcItem)(unsafe.Pointer(arcPtr)).FactiveFillStipple } } else { if state == int32(TK_STATE_DISABLED) { if (*TArcItem)(unsafe.Pointer(arcPtr)).Foutline.FdisabledColor != libc.UintptrFromInt32(0) { color = (*TArcItem)(unsafe.Pointer(arcPtr)).Foutline.FdisabledColor } if (*TArcItem)(unsafe.Pointer(arcPtr)).Foutline.FdisabledStipple != uint64(0) { stipple = (*TArcItem)(unsafe.Pointer(arcPtr)).Foutline.FdisabledStipple } if (*TArcItem)(unsafe.Pointer(arcPtr)).FdisabledFillColor != libc.UintptrFromInt32(0) { fillColor = (*TArcItem)(unsafe.Pointer(arcPtr)).FdisabledFillColor } if (*TArcItem)(unsafe.Pointer(arcPtr)).FdisabledFillStipple != uint64(0) { fillStipple = (*TArcItem)(unsafe.Pointer(arcPtr)).FdisabledFillStipple } } } /* * Make our working space. */ psObj = libtcl9_0.XTcl_NewObj(tls) interpState = libtcl9_0.XTcl_SaveInterpState(tls, interp, TCL_OK) /* * If the arc is filled, output Postscript for the interior region of the * arc. */ if (*TArcItem)(unsafe.Pointer(arcPtr)).FfillGC != libc.UintptrFromInt32(0) { libtcl9_0.XTcl_AppendPrintfToObj(tls, psObj, __ccgo_ts+29026, libc.VaList(bp+8, (*(*float64)(unsafe.Pointer(arcPtr + 296))+*(*float64)(unsafe.Pointer(arcPtr + 296 + 2*8)))/libc.Float64FromInt32(2), (y1+y2)/libc.Float64FromInt32(2), (*(*float64)(unsafe.Pointer(arcPtr + 296 + 2*8))-*(*float64)(unsafe.Pointer(arcPtr + 296)))/libc.Float64FromInt32(2), (y1-y2)/libc.Float64FromInt32(2))) if (*TArcItem)(unsafe.Pointer(arcPtr)).Fstyle != int32(CHORD_STYLE) { libtcl9_0.XTcl_AppendToObj(tls, psObj, __ccgo_ts+29088, int64(-libc.Int32FromInt32(1))) } libtcl9_0.XTcl_AppendPrintfToObj(tls, psObj, __ccgo_ts+29100, libc.VaList(bp+8, ang1, ang2)) libtcl9_0.XTcl_ResetResult(tls, interp) XTk_CanvasPsColor(tls, interp, canvas, fillColor) libtcl9_0.XTcl_AppendObjToObj(tls, psObj, libtcl9_0.XTcl_GetObjResult(tls, interp)) if fillStipple != uint64(0) { libtcl9_0.XTcl_AppendToObj(tls, psObj, __ccgo_ts+29143, int64(-libc.Int32FromInt32(1))) libtcl9_0.XTcl_ResetResult(tls, interp) XTk_CanvasPsStipple(tls, interp, canvas, fillStipple) libtcl9_0.XTcl_AppendObjToObj(tls, psObj, libtcl9_0.XTcl_GetObjResult(tls, interp)) if (*TArcItem)(unsafe.Pointer(arcPtr)).Foutline.Fgc != libc.UintptrFromInt32(0) { libtcl9_0.XTcl_AppendToObj(tls, psObj, __ccgo_ts+29149, int64(-libc.Int32FromInt32(1))) } } else { libtcl9_0.XTcl_AppendToObj(tls, psObj, __ccgo_ts+29165, int64(-libc.Int32FromInt32(1))) } } /* * If there's an outline for the arc, draw it. */ if (*TArcItem)(unsafe.Pointer(arcPtr)).Foutline.Fgc != libc.UintptrFromInt32(0) { libtcl9_0.XTcl_AppendPrintfToObj(tls, psObj, __ccgo_ts+29026, libc.VaList(bp+8, (*(*float64)(unsafe.Pointer(arcPtr + 296))+*(*float64)(unsafe.Pointer(arcPtr + 296 + 2*8)))/libc.Float64FromInt32(2), (y1+y2)/libc.Float64FromInt32(2), (*(*float64)(unsafe.Pointer(arcPtr + 296 + 2*8))-*(*float64)(unsafe.Pointer(arcPtr + 296)))/libc.Float64FromInt32(2), (y1-y2)/libc.Float64FromInt32(2))) libtcl9_0.XTcl_AppendPrintfToObj(tls, psObj, __ccgo_ts+29171, libc.VaList(bp+8, ang1, ang2)) libtcl9_0.XTcl_ResetResult(tls, interp) XTk_CanvasPsOutline(tls, canvas, itemPtr, arcPtr+120) libtcl9_0.XTcl_AppendObjToObj(tls, psObj, libtcl9_0.XTcl_GetObjResult(tls, interp)) if (*TArcItem)(unsafe.Pointer(arcPtr)).Fstyle != int32(ARC_STYLE) { libtcl9_0.XTcl_AppendToObj(tls, psObj, __ccgo_ts+29149, int64(-libc.Int32FromInt32(1))) libtcl9_0.XTcl_ResetResult(tls, interp) if (*TArcItem)(unsafe.Pointer(arcPtr)).Fstyle == int32(CHORD_STYLE) { XTk_CanvasPsPath(tls, interp, canvas, (*TArcItem)(unsafe.Pointer(arcPtr)).FoutlinePtr, int64(CHORD_OUTLINE_PTS)) } else { XTk_CanvasPsPath(tls, interp, canvas, (*TArcItem)(unsafe.Pointer(arcPtr)).FoutlinePtr, int64(PIE_OUTLINE1_PTS)) XTk_CanvasPsColor(tls, interp, canvas, color) libtcl9_0.XTcl_AppendObjToObj(tls, psObj, libtcl9_0.XTcl_GetObjResult(tls, interp)) if stipple != uint64(0) { libtcl9_0.XTcl_AppendToObj(tls, psObj, __ccgo_ts+29143, int64(-libc.Int32FromInt32(1))) libtcl9_0.XTcl_ResetResult(tls, interp) XTk_CanvasPsStipple(tls, interp, canvas, stipple) libtcl9_0.XTcl_AppendObjToObj(tls, psObj, libtcl9_0.XTcl_GetObjResult(tls, interp)) } else { libtcl9_0.XTcl_AppendToObj(tls, psObj, __ccgo_ts+29165, int64(-libc.Int32FromInt32(1))) } libtcl9_0.XTcl_AppendToObj(tls, psObj, __ccgo_ts+29149, int64(-libc.Int32FromInt32(1))) libtcl9_0.XTcl_ResetResult(tls, interp) XTk_CanvasPsPath(tls, interp, canvas, (*TArcItem)(unsafe.Pointer(arcPtr)).FoutlinePtr+uintptr(libc.Int32FromInt32(2)*libc.Int32FromInt32(PIE_OUTLINE1_PTS))*8, int64(PIE_OUTLINE2_PTS)) } XTk_CanvasPsColor(tls, interp, canvas, color) libtcl9_0.XTcl_AppendObjToObj(tls, psObj, libtcl9_0.XTcl_GetObjResult(tls, interp)) if stipple != uint64(0) { libtcl9_0.XTcl_AppendToObj(tls, psObj, __ccgo_ts+29143, int64(-libc.Int32FromInt32(1))) libtcl9_0.XTcl_ResetResult(tls, interp) XTk_CanvasPsStipple(tls, interp, canvas, stipple) libtcl9_0.XTcl_AppendObjToObj(tls, psObj, libtcl9_0.XTcl_GetObjResult(tls, interp)) } else { libtcl9_0.XTcl_AppendToObj(tls, psObj, __ccgo_ts+29165, int64(-libc.Int32FromInt32(1))) } } } /* * Plug the accumulated postscript back into the result. */ libtcl9_0.XTcl_RestoreInterpState(tls, interp, interpState) libtcl9_0.XTcl_AppendObjToObj(tls, libtcl9_0.XTcl_GetObjResult(tls, interp), psObj) _objPtr = psObj v2 = _objPtr v1 = *(*TTcl_Size)(unsafe.Pointer(v2)) *(*TTcl_Size)(unsafe.Pointer(v2))-- if v1 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr) } return TCL_OK } /* *-------------------------------------------------------------- * * StyleParseProc -- * * This function is invoked during option processing to handle the * "-style" option. * * Results: * A standard Tcl return value. * * Side effects: * The state for a given item gets replaced by the state indicated in the * value argument. * *-------------------------------------------------------------- */ func _StyleParseProc(tls *libc.TLS, dummy2196 uintptr, interp uintptr, dummy2198 TTk_Window, value uintptr, widgRec uintptr, offset TTcl_Size) (r int32) { bp := tls.Alloc(48) defer tls.Free(48) /* Offset into item. */ var c int32 var length Tsize_t var stylePtr uintptr _, _, _ = c, length, stylePtr stylePtr = widgRec + uintptr(offset) if value == libc.UintptrFromInt32(0) || libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(value))) == 0 { *(*TStyle1)(unsafe.Pointer(stylePtr)) = int32(PIESLICE_STYLE) return TCL_OK } c = libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(value))) length = libc.Xstrlen(tls, value) if c == int32('a') && libc.Xstrncmp(tls, value, __ccgo_ts+28609, length) == 0 { *(*TStyle1)(unsafe.Pointer(stylePtr)) = int32(ARC_STYLE) return TCL_OK } if c == int32('c') && libc.Xstrncmp(tls, value, __ccgo_ts+29217, length) == 0 { *(*TStyle1)(unsafe.Pointer(stylePtr)) = int32(CHORD_STYLE) return TCL_OK } if c == int32('p') && libc.Xstrncmp(tls, value, __ccgo_ts+29223, length) == 0 { *(*TStyle1)(unsafe.Pointer(stylePtr)) = int32(PIESLICE_STYLE) return TCL_OK } libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+29232, libc.VaList(bp+8, value))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+8, __ccgo_ts+179, __ccgo_ts+27003, __ccgo_ts+29288, libc.UintptrFromInt32(0))) *(*TStyle1)(unsafe.Pointer(stylePtr)) = int32(PIESLICE_STYLE) return int32(TCL_ERROR) } /* *-------------------------------------------------------------- * * StylePrintProc -- * * This function is invoked by the Tk configuration code to produce a * printable string for the "-style" configuration option. * * Results: * The return value is a string describing the state for the item * referred to by "widgRec". In addition, *freeProcPtr is filled in with * the address of a function to call to free the result string when it's * no longer needed (or NULL to indicate that the string doesn't need to * be freed). * * Side effects: * None. * *-------------------------------------------------------------- */ func _StylePrintProc(tls *libc.TLS, dummy2259 uintptr, dummy2260 TTk_Window, widgRec uintptr, offset TTcl_Size, dummy2263 uintptr) (r uintptr) { /* Pointer to variable to fill in with * information about how to reclaim storage * for return string. */ var stylePtr uintptr _ = stylePtr stylePtr = widgRec + uintptr(offset) if *(*TStyle1)(unsafe.Pointer(stylePtr)) == int32(ARC_STYLE) { return __ccgo_ts + 28609 } else { if *(*TStyle1)(unsafe.Pointer(stylePtr)) == int32(CHORD_STYLE) { return __ccgo_ts + 29217 } else { return __ccgo_ts + 29223 } } return r } const M_PI4 = 0 /* * Convenience macro. */ /* * default.h -- * * This file defines the defaults for all options for all of * the Tk widgets. * * Copyright © 1991-1994 The Regents of the University of California. * Copyright © 1994 Sun Microsystems, Inc. * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. */ /* * tkUnixDefault.h -- * * This file defines the defaults for all options for all of * the Tk widgets. * * Copyright © 1991-1994 The Regents of the University of California. * Copyright © 1994-1997 Sun Microsystems, Inc. * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. */ /* * The definitions below provide symbolic names for the default colors. * NORMAL_BG - Normal background color. * ACTIVE_BG - Background color when widget is active. * SELECT_BG - Background color for selected text. * TROUGH - Background color for troughs in scales and scrollbars. * INDICATOR - Color for indicator when button is selected. * DISABLED - Foreground color when widget is disabled. * PLACEHOLDER_FG - Foreground color for placeholder text. */ /* * Defaults for labels, buttons, checkbuttons, and radiobuttons: */ /* * Defaults for canvases: */ /* * Defaults for entries: */ /* * Defaults for frames: */ /* * Defaults for labelframes: */ /* * Defaults for listboxes: */ /* * Defaults for individual entries of menus: */ /* * Defaults for menus overall: */ /* * Defaults for menubuttons: */ /* * Defaults for messages: */ /* * Defaults for panedwindows */ /* * Defaults for panedwindow panes */ /* * Defaults for scales: */ /* * Defaults for scrollbars: */ /* * Defaults for texts: */ /* * Defaults for canvas text: */ /* * Defaults for canvas items * (arcs, bitmaps, lines, polygons, rectangles, and ovals): */ /* * Defaults for toplevels (most of the defaults for frames also apply * to toplevels): */ /* * Defaults for busy windows: */ /* * The structure below defines the record for each bitmap item. */ type TBitmapItem = struct { Fheader TTk_Item Fx float64 Fy float64 Fanchor TTk_Anchor Fbitmap TPixmap FactiveBitmap TPixmap FdisabledBitmap TPixmap FfgColor uintptr FactiveFgColor uintptr FdisabledFgColor uintptr FbgColor uintptr FactiveBgColor uintptr FdisabledBgColor uintptr Fgc TGC } /* * Information used for parsing configuration specs: */ var _stateOption2 = TTk_CustomOption{ FclientData: uintptr(int64(libc.Int32FromInt32(2))), } func init() { p := unsafe.Pointer(&_stateOption2) *(*uintptr)(unsafe.Add(p, 0)) = __ccgo_fp(XTkStateParseProc) *(*uintptr)(unsafe.Add(p, 8)) = __ccgo_fp(XTkStatePrintProc) } var _tagsOption1 = TTk_CustomOption{} func init() { p := unsafe.Pointer(&_tagsOption1) *(*uintptr)(unsafe.Add(p, 0)) = __ccgo_fp(XTk_CanvasTagsParseProc) *(*uintptr)(unsafe.Add(p, 8)) = __ccgo_fp(XTk_CanvasTagsPrintProc) } var _configSpecs3 = [13]TTk_ConfigSpec{ 0: { Ftype1: int32(TK_CONFIG_COLOR), FargvName: __ccgo_ts + 19775, Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 200)), FspecFlags: int32(TCL_NULL_OK), }, 1: { Ftype1: int32(TK_CONFIG_BITMAP), FargvName: __ccgo_ts + 29298, Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 152)), FspecFlags: int32(TCL_NULL_OK), }, 2: { Ftype1: int32(TK_CONFIG_COLOR), FargvName: __ccgo_ts + 19837, Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 176)), FspecFlags: int32(TCL_NULL_OK), }, 3: { Ftype1: int32(TK_CONFIG_ANCHOR), FargvName: __ccgo_ts + 15168, FdefValue: __ccgo_ts + 10959, Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 136)), FspecFlags: libc.Int32FromInt32(1) << libc.Int32FromInt32(3), }, 4: { Ftype1: int32(TK_CONFIG_COLOR), FargvName: __ccgo_ts + 19898, Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 192)), FspecFlags: int32(TCL_NULL_OK), }, 5: { Ftype1: int32(TK_CONFIG_BITMAP), FargvName: __ccgo_ts + 19937, Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 144)), FspecFlags: int32(TCL_NULL_OK), }, 6: { Ftype1: int32(TK_CONFIG_COLOR), FargvName: __ccgo_ts + 21106, Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 208)), FspecFlags: int32(TCL_NULL_OK), }, 7: { Ftype1: int32(TK_CONFIG_BITMAP), FargvName: __ccgo_ts + 29312, Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 160)), FspecFlags: int32(TCL_NULL_OK), }, 8: { Ftype1: int32(TK_CONFIG_COLOR), FargvName: __ccgo_ts + 20004, Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 184)), FspecFlags: int32(TCL_NULL_OK), }, 9: { Ftype1: int32(TK_CONFIG_COLOR), FargvName: __ccgo_ts + 20085, FdefValue: __ccgo_ts + 19829, Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 168)), }, 10: { Ftype1: int32(TK_CONFIG_CUSTOM), FargvName: __ccgo_ts + 2957, Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 96)), FspecFlags: int32(TCL_NULL_OK), FcustomPtr: uintptr(unsafe.Pointer(&_stateOption2)), }, 11: { Ftype1: int32(TK_CONFIG_CUSTOM), FargvName: __ccgo_ts + 28895, FspecFlags: int32(TCL_NULL_OK), FcustomPtr: uintptr(unsafe.Pointer(&_tagsOption1)), }, 12: { Ftype1: int32(TK_CONFIG_END), }, } func init() { p := unsafe.Pointer(&XtkBitmapType) *(*uintptr)(unsafe.Add(p, 16)) = __ccgo_fp(_TkcCreateBitmap) *(*uintptr)(unsafe.Add(p, 32)) = __ccgo_fp(_ConfigureBitmap) *(*uintptr)(unsafe.Add(p, 40)) = __ccgo_fp(_BitmapCoords) *(*uintptr)(unsafe.Add(p, 48)) = __ccgo_fp(_DeleteBitmap) *(*uintptr)(unsafe.Add(p, 56)) = __ccgo_fp(_DisplayBitmap) *(*uintptr)(unsafe.Add(p, 72)) = __ccgo_fp(_BitmapToPoint) *(*uintptr)(unsafe.Add(p, 80)) = __ccgo_fp(_BitmapToArea) *(*uintptr)(unsafe.Add(p, 88)) = __ccgo_fp(_BitmapToPostscript) *(*uintptr)(unsafe.Add(p, 96)) = __ccgo_fp(_ScaleBitmap) *(*uintptr)(unsafe.Add(p, 104)) = __ccgo_fp(_TranslateBitmap) *(*uintptr)(unsafe.Add(p, 160)) = __ccgo_fp(_RotateBitmap) } /* *-------------------------------------------------------------- * * TkcCreateBitmap -- * * This function is invoked to create a new bitmap item in a canvas. * * Results: * A standard Tcl return value. If an error occurred in creating the * item, then an error message is left in the interp's result; in this * case itemPtr is left uninitialized, so it can be safely freed by the * caller. * * Side effects: * A new bitmap item is created. * *-------------------------------------------------------------- */ func _TkcCreateBitmap(tls *libc.TLS, interp uintptr, canvas TTk_Canvas, itemPtr uintptr, objc TTcl_Size, objv uintptr) (r int32) { /* Arguments describing rectangle. */ var arg, bmapPtr uintptr var i TTcl_Size _, _, _ = arg, bmapPtr, i bmapPtr = itemPtr if objc == 0 { libtcl9_0.XTcl_Panic(tls, __ccgo_ts+28901, 0) } /* * Initialize item's record. */ (*TBitmapItem)(unsafe.Pointer(bmapPtr)).Fanchor = int32(TK_ANCHOR_CENTER) (*TBitmapItem)(unsafe.Pointer(bmapPtr)).Fbitmap = uint64(0) (*TBitmapItem)(unsafe.Pointer(bmapPtr)).FactiveBitmap = uint64(0) (*TBitmapItem)(unsafe.Pointer(bmapPtr)).FdisabledBitmap = uint64(0) (*TBitmapItem)(unsafe.Pointer(bmapPtr)).FfgColor = libc.UintptrFromInt32(0) (*TBitmapItem)(unsafe.Pointer(bmapPtr)).FactiveFgColor = libc.UintptrFromInt32(0) (*TBitmapItem)(unsafe.Pointer(bmapPtr)).FdisabledFgColor = libc.UintptrFromInt32(0) (*TBitmapItem)(unsafe.Pointer(bmapPtr)).FbgColor = libc.UintptrFromInt32(0) (*TBitmapItem)(unsafe.Pointer(bmapPtr)).FactiveBgColor = libc.UintptrFromInt32(0) (*TBitmapItem)(unsafe.Pointer(bmapPtr)).FdisabledBgColor = libc.UintptrFromInt32(0) (*TBitmapItem)(unsafe.Pointer(bmapPtr)).Fgc = libc.UintptrFromInt32(0) /* * Process the arguments to fill in the item record. Only 1 (list) or 2 (x * y) coords are allowed. */ if objc == int64(1) { i = int64(1) } else { arg = libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8)), libc.UintptrFromInt32(0)) i = int64(2) if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(arg))) == int32('-') && libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(arg + 1))) >= int32('a') && libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(arg + 1))) <= int32('z') { i = int64(1) } } if _BitmapCoords(tls, interp, canvas, itemPtr, i, objv) != TCL_OK { goto error } if _ConfigureBitmap(tls, interp, canvas, itemPtr, objc-i, objv+uintptr(i)*8, 0) == TCL_OK { return TCL_OK } goto error error: ; _DeleteBitmap(tls, canvas, itemPtr, (*TTk_FakeWin)(unsafe.Pointer(XTk_CanvasTkwin(tls, canvas))).Fdisplay) return int32(TCL_ERROR) } /* *-------------------------------------------------------------- * * BitmapCoords -- * * This function is invoked to process the "coords" widget command on * bitmap items. See the user documentation for details on what it does. * * Results: * Returns TCL_OK or TCL_ERROR, and sets the interp's result. * * Side effects: * The coordinates for the given item may be changed. * *-------------------------------------------------------------- */ func _BitmapCoords(tls *libc.TLS, interp uintptr, canvas TTk_Canvas, itemPtr uintptr, _objc TTcl_Size, _objv uintptr) (r int32) { bp := tls.Alloc(64) defer tls.Free(64) *(*TTcl_Size)(unsafe.Pointer(bp)) = _objc *(*uintptr)(unsafe.Pointer(bp + 8)) = _objv /* Array of coordinates: x1, y1, x2, y2, ... */ var bmapPtr, obj uintptr _, _ = bmapPtr, obj bmapPtr = itemPtr if *(*TTcl_Size)(unsafe.Pointer(bp)) == 0 { obj = libtcl9_0.XTcl_NewObj(tls) libtcl9_0.XTcl_ListObjAppendElement(tls, libc.UintptrFromInt32(0), obj, libtcl9_0.XTcl_NewDoubleObj(tls, (*TBitmapItem)(unsafe.Pointer(bmapPtr)).Fx)) libtcl9_0.XTcl_ListObjAppendElement(tls, libc.UintptrFromInt32(0), obj, libtcl9_0.XTcl_NewDoubleObj(tls, (*TBitmapItem)(unsafe.Pointer(bmapPtr)).Fy)) libtcl9_0.XTcl_SetObjResult(tls, interp, obj) } else { if *(*TTcl_Size)(unsafe.Pointer(bp)) < int64(3) { if *(*TTcl_Size)(unsafe.Pointer(bp)) == int64(1) { if libtcl9_0.XTcl_ListObjGetElements(tls, interp, *(*uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 8)))), bp, bp+8) != TCL_OK { return int32(TCL_ERROR) } else { if *(*TTcl_Size)(unsafe.Pointer(bp)) != int64(2) { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+29328, libc.VaList(bp+24, *(*TTcl_Size)(unsafe.Pointer(bp))))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+24, __ccgo_ts+179, __ccgo_ts+27003, __ccgo_ts+28973, __ccgo_ts+763, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) } } } if XTk_CanvasGetCoordFromObj(tls, interp, canvas, *(*uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 8)))), bmapPtr+120) != TCL_OK || XTk_CanvasGetCoordFromObj(tls, interp, canvas, *(*uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 8)) + 1*8)), bmapPtr+128) != TCL_OK { return int32(TCL_ERROR) } _ComputeBitmapBbox(tls, canvas, bmapPtr) } else { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+29369, libc.VaList(bp+24, *(*TTcl_Size)(unsafe.Pointer(bp))))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+24, __ccgo_ts+179, __ccgo_ts+27003, __ccgo_ts+28973, __ccgo_ts+763, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) } } return TCL_OK } /* *-------------------------------------------------------------- * * ConfigureBitmap -- * * This function is invoked to configure various aspects of a bitmap * item, such as its anchor position. * * Results: * A standard Tcl result code. If an error occurs, then an error message * is left in the interp's result. * * Side effects: * Configuration information may be set for itemPtr. * *-------------------------------------------------------------- */ func _ConfigureBitmap(tls *libc.TLS, interp uintptr, canvas TTk_Canvas, itemPtr uintptr, objc TTcl_Size, objv uintptr, flags int32) (r int32) { bp := tls.Alloc(128) defer tls.Free(128) /* Flags to pass to Tk_ConfigureWidget. */ var bgColor, bmapPtr, fgColor uintptr var bitmap TPixmap var mask uint64 var newGC TGC var state TTk_State var tkwin TTk_Window var _ /* gcValues at bp+0 */ TXGCValues _, _, _, _, _, _, _, _ = bgColor, bitmap, bmapPtr, fgColor, mask, newGC, state, tkwin bmapPtr = itemPtr tkwin = XTk_CanvasTkwin(tls, canvas) if TCL_OK != XTk_ConfigureWidget(tls, interp, tkwin, uintptr(unsafe.Pointer(&_configSpecs3)), objc, objv, bmapPtr, flags) { return int32(TCL_ERROR) } /* * A few of the options require additional processing, such as those that * determine the graphics context. */ state = (*TTk_Item)(unsafe.Pointer(itemPtr)).Fstate if (*TBitmapItem)(unsafe.Pointer(bmapPtr)).FactiveFgColor != libc.UintptrFromInt32(0) || (*TBitmapItem)(unsafe.Pointer(bmapPtr)).FactiveBgColor != libc.UintptrFromInt32(0) || (*TBitmapItem)(unsafe.Pointer(bmapPtr)).FactiveBitmap != uint64(0) { *(*int32)(unsafe.Pointer(itemPtr + 112)) |= int32(TK_ITEM_STATE_DEPENDANT) } else { *(*int32)(unsafe.Pointer(itemPtr + 112)) &= ^libc.Int32FromInt32(TK_ITEM_STATE_DEPENDANT) } if state == int32(TK_STATE_NULL) { state = (*TTkCanvas)(unsafe.Pointer(canvas)).Fcanvas_state } if state == int32(TK_STATE_HIDDEN) { _ComputeBitmapBbox(tls, canvas, bmapPtr) return TCL_OK } fgColor = (*TBitmapItem)(unsafe.Pointer(bmapPtr)).FfgColor bgColor = (*TBitmapItem)(unsafe.Pointer(bmapPtr)).FbgColor bitmap = (*TBitmapItem)(unsafe.Pointer(bmapPtr)).Fbitmap if (*TTkCanvas)(unsafe.Pointer(canvas)).FcurrentItemPtr == itemPtr { if (*TBitmapItem)(unsafe.Pointer(bmapPtr)).FactiveFgColor != libc.UintptrFromInt32(0) { fgColor = (*TBitmapItem)(unsafe.Pointer(bmapPtr)).FactiveFgColor } if (*TBitmapItem)(unsafe.Pointer(bmapPtr)).FactiveBgColor != libc.UintptrFromInt32(0) { bgColor = (*TBitmapItem)(unsafe.Pointer(bmapPtr)).FactiveBgColor } if (*TBitmapItem)(unsafe.Pointer(bmapPtr)).FactiveBitmap != uint64(0) { bitmap = (*TBitmapItem)(unsafe.Pointer(bmapPtr)).FactiveBitmap } } else { if state == int32(TK_STATE_DISABLED) { if (*TBitmapItem)(unsafe.Pointer(bmapPtr)).FdisabledFgColor != libc.UintptrFromInt32(0) { fgColor = (*TBitmapItem)(unsafe.Pointer(bmapPtr)).FdisabledFgColor } if (*TBitmapItem)(unsafe.Pointer(bmapPtr)).FdisabledBgColor != libc.UintptrFromInt32(0) { bgColor = (*TBitmapItem)(unsafe.Pointer(bmapPtr)).FdisabledBgColor } if (*TBitmapItem)(unsafe.Pointer(bmapPtr)).FdisabledBitmap != uint64(0) { bitmap = (*TBitmapItem)(unsafe.Pointer(bmapPtr)).FdisabledBitmap } } } if bitmap == uint64(0) { newGC = libc.UintptrFromInt32(0) } else { (*(*TXGCValues)(unsafe.Pointer(bp))).Fforeground = (*TXColor)(unsafe.Pointer(fgColor)).Fpixel mask = libc.Uint64FromInt64(libc.Int64FromInt64(1) << libc.Int32FromInt32(2)) if bgColor != libc.UintptrFromInt32(0) { (*(*TXGCValues)(unsafe.Pointer(bp))).Fbackground = (*TXColor)(unsafe.Pointer(bgColor)).Fpixel mask |= libc.Uint64FromInt64(libc.Int64FromInt64(1) << libc.Int32FromInt32(3)) } else { (*(*TXGCValues)(unsafe.Pointer(bp))).Fclip_mask = bitmap mask |= libc.Uint64FromInt64(libc.Int64FromInt64(1) << libc.Int32FromInt32(19)) } newGC = XTk_GetGC(tls, tkwin, mask, bp) } if (*TBitmapItem)(unsafe.Pointer(bmapPtr)).Fgc != libc.UintptrFromInt32(0) { XTk_FreeGC(tls, (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fdisplay, (*TBitmapItem)(unsafe.Pointer(bmapPtr)).Fgc) } (*TBitmapItem)(unsafe.Pointer(bmapPtr)).Fgc = newGC _ComputeBitmapBbox(tls, canvas, bmapPtr) return TCL_OK } /* *-------------------------------------------------------------- * * DeleteBitmap -- * * This function is called to clean up the data structure associated with * a bitmap item. * * Results: * None. * * Side effects: * Resources associated with itemPtr are released. * *-------------------------------------------------------------- */ func _DeleteBitmap(tls *libc.TLS, dummy420 TTk_Canvas, itemPtr uintptr, display uintptr) { /* Display containing window for canvas. */ var bmapPtr uintptr _ = bmapPtr bmapPtr = itemPtr if (*TBitmapItem)(unsafe.Pointer(bmapPtr)).Fbitmap != uint64(0) { XTk_FreeBitmap(tls, display, (*TBitmapItem)(unsafe.Pointer(bmapPtr)).Fbitmap) } if (*TBitmapItem)(unsafe.Pointer(bmapPtr)).FactiveBitmap != uint64(0) { XTk_FreeBitmap(tls, display, (*TBitmapItem)(unsafe.Pointer(bmapPtr)).FactiveBitmap) } if (*TBitmapItem)(unsafe.Pointer(bmapPtr)).FdisabledBitmap != uint64(0) { XTk_FreeBitmap(tls, display, (*TBitmapItem)(unsafe.Pointer(bmapPtr)).FdisabledBitmap) } if (*TBitmapItem)(unsafe.Pointer(bmapPtr)).FfgColor != libc.UintptrFromInt32(0) { XTk_FreeColor(tls, (*TBitmapItem)(unsafe.Pointer(bmapPtr)).FfgColor) } if (*TBitmapItem)(unsafe.Pointer(bmapPtr)).FactiveFgColor != libc.UintptrFromInt32(0) { XTk_FreeColor(tls, (*TBitmapItem)(unsafe.Pointer(bmapPtr)).FactiveFgColor) } if (*TBitmapItem)(unsafe.Pointer(bmapPtr)).FdisabledFgColor != libc.UintptrFromInt32(0) { XTk_FreeColor(tls, (*TBitmapItem)(unsafe.Pointer(bmapPtr)).FdisabledFgColor) } if (*TBitmapItem)(unsafe.Pointer(bmapPtr)).FbgColor != libc.UintptrFromInt32(0) { XTk_FreeColor(tls, (*TBitmapItem)(unsafe.Pointer(bmapPtr)).FbgColor) } if (*TBitmapItem)(unsafe.Pointer(bmapPtr)).FactiveBgColor != libc.UintptrFromInt32(0) { XTk_FreeColor(tls, (*TBitmapItem)(unsafe.Pointer(bmapPtr)).FactiveBgColor) } if (*TBitmapItem)(unsafe.Pointer(bmapPtr)).FdisabledBgColor != libc.UintptrFromInt32(0) { XTk_FreeColor(tls, (*TBitmapItem)(unsafe.Pointer(bmapPtr)).FdisabledBgColor) } if (*TBitmapItem)(unsafe.Pointer(bmapPtr)).Fgc != libc.UintptrFromInt32(0) { XTk_FreeGC(tls, display, (*TBitmapItem)(unsafe.Pointer(bmapPtr)).Fgc) } } /* *-------------------------------------------------------------- * * ComputeBitmapBbox -- * * This function is invoked to compute the bounding box of all the pixels * that may be drawn as part of a bitmap item. This function is where the * child bitmap's placement is computed. * * Results: * None. * * Side effects: * The fields x1, y1, x2, and y2 are updated in the header for itemPtr. * *-------------------------------------------------------------- */ func _ComputeBitmapBbox(tls *libc.TLS, canvas TTk_Canvas, bmapPtr uintptr) { bp := tls.Alloc(16) defer tls.Free(16) /* Item whose bbox is to be recomputed. */ var bitmap TPixmap var state TTk_State var x, y, v3, v4 int32 var v1, v2 float64 var _ /* height at bp+4 */ int32 var _ /* width at bp+0 */ int32 _, _, _, _, _, _, _, _ = bitmap, state, x, y, v1, v2, v3, v4 state = (*TBitmapItem)(unsafe.Pointer(bmapPtr)).Fheader.Fstate if state == int32(TK_STATE_NULL) { state = (*TTkCanvas)(unsafe.Pointer(canvas)).Fcanvas_state } bitmap = (*TBitmapItem)(unsafe.Pointer(bmapPtr)).Fbitmap if (*TTkCanvas)(unsafe.Pointer(canvas)).FcurrentItemPtr == bmapPtr { if (*TBitmapItem)(unsafe.Pointer(bmapPtr)).FactiveBitmap != uint64(0) { bitmap = (*TBitmapItem)(unsafe.Pointer(bmapPtr)).FactiveBitmap } } else { if state == int32(TK_STATE_DISABLED) { if (*TBitmapItem)(unsafe.Pointer(bmapPtr)).FdisabledBitmap != uint64(0) { bitmap = (*TBitmapItem)(unsafe.Pointer(bmapPtr)).FdisabledBitmap } } } if (*TBitmapItem)(unsafe.Pointer(bmapPtr)).Fx >= libc.Float64FromInt32(0) { v1 = float64(0.5) } else { v1 = -libc.Float64FromFloat64(0.5) } x = int32((*TBitmapItem)(unsafe.Pointer(bmapPtr)).Fx + v1) if (*TBitmapItem)(unsafe.Pointer(bmapPtr)).Fy >= libc.Float64FromInt32(0) { v2 = float64(0.5) } else { v2 = -libc.Float64FromFloat64(0.5) } y = int32((*TBitmapItem)(unsafe.Pointer(bmapPtr)).Fy + v2) if state == int32(TK_STATE_HIDDEN) || bitmap == uint64(0) { v3 = x (*TBitmapItem)(unsafe.Pointer(bmapPtr)).Fheader.Fx2 = v3 (*TBitmapItem)(unsafe.Pointer(bmapPtr)).Fheader.Fx1 = v3 v4 = y (*TBitmapItem)(unsafe.Pointer(bmapPtr)).Fheader.Fy2 = v4 (*TBitmapItem)(unsafe.Pointer(bmapPtr)).Fheader.Fy1 = v4 return } /* * Compute location and size of bitmap, using anchor information. */ XTk_SizeOfBitmap(tls, (*TTk_FakeWin)(unsafe.Pointer(XTk_CanvasTkwin(tls, canvas))).Fdisplay, bitmap, bp, bp+4) switch (*TBitmapItem)(unsafe.Pointer(bmapPtr)).Fanchor { case int32(TK_ANCHOR_N): x -= *(*int32)(unsafe.Pointer(bp)) / int32(2) case int32(TK_ANCHOR_NE): x -= *(*int32)(unsafe.Pointer(bp)) case int32(TK_ANCHOR_E): x -= *(*int32)(unsafe.Pointer(bp)) y -= *(*int32)(unsafe.Pointer(bp + 4)) / int32(2) case int32(TK_ANCHOR_SE): x -= *(*int32)(unsafe.Pointer(bp)) y -= *(*int32)(unsafe.Pointer(bp + 4)) case int32(TK_ANCHOR_S): x -= *(*int32)(unsafe.Pointer(bp)) / int32(2) y -= *(*int32)(unsafe.Pointer(bp + 4)) case int32(TK_ANCHOR_SW): y -= *(*int32)(unsafe.Pointer(bp + 4)) case int32(TK_ANCHOR_W): y -= *(*int32)(unsafe.Pointer(bp + 4)) / int32(2) case int32(TK_ANCHOR_NW): default: x -= *(*int32)(unsafe.Pointer(bp)) / int32(2) y -= *(*int32)(unsafe.Pointer(bp + 4)) / int32(2) break } /* * Store the information in the item header. */ (*TBitmapItem)(unsafe.Pointer(bmapPtr)).Fheader.Fx1 = x (*TBitmapItem)(unsafe.Pointer(bmapPtr)).Fheader.Fy1 = y (*TBitmapItem)(unsafe.Pointer(bmapPtr)).Fheader.Fx2 = x + *(*int32)(unsafe.Pointer(bp)) (*TBitmapItem)(unsafe.Pointer(bmapPtr)).Fheader.Fy2 = y + *(*int32)(unsafe.Pointer(bp + 4)) } /* *-------------------------------------------------------------- * * DisplayBitmap -- * * This function is invoked to draw a bitmap item in a given drawable. * * Results: * None. * * Side effects: * ItemPtr is drawn in drawable using the transformation information in * canvas. * *-------------------------------------------------------------- */ func _DisplayBitmap(tls *libc.TLS, canvas TTk_Canvas, itemPtr uintptr, display uintptr, drawable TDrawable, x int32, y int32, width int32, height int32) { bp := tls.Alloc(16) defer tls.Free(16) /* Describes region of canvas that must be * redisplayed (not used). */ var bitmap TPixmap var bmapHeight, bmapWidth, bmapX, bmapY int32 var bmapPtr uintptr var state TTk_State var _ /* drawableX at bp+0 */ int16 var _ /* drawableY at bp+2 */ int16 _, _, _, _, _, _, _ = bitmap, bmapHeight, bmapPtr, bmapWidth, bmapX, bmapY, state bmapPtr = itemPtr state = (*TTk_Item)(unsafe.Pointer(itemPtr)).Fstate /* * If the area being displayed doesn't cover the whole bitmap, then only * redisplay the part of the bitmap that needs redisplay. */ if state == int32(TK_STATE_NULL) { state = (*TTkCanvas)(unsafe.Pointer(canvas)).Fcanvas_state } bitmap = (*TBitmapItem)(unsafe.Pointer(bmapPtr)).Fbitmap if (*TTkCanvas)(unsafe.Pointer(canvas)).FcurrentItemPtr == itemPtr { if (*TBitmapItem)(unsafe.Pointer(bmapPtr)).FactiveBitmap != uint64(0) { bitmap = (*TBitmapItem)(unsafe.Pointer(bmapPtr)).FactiveBitmap } } else { if state == int32(TK_STATE_DISABLED) { if (*TBitmapItem)(unsafe.Pointer(bmapPtr)).FdisabledBitmap != uint64(0) { bitmap = (*TBitmapItem)(unsafe.Pointer(bmapPtr)).FdisabledBitmap } } } if bitmap != uint64(0) { if x > (*TBitmapItem)(unsafe.Pointer(bmapPtr)).Fheader.Fx1 { bmapX = x - (*TBitmapItem)(unsafe.Pointer(bmapPtr)).Fheader.Fx1 bmapWidth = (*TBitmapItem)(unsafe.Pointer(bmapPtr)).Fheader.Fx2 - x } else { bmapX = 0 if x+width < (*TBitmapItem)(unsafe.Pointer(bmapPtr)).Fheader.Fx2 { bmapWidth = x + width - (*TBitmapItem)(unsafe.Pointer(bmapPtr)).Fheader.Fx1 } else { bmapWidth = (*TBitmapItem)(unsafe.Pointer(bmapPtr)).Fheader.Fx2 - (*TBitmapItem)(unsafe.Pointer(bmapPtr)).Fheader.Fx1 } } if y > (*TBitmapItem)(unsafe.Pointer(bmapPtr)).Fheader.Fy1 { bmapY = y - (*TBitmapItem)(unsafe.Pointer(bmapPtr)).Fheader.Fy1 bmapHeight = (*TBitmapItem)(unsafe.Pointer(bmapPtr)).Fheader.Fy2 - y } else { bmapY = 0 if y+height < (*TBitmapItem)(unsafe.Pointer(bmapPtr)).Fheader.Fy2 { bmapHeight = y + height - (*TBitmapItem)(unsafe.Pointer(bmapPtr)).Fheader.Fy1 } else { bmapHeight = (*TBitmapItem)(unsafe.Pointer(bmapPtr)).Fheader.Fy2 - (*TBitmapItem)(unsafe.Pointer(bmapPtr)).Fheader.Fy1 } } XTk_CanvasDrawableCoords(tls, canvas, float64((*TBitmapItem)(unsafe.Pointer(bmapPtr)).Fheader.Fx1+bmapX), float64((*TBitmapItem)(unsafe.Pointer(bmapPtr)).Fheader.Fy1+bmapY), bp, bp+2) /* * Must modify the mask origin within the graphics context to line up * with the bitmap's origin (in order to make bitmaps with * "-background {}" work right). */ libx11.XXSetClipOrigin(tls, display, (*TBitmapItem)(unsafe.Pointer(bmapPtr)).Fgc, int32(*(*int16)(unsafe.Pointer(bp)))-bmapX, int32(*(*int16)(unsafe.Pointer(bp + 2)))-bmapY) libx11.XXCopyPlane(tls, display, bitmap, drawable, (*TBitmapItem)(unsafe.Pointer(bmapPtr)).Fgc, bmapX, bmapY, libc.Uint32FromInt32(bmapWidth), libc.Uint32FromInt32(bmapHeight), int32(*(*int16)(unsafe.Pointer(bp))), int32(*(*int16)(unsafe.Pointer(bp + 2))), uint64(1)) libx11.XXSetClipOrigin(tls, display, (*TBitmapItem)(unsafe.Pointer(bmapPtr)).Fgc, 0, 0) } } /* *-------------------------------------------------------------- * * BitmapToPoint -- * * Computes the distance from a given point to a given rectangle, in * canvas units. * * Results: * The return value is 0 if the point whose x and y coordinates are * coordPtr[0] and coordPtr[1] is inside the bitmap. If the point isn't * inside the bitmap then the return value is the distance from the point * to the bitmap. * * Side effects: * None. * *-------------------------------------------------------------- */ func _BitmapToPoint(tls *libc.TLS, dummy675 TTk_Canvas, itemPtr uintptr, coordPtr uintptr) (r float64) { /* Pointer to x and y coordinates. */ var bmapPtr uintptr var x1, x2, xDiff, y1, y2, yDiff float64 _, _, _, _, _, _, _ = bmapPtr, x1, x2, xDiff, y1, y2, yDiff bmapPtr = itemPtr x1 = float64((*TBitmapItem)(unsafe.Pointer(bmapPtr)).Fheader.Fx1) y1 = float64((*TBitmapItem)(unsafe.Pointer(bmapPtr)).Fheader.Fy1) x2 = float64((*TBitmapItem)(unsafe.Pointer(bmapPtr)).Fheader.Fx2) y2 = float64((*TBitmapItem)(unsafe.Pointer(bmapPtr)).Fheader.Fy2) /* * Point is outside rectangle. */ if *(*float64)(unsafe.Pointer(coordPtr)) < x1 { xDiff = x1 - *(*float64)(unsafe.Pointer(coordPtr)) } else { if *(*float64)(unsafe.Pointer(coordPtr)) > x2 { xDiff = *(*float64)(unsafe.Pointer(coordPtr)) - x2 } else { xDiff = libc.Float64FromInt32(0) } } if *(*float64)(unsafe.Pointer(coordPtr + 1*8)) < y1 { yDiff = y1 - *(*float64)(unsafe.Pointer(coordPtr + 1*8)) } else { if *(*float64)(unsafe.Pointer(coordPtr + 1*8)) > y2 { yDiff = *(*float64)(unsafe.Pointer(coordPtr + 1*8)) - y2 } else { yDiff = libc.Float64FromInt32(0) } } return libc.X__builtin_hypot(tls, xDiff, yDiff) } /* *-------------------------------------------------------------- * * BitmapToArea -- * * This function is called to determine whether an item lies entirely * inside, entirely outside, or overlapping a given rectangle. * * Results: * -1 is returned if the item is entirely outside the area given by * rectPtr, 0 if it overlaps, and 1 if it is entirely inside the given * area. * * Side effects: * None. * *-------------------------------------------------------------- */ func _BitmapToArea(tls *libc.TLS, dummy731 TTk_Canvas, itemPtr uintptr, rectPtr uintptr) (r int32) { /* Pointer to array of four coordinates * (x1,y1,x2,y2) describing rectangular * area. */ var bmapPtr uintptr _ = bmapPtr bmapPtr = itemPtr if *(*float64)(unsafe.Pointer(rectPtr + 2*8)) <= float64((*TBitmapItem)(unsafe.Pointer(bmapPtr)).Fheader.Fx1) || *(*float64)(unsafe.Pointer(rectPtr)) >= float64((*TBitmapItem)(unsafe.Pointer(bmapPtr)).Fheader.Fx2) || *(*float64)(unsafe.Pointer(rectPtr + 3*8)) <= float64((*TBitmapItem)(unsafe.Pointer(bmapPtr)).Fheader.Fy1) || *(*float64)(unsafe.Pointer(rectPtr + 1*8)) >= float64((*TBitmapItem)(unsafe.Pointer(bmapPtr)).Fheader.Fy2) { return -int32(1) } if *(*float64)(unsafe.Pointer(rectPtr)) <= float64((*TBitmapItem)(unsafe.Pointer(bmapPtr)).Fheader.Fx1) && *(*float64)(unsafe.Pointer(rectPtr + 1*8)) <= float64((*TBitmapItem)(unsafe.Pointer(bmapPtr)).Fheader.Fy1) && *(*float64)(unsafe.Pointer(rectPtr + 2*8)) >= float64((*TBitmapItem)(unsafe.Pointer(bmapPtr)).Fheader.Fx2) && *(*float64)(unsafe.Pointer(rectPtr + 3*8)) >= float64((*TBitmapItem)(unsafe.Pointer(bmapPtr)).Fheader.Fy2) { return int32(1) } return 0 } /* *-------------------------------------------------------------- * * ScaleBitmap -- * * This function is invoked to rescale a bitmap item in a canvas. It is * one of the standard item functions for bitmap items, and is invoked by * the generic canvas code. * * Results: * None. * * Side effects: * The item referred to by itemPtr is rescaled so that the following * transformation is applied to all point coordinates: * x' = originX + scaleX*(x-originX) * y' = originY + scaleY*(y-originY) * *-------------------------------------------------------------- */ func _ScaleBitmap(tls *libc.TLS, canvas TTk_Canvas, itemPtr uintptr, originX float64, originY float64, scaleX float64, scaleY float64) { /* Amount to scale in Y direction. */ var bmapPtr uintptr _ = bmapPtr bmapPtr = itemPtr (*TBitmapItem)(unsafe.Pointer(bmapPtr)).Fx = originX + float64(scaleX*((*TBitmapItem)(unsafe.Pointer(bmapPtr)).Fx-originX)) (*TBitmapItem)(unsafe.Pointer(bmapPtr)).Fy = originY + float64(scaleY*((*TBitmapItem)(unsafe.Pointer(bmapPtr)).Fy-originY)) _ComputeBitmapBbox(tls, canvas, bmapPtr) } /* *-------------------------------------------------------------- * * RotateBitmap -- * * This function is called to rotate a bitmap's origin by a given amount. * * Results: * None. * * Side effects: * The position of the bitmap is rotated by angleRad radians about * (originX, originY), and the bounding box is updated in the generic * part of the item structure. * *-------------------------------------------------------------- */ func _RotateBitmap(tls *libc.TLS, canvas TTk_Canvas, itemPtr uintptr, originX float64, originY float64, angleRad float64) { var bmapPtr uintptr _ = bmapPtr bmapPtr = itemPtr XTkRotatePoint(tls, originX, originY, libc.Xsin(tls, angleRad), libc.Xcos(tls, angleRad), bmapPtr+120, bmapPtr+128) _ComputeBitmapBbox(tls, canvas, bmapPtr) } /* *-------------------------------------------------------------- * * TranslateBitmap -- * * This function is called to move an item by a given amount. * * Results: * None. * * Side effects: * The position of the item is offset by (xDelta, yDelta), and the * bounding box is updated in the generic part of the item structure. * *-------------------------------------------------------------- */ func _TranslateBitmap(tls *libc.TLS, canvas TTk_Canvas, itemPtr uintptr, deltaX float64, deltaY float64) { /* Amount by which item is to be moved. */ var bmapPtr uintptr _ = bmapPtr bmapPtr = itemPtr *(*float64)(unsafe.Pointer(bmapPtr + 120)) += deltaX *(*float64)(unsafe.Pointer(bmapPtr + 128)) += deltaY _ComputeBitmapBbox(tls, canvas, bmapPtr) } /* *-------------------------------------------------------------- * * BitmapToPostscript -- * * This function is called to generate Postscript for bitmap items. * * Results: * The return value is a standard Tcl result. If an error occurs in * generating Postscript then an error message is left in the interp's * result, replacing whatever used to be there. If no error occurs, then * Postscript for the item is appended to the result. * * Side effects: * None. * *-------------------------------------------------------------- */ func _BitmapToPostscript(tls *libc.TLS, interp uintptr, canvas TTk_Canvas, itemPtr uintptr, dummy879 int32) (r int32) { bp := tls.Alloc(64) defer tls.Free(64) /* 1 means this is a prepass to collect font * information; 0 means final Postscript is * being created. */ var _objPtr, _objPtr1, bgColor, bmapPtr, fgColor, psObj, v3, v5 uintptr var bitmap TPixmap var curRow, rowsAtOnce, rowsThisTime int32 var interpState TTcl_InterpState var state TTk_State var x, y float64 var v2, v4 TTcl_Size var _ /* height at bp+4 */ int32 var _ /* width at bp+0 */ int32 _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = _objPtr, _objPtr1, bgColor, bitmap, bmapPtr, curRow, fgColor, interpState, psObj, rowsAtOnce, rowsThisTime, state, x, y, v2, v3, v4, v5 bmapPtr = itemPtr state = (*TTk_Item)(unsafe.Pointer(itemPtr)).Fstate if state == int32(TK_STATE_NULL) { state = (*TTkCanvas)(unsafe.Pointer(canvas)).Fcanvas_state } fgColor = (*TBitmapItem)(unsafe.Pointer(bmapPtr)).FfgColor bgColor = (*TBitmapItem)(unsafe.Pointer(bmapPtr)).FbgColor bitmap = (*TBitmapItem)(unsafe.Pointer(bmapPtr)).Fbitmap if (*TTkCanvas)(unsafe.Pointer(canvas)).FcurrentItemPtr == itemPtr { if (*TBitmapItem)(unsafe.Pointer(bmapPtr)).FactiveFgColor != libc.UintptrFromInt32(0) { fgColor = (*TBitmapItem)(unsafe.Pointer(bmapPtr)).FactiveFgColor } if (*TBitmapItem)(unsafe.Pointer(bmapPtr)).FactiveBgColor != libc.UintptrFromInt32(0) { bgColor = (*TBitmapItem)(unsafe.Pointer(bmapPtr)).FactiveBgColor } if (*TBitmapItem)(unsafe.Pointer(bmapPtr)).FactiveBitmap != uint64(0) { bitmap = (*TBitmapItem)(unsafe.Pointer(bmapPtr)).FactiveBitmap } } else { if state == int32(TK_STATE_DISABLED) { if (*TBitmapItem)(unsafe.Pointer(bmapPtr)).FdisabledFgColor != libc.UintptrFromInt32(0) { fgColor = (*TBitmapItem)(unsafe.Pointer(bmapPtr)).FdisabledFgColor } if (*TBitmapItem)(unsafe.Pointer(bmapPtr)).FdisabledBgColor != libc.UintptrFromInt32(0) { bgColor = (*TBitmapItem)(unsafe.Pointer(bmapPtr)).FdisabledBgColor } if (*TBitmapItem)(unsafe.Pointer(bmapPtr)).FdisabledBitmap != uint64(0) { bitmap = (*TBitmapItem)(unsafe.Pointer(bmapPtr)).FdisabledBitmap } } } if bitmap == uint64(0) { return TCL_OK } /* * Compute the coordinates of the lower-left corner of the bitmap, taking * into account the anchor position for the bitmp. */ x = (*TBitmapItem)(unsafe.Pointer(bmapPtr)).Fx y = XTk_CanvasPsY(tls, canvas, (*TBitmapItem)(unsafe.Pointer(bmapPtr)).Fy) XTk_SizeOfBitmap(tls, (*TTk_FakeWin)(unsafe.Pointer(XTk_CanvasTkwin(tls, canvas))).Fdisplay, bitmap, bp, bp+4) switch (*TBitmapItem)(unsafe.Pointer(bmapPtr)).Fanchor { case int32(TK_ANCHOR_NW): y -= float64(*(*int32)(unsafe.Pointer(bp + 4))) case int32(TK_ANCHOR_N): x -= float64(*(*int32)(unsafe.Pointer(bp))) / float64(2) y -= float64(*(*int32)(unsafe.Pointer(bp + 4))) case int32(TK_ANCHOR_NE): x -= float64(*(*int32)(unsafe.Pointer(bp))) y -= float64(*(*int32)(unsafe.Pointer(bp + 4))) case int32(TK_ANCHOR_E): x -= float64(*(*int32)(unsafe.Pointer(bp))) y -= float64(*(*int32)(unsafe.Pointer(bp + 4))) / float64(2) case int32(TK_ANCHOR_SE): x -= float64(*(*int32)(unsafe.Pointer(bp))) case int32(TK_ANCHOR_S): x -= float64(*(*int32)(unsafe.Pointer(bp))) / float64(2) case int32(TK_ANCHOR_SW): case int32(TK_ANCHOR_W): y -= float64(*(*int32)(unsafe.Pointer(bp + 4))) / float64(2) default: x -= float64(*(*int32)(unsafe.Pointer(bp))) / float64(2) y -= float64(*(*int32)(unsafe.Pointer(bp + 4))) / float64(2) break } /* * Make our working space. */ psObj = libtcl9_0.XTcl_NewObj(tls) interpState = libtcl9_0.XTcl_SaveInterpState(tls, interp, TCL_OK) /* * Color the background, if there is one. */ if bgColor != libc.UintptrFromInt32(0) { libtcl9_0.XTcl_AppendPrintfToObj(tls, psObj, __ccgo_ts+29415, libc.VaList(bp+16, x, y, *(*int32)(unsafe.Pointer(bp)), *(*int32)(unsafe.Pointer(bp + 4)), -*(*int32)(unsafe.Pointer(bp)))) libtcl9_0.XTcl_ResetResult(tls, interp) XTk_CanvasPsColor(tls, interp, canvas, bgColor) libtcl9_0.XTcl_AppendObjToObj(tls, psObj, libtcl9_0.XTcl_GetObjResult(tls, interp)) libtcl9_0.XTcl_AppendToObj(tls, psObj, __ccgo_ts+29165, int64(-libc.Int32FromInt32(1))) } /* * Draw the bitmap, if there is a foreground color. If the bitmap is very * large, then chop it up into multiple bitmaps, each consisting of one or * more rows. This is needed because Postscript can't handle single * strings longer than 64 KBytes long. */ if fgColor != libc.UintptrFromInt32(0) { libtcl9_0.XTcl_ResetResult(tls, interp) XTk_CanvasPsColor(tls, interp, canvas, fgColor) libtcl9_0.XTcl_AppendObjToObj(tls, psObj, libtcl9_0.XTcl_GetObjResult(tls, interp)) if *(*int32)(unsafe.Pointer(bp)) > int32(60000) { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+29484, int64(-libc.Int32FromInt32(1)))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+16, __ccgo_ts+179, __ccgo_ts+27003, __ccgo_ts+29550, __ccgo_ts+29553, libc.UintptrFromInt32(0))) goto error } rowsAtOnce = int32(60000) / *(*int32)(unsafe.Pointer(bp)) if rowsAtOnce < int32(1) { rowsAtOnce = int32(1) } libtcl9_0.XTcl_AppendPrintfToObj(tls, psObj, __ccgo_ts+29562, libc.VaList(bp+16, x, y+float64(*(*int32)(unsafe.Pointer(bp + 4))))) curRow = 0 for { if !(curRow < *(*int32)(unsafe.Pointer(bp + 4))) { break } rowsThisTime = rowsAtOnce if rowsThisTime > *(*int32)(unsafe.Pointer(bp + 4))-curRow { rowsThisTime = *(*int32)(unsafe.Pointer(bp + 4)) - curRow } libtcl9_0.XTcl_AppendPrintfToObj(tls, psObj, __ccgo_ts+29585, libc.VaList(bp+16, float64(rowsThisTime), *(*int32)(unsafe.Pointer(bp)), rowsThisTime)) libtcl9_0.XTcl_ResetResult(tls, interp) XTk_CanvasPsBitmap(tls, interp, canvas, bitmap, 0, curRow, *(*int32)(unsafe.Pointer(bp)), rowsThisTime) libtcl9_0.XTcl_AppendObjToObj(tls, psObj, libtcl9_0.XTcl_GetObjResult(tls, interp)) libtcl9_0.XTcl_AppendToObj(tls, psObj, __ccgo_ts+29625, int64(-libc.Int32FromInt32(1))) goto _1 _1: ; curRow += rowsAtOnce } } /* * Plug the accumulated postscript back into the result. */ libtcl9_0.XTcl_RestoreInterpState(tls, interp, interpState) libtcl9_0.XTcl_AppendObjToObj(tls, libtcl9_0.XTcl_GetObjResult(tls, interp), psObj) _objPtr = psObj v3 = _objPtr v2 = *(*TTcl_Size)(unsafe.Pointer(v3)) *(*TTcl_Size)(unsafe.Pointer(v3))-- if v2 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr) } return TCL_OK goto error error: ; libtcl9_0.XTcl_DiscardInterpState(tls, interpState) _objPtr1 = psObj v5 = _objPtr1 v4 = *(*TTcl_Size)(unsafe.Pointer(v5)) *(*TTcl_Size)(unsafe.Pointer(v5))-- if v4 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr1) } return int32(TCL_ERROR) } /* * Convenience macro. */ /* * The structure below defines the record for each image item. */ type TImageItem = struct { Fheader TTk_Item Fcanvas TTk_Canvas Fx float64 Fy float64 Fanchor TTk_Anchor FimageObj uintptr FactiveImageObj uintptr FdisabledImageObj uintptr Fimage TTk_Image FactiveImage TTk_Image FdisabledImage TTk_Image } /* * Information used for parsing configuration specs: */ var _stateOption3 = TTk_CustomOption{ FclientData: uintptr(int64(libc.Int32FromInt32(2))), } func init() { p := unsafe.Pointer(&_stateOption3) *(*uintptr)(unsafe.Add(p, 0)) = __ccgo_fp(XTkStateParseProc) *(*uintptr)(unsafe.Add(p, 8)) = __ccgo_fp(XTkStatePrintProc) } var _tagsOption2 = TTk_CustomOption{} func init() { p := unsafe.Pointer(&_tagsOption2) *(*uintptr)(unsafe.Add(p, 0)) = __ccgo_fp(XTk_CanvasTagsParseProc) *(*uintptr)(unsafe.Add(p, 8)) = __ccgo_fp(XTk_CanvasTagsPrintProc) } var _configSpecs4 = [7]TTk_ConfigSpec{ 0: { Ftype1: int32(TK_CONFIG_STRING), FargvName: __ccgo_ts + 29639, Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 160)), FspecFlags: libc.Int32FromInt32(TK_CONFIG_OBJS) | libc.Int32FromInt32(TCL_NULL_OK), }, 1: { Ftype1: int32(TK_CONFIG_ANCHOR), FargvName: __ccgo_ts + 15168, FdefValue: __ccgo_ts + 10959, Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 144)), FspecFlags: libc.Int32FromInt32(1) << libc.Int32FromInt32(3), }, 2: { Ftype1: int32(TK_CONFIG_STRING), FargvName: __ccgo_ts + 29652, Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 168)), FspecFlags: libc.Int32FromInt32(TK_CONFIG_OBJS) | libc.Int32FromInt32(TCL_NULL_OK), }, 3: { Ftype1: int32(TK_CONFIG_STRING), FargvName: __ccgo_ts + 20294, Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 152)), FspecFlags: libc.Int32FromInt32(TK_CONFIG_OBJS) | libc.Int32FromInt32(TCL_NULL_OK), }, 4: { Ftype1: int32(TK_CONFIG_CUSTOM), FargvName: __ccgo_ts + 2957, Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 96)), FspecFlags: int32(TCL_NULL_OK), FcustomPtr: uintptr(unsafe.Pointer(&_stateOption3)), }, 5: { Ftype1: int32(TK_CONFIG_CUSTOM), FargvName: __ccgo_ts + 28895, FspecFlags: int32(TCL_NULL_OK), FcustomPtr: uintptr(unsafe.Pointer(&_tagsOption2)), }, 6: { Ftype1: int32(TK_CONFIG_END), }, } func init() { p := unsafe.Pointer(&XtkImageType) *(*uintptr)(unsafe.Add(p, 16)) = __ccgo_fp(_CreateImage) *(*uintptr)(unsafe.Add(p, 32)) = __ccgo_fp(_ConfigureImage) *(*uintptr)(unsafe.Add(p, 40)) = __ccgo_fp(_ImageCoords) *(*uintptr)(unsafe.Add(p, 48)) = __ccgo_fp(_DeleteImage) *(*uintptr)(unsafe.Add(p, 56)) = __ccgo_fp(_DisplayImage) *(*uintptr)(unsafe.Add(p, 72)) = __ccgo_fp(_ImageToPoint) *(*uintptr)(unsafe.Add(p, 80)) = __ccgo_fp(_ImageToArea) *(*uintptr)(unsafe.Add(p, 88)) = __ccgo_fp(_ImageToPostscript) *(*uintptr)(unsafe.Add(p, 96)) = __ccgo_fp(_ScaleImage) *(*uintptr)(unsafe.Add(p, 104)) = __ccgo_fp(_TranslateImage) *(*uintptr)(unsafe.Add(p, 160)) = __ccgo_fp(_RotateImage) } /* *-------------------------------------------------------------- * * CreateImage -- * * This function is invoked to create a new image item in a canvas. * * Results: * A standard Tcl return value. If an error occurred in creating the * item, then an error message is left in the interp's result; in this * case itemPtr is left uninitialized, so it can be safely freed by the * caller. * * Side effects: * A new image item is created. * *-------------------------------------------------------------- */ func _CreateImage(tls *libc.TLS, interp uintptr, canvas TTk_Canvas, itemPtr uintptr, objc TTcl_Size, objv uintptr) (r int32) { /* Arguments describing rectangle. */ var arg, imgPtr uintptr var i TTcl_Size _, _, _ = arg, i, imgPtr imgPtr = itemPtr if objc == 0 { libtcl9_0.XTcl_Panic(tls, __ccgo_ts+28901, 0) } /* * Initialize item's record. */ (*TImageItem)(unsafe.Pointer(imgPtr)).Fcanvas = canvas (*TImageItem)(unsafe.Pointer(imgPtr)).Fanchor = int32(TK_ANCHOR_CENTER) (*TImageItem)(unsafe.Pointer(imgPtr)).FimageObj = libc.UintptrFromInt32(0) (*TImageItem)(unsafe.Pointer(imgPtr)).FactiveImageObj = libc.UintptrFromInt32(0) (*TImageItem)(unsafe.Pointer(imgPtr)).FdisabledImageObj = libc.UintptrFromInt32(0) (*TImageItem)(unsafe.Pointer(imgPtr)).Fimage = libc.UintptrFromInt32(0) (*TImageItem)(unsafe.Pointer(imgPtr)).FactiveImage = libc.UintptrFromInt32(0) (*TImageItem)(unsafe.Pointer(imgPtr)).FdisabledImage = libc.UintptrFromInt32(0) /* * Process the arguments to fill in the item record. Only 1 (list) or 2 (x * y) coords are allowed. */ if objc == int64(1) { i = int64(1) } else { arg = libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8)), libc.UintptrFromInt32(0)) i = int64(2) if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(arg))) == int32('-') && libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(arg + 1))) >= int32('a') && libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(arg + 1))) <= int32('z') { i = int64(1) } } if _ImageCoords(tls, interp, canvas, itemPtr, i, objv) != TCL_OK { goto error } if _ConfigureImage(tls, interp, canvas, itemPtr, objc-i, objv+uintptr(i)*8, 0) == TCL_OK { return TCL_OK } goto error error: ; _DeleteImage(tls, canvas, itemPtr, (*TTk_FakeWin)(unsafe.Pointer(XTk_CanvasTkwin(tls, canvas))).Fdisplay) return int32(TCL_ERROR) } /* *-------------------------------------------------------------- * * ImageCoords -- * * This function is invoked to process the "coords" widget command on * image items. See the user documentation for details on what it does. * * Results: * Returns TCL_OK or TCL_ERROR, and sets the interp's result. * * Side effects: * The coordinates for the given item may be changed. * *-------------------------------------------------------------- */ func _ImageCoords(tls *libc.TLS, interp uintptr, canvas TTk_Canvas, itemPtr uintptr, _objc TTcl_Size, _objv uintptr) (r int32) { bp := tls.Alloc(80) defer tls.Free(80) *(*TTcl_Size)(unsafe.Pointer(bp)) = _objc *(*uintptr)(unsafe.Pointer(bp + 8)) = _objv /* Array of coordinates: x1, y1, x2, y2, ... */ var imgPtr uintptr var _ /* objs at bp+16 */ [2]uintptr _ = imgPtr imgPtr = itemPtr if *(*TTcl_Size)(unsafe.Pointer(bp)) == 0 { (*(*[2]uintptr)(unsafe.Pointer(bp + 16)))[0] = libtcl9_0.XTcl_NewDoubleObj(tls, (*TImageItem)(unsafe.Pointer(imgPtr)).Fx) (*(*[2]uintptr)(unsafe.Pointer(bp + 16)))[int32(1)] = libtcl9_0.XTcl_NewDoubleObj(tls, (*TImageItem)(unsafe.Pointer(imgPtr)).Fy) libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewListObj(tls, int64(2), bp+16)) } else { if *(*TTcl_Size)(unsafe.Pointer(bp)) < int64(3) { if *(*TTcl_Size)(unsafe.Pointer(bp)) == int64(1) { if libtcl9_0.XTcl_ListObjGetElements(tls, interp, *(*uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 8)))), bp, bp+8) != TCL_OK { return int32(TCL_ERROR) } else { if *(*TTcl_Size)(unsafe.Pointer(bp)) != int64(2) { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+29328, libc.VaList(bp+40, *(*TTcl_Size)(unsafe.Pointer(bp))))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+40, __ccgo_ts+179, __ccgo_ts+27003, __ccgo_ts+28973, __ccgo_ts+29667, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) } } } if XTk_CanvasGetCoordFromObj(tls, interp, canvas, *(*uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 8)))), imgPtr+128) != TCL_OK || XTk_CanvasGetCoordFromObj(tls, interp, canvas, *(*uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 8)) + 1*8)), imgPtr+136) != TCL_OK { return int32(TCL_ERROR) } _ComputeImageBbox(tls, canvas, imgPtr) } else { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+29369, libc.VaList(bp+40, *(*TTcl_Size)(unsafe.Pointer(bp))))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+40, __ccgo_ts+179, __ccgo_ts+27003, __ccgo_ts+28973, __ccgo_ts+29667, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) } } return TCL_OK } /* *-------------------------------------------------------------- * * ConfigureImage -- * * This function is invoked to configure various aspects of an image * item, such as its anchor position. * * Results: * A standard Tcl result code. If an error occurs, then an error message * is left in the interp's result. * * Side effects: * Configuration information may be set for itemPtr. * *-------------------------------------------------------------- */ func _ConfigureImage(tls *libc.TLS, interp uintptr, canvas TTk_Canvas, itemPtr uintptr, objc TTcl_Size, objv uintptr, flags int32) (r int32) { /* Flags to pass to Tk_ConfigureWidget. */ var image TTk_Image var imgPtr uintptr var tkwin TTk_Window _, _, _ = image, imgPtr, tkwin imgPtr = itemPtr tkwin = XTk_CanvasTkwin(tls, canvas) if TCL_OK != XTk_ConfigureWidget(tls, interp, tkwin, uintptr(unsafe.Pointer(&_configSpecs4)), objc, objv, imgPtr, flags) { return int32(TCL_ERROR) } /* * Create the image. Save the old image around and don't free it until * after the new one is allocated. This keeps the reference count from * going to zero so the image doesn't have to be recreated if it hasn't * changed. */ if (*TImageItem)(unsafe.Pointer(imgPtr)).FactiveImageObj != libc.UintptrFromInt32(0) { *(*int32)(unsafe.Pointer(itemPtr + 112)) |= int32(TK_ITEM_STATE_DEPENDANT) } else { *(*int32)(unsafe.Pointer(itemPtr + 112)) &= ^libc.Int32FromInt32(TK_ITEM_STATE_DEPENDANT) } if (*TImageItem)(unsafe.Pointer(imgPtr)).FimageObj != libc.UintptrFromInt32(0) { image = XTk_GetImage(tls, interp, tkwin, libtcl9_0.XTcl_GetStringFromObj(tls, (*TImageItem)(unsafe.Pointer(imgPtr)).FimageObj, libc.UintptrFromInt32(0)), __ccgo_fp(_ImageChangedProc), imgPtr) if image == libc.UintptrFromInt32(0) { return int32(TCL_ERROR) } } else { image = libc.UintptrFromInt32(0) } if (*TImageItem)(unsafe.Pointer(imgPtr)).Fimage != libc.UintptrFromInt32(0) { XTk_FreeImage(tls, (*TImageItem)(unsafe.Pointer(imgPtr)).Fimage) } (*TImageItem)(unsafe.Pointer(imgPtr)).Fimage = image if (*TImageItem)(unsafe.Pointer(imgPtr)).FactiveImageObj != libc.UintptrFromInt32(0) { image = XTk_GetImage(tls, interp, tkwin, libtcl9_0.XTcl_GetStringFromObj(tls, (*TImageItem)(unsafe.Pointer(imgPtr)).FactiveImageObj, libc.UintptrFromInt32(0)), __ccgo_fp(_ImageChangedProc), imgPtr) if image == libc.UintptrFromInt32(0) { return int32(TCL_ERROR) } } else { image = libc.UintptrFromInt32(0) } if (*TImageItem)(unsafe.Pointer(imgPtr)).FactiveImage != libc.UintptrFromInt32(0) { XTk_FreeImage(tls, (*TImageItem)(unsafe.Pointer(imgPtr)).FactiveImage) } (*TImageItem)(unsafe.Pointer(imgPtr)).FactiveImage = image if (*TImageItem)(unsafe.Pointer(imgPtr)).FdisabledImageObj != libc.UintptrFromInt32(0) { image = XTk_GetImage(tls, interp, tkwin, libtcl9_0.XTcl_GetStringFromObj(tls, (*TImageItem)(unsafe.Pointer(imgPtr)).FdisabledImageObj, libc.UintptrFromInt32(0)), __ccgo_fp(_ImageChangedProc), imgPtr) if image == libc.UintptrFromInt32(0) { return int32(TCL_ERROR) } } else { image = libc.UintptrFromInt32(0) } if (*TImageItem)(unsafe.Pointer(imgPtr)).FdisabledImage != libc.UintptrFromInt32(0) { XTk_FreeImage(tls, (*TImageItem)(unsafe.Pointer(imgPtr)).FdisabledImage) } (*TImageItem)(unsafe.Pointer(imgPtr)).FdisabledImage = image _ComputeImageBbox(tls, canvas, imgPtr) return TCL_OK } /* *-------------------------------------------------------------- * * DeleteImage -- * * This function is called to clean up the data structure associated with * a image item. * * Results: * None. * * Side effects: * Resources associated with itemPtr are released. * *-------------------------------------------------------------- */ func _DeleteImage(tls *libc.TLS, dummy382 TTk_Canvas, itemPtr uintptr, dummy384 uintptr) { /* Display containing window for canvas. */ var _objPtr, _objPtr1, _objPtr2, imgPtr, v2, v4, v6 uintptr var v1, v3, v5 TTcl_Size _, _, _, _, _, _, _, _, _, _ = _objPtr, _objPtr1, _objPtr2, imgPtr, v1, v2, v3, v4, v5, v6 imgPtr = itemPtr if (*TImageItem)(unsafe.Pointer(imgPtr)).FimageObj != libc.UintptrFromInt32(0) { _objPtr = (*TImageItem)(unsafe.Pointer(imgPtr)).FimageObj v2 = _objPtr v1 = *(*TTcl_Size)(unsafe.Pointer(v2)) *(*TTcl_Size)(unsafe.Pointer(v2))-- if v1 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr) } } if (*TImageItem)(unsafe.Pointer(imgPtr)).FactiveImageObj != libc.UintptrFromInt32(0) { _objPtr1 = (*TImageItem)(unsafe.Pointer(imgPtr)).FactiveImageObj v4 = _objPtr1 v3 = *(*TTcl_Size)(unsafe.Pointer(v4)) *(*TTcl_Size)(unsafe.Pointer(v4))-- if v3 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr1) } } if (*TImageItem)(unsafe.Pointer(imgPtr)).FdisabledImageObj != libc.UintptrFromInt32(0) { _objPtr2 = (*TImageItem)(unsafe.Pointer(imgPtr)).FdisabledImageObj v6 = _objPtr2 v5 = *(*TTcl_Size)(unsafe.Pointer(v6)) *(*TTcl_Size)(unsafe.Pointer(v6))-- if v5 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr2) } } if (*TImageItem)(unsafe.Pointer(imgPtr)).Fimage != libc.UintptrFromInt32(0) { XTk_FreeImage(tls, (*TImageItem)(unsafe.Pointer(imgPtr)).Fimage) } if (*TImageItem)(unsafe.Pointer(imgPtr)).FactiveImage != libc.UintptrFromInt32(0) { XTk_FreeImage(tls, (*TImageItem)(unsafe.Pointer(imgPtr)).FactiveImage) } if (*TImageItem)(unsafe.Pointer(imgPtr)).FdisabledImage != libc.UintptrFromInt32(0) { XTk_FreeImage(tls, (*TImageItem)(unsafe.Pointer(imgPtr)).FdisabledImage) } } /* *-------------------------------------------------------------- * * ComputeImageBbox -- * * This function is invoked to compute the bounding box of all the pixels * that may be drawn as part of a image item. This function is where the * child image's placement is computed. * * Results: * None. * * Side effects: * The fields x1, y1, x2, and y2 are updated in the header for itemPtr. * *-------------------------------------------------------------- */ func _ComputeImageBbox(tls *libc.TLS, canvas TTk_Canvas, imgPtr uintptr) { bp := tls.Alloc(16) defer tls.Free(16) /* Item whose bbox is to be recomputed. */ var image TTk_Image var state TTk_State var x, y, v3, v4 int32 var v1, v2 float64 var _ /* height at bp+4 */ int32 var _ /* width at bp+0 */ int32 _, _, _, _, _, _, _, _ = image, state, x, y, v1, v2, v3, v4 state = (*TImageItem)(unsafe.Pointer(imgPtr)).Fheader.Fstate if state == int32(TK_STATE_NULL) { state = (*TTkCanvas)(unsafe.Pointer(canvas)).Fcanvas_state } image = (*TImageItem)(unsafe.Pointer(imgPtr)).Fimage if (*TTkCanvas)(unsafe.Pointer(canvas)).FcurrentItemPtr == imgPtr { if (*TImageItem)(unsafe.Pointer(imgPtr)).FactiveImage != libc.UintptrFromInt32(0) { image = (*TImageItem)(unsafe.Pointer(imgPtr)).FactiveImage } } else { if state == int32(TK_STATE_DISABLED) { if (*TImageItem)(unsafe.Pointer(imgPtr)).FdisabledImage != libc.UintptrFromInt32(0) { image = (*TImageItem)(unsafe.Pointer(imgPtr)).FdisabledImage } } } if (*TImageItem)(unsafe.Pointer(imgPtr)).Fx >= libc.Float64FromInt32(0) { v1 = float64(0.5) } else { v1 = -libc.Float64FromFloat64(0.5) } x = int32((*TImageItem)(unsafe.Pointer(imgPtr)).Fx + v1) if (*TImageItem)(unsafe.Pointer(imgPtr)).Fy >= libc.Float64FromInt32(0) { v2 = float64(0.5) } else { v2 = -libc.Float64FromFloat64(0.5) } y = int32((*TImageItem)(unsafe.Pointer(imgPtr)).Fy + v2) if state == int32(TK_STATE_HIDDEN) || image == libc.UintptrFromInt32(0) { v3 = x (*TImageItem)(unsafe.Pointer(imgPtr)).Fheader.Fx2 = v3 (*TImageItem)(unsafe.Pointer(imgPtr)).Fheader.Fx1 = v3 v4 = y (*TImageItem)(unsafe.Pointer(imgPtr)).Fheader.Fy2 = v4 (*TImageItem)(unsafe.Pointer(imgPtr)).Fheader.Fy1 = v4 return } /* * Compute location and size of image, using anchor information. */ XTk_SizeOfImage(tls, image, bp, bp+4) switch (*TImageItem)(unsafe.Pointer(imgPtr)).Fanchor { case int32(TK_ANCHOR_N): x -= *(*int32)(unsafe.Pointer(bp)) / int32(2) case int32(TK_ANCHOR_NE): x -= *(*int32)(unsafe.Pointer(bp)) case int32(TK_ANCHOR_E): x -= *(*int32)(unsafe.Pointer(bp)) y -= *(*int32)(unsafe.Pointer(bp + 4)) / int32(2) case int32(TK_ANCHOR_SE): x -= *(*int32)(unsafe.Pointer(bp)) y -= *(*int32)(unsafe.Pointer(bp + 4)) case int32(TK_ANCHOR_S): x -= *(*int32)(unsafe.Pointer(bp)) / int32(2) y -= *(*int32)(unsafe.Pointer(bp + 4)) case int32(TK_ANCHOR_SW): y -= *(*int32)(unsafe.Pointer(bp + 4)) case int32(TK_ANCHOR_W): y -= *(*int32)(unsafe.Pointer(bp + 4)) / int32(2) case int32(TK_ANCHOR_NW): default: x -= *(*int32)(unsafe.Pointer(bp)) / int32(2) y -= *(*int32)(unsafe.Pointer(bp + 4)) / int32(2) break } /* * Store the information in the item header. */ (*TImageItem)(unsafe.Pointer(imgPtr)).Fheader.Fx1 = x (*TImageItem)(unsafe.Pointer(imgPtr)).Fheader.Fy1 = y (*TImageItem)(unsafe.Pointer(imgPtr)).Fheader.Fx2 = x + *(*int32)(unsafe.Pointer(bp)) (*TImageItem)(unsafe.Pointer(imgPtr)).Fheader.Fy2 = y + *(*int32)(unsafe.Pointer(bp + 4)) } /* *-------------------------------------------------------------- * * DisplayImage -- * * This function is invoked to draw a image item in a given drawable. * * Results: * None. * * Side effects: * ItemPtr is drawn in drawable using the transformation information in * canvas. * *-------------------------------------------------------------- */ func _DisplayImage(tls *libc.TLS, canvas TTk_Canvas, itemPtr uintptr, dummy528 uintptr, drawable TDrawable, x int32, y int32, width int32, height int32) { bp := tls.Alloc(16) defer tls.Free(16) /* Describes region of canvas that must be * redisplayed (not used). */ var image TTk_Image var imgPtr uintptr var state TTk_State var _ /* drawableX at bp+0 */ int16 var _ /* drawableY at bp+2 */ int16 _, _, _ = image, imgPtr, state imgPtr = itemPtr state = (*TTk_Item)(unsafe.Pointer(itemPtr)).Fstate if state == int32(TK_STATE_NULL) { state = (*TTkCanvas)(unsafe.Pointer(canvas)).Fcanvas_state } image = (*TImageItem)(unsafe.Pointer(imgPtr)).Fimage if (*TTkCanvas)(unsafe.Pointer(canvas)).FcurrentItemPtr == itemPtr { if (*TImageItem)(unsafe.Pointer(imgPtr)).FactiveImage != libc.UintptrFromInt32(0) { image = (*TImageItem)(unsafe.Pointer(imgPtr)).FactiveImage } } else { if state == int32(TK_STATE_DISABLED) { if (*TImageItem)(unsafe.Pointer(imgPtr)).FdisabledImage != libc.UintptrFromInt32(0) { image = (*TImageItem)(unsafe.Pointer(imgPtr)).FdisabledImage } } } if image == libc.UintptrFromInt32(0) { return } /* * Translate the coordinates to those of the image, then redisplay it. */ XTk_CanvasDrawableCoords(tls, canvas, float64(x), float64(y), bp, bp+2) XTk_RedrawImage(tls, image, x-(*TImageItem)(unsafe.Pointer(imgPtr)).Fheader.Fx1, y-(*TImageItem)(unsafe.Pointer(imgPtr)).Fheader.Fy1, width, height, drawable, int32(*(*int16)(unsafe.Pointer(bp))), int32(*(*int16)(unsafe.Pointer(bp + 2)))) } /* *-------------------------------------------------------------- * * ImageToPoint -- * * Computes the distance from a given point to a given rectangle, in * canvas units. * * Results: * The return value is 0 if the point whose x and y coordinates are * coordPtr[0] and coordPtr[1] is inside the image. If the point isn't * inside the image then the return value is the distance from the point * to the image. * * Side effects: * None. * *-------------------------------------------------------------- */ func _ImageToPoint(tls *libc.TLS, dummy590 TTk_Canvas, itemPtr uintptr, coordPtr uintptr) (r float64) { /* Pointer to x and y coordinates. */ var imgPtr uintptr var x1, x2, xDiff, y1, y2, yDiff float64 _, _, _, _, _, _, _ = imgPtr, x1, x2, xDiff, y1, y2, yDiff imgPtr = itemPtr x1 = float64((*TImageItem)(unsafe.Pointer(imgPtr)).Fheader.Fx1) y1 = float64((*TImageItem)(unsafe.Pointer(imgPtr)).Fheader.Fy1) x2 = float64((*TImageItem)(unsafe.Pointer(imgPtr)).Fheader.Fx2) y2 = float64((*TImageItem)(unsafe.Pointer(imgPtr)).Fheader.Fy2) /* * Point is outside rectangle. */ if *(*float64)(unsafe.Pointer(coordPtr)) < x1 { xDiff = x1 - *(*float64)(unsafe.Pointer(coordPtr)) } else { if *(*float64)(unsafe.Pointer(coordPtr)) > x2 { xDiff = *(*float64)(unsafe.Pointer(coordPtr)) - x2 } else { xDiff = libc.Float64FromInt32(0) } } if *(*float64)(unsafe.Pointer(coordPtr + 1*8)) < y1 { yDiff = y1 - *(*float64)(unsafe.Pointer(coordPtr + 1*8)) } else { if *(*float64)(unsafe.Pointer(coordPtr + 1*8)) > y2 { yDiff = *(*float64)(unsafe.Pointer(coordPtr + 1*8)) - y2 } else { yDiff = libc.Float64FromInt32(0) } } return libc.X__builtin_hypot(tls, xDiff, yDiff) } /* *-------------------------------------------------------------- * * ImageToArea -- * * This function is called to determine whether an item lies entirely * inside, entirely outside, or overlapping a given rectangle. * * Results: * -1 is returned if the item is entirely outside the area given by * rectPtr, 0 if it overlaps, and 1 if it is entirely inside the given * area. * * Side effects: * None. * *-------------------------------------------------------------- */ func _ImageToArea(tls *libc.TLS, dummy646 TTk_Canvas, itemPtr uintptr, rectPtr uintptr) (r int32) { /* Pointer to array of four coordinates * (x1,y1,x2,y2) describing rectangular * area. */ var imgPtr uintptr _ = imgPtr imgPtr = itemPtr if *(*float64)(unsafe.Pointer(rectPtr + 2*8)) <= float64((*TImageItem)(unsafe.Pointer(imgPtr)).Fheader.Fx1) || *(*float64)(unsafe.Pointer(rectPtr)) >= float64((*TImageItem)(unsafe.Pointer(imgPtr)).Fheader.Fx2) || *(*float64)(unsafe.Pointer(rectPtr + 3*8)) <= float64((*TImageItem)(unsafe.Pointer(imgPtr)).Fheader.Fy1) || *(*float64)(unsafe.Pointer(rectPtr + 1*8)) >= float64((*TImageItem)(unsafe.Pointer(imgPtr)).Fheader.Fy2) { return -int32(1) } if *(*float64)(unsafe.Pointer(rectPtr)) <= float64((*TImageItem)(unsafe.Pointer(imgPtr)).Fheader.Fx1) && *(*float64)(unsafe.Pointer(rectPtr + 1*8)) <= float64((*TImageItem)(unsafe.Pointer(imgPtr)).Fheader.Fy1) && *(*float64)(unsafe.Pointer(rectPtr + 2*8)) >= float64((*TImageItem)(unsafe.Pointer(imgPtr)).Fheader.Fx2) && *(*float64)(unsafe.Pointer(rectPtr + 3*8)) >= float64((*TImageItem)(unsafe.Pointer(imgPtr)).Fheader.Fy2) { return int32(1) } return 0 } /* *-------------------------------------------------------------- * * ImageToPostscript -- * * This function is called to generate Postscript for image items. * * Results: * The return value is a standard Tcl result. If an error occurs in * generating Postscript then an error message is left in interp->result, * replacing whatever used to be there. If no error occurs, then * Postscript for the item is appended to the result. * * Side effects: * None. * *-------------------------------------------------------------- */ func _ImageToPostscript(tls *libc.TLS, interp uintptr, canvas TTk_Canvas, itemPtr uintptr, prepass int32) (r int32) { bp := tls.Alloc(32) defer tls.Free(32) /* 1 means this is a prepass to collect font * information; 0 means final Postscript is * being created.*/ var canvasWin TTk_Window var image TTk_Image var imgPtr, psObj uintptr var state TTk_State var x, y float64 var _ /* height at bp+4 */ int32 var _ /* width at bp+0 */ int32 _, _, _, _, _, _, _ = canvasWin, image, imgPtr, psObj, state, x, y imgPtr = itemPtr canvasWin = XTk_CanvasTkwin(tls, canvas) state = (*TTk_Item)(unsafe.Pointer(itemPtr)).Fstate if state == int32(TK_STATE_NULL) { state = (*TTkCanvas)(unsafe.Pointer(canvas)).Fcanvas_state } image = (*TImageItem)(unsafe.Pointer(imgPtr)).Fimage if (*TTkCanvas)(unsafe.Pointer(canvas)).FcurrentItemPtr == itemPtr { if (*TImageItem)(unsafe.Pointer(imgPtr)).FactiveImage != libc.UintptrFromInt32(0) { image = (*TImageItem)(unsafe.Pointer(imgPtr)).FactiveImage } } else { if state == int32(TK_STATE_DISABLED) { if (*TImageItem)(unsafe.Pointer(imgPtr)).FdisabledImage != libc.UintptrFromInt32(0) { image = (*TImageItem)(unsafe.Pointer(imgPtr)).FdisabledImage } } } if image == libc.UintptrFromInt32(0) { /* * Image item without actual image specified. */ return TCL_OK } XTk_SizeOfImage(tls, image, bp, bp+4) /* * Compute the coordinates of the lower-left corner of the image, taking * into account the anchor position for the image. */ x = (*TImageItem)(unsafe.Pointer(imgPtr)).Fx y = XTk_CanvasPsY(tls, canvas, (*TImageItem)(unsafe.Pointer(imgPtr)).Fy) switch (*TImageItem)(unsafe.Pointer(imgPtr)).Fanchor { case int32(TK_ANCHOR_NW): y -= float64(*(*int32)(unsafe.Pointer(bp + 4))) case int32(TK_ANCHOR_N): x -= float64(*(*int32)(unsafe.Pointer(bp))) / float64(2) y -= float64(*(*int32)(unsafe.Pointer(bp + 4))) case int32(TK_ANCHOR_NE): x -= float64(*(*int32)(unsafe.Pointer(bp))) y -= float64(*(*int32)(unsafe.Pointer(bp + 4))) case int32(TK_ANCHOR_E): x -= float64(*(*int32)(unsafe.Pointer(bp))) y -= float64(*(*int32)(unsafe.Pointer(bp + 4))) / float64(2) case int32(TK_ANCHOR_SE): x -= float64(*(*int32)(unsafe.Pointer(bp))) case int32(TK_ANCHOR_S): x -= float64(*(*int32)(unsafe.Pointer(bp))) / float64(2) case int32(TK_ANCHOR_SW): case int32(TK_ANCHOR_W): y -= float64(*(*int32)(unsafe.Pointer(bp + 4))) / float64(2) default: x -= float64(*(*int32)(unsafe.Pointer(bp))) / float64(2) y -= float64(*(*int32)(unsafe.Pointer(bp + 4))) / float64(2) break } if !(prepass != 0) { psObj = libtcl9_0.XTcl_GetObjResult(tls, interp) if (*TTcl_Obj)(unsafe.Pointer(psObj)).FrefCount > int64(1) { psObj = libtcl9_0.XTcl_DuplicateObj(tls, psObj) libtcl9_0.XTcl_SetObjResult(tls, interp, psObj) } libtcl9_0.XTcl_AppendPrintfToObj(tls, psObj, __ccgo_ts+29562, libc.VaList(bp+16, x, y)) } return XTk_PostscriptImage(tls, image, interp, canvasWin, (*TTkCanvas)(unsafe.Pointer(canvas)).FpsInfo, 0, 0, *(*int32)(unsafe.Pointer(bp)), *(*int32)(unsafe.Pointer(bp + 4)), prepass) } /* *-------------------------------------------------------------- * * RotateImage -- * * This function is called to rotate an image's origin by a given amount. * This does *not* rotate the contents of the image. * * Results: * None. * * Side effects: * The position of the image anchor is rotated by angleRad radians about * (originX, originY), and the bounding box is updated in the generic * part of the item structure. * *-------------------------------------------------------------- */ func _RotateImage(tls *libc.TLS, canvas TTk_Canvas, itemPtr uintptr, originX float64, originY float64, angleRad float64) { var imgPtr uintptr _ = imgPtr imgPtr = itemPtr XTkRotatePoint(tls, originX, originY, libc.Xsin(tls, angleRad), libc.Xcos(tls, angleRad), imgPtr+128, imgPtr+136) _ComputeImageBbox(tls, canvas, imgPtr) } /* *-------------------------------------------------------------- * * ScaleImage -- * * This function is invoked to rescale an item. * * Results: * None. * * Side effects: * The item referred to by itemPtr is rescaled so that the following * transformation is applied to all point coordinates: * x' = originX + scaleX*(x-originX) * y' = originY + scaleY*(y-originY) * *-------------------------------------------------------------- */ func _ScaleImage(tls *libc.TLS, canvas TTk_Canvas, itemPtr uintptr, originX float64, originY float64, scaleX float64, scaleY float64) { /* Amount to scale in Y direction. */ var imgPtr uintptr _ = imgPtr imgPtr = itemPtr (*TImageItem)(unsafe.Pointer(imgPtr)).Fx = originX + float64(scaleX*((*TImageItem)(unsafe.Pointer(imgPtr)).Fx-originX)) (*TImageItem)(unsafe.Pointer(imgPtr)).Fy = originY + float64(scaleY*((*TImageItem)(unsafe.Pointer(imgPtr)).Fy-originY)) _ComputeImageBbox(tls, canvas, imgPtr) } /* *-------------------------------------------------------------- * * TranslateImage -- * * This function is called to move an item by a given amount. * * Results: * None. * * Side effects: * The position of the item is offset by (xDelta, yDelta), and the * bounding box is updated in the generic part of the item structure. * *-------------------------------------------------------------- */ func _TranslateImage(tls *libc.TLS, canvas TTk_Canvas, itemPtr uintptr, deltaX float64, deltaY float64) { /* Amount by which item is to be moved. */ var imgPtr uintptr _ = imgPtr imgPtr = itemPtr *(*float64)(unsafe.Pointer(imgPtr + 128)) += deltaX *(*float64)(unsafe.Pointer(imgPtr + 136)) += deltaY _ComputeImageBbox(tls, canvas, imgPtr) } /* *---------------------------------------------------------------------- * * ImageChangedProc -- * * This function is invoked by the image code whenever the manager for an * image does something that affects the image's size or how it is * displayed. * * Results: * None. * * Side effects: * Arranges for the canvas to get redisplayed. * *---------------------------------------------------------------------- */ func _ImageChangedProc(tls *libc.TLS, clientData uintptr, x int32, y int32, width int32, height int32, imgWidth int32, imgHeight int32) { /* New dimensions of image. */ var imgPtr uintptr var v1 int32 _, _ = imgPtr, v1 imgPtr = clientData /* * If the image's size changed and it's not anchored at its northwest * corner then just redisplay the entire area of the image. This is a bit * over-conservative, but we need to do something because a size change * also means a position change. */ if (*TImageItem)(unsafe.Pointer(imgPtr)).Fheader.Fx2-(*TImageItem)(unsafe.Pointer(imgPtr)).Fheader.Fx1 != imgWidth || (*TImageItem)(unsafe.Pointer(imgPtr)).Fheader.Fy2-(*TImageItem)(unsafe.Pointer(imgPtr)).Fheader.Fy1 != imgHeight { v1 = libc.Int32FromInt32(0) y = v1 x = v1 width = imgWidth height = imgHeight XTk_CanvasEventuallyRedraw(tls, (*TImageItem)(unsafe.Pointer(imgPtr)).Fcanvas, (*TImageItem)(unsafe.Pointer(imgPtr)).Fheader.Fx1, (*TImageItem)(unsafe.Pointer(imgPtr)).Fheader.Fy1, (*TImageItem)(unsafe.Pointer(imgPtr)).Fheader.Fx2, (*TImageItem)(unsafe.Pointer(imgPtr)).Fheader.Fy2) } _ComputeImageBbox(tls, (*TImageItem)(unsafe.Pointer(imgPtr)).Fcanvas, imgPtr) XTk_CanvasEventuallyRedraw(tls, (*TImageItem)(unsafe.Pointer(imgPtr)).Fcanvas, (*TImageItem)(unsafe.Pointer(imgPtr)).Fheader.Fx1+x, (*TImageItem)(unsafe.Pointer(imgPtr)).Fheader.Fy1+y, (*TImageItem)(unsafe.Pointer(imgPtr)).Fheader.Fx1+x+width, (*TImageItem)(unsafe.Pointer(imgPtr)).Fheader.Fy1+y+height) } const MAX_STATIC_POINTS = 200 const PTS_IN_ARROW = 6 /* * Convenience macro. */ /* * default.h -- * * This file defines the defaults for all options for all of * the Tk widgets. * * Copyright © 1991-1994 The Regents of the University of California. * Copyright © 1994 Sun Microsystems, Inc. * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. */ /* * tkUnixDefault.h -- * * This file defines the defaults for all options for all of * the Tk widgets. * * Copyright © 1991-1994 The Regents of the University of California. * Copyright © 1994-1997 Sun Microsystems, Inc. * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. */ /* * The definitions below provide symbolic names for the default colors. * NORMAL_BG - Normal background color. * ACTIVE_BG - Background color when widget is active. * SELECT_BG - Background color for selected text. * TROUGH - Background color for troughs in scales and scrollbars. * INDICATOR - Color for indicator when button is selected. * DISABLED - Foreground color when widget is disabled. * PLACEHOLDER_FG - Foreground color for placeholder text. */ /* * Defaults for labels, buttons, checkbuttons, and radiobuttons: */ /* * Defaults for canvases: */ /* * Defaults for entries: */ /* * Defaults for frames: */ /* * Defaults for labelframes: */ /* * Defaults for listboxes: */ /* * Defaults for individual entries of menus: */ /* * Defaults for menus overall: */ /* * Defaults for menubuttons: */ /* * Defaults for messages: */ /* * Defaults for panedwindows */ /* * Defaults for panedwindow panes */ /* * Defaults for scales: */ /* * Defaults for scrollbars: */ /* * Defaults for texts: */ /* * Defaults for canvas text: */ /* * Defaults for canvas items * (arcs, bitmaps, lines, polygons, rectangles, and ovals): */ /* * Defaults for toplevels (most of the defaults for frames also apply * to toplevels): */ /* * Defaults for busy windows: */ /* * The structure below defines the record for each line item. */ type TArrows = int32 const ARROWS_NONE = 0 const ARROWS_FIRST = 1 const ARROWS_LAST = 2 const ARROWS_BOTH = 3 type TLineItem = struct { Fheader TTk_Item Foutline TTk_Outline Fcanvas TTk_Canvas FnumPoints TTcl_Size FcoordPtr uintptr FcapStyle int32 FjoinStyle int32 FarrowGC TGC Farrow TArrows FarrowShapeA float32 FarrowShapeB float32 FarrowShapeC float32 FfirstArrowPtr uintptr FlastArrowPtr uintptr Fsmooth uintptr FsplineSteps int32 } /* * Information used for parsing configuration specs. If you change any of the * default strings, be sure to change the corresponding default values in * CreateLine. */ var _arrowShapeOption = TTk_CustomOption{} func init() { p := unsafe.Pointer(&_arrowShapeOption) *(*uintptr)(unsafe.Add(p, 0)) = __ccgo_fp(_ParseArrowShape) *(*uintptr)(unsafe.Add(p, 8)) = __ccgo_fp(_PrintArrowShape) } var _arrowOption = TTk_CustomOption{} func init() { p := unsafe.Pointer(&_arrowOption) *(*uintptr)(unsafe.Add(p, 0)) = __ccgo_fp(_ArrowParseProc) *(*uintptr)(unsafe.Add(p, 8)) = __ccgo_fp(_ArrowPrintProc) } var _smoothOption = TTk_CustomOption{} func init() { p := unsafe.Pointer(&_smoothOption) *(*uintptr)(unsafe.Add(p, 0)) = __ccgo_fp(XTkSmoothParseProc) *(*uintptr)(unsafe.Add(p, 8)) = __ccgo_fp(XTkSmoothPrintProc) } var _stateOption4 = TTk_CustomOption{ FclientData: uintptr(int64(libc.Int32FromInt32(2))), } func init() { p := unsafe.Pointer(&_stateOption4) *(*uintptr)(unsafe.Add(p, 0)) = __ccgo_fp(XTkStateParseProc) *(*uintptr)(unsafe.Add(p, 8)) = __ccgo_fp(XTkStatePrintProc) } var _tagsOption3 = TTk_CustomOption{} func init() { p := unsafe.Pointer(&_tagsOption3) *(*uintptr)(unsafe.Add(p, 0)) = __ccgo_fp(XTk_CanvasTagsParseProc) *(*uintptr)(unsafe.Add(p, 8)) = __ccgo_fp(XTk_CanvasTagsPrintProc) } var _dashOption1 = TTk_CustomOption{} func init() { p := unsafe.Pointer(&_dashOption1) *(*uintptr)(unsafe.Add(p, 0)) = __ccgo_fp(XTkCanvasDashParseProc) *(*uintptr)(unsafe.Add(p, 8)) = __ccgo_fp(XTkCanvasDashPrintProc) } var _offsetOption2 = TTk_CustomOption{ FclientData: uintptr(int64(libc.Int32FromInt32(TK_OFFSET_RELATIVE) | libc.Int32FromInt32(TK_OFFSET_INDEX))), } func init() { p := unsafe.Pointer(&_offsetOption2) *(*uintptr)(unsafe.Add(p, 0)) = __ccgo_fp(XTkOffsetParseProc) *(*uintptr)(unsafe.Add(p, 8)) = __ccgo_fp(XTkOffsetPrintProc) } var _pixelOption1 = TTk_CustomOption{} func init() { p := unsafe.Pointer(&_pixelOption1) *(*uintptr)(unsafe.Add(p, 0)) = __ccgo_fp(XTkPixelParseProc) *(*uintptr)(unsafe.Add(p, 8)) = __ccgo_fp(XTkPixelPrintProc) } var _configSpecs5 = [23]TTk_ConfigSpec{ 0: { Ftype1: int32(TK_CONFIG_CUSTOM), FargvName: __ccgo_ts + 28613, Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 120 + 56)), FspecFlags: int32(TCL_NULL_OK), FcustomPtr: uintptr(unsafe.Pointer(&_dashOption1)), }, 1: { Ftype1: int32(TK_CONFIG_COLOR), FargvName: __ccgo_ts + 28625, Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 120 + 136)), FspecFlags: int32(TCL_NULL_OK), }, 2: { Ftype1: int32(TK_CONFIG_BITMAP), FargvName: __ccgo_ts + 28674, Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 120 + 160)), FspecFlags: int32(TCL_NULL_OK), }, 3: { Ftype1: int32(TK_CONFIG_CUSTOM), FargvName: __ccgo_ts + 28689, FdefValue: __ccgo_ts + 14146, Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 120 + 16)), FspecFlags: libc.Int32FromInt32(1) << libc.Int32FromInt32(3), FcustomPtr: uintptr(unsafe.Pointer(&_pixelOption1)), }, 4: { Ftype1: int32(TK_CONFIG_CUSTOM), FargvName: __ccgo_ts + 29678, FdefValue: __ccgo_ts + 8223, Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 336)), FspecFlags: libc.Int32FromInt32(1) << libc.Int32FromInt32(3), FcustomPtr: uintptr(unsafe.Pointer(&_arrowOption)), }, 5: { Ftype1: int32(TK_CONFIG_CUSTOM), FargvName: __ccgo_ts + 29685, FdefValue: __ccgo_ts + 29697, Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 340)), FspecFlags: libc.Int32FromInt32(1) << libc.Int32FromInt32(3), FcustomPtr: uintptr(unsafe.Pointer(&_arrowShapeOption)), }, 6: { Ftype1: int32(TK_CONFIG_CAP_STYLE), FargvName: __ccgo_ts + 29704, FdefValue: __ccgo_ts + 11165, Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 320)), FspecFlags: libc.Int32FromInt32(1) << libc.Int32FromInt32(3), }, 7: { Ftype1: int32(TK_CONFIG_COLOR), FargvName: __ccgo_ts + 15184, FdefValue: __ccgo_ts + 19829, Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 120 + 128)), FspecFlags: int32(TCL_NULL_OK), }, 8: { Ftype1: int32(TK_CONFIG_CUSTOM), FargvName: __ccgo_ts + 28702, Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 120 + 40)), FspecFlags: int32(TCL_NULL_OK), FcustomPtr: uintptr(unsafe.Pointer(&_dashOption1)), }, 9: { Ftype1: int32(TK_CONFIG_PIXELS), FargvName: __ccgo_ts + 28708, FdefValue: __ccgo_ts + 10533, Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 120 + 88)), FspecFlags: int32(TK_CONFIG_OBJS), }, 10: { Ftype1: int32(TK_CONFIG_CUSTOM), FargvName: __ccgo_ts + 28720, Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 120 + 72)), FspecFlags: int32(TCL_NULL_OK), FcustomPtr: uintptr(unsafe.Pointer(&_dashOption1)), }, 11: { Ftype1: int32(TK_CONFIG_COLOR), FargvName: __ccgo_ts + 28734, Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 120 + 144)), FspecFlags: int32(TCL_NULL_OK), }, 12: { Ftype1: int32(TK_CONFIG_BITMAP), FargvName: __ccgo_ts + 28789, Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 120 + 168)), FspecFlags: int32(TCL_NULL_OK), }, 13: { Ftype1: int32(TK_CONFIG_CUSTOM), FargvName: __ccgo_ts + 28806, FdefValue: __ccgo_ts + 14146, Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 120 + 24)), FspecFlags: libc.Int32FromInt32(1) << libc.Int32FromInt32(3), FcustomPtr: uintptr(unsafe.Pointer(&_pixelOption1)), }, 14: { Ftype1: int32(TK_CONFIG_JOIN_STYLE), FargvName: __ccgo_ts + 29714, FdefValue: __ccgo_ts + 11083, Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 324)), FspecFlags: libc.Int32FromInt32(1) << libc.Int32FromInt32(3), }, 15: { Ftype1: int32(TK_CONFIG_CUSTOM), FargvName: __ccgo_ts + 26544, FdefValue: __ccgo_ts + 26566, Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 120 + 112)), FspecFlags: libc.Int32FromInt32(1) << libc.Int32FromInt32(3), FcustomPtr: uintptr(unsafe.Pointer(&_offsetOption2)), }, 16: { Ftype1: int32(TK_CONFIG_CUSTOM), FargvName: __ccgo_ts + 29725, FdefValue: __ccgo_ts + 10533, Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 368)), FspecFlags: libc.Int32FromInt32(1) << libc.Int32FromInt32(3), FcustomPtr: uintptr(unsafe.Pointer(&_smoothOption)), }, 17: { Ftype1: int32(TK_CONFIG_INT), FargvName: __ccgo_ts + 29733, FdefValue: __ccgo_ts + 29746, Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 376)), FspecFlags: libc.Int32FromInt32(1) << libc.Int32FromInt32(3), }, 18: { Ftype1: int32(TK_CONFIG_CUSTOM), FargvName: __ccgo_ts + 2957, Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 96)), FspecFlags: int32(TCL_NULL_OK), FcustomPtr: uintptr(unsafe.Pointer(&_stateOption4)), }, 19: { Ftype1: int32(TK_CONFIG_BITMAP), FargvName: __ccgo_ts + 28879, Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 120 + 152)), FspecFlags: int32(TCL_NULL_OK), }, 20: { Ftype1: int32(TK_CONFIG_CUSTOM), FargvName: __ccgo_ts + 28895, FspecFlags: int32(TCL_NULL_OK), FcustomPtr: uintptr(unsafe.Pointer(&_tagsOption3)), }, 21: { Ftype1: int32(TK_CONFIG_CUSTOM), FargvName: __ccgo_ts + 2987, FdefValue: __ccgo_ts + 22084, Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 120 + 8)), FspecFlags: libc.Int32FromInt32(1) << libc.Int32FromInt32(3), FcustomPtr: uintptr(unsafe.Pointer(&_pixelOption1)), }, 22: { Ftype1: int32(TK_CONFIG_END), }, } func init() { p := unsafe.Pointer(&XtkLineType) *(*uintptr)(unsafe.Add(p, 16)) = __ccgo_fp(_CreateLine) *(*uintptr)(unsafe.Add(p, 32)) = __ccgo_fp(_ConfigureLine) *(*uintptr)(unsafe.Add(p, 40)) = __ccgo_fp(_LineCoords) *(*uintptr)(unsafe.Add(p, 48)) = __ccgo_fp(_DeleteLine) *(*uintptr)(unsafe.Add(p, 56)) = __ccgo_fp(_DisplayLine) *(*uintptr)(unsafe.Add(p, 72)) = __ccgo_fp(_LineToPoint) *(*uintptr)(unsafe.Add(p, 80)) = __ccgo_fp(_LineToArea) *(*uintptr)(unsafe.Add(p, 88)) = __ccgo_fp(_LineToPostscript) *(*uintptr)(unsafe.Add(p, 96)) = __ccgo_fp(_ScaleLine) *(*uintptr)(unsafe.Add(p, 104)) = __ccgo_fp(_TranslateLine) *(*uintptr)(unsafe.Add(p, 112)) = __ccgo_fp(_GetLineIndex) *(*uintptr)(unsafe.Add(p, 136)) = __ccgo_fp(_LineInsert) *(*uintptr)(unsafe.Add(p, 144)) = __ccgo_fp(_LineDeleteCoords) *(*uintptr)(unsafe.Add(p, 160)) = __ccgo_fp(_RotateLine) } /* * The definition below determines how large are static arrays used to hold * spline points (splines larger than this have to have their arrays * malloc-ed). */ /* *-------------------------------------------------------------- * * CreateLine -- * * This function is invoked to create a new line item in a canvas. * * Results: * A standard Tcl return value. If an error occurred in creating the * item, then an error message is left in the interp's result; in this * case itemPtr is left uninitialized, so it can be safely freed by the * caller. * * Side effects: * A new line item is created. * *-------------------------------------------------------------- */ func _CreateLine(tls *libc.TLS, interp uintptr, canvas TTk_Canvas, itemPtr uintptr, objc TTcl_Size, objv uintptr) (r int32) { /* Arguments describing line. */ var arg, linePtr uintptr var i TTcl_Size _, _, _ = arg, i, linePtr linePtr = itemPtr if objc == 0 { libtcl9_0.XTcl_Panic(tls, __ccgo_ts+28901, 0) } /* * Carry out initialization that is needed to set defaults and to allow * proper cleanup after errors during the the remainder of this function. */ XTk_CreateOutline(tls, linePtr+120) (*TLineItem)(unsafe.Pointer(linePtr)).Fcanvas = canvas (*TLineItem)(unsafe.Pointer(linePtr)).FnumPoints = 0 (*TLineItem)(unsafe.Pointer(linePtr)).FcoordPtr = libc.UintptrFromInt32(0) (*TLineItem)(unsafe.Pointer(linePtr)).FcapStyle = int32(CapButt) (*TLineItem)(unsafe.Pointer(linePtr)).FjoinStyle = int32(JoinRound) (*TLineItem)(unsafe.Pointer(linePtr)).FarrowGC = libc.UintptrFromInt32(0) (*TLineItem)(unsafe.Pointer(linePtr)).Farrow = int32(ARROWS_NONE) (*TLineItem)(unsafe.Pointer(linePtr)).FarrowShapeA = libc.Float32FromFloat64(8) (*TLineItem)(unsafe.Pointer(linePtr)).FarrowShapeB = libc.Float32FromFloat64(10) (*TLineItem)(unsafe.Pointer(linePtr)).FarrowShapeC = libc.Float32FromFloat64(3) (*TLineItem)(unsafe.Pointer(linePtr)).FfirstArrowPtr = libc.UintptrFromInt32(0) (*TLineItem)(unsafe.Pointer(linePtr)).FlastArrowPtr = libc.UintptrFromInt32(0) (*TLineItem)(unsafe.Pointer(linePtr)).Fsmooth = libc.UintptrFromInt32(0) (*TLineItem)(unsafe.Pointer(linePtr)).FsplineSteps = int32(12) /* * Count the number of points and then parse them into a point array. * Leading arguments are assumed to be points if they start with a digit * or a minus sign followed by a digit. */ i = int64(1) for { if !(i < objc) { break } arg = libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(i)*8)), libc.UintptrFromInt32(0)) if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(arg))) == int32('-') && libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(arg + 1))) >= int32('a') && libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(arg + 1))) <= int32('z') { break } goto _1 _1: ; i++ } if _LineCoords(tls, interp, canvas, itemPtr, i, objv) != TCL_OK { goto error } if _ConfigureLine(tls, interp, canvas, itemPtr, objc-i, objv+uintptr(i)*8, 0) == TCL_OK { return TCL_OK } goto error error: ; _DeleteLine(tls, canvas, itemPtr, (*TTk_FakeWin)(unsafe.Pointer(XTk_CanvasTkwin(tls, canvas))).Fdisplay) return int32(TCL_ERROR) } /* *-------------------------------------------------------------- * * LineCoords -- * * This function is invoked to process the "coords" widget command on * lines. See the user documentation for details on what it does. * * Results: * Returns TCL_OK or TCL_ERROR, and sets the interp's result. * * Side effects: * The coordinates for the given item may be changed. * *-------------------------------------------------------------- */ func _LineCoords(tls *libc.TLS, interp uintptr, canvas TTk_Canvas, itemPtr uintptr, _objc TTcl_Size, _objv uintptr) (r int32) { bp := tls.Alloc(64) defer tls.Free(64) *(*TTcl_Size)(unsafe.Pointer(bp)) = _objc *(*uintptr)(unsafe.Pointer(bp + 8)) = _objv /* Array of coordinates: x1, y1, x2, y2, ... */ var coordPtr, linePtr, obj, subobj, v3 uintptr var i, numCoords, numPoints TTcl_Size _, _, _, _, _, _, _, _ = coordPtr, i, linePtr, numCoords, numPoints, obj, subobj, v3 linePtr = itemPtr if *(*TTcl_Size)(unsafe.Pointer(bp)) == 0 { obj = libtcl9_0.XTcl_NewObj(tls) numCoords = int64(2) * (*TLineItem)(unsafe.Pointer(linePtr)).FnumPoints if (*TLineItem)(unsafe.Pointer(linePtr)).FfirstArrowPtr != libc.UintptrFromInt32(0) { coordPtr = (*TLineItem)(unsafe.Pointer(linePtr)).FfirstArrowPtr } else { coordPtr = (*TLineItem)(unsafe.Pointer(linePtr)).FcoordPtr } i = 0 for { if !(i < numCoords) { break } if i == int64(2) { coordPtr = (*TLineItem)(unsafe.Pointer(linePtr)).FcoordPtr + uintptr(2)*8 } if (*TLineItem)(unsafe.Pointer(linePtr)).FlastArrowPtr != libc.UintptrFromInt32(0) && i == numCoords-int64(2) { coordPtr = (*TLineItem)(unsafe.Pointer(linePtr)).FlastArrowPtr } subobj = libtcl9_0.XTcl_NewDoubleObj(tls, *(*float64)(unsafe.Pointer(coordPtr))) libtcl9_0.XTcl_ListObjAppendElement(tls, interp, obj, subobj) goto _1 _1: ; i++ coordPtr += 8 } libtcl9_0.XTcl_SetObjResult(tls, interp, obj) return TCL_OK } if *(*TTcl_Size)(unsafe.Pointer(bp)) == int64(1) { if libtcl9_0.XTcl_ListObjGetElements(tls, interp, *(*uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 8)))), bp, bp+8) != TCL_OK { return int32(TCL_ERROR) } } if *(*TTcl_Size)(unsafe.Pointer(bp))&int64(1) != 0 { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+29749, libc.VaList(bp+24, *(*TTcl_Size)(unsafe.Pointer(bp))))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+24, __ccgo_ts+179, __ccgo_ts+27003, __ccgo_ts+28973, __ccgo_ts+29803, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) } else { if *(*TTcl_Size)(unsafe.Pointer(bp)) < int64(4) { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+29808, libc.VaList(bp+24, *(*TTcl_Size)(unsafe.Pointer(bp))))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+24, __ccgo_ts+179, __ccgo_ts+27003, __ccgo_ts+28973, __ccgo_ts+29803, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) } } numPoints = *(*TTcl_Size)(unsafe.Pointer(bp)) / int64(2) if (*TLineItem)(unsafe.Pointer(linePtr)).FnumPoints != numPoints { coordPtr = libtcl9_0.XTcl_Alloc(tls, uint64(8)*libc.Uint64FromInt64(*(*TTcl_Size)(unsafe.Pointer(bp)))) if (*TLineItem)(unsafe.Pointer(linePtr)).FcoordPtr != libc.UintptrFromInt32(0) { libtcl9_0.XTcl_Free(tls, (*TLineItem)(unsafe.Pointer(linePtr)).FcoordPtr) } (*TLineItem)(unsafe.Pointer(linePtr)).FcoordPtr = coordPtr (*TLineItem)(unsafe.Pointer(linePtr)).FnumPoints = numPoints } coordPtr = (*TLineItem)(unsafe.Pointer(linePtr)).FcoordPtr i = 0 for { if !(i < *(*TTcl_Size)(unsafe.Pointer(bp))) { break } v3 = coordPtr coordPtr += 8 if XTk_CanvasGetCoordFromObj(tls, interp, canvas, *(*uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 8)) + uintptr(i)*8)), v3) != TCL_OK { return int32(TCL_ERROR) } goto _2 _2: ; i++ } /* * Update arrowheads by throwing away any existing arrow-head information * and calling ConfigureArrows to recompute it. */ if (*TLineItem)(unsafe.Pointer(linePtr)).FfirstArrowPtr != libc.UintptrFromInt32(0) { libtcl9_0.XTcl_Free(tls, (*TLineItem)(unsafe.Pointer(linePtr)).FfirstArrowPtr) (*TLineItem)(unsafe.Pointer(linePtr)).FfirstArrowPtr = libc.UintptrFromInt32(0) } if (*TLineItem)(unsafe.Pointer(linePtr)).FlastArrowPtr != libc.UintptrFromInt32(0) { libtcl9_0.XTcl_Free(tls, (*TLineItem)(unsafe.Pointer(linePtr)).FlastArrowPtr) (*TLineItem)(unsafe.Pointer(linePtr)).FlastArrowPtr = libc.UintptrFromInt32(0) } if (*TLineItem)(unsafe.Pointer(linePtr)).Farrow != int32(ARROWS_NONE) { _ConfigureArrows(tls, canvas, linePtr) } _ComputeLineBbox(tls, canvas, linePtr) return TCL_OK } /* *-------------------------------------------------------------- * * ConfigureLine -- * * This function is invoked to configure various aspects of a line item * such as its background color. * * Results: * A standard Tcl result code. If an error occurs, then an error message * is left in the interp's result. * * Side effects: * Configuration information, such as colors and stipple patterns, may be * set for itemPtr. * *-------------------------------------------------------------- */ func _ConfigureLine(tls *libc.TLS, interp uintptr, canvas TTk_Canvas, itemPtr uintptr, objc TTcl_Size, objv uintptr, flags int32) (r int32) { bp := tls.Alloc(128) defer tls.Free(128) /* Flags to pass to Tk_ConfigureWidget. */ var arrowGC, newGC, v1 TGC var i int32 var linePtr uintptr var mask uint64 var state TTk_State var tkwin TTk_Window var _ /* gcValues at bp+0 */ TXGCValues _, _, _, _, _, _, _, _ = arrowGC, i, linePtr, mask, newGC, state, tkwin, v1 linePtr = itemPtr tkwin = XTk_CanvasTkwin(tls, canvas) if TCL_OK != XTk_ConfigureWidget(tls, interp, tkwin, uintptr(unsafe.Pointer(&_configSpecs5)), objc, objv, linePtr, flags) { return int32(TCL_ERROR) } /* * A few of the options require additional processing, such as graphics * contexts. */ state = (*TTk_Item)(unsafe.Pointer(itemPtr)).Fstate if state == int32(TK_STATE_NULL) { state = (*TTkCanvas)(unsafe.Pointer(canvas)).Fcanvas_state } if (*TLineItem)(unsafe.Pointer(linePtr)).Foutline.FactiveWidth > (*TLineItem)(unsafe.Pointer(linePtr)).Foutline.Fwidth || (*TLineItem)(unsafe.Pointer(linePtr)).Foutline.FactiveDash.Fnumber != 0 || (*TLineItem)(unsafe.Pointer(linePtr)).Foutline.FactiveColor != libc.UintptrFromInt32(0) || (*TLineItem)(unsafe.Pointer(linePtr)).Foutline.FactiveStipple != uint64(0) { *(*int32)(unsafe.Pointer(itemPtr + 112)) |= int32(TK_ITEM_STATE_DEPENDANT) } else { *(*int32)(unsafe.Pointer(itemPtr + 112)) &= ^libc.Int32FromInt32(TK_ITEM_STATE_DEPENDANT) } mask = libc.Uint64FromInt32(XTk_ConfigOutlineGC(tls, bp, canvas, itemPtr, linePtr+120)) if mask != 0 { if (*TLineItem)(unsafe.Pointer(linePtr)).Farrow == int32(ARROWS_NONE) { (*(*TXGCValues)(unsafe.Pointer(bp))).Fcap_style = (*TLineItem)(unsafe.Pointer(linePtr)).FcapStyle mask |= libc.Uint64FromInt64(libc.Int64FromInt64(1) << libc.Int32FromInt32(6)) } (*(*TXGCValues)(unsafe.Pointer(bp))).Fjoin_style = (*TLineItem)(unsafe.Pointer(linePtr)).FjoinStyle mask |= libc.Uint64FromInt64(libc.Int64FromInt64(1) << libc.Int32FromInt32(7)) newGC = XTk_GetGC(tls, tkwin, mask, bp) (*(*TXGCValues)(unsafe.Pointer(bp))).Fline_width = 0 arrowGC = XTk_GetGC(tls, tkwin, mask, bp) } else { v1 = libc.UintptrFromInt32(0) arrowGC = v1 newGC = v1 } if (*TLineItem)(unsafe.Pointer(linePtr)).Foutline.Fgc != libc.UintptrFromInt32(0) { XTk_FreeGC(tls, (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fdisplay, (*TLineItem)(unsafe.Pointer(linePtr)).Foutline.Fgc) } if (*TLineItem)(unsafe.Pointer(linePtr)).FarrowGC != libc.UintptrFromInt32(0) { XTk_FreeGC(tls, (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fdisplay, (*TLineItem)(unsafe.Pointer(linePtr)).FarrowGC) } (*TLineItem)(unsafe.Pointer(linePtr)).Foutline.Fgc = newGC (*TLineItem)(unsafe.Pointer(linePtr)).FarrowGC = arrowGC /* * Keep spline parameters within reasonable limits. */ if (*TLineItem)(unsafe.Pointer(linePtr)).FsplineSteps < int32(1) { (*TLineItem)(unsafe.Pointer(linePtr)).FsplineSteps = int32(1) } else { if (*TLineItem)(unsafe.Pointer(linePtr)).FsplineSteps > int32(100) { (*TLineItem)(unsafe.Pointer(linePtr)).FsplineSteps = int32(100) } } if !((*TLineItem)(unsafe.Pointer(linePtr)).FnumPoints != 0) || state == int32(TK_STATE_HIDDEN) { _ComputeLineBbox(tls, canvas, linePtr) return TCL_OK } /* * Setup arrowheads, if needed. If arrowheads are turned off, restore the * line's endpoints (they were shortened when the arrowheads were added). */ if (*TLineItem)(unsafe.Pointer(linePtr)).FfirstArrowPtr != libc.UintptrFromInt32(0) && (*TLineItem)(unsafe.Pointer(linePtr)).Farrow != int32(ARROWS_FIRST) && (*TLineItem)(unsafe.Pointer(linePtr)).Farrow != int32(ARROWS_BOTH) { *(*float64)(unsafe.Pointer((*TLineItem)(unsafe.Pointer(linePtr)).FcoordPtr)) = *(*float64)(unsafe.Pointer((*TLineItem)(unsafe.Pointer(linePtr)).FfirstArrowPtr)) *(*float64)(unsafe.Pointer((*TLineItem)(unsafe.Pointer(linePtr)).FcoordPtr + 1*8)) = *(*float64)(unsafe.Pointer((*TLineItem)(unsafe.Pointer(linePtr)).FfirstArrowPtr + 1*8)) libtcl9_0.XTcl_Free(tls, (*TLineItem)(unsafe.Pointer(linePtr)).FfirstArrowPtr) (*TLineItem)(unsafe.Pointer(linePtr)).FfirstArrowPtr = libc.UintptrFromInt32(0) } if (*TLineItem)(unsafe.Pointer(linePtr)).FlastArrowPtr != libc.UintptrFromInt32(0) && (*TLineItem)(unsafe.Pointer(linePtr)).Farrow != int32(ARROWS_LAST) && (*TLineItem)(unsafe.Pointer(linePtr)).Farrow != int32(ARROWS_BOTH) { i = int32(int64(2) * ((*TLineItem)(unsafe.Pointer(linePtr)).FnumPoints - int64(1))) *(*float64)(unsafe.Pointer((*TLineItem)(unsafe.Pointer(linePtr)).FcoordPtr + uintptr(i)*8)) = *(*float64)(unsafe.Pointer((*TLineItem)(unsafe.Pointer(linePtr)).FlastArrowPtr)) *(*float64)(unsafe.Pointer((*TLineItem)(unsafe.Pointer(linePtr)).FcoordPtr + uintptr(i+int32(1))*8)) = *(*float64)(unsafe.Pointer((*TLineItem)(unsafe.Pointer(linePtr)).FlastArrowPtr + 1*8)) libtcl9_0.XTcl_Free(tls, (*TLineItem)(unsafe.Pointer(linePtr)).FlastArrowPtr) (*TLineItem)(unsafe.Pointer(linePtr)).FlastArrowPtr = libc.UintptrFromInt32(0) } if (*TLineItem)(unsafe.Pointer(linePtr)).Farrow != int32(ARROWS_NONE) { _ConfigureArrows(tls, canvas, linePtr) } /* * Recompute bounding box for line. */ _ComputeLineBbox(tls, canvas, linePtr) return TCL_OK } /* *-------------------------------------------------------------- * * DeleteLine -- * * This function is called to clean up the data structure associated with * a line item. * * Results: * None. * * Side effects: * Resources associated with itemPtr are released. * *-------------------------------------------------------------- */ func _DeleteLine(tls *libc.TLS, dummy612 TTk_Canvas, itemPtr uintptr, display uintptr) { /* Display containing window for canvas. */ var linePtr uintptr _ = linePtr linePtr = itemPtr XTk_DeleteOutline(tls, display, linePtr+120) if (*TLineItem)(unsafe.Pointer(linePtr)).FcoordPtr != libc.UintptrFromInt32(0) { libtcl9_0.XTcl_Free(tls, (*TLineItem)(unsafe.Pointer(linePtr)).FcoordPtr) } if (*TLineItem)(unsafe.Pointer(linePtr)).FarrowGC != libc.UintptrFromInt32(0) { XTk_FreeGC(tls, display, (*TLineItem)(unsafe.Pointer(linePtr)).FarrowGC) } if (*TLineItem)(unsafe.Pointer(linePtr)).FfirstArrowPtr != libc.UintptrFromInt32(0) { libtcl9_0.XTcl_Free(tls, (*TLineItem)(unsafe.Pointer(linePtr)).FfirstArrowPtr) } if (*TLineItem)(unsafe.Pointer(linePtr)).FlastArrowPtr != libc.UintptrFromInt32(0) { libtcl9_0.XTcl_Free(tls, (*TLineItem)(unsafe.Pointer(linePtr)).FlastArrowPtr) } } /* *-------------------------------------------------------------- * * ComputeLineBbox -- * * This function is invoked to compute the bounding box of all the pixels * that may be drawn as part of a line. * * Results: * None. * * Side effects: * The fields x1, y1, x2, and y2 are updated in the header for itemPtr. * *-------------------------------------------------------------- */ func _ComputeLineBbox(tls *libc.TLS, canvas TTk_Canvas, linePtr uintptr) { bp := tls.Alloc(32) defer tls.Free(32) /* Item whose bbos is to be recomputed. */ var coordPtr, tsoffset uintptr var i TTcl_Size var intWidth, j, v1, v2 int32 var state TTk_State var width float64 var _ /* miter at bp+0 */ [4]float64 _, _, _, _, _, _, _, _, _ = coordPtr, i, intWidth, j, state, tsoffset, width, v1, v2 state = (*TLineItem)(unsafe.Pointer(linePtr)).Fheader.Fstate if state == int32(TK_STATE_NULL) { state = (*TTkCanvas)(unsafe.Pointer(canvas)).Fcanvas_state } if !((*TLineItem)(unsafe.Pointer(linePtr)).FnumPoints != 0) || state == int32(TK_STATE_HIDDEN) { (*TLineItem)(unsafe.Pointer(linePtr)).Fheader.Fx1 = -int32(1) (*TLineItem)(unsafe.Pointer(linePtr)).Fheader.Fx2 = -int32(1) (*TLineItem)(unsafe.Pointer(linePtr)).Fheader.Fy1 = -int32(1) (*TLineItem)(unsafe.Pointer(linePtr)).Fheader.Fy2 = -int32(1) return } width = (*TLineItem)(unsafe.Pointer(linePtr)).Foutline.Fwidth if (*TTkCanvas)(unsafe.Pointer(canvas)).FcurrentItemPtr == linePtr { if (*TLineItem)(unsafe.Pointer(linePtr)).Foutline.FactiveWidth > width { width = (*TLineItem)(unsafe.Pointer(linePtr)).Foutline.FactiveWidth } } else { if state == int32(TK_STATE_DISABLED) { if (*TLineItem)(unsafe.Pointer(linePtr)).Foutline.FdisabledWidth > libc.Float64FromInt32(0) { width = (*TLineItem)(unsafe.Pointer(linePtr)).Foutline.FdisabledWidth } } } coordPtr = (*TLineItem)(unsafe.Pointer(linePtr)).FcoordPtr v1 = int32(*(*float64)(unsafe.Pointer(coordPtr))) (*TLineItem)(unsafe.Pointer(linePtr)).Fheader.Fx2 = v1 (*TLineItem)(unsafe.Pointer(linePtr)).Fheader.Fx1 = v1 v2 = int32(*(*float64)(unsafe.Pointer(coordPtr + 1*8))) (*TLineItem)(unsafe.Pointer(linePtr)).Fheader.Fy2 = v2 (*TLineItem)(unsafe.Pointer(linePtr)).Fheader.Fy1 = v2 /* * Compute the bounding box of all the points in the line, then expand in * all directions by the line's width to take care of butting or rounded * corners and projecting or rounded caps. This expansion is an * overestimate (worst-case is square root of two over two) but it's * simple. Don't do anything special for curves. This causes an additional * overestimate in the bounding box, but is faster. */ i = int64(1) coordPtr = (*TLineItem)(unsafe.Pointer(linePtr)).FcoordPtr + libc.UintptrFromInt32(2)*8 for { if !(i < (*TLineItem)(unsafe.Pointer(linePtr)).FnumPoints) { break } XTkIncludePoint(tls, linePtr, coordPtr) goto _3 _3: ; i++ coordPtr += uintptr(2) * 8 } width = (*TLineItem)(unsafe.Pointer(linePtr)).Foutline.Fwidth if width < float64(1) { width = float64(1) } if (*TLineItem)(unsafe.Pointer(linePtr)).Farrow != int32(ARROWS_NONE) { if (*TLineItem)(unsafe.Pointer(linePtr)).Farrow != int32(ARROWS_LAST) && (*TLineItem)(unsafe.Pointer(linePtr)).FfirstArrowPtr != 0 { XTkIncludePoint(tls, linePtr, (*TLineItem)(unsafe.Pointer(linePtr)).FfirstArrowPtr) } if (*TLineItem)(unsafe.Pointer(linePtr)).Farrow != int32(ARROWS_FIRST) && (*TLineItem)(unsafe.Pointer(linePtr)).FlastArrowPtr != 0 { XTkIncludePoint(tls, linePtr, (*TLineItem)(unsafe.Pointer(linePtr)).FlastArrowPtr) } } tsoffset = linePtr + 120 + 112 if (*TTk_TSOffset)(unsafe.Pointer(tsoffset)).Fflags&int32(TK_OFFSET_INDEX) != 0 { coordPtr = (*TLineItem)(unsafe.Pointer(linePtr)).FcoordPtr + uintptr((*TTk_TSOffset)(unsafe.Pointer(tsoffset)).Fflags & ^libc.Int32FromInt32(TK_OFFSET_INDEX))*8 if (*TTk_TSOffset)(unsafe.Pointer(tsoffset)).Fflags <= 0 { coordPtr = (*TLineItem)(unsafe.Pointer(linePtr)).FcoordPtr if (*TLineItem)(unsafe.Pointer(linePtr)).Farrow == int32(ARROWS_FIRST) || (*TLineItem)(unsafe.Pointer(linePtr)).Farrow == int32(ARROWS_BOTH) { coordPtr = (*TLineItem)(unsafe.Pointer(linePtr)).FfirstArrowPtr } } if int64((*TTk_TSOffset)(unsafe.Pointer(tsoffset)).Fflags) > (*TLineItem)(unsafe.Pointer(linePtr)).FnumPoints*int64(2) { coordPtr = (*TLineItem)(unsafe.Pointer(linePtr)).FcoordPtr + uintptr((*TLineItem)(unsafe.Pointer(linePtr)).FnumPoints*libc.Int64FromInt32(2))*8 if (*TLineItem)(unsafe.Pointer(linePtr)).Farrow == int32(ARROWS_LAST) || (*TLineItem)(unsafe.Pointer(linePtr)).Farrow == int32(ARROWS_BOTH) { coordPtr = (*TLineItem)(unsafe.Pointer(linePtr)).FlastArrowPtr } } (*TTk_TSOffset)(unsafe.Pointer(tsoffset)).Fxoffset = int32(*(*float64)(unsafe.Pointer(coordPtr)) + libc.Float64FromFloat64(0.5)) (*TTk_TSOffset)(unsafe.Pointer(tsoffset)).Fyoffset = int32(*(*float64)(unsafe.Pointer(coordPtr + 1*8)) + libc.Float64FromFloat64(0.5)) } else { if (*TTk_TSOffset)(unsafe.Pointer(tsoffset)).Fflags&int32(TK_OFFSET_LEFT) != 0 { (*TTk_TSOffset)(unsafe.Pointer(tsoffset)).Fxoffset = (*TLineItem)(unsafe.Pointer(linePtr)).Fheader.Fx1 } else { if (*TTk_TSOffset)(unsafe.Pointer(tsoffset)).Fflags&int32(TK_OFFSET_CENTER) != 0 { (*TTk_TSOffset)(unsafe.Pointer(tsoffset)).Fxoffset = ((*TLineItem)(unsafe.Pointer(linePtr)).Fheader.Fx1 + (*TLineItem)(unsafe.Pointer(linePtr)).Fheader.Fx2) / int32(2) } else { if (*TTk_TSOffset)(unsafe.Pointer(tsoffset)).Fflags&int32(TK_OFFSET_RIGHT) != 0 { (*TTk_TSOffset)(unsafe.Pointer(tsoffset)).Fxoffset = (*TLineItem)(unsafe.Pointer(linePtr)).Fheader.Fx2 } } } if (*TTk_TSOffset)(unsafe.Pointer(tsoffset)).Fflags&int32(TK_OFFSET_TOP) != 0 { (*TTk_TSOffset)(unsafe.Pointer(tsoffset)).Fyoffset = (*TLineItem)(unsafe.Pointer(linePtr)).Fheader.Fy1 } else { if (*TTk_TSOffset)(unsafe.Pointer(tsoffset)).Fflags&int32(TK_OFFSET_MIDDLE) != 0 { (*TTk_TSOffset)(unsafe.Pointer(tsoffset)).Fyoffset = ((*TLineItem)(unsafe.Pointer(linePtr)).Fheader.Fy1 + (*TLineItem)(unsafe.Pointer(linePtr)).Fheader.Fy2) / int32(2) } else { if (*TTk_TSOffset)(unsafe.Pointer(tsoffset)).Fflags&int32(TK_OFFSET_BOTTOM) != 0 { (*TTk_TSOffset)(unsafe.Pointer(tsoffset)).Fyoffset = (*TLineItem)(unsafe.Pointer(linePtr)).Fheader.Fy2 } } } } intWidth = int32(width + libc.Float64FromFloat64(0.5)) (*TLineItem)(unsafe.Pointer(linePtr)).Fheader.Fx1 -= intWidth (*TLineItem)(unsafe.Pointer(linePtr)).Fheader.Fx2 += intWidth (*TLineItem)(unsafe.Pointer(linePtr)).Fheader.Fy1 -= intWidth (*TLineItem)(unsafe.Pointer(linePtr)).Fheader.Fy2 += intWidth if (*TLineItem)(unsafe.Pointer(linePtr)).FnumPoints == int64(1) { (*TLineItem)(unsafe.Pointer(linePtr)).Fheader.Fx1 -= int32(1) (*TLineItem)(unsafe.Pointer(linePtr)).Fheader.Fx2 += int32(1) (*TLineItem)(unsafe.Pointer(linePtr)).Fheader.Fy1 -= int32(1) (*TLineItem)(unsafe.Pointer(linePtr)).Fheader.Fy2 += int32(1) return } /* * For mitered lines, make a second pass through all the points. Compute * the locations of the two miter vertex points and add those into the * bounding box. */ if (*TLineItem)(unsafe.Pointer(linePtr)).FjoinStyle == JoinMiter { i = (*TLineItem)(unsafe.Pointer(linePtr)).FnumPoints coordPtr = (*TLineItem)(unsafe.Pointer(linePtr)).FcoordPtr for { if !(i >= int64(3)) { break } if XTkGetMiterPoints(tls, coordPtr, coordPtr+uintptr(2)*8, coordPtr+uintptr(4)*8, width, bp, bp+uintptr(2)*8) != 0 { j = 0 for { if !(j < int32(4)) { break } XTkIncludePoint(tls, linePtr, bp+uintptr(j)*8) goto _5 _5: ; j += int32(2) } } goto _4 _4: ; i-- coordPtr += uintptr(2) * 8 } } /* * Add in the sizes of arrowheads, if any. */ if (*TLineItem)(unsafe.Pointer(linePtr)).Farrow != int32(ARROWS_NONE) { if (*TLineItem)(unsafe.Pointer(linePtr)).Farrow != int32(ARROWS_LAST) { i = 0 coordPtr = (*TLineItem)(unsafe.Pointer(linePtr)).FfirstArrowPtr for { if !(i < int64(PTS_IN_ARROW)) { break } XTkIncludePoint(tls, linePtr, coordPtr) goto _6 _6: ; i++ coordPtr += uintptr(2) * 8 } } if (*TLineItem)(unsafe.Pointer(linePtr)).Farrow != int32(ARROWS_FIRST) { i = 0 coordPtr = (*TLineItem)(unsafe.Pointer(linePtr)).FlastArrowPtr for { if !(i < int64(PTS_IN_ARROW)) { break } XTkIncludePoint(tls, linePtr, coordPtr) goto _7 _7: ; i++ coordPtr += uintptr(2) * 8 } } } /* * Add one more pixel of fudge factor just to be safe (e.g. X may round * differently than we do). */ (*TLineItem)(unsafe.Pointer(linePtr)).Fheader.Fx1 -= int32(1) (*TLineItem)(unsafe.Pointer(linePtr)).Fheader.Fx2 += int32(1) (*TLineItem)(unsafe.Pointer(linePtr)).Fheader.Fy1 -= int32(1) (*TLineItem)(unsafe.Pointer(linePtr)).Fheader.Fy2 += int32(1) } /* *-------------------------------------------------------------- * * DisplayLine -- * * This function is invoked to draw a line item in a given drawable. * * Results: * None. * * Side effects: * ItemPtr is drawn in drawable using the transformation information in * canvas. * *-------------------------------------------------------------- */ func _DisplayLine(tls *libc.TLS, canvas TTk_Canvas, itemPtr uintptr, display uintptr, drawable TDrawable, dummy841 int32, dummy842 int32, dummy843 int32, dummy844 int32) { bp := tls.Alloc(2400) defer tls.Free(2400) var intwidth, numPoints int32 var linePtr, pointPtr uintptr var linewidth float64 var state TTk_State var _ /* staticPoints at bp+0 */ [600]TXPoint _, _, _, _, _, _ = intwidth, linePtr, linewidth, numPoints, pointPtr, state linePtr = itemPtr state = (*TTk_Item)(unsafe.Pointer(itemPtr)).Fstate if !((*TLineItem)(unsafe.Pointer(linePtr)).FnumPoints != 0) || (*TLineItem)(unsafe.Pointer(linePtr)).Foutline.Fgc == libc.UintptrFromInt32(0) { return } if state == int32(TK_STATE_NULL) { state = (*TTkCanvas)(unsafe.Pointer(canvas)).Fcanvas_state } linewidth = (*TLineItem)(unsafe.Pointer(linePtr)).Foutline.Fwidth if (*TTkCanvas)(unsafe.Pointer(canvas)).FcurrentItemPtr == itemPtr { if (*TLineItem)(unsafe.Pointer(linePtr)).Foutline.FactiveWidth != linewidth { linewidth = (*TLineItem)(unsafe.Pointer(linePtr)).Foutline.FactiveWidth } } else { if state == int32(TK_STATE_DISABLED) { if (*TLineItem)(unsafe.Pointer(linePtr)).Foutline.FdisabledWidth != linewidth { linewidth = (*TLineItem)(unsafe.Pointer(linePtr)).Foutline.FdisabledWidth } } } /* * Build up an array of points in screen coordinates. Use a static array * unless the line has an enormous number of points; in this case, * dynamically allocate an array. For smoothed lines, generate the curve * points on each redisplay. */ if (*TLineItem)(unsafe.Pointer(linePtr)).Fsmooth != 0 && (*TLineItem)(unsafe.Pointer(linePtr)).FnumPoints > int64(2) { numPoints = (*(*func(*libc.TLS, TTk_Canvas, uintptr, int32, int32, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*TTk_SmoothMethod)(unsafe.Pointer((*TLineItem)(unsafe.Pointer(linePtr)).Fsmooth)).FcoordProc})))(tls, canvas, libc.UintptrFromInt32(0), int32((*TLineItem)(unsafe.Pointer(linePtr)).FnumPoints), (*TLineItem)(unsafe.Pointer(linePtr)).FsplineSteps, libc.UintptrFromInt32(0), libc.UintptrFromInt32(0)) } else { numPoints = int32((*TLineItem)(unsafe.Pointer(linePtr)).FnumPoints) } if numPoints <= int32(MAX_STATIC_POINTS) { pointPtr = bp } else { pointPtr = libtcl9_0.XTcl_Alloc(tls, libc.Uint64FromInt32(numPoints*int32(3))*uint64(4)) } if (*TLineItem)(unsafe.Pointer(linePtr)).Fsmooth != 0 && (*TLineItem)(unsafe.Pointer(linePtr)).FnumPoints > int64(2) { numPoints = (*(*func(*libc.TLS, TTk_Canvas, uintptr, int32, int32, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*TTk_SmoothMethod)(unsafe.Pointer((*TLineItem)(unsafe.Pointer(linePtr)).Fsmooth)).FcoordProc})))(tls, canvas, (*TLineItem)(unsafe.Pointer(linePtr)).FcoordPtr, int32((*TLineItem)(unsafe.Pointer(linePtr)).FnumPoints), (*TLineItem)(unsafe.Pointer(linePtr)).FsplineSteps, pointPtr, libc.UintptrFromInt32(0)) } else { numPoints = XTkCanvTranslatePath(tls, canvas, numPoints, (*TLineItem)(unsafe.Pointer(linePtr)).FcoordPtr, 0, pointPtr) } /* * Display line, the free up line storage if it was dynamically allocated. * If we're stippling, then modify the stipple offset in the GC. Be sure * to reset the offset when done, since the GC is supposed to be * read-only. */ if XTk_ChangeOutlineGC(tls, canvas, itemPtr, linePtr+120) != 0 { XTk_CanvasSetOffset(tls, canvas, (*TLineItem)(unsafe.Pointer(linePtr)).FarrowGC, linePtr+120+112) } if numPoints > int32(1) { libx11.XXDrawLines(tls, display, drawable, (*TLineItem)(unsafe.Pointer(linePtr)).Foutline.Fgc, pointPtr, numPoints, CoordModeOrigin) } else { intwidth = int32(linewidth + libc.Float64FromFloat64(0.5)) if intwidth < int32(1) { intwidth = int32(1) } libx11.XXFillArc(tls, display, drawable, (*TLineItem)(unsafe.Pointer(linePtr)).Foutline.Fgc, int32((*TXPoint)(unsafe.Pointer(pointPtr)).Fx)-intwidth/int32(2), int32((*TXPoint)(unsafe.Pointer(pointPtr)).Fy)-intwidth/int32(2), libc.Uint32FromInt32(intwidth)+uint32(1), libc.Uint32FromInt32(intwidth)+uint32(1), 0, libc.Int32FromInt32(64)*libc.Int32FromInt32(360)) } if pointPtr != bp { libtcl9_0.XTcl_Free(tls, pointPtr) } /* * Display arrowheads, if they are wanted. */ if (*TLineItem)(unsafe.Pointer(linePtr)).FfirstArrowPtr != libc.UintptrFromInt32(0) { XTkFillPolygon(tls, canvas, (*TLineItem)(unsafe.Pointer(linePtr)).FfirstArrowPtr, int32(PTS_IN_ARROW), display, drawable, (*TLineItem)(unsafe.Pointer(linePtr)).FarrowGC, libc.UintptrFromInt32(0)) } if (*TLineItem)(unsafe.Pointer(linePtr)).FlastArrowPtr != libc.UintptrFromInt32(0) { XTkFillPolygon(tls, canvas, (*TLineItem)(unsafe.Pointer(linePtr)).FlastArrowPtr, int32(PTS_IN_ARROW), display, drawable, (*TLineItem)(unsafe.Pointer(linePtr)).FarrowGC, libc.UintptrFromInt32(0)) } if XTk_ResetOutlineGC(tls, canvas, itemPtr, linePtr+120) != 0 { libx11.XXSetTSOrigin(tls, display, (*TLineItem)(unsafe.Pointer(linePtr)).FarrowGC, 0, 0) } } /* *-------------------------------------------------------------- * * LineInsert -- * * Insert coords into a line item at a given index. * * Results: * None. * * Side effects: * The coords in the given item is modified. * *-------------------------------------------------------------- */ func _LineInsert(tls *libc.TLS, canvas TTk_Canvas, itemPtr uintptr, beforeThis TTcl_Size, obj uintptr) { bp := tls.Alloc(16) defer tls.Free(16) /* New coordinates to be inserted. */ var coordPtr, linePtr, newCoordPtr uintptr var i, length, nbInsPoints, oriNumPoints TTcl_Size var intWidth, v4, v5 int32 var state TTk_State var width float64 var _ /* objc at bp+0 */ TTcl_Size var _ /* objv at bp+8 */ uintptr _, _, _, _, _, _, _, _, _, _, _, _ = coordPtr, i, intWidth, length, linePtr, nbInsPoints, newCoordPtr, oriNumPoints, state, width, v4, v5 linePtr = itemPtr state = (*TTk_Item)(unsafe.Pointer(itemPtr)).Fstate if state == int32(TK_STATE_NULL) { state = (*TTkCanvas)(unsafe.Pointer(canvas)).Fcanvas_state } if !(obj != 0) || libtcl9_0.XTcl_ListObjGetElements(tls, libc.UintptrFromInt32(0), obj, bp, bp+8) != TCL_OK || !(*(*TTcl_Size)(unsafe.Pointer(bp)) != 0) || *(*TTcl_Size)(unsafe.Pointer(bp))&int64(1) != 0 { return } oriNumPoints = (*TLineItem)(unsafe.Pointer(linePtr)).FnumPoints length = int64(2) * (*TLineItem)(unsafe.Pointer(linePtr)).FnumPoints nbInsPoints = *(*TTcl_Size)(unsafe.Pointer(bp)) / int64(2) if beforeThis < 0 { beforeThis = 0 } if beforeThis > length { beforeThis = length } /* * With arrows, the end points of the line are adjusted so that a thick * line doesn't stick out past the arrowheads (see ConfigureArrows). */ if (*TLineItem)(unsafe.Pointer(linePtr)).FfirstArrowPtr != libc.UintptrFromInt32(0) { *(*float64)(unsafe.Pointer((*TLineItem)(unsafe.Pointer(linePtr)).FcoordPtr)) = *(*float64)(unsafe.Pointer((*TLineItem)(unsafe.Pointer(linePtr)).FfirstArrowPtr)) *(*float64)(unsafe.Pointer((*TLineItem)(unsafe.Pointer(linePtr)).FcoordPtr + 1*8)) = *(*float64)(unsafe.Pointer((*TLineItem)(unsafe.Pointer(linePtr)).FfirstArrowPtr + 1*8)) } if (*TLineItem)(unsafe.Pointer(linePtr)).FlastArrowPtr != libc.UintptrFromInt32(0) { *(*float64)(unsafe.Pointer((*TLineItem)(unsafe.Pointer(linePtr)).FcoordPtr + uintptr(length-int64(2))*8)) = *(*float64)(unsafe.Pointer((*TLineItem)(unsafe.Pointer(linePtr)).FlastArrowPtr)) *(*float64)(unsafe.Pointer((*TLineItem)(unsafe.Pointer(linePtr)).FcoordPtr + uintptr(length-int64(1))*8)) = *(*float64)(unsafe.Pointer((*TLineItem)(unsafe.Pointer(linePtr)).FlastArrowPtr + 1*8)) } newCoordPtr = libtcl9_0.XTcl_Alloc(tls, uint64(8)*libc.Uint64FromInt64(length+*(*TTcl_Size)(unsafe.Pointer(bp)))) i = 0 for { if !(i < beforeThis) { break } *(*float64)(unsafe.Pointer(newCoordPtr + uintptr(i)*8)) = *(*float64)(unsafe.Pointer((*TLineItem)(unsafe.Pointer(linePtr)).FcoordPtr + uintptr(i)*8)) goto _1 _1: ; i++ } i = 0 for { if !(i < *(*TTcl_Size)(unsafe.Pointer(bp))) { break } if libtcl9_0.XTcl_GetDoubleFromObj(tls, libc.UintptrFromInt32(0), *(*uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 8)) + uintptr(i)*8)), newCoordPtr+uintptr(i+beforeThis)*8) != TCL_OK { libtcl9_0.XTcl_ResetResult(tls, (*TTkCanvas)(unsafe.Pointer(canvas)).Finterp) libtcl9_0.XTcl_Free(tls, newCoordPtr) return } goto _2 _2: ; i++ } i = int64(int32(beforeThis)) for { if !(i < length) { break } *(*float64)(unsafe.Pointer(newCoordPtr + uintptr(i+*(*TTcl_Size)(unsafe.Pointer(bp)))*8)) = *(*float64)(unsafe.Pointer((*TLineItem)(unsafe.Pointer(linePtr)).FcoordPtr + uintptr(i)*8)) goto _3 _3: ; i++ } if (*TLineItem)(unsafe.Pointer(linePtr)).FcoordPtr != 0 { libtcl9_0.XTcl_Free(tls, (*TLineItem)(unsafe.Pointer(linePtr)).FcoordPtr) } (*TLineItem)(unsafe.Pointer(linePtr)).FcoordPtr = newCoordPtr length += *(*TTcl_Size)(unsafe.Pointer(bp)) (*TLineItem)(unsafe.Pointer(linePtr)).FnumPoints = length / int64(2) if length > int64(3) && state != int32(TK_STATE_HIDDEN) { /* * This is some optimizing code that will result that only the part of * the line that changed (and the objects that are overlapping with * that part) need to be redrawn. A special flag is set that instructs * the general canvas code not to redraw the whole object. If this * flag is not set, the canvas will do the redrawing, otherwise I have * to do it here. * Rationale for the optimization code can be found in Tk ticket * [5fb8145997]. */ *(*int32)(unsafe.Pointer(itemPtr + 112)) |= int32(TK_ITEM_DONT_REDRAW) /* * Include one point at left of the left insert position, and one * point at right of the right insert position. */ beforeThis -= int64(2) *(*TTcl_Size)(unsafe.Pointer(bp)) += int64(4) if (*TLineItem)(unsafe.Pointer(linePtr)).Fsmooth != 0 { if !(libc.Xstrcmp(tls, (*TTk_SmoothMethod)(unsafe.Pointer((*TLineItem)(unsafe.Pointer(linePtr)).Fsmooth)).Fname, __ccgo_ts+29858) != 0) { /* * Quadratic Bezier splines. A second point must be included at * each side of the insert position. */ beforeThis -= int64(2) *(*TTcl_Size)(unsafe.Pointer(bp)) += int64(4) /* * Moreover, if the insert position is the first or last point * of the line, include a third point. */ if beforeThis == int64(-libc.Int32FromInt32(4)) { *(*TTcl_Size)(unsafe.Pointer(bp)) += int64(2) } if beforeThis+int64(4) == length-(*(*TTcl_Size)(unsafe.Pointer(bp))-int64(8)) { beforeThis -= int64(2) *(*TTcl_Size)(unsafe.Pointer(bp)) += int64(2) } } else { if !(libc.Xstrcmp(tls, (*TTk_SmoothMethod)(unsafe.Pointer((*TLineItem)(unsafe.Pointer(linePtr)).Fsmooth)).Fname, __ccgo_ts+29863) != 0) { /* * Cubic Bezier splines. See details in ticket [5fb8145997]. */ if (oriNumPoints-int64(1))%int64(3) != 0 || nbInsPoints%int64(3) != 0 { /* * No optimization for "degenerate" lines or when inserting * something else than a multiple of 3 points. */ *(*int32)(unsafe.Pointer(itemPtr + 112)) &= ^libc.Int32FromInt32(TK_ITEM_DONT_REDRAW) } else { beforeThis -= int64(int32(beforeThis) % int32(6)) *(*TTcl_Size)(unsafe.Pointer(bp)) += int64(4) } } else { /* * Custom smoothing method. No optimization is possible. */ *(*int32)(unsafe.Pointer(itemPtr + 112)) &= ^libc.Int32FromInt32(TK_ITEM_DONT_REDRAW) } } } if (*TTk_Item)(unsafe.Pointer(itemPtr)).Fredraw_flags&int32(TK_ITEM_DONT_REDRAW) != 0 { if int32(beforeThis) < 0 { beforeThis = 0 } if int64(int32(beforeThis))+*(*TTcl_Size)(unsafe.Pointer(bp)) > length { *(*TTcl_Size)(unsafe.Pointer(bp)) = length - int64(int32(beforeThis)) } v4 = int32(*(*float64)(unsafe.Pointer((*TLineItem)(unsafe.Pointer(linePtr)).FcoordPtr + uintptr(beforeThis)*8))) (*TTk_Item)(unsafe.Pointer(itemPtr)).Fx2 = v4 (*TTk_Item)(unsafe.Pointer(itemPtr)).Fx1 = v4 v5 = int32(*(*float64)(unsafe.Pointer((*TLineItem)(unsafe.Pointer(linePtr)).FcoordPtr + uintptr(beforeThis+int64(1))*8))) (*TTk_Item)(unsafe.Pointer(itemPtr)).Fy2 = v5 (*TTk_Item)(unsafe.Pointer(itemPtr)).Fy1 = v5 if (*TLineItem)(unsafe.Pointer(linePtr)).FfirstArrowPtr != libc.UintptrFromInt32(0) && int32(beforeThis) < int32(2) { /* * Include old first arrow. */ i = 0 coordPtr = (*TLineItem)(unsafe.Pointer(linePtr)).FfirstArrowPtr for { if !(i < int64(PTS_IN_ARROW)) { break } XTkIncludePoint(tls, itemPtr, coordPtr) goto _6 _6: ; i++ coordPtr += uintptr(2) * 8 } } if (*TLineItem)(unsafe.Pointer(linePtr)).FlastArrowPtr != libc.UintptrFromInt32(0) && int64(int32(beforeThis))+*(*TTcl_Size)(unsafe.Pointer(bp)) >= length { /* * Include old last arrow. */ i = 0 coordPtr = (*TLineItem)(unsafe.Pointer(linePtr)).FlastArrowPtr for { if !(i < int64(PTS_IN_ARROW)) { break } XTkIncludePoint(tls, itemPtr, coordPtr) goto _7 _7: ; i++ coordPtr += uintptr(2) * 8 } } coordPtr = (*TLineItem)(unsafe.Pointer(linePtr)).FcoordPtr + uintptr(beforeThis)*8 i = 0 for { if !(i < *(*TTcl_Size)(unsafe.Pointer(bp))) { break } XTkIncludePoint(tls, itemPtr, coordPtr) coordPtr += uintptr(2) * 8 goto _8 _8: ; i += int64(2) } } } if (*TLineItem)(unsafe.Pointer(linePtr)).FfirstArrowPtr != libc.UintptrFromInt32(0) { libtcl9_0.XTcl_Free(tls, (*TLineItem)(unsafe.Pointer(linePtr)).FfirstArrowPtr) (*TLineItem)(unsafe.Pointer(linePtr)).FfirstArrowPtr = libc.UintptrFromInt32(0) } if (*TLineItem)(unsafe.Pointer(linePtr)).FlastArrowPtr != libc.UintptrFromInt32(0) { libtcl9_0.XTcl_Free(tls, (*TLineItem)(unsafe.Pointer(linePtr)).FlastArrowPtr) (*TLineItem)(unsafe.Pointer(linePtr)).FlastArrowPtr = libc.UintptrFromInt32(0) } if (*TLineItem)(unsafe.Pointer(linePtr)).Farrow != int32(ARROWS_NONE) { _ConfigureArrows(tls, canvas, linePtr) } if (*TTk_Item)(unsafe.Pointer(itemPtr)).Fredraw_flags&int32(TK_ITEM_DONT_REDRAW) != 0 { if (*TLineItem)(unsafe.Pointer(linePtr)).FfirstArrowPtr != libc.UintptrFromInt32(0) && int32(beforeThis) < int32(2) { /* * Include new first arrow. */ i = 0 coordPtr = (*TLineItem)(unsafe.Pointer(linePtr)).FfirstArrowPtr for { if !(i < int64(PTS_IN_ARROW)) { break } XTkIncludePoint(tls, itemPtr, coordPtr) goto _9 _9: ; i++ coordPtr += uintptr(2) * 8 } } if (*TLineItem)(unsafe.Pointer(linePtr)).FlastArrowPtr != libc.UintptrFromInt32(0) && int64(int32(beforeThis))+*(*TTcl_Size)(unsafe.Pointer(bp)) >= length { /* * Include new last arrow. */ i = 0 coordPtr = (*TLineItem)(unsafe.Pointer(linePtr)).FlastArrowPtr for { if !(i < int64(PTS_IN_ARROW)) { break } XTkIncludePoint(tls, itemPtr, coordPtr) goto _10 _10: ; i++ coordPtr += uintptr(2) * 8 } } width = (*TLineItem)(unsafe.Pointer(linePtr)).Foutline.Fwidth if (*TTkCanvas)(unsafe.Pointer(canvas)).FcurrentItemPtr == itemPtr { if (*TLineItem)(unsafe.Pointer(linePtr)).Foutline.FactiveWidth > width { width = (*TLineItem)(unsafe.Pointer(linePtr)).Foutline.FactiveWidth } } else { if state == int32(TK_STATE_DISABLED) { if (*TLineItem)(unsafe.Pointer(linePtr)).Foutline.FdisabledWidth > libc.Float64FromInt32(0) { width = (*TLineItem)(unsafe.Pointer(linePtr)).Foutline.FdisabledWidth } } } intWidth = int32(width + libc.Float64FromFloat64(0.5)) if intWidth < int32(1) { intWidth = int32(1) } *(*int32)(unsafe.Pointer(itemPtr + 72)) -= intWidth *(*int32)(unsafe.Pointer(itemPtr + 76)) -= intWidth *(*int32)(unsafe.Pointer(itemPtr + 80)) += intWidth *(*int32)(unsafe.Pointer(itemPtr + 84)) += intWidth XTk_CanvasEventuallyRedraw(tls, canvas, (*TTk_Item)(unsafe.Pointer(itemPtr)).Fx1, (*TTk_Item)(unsafe.Pointer(itemPtr)).Fy1, (*TTk_Item)(unsafe.Pointer(itemPtr)).Fx2, (*TTk_Item)(unsafe.Pointer(itemPtr)).Fy2) } _ComputeLineBbox(tls, canvas, linePtr) } /* *-------------------------------------------------------------- * * LineDeleteCoords -- * * Delete one or more coordinates from a line item. * * Results: * None. * * Side effects: * Characters between "first" and "last", inclusive, get deleted from * itemPtr. * *-------------------------------------------------------------- */ func _LineDeleteCoords(tls *libc.TLS, canvas TTk_Canvas, itemPtr uintptr, first TTcl_Size, last TTcl_Size) { /* Index of last character to delete. */ var canOptimize, count, first1, i, intWidth, last1, length, nbDelPoints, oriNumPoints, v1, v2 int32 var coordPtr, linePtr uintptr var state TTk_State var width float64 _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = canOptimize, coordPtr, count, first1, i, intWidth, last1, length, linePtr, nbDelPoints, oriNumPoints, state, width, v1, v2 linePtr = itemPtr oriNumPoints = int32((*TLineItem)(unsafe.Pointer(linePtr)).FnumPoints) canOptimize = int32(1) length = int32(int64(2) * (*TLineItem)(unsafe.Pointer(linePtr)).FnumPoints) state = (*TTk_Item)(unsafe.Pointer(itemPtr)).Fstate if state == int32(TK_STATE_NULL) { state = (*TTkCanvas)(unsafe.Pointer(canvas)).Fcanvas_state } first &= int64(-int32(2)) /* If odd, make it even. */ last &= int64(-int32(2)) if int32(first) < 0 { first = 0 } if int32(last) >= length { last = int64(length - int32(2)) } if int32(first) > int32(last) { return } /* * With arrows, the end points of the line are adjusted so that a thick * line doesn't stick out past the arrowheads (see ConfigureArrows). */ if (*TLineItem)(unsafe.Pointer(linePtr)).FfirstArrowPtr != libc.UintptrFromInt32(0) { *(*float64)(unsafe.Pointer((*TLineItem)(unsafe.Pointer(linePtr)).FcoordPtr)) = *(*float64)(unsafe.Pointer((*TLineItem)(unsafe.Pointer(linePtr)).FfirstArrowPtr)) *(*float64)(unsafe.Pointer((*TLineItem)(unsafe.Pointer(linePtr)).FcoordPtr + 1*8)) = *(*float64)(unsafe.Pointer((*TLineItem)(unsafe.Pointer(linePtr)).FfirstArrowPtr + 1*8)) } if (*TLineItem)(unsafe.Pointer(linePtr)).FlastArrowPtr != libc.UintptrFromInt32(0) { *(*float64)(unsafe.Pointer((*TLineItem)(unsafe.Pointer(linePtr)).FcoordPtr + uintptr(length-int32(2))*8)) = *(*float64)(unsafe.Pointer((*TLineItem)(unsafe.Pointer(linePtr)).FlastArrowPtr)) *(*float64)(unsafe.Pointer((*TLineItem)(unsafe.Pointer(linePtr)).FcoordPtr + uintptr(length-int32(1))*8)) = *(*float64)(unsafe.Pointer((*TLineItem)(unsafe.Pointer(linePtr)).FlastArrowPtr + 1*8)) } first1 = int32(first) last1 = int32(last) nbDelPoints = int32((last-first)/int64(2) + int64(1)) /* * Include one point at left of the left delete position, and one * point at right of the right delete position. */ first1 -= int32(2) last1 += int32(2) if (*TLineItem)(unsafe.Pointer(linePtr)).Fsmooth != 0 { if !(libc.Xstrcmp(tls, (*TTk_SmoothMethod)(unsafe.Pointer((*TLineItem)(unsafe.Pointer(linePtr)).Fsmooth)).Fname, __ccgo_ts+29858) != 0) { /* * Quadratic Bezier splines. A second point must be included at * each side of the delete position. */ first1 -= int32(2) last1 += int32(2) /* * If the delete position is the first or last point of the line, * include a third point. */ if first1 == -int32(4) { last1 += int32(2) } if last1-int32(4) == length-int32(2) { first1 -= int32(2) } } else { if !(libc.Xstrcmp(tls, (*TTk_SmoothMethod)(unsafe.Pointer((*TLineItem)(unsafe.Pointer(linePtr)).Fsmooth)).Fname, __ccgo_ts+29863) != 0) { /* * Cubic Bezier splines. See details in ticket [5fb8145997]. */ if (oriNumPoints-int32(1))%int32(3) != 0 || nbDelPoints%int32(3) != 0 { /* * No optimization for "degenerate" lines or when deleting * something else than a multiple of 3 points. */ canOptimize = 0 } else { first1 -= first1 % int32(6) last1 = int32(last + int64(6) - last%int64(6)) } } else { /* * Custom smoothing method. No optimization is possible. */ canOptimize = 0 } } } if first1 < 0 { first1 = 0 } if last1 >= length { last1 = length - int32(2) } if canOptimize != 0 && (first1 >= int32(2) || last1 < length-int32(2)) { /* * This is some optimizing code that will result that only the part of * the line that changed (and the objects that are overlapping with * that part) need to be redrawn. A special flag is set that instructs * the general canvas code not to redraw the whole object. If this * flag is set, the redrawing has to be done here, otherwise the * general Canvas code will take care of it. * Rationale for the optimization code can be found in Tk ticket * [5fb8145997]. */ *(*int32)(unsafe.Pointer(itemPtr + 112)) |= int32(TK_ITEM_DONT_REDRAW) v1 = int32(*(*float64)(unsafe.Pointer((*TLineItem)(unsafe.Pointer(linePtr)).FcoordPtr + uintptr(first1)*8))) (*TTk_Item)(unsafe.Pointer(itemPtr)).Fx2 = v1 (*TTk_Item)(unsafe.Pointer(itemPtr)).Fx1 = v1 v2 = int32(*(*float64)(unsafe.Pointer((*TLineItem)(unsafe.Pointer(linePtr)).FcoordPtr + uintptr(first1+int32(1))*8))) (*TTk_Item)(unsafe.Pointer(itemPtr)).Fy2 = v2 (*TTk_Item)(unsafe.Pointer(itemPtr)).Fy1 = v2 if (*TLineItem)(unsafe.Pointer(linePtr)).FfirstArrowPtr != libc.UintptrFromInt32(0) && first1 < int32(2) { /* * Include old first arrow. */ i = 0 coordPtr = (*TLineItem)(unsafe.Pointer(linePtr)).FfirstArrowPtr for { if !(i < int32(PTS_IN_ARROW)) { break } XTkIncludePoint(tls, itemPtr, coordPtr) goto _3 _3: ; i++ coordPtr += uintptr(2) * 8 } } if (*TLineItem)(unsafe.Pointer(linePtr)).FlastArrowPtr != libc.UintptrFromInt32(0) && last1 >= length-int32(2) { /* * Include old last arrow. */ i = 0 coordPtr = (*TLineItem)(unsafe.Pointer(linePtr)).FlastArrowPtr for { if !(i < int32(PTS_IN_ARROW)) { break } XTkIncludePoint(tls, itemPtr, coordPtr) goto _4 _4: ; i++ coordPtr += uintptr(2) * 8 } } coordPtr = (*TLineItem)(unsafe.Pointer(linePtr)).FcoordPtr + uintptr(first1)*8 + uintptr(2)*8 i = first1 + int32(2) for { if !(i <= last1) { break } XTkIncludePoint(tls, itemPtr, coordPtr) coordPtr += uintptr(2) * 8 goto _5 _5: ; i += int32(2) } } count = int32(last + int64(2) - first) i = int32(last + int64(2)) for { if !(i < length) { break } *(*float64)(unsafe.Pointer((*TLineItem)(unsafe.Pointer(linePtr)).FcoordPtr + uintptr(i-count)*8)) = *(*float64)(unsafe.Pointer((*TLineItem)(unsafe.Pointer(linePtr)).FcoordPtr + uintptr(i)*8)) goto _6 _6: ; i++ } *(*TTcl_Size)(unsafe.Pointer(linePtr + 304)) -= int64(count / int32(2)) if (*TLineItem)(unsafe.Pointer(linePtr)).FfirstArrowPtr != libc.UintptrFromInt32(0) { libtcl9_0.XTcl_Free(tls, (*TLineItem)(unsafe.Pointer(linePtr)).FfirstArrowPtr) (*TLineItem)(unsafe.Pointer(linePtr)).FfirstArrowPtr = libc.UintptrFromInt32(0) } if (*TLineItem)(unsafe.Pointer(linePtr)).FlastArrowPtr != libc.UintptrFromInt32(0) { libtcl9_0.XTcl_Free(tls, (*TLineItem)(unsafe.Pointer(linePtr)).FlastArrowPtr) (*TLineItem)(unsafe.Pointer(linePtr)).FlastArrowPtr = libc.UintptrFromInt32(0) } if (*TLineItem)(unsafe.Pointer(linePtr)).Farrow != int32(ARROWS_NONE) { _ConfigureArrows(tls, canvas, linePtr) } if (*TTk_Item)(unsafe.Pointer(itemPtr)).Fredraw_flags&int32(TK_ITEM_DONT_REDRAW) != 0 { if (*TLineItem)(unsafe.Pointer(linePtr)).FfirstArrowPtr != libc.UintptrFromInt32(0) && first1 < int32(2) { /* * Include new first arrow. */ i = 0 coordPtr = (*TLineItem)(unsafe.Pointer(linePtr)).FfirstArrowPtr for { if !(i < int32(PTS_IN_ARROW)) { break } XTkIncludePoint(tls, itemPtr, coordPtr) goto _7 _7: ; i++ coordPtr += uintptr(2) * 8 } } if (*TLineItem)(unsafe.Pointer(linePtr)).FlastArrowPtr != libc.UintptrFromInt32(0) && last1 >= length-int32(2) { /* * Include new last arrow. */ i = 0 coordPtr = (*TLineItem)(unsafe.Pointer(linePtr)).FlastArrowPtr for { if !(i < int32(PTS_IN_ARROW)) { break } XTkIncludePoint(tls, itemPtr, coordPtr) goto _8 _8: ; i++ coordPtr += uintptr(2) * 8 } } width = (*TLineItem)(unsafe.Pointer(linePtr)).Foutline.Fwidth if (*TTkCanvas)(unsafe.Pointer(canvas)).FcurrentItemPtr == itemPtr { if (*TLineItem)(unsafe.Pointer(linePtr)).Foutline.FactiveWidth > width { width = (*TLineItem)(unsafe.Pointer(linePtr)).Foutline.FactiveWidth } } else { if state == int32(TK_STATE_DISABLED) { if (*TLineItem)(unsafe.Pointer(linePtr)).Foutline.FdisabledWidth > libc.Float64FromInt32(0) { width = (*TLineItem)(unsafe.Pointer(linePtr)).Foutline.FdisabledWidth } } } intWidth = int32(width + libc.Float64FromFloat64(0.5)) if intWidth < int32(1) { intWidth = int32(1) } *(*int32)(unsafe.Pointer(itemPtr + 72)) -= intWidth *(*int32)(unsafe.Pointer(itemPtr + 76)) -= intWidth *(*int32)(unsafe.Pointer(itemPtr + 80)) += intWidth *(*int32)(unsafe.Pointer(itemPtr + 84)) += intWidth XTk_CanvasEventuallyRedraw(tls, canvas, (*TTk_Item)(unsafe.Pointer(itemPtr)).Fx1, (*TTk_Item)(unsafe.Pointer(itemPtr)).Fy1, (*TTk_Item)(unsafe.Pointer(itemPtr)).Fx2, (*TTk_Item)(unsafe.Pointer(itemPtr)).Fy2) } _ComputeLineBbox(tls, canvas, linePtr) } /* *-------------------------------------------------------------- * * LineToPoint -- * * Computes the distance from a given point to a given line, in canvas * units. * * Results: * The return value is 0 if the point whose x and y coordinates are * pointPtr[0] and pointPtr[1] is inside the line. If the point isn't * inside the line then the return value is the distance from the point * to the line. * * Side effects: * None. * *-------------------------------------------------------------- */ func _LineToPoint(tls *libc.TLS, canvas TTk_Canvas, itemPtr uintptr, pointPtr uintptr) (r float64) { bp := tls.Alloc(3280) defer tls.Free(3280) /* Pointer to x and y coordinates. */ var bestDist, dist, width float64 var changedMiterToBevel, count, numPoints int32 var coordPtr, linePoints, linePtr uintptr var state TTk_State var _ /* poly at bp+3200 */ [10]float64 var _ /* staticSpace at bp+0 */ [400]float64 _, _, _, _, _, _, _, _, _, _ = bestDist, changedMiterToBevel, coordPtr, count, dist, linePoints, linePtr, numPoints, state, width state = (*TTk_Item)(unsafe.Pointer(itemPtr)).Fstate linePtr = itemPtr /* Non-zero means that a mitered corner had to * be treated as beveled after all because the * angle was < 11 degrees. */ bestDist = float64(1e+36) /* * Handle smoothed lines by generating an expanded set of points against * which to do the check. */ if state == int32(TK_STATE_NULL) { state = (*TTkCanvas)(unsafe.Pointer(canvas)).Fcanvas_state } width = (*TLineItem)(unsafe.Pointer(linePtr)).Foutline.Fwidth if (*TTkCanvas)(unsafe.Pointer(canvas)).FcurrentItemPtr == itemPtr { if (*TLineItem)(unsafe.Pointer(linePtr)).Foutline.FactiveWidth > width { width = (*TLineItem)(unsafe.Pointer(linePtr)).Foutline.FactiveWidth } } else { if state == int32(TK_STATE_DISABLED) { if (*TLineItem)(unsafe.Pointer(linePtr)).Foutline.FdisabledWidth > libc.Float64FromInt32(0) { width = (*TLineItem)(unsafe.Pointer(linePtr)).Foutline.FdisabledWidth } } } if (*TLineItem)(unsafe.Pointer(linePtr)).Fsmooth != 0 && (*TLineItem)(unsafe.Pointer(linePtr)).FnumPoints > int64(2) { numPoints = (*(*func(*libc.TLS, TTk_Canvas, uintptr, int32, int32, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*TTk_SmoothMethod)(unsafe.Pointer((*TLineItem)(unsafe.Pointer(linePtr)).Fsmooth)).FcoordProc})))(tls, canvas, libc.UintptrFromInt32(0), int32((*TLineItem)(unsafe.Pointer(linePtr)).FnumPoints), (*TLineItem)(unsafe.Pointer(linePtr)).FsplineSteps, libc.UintptrFromInt32(0), libc.UintptrFromInt32(0)) if numPoints <= int32(MAX_STATIC_POINTS) { linePoints = bp } else { linePoints = libtcl9_0.XTcl_Alloc(tls, libc.Uint64FromInt32(int32(2)*numPoints)*uint64(8)) } numPoints = (*(*func(*libc.TLS, TTk_Canvas, uintptr, int32, int32, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*TTk_SmoothMethod)(unsafe.Pointer((*TLineItem)(unsafe.Pointer(linePtr)).Fsmooth)).FcoordProc})))(tls, canvas, (*TLineItem)(unsafe.Pointer(linePtr)).FcoordPtr, int32((*TLineItem)(unsafe.Pointer(linePtr)).FnumPoints), (*TLineItem)(unsafe.Pointer(linePtr)).FsplineSteps, libc.UintptrFromInt32(0), linePoints) } else { numPoints = int32((*TLineItem)(unsafe.Pointer(linePtr)).FnumPoints) linePoints = (*TLineItem)(unsafe.Pointer(linePtr)).FcoordPtr } if width < float64(1) { width = float64(1) } if !(numPoints != 0) || (*TTk_Item)(unsafe.Pointer(itemPtr)).Fstate == int32(TK_STATE_HIDDEN) { return bestDist } else { if numPoints == int32(1) { bestDist = libc.X__builtin_hypot(tls, *(*float64)(unsafe.Pointer(linePoints))-*(*float64)(unsafe.Pointer(pointPtr)), *(*float64)(unsafe.Pointer(linePoints + 1*8))-*(*float64)(unsafe.Pointer(pointPtr + 1*8))) - width/float64(2) if bestDist < libc.Float64FromInt32(0) { bestDist = libc.Float64FromInt32(0) } return bestDist } } /* * The overall idea is to iterate through all of the edges of the line, * computing a polygon for each edge and testing the point against that * polygon. In addition, there are additional tests to deal with rounded * joints and caps. */ changedMiterToBevel = 0 count = numPoints coordPtr = linePoints for { if !(count >= int32(2)) { break } /* * If rounding is done around the first point then compute the * distance between the point and the point. */ if (*TLineItem)(unsafe.Pointer(linePtr)).FcapStyle == int32(CapRound) && count == numPoints || (*TLineItem)(unsafe.Pointer(linePtr)).FjoinStyle == int32(JoinRound) && count != numPoints { dist = libc.X__builtin_hypot(tls, *(*float64)(unsafe.Pointer(coordPtr))-*(*float64)(unsafe.Pointer(pointPtr)), *(*float64)(unsafe.Pointer(coordPtr + 1*8))-*(*float64)(unsafe.Pointer(pointPtr + 1*8))) - width/float64(2) if dist <= float64(0) { bestDist = float64(0) goto done } else { if dist < bestDist { bestDist = dist } } } /* * Compute the polygonal shape corresponding to this edge, consisting * of two points for the first point of the edge and two points for * the last point of the edge. */ if count == numPoints { XTkGetButtPoints(tls, coordPtr+uintptr(2)*8, coordPtr, width, libc.BoolInt32((*TLineItem)(unsafe.Pointer(linePtr)).FcapStyle == int32(CapProjecting)), bp+3200, bp+3200+uintptr(2)*8) } else { if (*TLineItem)(unsafe.Pointer(linePtr)).FjoinStyle == JoinMiter && !(changedMiterToBevel != 0) { (*(*[10]float64)(unsafe.Pointer(bp + 3200)))[0] = (*(*[10]float64)(unsafe.Pointer(bp + 3200)))[int32(6)] (*(*[10]float64)(unsafe.Pointer(bp + 3200)))[int32(1)] = (*(*[10]float64)(unsafe.Pointer(bp + 3200)))[int32(7)] (*(*[10]float64)(unsafe.Pointer(bp + 3200)))[int32(2)] = (*(*[10]float64)(unsafe.Pointer(bp + 3200)))[int32(4)] (*(*[10]float64)(unsafe.Pointer(bp + 3200)))[int32(3)] = (*(*[10]float64)(unsafe.Pointer(bp + 3200)))[int32(5)] } else { XTkGetButtPoints(tls, coordPtr+uintptr(2)*8, coordPtr, width, 0, bp+3200, bp+3200+uintptr(2)*8) /* * If this line uses beveled joints, then check the distance to a * polygon comprising the last two points of the previous polygon * and the first two from this polygon; this checks the wedges * that fill the mitered joint. */ if (*TLineItem)(unsafe.Pointer(linePtr)).FjoinStyle == int32(JoinBevel) || changedMiterToBevel != 0 { (*(*[10]float64)(unsafe.Pointer(bp + 3200)))[int32(8)] = (*(*[10]float64)(unsafe.Pointer(bp + 3200)))[0] (*(*[10]float64)(unsafe.Pointer(bp + 3200)))[int32(9)] = (*(*[10]float64)(unsafe.Pointer(bp + 3200)))[int32(1)] dist = XTkPolygonToPoint(tls, bp+3200, int32(5), pointPtr) if dist <= float64(0) { bestDist = float64(0) goto done } else { if dist < bestDist { bestDist = dist } } changedMiterToBevel = 0 } } } if count == int32(2) { XTkGetButtPoints(tls, coordPtr, coordPtr+uintptr(2)*8, width, libc.BoolInt32((*TLineItem)(unsafe.Pointer(linePtr)).FcapStyle == int32(CapProjecting)), bp+3200+uintptr(4)*8, bp+3200+uintptr(6)*8) } else { if (*TLineItem)(unsafe.Pointer(linePtr)).FjoinStyle == JoinMiter { if XTkGetMiterPoints(tls, coordPtr, coordPtr+uintptr(2)*8, coordPtr+uintptr(4)*8, width, bp+3200+uintptr(4)*8, bp+3200+uintptr(6)*8) == 0 { changedMiterToBevel = int32(1) XTkGetButtPoints(tls, coordPtr, coordPtr+uintptr(2)*8, width, 0, bp+3200+uintptr(4)*8, bp+3200+uintptr(6)*8) } } else { XTkGetButtPoints(tls, coordPtr, coordPtr+uintptr(2)*8, width, 0, bp+3200+uintptr(4)*8, bp+3200+uintptr(6)*8) } } (*(*[10]float64)(unsafe.Pointer(bp + 3200)))[int32(8)] = (*(*[10]float64)(unsafe.Pointer(bp + 3200)))[0] (*(*[10]float64)(unsafe.Pointer(bp + 3200)))[int32(9)] = (*(*[10]float64)(unsafe.Pointer(bp + 3200)))[int32(1)] dist = XTkPolygonToPoint(tls, bp+3200, int32(5), pointPtr) if dist <= float64(0) { bestDist = float64(0) goto done } else { if dist < bestDist { bestDist = dist } } goto _1 _1: ; count-- coordPtr += uintptr(2) * 8 } /* * If caps are rounded, check the distance to the cap around the final end * point of the line. */ if (*TLineItem)(unsafe.Pointer(linePtr)).FcapStyle == int32(CapRound) { dist = libc.X__builtin_hypot(tls, *(*float64)(unsafe.Pointer(coordPtr))-*(*float64)(unsafe.Pointer(pointPtr)), *(*float64)(unsafe.Pointer(coordPtr + 1*8))-*(*float64)(unsafe.Pointer(pointPtr + 1*8))) - width/float64(2) if dist <= float64(0) { bestDist = float64(0) goto done } else { if dist < bestDist { bestDist = dist } } } /* * If there are arrowheads, check the distance to the arrowheads. */ if (*TLineItem)(unsafe.Pointer(linePtr)).Farrow != int32(ARROWS_NONE) { if (*TLineItem)(unsafe.Pointer(linePtr)).Farrow != int32(ARROWS_LAST) { dist = XTkPolygonToPoint(tls, (*TLineItem)(unsafe.Pointer(linePtr)).FfirstArrowPtr, int32(PTS_IN_ARROW), pointPtr) if dist <= float64(0) { bestDist = float64(0) goto done } else { if dist < bestDist { bestDist = dist } } } if (*TLineItem)(unsafe.Pointer(linePtr)).Farrow != int32(ARROWS_FIRST) { dist = XTkPolygonToPoint(tls, (*TLineItem)(unsafe.Pointer(linePtr)).FlastArrowPtr, int32(PTS_IN_ARROW), pointPtr) if dist <= float64(0) { bestDist = float64(0) goto done } else { if dist < bestDist { bestDist = dist } } } } goto done done: ; if linePoints != bp && linePoints != (*TLineItem)(unsafe.Pointer(linePtr)).FcoordPtr { libtcl9_0.XTcl_Free(tls, linePoints) } return bestDist } /* *-------------------------------------------------------------- * * LineToArea -- * * This function is called to determine whether an item lies entirely * inside, entirely outside, or overlapping a given rectangular area. * * Results: * -1 is returned if the item is entirely outside the area, 0 if it * overlaps, and 1 if it is entirely inside the given area. * * Side effects: * None. * *-------------------------------------------------------------- */ func _LineToArea(tls *libc.TLS, canvas TTk_Canvas, itemPtr uintptr, rectPtr uintptr) (r int32) { bp := tls.Alloc(3232) defer tls.Free(3232) var linePoints, linePtr uintptr var numPoints, result int32 var radius, width float64 var state TTk_State var _ /* oval at bp+3200 */ [4]float64 var _ /* staticSpace at bp+0 */ [400]float64 _, _, _, _, _, _, _ = linePoints, linePtr, numPoints, radius, result, state, width linePtr = itemPtr state = (*TTk_Item)(unsafe.Pointer(itemPtr)).Fstate if state == int32(TK_STATE_NULL) { state = (*TTkCanvas)(unsafe.Pointer(canvas)).Fcanvas_state } width = (*TLineItem)(unsafe.Pointer(linePtr)).Foutline.Fwidth if (*TTkCanvas)(unsafe.Pointer(canvas)).FcurrentItemPtr == itemPtr { if (*TLineItem)(unsafe.Pointer(linePtr)).Foutline.FactiveWidth > width { width = (*TLineItem)(unsafe.Pointer(linePtr)).Foutline.FactiveWidth } } else { if state == int32(TK_STATE_DISABLED) { if (*TLineItem)(unsafe.Pointer(linePtr)).Foutline.FdisabledWidth > libc.Float64FromInt32(0) { width = (*TLineItem)(unsafe.Pointer(linePtr)).Foutline.FdisabledWidth } } } radius = (width + float64(1)) / float64(2) if state == int32(TK_STATE_HIDDEN) || !((*TLineItem)(unsafe.Pointer(linePtr)).FnumPoints != 0) { return -int32(1) } else { if (*TLineItem)(unsafe.Pointer(linePtr)).FnumPoints == int64(1) { (*(*[4]float64)(unsafe.Pointer(bp + 3200)))[0] = *(*float64)(unsafe.Pointer((*TLineItem)(unsafe.Pointer(linePtr)).FcoordPtr)) - radius (*(*[4]float64)(unsafe.Pointer(bp + 3200)))[int32(1)] = *(*float64)(unsafe.Pointer((*TLineItem)(unsafe.Pointer(linePtr)).FcoordPtr + 1*8)) - radius (*(*[4]float64)(unsafe.Pointer(bp + 3200)))[int32(2)] = *(*float64)(unsafe.Pointer((*TLineItem)(unsafe.Pointer(linePtr)).FcoordPtr)) + radius (*(*[4]float64)(unsafe.Pointer(bp + 3200)))[int32(3)] = *(*float64)(unsafe.Pointer((*TLineItem)(unsafe.Pointer(linePtr)).FcoordPtr + 1*8)) + radius return XTkOvalToArea(tls, bp+3200, rectPtr) } } /* * Handle smoothed lines by generating an expanded set of points against * which to do the check. */ if (*TLineItem)(unsafe.Pointer(linePtr)).Fsmooth != 0 && (*TLineItem)(unsafe.Pointer(linePtr)).FnumPoints > int64(2) { numPoints = (*(*func(*libc.TLS, TTk_Canvas, uintptr, int32, int32, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*TTk_SmoothMethod)(unsafe.Pointer((*TLineItem)(unsafe.Pointer(linePtr)).Fsmooth)).FcoordProc})))(tls, canvas, libc.UintptrFromInt32(0), int32((*TLineItem)(unsafe.Pointer(linePtr)).FnumPoints), (*TLineItem)(unsafe.Pointer(linePtr)).FsplineSteps, libc.UintptrFromInt32(0), libc.UintptrFromInt32(0)) if numPoints <= int32(MAX_STATIC_POINTS) { linePoints = bp } else { linePoints = libtcl9_0.XTcl_Alloc(tls, libc.Uint64FromInt32(int32(2)*numPoints)*uint64(8)) } numPoints = (*(*func(*libc.TLS, TTk_Canvas, uintptr, int32, int32, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*TTk_SmoothMethod)(unsafe.Pointer((*TLineItem)(unsafe.Pointer(linePtr)).Fsmooth)).FcoordProc})))(tls, canvas, (*TLineItem)(unsafe.Pointer(linePtr)).FcoordPtr, int32((*TLineItem)(unsafe.Pointer(linePtr)).FnumPoints), (*TLineItem)(unsafe.Pointer(linePtr)).FsplineSteps, libc.UintptrFromInt32(0), linePoints) } else { numPoints = int32((*TLineItem)(unsafe.Pointer(linePtr)).FnumPoints) linePoints = (*TLineItem)(unsafe.Pointer(linePtr)).FcoordPtr } /* * Check the segments of the line. */ if width < float64(1) { width = float64(1) } result = XTkThickPolyLineToArea(tls, linePoints, numPoints, width, (*TLineItem)(unsafe.Pointer(linePtr)).FcapStyle, (*TLineItem)(unsafe.Pointer(linePtr)).FjoinStyle, rectPtr) if result == 0 { goto done } /* * Check arrowheads, if any. */ if (*TLineItem)(unsafe.Pointer(linePtr)).Farrow != int32(ARROWS_NONE) { if (*TLineItem)(unsafe.Pointer(linePtr)).Farrow != int32(ARROWS_LAST) { if XTkPolygonToArea(tls, (*TLineItem)(unsafe.Pointer(linePtr)).FfirstArrowPtr, int32(PTS_IN_ARROW), rectPtr) != result { result = 0 goto done } } if (*TLineItem)(unsafe.Pointer(linePtr)).Farrow != int32(ARROWS_FIRST) { if XTkPolygonToArea(tls, (*TLineItem)(unsafe.Pointer(linePtr)).FlastArrowPtr, int32(PTS_IN_ARROW), rectPtr) != result { result = 0 goto done } } } goto done done: ; if linePoints != bp && linePoints != (*TLineItem)(unsafe.Pointer(linePtr)).FcoordPtr { libtcl9_0.XTcl_Free(tls, linePoints) } return result } /* *-------------------------------------------------------------- * * ScaleLine -- * * This function is invoked to rescale a line item. * * Results: * None. * * Side effects: * The line referred to by itemPtr is rescaled so that the following * transformation is applied to all point coordinates: * x' = originX + scaleX*(x-originX) * y' = originY + scaleY*(y-originY) * *-------------------------------------------------------------- */ func _ScaleLine(tls *libc.TLS, canvas TTk_Canvas, itemPtr uintptr, originX float64, originY float64, scaleX float64, scaleY float64) { /* Amount to scale in Y direction. */ var coordPtr, linePtr uintptr var i TTcl_Size _, _, _ = coordPtr, i, linePtr linePtr = itemPtr /* * Delete any arrowheads before scaling all the points (so that the * end-points of the line get restored). */ if (*TLineItem)(unsafe.Pointer(linePtr)).FfirstArrowPtr != libc.UintptrFromInt32(0) { *(*float64)(unsafe.Pointer((*TLineItem)(unsafe.Pointer(linePtr)).FcoordPtr)) = *(*float64)(unsafe.Pointer((*TLineItem)(unsafe.Pointer(linePtr)).FfirstArrowPtr)) *(*float64)(unsafe.Pointer((*TLineItem)(unsafe.Pointer(linePtr)).FcoordPtr + 1*8)) = *(*float64)(unsafe.Pointer((*TLineItem)(unsafe.Pointer(linePtr)).FfirstArrowPtr + 1*8)) libtcl9_0.XTcl_Free(tls, (*TLineItem)(unsafe.Pointer(linePtr)).FfirstArrowPtr) (*TLineItem)(unsafe.Pointer(linePtr)).FfirstArrowPtr = libc.UintptrFromInt32(0) } if (*TLineItem)(unsafe.Pointer(linePtr)).FlastArrowPtr != libc.UintptrFromInt32(0) { i = int64(2) * ((*TLineItem)(unsafe.Pointer(linePtr)).FnumPoints - int64(1)) *(*float64)(unsafe.Pointer((*TLineItem)(unsafe.Pointer(linePtr)).FcoordPtr + uintptr(i)*8)) = *(*float64)(unsafe.Pointer((*TLineItem)(unsafe.Pointer(linePtr)).FlastArrowPtr)) *(*float64)(unsafe.Pointer((*TLineItem)(unsafe.Pointer(linePtr)).FcoordPtr + uintptr(i+int64(1))*8)) = *(*float64)(unsafe.Pointer((*TLineItem)(unsafe.Pointer(linePtr)).FlastArrowPtr + 1*8)) libtcl9_0.XTcl_Free(tls, (*TLineItem)(unsafe.Pointer(linePtr)).FlastArrowPtr) (*TLineItem)(unsafe.Pointer(linePtr)).FlastArrowPtr = libc.UintptrFromInt32(0) } i = 0 coordPtr = (*TLineItem)(unsafe.Pointer(linePtr)).FcoordPtr for { if !(i < (*TLineItem)(unsafe.Pointer(linePtr)).FnumPoints) { break } *(*float64)(unsafe.Pointer(coordPtr)) = originX + float64(scaleX*(*(*float64)(unsafe.Pointer(coordPtr))-originX)) *(*float64)(unsafe.Pointer(coordPtr + 1*8)) = originY + float64(scaleY*(*(*float64)(unsafe.Pointer(coordPtr + 1*8))-originY)) goto _1 _1: ; i++ coordPtr += uintptr(2) * 8 } if (*TLineItem)(unsafe.Pointer(linePtr)).Farrow != int32(ARROWS_NONE) { _ConfigureArrows(tls, canvas, linePtr) } _ComputeLineBbox(tls, canvas, linePtr) } /* *-------------------------------------------------------------- * * GetLineIndex -- * * Parse an index into a line item and return either its value or an * error. * * Results: * A standard Tcl result. If all went well, then *indexPtr is filled in * with the index (into itemPtr) corresponding to string. Otherwise an * error message is left in interp->result. * * Side effects: * None. * *-------------------------------------------------------------- */ func _GetLineIndex(tls *libc.TLS, interp uintptr, dummy1867 TTk_Canvas, itemPtr uintptr, obj uintptr, indexPtr uintptr) (r int32) { bp := tls.Alloc(80) defer tls.Free(80) /* Where to store converted index. */ var bestDist, dist float64 var coordPtr, linePtr, p, sep, string1 uintptr var i TTcl_Size var savechar uint8 var _ /* idx at bp+0 */ TTcl_Size var _ /* length at bp+8 */ TTcl_Size var _ /* x at bp+16 */ float64 var _ /* y at bp+24 */ float64 _, _, _, _, _, _, _, _, _ = bestDist, coordPtr, dist, i, linePtr, p, savechar, sep, string1 linePtr = itemPtr if TCL_OK == XTkGetIntForIndex(tls, obj, int64(2)*(*TLineItem)(unsafe.Pointer(linePtr)).FnumPoints-int64(1), int32(1), bp) { if *(*TTcl_Size)(unsafe.Pointer(bp)) < 0 { *(*TTcl_Size)(unsafe.Pointer(bp)) = 0 } else { if *(*TTcl_Size)(unsafe.Pointer(bp)) > int64(2)*(*TLineItem)(unsafe.Pointer(linePtr)).FnumPoints { *(*TTcl_Size)(unsafe.Pointer(bp)) = int64(2) * (*TLineItem)(unsafe.Pointer(linePtr)).FnumPoints } else { *(*TTcl_Size)(unsafe.Pointer(bp)) &= int64(-libc.Int32FromInt32(2)) /* If index is odd, make it even. */ } } *(*TTcl_Size)(unsafe.Pointer(indexPtr)) = *(*TTcl_Size)(unsafe.Pointer(bp)) return TCL_OK } string1 = libtcl9_0.XTcl_GetStringFromObj(tls, obj, bp+8) if !(libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(string1))) == int32('@')) { goto _1 } p = string1 + uintptr(1) sep = libc.Xstrchr(tls, p, int32(',')) if !(sep != 0) { goto badIndex } savechar = *(*uint8)(unsafe.Pointer(sep)) *(*uint8)(unsafe.Pointer(sep)) = uint8('\000') i = int64(libtcl9_0.XTcl_GetDouble(tls, libc.UintptrFromInt32(0), p, bp+16)) *(*uint8)(unsafe.Pointer(sep)) = savechar if i != TCL_OK { goto badIndex } p = sep + uintptr(1) i = int64(libtcl9_0.XTcl_GetDouble(tls, libc.UintptrFromInt32(0), p, bp+24)) if i != TCL_OK { goto badIndex } bestDist = float64(1e+36) coordPtr = (*TLineItem)(unsafe.Pointer(linePtr)).FcoordPtr *(*TTcl_Size)(unsafe.Pointer(indexPtr)) = 0 i = 0 for { if !(i < (*TLineItem)(unsafe.Pointer(linePtr)).FnumPoints) { break } dist = libc.X__builtin_hypot(tls, *(*float64)(unsafe.Pointer(coordPtr))-*(*float64)(unsafe.Pointer(bp + 16)), *(*float64)(unsafe.Pointer(coordPtr + 1*8))-*(*float64)(unsafe.Pointer(bp + 24))) if dist < bestDist { bestDist = dist *(*TTcl_Size)(unsafe.Pointer(indexPtr)) = int64(2) * i } coordPtr += uintptr(2) * 8 goto _3 _3: ; i++ } goto _2 _1: ; goto badIndex badIndex: ; libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+29867, libc.VaList(bp+40, string1))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+40, __ccgo_ts+179, __ccgo_ts+27003, __ccgo_ts+23800, __ccgo_ts+29803, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) _2: ; return TCL_OK } /* *-------------------------------------------------------------- * * TranslateLine -- * * This function is called to move a line by a given amount. * * Results: * None. * * Side effects: * The position of the line is offset by (xDelta, yDelta), and the * bounding box is updated in the generic part of the item structure. * *-------------------------------------------------------------- */ func _TranslateLine(tls *libc.TLS, canvas TTk_Canvas, itemPtr uintptr, deltaX float64, deltaY float64) { /* Amount by which item is to be moved. */ var coordPtr, linePtr uintptr var i TTcl_Size _, _, _ = coordPtr, i, linePtr linePtr = itemPtr i = 0 coordPtr = (*TLineItem)(unsafe.Pointer(linePtr)).FcoordPtr for { if !(i < (*TLineItem)(unsafe.Pointer(linePtr)).FnumPoints) { break } *(*float64)(unsafe.Pointer(coordPtr)) += deltaX *(*float64)(unsafe.Pointer(coordPtr + 1*8)) += deltaY goto _1 _1: ; i++ coordPtr += uintptr(2) * 8 } if (*TLineItem)(unsafe.Pointer(linePtr)).FfirstArrowPtr != libc.UintptrFromInt32(0) { i = 0 coordPtr = (*TLineItem)(unsafe.Pointer(linePtr)).FfirstArrowPtr for { if !(i < int64(PTS_IN_ARROW)) { break } *(*float64)(unsafe.Pointer(coordPtr)) += deltaX *(*float64)(unsafe.Pointer(coordPtr + 1*8)) += deltaY goto _2 _2: ; i++ coordPtr += uintptr(2) * 8 } } if (*TLineItem)(unsafe.Pointer(linePtr)).FlastArrowPtr != libc.UintptrFromInt32(0) { i = 0 coordPtr = (*TLineItem)(unsafe.Pointer(linePtr)).FlastArrowPtr for { if !(i < int64(PTS_IN_ARROW)) { break } *(*float64)(unsafe.Pointer(coordPtr)) += deltaX *(*float64)(unsafe.Pointer(coordPtr + 1*8)) += deltaY goto _3 _3: ; i++ coordPtr += uintptr(2) * 8 } } _ComputeLineBbox(tls, canvas, linePtr) } /* *-------------------------------------------------------------- * * RotateLine -- * * This function is called to rotate a line by a given amount about a * point. * * Results: * None. * * Side effects: * The position of the line is rotated by angleRad about (originX, * originY), and the bounding box is updated in the generic part of the * item structure. * *-------------------------------------------------------------- */ func _RotateLine(tls *libc.TLS, canvas TTk_Canvas, itemPtr uintptr, originX float64, originY float64, angleRad float64) { /* Amount by which item is to be rotated. */ var c, s float64 var coordPtr, linePtr uintptr var i TTcl_Size _, _, _, _, _ = c, coordPtr, i, linePtr, s linePtr = itemPtr s = libc.Xsin(tls, angleRad) c = libc.Xcos(tls, angleRad) i = 0 coordPtr = (*TLineItem)(unsafe.Pointer(linePtr)).FcoordPtr for { if !(i < (*TLineItem)(unsafe.Pointer(linePtr)).FnumPoints) { break } XTkRotatePoint(tls, originX, originY, s, c, coordPtr, coordPtr+1*8) goto _1 _1: ; i++ coordPtr += uintptr(2) * 8 } if (*TLineItem)(unsafe.Pointer(linePtr)).FfirstArrowPtr != libc.UintptrFromInt32(0) { i = 0 coordPtr = (*TLineItem)(unsafe.Pointer(linePtr)).FfirstArrowPtr for { if !(i < int64(PTS_IN_ARROW)) { break } XTkRotatePoint(tls, originX, originY, s, c, coordPtr, coordPtr+1*8) goto _2 _2: ; i++ coordPtr += uintptr(2) * 8 } } if (*TLineItem)(unsafe.Pointer(linePtr)).FlastArrowPtr != libc.UintptrFromInt32(0) { i = 0 coordPtr = (*TLineItem)(unsafe.Pointer(linePtr)).FlastArrowPtr for { if !(i < int64(PTS_IN_ARROW)) { break } XTkRotatePoint(tls, originX, originY, s, c, coordPtr, coordPtr+1*8) goto _3 _3: ; i++ coordPtr += uintptr(2) * 8 } } _ComputeLineBbox(tls, canvas, linePtr) } /* *-------------------------------------------------------------- * * ParseArrowShape -- * * This function is called back during option parsing to parse arrow * shape information. * * Results: * The return value is a standard Tcl result: TCL_OK means that the arrow * shape information was parsed ok, and TCL_ERROR means it couldn't be * parsed. * * Side effects: * Arrow information in recordPtr is updated. * *-------------------------------------------------------------- */ func _ParseArrowShape(tls *libc.TLS, dummy2056 uintptr, interp uintptr, dummy2058 TTk_Window, value uintptr, recordPtr uintptr, offset TTcl_Size) (r int32) { bp := tls.Alloc(80) defer tls.Free(80) /* Offset of shape information in widget * record. */ var linePtr uintptr var _ /* a at bp+0 */ float64 var _ /* argc at bp+24 */ TTcl_Size var _ /* argv at bp+32 */ uintptr var _ /* b at bp+8 */ float64 var _ /* c at bp+16 */ float64 _ = linePtr linePtr = recordPtr *(*uintptr)(unsafe.Pointer(bp + 32)) = libc.UintptrFromInt32(0) if libc.Uint64FromInt64(offset) != uint64(libc.UintptrFromInt32(0)+340) { libtcl9_0.XTcl_Panic(tls, __ccgo_ts+29882, 0) } if libtcl9_0.XTcl_SplitList(tls, interp, value, bp+24, bp+32) != TCL_OK { goto syntaxError } else { if *(*TTcl_Size)(unsafe.Pointer(bp + 24)) != int64(3) { goto syntaxError } } if XTk_CanvasGetCoord(tls, interp, (*TLineItem)(unsafe.Pointer(linePtr)).Fcanvas, *(*uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 32)))), bp) != TCL_OK || XTk_CanvasGetCoord(tls, interp, (*TLineItem)(unsafe.Pointer(linePtr)).Fcanvas, *(*uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 32)) + 1*8)), bp+8) != TCL_OK || XTk_CanvasGetCoord(tls, interp, (*TLineItem)(unsafe.Pointer(linePtr)).Fcanvas, *(*uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 32)) + 2*8)), bp+16) != TCL_OK { goto syntaxError } (*TLineItem)(unsafe.Pointer(linePtr)).FarrowShapeA = float32(*(*float64)(unsafe.Pointer(bp))) (*TLineItem)(unsafe.Pointer(linePtr)).FarrowShapeB = float32(*(*float64)(unsafe.Pointer(bp + 8))) (*TLineItem)(unsafe.Pointer(linePtr)).FarrowShapeC = float32(*(*float64)(unsafe.Pointer(bp + 16))) libtcl9_0.XTcl_Free(tls, *(*uintptr)(unsafe.Pointer(bp + 32))) return TCL_OK goto syntaxError syntaxError: ; libtcl9_0.XTcl_ResetResult(tls, interp) libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+29920, libc.VaList(bp+48, value))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+48, __ccgo_ts+179, __ccgo_ts+27003, __ccgo_ts+29974, libc.UintptrFromInt32(0))) if *(*uintptr)(unsafe.Pointer(bp + 32)) != libc.UintptrFromInt32(0) { libtcl9_0.XTcl_Free(tls, *(*uintptr)(unsafe.Pointer(bp + 32))) } return int32(TCL_ERROR) } /* *-------------------------------------------------------------- * * PrintArrowShape -- * * This function is a callback invoked by the configuration code to * return a printable value describing an arrow shape. * * Results: * None. * * Side effects: * None. * *-------------------------------------------------------------- */ func _PrintArrowShape(tls *libc.TLS, dummy2124 uintptr, dummy2125 TTk_Window, recordPtr uintptr, dummy2128 TTcl_Size, freeProcPtr uintptr) (r uintptr) { bp := tls.Alloc(32) defer tls.Free(32) /* Store address of function to call to free * string here. */ var buffer, linePtr uintptr _, _ = buffer, linePtr linePtr = recordPtr buffer = libtcl9_0.XTcl_Alloc(tls, uint64(120)) libc.X__builtin_snprintf(tls, buffer, uint64(120), __ccgo_ts+29986, libc.VaList(bp+8, float64((*TLineItem)(unsafe.Pointer(linePtr)).FarrowShapeA), float64((*TLineItem)(unsafe.Pointer(linePtr)).FarrowShapeB), float64((*TLineItem)(unsafe.Pointer(linePtr)).FarrowShapeC))) *(*uintptr)(unsafe.Pointer(freeProcPtr)) = libc.UintptrFromInt32(3) return buffer } /* *-------------------------------------------------------------- * * ArrowParseProc -- * * This function is invoked during option processing to handle the * "-arrow" option. * * Results: * A standard Tcl return value. * * Side effects: * The arrow for a given item gets replaced by the arrow indicated in the * value argument. * *-------------------------------------------------------------- */ func _ArrowParseProc(tls *libc.TLS, dummy2161 uintptr, interp uintptr, dummy2163 TTk_Window, value uintptr, widgRec uintptr, offset TTcl_Size) (r int32) { bp := tls.Alloc(48) defer tls.Free(48) /* Offset into item. */ var arrowPtr uintptr var c int32 var length Tsize_t _, _, _ = arrowPtr, c, length arrowPtr = widgRec + uintptr(offset) if value == libc.UintptrFromInt32(0) || libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(value))) == 0 { *(*TArrows)(unsafe.Pointer(arrowPtr)) = int32(ARROWS_NONE) return TCL_OK } c = libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(value))) length = libc.Xstrlen(tls, value) if c == int32('n') && libc.Xstrncmp(tls, value, __ccgo_ts+8223, length) == 0 { *(*TArrows)(unsafe.Pointer(arrowPtr)) = int32(ARROWS_NONE) return TCL_OK } if c == int32('f') && libc.Xstrncmp(tls, value, __ccgo_ts+24978, length) == 0 { *(*TArrows)(unsafe.Pointer(arrowPtr)) = int32(ARROWS_FIRST) return TCL_OK } if c == int32('l') && libc.Xstrncmp(tls, value, __ccgo_ts+24701, length) == 0 { *(*TArrows)(unsafe.Pointer(arrowPtr)) = int32(ARROWS_LAST) return TCL_OK } if c == int32('b') && libc.Xstrncmp(tls, value, __ccgo_ts+15190, length) == 0 { *(*TArrows)(unsafe.Pointer(arrowPtr)) = int32(ARROWS_BOTH) return TCL_OK } libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+30001, libc.VaList(bp+8, value))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+8, __ccgo_ts+179, __ccgo_ts+27003, __ccgo_ts+30057, libc.UintptrFromInt32(0))) *(*TArrows)(unsafe.Pointer(arrowPtr)) = int32(ARROWS_NONE) return int32(TCL_ERROR) } /* *-------------------------------------------------------------- * * ArrowPrintProc -- * * This function is invoked by the Tk configuration code to produce a * printable string for the "-arrow" configuration option. * * Results: * The return value is a string describing the arrows for the item * referred to by "widgRec". In addition, *freeProcPtr is filled in with * the address of a function to call to free the result string when it's * no longer needed (or NULL to indicate that the string doesn't need to * be freed). * * Side effects: * None. * *-------------------------------------------------------------- */ func _ArrowPrintProc(tls *libc.TLS, dummy2228 uintptr, dummy2229 TTk_Window, widgRec uintptr, offset TTcl_Size, dummy2232 uintptr) (r uintptr) { /* Pointer to variable to fill in with * information about how to reclaim storage * for return string. */ var arrowPtr uintptr _ = arrowPtr arrowPtr = widgRec + uintptr(offset) switch *(*TArrows)(unsafe.Pointer(arrowPtr)) { case int32(ARROWS_FIRST): return __ccgo_ts + 24978 case int32(ARROWS_LAST): return __ccgo_ts + 24701 case int32(ARROWS_BOTH): return __ccgo_ts + 15190 default: return __ccgo_ts + 8223 } return r } /* *-------------------------------------------------------------- * * ConfigureArrows -- * * If arrowheads have been requested for a line, this function makes * arrangements for the arrowheads. * * Results: * Always returns TCL_OK. * * Side effects: * Information in linePtr is set up for one or two arrowheads. The * firstArrowPtr and lastArrowPtr polygons are allocated and initialized, * if need be, and the end points of the line are adjusted so that a * thick line doesn't stick out past the arrowheads. * *-------------------------------------------------------------- */ func _ConfigureArrows(tls *libc.TLS, canvas TTk_Canvas, linePtr uintptr) (r int32) { /* Item to configure for arrows. */ var backup, cosTheta, dx, dy, fracHeight, length, shapeA, shapeB, shapeC, sinTheta, temp, vertX, vertY, width, v1, v2, v3, v4, v5, v6 float64 var coordPtr, poly uintptr var state TTk_State _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = backup, coordPtr, cosTheta, dx, dy, fracHeight, length, poly, shapeA, shapeB, shapeC, sinTheta, state, temp, vertX, vertY, width, v1, v2, v3, v4, v5, v6 state = (*TLineItem)(unsafe.Pointer(linePtr)).Fheader.Fstate if (*TLineItem)(unsafe.Pointer(linePtr)).FnumPoints < int64(2) { return TCL_OK } if state == int32(TK_STATE_NULL) { state = (*TTkCanvas)(unsafe.Pointer(canvas)).Fcanvas_state } width = (*TLineItem)(unsafe.Pointer(linePtr)).Foutline.Fwidth if (*TTkCanvas)(unsafe.Pointer(canvas)).FcurrentItemPtr == linePtr { if (*TLineItem)(unsafe.Pointer(linePtr)).Foutline.FactiveWidth > width { width = (*TLineItem)(unsafe.Pointer(linePtr)).Foutline.FactiveWidth } } else { if state == int32(TK_STATE_DISABLED) { if (*TLineItem)(unsafe.Pointer(linePtr)).Foutline.FdisabledWidth > libc.Float64FromInt32(0) { width = (*TLineItem)(unsafe.Pointer(linePtr)).Foutline.FdisabledWidth } } } /* * The code below makes a tiny increase in the shape parameters for the * line. This is a bit of a hack, but it seems to result in displays that * more closely approximate the specified parameters. Without the * adjustment, the arrows come out smaller than expected. */ shapeA = float64((*TLineItem)(unsafe.Pointer(linePtr)).FarrowShapeA) + float64(0.001) shapeB = float64((*TLineItem)(unsafe.Pointer(linePtr)).FarrowShapeB) + float64(0.001) shapeC = float64((*TLineItem)(unsafe.Pointer(linePtr)).FarrowShapeC) + width/float64(2) + float64(0.001) /* * If there's an arrowhead on the first point of the line, compute its * polygon and adjust the first point of the line so that the line doesn't * stick out past the leading edge of the arrowhead. */ fracHeight = width / float64(2) / shapeC backup = float64(fracHeight*shapeB) + float64(shapeA*(float64(1)-fracHeight))/float64(2) if (*TLineItem)(unsafe.Pointer(linePtr)).Farrow != int32(ARROWS_LAST) { poly = (*TLineItem)(unsafe.Pointer(linePtr)).FfirstArrowPtr if poly == libc.UintptrFromInt32(0) { poly = libtcl9_0.XTcl_Alloc(tls, libc.Uint64FromInt32(libc.Int32FromInt32(2)*libc.Int32FromInt32(PTS_IN_ARROW))*libc.Uint64FromInt64(8)) v1 = *(*float64)(unsafe.Pointer((*TLineItem)(unsafe.Pointer(linePtr)).FcoordPtr)) *(*float64)(unsafe.Pointer(poly + 10*8)) = v1 *(*float64)(unsafe.Pointer(poly)) = v1 v2 = *(*float64)(unsafe.Pointer((*TLineItem)(unsafe.Pointer(linePtr)).FcoordPtr + 1*8)) *(*float64)(unsafe.Pointer(poly + 11*8)) = v2 *(*float64)(unsafe.Pointer(poly + 1*8)) = v2 (*TLineItem)(unsafe.Pointer(linePtr)).FfirstArrowPtr = poly } dx = *(*float64)(unsafe.Pointer(poly)) - *(*float64)(unsafe.Pointer((*TLineItem)(unsafe.Pointer(linePtr)).FcoordPtr + 2*8)) dy = *(*float64)(unsafe.Pointer(poly + 1*8)) - *(*float64)(unsafe.Pointer((*TLineItem)(unsafe.Pointer(linePtr)).FcoordPtr + 3*8)) length = libc.X__builtin_hypot(tls, dx, dy) if length == libc.Float64FromInt32(0) { v3 = libc.Float64FromFloat64(0) cosTheta = v3 sinTheta = v3 } else { sinTheta = dy / length cosTheta = dx / length } vertX = *(*float64)(unsafe.Pointer(poly)) - float64(shapeA*cosTheta) vertY = *(*float64)(unsafe.Pointer(poly + 1*8)) - float64(shapeA*sinTheta) temp = float64(shapeC * sinTheta) *(*float64)(unsafe.Pointer(poly + 2*8)) = *(*float64)(unsafe.Pointer(poly)) - float64(shapeB*cosTheta) + temp *(*float64)(unsafe.Pointer(poly + 8*8)) = *(*float64)(unsafe.Pointer(poly + 2*8)) - float64(libc.Float64FromInt32(2)*temp) temp = float64(shapeC * cosTheta) *(*float64)(unsafe.Pointer(poly + 3*8)) = *(*float64)(unsafe.Pointer(poly + 1*8)) - float64(shapeB*sinTheta) - temp *(*float64)(unsafe.Pointer(poly + 9*8)) = *(*float64)(unsafe.Pointer(poly + 3*8)) + float64(libc.Float64FromInt32(2)*temp) *(*float64)(unsafe.Pointer(poly + 4*8)) = float64(*(*float64)(unsafe.Pointer(poly + 2*8))*fracHeight) + float64(vertX*(float64(1)-fracHeight)) *(*float64)(unsafe.Pointer(poly + 5*8)) = float64(*(*float64)(unsafe.Pointer(poly + 3*8))*fracHeight) + float64(vertY*(float64(1)-fracHeight)) *(*float64)(unsafe.Pointer(poly + 6*8)) = float64(*(*float64)(unsafe.Pointer(poly + 8*8))*fracHeight) + float64(vertX*(float64(1)-fracHeight)) *(*float64)(unsafe.Pointer(poly + 7*8)) = float64(*(*float64)(unsafe.Pointer(poly + 9*8))*fracHeight) + float64(vertY*(float64(1)-fracHeight)) /* * Polygon done. Now move the first point towards the second so that * the corners at the end of the line are inside the arrowhead. */ *(*float64)(unsafe.Pointer((*TLineItem)(unsafe.Pointer(linePtr)).FcoordPtr)) = *(*float64)(unsafe.Pointer(poly)) - float64(backup*cosTheta) *(*float64)(unsafe.Pointer((*TLineItem)(unsafe.Pointer(linePtr)).FcoordPtr + 1*8)) = *(*float64)(unsafe.Pointer(poly + 1*8)) - float64(backup*sinTheta) } /* * Similar arrowhead calculation for the last point of the line. */ if (*TLineItem)(unsafe.Pointer(linePtr)).Farrow != int32(ARROWS_FIRST) { coordPtr = (*TLineItem)(unsafe.Pointer(linePtr)).FcoordPtr + uintptr(int64(2)*((*TLineItem)(unsafe.Pointer(linePtr)).FnumPoints-int64(2)))*8 poly = (*TLineItem)(unsafe.Pointer(linePtr)).FlastArrowPtr if poly == libc.UintptrFromInt32(0) { poly = libtcl9_0.XTcl_Alloc(tls, libc.Uint64FromInt32(libc.Int32FromInt32(2)*libc.Int32FromInt32(PTS_IN_ARROW))*libc.Uint64FromInt64(8)) v4 = *(*float64)(unsafe.Pointer(coordPtr + 2*8)) *(*float64)(unsafe.Pointer(poly + 10*8)) = v4 *(*float64)(unsafe.Pointer(poly)) = v4 v5 = *(*float64)(unsafe.Pointer(coordPtr + 3*8)) *(*float64)(unsafe.Pointer(poly + 11*8)) = v5 *(*float64)(unsafe.Pointer(poly + 1*8)) = v5 (*TLineItem)(unsafe.Pointer(linePtr)).FlastArrowPtr = poly } dx = *(*float64)(unsafe.Pointer(poly)) - *(*float64)(unsafe.Pointer(coordPtr)) dy = *(*float64)(unsafe.Pointer(poly + 1*8)) - *(*float64)(unsafe.Pointer(coordPtr + 1*8)) length = libc.X__builtin_hypot(tls, dx, dy) if length == libc.Float64FromInt32(0) { v6 = libc.Float64FromFloat64(0) cosTheta = v6 sinTheta = v6 } else { sinTheta = dy / length cosTheta = dx / length } vertX = *(*float64)(unsafe.Pointer(poly)) - float64(shapeA*cosTheta) vertY = *(*float64)(unsafe.Pointer(poly + 1*8)) - float64(shapeA*sinTheta) temp = float64(shapeC * sinTheta) *(*float64)(unsafe.Pointer(poly + 2*8)) = *(*float64)(unsafe.Pointer(poly)) - float64(shapeB*cosTheta) + temp *(*float64)(unsafe.Pointer(poly + 8*8)) = *(*float64)(unsafe.Pointer(poly + 2*8)) - float64(libc.Float64FromInt32(2)*temp) temp = float64(shapeC * cosTheta) *(*float64)(unsafe.Pointer(poly + 3*8)) = *(*float64)(unsafe.Pointer(poly + 1*8)) - float64(shapeB*sinTheta) - temp *(*float64)(unsafe.Pointer(poly + 9*8)) = *(*float64)(unsafe.Pointer(poly + 3*8)) + float64(libc.Float64FromInt32(2)*temp) *(*float64)(unsafe.Pointer(poly + 4*8)) = float64(*(*float64)(unsafe.Pointer(poly + 2*8))*fracHeight) + float64(vertX*(float64(1)-fracHeight)) *(*float64)(unsafe.Pointer(poly + 5*8)) = float64(*(*float64)(unsafe.Pointer(poly + 3*8))*fracHeight) + float64(vertY*(float64(1)-fracHeight)) *(*float64)(unsafe.Pointer(poly + 6*8)) = float64(*(*float64)(unsafe.Pointer(poly + 8*8))*fracHeight) + float64(vertX*(float64(1)-fracHeight)) *(*float64)(unsafe.Pointer(poly + 7*8)) = float64(*(*float64)(unsafe.Pointer(poly + 9*8))*fracHeight) + float64(vertY*(float64(1)-fracHeight)) *(*float64)(unsafe.Pointer(coordPtr + 2*8)) = *(*float64)(unsafe.Pointer(poly)) - float64(backup*cosTheta) *(*float64)(unsafe.Pointer(coordPtr + 3*8)) = *(*float64)(unsafe.Pointer(poly + 1*8)) - float64(backup*sinTheta) } return TCL_OK } /* *-------------------------------------------------------------- * * LineToPostscript -- * * This function is called to generate Postscript for line items. * * Results: * The return value is a standard Tcl result. If an error occurs in * generating Postscript then an error message is left in the interp's * result, replacing whatever used to be there. If no error occurs, then * Postscript for the item is appended to the result. * * Side effects: * None. * *-------------------------------------------------------------- */ func _LineToPostscript(tls *libc.TLS, interp uintptr, canvas TTk_Canvas, itemPtr uintptr, dummy2431 int32) (r int32) { bp := tls.Alloc(3248) defer tls.Free(3248) /* 1 means this is a prepass to collect font * information; 0 means final Postscript is * being created. */ var _objPtr, color, linePtr, pointPtr, psObj, v2 uintptr var interpState TTcl_InterpState var numPoints, style int32 var state TTk_State var stipple TPixmap var width float64 var v1 TTcl_Size var _ /* staticPoints at bp+0 */ [400]float64 _, _, _, _, _, _, _, _, _, _, _, _, _ = _objPtr, color, interpState, linePtr, numPoints, pointPtr, psObj, state, stipple, style, width, v1, v2 linePtr = itemPtr state = (*TTk_Item)(unsafe.Pointer(itemPtr)).Fstate if state == int32(TK_STATE_NULL) { state = (*TTkCanvas)(unsafe.Pointer(canvas)).Fcanvas_state } width = (*TLineItem)(unsafe.Pointer(linePtr)).Foutline.Fwidth color = (*TLineItem)(unsafe.Pointer(linePtr)).Foutline.Fcolor stipple = (*TLineItem)(unsafe.Pointer(linePtr)).Foutline.Fstipple if (*TTkCanvas)(unsafe.Pointer(canvas)).FcurrentItemPtr == itemPtr { if (*TLineItem)(unsafe.Pointer(linePtr)).Foutline.FactiveWidth > width { width = (*TLineItem)(unsafe.Pointer(linePtr)).Foutline.FactiveWidth } if (*TLineItem)(unsafe.Pointer(linePtr)).Foutline.FactiveColor != libc.UintptrFromInt32(0) { color = (*TLineItem)(unsafe.Pointer(linePtr)).Foutline.FactiveColor } if (*TLineItem)(unsafe.Pointer(linePtr)).Foutline.FactiveStipple != uint64(0) { stipple = (*TLineItem)(unsafe.Pointer(linePtr)).Foutline.FactiveStipple } } else { if state == int32(TK_STATE_DISABLED) { if (*TLineItem)(unsafe.Pointer(linePtr)).Foutline.FdisabledWidth > libc.Float64FromInt32(0) { width = (*TLineItem)(unsafe.Pointer(linePtr)).Foutline.FdisabledWidth } if (*TLineItem)(unsafe.Pointer(linePtr)).Foutline.FdisabledColor != libc.UintptrFromInt32(0) { color = (*TLineItem)(unsafe.Pointer(linePtr)).Foutline.FdisabledColor } if (*TLineItem)(unsafe.Pointer(linePtr)).Foutline.FdisabledStipple != uint64(0) { stipple = (*TLineItem)(unsafe.Pointer(linePtr)).Foutline.FdisabledStipple } } } if color == libc.UintptrFromInt32(0) || (*TLineItem)(unsafe.Pointer(linePtr)).FnumPoints < int64(1) || (*TLineItem)(unsafe.Pointer(linePtr)).FcoordPtr == libc.UintptrFromInt32(0) { return TCL_OK } /* * Make our working space. */ psObj = libtcl9_0.XTcl_NewObj(tls) interpState = libtcl9_0.XTcl_SaveInterpState(tls, interp, TCL_OK) /* * Check if we're just doing a "pixel". */ if (*TLineItem)(unsafe.Pointer(linePtr)).FnumPoints == int64(1) { libtcl9_0.XTcl_AppendToObj(tls, psObj, __ccgo_ts+30063, int64(-libc.Int32FromInt32(1))) libtcl9_0.XTcl_AppendPrintfToObj(tls, psObj, __ccgo_ts+30085, libc.VaList(bp+3208, *(*float64)(unsafe.Pointer((*TLineItem)(unsafe.Pointer(linePtr)).FcoordPtr)), XTk_CanvasPsY(tls, canvas, *(*float64)(unsafe.Pointer((*TLineItem)(unsafe.Pointer(linePtr)).FcoordPtr + 1*8))), width/float64(2), width/float64(2))) libtcl9_0.XTcl_AppendToObj(tls, psObj, __ccgo_ts+30119, int64(-libc.Int32FromInt32(1))) libtcl9_0.XTcl_ResetResult(tls, interp) XTk_CanvasPsColor(tls, interp, canvas, color) libtcl9_0.XTcl_AppendObjToObj(tls, psObj, libtcl9_0.XTcl_GetObjResult(tls, interp)) if stipple != uint64(0) { libtcl9_0.XTcl_AppendToObj(tls, psObj, __ccgo_ts+29143, int64(-libc.Int32FromInt32(1))) libtcl9_0.XTcl_ResetResult(tls, interp) XTk_CanvasPsStipple(tls, interp, canvas, stipple) libtcl9_0.XTcl_AppendObjToObj(tls, psObj, libtcl9_0.XTcl_GetObjResult(tls, interp)) } else { libtcl9_0.XTcl_AppendToObj(tls, psObj, __ccgo_ts+29165, int64(-libc.Int32FromInt32(1))) } goto done } /* * Generate a path for the line's center-line (do this differently for * straight lines and smoothed lines). */ libtcl9_0.XTcl_ResetResult(tls, interp) if !((*TLineItem)(unsafe.Pointer(linePtr)).Fsmooth != 0) || (*TLineItem)(unsafe.Pointer(linePtr)).FnumPoints < int64(3) { XTk_CanvasPsPath(tls, interp, canvas, (*TLineItem)(unsafe.Pointer(linePtr)).FcoordPtr, (*TLineItem)(unsafe.Pointer(linePtr)).FnumPoints) } else { if stipple == uint64(0) && (*TTk_SmoothMethod)(unsafe.Pointer((*TLineItem)(unsafe.Pointer(linePtr)).Fsmooth)).FpostscriptProc != 0 { (*(*func(*libc.TLS, uintptr, TTk_Canvas, uintptr, int32, int32))(unsafe.Pointer(&struct{ uintptr }{(*TTk_SmoothMethod)(unsafe.Pointer((*TLineItem)(unsafe.Pointer(linePtr)).Fsmooth)).FpostscriptProc})))(tls, interp, canvas, (*TLineItem)(unsafe.Pointer(linePtr)).FcoordPtr, int32((*TLineItem)(unsafe.Pointer(linePtr)).FnumPoints), (*TLineItem)(unsafe.Pointer(linePtr)).FsplineSteps) } else { numPoints = (*(*func(*libc.TLS, TTk_Canvas, uintptr, int32, int32, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*TTk_SmoothMethod)(unsafe.Pointer((*TLineItem)(unsafe.Pointer(linePtr)).Fsmooth)).FcoordProc})))(tls, canvas, libc.UintptrFromInt32(0), int32((*TLineItem)(unsafe.Pointer(linePtr)).FnumPoints), (*TLineItem)(unsafe.Pointer(linePtr)).FsplineSteps, libc.UintptrFromInt32(0), libc.UintptrFromInt32(0)) pointPtr = bp if numPoints > int32(MAX_STATIC_POINTS) { pointPtr = libtcl9_0.XTcl_Alloc(tls, libc.Uint64FromInt32(numPoints*int32(2))*uint64(8)) } numPoints = (*(*func(*libc.TLS, TTk_Canvas, uintptr, int32, int32, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*TTk_SmoothMethod)(unsafe.Pointer((*TLineItem)(unsafe.Pointer(linePtr)).Fsmooth)).FcoordProc})))(tls, canvas, (*TLineItem)(unsafe.Pointer(linePtr)).FcoordPtr, int32((*TLineItem)(unsafe.Pointer(linePtr)).FnumPoints), (*TLineItem)(unsafe.Pointer(linePtr)).FsplineSteps, libc.UintptrFromInt32(0), pointPtr) XTk_CanvasPsPath(tls, interp, canvas, pointPtr, int64(numPoints)) if pointPtr != bp { libtcl9_0.XTcl_Free(tls, pointPtr) } } } libtcl9_0.XTcl_AppendObjToObj(tls, psObj, libtcl9_0.XTcl_GetObjResult(tls, interp)) /* * Set other line-drawing parameters and stroke out the line. */ if (*TLineItem)(unsafe.Pointer(linePtr)).FcapStyle == int32(CapRound) { style = int32(1) } else { if (*TLineItem)(unsafe.Pointer(linePtr)).FcapStyle == int32(CapProjecting) { style = int32(2) } else { style = 0 } } libtcl9_0.XTcl_AppendPrintfToObj(tls, psObj, __ccgo_ts+30164, libc.VaList(bp+3208, style)) if (*TLineItem)(unsafe.Pointer(linePtr)).FjoinStyle == int32(JoinRound) { style = int32(1) } else { if (*TLineItem)(unsafe.Pointer(linePtr)).FjoinStyle == int32(JoinBevel) { style = int32(2) } else { style = 0 } } libtcl9_0.XTcl_AppendPrintfToObj(tls, psObj, __ccgo_ts+30179, libc.VaList(bp+3208, style)) libtcl9_0.XTcl_ResetResult(tls, interp) XTk_CanvasPsOutline(tls, canvas, itemPtr, linePtr+120) libtcl9_0.XTcl_AppendObjToObj(tls, psObj, libtcl9_0.XTcl_GetObjResult(tls, interp)) /* * Output polygons for the arrowheads, if there are any. */ if (*TLineItem)(unsafe.Pointer(linePtr)).FfirstArrowPtr != libc.UintptrFromInt32(0) { if stipple != uint64(0) { libtcl9_0.XTcl_AppendToObj(tls, psObj, __ccgo_ts+29149, int64(-libc.Int32FromInt32(1))) } _ArrowheadPostscript(tls, interp, canvas, linePtr, (*TLineItem)(unsafe.Pointer(linePtr)).FfirstArrowPtr, psObj) } if (*TLineItem)(unsafe.Pointer(linePtr)).FlastArrowPtr != libc.UintptrFromInt32(0) { if stipple != uint64(0) { libtcl9_0.XTcl_AppendToObj(tls, psObj, __ccgo_ts+29149, int64(-libc.Int32FromInt32(1))) } _ArrowheadPostscript(tls, interp, canvas, linePtr, (*TLineItem)(unsafe.Pointer(linePtr)).FlastArrowPtr, psObj) } /* * Plug the accumulated postscript back into the result. */ goto done done: ; libtcl9_0.XTcl_RestoreInterpState(tls, interp, interpState) libtcl9_0.XTcl_AppendObjToObj(tls, libtcl9_0.XTcl_GetObjResult(tls, interp), psObj) _objPtr = psObj v2 = _objPtr v1 = *(*TTcl_Size)(unsafe.Pointer(v2)) *(*TTcl_Size)(unsafe.Pointer(v2))-- if v1 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr) } return TCL_OK } /* *-------------------------------------------------------------- * * ArrowheadPostscript -- * * This function is called to generate Postscript for an arrowhead for a * line item. * * Results: * The return value is a standard Tcl result. If an error occurs in * generating Postscript then an error message is left in the interp's * result, replacing whatever used to be there. If no error occurs, then * Postscript for the arrowhead is appended to the given object. * * Side effects: * None. * *-------------------------------------------------------------- */ func _ArrowheadPostscript(tls *libc.TLS, interp uintptr, canvas TTk_Canvas, linePtr uintptr, arrowPtr uintptr, psObj uintptr) (r int32) { /* Append postscript to this object. */ var state TTk_State var stipple TPixmap _, _ = state, stipple state = (*TLineItem)(unsafe.Pointer(linePtr)).Fheader.Fstate if state == int32(TK_STATE_NULL) { state = (*TTkCanvas)(unsafe.Pointer(canvas)).Fcanvas_state } stipple = (*TLineItem)(unsafe.Pointer(linePtr)).Foutline.Fstipple if (*TTkCanvas)(unsafe.Pointer(canvas)).FcurrentItemPtr == linePtr { if (*TLineItem)(unsafe.Pointer(linePtr)).Foutline.FactiveStipple != uint64(0) { stipple = (*TLineItem)(unsafe.Pointer(linePtr)).Foutline.FactiveStipple } } else { if state == int32(TK_STATE_DISABLED) { if (*TLineItem)(unsafe.Pointer(linePtr)).Foutline.FactiveStipple != uint64(0) { stipple = (*TLineItem)(unsafe.Pointer(linePtr)).Foutline.FdisabledStipple } } } libtcl9_0.XTcl_ResetResult(tls, interp) XTk_CanvasPsPath(tls, interp, canvas, arrowPtr, int64(PTS_IN_ARROW)) libtcl9_0.XTcl_AppendObjToObj(tls, psObj, libtcl9_0.XTcl_GetObjResult(tls, interp)) if stipple != uint64(0) { libtcl9_0.XTcl_AppendToObj(tls, psObj, __ccgo_ts+29143, int64(-libc.Int32FromInt32(1))) libtcl9_0.XTcl_ResetResult(tls, interp) XTk_CanvasPsStipple(tls, interp, canvas, stipple) libtcl9_0.XTcl_AppendObjToObj(tls, psObj, libtcl9_0.XTcl_GetObjResult(tls, interp)) } else { libtcl9_0.XTcl_AppendToObj(tls, psObj, __ccgo_ts+29165, int64(-libc.Int32FromInt32(1))) } return TCL_OK } /* * Convenience macro. */ /* * default.h -- * * This file defines the defaults for all options for all of * the Tk widgets. * * Copyright © 1991-1994 The Regents of the University of California. * Copyright © 1994 Sun Microsystems, Inc. * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. */ /* * tkUnixDefault.h -- * * This file defines the defaults for all options for all of * the Tk widgets. * * Copyright © 1991-1994 The Regents of the University of California. * Copyright © 1994-1997 Sun Microsystems, Inc. * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. */ /* * The definitions below provide symbolic names for the default colors. * NORMAL_BG - Normal background color. * ACTIVE_BG - Background color when widget is active. * SELECT_BG - Background color for selected text. * TROUGH - Background color for troughs in scales and scrollbars. * INDICATOR - Color for indicator when button is selected. * DISABLED - Foreground color when widget is disabled. * PLACEHOLDER_FG - Foreground color for placeholder text. */ /* * Defaults for labels, buttons, checkbuttons, and radiobuttons: */ /* * Defaults for canvases: */ /* * Defaults for entries: */ /* * Defaults for frames: */ /* * Defaults for labelframes: */ /* * Defaults for listboxes: */ /* * Defaults for individual entries of menus: */ /* * Defaults for menus overall: */ /* * Defaults for menubuttons: */ /* * Defaults for messages: */ /* * Defaults for panedwindows */ /* * Defaults for panedwindow panes */ /* * Defaults for scales: */ /* * Defaults for scrollbars: */ /* * Defaults for texts: */ /* * Defaults for canvas text: */ /* * Defaults for canvas items * (arcs, bitmaps, lines, polygons, rectangles, and ovals): */ /* * Defaults for toplevels (most of the defaults for frames also apply * to toplevels): */ /* * Defaults for busy windows: */ /* * The structure below defines the record for each polygon item. */ type TPolygonItem = struct { Fheader TTk_Item Foutline TTk_Outline FnumPoints int32 FpointsAllocated int32 FcoordPtr uintptr FjoinStyle int32 Ftsoffset TTk_TSOffset FfillColor uintptr FactiveFillColor uintptr FdisabledFillColor uintptr FfillStipple TPixmap FactiveFillStipple TPixmap FdisabledFillStipple TPixmap FfillGC TGC Fsmooth uintptr FsplineSteps int32 FautoClosed int32 } /* * Information used for parsing configuration specs: */ var _smoothOption1 = TTk_CustomOption{} func init() { p := unsafe.Pointer(&_smoothOption1) *(*uintptr)(unsafe.Add(p, 0)) = __ccgo_fp(XTkSmoothParseProc) *(*uintptr)(unsafe.Add(p, 8)) = __ccgo_fp(XTkSmoothPrintProc) } var _stateOption5 = TTk_CustomOption{ FclientData: uintptr(int64(libc.Int32FromInt32(2))), } func init() { p := unsafe.Pointer(&_stateOption5) *(*uintptr)(unsafe.Add(p, 0)) = __ccgo_fp(XTkStateParseProc) *(*uintptr)(unsafe.Add(p, 8)) = __ccgo_fp(XTkStatePrintProc) } var _tagsOption4 = TTk_CustomOption{} func init() { p := unsafe.Pointer(&_tagsOption4) *(*uintptr)(unsafe.Add(p, 0)) = __ccgo_fp(XTk_CanvasTagsParseProc) *(*uintptr)(unsafe.Add(p, 8)) = __ccgo_fp(XTk_CanvasTagsPrintProc) } var _dashOption2 = TTk_CustomOption{} func init() { p := unsafe.Pointer(&_dashOption2) *(*uintptr)(unsafe.Add(p, 0)) = __ccgo_fp(XTkCanvasDashParseProc) *(*uintptr)(unsafe.Add(p, 8)) = __ccgo_fp(XTkCanvasDashPrintProc) } var _offsetOption3 = TTk_CustomOption{ FclientData: uintptr(int64(libc.Int32FromInt32(TK_OFFSET_RELATIVE) | libc.Int32FromInt32(TK_OFFSET_INDEX))), } func init() { p := unsafe.Pointer(&_offsetOption3) *(*uintptr)(unsafe.Add(p, 0)) = __ccgo_fp(XTkOffsetParseProc) *(*uintptr)(unsafe.Add(p, 8)) = __ccgo_fp(XTkOffsetPrintProc) } var _pixelOption2 = TTk_CustomOption{} func init() { p := unsafe.Pointer(&_pixelOption2) *(*uintptr)(unsafe.Add(p, 0)) = __ccgo_fp(XTkPixelParseProc) *(*uintptr)(unsafe.Add(p, 8)) = __ccgo_fp(XTkPixelPrintProc) } var _configSpecs6 = [27]TTk_ConfigSpec{ 0: { Ftype1: int32(TK_CONFIG_CUSTOM), FargvName: __ccgo_ts + 28613, Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 120 + 56)), FspecFlags: int32(TCL_NULL_OK), FcustomPtr: uintptr(unsafe.Pointer(&_dashOption2)), }, 1: { Ftype1: int32(TK_CONFIG_COLOR), FargvName: __ccgo_ts + 28625, Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 336)), FspecFlags: int32(TCL_NULL_OK), }, 2: { Ftype1: int32(TK_CONFIG_COLOR), FargvName: __ccgo_ts + 28637, Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 120 + 136)), FspecFlags: int32(TCL_NULL_OK), }, 3: { Ftype1: int32(TK_CONFIG_BITMAP), FargvName: __ccgo_ts + 28652, Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 120 + 160)), FspecFlags: int32(TCL_NULL_OK), }, 4: { Ftype1: int32(TK_CONFIG_BITMAP), FargvName: __ccgo_ts + 28674, Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 360)), FspecFlags: int32(TCL_NULL_OK), }, 5: { Ftype1: int32(TK_CONFIG_CUSTOM), FargvName: __ccgo_ts + 28689, FdefValue: __ccgo_ts + 14146, Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 120 + 16)), FspecFlags: libc.Int32FromInt32(1) << libc.Int32FromInt32(3), FcustomPtr: uintptr(unsafe.Pointer(&_pixelOption2)), }, 6: { Ftype1: int32(TK_CONFIG_CUSTOM), FargvName: __ccgo_ts + 28702, Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 120 + 40)), FspecFlags: int32(TCL_NULL_OK), FcustomPtr: uintptr(unsafe.Pointer(&_dashOption2)), }, 7: { Ftype1: int32(TK_CONFIG_PIXELS), FargvName: __ccgo_ts + 28708, FdefValue: __ccgo_ts + 10533, Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 120 + 88)), FspecFlags: int32(TK_CONFIG_OBJS), }, 8: { Ftype1: int32(TK_CONFIG_CUSTOM), FargvName: __ccgo_ts + 28720, Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 120 + 72)), FspecFlags: int32(TCL_NULL_OK), FcustomPtr: uintptr(unsafe.Pointer(&_dashOption2)), }, 9: { Ftype1: int32(TK_CONFIG_COLOR), FargvName: __ccgo_ts + 28734, Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 344)), FspecFlags: int32(TCL_NULL_OK), }, 10: { Ftype1: int32(TK_CONFIG_COLOR), FargvName: __ccgo_ts + 28748, Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 120 + 144)), FspecFlags: int32(TCL_NULL_OK), }, 11: { Ftype1: int32(TK_CONFIG_BITMAP), FargvName: __ccgo_ts + 28765, Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 120 + 168)), FspecFlags: int32(TCL_NULL_OK), }, 12: { Ftype1: int32(TK_CONFIG_BITMAP), FargvName: __ccgo_ts + 28789, Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 368)), FspecFlags: int32(TCL_NULL_OK), }, 13: { Ftype1: int32(TK_CONFIG_CUSTOM), FargvName: __ccgo_ts + 28806, FdefValue: __ccgo_ts + 14146, Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 120 + 24)), FspecFlags: libc.Int32FromInt32(1) << libc.Int32FromInt32(3), FcustomPtr: uintptr(unsafe.Pointer(&_pixelOption2)), }, 14: { Ftype1: int32(TK_CONFIG_COLOR), FargvName: __ccgo_ts + 15184, Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 328)), FspecFlags: int32(TCL_NULL_OK), }, 15: { Ftype1: int32(TK_CONFIG_JOIN_STYLE), FargvName: __ccgo_ts + 29714, FdefValue: __ccgo_ts + 11083, Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 312)), FspecFlags: libc.Int32FromInt32(1) << libc.Int32FromInt32(3), }, 16: { Ftype1: int32(TK_CONFIG_CUSTOM), FargvName: __ccgo_ts + 26544, FdefValue: __ccgo_ts + 26566, Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 316)), FspecFlags: int32(TCL_NULL_OK), FcustomPtr: uintptr(unsafe.Pointer(&_offsetOption3)), }, 17: { Ftype1: int32(TK_CONFIG_COLOR), FargvName: __ccgo_ts + 28832, FdefValue: __ccgo_ts + 19829, Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 120 + 128)), FspecFlags: int32(TCL_NULL_OK), }, 18: { Ftype1: int32(TK_CONFIG_CUSTOM), FargvName: __ccgo_ts + 28841, FdefValue: __ccgo_ts + 26566, Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 120 + 112)), FspecFlags: int32(TCL_NULL_OK), FcustomPtr: uintptr(unsafe.Pointer(&_offsetOption3)), }, 19: { Ftype1: int32(TK_CONFIG_BITMAP), FargvName: __ccgo_ts + 28856, Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 120 + 152)), FspecFlags: int32(TCL_NULL_OK), }, 20: { Ftype1: int32(TK_CONFIG_CUSTOM), FargvName: __ccgo_ts + 29725, FdefValue: __ccgo_ts + 10533, Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 384)), FspecFlags: libc.Int32FromInt32(1) << libc.Int32FromInt32(3), FcustomPtr: uintptr(unsafe.Pointer(&_smoothOption1)), }, 21: { Ftype1: int32(TK_CONFIG_INT), FargvName: __ccgo_ts + 29733, FdefValue: __ccgo_ts + 29746, Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 392)), FspecFlags: libc.Int32FromInt32(1) << libc.Int32FromInt32(3), }, 22: { Ftype1: int32(TK_CONFIG_CUSTOM), FargvName: __ccgo_ts + 2957, Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 96)), FspecFlags: int32(TCL_NULL_OK), FcustomPtr: uintptr(unsafe.Pointer(&_stateOption5)), }, 23: { Ftype1: int32(TK_CONFIG_BITMAP), FargvName: __ccgo_ts + 28879, Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 352)), FspecFlags: int32(TCL_NULL_OK), }, 24: { Ftype1: int32(TK_CONFIG_CUSTOM), FargvName: __ccgo_ts + 28895, FspecFlags: int32(TCL_NULL_OK), FcustomPtr: uintptr(unsafe.Pointer(&_tagsOption4)), }, 25: { Ftype1: int32(TK_CONFIG_CUSTOM), FargvName: __ccgo_ts + 2987, FdefValue: __ccgo_ts + 22084, Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 120 + 8)), FspecFlags: libc.Int32FromInt32(1) << libc.Int32FromInt32(3), FcustomPtr: uintptr(unsafe.Pointer(&_pixelOption2)), }, 26: { Ftype1: int32(TK_CONFIG_END), }, } func init() { p := unsafe.Pointer(&XtkPolygonType) *(*uintptr)(unsafe.Add(p, 16)) = __ccgo_fp(_CreatePolygon) *(*uintptr)(unsafe.Add(p, 32)) = __ccgo_fp(_ConfigurePolygon) *(*uintptr)(unsafe.Add(p, 40)) = __ccgo_fp(_PolygonCoords) *(*uintptr)(unsafe.Add(p, 48)) = __ccgo_fp(_DeletePolygon) *(*uintptr)(unsafe.Add(p, 56)) = __ccgo_fp(_DisplayPolygon) *(*uintptr)(unsafe.Add(p, 72)) = __ccgo_fp(_PolygonToPoint) *(*uintptr)(unsafe.Add(p, 80)) = __ccgo_fp(_PolygonToArea) *(*uintptr)(unsafe.Add(p, 88)) = __ccgo_fp(_PolygonToPostscript) *(*uintptr)(unsafe.Add(p, 96)) = __ccgo_fp(_ScalePolygon) *(*uintptr)(unsafe.Add(p, 104)) = __ccgo_fp(_TranslatePolygon) *(*uintptr)(unsafe.Add(p, 112)) = __ccgo_fp(_GetPolygonIndex) *(*uintptr)(unsafe.Add(p, 136)) = __ccgo_fp(_PolygonInsert) *(*uintptr)(unsafe.Add(p, 144)) = __ccgo_fp(_PolygonDeleteCoords) *(*uintptr)(unsafe.Add(p, 160)) = __ccgo_fp(_RotatePolygon) } /* * The definition below determines how large are static arrays used to hold * spline points (splines larger than this have to have their arrays * malloc-ed). */ /* *-------------------------------------------------------------- * * CreatePolygon -- * * This function is invoked to create a new polygon item in a canvas. * * Results: * A standard Tcl return value. If an error occurred in creating the * item, then an error message is left in the interp's result; in this * case itemPtr is left uninitialized, so it can be safely freed by the * caller. * * Side effects: * A new polygon item is created. * *-------------------------------------------------------------- */ func _CreatePolygon(tls *libc.TLS, interp uintptr, canvas TTk_Canvas, itemPtr uintptr, objc TTcl_Size, objv uintptr) (r int32) { /* Arguments describing polygon. */ var arg, polyPtr uintptr var i TTcl_Size _, _, _ = arg, i, polyPtr polyPtr = itemPtr if objc == 0 { libtcl9_0.XTcl_Panic(tls, __ccgo_ts+28901, 0) } /* * Carry out initialization that is needed in order to clean up after * errors during the the remainder of this function. */ XTk_CreateOutline(tls, polyPtr+120) (*TPolygonItem)(unsafe.Pointer(polyPtr)).FnumPoints = 0 (*TPolygonItem)(unsafe.Pointer(polyPtr)).FpointsAllocated = 0 (*TPolygonItem)(unsafe.Pointer(polyPtr)).FcoordPtr = libc.UintptrFromInt32(0) (*TPolygonItem)(unsafe.Pointer(polyPtr)).FjoinStyle = int32(JoinRound) (*TPolygonItem)(unsafe.Pointer(polyPtr)).Ftsoffset.Fflags = 0 (*TPolygonItem)(unsafe.Pointer(polyPtr)).Ftsoffset.Fxoffset = 0 (*TPolygonItem)(unsafe.Pointer(polyPtr)).Ftsoffset.Fyoffset = 0 (*TPolygonItem)(unsafe.Pointer(polyPtr)).FfillColor = libc.UintptrFromInt32(0) (*TPolygonItem)(unsafe.Pointer(polyPtr)).FactiveFillColor = libc.UintptrFromInt32(0) (*TPolygonItem)(unsafe.Pointer(polyPtr)).FdisabledFillColor = libc.UintptrFromInt32(0) (*TPolygonItem)(unsafe.Pointer(polyPtr)).FfillStipple = uint64(0) (*TPolygonItem)(unsafe.Pointer(polyPtr)).FactiveFillStipple = uint64(0) (*TPolygonItem)(unsafe.Pointer(polyPtr)).FdisabledFillStipple = uint64(0) (*TPolygonItem)(unsafe.Pointer(polyPtr)).FfillGC = libc.UintptrFromInt32(0) (*TPolygonItem)(unsafe.Pointer(polyPtr)).Fsmooth = libc.UintptrFromInt32(0) (*TPolygonItem)(unsafe.Pointer(polyPtr)).FsplineSteps = int32(12) (*TPolygonItem)(unsafe.Pointer(polyPtr)).FautoClosed = 0 /* * Count the number of points and then parse them into a point array. * Leading arguments are assumed to be points if they start with a digit * or a minus sign followed by a digit. */ i = 0 for { if !(i < objc) { break } arg = libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(i)*8)), libc.UintptrFromInt32(0)) if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(arg))) == int32('-') && libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(arg + 1))) >= int32('a') && libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(arg + 1))) <= int32('z') { break } goto _1 _1: ; i++ } if i != 0 && _PolygonCoords(tls, interp, canvas, itemPtr, i, objv) != TCL_OK { goto error } if _ConfigurePolygon(tls, interp, canvas, itemPtr, objc-i, objv+uintptr(i)*8, 0) == TCL_OK { return TCL_OK } goto error error: ; _DeletePolygon(tls, canvas, itemPtr, (*TTk_FakeWin)(unsafe.Pointer(XTk_CanvasTkwin(tls, canvas))).Fdisplay) return int32(TCL_ERROR) } /* *-------------------------------------------------------------- * * PolygonCoords -- * * This function is invoked to process the "coords" widget command on * polygons. See the user documentation for details on what it does. * * Results: * Returns TCL_OK or TCL_ERROR, and sets the interp's result. * * Side effects: * The coordinates for the given item may be changed. * *-------------------------------------------------------------- */ func _PolygonCoords(tls *libc.TLS, interp uintptr, canvas TTk_Canvas, itemPtr uintptr, _objc TTcl_Size, _objv uintptr) (r int32) { bp := tls.Alloc(64) defer tls.Free(64) *(*TTcl_Size)(unsafe.Pointer(bp)) = _objc *(*uintptr)(unsafe.Pointer(bp + 8)) = _objv /* Array of coordinates: x1, y1, x2, y2, ... */ var i, numPoints int32 var obj, polyPtr, subobj uintptr _, _, _, _, _ = i, numPoints, obj, polyPtr, subobj polyPtr = itemPtr if *(*TTcl_Size)(unsafe.Pointer(bp)) == 0 { obj = libtcl9_0.XTcl_NewObj(tls) i = 0 for { if !(i < int32(2)*((*TPolygonItem)(unsafe.Pointer(polyPtr)).FnumPoints-(*TPolygonItem)(unsafe.Pointer(polyPtr)).FautoClosed)) { break } subobj = libtcl9_0.XTcl_NewDoubleObj(tls, *(*float64)(unsafe.Pointer((*TPolygonItem)(unsafe.Pointer(polyPtr)).FcoordPtr + uintptr(i)*8))) libtcl9_0.XTcl_ListObjAppendElement(tls, interp, obj, subobj) goto _1 _1: ; i++ } libtcl9_0.XTcl_SetObjResult(tls, interp, obj) return TCL_OK } if *(*TTcl_Size)(unsafe.Pointer(bp)) == int64(1) { if libtcl9_0.XTcl_ListObjGetElements(tls, interp, *(*uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 8)))), bp, bp+8) != TCL_OK { return int32(TCL_ERROR) } } if *(*TTcl_Size)(unsafe.Pointer(bp))&int64(1) != 0 { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+29749, libc.VaList(bp+24, *(*TTcl_Size)(unsafe.Pointer(bp))))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+24, __ccgo_ts+179, __ccgo_ts+27003, __ccgo_ts+28973, __ccgo_ts+30203, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) } numPoints = int32(*(*TTcl_Size)(unsafe.Pointer(bp)) / int64(2)) if (*TPolygonItem)(unsafe.Pointer(polyPtr)).FpointsAllocated <= numPoints { if (*TPolygonItem)(unsafe.Pointer(polyPtr)).FcoordPtr != libc.UintptrFromInt32(0) { libtcl9_0.XTcl_Free(tls, (*TPolygonItem)(unsafe.Pointer(polyPtr)).FcoordPtr) } /* * One extra point gets allocated here, because we always add * another point to close the polygon. */ (*TPolygonItem)(unsafe.Pointer(polyPtr)).FcoordPtr = libtcl9_0.XTcl_Alloc(tls, uint64(8)*libc.Uint64FromInt64(*(*TTcl_Size)(unsafe.Pointer(bp))+libc.Int64FromInt32(2))) (*TPolygonItem)(unsafe.Pointer(polyPtr)).FpointsAllocated = numPoints + int32(1) } i = int32(*(*TTcl_Size)(unsafe.Pointer(bp)) - int64(1)) for { if !(i >= 0) { break } if XTk_CanvasGetCoordFromObj(tls, interp, canvas, *(*uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 8)) + uintptr(i)*8)), (*TPolygonItem)(unsafe.Pointer(polyPtr)).FcoordPtr+uintptr(i)*8) != TCL_OK { return int32(TCL_ERROR) } goto _2 _2: ; i-- } (*TPolygonItem)(unsafe.Pointer(polyPtr)).FnumPoints = numPoints (*TPolygonItem)(unsafe.Pointer(polyPtr)).FautoClosed = 0 /* * Close the polygon if it isn't already closed. */ if *(*TTcl_Size)(unsafe.Pointer(bp)) > int64(2) && (*(*float64)(unsafe.Pointer((*TPolygonItem)(unsafe.Pointer(polyPtr)).FcoordPtr + uintptr(*(*TTcl_Size)(unsafe.Pointer(bp))-int64(2))*8)) != *(*float64)(unsafe.Pointer((*TPolygonItem)(unsafe.Pointer(polyPtr)).FcoordPtr)) || *(*float64)(unsafe.Pointer((*TPolygonItem)(unsafe.Pointer(polyPtr)).FcoordPtr + uintptr(*(*TTcl_Size)(unsafe.Pointer(bp))-int64(1))*8)) != *(*float64)(unsafe.Pointer((*TPolygonItem)(unsafe.Pointer(polyPtr)).FcoordPtr + 1*8))) { (*TPolygonItem)(unsafe.Pointer(polyPtr)).FautoClosed = int32(1) (*TPolygonItem)(unsafe.Pointer(polyPtr)).FnumPoints++ *(*float64)(unsafe.Pointer((*TPolygonItem)(unsafe.Pointer(polyPtr)).FcoordPtr + uintptr(*(*TTcl_Size)(unsafe.Pointer(bp)))*8)) = *(*float64)(unsafe.Pointer((*TPolygonItem)(unsafe.Pointer(polyPtr)).FcoordPtr)) *(*float64)(unsafe.Pointer((*TPolygonItem)(unsafe.Pointer(polyPtr)).FcoordPtr + uintptr(*(*TTcl_Size)(unsafe.Pointer(bp))+int64(1))*8)) = *(*float64)(unsafe.Pointer((*TPolygonItem)(unsafe.Pointer(polyPtr)).FcoordPtr + 1*8)) } _ComputePolygonBbox(tls, canvas, polyPtr) return TCL_OK } /* *-------------------------------------------------------------- * * ConfigurePolygon -- * * This function is invoked to configure various aspects of a polygon * item such as its background color. * * Results: * A standard Tcl result code. If an error occurs, then an error message * is left in the interp's result. * * Side effects: * Configuration information, such as colors and stipple patterns, may be * set for itemPtr. * *-------------------------------------------------------------- */ func _ConfigurePolygon(tls *libc.TLS, interp uintptr, canvas TTk_Canvas, itemPtr uintptr, objc TTcl_Size, objv uintptr, flags int32) (r int32) { bp := tls.Alloc(128) defer tls.Free(128) /* Flags to pass to Tk_ConfigureWidget. */ var color, polyPtr uintptr var mask uint64 var newGC TGC var state TTk_State var stipple TPixmap var tkwin TTk_Window var _ /* gcValues at bp+0 */ TXGCValues _, _, _, _, _, _, _ = color, mask, newGC, polyPtr, state, stipple, tkwin polyPtr = itemPtr tkwin = XTk_CanvasTkwin(tls, canvas) if TCL_OK != XTk_ConfigureWidget(tls, interp, tkwin, uintptr(unsafe.Pointer(&_configSpecs6)), objc, objv, polyPtr, flags) { return int32(TCL_ERROR) } /* * A few of the options require additional processing, such as graphics * contexts. */ state = (*TTk_Item)(unsafe.Pointer(itemPtr)).Fstate if (*TPolygonItem)(unsafe.Pointer(polyPtr)).Foutline.FactiveWidth > (*TPolygonItem)(unsafe.Pointer(polyPtr)).Foutline.Fwidth || (*TPolygonItem)(unsafe.Pointer(polyPtr)).Foutline.FactiveDash.Fnumber != 0 || (*TPolygonItem)(unsafe.Pointer(polyPtr)).Foutline.FactiveColor != libc.UintptrFromInt32(0) || (*TPolygonItem)(unsafe.Pointer(polyPtr)).Foutline.FactiveStipple != uint64(0) || (*TPolygonItem)(unsafe.Pointer(polyPtr)).FactiveFillColor != libc.UintptrFromInt32(0) || (*TPolygonItem)(unsafe.Pointer(polyPtr)).FactiveFillStipple != uint64(0) { *(*int32)(unsafe.Pointer(itemPtr + 112)) |= int32(TK_ITEM_STATE_DEPENDANT) } else { *(*int32)(unsafe.Pointer(itemPtr + 112)) &= ^libc.Int32FromInt32(TK_ITEM_STATE_DEPENDANT) } if state == int32(TK_STATE_NULL) { state = (*TTkCanvas)(unsafe.Pointer(canvas)).Fcanvas_state } if state == int32(TK_STATE_HIDDEN) { _ComputePolygonBbox(tls, canvas, polyPtr) return TCL_OK } mask = libc.Uint64FromInt32(XTk_ConfigOutlineGC(tls, bp, canvas, itemPtr, polyPtr+120)) if mask != 0 { (*(*TXGCValues)(unsafe.Pointer(bp))).Fcap_style = int32(CapRound) (*(*TXGCValues)(unsafe.Pointer(bp))).Fjoin_style = (*TPolygonItem)(unsafe.Pointer(polyPtr)).FjoinStyle mask |= libc.Uint64FromInt64(libc.Int64FromInt64(1)< int32(100) { (*TPolygonItem)(unsafe.Pointer(polyPtr)).FsplineSteps = int32(100) } } _ComputePolygonBbox(tls, canvas, polyPtr) return TCL_OK } /* *-------------------------------------------------------------- * * DeletePolygon -- * * This function is called to clean up the data structure associated with * a polygon item. * * Results: * None. * * Side effects: * Resources associated with itemPtr are released. * *-------------------------------------------------------------- */ func _DeletePolygon(tls *libc.TLS, dummy569 TTk_Canvas, itemPtr uintptr, display uintptr) { /* Display containing window for canvas. */ var polyPtr uintptr _ = polyPtr polyPtr = itemPtr XTk_DeleteOutline(tls, display, polyPtr+120) if (*TPolygonItem)(unsafe.Pointer(polyPtr)).FcoordPtr != libc.UintptrFromInt32(0) { libtcl9_0.XTcl_Free(tls, (*TPolygonItem)(unsafe.Pointer(polyPtr)).FcoordPtr) } if (*TPolygonItem)(unsafe.Pointer(polyPtr)).FfillColor != libc.UintptrFromInt32(0) { XTk_FreeColor(tls, (*TPolygonItem)(unsafe.Pointer(polyPtr)).FfillColor) } if (*TPolygonItem)(unsafe.Pointer(polyPtr)).FactiveFillColor != libc.UintptrFromInt32(0) { XTk_FreeColor(tls, (*TPolygonItem)(unsafe.Pointer(polyPtr)).FactiveFillColor) } if (*TPolygonItem)(unsafe.Pointer(polyPtr)).FdisabledFillColor != libc.UintptrFromInt32(0) { XTk_FreeColor(tls, (*TPolygonItem)(unsafe.Pointer(polyPtr)).FdisabledFillColor) } if (*TPolygonItem)(unsafe.Pointer(polyPtr)).FfillStipple != uint64(0) { XTk_FreeBitmap(tls, display, (*TPolygonItem)(unsafe.Pointer(polyPtr)).FfillStipple) } if (*TPolygonItem)(unsafe.Pointer(polyPtr)).FactiveFillStipple != uint64(0) { XTk_FreeBitmap(tls, display, (*TPolygonItem)(unsafe.Pointer(polyPtr)).FactiveFillStipple) } if (*TPolygonItem)(unsafe.Pointer(polyPtr)).FdisabledFillStipple != uint64(0) { XTk_FreeBitmap(tls, display, (*TPolygonItem)(unsafe.Pointer(polyPtr)).FdisabledFillStipple) } if (*TPolygonItem)(unsafe.Pointer(polyPtr)).FfillGC != libc.UintptrFromInt32(0) { XTk_FreeGC(tls, display, (*TPolygonItem)(unsafe.Pointer(polyPtr)).FfillGC) } } /* *-------------------------------------------------------------- * * ComputePolygonBbox -- * * This function is invoked to compute the bounding box of all the pixels * that may be drawn as part of a polygon. * * Results: * None. * * Side effects: * The fields x1, y1, x2, and y2 are updated in the header for itemPtr. * *-------------------------------------------------------------- */ func _ComputePolygonBbox(tls *libc.TLS, canvas TTk_Canvas, polyPtr uintptr) { bp := tls.Alloc(32) defer tls.Free(32) /* Item whose bbox is to be recomputed. */ var coordPtr, tsoffset uintptr var i, index, index1, j, v1, v2, v3, v4, v5 int32 var state TTk_State var width float64 var _ /* miter at bp+0 */ [4]float64 _, _, _, _, _, _, _, _, _, _, _, _, _ = coordPtr, i, index, index1, j, state, tsoffset, width, v1, v2, v3, v4, v5 state = (*TPolygonItem)(unsafe.Pointer(polyPtr)).Fheader.Fstate if state == int32(TK_STATE_NULL) { state = (*TTkCanvas)(unsafe.Pointer(canvas)).Fcanvas_state } width = (*TPolygonItem)(unsafe.Pointer(polyPtr)).Foutline.Fwidth if (*TPolygonItem)(unsafe.Pointer(polyPtr)).FcoordPtr == libc.UintptrFromInt32(0) || (*TPolygonItem)(unsafe.Pointer(polyPtr)).FnumPoints < int32(1) || state == int32(TK_STATE_HIDDEN) { v3 = -libc.Int32FromInt32(1) (*TPolygonItem)(unsafe.Pointer(polyPtr)).Fheader.Fy2 = v3 v2 = v3 (*TPolygonItem)(unsafe.Pointer(polyPtr)).Fheader.Fy1 = v2 v1 = v2 (*TPolygonItem)(unsafe.Pointer(polyPtr)).Fheader.Fx2 = v1 (*TPolygonItem)(unsafe.Pointer(polyPtr)).Fheader.Fx1 = v1 return } if (*TTkCanvas)(unsafe.Pointer(canvas)).FcurrentItemPtr == polyPtr { if (*TPolygonItem)(unsafe.Pointer(polyPtr)).Foutline.FactiveWidth > width { width = (*TPolygonItem)(unsafe.Pointer(polyPtr)).Foutline.FactiveWidth } } else { if state == int32(TK_STATE_DISABLED) { if (*TPolygonItem)(unsafe.Pointer(polyPtr)).Foutline.FdisabledWidth > float64(0) { width = (*TPolygonItem)(unsafe.Pointer(polyPtr)).Foutline.FdisabledWidth } } } coordPtr = (*TPolygonItem)(unsafe.Pointer(polyPtr)).FcoordPtr v4 = int32(*(*float64)(unsafe.Pointer(coordPtr))) (*TPolygonItem)(unsafe.Pointer(polyPtr)).Fheader.Fx2 = v4 (*TPolygonItem)(unsafe.Pointer(polyPtr)).Fheader.Fx1 = v4 v5 = int32(*(*float64)(unsafe.Pointer(coordPtr + 1*8))) (*TPolygonItem)(unsafe.Pointer(polyPtr)).Fheader.Fy2 = v5 (*TPolygonItem)(unsafe.Pointer(polyPtr)).Fheader.Fy1 = v5 /* * Compute the bounding box of all the points in the polygon, then expand * in all directions by the outline's width to take care of butting or * rounded corners and projecting or rounded caps. This expansion is an * overestimate (worst-case is square root of two over two) but it's * simple. Don't do anything special for curves. This causes an additional * overestimate in the bounding box, but is faster. */ i = int32(1) coordPtr = (*TPolygonItem)(unsafe.Pointer(polyPtr)).FcoordPtr + libc.UintptrFromInt32(2)*8 for { if !(i < (*TPolygonItem)(unsafe.Pointer(polyPtr)).FnumPoints-int32(1)) { break } XTkIncludePoint(tls, polyPtr, coordPtr) goto _6 _6: ; i++ coordPtr += uintptr(2) * 8 } tsoffset = polyPtr + 316 if (*TTk_TSOffset)(unsafe.Pointer(tsoffset)).Fflags&int32(TK_OFFSET_INDEX) != 0 { index = (*TTk_TSOffset)(unsafe.Pointer(tsoffset)).Fflags & ^libc.Int32FromInt32(TK_OFFSET_INDEX) if (*TTk_TSOffset)(unsafe.Pointer(tsoffset)).Fflags == int32(INT_MAX) { index = ((*TPolygonItem)(unsafe.Pointer(polyPtr)).FnumPoints - (*TPolygonItem)(unsafe.Pointer(polyPtr)).FautoClosed) * int32(2) if index < 0 { index = 0 } } index %= ((*TPolygonItem)(unsafe.Pointer(polyPtr)).FnumPoints - (*TPolygonItem)(unsafe.Pointer(polyPtr)).FautoClosed) * int32(2) if index < 0 { index += ((*TPolygonItem)(unsafe.Pointer(polyPtr)).FnumPoints - (*TPolygonItem)(unsafe.Pointer(polyPtr)).FautoClosed) * int32(2) } (*TTk_TSOffset)(unsafe.Pointer(tsoffset)).Fxoffset = int32(*(*float64)(unsafe.Pointer((*TPolygonItem)(unsafe.Pointer(polyPtr)).FcoordPtr + uintptr(index)*8)) + libc.Float64FromFloat64(0.5)) (*TTk_TSOffset)(unsafe.Pointer(tsoffset)).Fyoffset = int32(*(*float64)(unsafe.Pointer((*TPolygonItem)(unsafe.Pointer(polyPtr)).FcoordPtr + uintptr(index+int32(1))*8)) + libc.Float64FromFloat64(0.5)) } else { if (*TTk_TSOffset)(unsafe.Pointer(tsoffset)).Fflags&int32(TK_OFFSET_LEFT) != 0 { (*TTk_TSOffset)(unsafe.Pointer(tsoffset)).Fxoffset = (*TPolygonItem)(unsafe.Pointer(polyPtr)).Fheader.Fx1 } else { if (*TTk_TSOffset)(unsafe.Pointer(tsoffset)).Fflags&int32(TK_OFFSET_CENTER) != 0 { (*TTk_TSOffset)(unsafe.Pointer(tsoffset)).Fxoffset = ((*TPolygonItem)(unsafe.Pointer(polyPtr)).Fheader.Fx1 + (*TPolygonItem)(unsafe.Pointer(polyPtr)).Fheader.Fx2) / int32(2) } else { if (*TTk_TSOffset)(unsafe.Pointer(tsoffset)).Fflags&int32(TK_OFFSET_RIGHT) != 0 { (*TTk_TSOffset)(unsafe.Pointer(tsoffset)).Fxoffset = (*TPolygonItem)(unsafe.Pointer(polyPtr)).Fheader.Fx2 } } } if (*TTk_TSOffset)(unsafe.Pointer(tsoffset)).Fflags&int32(TK_OFFSET_TOP) != 0 { (*TTk_TSOffset)(unsafe.Pointer(tsoffset)).Fyoffset = (*TPolygonItem)(unsafe.Pointer(polyPtr)).Fheader.Fy1 } else { if (*TTk_TSOffset)(unsafe.Pointer(tsoffset)).Fflags&int32(TK_OFFSET_MIDDLE) != 0 { (*TTk_TSOffset)(unsafe.Pointer(tsoffset)).Fyoffset = ((*TPolygonItem)(unsafe.Pointer(polyPtr)).Fheader.Fy1 + (*TPolygonItem)(unsafe.Pointer(polyPtr)).Fheader.Fy2) / int32(2) } else { if (*TTk_TSOffset)(unsafe.Pointer(tsoffset)).Fflags&int32(TK_OFFSET_BOTTOM) != 0 { (*TTk_TSOffset)(unsafe.Pointer(tsoffset)).Fyoffset = (*TPolygonItem)(unsafe.Pointer(polyPtr)).Fheader.Fy2 } } } } if (*TPolygonItem)(unsafe.Pointer(polyPtr)).Foutline.Fgc != libc.UintptrFromInt32(0) { tsoffset = polyPtr + 120 + 112 if tsoffset != 0 { if (*TTk_TSOffset)(unsafe.Pointer(tsoffset)).Fflags&int32(TK_OFFSET_INDEX) != 0 { index1 = (*TTk_TSOffset)(unsafe.Pointer(tsoffset)).Fflags & ^libc.Int32FromInt32(TK_OFFSET_INDEX) if (*TTk_TSOffset)(unsafe.Pointer(tsoffset)).Fflags == int32(INT_MAX) { index1 = ((*TPolygonItem)(unsafe.Pointer(polyPtr)).FnumPoints - int32(1)) * int32(2) } index1 %= ((*TPolygonItem)(unsafe.Pointer(polyPtr)).FnumPoints - int32(1)) * int32(2) if index1 < 0 { index1 += ((*TPolygonItem)(unsafe.Pointer(polyPtr)).FnumPoints - int32(1)) * int32(2) } (*TTk_TSOffset)(unsafe.Pointer(tsoffset)).Fxoffset = int32(*(*float64)(unsafe.Pointer((*TPolygonItem)(unsafe.Pointer(polyPtr)).FcoordPtr + uintptr(index1)*8)) + libc.Float64FromFloat64(0.5)) (*TTk_TSOffset)(unsafe.Pointer(tsoffset)).Fyoffset = int32(*(*float64)(unsafe.Pointer((*TPolygonItem)(unsafe.Pointer(polyPtr)).FcoordPtr + uintptr(index1+int32(1))*8)) + libc.Float64FromFloat64(0.5)) } else { if (*TTk_TSOffset)(unsafe.Pointer(tsoffset)).Fflags&int32(TK_OFFSET_LEFT) != 0 { (*TTk_TSOffset)(unsafe.Pointer(tsoffset)).Fxoffset = (*TPolygonItem)(unsafe.Pointer(polyPtr)).Fheader.Fx1 } else { if (*TTk_TSOffset)(unsafe.Pointer(tsoffset)).Fflags&int32(TK_OFFSET_CENTER) != 0 { (*TTk_TSOffset)(unsafe.Pointer(tsoffset)).Fxoffset = ((*TPolygonItem)(unsafe.Pointer(polyPtr)).Fheader.Fx1 + (*TPolygonItem)(unsafe.Pointer(polyPtr)).Fheader.Fx2) / int32(2) } else { if (*TTk_TSOffset)(unsafe.Pointer(tsoffset)).Fflags&int32(TK_OFFSET_RIGHT) != 0 { (*TTk_TSOffset)(unsafe.Pointer(tsoffset)).Fxoffset = (*TPolygonItem)(unsafe.Pointer(polyPtr)).Fheader.Fx2 } } } if (*TTk_TSOffset)(unsafe.Pointer(tsoffset)).Fflags&int32(TK_OFFSET_TOP) != 0 { (*TTk_TSOffset)(unsafe.Pointer(tsoffset)).Fyoffset = (*TPolygonItem)(unsafe.Pointer(polyPtr)).Fheader.Fy1 } else { if (*TTk_TSOffset)(unsafe.Pointer(tsoffset)).Fflags&int32(TK_OFFSET_MIDDLE) != 0 { (*TTk_TSOffset)(unsafe.Pointer(tsoffset)).Fyoffset = ((*TPolygonItem)(unsafe.Pointer(polyPtr)).Fheader.Fy1 + (*TPolygonItem)(unsafe.Pointer(polyPtr)).Fheader.Fy2) / int32(2) } else { if (*TTk_TSOffset)(unsafe.Pointer(tsoffset)).Fflags&int32(TK_OFFSET_BOTTOM) != 0 { (*TTk_TSOffset)(unsafe.Pointer(tsoffset)).Fyoffset = (*TPolygonItem)(unsafe.Pointer(polyPtr)).Fheader.Fy2 } } } } } i = int32((width + libc.Float64FromFloat64(1.5)) / libc.Float64FromFloat64(2)) (*TPolygonItem)(unsafe.Pointer(polyPtr)).Fheader.Fx1 -= i (*TPolygonItem)(unsafe.Pointer(polyPtr)).Fheader.Fx2 += i (*TPolygonItem)(unsafe.Pointer(polyPtr)).Fheader.Fy1 -= i (*TPolygonItem)(unsafe.Pointer(polyPtr)).Fheader.Fy2 += i /* * For mitered lines, make a second pass through all the points. * Compute the locations of the two miter vertex points and add those * into the bounding box. */ if (*TPolygonItem)(unsafe.Pointer(polyPtr)).FjoinStyle == JoinMiter { coordPtr = (*TPolygonItem)(unsafe.Pointer(polyPtr)).FcoordPtr if (*TPolygonItem)(unsafe.Pointer(polyPtr)).FnumPoints > int32(3) { if XTkGetMiterPoints(tls, coordPtr+uintptr(int32(2)*((*TPolygonItem)(unsafe.Pointer(polyPtr)).FnumPoints-int32(2)))*8, coordPtr, coordPtr+uintptr(2)*8, width, bp, bp+uintptr(2)*8) != 0 { j = 0 for { if !(j < int32(4)) { break } XTkIncludePoint(tls, polyPtr, bp+uintptr(j)*8) goto _7 _7: ; j += int32(2) } } } i = (*TPolygonItem)(unsafe.Pointer(polyPtr)).FnumPoints for { if !(i >= int32(3)) { break } if XTkGetMiterPoints(tls, coordPtr, coordPtr+uintptr(2)*8, coordPtr+uintptr(4)*8, width, bp, bp+uintptr(2)*8) != 0 { j = 0 for { if !(j < int32(4)) { break } XTkIncludePoint(tls, polyPtr, bp+uintptr(j)*8) goto _9 _9: ; j += int32(2) } } goto _8 _8: ; i-- coordPtr += uintptr(2) * 8 } } } /* * Add one more pixel of fudge factor just to be safe (e.g. X may round * differently than we do). */ (*TPolygonItem)(unsafe.Pointer(polyPtr)).Fheader.Fx1 -= int32(1) (*TPolygonItem)(unsafe.Pointer(polyPtr)).Fheader.Fx2 += int32(1) (*TPolygonItem)(unsafe.Pointer(polyPtr)).Fheader.Fy1 -= int32(1) (*TPolygonItem)(unsafe.Pointer(polyPtr)).Fheader.Fy2 += int32(1) } /* *-------------------------------------------------------------- * * TkFillPolygon -- * * This function is invoked to convert a polygon to screen coordinates * and display it using a particular GC. * * Results: * None. * * Side effects: * ItemPtr is drawn in drawable using the transformation information in * canvas. * *-------------------------------------------------------------- */ func XTkFillPolygon(tls *libc.TLS, canvas TTk_Canvas, coordPtr uintptr, numPoints int32, display uintptr, drawable TDrawable, gc TGC, outlineGC TGC) { bp := tls.Alloc(800) defer tls.Free(800) /* If not None, use this to draw an outline * around the polygon after filling it. */ var i int32 var pPtr, pointPtr uintptr var _ /* staticPoints at bp+0 */ [200]TXPoint _, _, _ = i, pPtr, pointPtr /* * Build up an array of points in screen coordinates. Use a static array * unless the polygon has an enormous number of points; in this case, * dynamically allocate an array. */ if numPoints <= int32(MAX_STATIC_POINTS) { pointPtr = bp } else { pointPtr = libtcl9_0.XTcl_Alloc(tls, libc.Uint64FromInt32(numPoints)*uint64(4)) } i = 0 pPtr = pointPtr for { if !(i < numPoints) { break } XTk_CanvasDrawableCoords(tls, canvas, *(*float64)(unsafe.Pointer(coordPtr)), *(*float64)(unsafe.Pointer(coordPtr + 1*8)), pPtr, pPtr+2) goto _1 _1: ; i += int32(1) coordPtr += uintptr(2) * 8 pPtr += 4 } /* * Display polygon, then free up polygon storage if it was dynamically * allocated. */ if gc != libc.UintptrFromInt32(0) && numPoints > int32(3) { libx11.XXFillPolygon(tls, display, drawable, gc, pointPtr, numPoints, Complex, CoordModeOrigin) } if outlineGC != libc.UintptrFromInt32(0) { libx11.XXDrawLines(tls, display, drawable, outlineGC, pointPtr, numPoints, CoordModeOrigin) } if pointPtr != bp { libtcl9_0.XTcl_Free(tls, pointPtr) } } /* *-------------------------------------------------------------- * * DisplayPolygon -- * * This function is invoked to draw a polygon item in a given drawable. * * Results: * None. * * Side effects: * ItemPtr is drawn in drawable using the transformation information in * canvas. * *-------------------------------------------------------------- */ func _DisplayPolygon(tls *libc.TLS, canvas TTk_Canvas, itemPtr uintptr, display uintptr, drawable TDrawable, dummy879 int32, dummy880 int32, dummy881 int32, dummy882 int32) { bp := tls.Alloc(816) defer tls.Free(816) var flags, intLineWidth, numPoints int32 var linewidth float64 var pointPtr, polyPtr, tsoffset uintptr var state TTk_State var stipple TPixmap var _ /* h at bp+4 */ int32 var _ /* staticPoints at bp+12 */ [200]TXPoint var _ /* w at bp+0 */ int32 var _ /* x at bp+8 */ int16 var _ /* y at bp+10 */ int16 _, _, _, _, _, _, _, _, _ = flags, intLineWidth, linewidth, numPoints, pointPtr, polyPtr, state, stipple, tsoffset polyPtr = itemPtr state = (*TTk_Item)(unsafe.Pointer(itemPtr)).Fstate stipple = (*TPolygonItem)(unsafe.Pointer(polyPtr)).FfillStipple linewidth = (*TPolygonItem)(unsafe.Pointer(polyPtr)).Foutline.Fwidth if (*TPolygonItem)(unsafe.Pointer(polyPtr)).FfillGC == libc.UintptrFromInt32(0) && (*TPolygonItem)(unsafe.Pointer(polyPtr)).Foutline.Fgc == libc.UintptrFromInt32(0) || (*TPolygonItem)(unsafe.Pointer(polyPtr)).FnumPoints < int32(1) || (*TPolygonItem)(unsafe.Pointer(polyPtr)).FnumPoints < int32(3) && (*TPolygonItem)(unsafe.Pointer(polyPtr)).Foutline.Fgc == libc.UintptrFromInt32(0) { return } if state == int32(TK_STATE_NULL) { state = (*TTkCanvas)(unsafe.Pointer(canvas)).Fcanvas_state } if (*TTkCanvas)(unsafe.Pointer(canvas)).FcurrentItemPtr == itemPtr { if (*TPolygonItem)(unsafe.Pointer(polyPtr)).Foutline.FactiveWidth > linewidth { linewidth = (*TPolygonItem)(unsafe.Pointer(polyPtr)).Foutline.FactiveWidth } if (*TPolygonItem)(unsafe.Pointer(polyPtr)).FactiveFillStipple != uint64(0) { stipple = (*TPolygonItem)(unsafe.Pointer(polyPtr)).FactiveFillStipple } } else { if state == int32(TK_STATE_DISABLED) { if (*TPolygonItem)(unsafe.Pointer(polyPtr)).Foutline.FdisabledWidth > float64(0) { linewidth = (*TPolygonItem)(unsafe.Pointer(polyPtr)).Foutline.FdisabledWidth } if (*TPolygonItem)(unsafe.Pointer(polyPtr)).FdisabledFillStipple != uint64(0) { stipple = (*TPolygonItem)(unsafe.Pointer(polyPtr)).FdisabledFillStipple } } } /* * If we're stippling then modify the stipple offset in the GC. Be sure to * reset the offset when done, since the GC is supposed to be read-only. */ if stipple != uint64(0) && (*TPolygonItem)(unsafe.Pointer(polyPtr)).FfillGC != libc.UintptrFromInt32(0) { tsoffset = polyPtr + 316 *(*int32)(unsafe.Pointer(bp)) = 0 *(*int32)(unsafe.Pointer(bp + 4)) = 0 flags = (*TTk_TSOffset)(unsafe.Pointer(tsoffset)).Fflags if !(flags&libc.Int32FromInt32(TK_OFFSET_INDEX) != 0) && flags&(libc.Int32FromInt32(TK_OFFSET_CENTER)|libc.Int32FromInt32(TK_OFFSET_MIDDLE)) != 0 { XTk_SizeOfBitmap(tls, display, stipple, bp, bp+4) if flags&int32(TK_OFFSET_CENTER) != 0 { *(*int32)(unsafe.Pointer(bp)) /= int32(2) } else { *(*int32)(unsafe.Pointer(bp)) = 0 } if flags&int32(TK_OFFSET_MIDDLE) != 0 { *(*int32)(unsafe.Pointer(bp + 4)) /= int32(2) } else { *(*int32)(unsafe.Pointer(bp + 4)) = 0 } } *(*int32)(unsafe.Pointer(tsoffset + 4)) -= *(*int32)(unsafe.Pointer(bp)) *(*int32)(unsafe.Pointer(tsoffset + 8)) -= *(*int32)(unsafe.Pointer(bp + 4)) XTk_CanvasSetOffset(tls, canvas, (*TPolygonItem)(unsafe.Pointer(polyPtr)).FfillGC, tsoffset) *(*int32)(unsafe.Pointer(tsoffset + 4)) += *(*int32)(unsafe.Pointer(bp)) *(*int32)(unsafe.Pointer(tsoffset + 8)) += *(*int32)(unsafe.Pointer(bp + 4)) } XTk_ChangeOutlineGC(tls, canvas, itemPtr, polyPtr+120) if (*TPolygonItem)(unsafe.Pointer(polyPtr)).FnumPoints < int32(3) { intLineWidth = int32(linewidth + libc.Float64FromFloat64(0.5)) if intLineWidth < int32(1) { intLineWidth = int32(1) } XTk_CanvasDrawableCoords(tls, canvas, *(*float64)(unsafe.Pointer((*TPolygonItem)(unsafe.Pointer(polyPtr)).FcoordPtr)), *(*float64)(unsafe.Pointer((*TPolygonItem)(unsafe.Pointer(polyPtr)).FcoordPtr + 1*8)), bp+8, bp+10) libx11.XXFillArc(tls, display, drawable, (*TPolygonItem)(unsafe.Pointer(polyPtr)).Foutline.Fgc, int32(*(*int16)(unsafe.Pointer(bp + 8)))-intLineWidth/int32(2), int32(*(*int16)(unsafe.Pointer(bp + 10)))-intLineWidth/int32(2), libc.Uint32FromInt32(intLineWidth)+uint32(1), libc.Uint32FromInt32(intLineWidth)+uint32(1), 0, libc.Int32FromInt32(64)*libc.Int32FromInt32(360)) } else { if !((*TPolygonItem)(unsafe.Pointer(polyPtr)).Fsmooth != 0) || (*TPolygonItem)(unsafe.Pointer(polyPtr)).FnumPoints < int32(4) { XTkFillPolygon(tls, canvas, (*TPolygonItem)(unsafe.Pointer(polyPtr)).FcoordPtr, (*TPolygonItem)(unsafe.Pointer(polyPtr)).FnumPoints, display, drawable, (*TPolygonItem)(unsafe.Pointer(polyPtr)).FfillGC, (*TPolygonItem)(unsafe.Pointer(polyPtr)).Foutline.Fgc) } else { /* * This is a smoothed polygon. Display using a set of generated spline * points rather than the original points. */ numPoints = (*(*func(*libc.TLS, TTk_Canvas, uintptr, int32, int32, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*TTk_SmoothMethod)(unsafe.Pointer((*TPolygonItem)(unsafe.Pointer(polyPtr)).Fsmooth)).FcoordProc})))(tls, canvas, libc.UintptrFromInt32(0), (*TPolygonItem)(unsafe.Pointer(polyPtr)).FnumPoints, (*TPolygonItem)(unsafe.Pointer(polyPtr)).FsplineSteps, libc.UintptrFromInt32(0), libc.UintptrFromInt32(0)) if numPoints <= int32(MAX_STATIC_POINTS) { pointPtr = bp + 12 } else { pointPtr = libtcl9_0.XTcl_Alloc(tls, libc.Uint64FromInt32(numPoints)*uint64(4)) } numPoints = (*(*func(*libc.TLS, TTk_Canvas, uintptr, int32, int32, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*TTk_SmoothMethod)(unsafe.Pointer((*TPolygonItem)(unsafe.Pointer(polyPtr)).Fsmooth)).FcoordProc})))(tls, canvas, (*TPolygonItem)(unsafe.Pointer(polyPtr)).FcoordPtr, (*TPolygonItem)(unsafe.Pointer(polyPtr)).FnumPoints, (*TPolygonItem)(unsafe.Pointer(polyPtr)).FsplineSteps, pointPtr, libc.UintptrFromInt32(0)) if (*TPolygonItem)(unsafe.Pointer(polyPtr)).FfillGC != libc.UintptrFromInt32(0) { libx11.XXFillPolygon(tls, display, drawable, (*TPolygonItem)(unsafe.Pointer(polyPtr)).FfillGC, pointPtr, numPoints, Complex, CoordModeOrigin) } if (*TPolygonItem)(unsafe.Pointer(polyPtr)).Foutline.Fgc != libc.UintptrFromInt32(0) { libx11.XXDrawLines(tls, display, drawable, (*TPolygonItem)(unsafe.Pointer(polyPtr)).Foutline.Fgc, pointPtr, numPoints, CoordModeOrigin) } if pointPtr != bp+12 { libtcl9_0.XTcl_Free(tls, pointPtr) } } } XTk_ResetOutlineGC(tls, canvas, itemPtr, polyPtr+120) if stipple != uint64(0) && (*TPolygonItem)(unsafe.Pointer(polyPtr)).FfillGC != libc.UintptrFromInt32(0) { libx11.XXSetTSOrigin(tls, display, (*TPolygonItem)(unsafe.Pointer(polyPtr)).FfillGC, 0, 0) } } /* *-------------------------------------------------------------- * * PolygonInsert -- * * Insert coords into a polygon item at a given index. * * Results: * None. * * Side effects: * The coords in the given item is modified. * *-------------------------------------------------------------- */ func _PolygonInsert(tls *libc.TLS, canvas TTk_Canvas, itemPtr uintptr, beforeThis TTcl_Size, obj uintptr) { bp := tls.Alloc(16) defer tls.Free(16) /* New coordinates to be inserted. */ var i, j, length, nbInsPoints, oriNumPoints, v4, v5 int32 var newCoordPtr, polyPtr uintptr var state TTk_State var width float64 var _ /* objc at bp+0 */ TTcl_Size var _ /* objv at bp+8 */ uintptr _, _, _, _, _, _, _, _, _, _, _ = i, j, length, nbInsPoints, newCoordPtr, oriNumPoints, polyPtr, state, width, v4, v5 polyPtr = itemPtr state = (*TTk_Item)(unsafe.Pointer(itemPtr)).Fstate if state == int32(TK_STATE_NULL) { state = (*TTkCanvas)(unsafe.Pointer(canvas)).Fcanvas_state } if !(obj != 0) || libtcl9_0.XTcl_ListObjGetElements(tls, libc.UintptrFromInt32(0), obj, bp, bp+8) != TCL_OK || !(*(*TTcl_Size)(unsafe.Pointer(bp)) != 0) || *(*TTcl_Size)(unsafe.Pointer(bp))&int64(1) != 0 { return } oriNumPoints = (*TPolygonItem)(unsafe.Pointer(polyPtr)).FnumPoints - (*TPolygonItem)(unsafe.Pointer(polyPtr)).FautoClosed length = int32(2) * ((*TPolygonItem)(unsafe.Pointer(polyPtr)).FnumPoints - (*TPolygonItem)(unsafe.Pointer(polyPtr)).FautoClosed) nbInsPoints = int32(*(*TTcl_Size)(unsafe.Pointer(bp)) / int64(2)) for int32(beforeThis) > length { beforeThis -= int64(length) } for int32(beforeThis) < 0 { beforeThis += int64(length) } newCoordPtr = libtcl9_0.XTcl_Alloc(tls, uint64(8)*libc.Uint64FromInt64(int64(length+libc.Int32FromInt32(2))+*(*TTcl_Size)(unsafe.Pointer(bp)))) i = 0 for { if !(i < int32(beforeThis)) { break } *(*float64)(unsafe.Pointer(newCoordPtr + uintptr(i)*8)) = *(*float64)(unsafe.Pointer((*TPolygonItem)(unsafe.Pointer(polyPtr)).FcoordPtr + uintptr(i)*8)) goto _1 _1: ; i++ } i = 0 for { if !(int64(i) < *(*TTcl_Size)(unsafe.Pointer(bp))) { break } if libtcl9_0.XTcl_GetDoubleFromObj(tls, libc.UintptrFromInt32(0), *(*uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 8)) + uintptr(i)*8)), newCoordPtr+uintptr(int64(i)+beforeThis)*8) != TCL_OK { libtcl9_0.XTcl_Free(tls, newCoordPtr) return } goto _2 _2: ; i++ } i = int32(beforeThis) for { if !(i < length) { break } *(*float64)(unsafe.Pointer(newCoordPtr + uintptr(int64(i)+*(*TTcl_Size)(unsafe.Pointer(bp)))*8)) = *(*float64)(unsafe.Pointer((*TPolygonItem)(unsafe.Pointer(polyPtr)).FcoordPtr + uintptr(i)*8)) goto _3 _3: ; i++ } if (*TPolygonItem)(unsafe.Pointer(polyPtr)).FcoordPtr != 0 { libtcl9_0.XTcl_Free(tls, (*TPolygonItem)(unsafe.Pointer(polyPtr)).FcoordPtr) } length = int32(int64(length) + *(*TTcl_Size)(unsafe.Pointer(bp))) (*TPolygonItem)(unsafe.Pointer(polyPtr)).FcoordPtr = newCoordPtr (*TPolygonItem)(unsafe.Pointer(polyPtr)).FnumPoints = length/int32(2) + (*TPolygonItem)(unsafe.Pointer(polyPtr)).FautoClosed /* * Close the polygon if it isn't already closed, or remove autoclosing if * the user's coordinates are now closed. */ if (*TPolygonItem)(unsafe.Pointer(polyPtr)).FautoClosed != 0 { if *(*float64)(unsafe.Pointer(newCoordPtr + uintptr(length-int32(2))*8)) == *(*float64)(unsafe.Pointer(newCoordPtr)) && *(*float64)(unsafe.Pointer(newCoordPtr + uintptr(length-int32(1))*8)) == *(*float64)(unsafe.Pointer(newCoordPtr + 1*8)) { (*TPolygonItem)(unsafe.Pointer(polyPtr)).FautoClosed = 0 (*TPolygonItem)(unsafe.Pointer(polyPtr)).FnumPoints-- } } else { if *(*float64)(unsafe.Pointer(newCoordPtr + uintptr(length-int32(2))*8)) != *(*float64)(unsafe.Pointer(newCoordPtr)) || *(*float64)(unsafe.Pointer(newCoordPtr + uintptr(length-int32(1))*8)) != *(*float64)(unsafe.Pointer(newCoordPtr + 1*8)) { (*TPolygonItem)(unsafe.Pointer(polyPtr)).FautoClosed = int32(1) (*TPolygonItem)(unsafe.Pointer(polyPtr)).FnumPoints++ } } *(*float64)(unsafe.Pointer(newCoordPtr + uintptr(length)*8)) = *(*float64)(unsafe.Pointer(newCoordPtr)) *(*float64)(unsafe.Pointer(newCoordPtr + uintptr(length+int32(1))*8)) = *(*float64)(unsafe.Pointer(newCoordPtr + 1*8)) if int64(length)-*(*TTcl_Size)(unsafe.Pointer(bp)) > int64(3) && state != int32(TK_STATE_HIDDEN) { *(*int32)(unsafe.Pointer(itemPtr + 112)) |= int32(TK_ITEM_DONT_REDRAW) /* * The header elements that normally are used for the bounding box, * are now used to calculate the bounding box for only the part that * has to be redrawn. That doesn't matter, because afterwards the * bounding box has to be re-calculated anyway. */ v4 = int32(*(*float64)(unsafe.Pointer((*TPolygonItem)(unsafe.Pointer(polyPtr)).FcoordPtr + uintptr(beforeThis)*8))) (*TTk_Item)(unsafe.Pointer(itemPtr)).Fx2 = v4 (*TTk_Item)(unsafe.Pointer(itemPtr)).Fx1 = v4 v5 = int32(*(*float64)(unsafe.Pointer((*TPolygonItem)(unsafe.Pointer(polyPtr)).FcoordPtr + uintptr(beforeThis+int64(1))*8))) (*TTk_Item)(unsafe.Pointer(itemPtr)).Fy2 = v5 (*TTk_Item)(unsafe.Pointer(itemPtr)).Fy1 = v5 beforeThis -= int64(2) *(*TTcl_Size)(unsafe.Pointer(bp)) += int64(4) if (*TPolygonItem)(unsafe.Pointer(polyPtr)).Fsmooth != 0 { if !(libc.Xstrcmp(tls, (*TTk_SmoothMethod)(unsafe.Pointer((*TPolygonItem)(unsafe.Pointer(polyPtr)).Fsmooth)).Fname, __ccgo_ts+29858) != 0) { /* * Quadratic Bezier splines. */ beforeThis -= int64(2) *(*TTcl_Size)(unsafe.Pointer(bp)) += int64(4) } else { if !(libc.Xstrcmp(tls, (*TTk_SmoothMethod)(unsafe.Pointer((*TPolygonItem)(unsafe.Pointer(polyPtr)).Fsmooth)).Fname, __ccgo_ts+29863) != 0) { /* * Cubic Bezier splines. */ if oriNumPoints%int32(3) != 0 || nbInsPoints%int32(3) != 0 { /* * No optimization for "degenerate" polygons or when inserting * something else than a multiple of 3 points. */ *(*int32)(unsafe.Pointer(itemPtr + 112)) &= ^libc.Int32FromInt32(TK_ITEM_DONT_REDRAW) } else { beforeThis -= int64(libc.Xabs(tls, int32(beforeThis)) % int32(6)) *(*TTcl_Size)(unsafe.Pointer(bp)) += int64(4) } } else { /* * Custom smoothing method. No optimization is possible. */ *(*int32)(unsafe.Pointer(itemPtr + 112)) &= ^libc.Int32FromInt32(TK_ITEM_DONT_REDRAW) } } } if (*TTk_Item)(unsafe.Pointer(itemPtr)).Fredraw_flags&int32(TK_ITEM_DONT_REDRAW) != 0 { /* * Be careful; beforeThis could now be negative */ i = int32(beforeThis) for { if !(int64(i) < int64(int32(beforeThis))+*(*TTcl_Size)(unsafe.Pointer(bp))) { break } j = i if j < 0 { j += length } else { if j >= length { j -= length } } XTkIncludePoint(tls, itemPtr, (*TPolygonItem)(unsafe.Pointer(polyPtr)).FcoordPtr+uintptr(j)*8) goto _6 _6: ; i += int32(2) } width = (*TPolygonItem)(unsafe.Pointer(polyPtr)).Foutline.Fwidth if (*TTkCanvas)(unsafe.Pointer(canvas)).FcurrentItemPtr == itemPtr { if (*TPolygonItem)(unsafe.Pointer(polyPtr)).Foutline.FactiveWidth > width { width = (*TPolygonItem)(unsafe.Pointer(polyPtr)).Foutline.FactiveWidth } } else { if state == int32(TK_STATE_DISABLED) { if (*TPolygonItem)(unsafe.Pointer(polyPtr)).Foutline.FdisabledWidth > float64(0) { width = (*TPolygonItem)(unsafe.Pointer(polyPtr)).Foutline.FdisabledWidth } } } *(*int32)(unsafe.Pointer(itemPtr + 72)) -= int32(width) *(*int32)(unsafe.Pointer(itemPtr + 76)) -= int32(width) *(*int32)(unsafe.Pointer(itemPtr + 80)) += int32(width) *(*int32)(unsafe.Pointer(itemPtr + 84)) += int32(width) XTk_CanvasEventuallyRedraw(tls, canvas, (*TTk_Item)(unsafe.Pointer(itemPtr)).Fx1, (*TTk_Item)(unsafe.Pointer(itemPtr)).Fy1, (*TTk_Item)(unsafe.Pointer(itemPtr)).Fx2, (*TTk_Item)(unsafe.Pointer(itemPtr)).Fy2) } } _ComputePolygonBbox(tls, canvas, polyPtr) } /* *-------------------------------------------------------------- * * PolygonDeleteCoords -- * * Delete one or more coordinates from a polygon item. * * Results: * None. * * Side effects: * Characters between "first" and "last", inclusive, get deleted from * itemPtr. * *-------------------------------------------------------------- */ func _PolygonDeleteCoords(tls *libc.TLS, canvas TTk_Canvas, itemPtr uintptr, first TTcl_Size, last TTcl_Size) { /* Index of last character to delete. */ var count, i, length int32 var polyPtr uintptr _, _, _, _ = count, i, length, polyPtr polyPtr = itemPtr length = int32(2) * ((*TPolygonItem)(unsafe.Pointer(polyPtr)).FnumPoints - (*TPolygonItem)(unsafe.Pointer(polyPtr)).FautoClosed) for int32(first) >= length { first -= int64(length) } for int32(first) < 0 { first += int64(length) } for int32(last) >= length { last -= int64(length) } for int32(last) < 0 { last += int64(length) } first &= int64(-int32(2)) last &= int64(-int32(2)) count = int32(last + int64(2) - first) if count <= 0 { count += length } if count >= length { (*TPolygonItem)(unsafe.Pointer(polyPtr)).FnumPoints = 0 if (*TPolygonItem)(unsafe.Pointer(polyPtr)).FcoordPtr != libc.UintptrFromInt32(0) { libtcl9_0.XTcl_Free(tls, (*TPolygonItem)(unsafe.Pointer(polyPtr)).FcoordPtr) (*TPolygonItem)(unsafe.Pointer(polyPtr)).FcoordPtr = libc.UintptrFromInt32(0) } _ComputePolygonBbox(tls, canvas, polyPtr) return } if last >= first { i = int32(last + int64(2)) for { if !(i < length) { break } *(*float64)(unsafe.Pointer((*TPolygonItem)(unsafe.Pointer(polyPtr)).FcoordPtr + uintptr(i-count)*8)) = *(*float64)(unsafe.Pointer((*TPolygonItem)(unsafe.Pointer(polyPtr)).FcoordPtr + uintptr(i)*8)) goto _1 _1: ; i++ } } else { i = int32(last) for { if !(i <= int32(first)) { break } *(*float64)(unsafe.Pointer((*TPolygonItem)(unsafe.Pointer(polyPtr)).FcoordPtr + uintptr(int64(i)-last)*8)) = *(*float64)(unsafe.Pointer((*TPolygonItem)(unsafe.Pointer(polyPtr)).FcoordPtr + uintptr(i)*8)) goto _2 _2: ; i++ } } *(*float64)(unsafe.Pointer((*TPolygonItem)(unsafe.Pointer(polyPtr)).FcoordPtr + uintptr(length-count)*8)) = *(*float64)(unsafe.Pointer((*TPolygonItem)(unsafe.Pointer(polyPtr)).FcoordPtr)) *(*float64)(unsafe.Pointer((*TPolygonItem)(unsafe.Pointer(polyPtr)).FcoordPtr + uintptr(length-count+int32(1))*8)) = *(*float64)(unsafe.Pointer((*TPolygonItem)(unsafe.Pointer(polyPtr)).FcoordPtr + 1*8)) *(*int32)(unsafe.Pointer(polyPtr + 296)) -= count / int32(2) _ComputePolygonBbox(tls, canvas, polyPtr) } /* *-------------------------------------------------------------- * * PolygonToPoint -- * * Computes the distance from a given point to a given polygon, in canvas * units. * * Results: * The return value is 0 if the point whose x and y coordinates are * pointPtr[0] and pointPtr[1] is inside the polygon. If the point isn't * inside the polygon then the return value is the distance from the * point to the polygon. * * Side effects: * None. * *-------------------------------------------------------------- */ func _PolygonToPoint(tls *libc.TLS, canvas TTk_Canvas, itemPtr uintptr, pointPtr uintptr) (r float64) { bp := tls.Alloc(3280) defer tls.Free(3280) /* Pointer to x and y coordinates. */ var bestDist, dist, radius, width float64 var changedMiterToBevel, count, numPoints int32 var coordPtr, polyPoints, polyPtr uintptr var state TTk_State var _ /* poly at bp+3200 */ [10]float64 var _ /* staticSpace at bp+0 */ [400]float64 _, _, _, _, _, _, _, _, _, _, _ = bestDist, changedMiterToBevel, coordPtr, count, dist, numPoints, polyPoints, polyPtr, radius, state, width polyPtr = itemPtr state = (*TTk_Item)(unsafe.Pointer(itemPtr)).Fstate bestDist = float64(1e+36) if state == int32(TK_STATE_NULL) { state = (*TTkCanvas)(unsafe.Pointer(canvas)).Fcanvas_state } width = (*TPolygonItem)(unsafe.Pointer(polyPtr)).Foutline.Fwidth if (*TTkCanvas)(unsafe.Pointer(canvas)).FcurrentItemPtr == itemPtr { if (*TPolygonItem)(unsafe.Pointer(polyPtr)).Foutline.FactiveWidth > width { width = (*TPolygonItem)(unsafe.Pointer(polyPtr)).Foutline.FactiveWidth } } else { if state == int32(TK_STATE_DISABLED) { if (*TPolygonItem)(unsafe.Pointer(polyPtr)).Foutline.FdisabledWidth > float64(0) { width = (*TPolygonItem)(unsafe.Pointer(polyPtr)).Foutline.FdisabledWidth } } } radius = width / float64(2) /* * Handle smoothed polygons by generating an expanded set of points * against which to do the check. */ if (*TPolygonItem)(unsafe.Pointer(polyPtr)).Fsmooth != 0 && (*TPolygonItem)(unsafe.Pointer(polyPtr)).FnumPoints > int32(2) { numPoints = (*(*func(*libc.TLS, TTk_Canvas, uintptr, int32, int32, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*TTk_SmoothMethod)(unsafe.Pointer((*TPolygonItem)(unsafe.Pointer(polyPtr)).Fsmooth)).FcoordProc})))(tls, canvas, libc.UintptrFromInt32(0), (*TPolygonItem)(unsafe.Pointer(polyPtr)).FnumPoints, (*TPolygonItem)(unsafe.Pointer(polyPtr)).FsplineSteps, libc.UintptrFromInt32(0), libc.UintptrFromInt32(0)) if numPoints <= int32(MAX_STATIC_POINTS) { polyPoints = bp } else { polyPoints = libtcl9_0.XTcl_Alloc(tls, libc.Uint64FromInt32(int32(2)*numPoints)*uint64(8)) } numPoints = (*(*func(*libc.TLS, TTk_Canvas, uintptr, int32, int32, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*TTk_SmoothMethod)(unsafe.Pointer((*TPolygonItem)(unsafe.Pointer(polyPtr)).Fsmooth)).FcoordProc})))(tls, canvas, (*TPolygonItem)(unsafe.Pointer(polyPtr)).FcoordPtr, (*TPolygonItem)(unsafe.Pointer(polyPtr)).FnumPoints, (*TPolygonItem)(unsafe.Pointer(polyPtr)).FsplineSteps, libc.UintptrFromInt32(0), polyPoints) } else { numPoints = (*TPolygonItem)(unsafe.Pointer(polyPtr)).FnumPoints polyPoints = (*TPolygonItem)(unsafe.Pointer(polyPtr)).FcoordPtr } bestDist = XTkPolygonToPoint(tls, polyPoints, numPoints, pointPtr) if bestDist <= float64(0) { goto donepoint } if (*TPolygonItem)(unsafe.Pointer(polyPtr)).Foutline.Fgc != libc.UintptrFromInt32(0) && (*TPolygonItem)(unsafe.Pointer(polyPtr)).FjoinStyle == int32(JoinRound) { dist = bestDist - radius if dist <= float64(0) { bestDist = float64(0) goto donepoint } else { bestDist = dist } } if (*TPolygonItem)(unsafe.Pointer(polyPtr)).Foutline.Fgc == libc.UintptrFromInt32(0) || width <= libc.Float64FromInt32(1) { goto donepoint } /* * The overall idea is to iterate through all of the edges of the line, * computing a polygon for each edge and testing the point against that * polygon. In addition, there are additional tests to deal with rounded * joints and caps. */ changedMiterToBevel = 0 count = numPoints coordPtr = polyPoints for { if !(count >= int32(2)) { break } /* * If rounding is done around the first point then compute the * distance between the point and the point. */ if (*TPolygonItem)(unsafe.Pointer(polyPtr)).FjoinStyle == int32(JoinRound) { dist = libc.X__builtin_hypot(tls, *(*float64)(unsafe.Pointer(coordPtr))-*(*float64)(unsafe.Pointer(pointPtr)), *(*float64)(unsafe.Pointer(coordPtr + 1*8))-*(*float64)(unsafe.Pointer(pointPtr + 1*8))) - radius if dist <= float64(0) { bestDist = float64(0) goto donepoint } else { if dist < bestDist { bestDist = dist } } } /* * Compute the polygonal shape corresponding to this edge, consisting * of two points for the first point of the edge and two points for * the last point of the edge. */ if count == numPoints { XTkGetButtPoints(tls, coordPtr+uintptr(2)*8, coordPtr, width, 0, bp+3200, bp+3200+uintptr(2)*8) } else { if (*TPolygonItem)(unsafe.Pointer(polyPtr)).FjoinStyle == JoinMiter && !(changedMiterToBevel != 0) { (*(*[10]float64)(unsafe.Pointer(bp + 3200)))[0] = (*(*[10]float64)(unsafe.Pointer(bp + 3200)))[int32(6)] (*(*[10]float64)(unsafe.Pointer(bp + 3200)))[int32(1)] = (*(*[10]float64)(unsafe.Pointer(bp + 3200)))[int32(7)] (*(*[10]float64)(unsafe.Pointer(bp + 3200)))[int32(2)] = (*(*[10]float64)(unsafe.Pointer(bp + 3200)))[int32(4)] (*(*[10]float64)(unsafe.Pointer(bp + 3200)))[int32(3)] = (*(*[10]float64)(unsafe.Pointer(bp + 3200)))[int32(5)] } else { XTkGetButtPoints(tls, coordPtr+uintptr(2)*8, coordPtr, width, 0, bp+3200, bp+3200+uintptr(2)*8) /* * If this line uses beveled joints, then check the distance to a * polygon comprising the last two points of the previous polygon * and the first two from this polygon; this checks the wedges * that fill the mitered joint. */ if (*TPolygonItem)(unsafe.Pointer(polyPtr)).FjoinStyle == int32(JoinBevel) || changedMiterToBevel != 0 { (*(*[10]float64)(unsafe.Pointer(bp + 3200)))[int32(8)] = (*(*[10]float64)(unsafe.Pointer(bp + 3200)))[0] (*(*[10]float64)(unsafe.Pointer(bp + 3200)))[int32(9)] = (*(*[10]float64)(unsafe.Pointer(bp + 3200)))[int32(1)] dist = XTkPolygonToPoint(tls, bp+3200, int32(5), pointPtr) if dist <= float64(0) { bestDist = float64(0) goto donepoint } else { if dist < bestDist { bestDist = dist } } changedMiterToBevel = 0 } } } if count == int32(2) { XTkGetButtPoints(tls, coordPtr, coordPtr+uintptr(2)*8, width, 0, bp+3200+uintptr(4)*8, bp+3200+uintptr(6)*8) } else { if (*TPolygonItem)(unsafe.Pointer(polyPtr)).FjoinStyle == JoinMiter { if XTkGetMiterPoints(tls, coordPtr, coordPtr+uintptr(2)*8, coordPtr+uintptr(4)*8, width, bp+3200+uintptr(4)*8, bp+3200+uintptr(6)*8) == 0 { changedMiterToBevel = int32(1) XTkGetButtPoints(tls, coordPtr, coordPtr+uintptr(2)*8, width, 0, bp+3200+uintptr(4)*8, bp+3200+uintptr(6)*8) } } else { XTkGetButtPoints(tls, coordPtr, coordPtr+uintptr(2)*8, width, 0, bp+3200+uintptr(4)*8, bp+3200+uintptr(6)*8) } } (*(*[10]float64)(unsafe.Pointer(bp + 3200)))[int32(8)] = (*(*[10]float64)(unsafe.Pointer(bp + 3200)))[0] (*(*[10]float64)(unsafe.Pointer(bp + 3200)))[int32(9)] = (*(*[10]float64)(unsafe.Pointer(bp + 3200)))[int32(1)] dist = XTkPolygonToPoint(tls, bp+3200, int32(5), pointPtr) if dist <= float64(0) { bestDist = float64(0) goto donepoint } else { if dist < bestDist { bestDist = dist } } goto _1 _1: ; count-- coordPtr += uintptr(2) * 8 } goto donepoint donepoint: ; if polyPoints != bp && polyPoints != (*TPolygonItem)(unsafe.Pointer(polyPtr)).FcoordPtr { libtcl9_0.XTcl_Free(tls, polyPoints) } return bestDist } /* *-------------------------------------------------------------- * * PolygonToArea -- * * This function is called to determine whether an item lies entirely * inside, entirely outside, or overlapping a given rectangular area. * * Results: * -1 is returned if the item is entirely outside the area given by * rectPtr, 0 if it overlaps, and 1 if it is entirely inside the given * area. * * Side effects: * None. * *-------------------------------------------------------------- */ func _PolygonToArea(tls *libc.TLS, canvas TTk_Canvas, itemPtr uintptr, rectPtr uintptr) (r int32) { bp := tls.Alloc(3312) defer tls.Free(3312) /* Pointer to array of four coordinates * (x1,y1,x2,y2) describing rectangular * area. */ var changedMiterToBevel, count, inside, numPoints int32 var coordPtr, polyPoints, polyPtr uintptr var radius, width float64 var state TTk_State var _ /* oval at bp+3280 */ [4]float64 var _ /* poly at bp+3200 */ [10]float64 var _ /* staticSpace at bp+0 */ [400]float64 _, _, _, _, _, _, _, _, _, _ = changedMiterToBevel, coordPtr, count, inside, numPoints, polyPoints, polyPtr, radius, state, width polyPtr = itemPtr state = (*TTk_Item)(unsafe.Pointer(itemPtr)).Fstate if state == int32(TK_STATE_NULL) { state = (*TTkCanvas)(unsafe.Pointer(canvas)).Fcanvas_state } width = (*TPolygonItem)(unsafe.Pointer(polyPtr)).Foutline.Fwidth if (*TTkCanvas)(unsafe.Pointer(canvas)).FcurrentItemPtr == itemPtr { if (*TPolygonItem)(unsafe.Pointer(polyPtr)).Foutline.FactiveWidth > width { width = (*TPolygonItem)(unsafe.Pointer(polyPtr)).Foutline.FactiveWidth } } else { if state == int32(TK_STATE_DISABLED) { if (*TPolygonItem)(unsafe.Pointer(polyPtr)).Foutline.FdisabledWidth > float64(0) { width = (*TPolygonItem)(unsafe.Pointer(polyPtr)).Foutline.FdisabledWidth } } } radius = width / float64(2) inside = -int32(1) if state == int32(TK_STATE_HIDDEN) || (*TPolygonItem)(unsafe.Pointer(polyPtr)).FnumPoints < int32(2) { return -int32(1) } else { if (*TPolygonItem)(unsafe.Pointer(polyPtr)).FnumPoints < int32(3) { (*(*[4]float64)(unsafe.Pointer(bp + 3280)))[0] = *(*float64)(unsafe.Pointer((*TPolygonItem)(unsafe.Pointer(polyPtr)).FcoordPtr)) - radius (*(*[4]float64)(unsafe.Pointer(bp + 3280)))[int32(1)] = *(*float64)(unsafe.Pointer((*TPolygonItem)(unsafe.Pointer(polyPtr)).FcoordPtr + 1*8)) - radius (*(*[4]float64)(unsafe.Pointer(bp + 3280)))[int32(2)] = *(*float64)(unsafe.Pointer((*TPolygonItem)(unsafe.Pointer(polyPtr)).FcoordPtr)) + radius (*(*[4]float64)(unsafe.Pointer(bp + 3280)))[int32(3)] = *(*float64)(unsafe.Pointer((*TPolygonItem)(unsafe.Pointer(polyPtr)).FcoordPtr + 1*8)) + radius return XTkOvalToArea(tls, bp+3280, rectPtr) } } /* * Handle smoothed polygons by generating an expanded set of points * against which to do the check. */ if (*TPolygonItem)(unsafe.Pointer(polyPtr)).Fsmooth != 0 { numPoints = (*(*func(*libc.TLS, TTk_Canvas, uintptr, int32, int32, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*TTk_SmoothMethod)(unsafe.Pointer((*TPolygonItem)(unsafe.Pointer(polyPtr)).Fsmooth)).FcoordProc})))(tls, canvas, libc.UintptrFromInt32(0), (*TPolygonItem)(unsafe.Pointer(polyPtr)).FnumPoints, (*TPolygonItem)(unsafe.Pointer(polyPtr)).FsplineSteps, libc.UintptrFromInt32(0), libc.UintptrFromInt32(0)) if numPoints <= int32(MAX_STATIC_POINTS) { polyPoints = bp } else { polyPoints = libtcl9_0.XTcl_Alloc(tls, libc.Uint64FromInt32(int32(2)*numPoints)*uint64(8)) } numPoints = (*(*func(*libc.TLS, TTk_Canvas, uintptr, int32, int32, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*TTk_SmoothMethod)(unsafe.Pointer((*TPolygonItem)(unsafe.Pointer(polyPtr)).Fsmooth)).FcoordProc})))(tls, canvas, (*TPolygonItem)(unsafe.Pointer(polyPtr)).FcoordPtr, (*TPolygonItem)(unsafe.Pointer(polyPtr)).FnumPoints, (*TPolygonItem)(unsafe.Pointer(polyPtr)).FsplineSteps, libc.UintptrFromInt32(0), polyPoints) } else { numPoints = (*TPolygonItem)(unsafe.Pointer(polyPtr)).FnumPoints polyPoints = (*TPolygonItem)(unsafe.Pointer(polyPtr)).FcoordPtr } /* * Simple test to see if we are in the polygon. Polygons are different * from othe canvas items in that they register points being inside even * if it isn't filled. */ inside = XTkPolygonToArea(tls, polyPoints, numPoints, rectPtr) if inside == 0 { goto donearea } if (*TPolygonItem)(unsafe.Pointer(polyPtr)).Foutline.Fgc == libc.UintptrFromInt32(0) { goto donearea } /* * Iterate through all of the edges of the line, computing a polygon for * each edge and testing the area against that polygon. In addition, there * are additional tests to deal with rounded joints and caps. */ changedMiterToBevel = 0 count = numPoints coordPtr = polyPoints for { if !(count >= int32(2)) { break } /* * If rounding is done around the first point of the edge then test a * circular region around the point with the area. */ if (*TPolygonItem)(unsafe.Pointer(polyPtr)).FjoinStyle == int32(JoinRound) { (*(*[10]float64)(unsafe.Pointer(bp + 3200)))[0] = *(*float64)(unsafe.Pointer(coordPtr)) - radius (*(*[10]float64)(unsafe.Pointer(bp + 3200)))[int32(1)] = *(*float64)(unsafe.Pointer(coordPtr + 1*8)) - radius (*(*[10]float64)(unsafe.Pointer(bp + 3200)))[int32(2)] = *(*float64)(unsafe.Pointer(coordPtr)) + radius (*(*[10]float64)(unsafe.Pointer(bp + 3200)))[int32(3)] = *(*float64)(unsafe.Pointer(coordPtr + 1*8)) + radius if XTkOvalToArea(tls, bp+3200, rectPtr) != inside { inside = 0 goto donearea } } /* * Compute the polygonal shape corresponding to this edge, consisting * of two points for the first point of the edge and two points for * the last point of the edge. */ if count == numPoints { XTkGetButtPoints(tls, coordPtr+uintptr(2)*8, coordPtr, width, 0, bp+3200, bp+3200+uintptr(2)*8) } else { if (*TPolygonItem)(unsafe.Pointer(polyPtr)).FjoinStyle == JoinMiter && !(changedMiterToBevel != 0) { (*(*[10]float64)(unsafe.Pointer(bp + 3200)))[0] = (*(*[10]float64)(unsafe.Pointer(bp + 3200)))[int32(6)] (*(*[10]float64)(unsafe.Pointer(bp + 3200)))[int32(1)] = (*(*[10]float64)(unsafe.Pointer(bp + 3200)))[int32(7)] (*(*[10]float64)(unsafe.Pointer(bp + 3200)))[int32(2)] = (*(*[10]float64)(unsafe.Pointer(bp + 3200)))[int32(4)] (*(*[10]float64)(unsafe.Pointer(bp + 3200)))[int32(3)] = (*(*[10]float64)(unsafe.Pointer(bp + 3200)))[int32(5)] } else { XTkGetButtPoints(tls, coordPtr+uintptr(2)*8, coordPtr, width, 0, bp+3200, bp+3200+uintptr(2)*8) /* * If the last joint was beveled, then also check a polygon * comprising the last two points of the previous polygon and the * first two from this polygon; this checks the wedges that fill * the beveled joint. */ if (*TPolygonItem)(unsafe.Pointer(polyPtr)).FjoinStyle == int32(JoinBevel) || changedMiterToBevel != 0 { (*(*[10]float64)(unsafe.Pointer(bp + 3200)))[int32(8)] = (*(*[10]float64)(unsafe.Pointer(bp + 3200)))[0] (*(*[10]float64)(unsafe.Pointer(bp + 3200)))[int32(9)] = (*(*[10]float64)(unsafe.Pointer(bp + 3200)))[int32(1)] if XTkPolygonToArea(tls, bp+3200, int32(5), rectPtr) != inside { inside = 0 goto donearea } changedMiterToBevel = 0 } } } if count == int32(2) { XTkGetButtPoints(tls, coordPtr, coordPtr+uintptr(2)*8, width, 0, bp+3200+uintptr(4)*8, bp+3200+uintptr(6)*8) } else { if (*TPolygonItem)(unsafe.Pointer(polyPtr)).FjoinStyle == JoinMiter { if XTkGetMiterPoints(tls, coordPtr, coordPtr+uintptr(2)*8, coordPtr+uintptr(4)*8, width, bp+3200+uintptr(4)*8, bp+3200+uintptr(6)*8) == 0 { changedMiterToBevel = int32(1) XTkGetButtPoints(tls, coordPtr, coordPtr+uintptr(2)*8, width, 0, bp+3200+uintptr(4)*8, bp+3200+uintptr(6)*8) } } else { XTkGetButtPoints(tls, coordPtr, coordPtr+uintptr(2)*8, width, 0, bp+3200+uintptr(4)*8, bp+3200+uintptr(6)*8) } } (*(*[10]float64)(unsafe.Pointer(bp + 3200)))[int32(8)] = (*(*[10]float64)(unsafe.Pointer(bp + 3200)))[0] (*(*[10]float64)(unsafe.Pointer(bp + 3200)))[int32(9)] = (*(*[10]float64)(unsafe.Pointer(bp + 3200)))[int32(1)] if XTkPolygonToArea(tls, bp+3200, int32(5), rectPtr) != inside { inside = 0 goto donearea } goto _1 _1: ; count-- coordPtr += uintptr(2) * 8 } goto donearea donearea: ; if polyPoints != bp && polyPoints != (*TPolygonItem)(unsafe.Pointer(polyPtr)).FcoordPtr { libtcl9_0.XTcl_Free(tls, polyPoints) } return inside } /* *-------------------------------------------------------------- * * ScalePolygon -- * * This function is invoked to rescale a polygon item. * * Results: * None. * * Side effects: * The polygon referred to by itemPtr is rescaled so that the following * transformation is applied to all point coordinates: * x' = originX + scaleX*(x-originX) * y' = originY + scaleY*(y-originY) * *-------------------------------------------------------------- */ func _ScalePolygon(tls *libc.TLS, canvas TTk_Canvas, itemPtr uintptr, originX float64, originY float64, scaleX float64, scaleY float64) { /* Amount to scale in Y direction. */ var coordPtr, polyPtr uintptr var i int32 _, _, _ = coordPtr, i, polyPtr polyPtr = itemPtr i = 0 coordPtr = (*TPolygonItem)(unsafe.Pointer(polyPtr)).FcoordPtr for { if !(i < (*TPolygonItem)(unsafe.Pointer(polyPtr)).FnumPoints) { break } *(*float64)(unsafe.Pointer(coordPtr)) = originX + float64(scaleX*(*(*float64)(unsafe.Pointer(coordPtr))-originX)) *(*float64)(unsafe.Pointer(coordPtr + 1*8)) = originY + float64(scaleY*(*(*float64)(unsafe.Pointer(coordPtr + 1*8))-originY)) goto _1 _1: ; i++ coordPtr += uintptr(2) * 8 } _ComputePolygonBbox(tls, canvas, polyPtr) } /* *-------------------------------------------------------------- * * GetPolygonIndex -- * * Parse an index into a polygon item and return either its value or an * error. * * Results: * A standard Tcl result. If all went well, then *indexPtr is filled in * with the index (into itemPtr) corresponding to string. Otherwise an * error message is left in interp->result. * * Side effects: * None. * *-------------------------------------------------------------- */ func _GetPolygonIndex(tls *libc.TLS, interp uintptr, dummy1710 TTk_Canvas, itemPtr uintptr, obj uintptr, indexPtr uintptr) (r int32) { bp := tls.Alloc(80) defer tls.Free(80) /* Where to store converted index. */ var bestDist, dist float64 var coordPtr, p, polyPtr, rest, string1 uintptr var count TTcl_Size var i int32 var _ /* idx at bp+8 */ TTcl_Size var _ /* length at bp+0 */ TTcl_Size var _ /* x at bp+16 */ float64 var _ /* y at bp+24 */ float64 _, _, _, _, _, _, _, _, _ = bestDist, coordPtr, count, dist, i, p, polyPtr, rest, string1 polyPtr = itemPtr count = int64(int32(2) * ((*TPolygonItem)(unsafe.Pointer(polyPtr)).FnumPoints - (*TPolygonItem)(unsafe.Pointer(polyPtr)).FautoClosed)) if TCL_OK == XTkGetIntForIndex(tls, obj, int64(libc.Int32FromInt32(INT_MAX)-libc.Int32FromInt32(1))-int64(libc.Int32FromInt32(INT_MAX))%count, int32(1), bp+8) { if *(*TTcl_Size)(unsafe.Pointer(bp + 8)) < 0 { *(*TTcl_Size)(unsafe.Pointer(bp + 8)) = 0 } else { if *(*TTcl_Size)(unsafe.Pointer(bp + 8)) >= int64(INT_MAX)-int64(libc.Int32FromInt32(INT_MAX))%count { *(*TTcl_Size)(unsafe.Pointer(bp + 8)) = count } else { *(*TTcl_Size)(unsafe.Pointer(bp + 8)) = *(*TTcl_Size)(unsafe.Pointer(bp + 8)) & int64(-libc.Int32FromInt32(2)) % count } } *(*TTcl_Size)(unsafe.Pointer(indexPtr)) = *(*TTcl_Size)(unsafe.Pointer(bp + 8)) return TCL_OK } string1 = libtcl9_0.XTcl_GetStringFromObj(tls, obj, bp) if !(libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(string1))) == int32('@')) { goto _1 } p = string1 + uintptr(1) rest = libc.Xstrchr(tls, p, int32(',')) *(*uint8)(unsafe.Pointer(rest)) = uint8('\000') if libtcl9_0.XTcl_GetDouble(tls, libc.UintptrFromInt32(0), p, bp+16) != TCL_OK { *(*uint8)(unsafe.Pointer(rest)) = uint8(',') goto badIndex } *(*uint8)(unsafe.Pointer(rest)) = uint8(',') p = rest + uintptr(1) if libtcl9_0.XTcl_GetDouble(tls, libc.UintptrFromInt32(0), p, bp+24) != TCL_OK { goto badIndex } bestDist = float64(1e+36) coordPtr = (*TPolygonItem)(unsafe.Pointer(polyPtr)).FcoordPtr *(*TTcl_Size)(unsafe.Pointer(indexPtr)) = 0 i = 0 for { if !(i < (*TPolygonItem)(unsafe.Pointer(polyPtr)).FnumPoints-int32(1)) { break } dist = libc.X__builtin_hypot(tls, *(*float64)(unsafe.Pointer(coordPtr))-*(*float64)(unsafe.Pointer(bp + 16)), *(*float64)(unsafe.Pointer(coordPtr + 1*8))-*(*float64)(unsafe.Pointer(bp + 24))) if dist < bestDist { bestDist = dist *(*TTcl_Size)(unsafe.Pointer(indexPtr)) = int64(int32(2) * i) } coordPtr += uintptr(2) * 8 goto _3 _3: ; i++ } goto _2 _1: ; goto badIndex badIndex: ; libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+29867, libc.VaList(bp+40, string1))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+40, __ccgo_ts+179, __ccgo_ts+27003, __ccgo_ts+23800, __ccgo_ts+30211, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) _2: ; return TCL_OK } /* *-------------------------------------------------------------- * * RotatePolygon -- * * This function is called to rotate a polygon by a given amount about a * point. * * Results: * None. * * Side effects: * The position of the polygon is rotated by angleRad about (originX, * originY), and the bounding box is updated in the generic part of the * item structure. * *-------------------------------------------------------------- */ func _RotatePolygon(tls *libc.TLS, canvas TTk_Canvas, itemPtr uintptr, originX float64, originY float64, angleRad float64) { /* Amount by which item is to be rotated. */ var c, s float64 var coordPtr, polyPtr uintptr var i int32 _, _, _, _, _ = c, coordPtr, i, polyPtr, s polyPtr = itemPtr s = libc.Xsin(tls, angleRad) c = libc.Xcos(tls, angleRad) i = 0 coordPtr = (*TPolygonItem)(unsafe.Pointer(polyPtr)).FcoordPtr for { if !(i < (*TPolygonItem)(unsafe.Pointer(polyPtr)).FnumPoints) { break } XTkRotatePoint(tls, originX, originY, s, c, coordPtr, coordPtr+1*8) goto _1 _1: ; i++ coordPtr += uintptr(2) * 8 } _ComputePolygonBbox(tls, canvas, polyPtr) } /* *-------------------------------------------------------------- * * TranslatePolygon -- * * This function is called to move a polygon by a given amount. * * Results: * None. * * Side effects: * The position of the polygon is offset by (xDelta, yDelta), and the * bounding box is updated in the generic part of the item structure. * *-------------------------------------------------------------- */ func _TranslatePolygon(tls *libc.TLS, canvas TTk_Canvas, itemPtr uintptr, deltaX float64, deltaY float64) { /* Amount by which item is to be moved. */ var coordPtr, polyPtr uintptr var i int32 _, _, _ = coordPtr, i, polyPtr polyPtr = itemPtr i = 0 coordPtr = (*TPolygonItem)(unsafe.Pointer(polyPtr)).FcoordPtr for { if !(i < (*TPolygonItem)(unsafe.Pointer(polyPtr)).FnumPoints) { break } *(*float64)(unsafe.Pointer(coordPtr)) += deltaX *(*float64)(unsafe.Pointer(coordPtr + 1*8)) += deltaY goto _1 _1: ; i++ coordPtr += uintptr(2) * 8 } _ComputePolygonBbox(tls, canvas, polyPtr) } /* *-------------------------------------------------------------- * * PolygonToPostscript -- * * This function is called to generate Postscript for polygon items. * * Results: * The return value is a standard Tcl result. If an error occurs in * generating Postscript then an error message is left in the interp's * result, replacing whatever used to be there. If no error occurs, then * Postscript for the item is appended to the result. * * Side effects: * None. * *-------------------------------------------------------------- */ func _PolygonToPostscript(tls *libc.TLS, interp uintptr, canvas TTk_Canvas, itemPtr uintptr, dummy1872 int32) (r int32) { bp := tls.Alloc(48) defer tls.Free(48) /* 1 means this is a prepass to collect font * information; 0 means final Postscript is * being created. */ var _objPtr, color, fillColor, polyPtr, psObj, v2 uintptr var fillStipple, stipple TPixmap var interpState TTcl_InterpState var state TTk_State var style int32 var width float64 var v1 TTcl_Size _, _, _, _, _, _, _, _, _, _, _, _, _ = _objPtr, color, fillColor, fillStipple, interpState, polyPtr, psObj, state, stipple, style, width, v1, v2 polyPtr = itemPtr state = (*TTk_Item)(unsafe.Pointer(itemPtr)).Fstate if (*TPolygonItem)(unsafe.Pointer(polyPtr)).FnumPoints < int32(2) || (*TPolygonItem)(unsafe.Pointer(polyPtr)).FcoordPtr == libc.UintptrFromInt32(0) { return TCL_OK } if state == int32(TK_STATE_NULL) { state = (*TTkCanvas)(unsafe.Pointer(canvas)).Fcanvas_state } width = (*TPolygonItem)(unsafe.Pointer(polyPtr)).Foutline.Fwidth color = (*TPolygonItem)(unsafe.Pointer(polyPtr)).Foutline.Fcolor stipple = (*TPolygonItem)(unsafe.Pointer(polyPtr)).FfillStipple fillColor = (*TPolygonItem)(unsafe.Pointer(polyPtr)).FfillColor fillStipple = (*TPolygonItem)(unsafe.Pointer(polyPtr)).FfillStipple if (*TTkCanvas)(unsafe.Pointer(canvas)).FcurrentItemPtr == itemPtr { if (*TPolygonItem)(unsafe.Pointer(polyPtr)).Foutline.FactiveWidth > width { width = (*TPolygonItem)(unsafe.Pointer(polyPtr)).Foutline.FactiveWidth } if (*TPolygonItem)(unsafe.Pointer(polyPtr)).Foutline.FactiveColor != libc.UintptrFromInt32(0) { color = (*TPolygonItem)(unsafe.Pointer(polyPtr)).Foutline.FactiveColor } if (*TPolygonItem)(unsafe.Pointer(polyPtr)).Foutline.FactiveStipple != uint64(0) { stipple = (*TPolygonItem)(unsafe.Pointer(polyPtr)).Foutline.FactiveStipple } if (*TPolygonItem)(unsafe.Pointer(polyPtr)).FactiveFillColor != libc.UintptrFromInt32(0) { fillColor = (*TPolygonItem)(unsafe.Pointer(polyPtr)).FactiveFillColor } if (*TPolygonItem)(unsafe.Pointer(polyPtr)).FactiveFillStipple != uint64(0) { fillStipple = (*TPolygonItem)(unsafe.Pointer(polyPtr)).FactiveFillStipple } } else { if state == int32(TK_STATE_DISABLED) { if (*TPolygonItem)(unsafe.Pointer(polyPtr)).Foutline.FdisabledWidth > float64(0) { width = (*TPolygonItem)(unsafe.Pointer(polyPtr)).Foutline.FdisabledWidth } if (*TPolygonItem)(unsafe.Pointer(polyPtr)).Foutline.FdisabledColor != libc.UintptrFromInt32(0) { color = (*TPolygonItem)(unsafe.Pointer(polyPtr)).Foutline.FdisabledColor } if (*TPolygonItem)(unsafe.Pointer(polyPtr)).Foutline.FdisabledStipple != uint64(0) { stipple = (*TPolygonItem)(unsafe.Pointer(polyPtr)).Foutline.FdisabledStipple } if (*TPolygonItem)(unsafe.Pointer(polyPtr)).FdisabledFillColor != libc.UintptrFromInt32(0) { fillColor = (*TPolygonItem)(unsafe.Pointer(polyPtr)).FdisabledFillColor } if (*TPolygonItem)(unsafe.Pointer(polyPtr)).FdisabledFillStipple != uint64(0) { fillStipple = (*TPolygonItem)(unsafe.Pointer(polyPtr)).FdisabledFillStipple } } } /* * Make our working space. */ psObj = libtcl9_0.XTcl_NewObj(tls) interpState = libtcl9_0.XTcl_SaveInterpState(tls, interp, TCL_OK) if (*TPolygonItem)(unsafe.Pointer(polyPtr)).FnumPoints == int32(2) { if color == libc.UintptrFromInt32(0) { goto done } /* * Create a point by using a small circle. (Printer pixels are too * tiny to be used directly...) */ libtcl9_0.XTcl_AppendPrintfToObj(tls, psObj, __ccgo_ts+30216, libc.VaList(bp+8, *(*float64)(unsafe.Pointer((*TPolygonItem)(unsafe.Pointer(polyPtr)).FcoordPtr)), XTk_CanvasPsY(tls, canvas, *(*float64)(unsafe.Pointer((*TPolygonItem)(unsafe.Pointer(polyPtr)).FcoordPtr + 1*8))), width/float64(2), width/float64(2))) /* * Color it in. */ libtcl9_0.XTcl_ResetResult(tls, interp) XTk_CanvasPsColor(tls, interp, canvas, color) libtcl9_0.XTcl_AppendObjToObj(tls, psObj, libtcl9_0.XTcl_GetObjResult(tls, interp)) if stipple != uint64(0) { libtcl9_0.XTcl_AppendToObj(tls, psObj, __ccgo_ts+29143, int64(-libc.Int32FromInt32(1))) libtcl9_0.XTcl_ResetResult(tls, interp) XTk_CanvasPsStipple(tls, interp, canvas, stipple) libtcl9_0.XTcl_AppendObjToObj(tls, psObj, libtcl9_0.XTcl_GetObjResult(tls, interp)) } else { libtcl9_0.XTcl_AppendToObj(tls, psObj, __ccgo_ts+29165, int64(-libc.Int32FromInt32(1))) } goto done } /* * Fill the area of the polygon. */ if fillColor != libc.UintptrFromInt32(0) && (*TPolygonItem)(unsafe.Pointer(polyPtr)).FnumPoints > int32(3) { libtcl9_0.XTcl_ResetResult(tls, interp) if !((*TPolygonItem)(unsafe.Pointer(polyPtr)).Fsmooth != 0) || !((*TTk_SmoothMethod)(unsafe.Pointer((*TPolygonItem)(unsafe.Pointer(polyPtr)).Fsmooth)).FpostscriptProc != 0) { XTk_CanvasPsPath(tls, interp, canvas, (*TPolygonItem)(unsafe.Pointer(polyPtr)).FcoordPtr, int64((*TPolygonItem)(unsafe.Pointer(polyPtr)).FnumPoints)) } else { (*(*func(*libc.TLS, uintptr, TTk_Canvas, uintptr, int32, int32))(unsafe.Pointer(&struct{ uintptr }{(*TTk_SmoothMethod)(unsafe.Pointer((*TPolygonItem)(unsafe.Pointer(polyPtr)).Fsmooth)).FpostscriptProc})))(tls, interp, canvas, (*TPolygonItem)(unsafe.Pointer(polyPtr)).FcoordPtr, (*TPolygonItem)(unsafe.Pointer(polyPtr)).FnumPoints, (*TPolygonItem)(unsafe.Pointer(polyPtr)).FsplineSteps) } XTk_CanvasPsColor(tls, interp, canvas, fillColor) libtcl9_0.XTcl_AppendObjToObj(tls, psObj, libtcl9_0.XTcl_GetObjResult(tls, interp)) if fillStipple != uint64(0) { libtcl9_0.XTcl_AppendToObj(tls, psObj, __ccgo_ts+30315, int64(-libc.Int32FromInt32(1))) libtcl9_0.XTcl_ResetResult(tls, interp) XTk_CanvasPsStipple(tls, interp, canvas, fillStipple) libtcl9_0.XTcl_AppendObjToObj(tls, psObj, libtcl9_0.XTcl_GetObjResult(tls, interp)) if color != libc.UintptrFromInt32(0) { libtcl9_0.XTcl_AppendToObj(tls, psObj, __ccgo_ts+29149, int64(-libc.Int32FromInt32(1))) } } else { libtcl9_0.XTcl_AppendToObj(tls, psObj, __ccgo_ts+30323, int64(-libc.Int32FromInt32(1))) } } /* * Now draw the outline, if there is one. */ if color != libc.UintptrFromInt32(0) { libtcl9_0.XTcl_ResetResult(tls, interp) if !((*TPolygonItem)(unsafe.Pointer(polyPtr)).Fsmooth != 0) || !((*TTk_SmoothMethod)(unsafe.Pointer((*TPolygonItem)(unsafe.Pointer(polyPtr)).Fsmooth)).FpostscriptProc != 0) { XTk_CanvasPsPath(tls, interp, canvas, (*TPolygonItem)(unsafe.Pointer(polyPtr)).FcoordPtr, int64((*TPolygonItem)(unsafe.Pointer(polyPtr)).FnumPoints)) } else { (*(*func(*libc.TLS, uintptr, TTk_Canvas, uintptr, int32, int32))(unsafe.Pointer(&struct{ uintptr }{(*TTk_SmoothMethod)(unsafe.Pointer((*TPolygonItem)(unsafe.Pointer(polyPtr)).Fsmooth)).FpostscriptProc})))(tls, interp, canvas, (*TPolygonItem)(unsafe.Pointer(polyPtr)).FcoordPtr, (*TPolygonItem)(unsafe.Pointer(polyPtr)).FnumPoints, (*TPolygonItem)(unsafe.Pointer(polyPtr)).FsplineSteps) } libtcl9_0.XTcl_AppendObjToObj(tls, psObj, libtcl9_0.XTcl_GetObjResult(tls, interp)) if (*TPolygonItem)(unsafe.Pointer(polyPtr)).FjoinStyle == int32(JoinRound) { style = int32(1) } else { if (*TPolygonItem)(unsafe.Pointer(polyPtr)).FjoinStyle == int32(JoinBevel) { style = int32(2) } else { style = 0 } } libtcl9_0.XTcl_AppendPrintfToObj(tls, psObj, __ccgo_ts+30331, libc.VaList(bp+8, style)) libtcl9_0.XTcl_ResetResult(tls, interp) XTk_CanvasPsOutline(tls, canvas, itemPtr, polyPtr+120) libtcl9_0.XTcl_AppendObjToObj(tls, psObj, libtcl9_0.XTcl_GetObjResult(tls, interp)) } /* * Plug the accumulated postscript back into the result. */ goto done done: ; libtcl9_0.XTcl_RestoreInterpState(tls, interp, interpState) libtcl9_0.XTcl_AppendObjToObj(tls, libtcl9_0.XTcl_GetObjResult(tls, interp), psObj) _objPtr = psObj v2 = _objPtr v1 = *(*TTcl_Size)(unsafe.Pointer(v2)) *(*TTcl_Size)(unsafe.Pointer(v2))-- if v1 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr) } return TCL_OK } const STRING_LENGTH = 400 /* * See tkCanvas.h for key data structures used to implement canvases. */ /* * The following definition is used in generating postscript for images and * windows. */ type TTkColormapData = struct { Fseparated int32 Fcolor int32 Fncolors int32 Fcolors uintptr Fred_mask int32 Fgreen_mask int32 Fblue_mask int32 Fred_shift int32 Fgreen_shift int32 Fblue_shift int32 } /* * One of the following structures is created to keep track of Postscript * output being generated. It consists mostly of information provided on the * widget command line. */ type TTkPostscriptInfo = struct { Fx int32 Fy int32 Fwidth int32 Fheight int32 Fx2 int32 Fy2 int32 FpageXObj uintptr FpageYObj uintptr FpageX float64 FpageY float64 FpageWidthObj uintptr FpageHeightObj uintptr Fscale float64 FpageAnchor TTk_Anchor Frotate int32 FfontVarObj uintptr FcolorVarObj uintptr FcolorModeObj uintptr FcolorLevel int32 FfileNameObj uintptr FchannelNameObj uintptr Fchan1 TTcl_Channel FfontTable TTcl_HashTable Fprepass int32 Fprolog int32 Ftkwin TTk_Window } /* * The table below provides a template that's used to process arguments to the * canvas "postscript" command and fill in TkPostscriptInfo structures. */ var _configSpecs7 = [17]TTk_ConfigSpec{ 0: { Ftype1: int32(TK_CONFIG_STRING), FargvName: __ccgo_ts + 19101, FdefValue: __ccgo_ts + 195, Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 96)), FspecFlags: int32(TK_CONFIG_OBJS), }, 1: { Ftype1: int32(TK_CONFIG_STRING), FargvName: __ccgo_ts + 30360, FdefValue: __ccgo_ts + 195, Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 104)), FspecFlags: int32(TK_CONFIG_OBJS), }, 2: { Ftype1: int32(TK_CONFIG_STRING), FargvName: __ccgo_ts + 30371, FdefValue: __ccgo_ts + 195, Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 120)), FspecFlags: int32(TK_CONFIG_OBJS), }, 3: { Ftype1: int32(TK_CONFIG_STRING), FargvName: __ccgo_ts + 30377, FdefValue: __ccgo_ts + 195, Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 128)), FspecFlags: int32(TK_CONFIG_OBJS), }, 4: { Ftype1: int32(TK_CONFIG_STRING), FargvName: __ccgo_ts + 30386, FdefValue: __ccgo_ts + 195, Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 88)), FspecFlags: int32(TK_CONFIG_OBJS), }, 5: { Ftype1: int32(TK_CONFIG_PIXELS), FargvName: __ccgo_ts + 2870, FdefValue: __ccgo_ts + 195, Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 12)), }, 6: { Ftype1: int32(TK_CONFIG_ANCHOR), FargvName: __ccgo_ts + 30395, FdefValue: __ccgo_ts + 195, Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 80)), }, 7: { Ftype1: int32(TK_CONFIG_STRING), FargvName: __ccgo_ts + 30407, FdefValue: __ccgo_ts + 195, Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 64)), FspecFlags: int32(TK_CONFIG_OBJS), }, 8: { Ftype1: int32(TK_CONFIG_STRING), FargvName: __ccgo_ts + 30419, FdefValue: __ccgo_ts + 195, Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 56)), FspecFlags: int32(TK_CONFIG_OBJS), }, 9: { Ftype1: int32(TK_CONFIG_STRING), FargvName: __ccgo_ts + 30430, FdefValue: __ccgo_ts + 195, Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 24)), FspecFlags: int32(TK_CONFIG_OBJS), }, 10: { Ftype1: int32(TK_CONFIG_STRING), FargvName: __ccgo_ts + 30437, FdefValue: __ccgo_ts + 195, Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 32)), FspecFlags: int32(TK_CONFIG_OBJS), }, 11: { FargvName: __ccgo_ts + 30444, FdefValue: __ccgo_ts + 195, Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 252)), }, 12: { FargvName: __ccgo_ts + 30452, FdefValue: __ccgo_ts + 195, Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 84)), }, 13: { Ftype1: int32(TK_CONFIG_PIXELS), FargvName: __ccgo_ts + 2987, FdefValue: __ccgo_ts + 195, Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 8)), }, 14: { Ftype1: int32(TK_CONFIG_PIXELS), FargvName: __ccgo_ts + 3002, FdefValue: __ccgo_ts + 195, }, 15: { Ftype1: int32(TK_CONFIG_PIXELS), FargvName: __ccgo_ts + 3005, FdefValue: __ccgo_ts + 195, Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 4)), }, 16: { Ftype1: int32(TK_CONFIG_END), }, } /* *-------------------------------------------------------------- * * TkCanvPostscriptObjCmd -- * * This function is invoked to process the "postscript" options of the * widget command for canvas widgets. See the user documentation for * details on what it does. * * Results: * A standard Tcl result. * * Side effects: * See the user documentation. * *-------------------------------------------------------------- */ func XTkCanvPostscriptObjCmd(tls *libc.TLS, canvasPtr uintptr, interp uintptr, objc TTcl_Size, objv uintptr) (r int32) { bp := tls.Alloc(608) defer tls.Free(608) /* Argument strings. Caller has already parsed * this command enough to know that objv[1] is * "postscript". */ var _objPtr, _objPtr1, _objPtr10, _objPtr11, _objPtr12, _objPtr13, _objPtr2, _objPtr3, _objPtr4, _objPtr5, _objPtr6, _objPtr7, _objPtr8, _objPtr9, hPtr, itemPtr, p, preambleObj, psInfoPtr, psObj, pwPtr, v10, v12, v14, v17, v19, v21, v23, v25, v27, v29, v3, v31, v33, v35, v37, v39, v4, v6 uintptr var deltaX, deltaY, result int32 var length Tsize_t var oldInfoPtr TTk_PostscriptInfo var tkwin TTk_Window var v13, v16, v18, v20, v22, v24, v26, v28, v30, v32, v34, v36, v38, v9 TTcl_Size var _ /* buffer at bp+296 */ TTcl_DString var _ /* mode at bp+520 */ int32 var _ /* now at bp+264 */ Ttime_t var _ /* psInfo at bp+0 */ TTkPostscriptInfo var _ /* search at bp+272 */ TTcl_HashSearch _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = _objPtr, _objPtr1, _objPtr10, _objPtr11, _objPtr12, _objPtr13, _objPtr2, _objPtr3, _objPtr4, _objPtr5, _objPtr6, _objPtr7, _objPtr8, _objPtr9, deltaX, deltaY, hPtr, itemPtr, length, oldInfoPtr, p, preambleObj, psInfoPtr, psObj, pwPtr, result, tkwin, v10, v12, v13, v14, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v3, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v4, v6, v9 psInfoPtr = bp tkwin = (*TTkCanvas)(unsafe.Pointer(canvasPtr)).Ftkwin deltaX = 0 deltaY = 0 /* Offset of lower-left corner of area to be * marked up, measured in canvas units from * the positioning point on the page (reflects * anchor position). Initial values needed * only to stop compiler warnings. */ /* * Get the generic preamble. We only ever bother with the ASCII encoding; * the others just make life too complicated and never actually worked as * such. */ result = libtcl9_0.XTcl_EvalEx(tls, interp, __ccgo_ts+30460, int64(-libc.Int32FromInt32(1)), int32(TCL_EVAL_GLOBAL)) if result != TCL_OK { return result } preambleObj = libtcl9_0.XTcl_GetVar2Ex(tls, interp, __ccgo_ts+30489, libc.UintptrFromInt32(0), int32(TCL_LEAVE_ERR_MSG)) if preambleObj == libc.UintptrFromInt32(0) { return int32(TCL_ERROR) } (*TTcl_Obj)(unsafe.Pointer(preambleObj)).FrefCount++ libtcl9_0.XTcl_ResetResult(tls, interp) psObj = libtcl9_0.XTcl_NewObj(tls) /* * Initialize the data structure describing Postscript generation, then * process all the arguments to fill the data structure in. */ oldInfoPtr = (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FpsInfo (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FpsInfo = psInfoPtr (*(*TTkPostscriptInfo)(unsafe.Pointer(bp))).Fx = (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FxOrigin (*(*TTkPostscriptInfo)(unsafe.Pointer(bp))).Fy = (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FyOrigin (*(*TTkPostscriptInfo)(unsafe.Pointer(bp))).Fwidth = -int32(1) (*(*TTkPostscriptInfo)(unsafe.Pointer(bp))).Fheight = -int32(1) (*(*TTkPostscriptInfo)(unsafe.Pointer(bp))).FpageXObj = libc.UintptrFromInt32(0) (*(*TTkPostscriptInfo)(unsafe.Pointer(bp))).FpageYObj = libc.UintptrFromInt32(0) (*(*TTkPostscriptInfo)(unsafe.Pointer(bp))).FpageX = float64(libc.Float64FromInt32(72) * libc.Float64FromFloat64(4.25)) (*(*TTkPostscriptInfo)(unsafe.Pointer(bp))).FpageY = float64(libc.Float64FromInt32(72) * libc.Float64FromFloat64(5.5)) (*(*TTkPostscriptInfo)(unsafe.Pointer(bp))).FpageWidthObj = libc.UintptrFromInt32(0) (*(*TTkPostscriptInfo)(unsafe.Pointer(bp))).FpageHeightObj = libc.UintptrFromInt32(0) (*(*TTkPostscriptInfo)(unsafe.Pointer(bp))).Fscale = float64(1) (*(*TTkPostscriptInfo)(unsafe.Pointer(bp))).FpageAnchor = int32(TK_ANCHOR_CENTER) (*(*TTkPostscriptInfo)(unsafe.Pointer(bp))).Frotate = 0 (*(*TTkPostscriptInfo)(unsafe.Pointer(bp))).FfontVarObj = libc.UintptrFromInt32(0) (*(*TTkPostscriptInfo)(unsafe.Pointer(bp))).FcolorVarObj = libc.UintptrFromInt32(0) (*(*TTkPostscriptInfo)(unsafe.Pointer(bp))).FcolorModeObj = libc.UintptrFromInt32(0) (*(*TTkPostscriptInfo)(unsafe.Pointer(bp))).FcolorLevel = 0 (*(*TTkPostscriptInfo)(unsafe.Pointer(bp))).FfileNameObj = libc.UintptrFromInt32(0) (*(*TTkPostscriptInfo)(unsafe.Pointer(bp))).FchannelNameObj = libc.UintptrFromInt32(0) (*(*TTkPostscriptInfo)(unsafe.Pointer(bp))).Fchan1 = libc.UintptrFromInt32(0) (*(*TTkPostscriptInfo)(unsafe.Pointer(bp))).Fprepass = 0 (*(*TTkPostscriptInfo)(unsafe.Pointer(bp))).Fprolog = int32(1) (*(*TTkPostscriptInfo)(unsafe.Pointer(bp))).Ftkwin = tkwin libtcl9_0.XTcl_InitHashTable(tls, bp+144, TCL_STRING_KEYS) result = XTk_ConfigureWidget(tls, interp, tkwin, uintptr(unsafe.Pointer(&_configSpecs7)), objc-int64(2), objv+uintptr(2)*8, bp, int32(TK_CONFIG_ARGV_ONLY)) if result != TCL_OK { goto cleanup } if (*(*TTkPostscriptInfo)(unsafe.Pointer(bp))).Fwidth == -int32(1) { (*(*TTkPostscriptInfo)(unsafe.Pointer(bp))).Fwidth = (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fchanges.Fwidth } if (*(*TTkPostscriptInfo)(unsafe.Pointer(bp))).Fheight == -int32(1) { (*(*TTkPostscriptInfo)(unsafe.Pointer(bp))).Fheight = (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fchanges.Fheight } (*(*TTkPostscriptInfo)(unsafe.Pointer(bp))).Fx2 = (*(*TTkPostscriptInfo)(unsafe.Pointer(bp))).Fx + (*(*TTkPostscriptInfo)(unsafe.Pointer(bp))).Fwidth (*(*TTkPostscriptInfo)(unsafe.Pointer(bp))).Fy2 = (*(*TTkPostscriptInfo)(unsafe.Pointer(bp))).Fy + (*(*TTkPostscriptInfo)(unsafe.Pointer(bp))).Fheight if (*(*TTkPostscriptInfo)(unsafe.Pointer(bp))).FpageXObj != libc.UintptrFromInt32(0) { if _GetPostscriptPoints(tls, interp, (*(*TTkPostscriptInfo)(unsafe.Pointer(bp))).FpageXObj, bp+40) != TCL_OK { goto cleanup } } if (*(*TTkPostscriptInfo)(unsafe.Pointer(bp))).FpageYObj != libc.UintptrFromInt32(0) { if _GetPostscriptPoints(tls, interp, (*(*TTkPostscriptInfo)(unsafe.Pointer(bp))).FpageYObj, bp+48) != TCL_OK { goto cleanup } } if (*(*TTkPostscriptInfo)(unsafe.Pointer(bp))).FpageWidthObj != libc.UintptrFromInt32(0) { if _GetPostscriptPoints(tls, interp, (*(*TTkPostscriptInfo)(unsafe.Pointer(bp))).FpageWidthObj, bp+72) != TCL_OK { goto cleanup } (*(*TTkPostscriptInfo)(unsafe.Pointer(bp))).Fscale /= float64((*(*TTkPostscriptInfo)(unsafe.Pointer(bp))).Fwidth) } else { if (*(*TTkPostscriptInfo)(unsafe.Pointer(bp))).FpageHeightObj != libc.UintptrFromInt32(0) { if _GetPostscriptPoints(tls, interp, (*(*TTkPostscriptInfo)(unsafe.Pointer(bp))).FpageHeightObj, bp+72) != TCL_OK { goto cleanup } (*(*TTkPostscriptInfo)(unsafe.Pointer(bp))).Fscale /= float64((*(*TTkPostscriptInfo)(unsafe.Pointer(bp))).Fheight) } else { (*(*TTkPostscriptInfo)(unsafe.Pointer(bp))).Fscale = float64(libc.Float64FromFloat64(72) / libc.Float64FromFloat64(25.4) * float64((*TScreen)(unsafe.Pointer((*struct { Fext_data uintptr Fprivate1 uintptr Ffd int32 Fprivate2 int32 Fproto_major_version int32 Fproto_minor_version int32 Fvendor uintptr Fprivate3 TXID Fprivate4 TXID Fprivate5 TXID Fprivate6 int32 Fresource_alloc uintptr Fbyte_order int32 Fbitmap_unit int32 Fbitmap_pad int32 Fbitmap_bit_order int32 Fnformats int32 Fpixmap_format uintptr Fprivate8 int32 Frelease int32 Fprivate9 uintptr Fprivate10 uintptr Fqlen int32 Flast_request_read uint64 Frequest uint64 Fprivate11 TXPointer Fprivate12 TXPointer Fprivate13 TXPointer Fprivate14 TXPointer Fmax_request_size uint32 Fdb uintptr Fprivate15 uintptr Fdisplay_name uintptr Fdefault_screen int32 Fnscreens int32 Fscreens uintptr Fmotion_buffer uint64 Fprivate16 uint64 Fmin_keycode int32 Fmax_keycode int32 Fprivate17 TXPointer Fprivate18 TXPointer Fprivate19 int32 Fxdefaults uintptr })(unsafe.Pointer((*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fdisplay)).Fscreens+uintptr((*TTk_FakeWin)(unsafe.Pointer(tkwin)).FscreenNum)*128)).Fmwidth)) (*(*TTkPostscriptInfo)(unsafe.Pointer(bp))).Fscale /= float64((*TScreen)(unsafe.Pointer((*struct { Fext_data uintptr Fprivate1 uintptr Ffd int32 Fprivate2 int32 Fproto_major_version int32 Fproto_minor_version int32 Fvendor uintptr Fprivate3 TXID Fprivate4 TXID Fprivate5 TXID Fprivate6 int32 Fresource_alloc uintptr Fbyte_order int32 Fbitmap_unit int32 Fbitmap_pad int32 Fbitmap_bit_order int32 Fnformats int32 Fpixmap_format uintptr Fprivate8 int32 Frelease int32 Fprivate9 uintptr Fprivate10 uintptr Fqlen int32 Flast_request_read uint64 Frequest uint64 Fprivate11 TXPointer Fprivate12 TXPointer Fprivate13 TXPointer Fprivate14 TXPointer Fmax_request_size uint32 Fdb uintptr Fprivate15 uintptr Fdisplay_name uintptr Fdefault_screen int32 Fnscreens int32 Fscreens uintptr Fmotion_buffer uint64 Fprivate16 uint64 Fmin_keycode int32 Fmax_keycode int32 Fprivate17 TXPointer Fprivate18 TXPointer Fprivate19 int32 Fxdefaults uintptr })(unsafe.Pointer((*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fdisplay)).Fscreens + uintptr((*TTk_FakeWin)(unsafe.Pointer(tkwin)).FscreenNum)*128)).Fwidth) } } switch (*(*TTkPostscriptInfo)(unsafe.Pointer(bp))).FpageAnchor { case int32(TK_ANCHOR_NW): fallthrough case int32(TK_ANCHOR_W): fallthrough case int32(TK_ANCHOR_SW): deltaX = 0 case int32(TK_ANCHOR_NE): fallthrough case int32(TK_ANCHOR_E): fallthrough case int32(TK_ANCHOR_SE): deltaX = -(*(*TTkPostscriptInfo)(unsafe.Pointer(bp))).Fwidth default: deltaX = -(*(*TTkPostscriptInfo)(unsafe.Pointer(bp))).Fwidth / int32(2) break } switch (*(*TTkPostscriptInfo)(unsafe.Pointer(bp))).FpageAnchor { case int32(TK_ANCHOR_NW): fallthrough case int32(TK_ANCHOR_N): fallthrough case int32(TK_ANCHOR_NE): deltaY = -(*(*TTkPostscriptInfo)(unsafe.Pointer(bp))).Fheight case int32(TK_ANCHOR_SW): fallthrough case int32(TK_ANCHOR_S): fallthrough case int32(TK_ANCHOR_SE): deltaY = 0 default: deltaY = -(*(*TTkPostscriptInfo)(unsafe.Pointer(bp))).Fheight / int32(2) break } if (*(*TTkPostscriptInfo)(unsafe.Pointer(bp))).FcolorModeObj == libc.UintptrFromInt32(0) { (*(*TTkPostscriptInfo)(unsafe.Pointer(bp))).FcolorLevel = int32(2) } else { length = libc.Xstrlen(tls, libtcl9_0.XTcl_GetStringFromObj(tls, (*(*TTkPostscriptInfo)(unsafe.Pointer(bp))).FcolorModeObj, libc.UintptrFromInt32(0))) if libc.Xstrncmp(tls, libtcl9_0.XTcl_GetStringFromObj(tls, (*(*TTkPostscriptInfo)(unsafe.Pointer(bp))).FcolorModeObj, libc.UintptrFromInt32(0)), __ccgo_ts+30507, length) == 0 { (*(*TTkPostscriptInfo)(unsafe.Pointer(bp))).FcolorLevel = 0 } else { if libc.Xstrncmp(tls, libtcl9_0.XTcl_GetStringFromObj(tls, (*(*TTkPostscriptInfo)(unsafe.Pointer(bp))).FcolorModeObj, libc.UintptrFromInt32(0)), __ccgo_ts+30518, length) == 0 { (*(*TTkPostscriptInfo)(unsafe.Pointer(bp))).FcolorLevel = int32(1) } else { if libc.Xstrncmp(tls, libtcl9_0.XTcl_GetStringFromObj(tls, (*(*TTkPostscriptInfo)(unsafe.Pointer(bp))).FcolorModeObj, libc.UintptrFromInt32(0)), __ccgo_ts+6919, length) == 0 { (*(*TTkPostscriptInfo)(unsafe.Pointer(bp))).FcolorLevel = int32(2) } else { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+30523, libc.VaList(bp+536, libtcl9_0.XTcl_GetStringFromObj(tls, (*(*TTkPostscriptInfo)(unsafe.Pointer(bp))).FcolorModeObj, libc.UintptrFromInt32(0))))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+536, __ccgo_ts+179, __ccgo_ts+27003, __ccgo_ts+29550, __ccgo_ts+30579, libc.UintptrFromInt32(0))) result = int32(TCL_ERROR) goto cleanup } } } } if (*(*TTkPostscriptInfo)(unsafe.Pointer(bp))).FfileNameObj != libc.UintptrFromInt32(0) { /* * Check that -file and -channel are not both specified. */ if (*(*TTkPostscriptInfo)(unsafe.Pointer(bp))).FchannelNameObj != libc.UintptrFromInt32(0) { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+30589, int64(-libc.Int32FromInt32(1)))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+536, __ccgo_ts+179, __ccgo_ts+27003, __ccgo_ts+29550, __ccgo_ts+12516, libc.UintptrFromInt32(0))) result = int32(TCL_ERROR) goto cleanup } /* * Check that we are not in a safe interpreter. If we are, disallow * the -file specification. */ if libtcl9_0.XTcl_IsSafe(tls, interp) != 0 { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+30627, int64(-libc.Int32FromInt32(1)))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+536, __ccgo_ts+179, __ccgo_ts+4089, __ccgo_ts+30669, libc.UintptrFromInt32(0))) result = int32(TCL_ERROR) goto cleanup } p = libtcl9_0.XTcl_TranslateFileName(tls, interp, libtcl9_0.XTcl_GetStringFromObj(tls, (*(*TTkPostscriptInfo)(unsafe.Pointer(bp))).FfileNameObj, libc.UintptrFromInt32(0)), bp+296) if p == libc.UintptrFromInt32(0) { goto cleanup } (*(*TTkPostscriptInfo)(unsafe.Pointer(bp))).Fchan1 = libtcl9_0.XTcl_OpenFileChannel(tls, interp, p, __ccgo_ts+10954, int32(0666)) libtcl9_0.XTcl_DStringFree(tls, bp+296) if (*(*TTkPostscriptInfo)(unsafe.Pointer(bp))).Fchan1 == libc.UintptrFromInt32(0) { goto cleanup } } if (*(*TTkPostscriptInfo)(unsafe.Pointer(bp))).FchannelNameObj != libc.UintptrFromInt32(0) { /* * Check that the channel is found in this interpreter and that it is * open for writing. */ (*(*TTkPostscriptInfo)(unsafe.Pointer(bp))).Fchan1 = libtcl9_0.XTcl_GetChannel(tls, interp, libtcl9_0.XTcl_GetStringFromObj(tls, (*(*TTkPostscriptInfo)(unsafe.Pointer(bp))).FchannelNameObj, libc.UintptrFromInt32(0)), bp+520) if (*(*TTkPostscriptInfo)(unsafe.Pointer(bp))).Fchan1 == libc.UintptrFromInt32(0) { result = int32(TCL_ERROR) goto cleanup } if !(*(*int32)(unsafe.Pointer(bp + 520))&(libc.Int32FromInt32(1)<= (*(*TTkPostscriptInfo)(unsafe.Pointer(bp))).Fx2 || (*TTk_Item)(unsafe.Pointer(itemPtr)).Fx2 < (*(*TTkPostscriptInfo)(unsafe.Pointer(bp))).Fx || (*TTk_Item)(unsafe.Pointer(itemPtr)).Fy1 >= (*(*TTkPostscriptInfo)(unsafe.Pointer(bp))).Fy2 || (*TTk_Item)(unsafe.Pointer(itemPtr)).Fy2 < (*(*TTkPostscriptInfo)(unsafe.Pointer(bp))).Fy { goto _1 } if (*TTk_ItemType1)(unsafe.Pointer((*TTk_Item)(unsafe.Pointer(itemPtr)).FtypePtr)).FpostscriptProc == libc.UintptrFromInt32(0) { goto _1 } result = (*(*func(*libc.TLS, uintptr, TTk_Canvas, uintptr, int32) int32)(unsafe.Pointer(&struct{ uintptr }{(*TTk_ItemType1)(unsafe.Pointer((*TTk_Item)(unsafe.Pointer(itemPtr)).FtypePtr)).FpostscriptProc})))(tls, interp, canvasPtr, itemPtr, int32(1)) libtcl9_0.XTcl_ResetResult(tls, interp) if result != TCL_OK { /* * An error just occurred. Just skip out of this loop. There's no * need to report the error now; it can be reported later (errors * can happen later that don't happen now, so we still have to * check for errors later anyway). */ break } goto _1 _1: ; itemPtr = (*TTk_Item)(unsafe.Pointer(itemPtr)).FnextPtr } (*(*TTkPostscriptInfo)(unsafe.Pointer(bp))).Fprepass = 0 /* * Generate the header and prolog for the Postscript. */ if !((*(*TTkPostscriptInfo)(unsafe.Pointer(bp))).Fprolog != 0) { goto _2 } libtcl9_0.XTcl_AppendToObj(tls, psObj, __ccgo_ts+30727, int64(-libc.Int32FromInt32(1))) if !(libtcl9_0.XTcl_IsSafe(tls, interp) != 0) { pwPtr = libc.Xgetpwuid(tls, libc.Xgetuid(tls)) /* INTL: Native. */ if pwPtr != 0 { v3 = (*Tpasswd)(unsafe.Pointer(pwPtr)).Fpw_gecos } else { v3 = __ccgo_ts + 30780 } libtcl9_0.XTcl_AppendPrintfToObj(tls, psObj, __ccgo_ts+30788, libc.VaList(bp+536, v3)) libc.Xendpwent(tls) } libtcl9_0.XTcl_AppendPrintfToObj(tls, psObj, __ccgo_ts+30801, libc.VaList(bp+536, (*TTk_FakeWin)(unsafe.Pointer(tkwin)).FpathName)) libc.Xtime(tls, bp+264) libtcl9_0.XTcl_AppendPrintfToObj(tls, psObj, __ccgo_ts+30823, libc.VaList(bp+536, libc.Xctime(tls, bp+264))) /* INTL: Native. */ if !((*(*TTkPostscriptInfo)(unsafe.Pointer(bp))).Frotate != 0) { libtcl9_0.XTcl_AppendPrintfToObj(tls, psObj, __ccgo_ts+30844, libc.VaList(bp+536, int32((*(*TTkPostscriptInfo)(unsafe.Pointer(bp))).FpageX+float64((*(*TTkPostscriptInfo)(unsafe.Pointer(bp))).Fscale*float64(deltaX))), int32((*(*TTkPostscriptInfo)(unsafe.Pointer(bp))).FpageY+float64((*(*TTkPostscriptInfo)(unsafe.Pointer(bp))).Fscale*float64(deltaY))), int32((*(*TTkPostscriptInfo)(unsafe.Pointer(bp))).FpageX+float64((*(*TTkPostscriptInfo)(unsafe.Pointer(bp))).Fscale*float64(deltaX+(*(*TTkPostscriptInfo)(unsafe.Pointer(bp))).Fwidth))+libc.Float64FromFloat64(1)), int32((*(*TTkPostscriptInfo)(unsafe.Pointer(bp))).FpageY+float64((*(*TTkPostscriptInfo)(unsafe.Pointer(bp))).Fscale*float64(deltaY+(*(*TTkPostscriptInfo)(unsafe.Pointer(bp))).Fheight))+libc.Float64FromFloat64(1)))) } else { libtcl9_0.XTcl_AppendPrintfToObj(tls, psObj, __ccgo_ts+30844, libc.VaList(bp+536, int32((*(*TTkPostscriptInfo)(unsafe.Pointer(bp))).FpageX-float64((*(*TTkPostscriptInfo)(unsafe.Pointer(bp))).Fscale*float64(deltaY+(*(*TTkPostscriptInfo)(unsafe.Pointer(bp))).Fheight))), int32((*(*TTkPostscriptInfo)(unsafe.Pointer(bp))).FpageY+float64((*(*TTkPostscriptInfo)(unsafe.Pointer(bp))).Fscale*float64(deltaX))), int32((*(*TTkPostscriptInfo)(unsafe.Pointer(bp))).FpageX-float64((*(*TTkPostscriptInfo)(unsafe.Pointer(bp))).Fscale*float64(deltaY))+libc.Float64FromFloat64(1)), int32((*(*TTkPostscriptInfo)(unsafe.Pointer(bp))).FpageY+float64((*(*TTkPostscriptInfo)(unsafe.Pointer(bp))).Fscale*float64(deltaX+(*(*TTkPostscriptInfo)(unsafe.Pointer(bp))).Fwidth))+libc.Float64FromFloat64(1)))) } if (*(*TTkPostscriptInfo)(unsafe.Pointer(bp))).Frotate != 0 { v4 = __ccgo_ts + 30874 } else { v4 = __ccgo_ts + 30884 } libtcl9_0.XTcl_AppendPrintfToObj(tls, psObj, __ccgo_ts+30893, libc.VaList(bp+536, v4)) p = __ccgo_ts + 30955 hPtr = libtcl9_0.XTcl_FirstHashEntry(tls, bp+144, bp+272) for { if !(hPtr != libc.UintptrFromInt32(0)) { break } if (*TTcl_HashTable)(unsafe.Pointer(bp+144)).FkeyType == int32(TCL_ONE_WORD_KEYS) || (*TTcl_HashTable)(unsafe.Pointer(bp+144)).FkeyType == -int32(1) { v6 = *(*uintptr)(unsafe.Pointer(hPtr + 32)) } else { v6 = hPtr + 32 } libtcl9_0.XTcl_AppendPrintfToObj(tls, psObj, p, libc.VaList(bp+536, v6)) p = __ccgo_ts + 30993 goto _5 _5: ; hPtr = libtcl9_0.XTcl_NextHashEntry(tls, bp+272) } libtcl9_0.XTcl_AppendToObj(tls, psObj, __ccgo_ts+31008, int64(-libc.Int32FromInt32(1))) /* * Insert the prolog */ libtcl9_0.XTcl_AppendObjToObj(tls, psObj, preambleObj) if !((*(*TTkPostscriptInfo)(unsafe.Pointer(bp))).Fchan1 != libc.UintptrFromInt32(0)) { goto _7 } if !(libtcl9_0.XTcl_WriteObj(tls, (*(*TTkPostscriptInfo)(unsafe.Pointer(bp))).Fchan1, psObj) == int64(-libc.Int32FromInt32(1))) { goto _8 } goto channelWriteFailed channelWriteFailed: ; libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+31024, libc.VaList(bp+536, libtcl9_0.XTcl_PosixError(tls, interp)))) result = int32(TCL_ERROR) goto cleanup _8: ; _objPtr = psObj v10 = _objPtr v9 = *(*TTcl_Size)(unsafe.Pointer(v10)) *(*TTcl_Size)(unsafe.Pointer(v10))-- if v9 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr) } psObj = libtcl9_0.XTcl_NewObj(tls) _7: ; /* * Document setup: set the color level and include fonts. */ libtcl9_0.XTcl_AppendPrintfToObj(tls, psObj, __ccgo_ts+31071, libc.VaList(bp+536, (*(*TTkPostscriptInfo)(unsafe.Pointer(bp))).FcolorLevel)) hPtr = libtcl9_0.XTcl_FirstHashEntry(tls, bp+144, bp+272) for { if !(hPtr != libc.UintptrFromInt32(0)) { break } if (*TTcl_HashTable)(unsafe.Pointer(bp+144)).FkeyType == int32(TCL_ONE_WORD_KEYS) || (*TTcl_HashTable)(unsafe.Pointer(bp+144)).FkeyType == -int32(1) { v12 = *(*uintptr)(unsafe.Pointer(hPtr + 32)) } else { v12 = hPtr + 32 } libtcl9_0.XTcl_AppendPrintfToObj(tls, psObj, __ccgo_ts+31098, libc.VaList(bp+536, v12)) goto _11 _11: ; hPtr = libtcl9_0.XTcl_NextHashEntry(tls, bp+272) } libtcl9_0.XTcl_AppendToObj(tls, psObj, __ccgo_ts+31128, int64(-libc.Int32FromInt32(1))) /* * Page setup: move to page positioning point, rotate if needed, set * scale factor, offset for proper anchor position, and set clip * region. */ libtcl9_0.XTcl_AppendToObj(tls, psObj, __ccgo_ts+31141, int64(-libc.Int32FromInt32(1))) libtcl9_0.XTcl_AppendPrintfToObj(tls, psObj, __ccgo_ts+31159, libc.VaList(bp+536, (*(*TTkPostscriptInfo)(unsafe.Pointer(bp))).FpageX, (*(*TTkPostscriptInfo)(unsafe.Pointer(bp))).FpageY)) if (*(*TTkPostscriptInfo)(unsafe.Pointer(bp))).Frotate != 0 { libtcl9_0.XTcl_AppendToObj(tls, psObj, __ccgo_ts+31180, int64(-libc.Int32FromInt32(1))) } libtcl9_0.XTcl_AppendPrintfToObj(tls, psObj, __ccgo_ts+31191, libc.VaList(bp+536, (*(*TTkPostscriptInfo)(unsafe.Pointer(bp))).Fscale, (*(*TTkPostscriptInfo)(unsafe.Pointer(bp))).Fscale)) libtcl9_0.XTcl_AppendPrintfToObj(tls, psObj, __ccgo_ts+31208, libc.VaList(bp+536, deltaX-(*(*TTkPostscriptInfo)(unsafe.Pointer(bp))).Fx, deltaY)) libtcl9_0.XTcl_AppendPrintfToObj(tls, psObj, __ccgo_ts+31225, libc.VaList(bp+536, (*(*TTkPostscriptInfo)(unsafe.Pointer(bp))).Fx, XTk_PostscriptY(tls, float64((*(*TTkPostscriptInfo)(unsafe.Pointer(bp))).Fy), psInfoPtr), (*(*TTkPostscriptInfo)(unsafe.Pointer(bp))).Fx2, XTk_PostscriptY(tls, float64((*(*TTkPostscriptInfo)(unsafe.Pointer(bp))).Fy), psInfoPtr), (*(*TTkPostscriptInfo)(unsafe.Pointer(bp))).Fx2, XTk_PostscriptY(tls, float64((*(*TTkPostscriptInfo)(unsafe.Pointer(bp))).Fy2), psInfoPtr), (*(*TTkPostscriptInfo)(unsafe.Pointer(bp))).Fx, XTk_PostscriptY(tls, float64((*(*TTkPostscriptInfo)(unsafe.Pointer(bp))).Fy2), psInfoPtr))) if (*(*TTkPostscriptInfo)(unsafe.Pointer(bp))).Fchan1 != libc.UintptrFromInt32(0) { if libtcl9_0.XTcl_WriteObj(tls, (*(*TTkPostscriptInfo)(unsafe.Pointer(bp))).Fchan1, psObj) == int64(-libc.Int32FromInt32(1)) { goto channelWriteFailed } _objPtr1 = psObj v14 = _objPtr1 v13 = *(*TTcl_Size)(unsafe.Pointer(v14)) *(*TTcl_Size)(unsafe.Pointer(v14))-- if v13 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr1) } psObj = libtcl9_0.XTcl_NewObj(tls) } _2: ; /* * Iterate through all the items, having each relevant one draw itself. * Quit if any of the items returns an error. */ result = TCL_OK itemPtr = (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FfirstItemPtr for { if !(itemPtr != libc.UintptrFromInt32(0)) { break } if (*TTk_Item)(unsafe.Pointer(itemPtr)).Fx1 >= (*(*TTkPostscriptInfo)(unsafe.Pointer(bp))).Fx2 || (*TTk_Item)(unsafe.Pointer(itemPtr)).Fx2 < (*(*TTkPostscriptInfo)(unsafe.Pointer(bp))).Fx || (*TTk_Item)(unsafe.Pointer(itemPtr)).Fy1 >= (*(*TTkPostscriptInfo)(unsafe.Pointer(bp))).Fy2 || (*TTk_Item)(unsafe.Pointer(itemPtr)).Fy2 < (*(*TTkPostscriptInfo)(unsafe.Pointer(bp))).Fy { goto _15 } if (*TTk_ItemType1)(unsafe.Pointer((*TTk_Item)(unsafe.Pointer(itemPtr)).FtypePtr)).FpostscriptProc == libc.UintptrFromInt32(0) { goto _15 } if (*TTk_Item)(unsafe.Pointer(itemPtr)).Fstate == int32(TK_STATE_HIDDEN) { goto _15 } result = (*(*func(*libc.TLS, uintptr, TTk_Canvas, uintptr, int32) int32)(unsafe.Pointer(&struct{ uintptr }{(*TTk_ItemType1)(unsafe.Pointer((*TTk_Item)(unsafe.Pointer(itemPtr)).FtypePtr)).FpostscriptProc})))(tls, interp, canvasPtr, itemPtr, 0) if result != TCL_OK { libtcl9_0.XTcl_AppendObjToErrorInfo(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+31313, libc.VaList(bp+536, int32((*TTk_Item)(unsafe.Pointer(itemPtr)).Fid)))) goto cleanup } libtcl9_0.XTcl_AppendToObj(tls, psObj, __ccgo_ts+31354, int64(-libc.Int32FromInt32(1))) libtcl9_0.XTcl_AppendObjToObj(tls, psObj, libtcl9_0.XTcl_GetObjResult(tls, interp)) libtcl9_0.XTcl_AppendToObj(tls, psObj, __ccgo_ts+31361, int64(-libc.Int32FromInt32(1))) libtcl9_0.XTcl_ResetResult(tls, interp) if (*(*TTkPostscriptInfo)(unsafe.Pointer(bp))).Fchan1 != libc.UintptrFromInt32(0) { if libtcl9_0.XTcl_WriteObj(tls, (*(*TTkPostscriptInfo)(unsafe.Pointer(bp))).Fchan1, psObj) == int64(-libc.Int32FromInt32(1)) { goto channelWriteFailed } _objPtr2 = psObj v17 = _objPtr2 v16 = *(*TTcl_Size)(unsafe.Pointer(v17)) *(*TTcl_Size)(unsafe.Pointer(v17))-- if v16 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr2) } psObj = libtcl9_0.XTcl_NewObj(tls) } goto _15 _15: ; itemPtr = (*TTk_Item)(unsafe.Pointer(itemPtr)).FnextPtr } /* * Output page-end information, such as commands to print the page and * document trailer stuff. */ if (*(*TTkPostscriptInfo)(unsafe.Pointer(bp))).Fprolog != 0 { libtcl9_0.XTcl_AppendToObj(tls, psObj, __ccgo_ts+31371, int64(-libc.Int32FromInt32(1))) if (*(*TTkPostscriptInfo)(unsafe.Pointer(bp))).Fchan1 != libc.UintptrFromInt32(0) { if libtcl9_0.XTcl_WriteObj(tls, (*(*TTkPostscriptInfo)(unsafe.Pointer(bp))).Fchan1, psObj) == int64(-libc.Int32FromInt32(1)) { goto channelWriteFailed } } } if (*(*TTkPostscriptInfo)(unsafe.Pointer(bp))).Fchan1 == libc.UintptrFromInt32(0) { libtcl9_0.XTcl_SetObjResult(tls, interp, psObj) psObj = libtcl9_0.XTcl_NewObj(tls) } /* * Clean up psInfo to release malloc'ed stuff. */ goto cleanup cleanup: ; if (*(*TTkPostscriptInfo)(unsafe.Pointer(bp))).FpageXObj != libc.UintptrFromInt32(0) { _objPtr3 = (*(*TTkPostscriptInfo)(unsafe.Pointer(bp))).FpageXObj v19 = _objPtr3 v18 = *(*TTcl_Size)(unsafe.Pointer(v19)) *(*TTcl_Size)(unsafe.Pointer(v19))-- if v18 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr3) } } if (*(*TTkPostscriptInfo)(unsafe.Pointer(bp))).FpageYObj != libc.UintptrFromInt32(0) { _objPtr4 = (*(*TTkPostscriptInfo)(unsafe.Pointer(bp))).FpageYObj v21 = _objPtr4 v20 = *(*TTcl_Size)(unsafe.Pointer(v21)) *(*TTcl_Size)(unsafe.Pointer(v21))-- if v20 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr4) } } if (*(*TTkPostscriptInfo)(unsafe.Pointer(bp))).FpageWidthObj != libc.UintptrFromInt32(0) { _objPtr5 = (*(*TTkPostscriptInfo)(unsafe.Pointer(bp))).FpageWidthObj v23 = _objPtr5 v22 = *(*TTcl_Size)(unsafe.Pointer(v23)) *(*TTcl_Size)(unsafe.Pointer(v23))-- if v22 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr5) } } if (*(*TTkPostscriptInfo)(unsafe.Pointer(bp))).FpageHeightObj != libc.UintptrFromInt32(0) { _objPtr6 = (*(*TTkPostscriptInfo)(unsafe.Pointer(bp))).FpageHeightObj v25 = _objPtr6 v24 = *(*TTcl_Size)(unsafe.Pointer(v25)) *(*TTcl_Size)(unsafe.Pointer(v25))-- if v24 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr6) } } if (*(*TTkPostscriptInfo)(unsafe.Pointer(bp))).FfontVarObj != libc.UintptrFromInt32(0) { _objPtr7 = (*(*TTkPostscriptInfo)(unsafe.Pointer(bp))).FfontVarObj v27 = _objPtr7 v26 = *(*TTcl_Size)(unsafe.Pointer(v27)) *(*TTcl_Size)(unsafe.Pointer(v27))-- if v26 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr7) } } if (*(*TTkPostscriptInfo)(unsafe.Pointer(bp))).FcolorVarObj != libc.UintptrFromInt32(0) { _objPtr8 = (*(*TTkPostscriptInfo)(unsafe.Pointer(bp))).FcolorVarObj v29 = _objPtr8 v28 = *(*TTcl_Size)(unsafe.Pointer(v29)) *(*TTcl_Size)(unsafe.Pointer(v29))-- if v28 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr8) } } if (*(*TTkPostscriptInfo)(unsafe.Pointer(bp))).FcolorModeObj != libc.UintptrFromInt32(0) { _objPtr9 = (*(*TTkPostscriptInfo)(unsafe.Pointer(bp))).FcolorModeObj v31 = _objPtr9 v30 = *(*TTcl_Size)(unsafe.Pointer(v31)) *(*TTcl_Size)(unsafe.Pointer(v31))-- if v30 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr9) } } if (*(*TTkPostscriptInfo)(unsafe.Pointer(bp))).FfileNameObj != libc.UintptrFromInt32(0) { _objPtr10 = (*(*TTkPostscriptInfo)(unsafe.Pointer(bp))).FfileNameObj v33 = _objPtr10 v32 = *(*TTcl_Size)(unsafe.Pointer(v33)) *(*TTcl_Size)(unsafe.Pointer(v33))-- if v32 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr10) } } if (*(*TTkPostscriptInfo)(unsafe.Pointer(bp))).Fchan1 != libc.UintptrFromInt32(0) && (*(*TTkPostscriptInfo)(unsafe.Pointer(bp))).FchannelNameObj == libc.UintptrFromInt32(0) { libtcl9_0.XTcl_CloseEx(tls, interp, (*(*TTkPostscriptInfo)(unsafe.Pointer(bp))).Fchan1, 0) } if (*(*TTkPostscriptInfo)(unsafe.Pointer(bp))).FchannelNameObj != libc.UintptrFromInt32(0) { _objPtr11 = (*(*TTkPostscriptInfo)(unsafe.Pointer(bp))).FchannelNameObj v35 = _objPtr11 v34 = *(*TTcl_Size)(unsafe.Pointer(v35)) *(*TTcl_Size)(unsafe.Pointer(v35))-- if v34 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr11) } } libtcl9_0.XTcl_DeleteHashTable(tls, bp+144) (*TTkCanvas)(unsafe.Pointer(canvasPtr)).FpsInfo = oldInfoPtr _objPtr12 = preambleObj v37 = _objPtr12 v36 = *(*TTcl_Size)(unsafe.Pointer(v37)) *(*TTcl_Size)(unsafe.Pointer(v37))-- if v36 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr12) } _objPtr13 = psObj v39 = _objPtr13 v38 = *(*TTcl_Size)(unsafe.Pointer(v39)) *(*TTcl_Size)(unsafe.Pointer(v39))-- if v38 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr13) } return result } func _GetPostscriptBuffer(tls *libc.TLS, interp uintptr) (r uintptr) { var psObj uintptr _ = psObj psObj = libtcl9_0.XTcl_GetObjResult(tls, interp) if (*TTcl_Obj)(unsafe.Pointer(psObj)).FrefCount > int64(1) { psObj = libtcl9_0.XTcl_DuplicateObj(tls, psObj) libtcl9_0.XTcl_SetObjResult(tls, interp, psObj) } return psObj } /* *-------------------------------------------------------------- * * Tk_PostscriptColor -- * * This function is called by individual canvas items when they want to * set a color value for output. Given information about an X color, this * function will generate Postscript commands to set up an appropriate * color in Postscript. * * Results: * Returns a standard Tcl return value. If an error occurs then an error * message will be left in the interp's result. If no error occurs, then * additional Postscript will be appended to the interp's result. * * Side effects: * None. * *-------------------------------------------------------------- */ func XTk_PostscriptColor(tls *libc.TLS, interp uintptr, psInfo TTk_PostscriptInfo, colorPtr uintptr) (r int32) { bp := tls.Alloc(32) defer tls.Free(32) /* Information about color. */ var blue, green, red float64 var cmdString, psInfoPtr uintptr _, _, _, _, _ = blue, cmdString, green, psInfoPtr, red psInfoPtr = psInfo if (*TTkPostscriptInfo)(unsafe.Pointer(psInfoPtr)).Fprepass != 0 { return TCL_OK } /* * If there is a color map defined, then look up the color's name in the * map and use the Postscript commands found there, if there are any. */ if (*TTkPostscriptInfo)(unsafe.Pointer(psInfoPtr)).FcolorVarObj != libc.UintptrFromInt32(0) { cmdString = libtcl9_0.XTcl_GetVar2(tls, interp, libtcl9_0.XTcl_GetStringFromObj(tls, (*TTkPostscriptInfo)(unsafe.Pointer(psInfoPtr)).FcolorVarObj, libc.UintptrFromInt32(0)), XTk_NameOfColor(tls, colorPtr), 0) if cmdString != libc.UintptrFromInt32(0) { libtcl9_0.XTcl_AppendPrintfToObj(tls, _GetPostscriptBuffer(tls, interp), __ccgo_ts+31410, libc.VaList(bp+8, cmdString)) return TCL_OK } } /* * No color map entry for this color. Grab the color's intensities and * output Postscript commands for them. Special note: X uses a range of * 0-65535 for intensities, but most displays only use a range of 0-255, * which maps to (0, 256, 512, ... 65280) in the X scale. This means that * there's no way to get perfect white, since the highest intensity is * only 65280 out of 65535. To work around this problem, rescale the X * intensity to a 0-255 scale and use that as the basis for the Postscript * colors. This scheme still won't work if the display only uses 4 bits * per color, but most diplays use at least 8 bits. */ red = float64(libc.Int32FromUint16((*TXColor)(unsafe.Pointer(colorPtr)).Fred)>>libc.Int32FromInt32(8)) / float64(255) green = float64(libc.Int32FromUint16((*TXColor)(unsafe.Pointer(colorPtr)).Fgreen)>>libc.Int32FromInt32(8)) / float64(255) blue = float64(libc.Int32FromUint16((*TXColor)(unsafe.Pointer(colorPtr)).Fblue)>>libc.Int32FromInt32(8)) / float64(255) libtcl9_0.XTcl_AppendPrintfToObj(tls, _GetPostscriptBuffer(tls, interp), __ccgo_ts+31414, libc.VaList(bp+8, red, green, blue)) return TCL_OK } /* *-------------------------------------------------------------- * * Tk_PostscriptFont -- * * This function is called by individual canvas items when they want to * output text. Given information about an X font, this function will * generate Postscript commands to set up an appropriate font in * Postscript. * * Results: * Returns a standard Tcl return value. If an error occurs then an error * message will be left in the interp's result. If no error occurs, then * additional Postscript will be appended to the interp's result. * * Side effects: * The Postscript font name is entered into psInfoPtr->fontTable if it * wasn't already there. * *-------------------------------------------------------------- */ func XTk_PostscriptFont(tls *libc.TLS, interp uintptr, psInfo TTk_PostscriptInfo, tkfont TTk_Font) (r int32) { bp := tls.Alloc(304) defer tls.Free(304) /* Information about font in which text is to * be printed. */ var fontname, list, name, psInfoPtr, v1, v3, v4 uintptr var points int32 var v2 bool var _ /* ds at bp+0 */ TTcl_DString var _ /* i at bp+224 */ int32 var _ /* objc at bp+240 */ TTcl_Size var _ /* objv at bp+232 */ uintptr var _ /* size at bp+248 */ float64 _, _, _, _, _, _, _, _, _ = fontname, list, name, points, psInfoPtr, v1, v2, v3, v4 psInfoPtr = psInfo /* * First, look up the font's name in the font map, if there is one. If * there is an entry for this font, it consists of a list containing font * name and size. Use this information. */ if (*TTkPostscriptInfo)(unsafe.Pointer(psInfoPtr)).FfontVarObj != libc.UintptrFromInt32(0) { name = XTk_NameOfFont(tls, tkfont) list = libtcl9_0.XTcl_GetVar2Ex(tls, interp, libtcl9_0.XTcl_GetStringFromObj(tls, (*TTkPostscriptInfo)(unsafe.Pointer(psInfoPtr)).FfontVarObj, libc.UintptrFromInt32(0)), name, 0) if list != libc.UintptrFromInt32(0) { if v2 = libtcl9_0.XTcl_ListObjGetElements(tls, interp, list, bp+240, bp+232) != TCL_OK || *(*TTcl_Size)(unsafe.Pointer(bp + 240)) != int64(2); !v2 { v1 = libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 232)))), libc.UintptrFromInt32(0)) fontname = v1 } if v2 || libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(v1))) == int32('\000') || libc.Xstrchr(tls, fontname, int32(' ')) != libc.UintptrFromInt32(0) || libtcl9_0.XTcl_GetDoubleFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 232)) + 1*8)), bp+248) != TCL_OK || *(*float64)(unsafe.Pointer(bp + 248)) <= libc.Float64FromInt32(0) { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+31454, libc.VaList(bp+264, name, libtcl9_0.XTcl_GetStringFromObj(tls, list, libc.UintptrFromInt32(0))))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+264, __ccgo_ts+179, __ccgo_ts+27003, __ccgo_ts+29550, __ccgo_ts+31488, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) } if libc.Xstrncasecmp(tls, fontname, __ccgo_ts+31496, uint64(7)) != 0 { v3 = __ccgo_ts + 31503 } else { v3 = __ccgo_ts + 195 } libtcl9_0.XTcl_AppendPrintfToObj(tls, _GetPostscriptBuffer(tls, interp), __ccgo_ts+31514, libc.VaList(bp+264, fontname, int32(*(*float64)(unsafe.Pointer(bp + 248))), v3)) (*(*func(*libc.TLS, uintptr, uintptr, uintptr) uintptr)(unsafe.Pointer(&struct{ uintptr }{(*TTcl_HashTable)(unsafe.Pointer(psInfoPtr + 144)).FcreateProc})))(tls, psInfoPtr+144, fontname, bp+224) return TCL_OK } } /* * Nothing in the font map, so fall back to the old guessing technique. */ libtcl9_0.XTcl_DStringInit(tls, bp) points = XTk_PostscriptFontName(tls, tkfont, bp) fontname = (*TTcl_DString)(unsafe.Pointer(bp)).Fstring1 if libc.Xstrncasecmp(tls, fontname, __ccgo_ts+31496, uint64(7)) != 0 { v4 = __ccgo_ts + 31503 } else { v4 = __ccgo_ts + 195 } libtcl9_0.XTcl_AppendPrintfToObj(tls, _GetPostscriptBuffer(tls, interp), __ccgo_ts+31514, libc.VaList(bp+264, fontname, int32(XTkFontGetPoints(tls, (*TTkPostscriptInfo)(unsafe.Pointer(psInfoPtr)).Ftkwin, float64(points))+libc.Float64FromFloat64(0.5)), v4)) (*(*func(*libc.TLS, uintptr, uintptr, uintptr) uintptr)(unsafe.Pointer(&struct{ uintptr }{(*TTcl_HashTable)(unsafe.Pointer(psInfoPtr + 144)).FcreateProc})))(tls, psInfoPtr+144, (*TTcl_DString)(unsafe.Pointer(bp)).Fstring1, bp+224) libtcl9_0.XTcl_DStringFree(tls, bp) return TCL_OK } /* *-------------------------------------------------------------- * * Tk_PostscriptBitmap -- * * This function is called to output the contents of a sub-region of a * bitmap in proper image data format for Postscript (i.e. data between * angle brackets, one bit per pixel). * * Results: * Returns a standard Tcl return value. If an error occurs then an error * message will be left in the interp's result. If no error occurs, then * additional Postscript will be appended to the interp's result. * * Side effects: * None. * *-------------------------------------------------------------- */ func XTk_PostscriptBitmap(tls *libc.TLS, interp uintptr, tkwin TTk_Window, psInfo TTk_PostscriptInfo, bitmap TPixmap, startX int32, startY int32, width int32, height int32) (r int32) { /* Height of rectangular region. */ var psInfoPtr uintptr _ = psInfoPtr psInfoPtr = psInfo if (*TTkPostscriptInfo)(unsafe.Pointer(psInfoPtr)).Fprepass != 0 { return TCL_OK } _PostscriptBitmap(tls, tkwin, bitmap, startX, startY, width, height, _GetPostscriptBuffer(tls, interp)) return TCL_OK } func _PostscriptBitmap(tls *libc.TLS, tkwin TTk_Window, bitmap TPixmap, startX int32, startY int32, width int32, height int32, psObj uintptr) { bp := tls.Alloc(48) defer tls.Free(48) /* Where to append the postscript. */ var charsInLine, lastX, lastY, mask, value, x, y int32 var imagePtr uintptr var _ /* dummyBorderwidth at bp+24 */ uint32 var _ /* dummyDepth at bp+28 */ uint32 var _ /* dummyRoot at bp+8 */ TWindow var _ /* dummyX at bp+16 */ int32 var _ /* dummyY at bp+20 */ int32 var _ /* totalHeight at bp+4 */ uint32 var _ /* totalWidth at bp+0 */ uint32 _, _, _, _, _, _, _, _ = charsInLine, imagePtr, lastX, lastY, mask, value, x, y /* * The following call should probably be a call to Tk_SizeOfBitmap * instead, but it seems that we are occasionally invoked by custom item * types that create their own bitmaps without registering them with Tk. * XGetGeometry is a bit slower than Tk_SizeOfBitmap, but it shouldn't * matter here. */ libx11.XXGetGeometry(tls, (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fdisplay, bitmap, bp+8, bp+16, bp+20, bp, bp+4, bp+24, bp+28) imagePtr = libx11.XXGetImage(tls, (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fdisplay, bitmap, 0, 0, *(*uint32)(unsafe.Pointer(bp)), *(*uint32)(unsafe.Pointer(bp + 4)), uint64(1), int32(XYPixmap)) if !(imagePtr != 0) { /* * The XGetImage() function is apparently not implemented on this * system. Just skip the pixels, the Postscript will still be * syntactically correct. */ libtcl9_0.XTcl_AppendToObj(tls, psObj, __ccgo_ts+31551, int64(-libc.Int32FromInt32(1))) return } libtcl9_0.XTcl_AppendToObj(tls, psObj, __ccgo_ts+3977, int64(-libc.Int32FromInt32(1))) mask = int32(0x80) value = 0 charsInLine = 0 lastX = startX + width - int32(1) lastY = startY + height - int32(1) y = lastY for { if !(y >= startY) { break } x = startX for { if !(x <= lastX) { break } if (*(*func(*libc.TLS, uintptr, int32, int32) uint64)(unsafe.Pointer(&struct{ uintptr }{(*TXImage)(unsafe.Pointer(imagePtr)).Ff.Fget_pixel})))(tls, imagePtr, x, y) != 0 { value |= mask } mask >>= int32(1) if mask == 0 { libtcl9_0.XTcl_AppendPrintfToObj(tls, psObj, __ccgo_ts+31554, libc.VaList(bp+40, value)) mask = int32(0x80) value = 0 charsInLine += int32(2) if charsInLine >= int32(60) { libtcl9_0.XTcl_AppendToObj(tls, psObj, __ccgo_ts+14046, int64(-libc.Int32FromInt32(1))) charsInLine = 0 } } goto _2 _2: ; x++ } if mask != int32(0x80) { libtcl9_0.XTcl_AppendPrintfToObj(tls, psObj, __ccgo_ts+31554, libc.VaList(bp+40, value)) mask = int32(0x80) value = 0 charsInLine += int32(2) } goto _1 _1: ; y-- } libtcl9_0.XTcl_AppendToObj(tls, psObj, __ccgo_ts+4016, int64(-libc.Int32FromInt32(1))) (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*TXImage)(unsafe.Pointer(imagePtr)).Ff.Fdestroy_image})))(tls, imagePtr) } /* *-------------------------------------------------------------- * * Tk_PostscriptStipple -- * * This function is called by individual canvas items when they have * created a path that they'd like to be filled with a stipple pattern. * Given information about an X bitmap, this function will generate * Postscript commands to fill the current clip region using a stipple * pattern defined by the bitmap. * * Results: * Returns a standard Tcl return value. If an error occurs then an error * message will be left in the interp's result. If no error occurs, then * additional Postscript will be appended to the interp's result. * * Side effects: * None. * *-------------------------------------------------------------- */ func XTk_PostscriptStipple(tls *libc.TLS, interp uintptr, tkwin TTk_Window, psInfo TTk_PostscriptInfo, bitmap TPixmap) (r int32) { bp := tls.Alloc(64) defer tls.Free(64) /* Bitmap to use for stippling. */ var psInfoPtr, psObj uintptr var _ /* dummyBorderwidth at bp+24 */ uint32 var _ /* dummyDepth at bp+28 */ uint32 var _ /* dummyRoot at bp+8 */ TWindow var _ /* dummyX at bp+16 */ int32 var _ /* dummyY at bp+20 */ int32 var _ /* height at bp+4 */ int32 var _ /* width at bp+0 */ int32 _, _ = psInfoPtr, psObj psInfoPtr = psInfo if (*TTkPostscriptInfo)(unsafe.Pointer(psInfoPtr)).Fprepass != 0 { return TCL_OK } /* * The following call should probably be a call to Tk_SizeOfBitmap * instead, but it seems that we are occasionally invoked by custom item * types that create their own bitmaps without registering them with Tk. * XGetGeometry is a bit slower than Tk_SizeOfBitmap, but it shouldn't * matter here. */ libx11.XXGetGeometry(tls, (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fdisplay, bitmap, bp+8, bp+16, bp+20, bp, bp+4, bp+24, bp+28) psObj = _GetPostscriptBuffer(tls, interp) libtcl9_0.XTcl_AppendPrintfToObj(tls, psObj, __ccgo_ts+31559, libc.VaList(bp+40, *(*int32)(unsafe.Pointer(bp)), *(*int32)(unsafe.Pointer(bp + 4)))) _PostscriptBitmap(tls, tkwin, bitmap, 0, 0, *(*int32)(unsafe.Pointer(bp)), *(*int32)(unsafe.Pointer(bp + 4)), psObj) libtcl9_0.XTcl_AppendToObj(tls, psObj, __ccgo_ts+31566, int64(-libc.Int32FromInt32(1))) return TCL_OK } /* *-------------------------------------------------------------- * * Tk_PostscriptY -- * * Given a y-coordinate in local coordinates, this function returns a * y-coordinate to use for Postscript output. Required because canvases * have their origin in the top-left, but postscript pages have their * origin in the bottom left. * * Results: * Returns the Postscript coordinate that corresponds to "y". * * Side effects: * None. * *-------------------------------------------------------------- */ func XTk_PostscriptY(tls *libc.TLS, y float64, psInfo TTk_PostscriptInfo) (r float64) { /* Postscript info */ var psInfoPtr uintptr _ = psInfoPtr psInfoPtr = psInfo return float64((*TTkPostscriptInfo)(unsafe.Pointer(psInfoPtr)).Fy2) - y } /* *-------------------------------------------------------------- * * Tk_PostscriptPath -- * * Given an array of points for a path, generate Postscript commands to * create the path. * * Results: * Postscript commands get appended to what's in the interp's result. * * Side effects: * None. * *-------------------------------------------------------------- */ func XTk_PostscriptPath(tls *libc.TLS, interp uintptr, psInfo TTk_PostscriptInfo, coordPtr uintptr, numPoints TTcl_Size) { bp := tls.Alloc(32) defer tls.Free(32) /* Number of points at *coordPtr. */ var psInfoPtr, psObj uintptr _, _ = psInfoPtr, psObj psInfoPtr = psInfo if (*TTkPostscriptInfo)(unsafe.Pointer(psInfoPtr)).Fprepass != 0 { return } psObj = _GetPostscriptBuffer(tls, interp) libtcl9_0.XTcl_AppendPrintfToObj(tls, psObj, __ccgo_ts+31580, libc.VaList(bp+8, *(*float64)(unsafe.Pointer(coordPtr)), XTk_PostscriptY(tls, *(*float64)(unsafe.Pointer(coordPtr + 1*8)), psInfo))) numPoints-- coordPtr += uintptr(2) * 8 for { if !(numPoints > 0) { break } libtcl9_0.XTcl_AppendPrintfToObj(tls, psObj, __ccgo_ts+31600, libc.VaList(bp+8, *(*float64)(unsafe.Pointer(coordPtr)), XTk_PostscriptY(tls, *(*float64)(unsafe.Pointer(coordPtr + 1*8)), psInfo))) goto _1 _1: ; numPoints-- coordPtr += uintptr(2) * 8 } } /* *-------------------------------------------------------------- * * GetPostscriptPoints -- * * Given a string, returns the number of Postscript points corresponding * to that string. * * Results: * The return value is a standard Tcl return result. If TCL_OK is * returned, then everything went well and the screen distance is stored * at *doublePtr; otherwise TCL_ERROR is returned and an error message is * left in the interp's result. * * Side effects: * None. * *-------------------------------------------------------------- */ func _GetPostscriptPoints(tls *libc.TLS, interp uintptr, value uintptr, doublePtr uintptr) (r int32) { bp := tls.Alloc(288) defer tls.Free(288) /* Place to store converted result. */ var rest, string1 uintptr var v1, v2 int32 var v4 bool var _ /* d at bp+0 */ float64 var _ /* ds at bp+8 */ TTcl_DString _, _, _, _, _ = rest, string1, v1, v2, v4 string1 = libtcl9_0.XTcl_GetStringFromObj(tls, value, libc.UintptrFromInt32(0)) if libtcl9_0.XTcl_GetDoubleFromObj(tls, libc.UintptrFromInt32(0), value, bp) == TCL_OK { *(*float64)(unsafe.Pointer(doublePtr)) = *(*float64)(unsafe.Pointer(bp)) return TCL_OK } rest = string1 + uintptr(libc.Xstrlen(tls, string1)) for { if v4 = rest > string1; v4 { v1 = libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(rest + uintptr(-libc.Int32FromInt32(1))))) v2 = libc.BoolInt32(v1 == int32(' ') || libc.Uint32FromInt32(v1)-uint32('\t') < uint32(5)) goto _3 _3: } if !(v4 && v2 != 0) { break } rest-- /* skip all spaces at the end */ } if rest > string1 { rest-- /* point to the character just before the last space */ } if !(rest == string1) { goto _5 } goto error error: ; if interp != libc.UintptrFromInt32(0) { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+31620, libc.VaList(bp+240, string1))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+240, __ccgo_ts+179, __ccgo_ts+27003, __ccgo_ts+29550, __ccgo_ts+31638, libc.UintptrFromInt32(0))) } return int32(TCL_ERROR) _5: ; libtcl9_0.XTcl_DStringInit(tls, bp+8) libtcl9_0.XTcl_DStringAppend(tls, bp+8, string1, int64(rest)-int64(string1)) if libtcl9_0.XTcl_GetDouble(tls, libc.UintptrFromInt32(0), (*TTcl_DString)(unsafe.Pointer(bp+8)).Fstring1, bp) != TCL_OK { libtcl9_0.XTcl_DStringFree(tls, bp+8) goto error } libtcl9_0.XTcl_DStringFree(tls, bp+8) switch libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(rest))) { case int32('c'): *(*float64)(unsafe.Pointer(bp)) *= libc.Float64FromFloat64(72) / libc.Float64FromFloat64(2.54) case int32('i'): *(*float64)(unsafe.Pointer(bp)) *= float64(72) case int32('m'): *(*float64)(unsafe.Pointer(bp)) *= libc.Float64FromFloat64(72) / libc.Float64FromFloat64(25.4) case int32('p'): default: goto error } *(*float64)(unsafe.Pointer(doublePtr)) = *(*float64)(unsafe.Pointer(bp)) return TCL_OK } /* *-------------------------------------------------------------- * * TkImageGetColor -- * * This function converts a pixel value to three floating point numbers, * representing the amount of red, green, and blue in that pixel on the * screen. It makes use of colormap data passed as an argument, and * should work for all Visual types. * * This implementation is bogus on Windows because the colormap data is * never filled in. Instead all postscript generated data coming through * here is expected to be RGB color data. To handle lower bit-depth * images properly, XQueryColors must be implemented for Windows. * * Results: * Returns red, green, and blue color values in the range 0 to 1. There * are no error returns. * * Side effects: * None. * *-------------------------------------------------------------- */ func _TkImageGetColor(tls *libc.TLS, cdata uintptr, pixel uint64, red uintptr, green uintptr, blue uintptr) { /* Color data to return */ var b, g, r int32 _, _, _ = b, g, r if (*TTkColormapData)(unsafe.Pointer(cdata)).Fseparated != 0 { r = libc.Int32FromUint64(pixel & libc.Uint64FromInt32((*TTkColormapData)(unsafe.Pointer(cdata)).Fred_mask) >> (*TTkColormapData)(unsafe.Pointer(cdata)).Fred_shift) g = libc.Int32FromUint64(pixel & libc.Uint64FromInt32((*TTkColormapData)(unsafe.Pointer(cdata)).Fgreen_mask) >> (*TTkColormapData)(unsafe.Pointer(cdata)).Fgreen_shift) b = libc.Int32FromUint64(pixel & libc.Uint64FromInt32((*TTkColormapData)(unsafe.Pointer(cdata)).Fblue_mask) >> (*TTkColormapData)(unsafe.Pointer(cdata)).Fblue_shift) *(*float64)(unsafe.Pointer(red)) = float64((*(*TXColor)(unsafe.Pointer((*TTkColormapData)(unsafe.Pointer(cdata)).Fcolors + uintptr(r)*16))).Fred) / float64(65535) *(*float64)(unsafe.Pointer(green)) = float64((*(*TXColor)(unsafe.Pointer((*TTkColormapData)(unsafe.Pointer(cdata)).Fcolors + uintptr(g)*16))).Fgreen) / float64(65535) *(*float64)(unsafe.Pointer(blue)) = float64((*(*TXColor)(unsafe.Pointer((*TTkColormapData)(unsafe.Pointer(cdata)).Fcolors + uintptr(b)*16))).Fblue) / float64(65535) } else { *(*float64)(unsafe.Pointer(red)) = float64((*(*TXColor)(unsafe.Pointer((*TTkColormapData)(unsafe.Pointer(cdata)).Fcolors + uintptr(pixel)*16))).Fred) / float64(65535) *(*float64)(unsafe.Pointer(green)) = float64((*(*TXColor)(unsafe.Pointer((*TTkColormapData)(unsafe.Pointer(cdata)).Fcolors + uintptr(pixel)*16))).Fgreen) / float64(65535) *(*float64)(unsafe.Pointer(blue)) = float64((*(*TXColor)(unsafe.Pointer((*TTkColormapData)(unsafe.Pointer(cdata)).Fcolors + uintptr(pixel)*16))).Fblue) / float64(65535) } } /* *-------------------------------------------------------------- * * TkPostscriptImage -- * * This function is called to output the contents of an image in * Postscript, using a format appropriate for the current color mode * (i.e. one bit per pixel in monochrome, one byte per pixel in gray, and * three bytes per pixel in color). * * Results: * Returns a standard Tcl return value. If an error occurs then an error * message will be left in interp->result. If no error occurs, then * additional Postscript will be appended to interp->result. * * Side effects: * None. * *-------------------------------------------------------------- */ func XTkPostscriptImage(tls *libc.TLS, interp uintptr, tkwin TTk_Window, psInfo TTk_PostscriptInfo, ximage uintptr, x int32, dummy1262 int32, width int32, height int32) (r int32) { bp := tls.Alloc(128) defer tls.Free(128) /* Width and height of area */ var band, bytesPerLine, i, level, lineLen, maxRows, maxWidth, ncolors, rows, xx, yy, v4 int32 var cmap TColormap var data, mask uint8 var psInfoPtr, psObj, visual uintptr var _ /* blue at bp+16 */ float64 var _ /* cdata at bp+24 */ TTkColormapData var _ /* green at bp+8 */ float64 var _ /* red at bp+0 */ float64 _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = band, bytesPerLine, cmap, data, i, level, lineLen, mask, maxRows, maxWidth, ncolors, psInfoPtr, psObj, rows, visual, xx, yy, v4 psInfoPtr = psInfo bytesPerLine = 0 maxWidth = 0 level = (*TTkPostscriptInfo)(unsafe.Pointer(psInfoPtr)).FcolorLevel if (*TTkPostscriptInfo)(unsafe.Pointer(psInfoPtr)).Fprepass != 0 { return TCL_OK } cmap = (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fatts.Fcolormap visual = (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fvisual /* * Obtain information about the colormap, ie the mapping between pixel * values and RGB values. The code below should work for all Visual types. */ ncolors = (*TVisual)(unsafe.Pointer(visual)).Fmap_entries (*(*TTkColormapData)(unsafe.Pointer(bp + 24))).Fcolors = libtcl9_0.XTcl_Alloc(tls, uint64(16)*libc.Uint64FromInt32(ncolors)) (*(*TTkColormapData)(unsafe.Pointer(bp + 24))).Fncolors = ncolors if (*TVisual)(unsafe.Pointer(visual)).Fclass == int32(DirectColor) || (*TVisual)(unsafe.Pointer(visual)).Fclass == int32(TrueColor) { (*(*TTkColormapData)(unsafe.Pointer(bp + 24))).Fseparated = int32(1) (*(*TTkColormapData)(unsafe.Pointer(bp + 24))).Fred_mask = libc.Int32FromUint64((*TVisual)(unsafe.Pointer(visual)).Fred_mask) (*(*TTkColormapData)(unsafe.Pointer(bp + 24))).Fgreen_mask = libc.Int32FromUint64((*TVisual)(unsafe.Pointer(visual)).Fgreen_mask) (*(*TTkColormapData)(unsafe.Pointer(bp + 24))).Fblue_mask = libc.Int32FromUint64((*TVisual)(unsafe.Pointer(visual)).Fblue_mask) (*(*TTkColormapData)(unsafe.Pointer(bp + 24))).Fred_shift = 0 (*(*TTkColormapData)(unsafe.Pointer(bp + 24))).Fgreen_shift = 0 (*(*TTkColormapData)(unsafe.Pointer(bp + 24))).Fblue_shift = 0 for int32(0x0001)&((*(*TTkColormapData)(unsafe.Pointer(bp + 24))).Fred_mask>>(*(*TTkColormapData)(unsafe.Pointer(bp + 24))).Fred_shift) == 0 { (*(*TTkColormapData)(unsafe.Pointer(bp + 24))).Fred_shift++ } for int32(0x0001)&((*(*TTkColormapData)(unsafe.Pointer(bp + 24))).Fgreen_mask>>(*(*TTkColormapData)(unsafe.Pointer(bp + 24))).Fgreen_shift) == 0 { (*(*TTkColormapData)(unsafe.Pointer(bp + 24))).Fgreen_shift++ } for int32(0x0001)&((*(*TTkColormapData)(unsafe.Pointer(bp + 24))).Fblue_mask>>(*(*TTkColormapData)(unsafe.Pointer(bp + 24))).Fblue_shift) == 0 { (*(*TTkColormapData)(unsafe.Pointer(bp + 24))).Fblue_shift++ } i = 0 for { if !(i < ncolors) { break } (*(*TXColor)(unsafe.Pointer((*(*TTkColormapData)(unsafe.Pointer(bp + 24))).Fcolors + uintptr(i)*16))).Fpixel = libc.Uint64FromInt32(i<<(*(*TTkColormapData)(unsafe.Pointer(bp + 24))).Fred_shift&(*(*TTkColormapData)(unsafe.Pointer(bp + 24))).Fred_mask | i<<(*(*TTkColormapData)(unsafe.Pointer(bp + 24))).Fgreen_shift&(*(*TTkColormapData)(unsafe.Pointer(bp + 24))).Fgreen_mask | i<<(*(*TTkColormapData)(unsafe.Pointer(bp + 24))).Fblue_shift&(*(*TTkColormapData)(unsafe.Pointer(bp + 24))).Fblue_mask) goto _1 _1: ; i++ } } else { (*(*TTkColormapData)(unsafe.Pointer(bp + 24))).Fseparated = 0 i = 0 for { if !(i < ncolors) { break } (*(*TXColor)(unsafe.Pointer((*(*TTkColormapData)(unsafe.Pointer(bp + 24))).Fcolors + uintptr(i)*16))).Fpixel = libc.Uint64FromInt32(i) goto _2 _2: ; i++ } } if (*TVisual)(unsafe.Pointer(visual)).Fclass == StaticGray || (*TVisual)(unsafe.Pointer(visual)).Fclass == int32(GrayScale) { (*(*TTkColormapData)(unsafe.Pointer(bp + 24))).Fcolor = 0 } else { (*(*TTkColormapData)(unsafe.Pointer(bp + 24))).Fcolor = int32(1) } libx11.XXQueryColors(tls, (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fdisplay, cmap, (*(*TTkColormapData)(unsafe.Pointer(bp + 24))).Fcolors, ncolors) /* * Figure out which color level to use (possibly lower than the one * specified by the user). For example, if the user specifies color with * monochrome screen, use gray or monochrome mode instead. */ if !((*(*TTkColormapData)(unsafe.Pointer(bp + 24))).Fcolor != 0) && level >= int32(2) { level = int32(1) } if !((*(*TTkColormapData)(unsafe.Pointer(bp + 24))).Fcolor != 0) && (*(*TTkColormapData)(unsafe.Pointer(bp + 24))).Fncolors == int32(2) { level = 0 } /* * Check that at least one row of the image can be represented with a * string less than 64 KB long (this is a limit in the Postscript * interpreter). */ switch level { case 0: bytesPerLine = (width + int32(7)) / int32(8) maxWidth = int32(240000) case int32(1): bytesPerLine = width maxWidth = int32(60000) default: bytesPerLine = int32(3) * width maxWidth = int32(20000) break } if bytesPerLine > int32(60000) { libtcl9_0.XTcl_ResetResult(tls, interp) libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+31645, libc.VaList(bp+80, maxWidth))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+80, __ccgo_ts+179, __ccgo_ts+27003, __ccgo_ts+29550, __ccgo_ts+29553, libc.UintptrFromInt32(0))) libtcl9_0.XTcl_Free(tls, (*(*TTkColormapData)(unsafe.Pointer(bp + 24))).Fcolors) return int32(TCL_ERROR) } maxRows = int32(60000) / bytesPerLine psObj = _GetPostscriptBuffer(tls, interp) band = height - int32(1) for { if !(band >= 0) { break } if band >= maxRows { v4 = maxRows } else { v4 = band + int32(1) } rows = v4 lineLen = 0 switch level { case 0: libtcl9_0.XTcl_AppendPrintfToObj(tls, psObj, __ccgo_ts+31707, libc.VaList(bp+80, width, rows)) case int32(1): libtcl9_0.XTcl_AppendPrintfToObj(tls, psObj, __ccgo_ts+31726, libc.VaList(bp+80, width, rows)) default: libtcl9_0.XTcl_AppendPrintfToObj(tls, psObj, __ccgo_ts+31726, libc.VaList(bp+80, width, rows)) break } yy = band for { if !(yy > band-rows) { break } switch level { case 0: goto _6 case int32(1): goto _7 default: goto _8 } goto _9 _6: ; /* * Generate data for image in monochrome mode. No attempt at * dithering is made--instead, just set a threshold. */ mask = uint8(0x80) data = uint8(0x00) xx = x for { if !(xx < x+width) { break } _TkImageGetColor(tls, bp+24, (*(*func(*libc.TLS, uintptr, int32, int32) uint64)(unsafe.Pointer(&struct{ uintptr }{(*TXImage)(unsafe.Pointer(ximage)).Ff.Fget_pixel})))(tls, ximage, xx, yy), bp, bp+8, bp+16) if float64(float64(0.3)**(*float64)(unsafe.Pointer(bp)))+float64(float64(0.59)**(*float64)(unsafe.Pointer(bp + 8)))+float64(float64(0.11)**(*float64)(unsafe.Pointer(bp + 16))) > float64(0.5) { data = uint8(int32(data) | libc.Int32FromUint8(mask)) } mask = uint8(int32(mask) >> libc.Int32FromInt32(1)) if libc.Int32FromUint8(mask) == 0 { libtcl9_0.XTcl_AppendPrintfToObj(tls, psObj, __ccgo_ts+31745, libc.VaList(bp+80, libc.Int32FromUint8(data))) lineLen += int32(2) if lineLen > int32(60) { lineLen = 0 libtcl9_0.XTcl_AppendToObj(tls, psObj, __ccgo_ts+14046, int64(-libc.Int32FromInt32(1))) } mask = uint8(0x80) data = uint8(0x00) } goto _10 _10: ; xx++ } if width%int32(8) != 0 { libtcl9_0.XTcl_AppendPrintfToObj(tls, psObj, __ccgo_ts+31745, libc.VaList(bp+80, libc.Int32FromUint8(data))) mask = uint8(0x80) data = uint8(0x00) } goto _9 _7: ; /* * Generate data in gray mode; in this case, take a weighted * sum of the red, green, and blue values. */ xx = x _13: ; if !(xx < x+width) { goto _11 } _TkImageGetColor(tls, bp+24, (*(*func(*libc.TLS, uintptr, int32, int32) uint64)(unsafe.Pointer(&struct{ uintptr }{(*TXImage)(unsafe.Pointer(ximage)).Ff.Fget_pixel})))(tls, ximage, xx, yy), bp, bp+8, bp+16) libtcl9_0.XTcl_AppendPrintfToObj(tls, psObj, __ccgo_ts+31745, libc.VaList(bp+80, int32(libc.Xfloor(tls, float64(0.5)+float64(float64(255)*(float64(float64(0.3)**(*float64)(unsafe.Pointer(bp)))+float64(float64(0.59)**(*float64)(unsafe.Pointer(bp + 8)))+float64(float64(0.11)**(*float64)(unsafe.Pointer(bp + 16))))))))) lineLen += int32(2) if lineLen > int32(60) { lineLen = 0 libtcl9_0.XTcl_AppendToObj(tls, psObj, __ccgo_ts+14046, int64(-libc.Int32FromInt32(1))) } goto _12 _12: ; xx++ goto _13 goto _11 _11: ; goto _9 _8: ; /* * Finally, color mode. Here, just output the red, green, and * blue values directly. */ xx = x for { if !(xx < x+width) { break } _TkImageGetColor(tls, bp+24, (*(*func(*libc.TLS, uintptr, int32, int32) uint64)(unsafe.Pointer(&struct{ uintptr }{(*TXImage)(unsafe.Pointer(ximage)).Ff.Fget_pixel})))(tls, ximage, xx, yy), bp, bp+8, bp+16) libtcl9_0.XTcl_AppendPrintfToObj(tls, psObj, __ccgo_ts+31750, libc.VaList(bp+80, int32(libc.Xfloor(tls, float64(0.5)+float64(float64(255)**(*float64)(unsafe.Pointer(bp))))), int32(libc.Xfloor(tls, float64(0.5)+float64(float64(255)**(*float64)(unsafe.Pointer(bp + 8))))), int32(libc.Xfloor(tls, float64(0.5)+float64(float64(255)**(*float64)(unsafe.Pointer(bp + 16))))))) lineLen += int32(6) if lineLen > int32(60) { lineLen = 0 libtcl9_0.XTcl_AppendToObj(tls, psObj, __ccgo_ts+14046, int64(-libc.Int32FromInt32(1))) } goto _14 _14: ; xx++ } goto _9 _9: ; goto _5 _5: ; yy-- } switch level { case 0: fallthrough case int32(1): libtcl9_0.XTcl_AppendToObj(tls, psObj, __ccgo_ts+31763, int64(-libc.Int32FromInt32(1))) default: libtcl9_0.XTcl_AppendToObj(tls, psObj, __ccgo_ts+31774, int64(-libc.Int32FromInt32(1))) break } libtcl9_0.XTcl_AppendPrintfToObj(tls, psObj, __ccgo_ts+31798, libc.VaList(bp+80, rows)) goto _3 _3: ; band -= maxRows } libtcl9_0.XTcl_Free(tls, (*(*TTkColormapData)(unsafe.Pointer(bp + 24))).Fcolors) return TCL_OK } /* *-------------------------------------------------------------- * * Tk_PostscriptPhoto -- * * This function is called to output the contents of a photo image in * Postscript, using a format appropriate for the requested postscript * color mode (i.e. one byte per pixel in gray, and three bytes per pixel * in color). * * Results: * Returns a standard Tcl return value. If an error occurs then an error * message will be left in interp->result. If no error occurs, then * additional Postscript will be appended to the interpreter's result. * * Side effects: * None. * *-------------------------------------------------------------- */ func XTk_PostscriptPhoto(tls *libc.TLS, interp uintptr, blockPtr uintptr, psInfo TTk_PostscriptInfo, width int32, height int32) (r int32) { bp := tls.Alloc(64) defer tls.Free(64) var alpha, alphaIncr, alphaOffset, alphaPitch, bpc, bytesPerLine, colorLevel, lineLen, maxWidth, xx, yy, v1, v2 int32 var alphaPtr, decode, displayOperation, pixelPtr, psInfoPtr, psObj uintptr var blue, green, red float32 var data, mask uint8 var _ /* opaque at bp+0 */ uint8 _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = alpha, alphaIncr, alphaOffset, alphaPitch, alphaPtr, blue, bpc, bytesPerLine, colorLevel, data, decode, displayOperation, green, lineLen, mask, maxWidth, pixelPtr, psInfoPtr, psObj, red, xx, yy, v1, v2 psInfoPtr = psInfo colorLevel = (*TTkPostscriptInfo)(unsafe.Pointer(psInfoPtr)).FcolorLevel bytesPerLine = 0 maxWidth = 0 *(*uint8)(unsafe.Pointer(bp)) = uint8(255) if (*TTkPostscriptInfo)(unsafe.Pointer(psInfoPtr)).Fprepass != 0 { return TCL_OK } if colorLevel != 0 { /* * Color and gray-scale code. */ displayOperation = __ccgo_ts + 31814 } else { /* * Monochrome-only code */ displayOperation = __ccgo_ts + 31827 } /* * Check that at least one row of the image can be represented with a * string less than 64 KB long (this is a limit in the Postscript * interpreter). */ switch colorLevel { case 0: bytesPerLine = (width + int32(7)) / int32(8) maxWidth = int32(240000) case int32(1): bytesPerLine = width maxWidth = int32(60000) default: bytesPerLine = int32(3) * width maxWidth = int32(20000) break } if bytesPerLine > int32(60000) { libtcl9_0.XTcl_ResetResult(tls, interp) libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+31645, libc.VaList(bp+16, maxWidth))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+16, __ccgo_ts+179, __ccgo_ts+27003, __ccgo_ts+29550, __ccgo_ts+29553, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) } /* * Set up the postscript code except for the image-data stream. */ psObj = _GetPostscriptBuffer(tls, interp) switch colorLevel { case 0: libtcl9_0.XTcl_AppendToObj(tls, psObj, __ccgo_ts+31839, int64(-libc.Int32FromInt32(1))) decode = __ccgo_ts + 31867 bpc = int32(1) case int32(1): libtcl9_0.XTcl_AppendToObj(tls, psObj, __ccgo_ts+31839, int64(-libc.Int32FromInt32(1))) decode = __ccgo_ts + 31871 bpc = int32(8) default: libtcl9_0.XTcl_AppendToObj(tls, psObj, __ccgo_ts+31875, int64(-libc.Int32FromInt32(1))) decode = __ccgo_ts + 31902 bpc = int32(8) break } libtcl9_0.XTcl_AppendPrintfToObj(tls, psObj, __ccgo_ts+31914, libc.VaList(bp+16, width, height, bpc, height, decode, displayOperation)) /* * Check the PhotoImageBlock information. We assume that: * if pixelSize is 1,2 or 4, the image is R,G,B,A; * if pixelSize is 3, the image is R,G,B and offset[3] is bogus. */ if (*TTk_PhotoImageBlock)(unsafe.Pointer(blockPtr)).FpixelSize == int32(3) { /* * No alpha information: the whole image is opaque. */ alphaPtr = bp v2 = libc.Int32FromInt32(0) alphaOffset = v2 v1 = v2 alphaIncr = v1 alphaPitch = v1 } else { /* * Set up alpha handling. */ alphaPtr = (*TTk_PhotoImageBlock)(unsafe.Pointer(blockPtr)).FpixelPtr alphaPitch = (*TTk_PhotoImageBlock)(unsafe.Pointer(blockPtr)).Fpitch alphaIncr = (*TTk_PhotoImageBlock)(unsafe.Pointer(blockPtr)).FpixelSize alphaOffset = *(*int32)(unsafe.Pointer(blockPtr + 24 + 3*4)) } yy = 0 lineLen = libc.Int32FromInt32(0) for { if !(yy < height) { break } switch colorLevel { case 0: goto _4 case int32(1): goto _5 default: goto _6 } goto _7 _4: ; /* * Generate data for image in monochrome mode. No attempt at * dithering is made--instead, just set a threshold. To handle * transparencies we need to output two lines: one for the black * pixels, one for the white ones. */ mask = uint8(0x80) data = uint8(0x00) xx = 0 for { if !(xx < width) { break } pixelPtr = (*TTk_PhotoImageBlock)(unsafe.Pointer(blockPtr)).FpixelPtr + uintptr(yy*(*TTk_PhotoImageBlock)(unsafe.Pointer(blockPtr)).Fpitch) + uintptr(xx*(*TTk_PhotoImageBlock)(unsafe.Pointer(blockPtr)).FpixelSize) red = float32(*(*uint8)(unsafe.Pointer(pixelPtr + uintptr(*(*int32)(unsafe.Pointer(blockPtr + 24)))))) green = float32(*(*uint8)(unsafe.Pointer(pixelPtr + uintptr(*(*int32)(unsafe.Pointer(blockPtr + 24 + 1*4)))))) blue = float32(*(*uint8)(unsafe.Pointer(pixelPtr + uintptr(*(*int32)(unsafe.Pointer(blockPtr + 24 + 2*4)))))) alpha = libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(alphaPtr + uintptr(yy*alphaPitch) + uintptr(xx*alphaIncr) + uintptr(alphaOffset)))) /* * If pixel is less than threshold, then it is black. */ if alpha != 0 && float64(float64(0.3086)*float64(red))+float64(float64(0.6094)*float64(green))+float64(float64(0.082)*float64(blue)) < libc.Float64FromInt32(128) { data = uint8(int32(data) | libc.Int32FromUint8(mask)) } mask = uint8(int32(mask) >> libc.Int32FromInt32(1)) if libc.Int32FromUint8(mask) == 0 { libtcl9_0.XTcl_AppendPrintfToObj(tls, psObj, __ccgo_ts+31745, libc.VaList(bp+16, libc.Int32FromUint8(data))) lineLen += int32(2) if lineLen >= int32(60) { lineLen = 0 libtcl9_0.XTcl_AppendToObj(tls, psObj, __ccgo_ts+14046, int64(-libc.Int32FromInt32(1))) } mask = uint8(0x80) data = uint8(0x00) } goto _8 _8: ; xx++ } if width%int32(8) != 0 { libtcl9_0.XTcl_AppendPrintfToObj(tls, psObj, __ccgo_ts+31745, libc.VaList(bp+16, libc.Int32FromUint8(data))) mask = uint8(0x80) data = uint8(0x00) } mask = uint8(0x80) data = uint8(0x00) xx = 0 for { if !(xx < width) { break } pixelPtr = (*TTk_PhotoImageBlock)(unsafe.Pointer(blockPtr)).FpixelPtr + uintptr(yy*(*TTk_PhotoImageBlock)(unsafe.Pointer(blockPtr)).Fpitch) + uintptr(xx*(*TTk_PhotoImageBlock)(unsafe.Pointer(blockPtr)).FpixelSize) red = float32(*(*uint8)(unsafe.Pointer(pixelPtr + uintptr(*(*int32)(unsafe.Pointer(blockPtr + 24)))))) green = float32(*(*uint8)(unsafe.Pointer(pixelPtr + uintptr(*(*int32)(unsafe.Pointer(blockPtr + 24 + 1*4)))))) blue = float32(*(*uint8)(unsafe.Pointer(pixelPtr + uintptr(*(*int32)(unsafe.Pointer(blockPtr + 24 + 2*4)))))) alpha = libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(alphaPtr + uintptr(yy*alphaPitch) + uintptr(xx*alphaIncr) + uintptr(alphaOffset)))) /* * If pixel is greater than threshold, then it is white. */ if alpha != 0 && float64(float64(0.3086)*float64(red))+float64(float64(0.6094)*float64(green))+float64(float64(0.082)*float64(blue)) >= libc.Float64FromInt32(128) { data = uint8(int32(data) | libc.Int32FromUint8(mask)) } mask = uint8(int32(mask) >> libc.Int32FromInt32(1)) if libc.Int32FromUint8(mask) == 0 { libtcl9_0.XTcl_AppendPrintfToObj(tls, psObj, __ccgo_ts+31745, libc.VaList(bp+16, libc.Int32FromUint8(data))) lineLen += int32(2) if lineLen >= int32(60) { lineLen = 0 libtcl9_0.XTcl_AppendToObj(tls, psObj, __ccgo_ts+14046, int64(-libc.Int32FromInt32(1))) } mask = uint8(0x80) data = uint8(0x00) } goto _9 _9: ; xx++ } if width%int32(8) != 0 { libtcl9_0.XTcl_AppendPrintfToObj(tls, psObj, __ccgo_ts+31745, libc.VaList(bp+16, libc.Int32FromUint8(data))) mask = uint8(0x80) data = uint8(0x00) } goto _7 _5: ; /* * Generate transparency data. We must prevent a transparent value * of 0 because of a bug in some HP printers. */ xx = 0 for { if !(xx < width) { break } alpha = libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(alphaPtr + uintptr(yy*alphaPitch) + uintptr(xx*alphaIncr) + uintptr(alphaOffset)))) libtcl9_0.XTcl_AppendPrintfToObj(tls, psObj, __ccgo_ts+31745, libc.VaList(bp+16, alpha|int32(0x01))) lineLen += int32(2) if lineLen >= int32(60) { lineLen = 0 libtcl9_0.XTcl_AppendToObj(tls, psObj, __ccgo_ts+14046, int64(-libc.Int32FromInt32(1))) } goto _10 _10: ; xx++ } /* * Generate data in gray mode; in this case, take a weighted sum * of the red, green, and blue values. */ xx = 0 for { if !(xx < width) { break } pixelPtr = (*TTk_PhotoImageBlock)(unsafe.Pointer(blockPtr)).FpixelPtr + uintptr(yy*(*TTk_PhotoImageBlock)(unsafe.Pointer(blockPtr)).Fpitch) + uintptr(xx*(*TTk_PhotoImageBlock)(unsafe.Pointer(blockPtr)).FpixelSize) red = float32(*(*uint8)(unsafe.Pointer(pixelPtr + uintptr(*(*int32)(unsafe.Pointer(blockPtr + 24)))))) green = float32(*(*uint8)(unsafe.Pointer(pixelPtr + uintptr(*(*int32)(unsafe.Pointer(blockPtr + 24 + 1*4)))))) blue = float32(*(*uint8)(unsafe.Pointer(pixelPtr + uintptr(*(*int32)(unsafe.Pointer(blockPtr + 24 + 2*4)))))) libtcl9_0.XTcl_AppendPrintfToObj(tls, psObj, __ccgo_ts+31745, libc.VaList(bp+16, int32(libc.Xfloor(tls, float64(0.5)+(float64(float64(0.3086)*float64(red))+float64(float64(0.6094)*float64(green))+float64(float64(0.082)*float64(blue))))))) lineLen += int32(2) if lineLen >= int32(60) { lineLen = 0 libtcl9_0.XTcl_AppendToObj(tls, psObj, __ccgo_ts+14046, int64(-libc.Int32FromInt32(1))) } goto _11 _11: ; xx++ } goto _7 _6: ; /* * Generate transparency data. We must prevent a transparent value * of 0 because of a bug in some HP printers. */ xx = 0 _14: ; if !(xx < width) { goto _12 } alpha = libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(alphaPtr + uintptr(yy*alphaPitch) + uintptr(xx*alphaIncr) + uintptr(alphaOffset)))) libtcl9_0.XTcl_AppendPrintfToObj(tls, psObj, __ccgo_ts+31745, libc.VaList(bp+16, alpha|int32(0x01))) lineLen += int32(2) if lineLen >= int32(60) { lineLen = 0 libtcl9_0.XTcl_AppendToObj(tls, psObj, __ccgo_ts+14046, int64(-libc.Int32FromInt32(1))) } goto _13 _13: ; xx++ goto _14 goto _12 _12: ; /* * Finally, color mode. Here, just output the red, green, and blue * values directly. */ xx = 0 for { if !(xx < width) { break } pixelPtr = (*TTk_PhotoImageBlock)(unsafe.Pointer(blockPtr)).FpixelPtr + uintptr(yy*(*TTk_PhotoImageBlock)(unsafe.Pointer(blockPtr)).Fpitch) + uintptr(xx*(*TTk_PhotoImageBlock)(unsafe.Pointer(blockPtr)).FpixelSize) libtcl9_0.XTcl_AppendPrintfToObj(tls, psObj, __ccgo_ts+31750, libc.VaList(bp+16, libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(pixelPtr + uintptr(*(*int32)(unsafe.Pointer(blockPtr + 24)))))), libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(pixelPtr + uintptr(*(*int32)(unsafe.Pointer(blockPtr + 24 + 1*4)))))), libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(pixelPtr + uintptr(*(*int32)(unsafe.Pointer(blockPtr + 24 + 2*4)))))))) lineLen += int32(6) if lineLen >= int32(60) { lineLen = 0 libtcl9_0.XTcl_AppendToObj(tls, psObj, __ccgo_ts+14046, int64(-libc.Int32FromInt32(1))) } goto _15 _15: ; xx++ } goto _7 _7: ; goto _3 _3: ; yy++ } /* * The end-of-data marker. */ libtcl9_0.XTcl_AppendToObj(tls, psObj, __ccgo_ts+32086, int64(-libc.Int32FromInt32(1))) return TCL_OK } const M_PI5 = 3.141592653589793 /* * Convenience macro. */ /* * default.h -- * * This file defines the defaults for all options for all of * the Tk widgets. * * Copyright © 1991-1994 The Regents of the University of California. * Copyright © 1994 Sun Microsystems, Inc. * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. */ /* * tkUnixDefault.h -- * * This file defines the defaults for all options for all of * the Tk widgets. * * Copyright © 1991-1994 The Regents of the University of California. * Copyright © 1994-1997 Sun Microsystems, Inc. * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. */ /* * The definitions below provide symbolic names for the default colors. * NORMAL_BG - Normal background color. * ACTIVE_BG - Background color when widget is active. * SELECT_BG - Background color for selected text. * TROUGH - Background color for troughs in scales and scrollbars. * INDICATOR - Color for indicator when button is selected. * DISABLED - Foreground color when widget is disabled. * PLACEHOLDER_FG - Foreground color for placeholder text. */ /* * Defaults for labels, buttons, checkbuttons, and radiobuttons: */ /* * Defaults for canvases: */ /* * Defaults for entries: */ /* * Defaults for frames: */ /* * Defaults for labelframes: */ /* * Defaults for listboxes: */ /* * Defaults for individual entries of menus: */ /* * Defaults for menus overall: */ /* * Defaults for menubuttons: */ /* * Defaults for messages: */ /* * Defaults for panedwindows */ /* * Defaults for panedwindow panes */ /* * Defaults for scales: */ /* * Defaults for scrollbars: */ /* * Defaults for texts: */ /* * Defaults for canvas text: */ /* * Defaults for canvas items * (arcs, bitmaps, lines, polygons, rectangles, and ovals): */ /* * Defaults for toplevels (most of the defaults for frames also apply * to toplevels): */ /* * Defaults for busy windows: */ /* * The structure below defines the record for each text item. */ type TTextItem = struct { Fheader TTk_Item FtextInfoPtr uintptr Fx float64 Fy float64 FinsertPos TTcl_Size Fanchor TTk_Anchor Ftsoffset TTk_TSOffset Fcolor uintptr FactiveColor uintptr FdisabledColor uintptr Ftkfont TTk_Font Fjustify TTk_Justify Fstipple TPixmap FactiveStipple TPixmap FdisabledStipple TPixmap FtextObj uintptr FwidthObj uintptr Funderline int32 Fangle float64 FtextLayout TTk_TextLayout FactualWidth int32 FdrawOrigin [2]float64 Fgc TGC FselTextGC TGC FcursorOffGC TGC Fsine float64 Fcosine float64 } /* * Information used for parsing configuration specs: */ var _stateOption6 = TTk_CustomOption{ FclientData: uintptr(int64(libc.Int32FromInt32(2))), } func init() { p := unsafe.Pointer(&_stateOption6) *(*uintptr)(unsafe.Add(p, 0)) = __ccgo_fp(XTkStateParseProc) *(*uintptr)(unsafe.Add(p, 8)) = __ccgo_fp(XTkStatePrintProc) } var _tagsOption5 = TTk_CustomOption{} func init() { p := unsafe.Pointer(&_tagsOption5) *(*uintptr)(unsafe.Add(p, 0)) = __ccgo_fp(XTk_CanvasTagsParseProc) *(*uintptr)(unsafe.Add(p, 8)) = __ccgo_fp(XTk_CanvasTagsPrintProc) } var _offsetOption4 = TTk_CustomOption{ FclientData: uintptr(int64(libc.Int32FromInt32(TK_OFFSET_RELATIVE))), } func init() { p := unsafe.Pointer(&_offsetOption4) *(*uintptr)(unsafe.Add(p, 0)) = __ccgo_fp(XTkOffsetParseProc) *(*uintptr)(unsafe.Add(p, 8)) = __ccgo_fp(XTkOffsetPrintProc) } func _UnderlineParseProc(tls *libc.TLS, dummy100 uintptr, interp uintptr, dummy102 TTk_Window, value uintptr, widgRec uintptr, offset TTcl_Size) (r int32) { bp := tls.Alloc(96) defer tls.Free(96) /* Offset into item (ignored). */ var code int32 var underlinePtr uintptr var _ /* obj at bp+0 */ TTcl_Obj var _ /* underline at bp+48 */ TTcl_Size _, _ = code, underlinePtr underlinePtr = widgRec + uintptr(offset) if value == libc.UintptrFromInt32(0) || libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(value))) == 0 { *(*int32)(unsafe.Pointer(underlinePtr)) = -libc.Int32FromInt32(1) - libc.Int32FromInt32(0x7fffffff) /* No underline */ return TCL_OK } (*(*TTcl_Obj)(unsafe.Pointer(bp))).FrefCount = int64(1) (*(*TTcl_Obj)(unsafe.Pointer(bp))).Fbytes = value (*(*TTcl_Obj)(unsafe.Pointer(bp))).Flength = libc.Int64FromUint64(libc.Xstrlen(tls, value)) (*(*TTcl_Obj)(unsafe.Pointer(bp))).FtypePtr = libc.UintptrFromInt32(0) code = XTkGetIntForIndex(tls, bp, int64(-libc.Int32FromInt32(1)), 0, bp+48) if code == TCL_OK { if *(*TTcl_Size)(unsafe.Pointer(bp + 48)) < int64(-libc.Int32FromInt32(1)-libc.Int32FromInt32(0x7fffffff)) { *(*TTcl_Size)(unsafe.Pointer(bp + 48)) = int64(-libc.Int32FromInt32(1) - libc.Int32FromInt32(0x7fffffff)) } else { if *(*TTcl_Size)(unsafe.Pointer(bp + 48)) > int64(INT_MAX) { *(*TTcl_Size)(unsafe.Pointer(bp + 48)) = int64(INT_MAX) } } *(*int32)(unsafe.Pointer(underlinePtr)) = int32(*(*TTcl_Size)(unsafe.Pointer(bp + 48))) } else { libtcl9_0.XTcl_AppendResult(tls, interp, libc.VaList(bp+64, __ccgo_ts+7693, value, __ccgo_ts+7705, libc.UintptrFromInt32(0))) } return code } func _UnderlinePrintProc(tls *libc.TLS, dummy139 uintptr, dummy140 TTk_Window, widgRec uintptr, offset TTcl_Size, freeProcPtr uintptr) (r uintptr) { bp := tls.Alloc(16) defer tls.Free(16) /* Pointer to variable to fill in with * information about how to reclaim storage * for return string. */ var p uintptr var underline int32 _, _ = p, underline underline = *(*int32)(unsafe.Pointer(widgRec + uintptr(offset))) if underline == -libc.Int32FromInt32(1)-libc.Int32FromInt32(0x7fffffff) { p = __ccgo_ts + 195 *(*uintptr)(unsafe.Pointer(freeProcPtr)) = libc.UintptrFromInt32(0) return p } else { if underline == int32(INT_MAX) { p = __ccgo_ts + 8120 *(*uintptr)(unsafe.Pointer(freeProcPtr)) = libc.UintptrFromInt32(0) return p } else { if underline == -int32(1) { p = __ccgo_ts + 8126 *(*uintptr)(unsafe.Pointer(freeProcPtr)) = libc.UintptrFromInt32(0) return p } } } p = libtcl9_0.XTcl_Alloc(tls, uint64(32)) if underline < 0 { libc.X__builtin_snprintf(tls, p, uint64(32), __ccgo_ts+8130, libc.VaList(bp+8, int32(1)+underline)) } else { libc.X__builtin_snprintf(tls, p, uint64(32), __ccgo_ts+14540, libc.VaList(bp+8, underline)) } *(*uintptr)(unsafe.Pointer(freeProcPtr)) = libc.UintptrFromInt32(3) return p } var _underlineOption = TTk_CustomOption{} func init() { p := unsafe.Pointer(&_underlineOption) *(*uintptr)(unsafe.Add(p, 0)) = __ccgo_fp(_UnderlineParseProc) *(*uintptr)(unsafe.Add(p, 8)) = __ccgo_fp(_UnderlinePrintProc) } var _configSpecs8 = [17]TTk_ConfigSpec{ 0: { Ftype1: int32(TK_CONFIG_COLOR), FargvName: __ccgo_ts + 28625, Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 176)), FspecFlags: int32(TCL_NULL_OK), }, 1: { Ftype1: int32(TK_CONFIG_BITMAP), FargvName: __ccgo_ts + 28674, Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 216)), FspecFlags: int32(TCL_NULL_OK), }, 2: { Ftype1: int32(TK_CONFIG_ANCHOR), FargvName: __ccgo_ts + 15168, FdefValue: __ccgo_ts + 10959, Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 152)), FspecFlags: libc.Int32FromInt32(1) << libc.Int32FromInt32(3), }, 3: { Ftype1: int32(TK_CONFIG_DOUBLE), FargvName: __ccgo_ts + 32089, FdefValue: __ccgo_ts + 14146, Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 256)), FspecFlags: libc.Int32FromInt32(1) << libc.Int32FromInt32(3), }, 4: { Ftype1: int32(TK_CONFIG_COLOR), FargvName: __ccgo_ts + 28734, Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 184)), FspecFlags: int32(TCL_NULL_OK), }, 5: { Ftype1: int32(TK_CONFIG_BITMAP), FargvName: __ccgo_ts + 28789, Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 224)), FspecFlags: int32(TCL_NULL_OK), }, 6: { Ftype1: int32(TK_CONFIG_COLOR), FargvName: __ccgo_ts + 15184, FdefValue: __ccgo_ts + 19829, Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 168)), FspecFlags: int32(TCL_NULL_OK), }, 7: { Ftype1: int32(TK_CONFIG_FONT), FargvName: __ccgo_ts + 20097, FdefValue: __ccgo_ts + 20108, Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 192)), }, 8: { Ftype1: int32(TK_CONFIG_JUSTIFY), FargvName: __ccgo_ts + 20307, FdefValue: __ccgo_ts + 10966, Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 200)), FspecFlags: libc.Int32FromInt32(1) << libc.Int32FromInt32(3), }, 9: { Ftype1: int32(TK_CONFIG_CUSTOM), FargvName: __ccgo_ts + 26544, FdefValue: __ccgo_ts + 26566, Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 156)), FspecFlags: libc.Int32FromInt32(1) << libc.Int32FromInt32(3), FcustomPtr: uintptr(unsafe.Pointer(&_offsetOption4)), }, 10: { Ftype1: int32(TK_CONFIG_CUSTOM), FargvName: __ccgo_ts + 2957, Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 96)), FspecFlags: int32(TCL_NULL_OK), FcustomPtr: uintptr(unsafe.Pointer(&_stateOption6)), }, 11: { Ftype1: int32(TK_CONFIG_BITMAP), FargvName: __ccgo_ts + 28879, Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 208)), FspecFlags: int32(TCL_NULL_OK), }, 12: { Ftype1: int32(TK_CONFIG_CUSTOM), FargvName: __ccgo_ts + 28895, FspecFlags: int32(TCL_NULL_OK), FcustomPtr: uintptr(unsafe.Pointer(&_tagsOption5)), }, 13: { Ftype1: int32(TK_CONFIG_STRING), FargvName: __ccgo_ts + 20398, FdefValue: __ccgo_ts + 195, Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 232)), FspecFlags: libc.Int32FromInt32(TK_CONFIG_OBJS) | libc.Int32FromInt32(TCL_NULL_OK), }, 14: { Ftype1: int32(TK_CONFIG_CUSTOM), FargvName: __ccgo_ts + 9507, Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 248)), FspecFlags: int32(TCL_NULL_OK), FcustomPtr: uintptr(unsafe.Pointer(&_underlineOption)), }, 15: { Ftype1: int32(TK_CONFIG_PIXELS), FargvName: __ccgo_ts + 2987, FdefValue: __ccgo_ts + 10533, Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 240)), FspecFlags: int32(TK_CONFIG_OBJS), }, 16: { Ftype1: int32(TK_CONFIG_END), }, } func init() { p := unsafe.Pointer(&XtkTextType) *(*uintptr)(unsafe.Add(p, 16)) = __ccgo_fp(_CreateText) *(*uintptr)(unsafe.Add(p, 32)) = __ccgo_fp(_ConfigureText) *(*uintptr)(unsafe.Add(p, 40)) = __ccgo_fp(_TextCoords) *(*uintptr)(unsafe.Add(p, 48)) = __ccgo_fp(_DeleteText) *(*uintptr)(unsafe.Add(p, 56)) = __ccgo_fp(_DisplayCanvText) *(*uintptr)(unsafe.Add(p, 72)) = __ccgo_fp(_TextToPoint) *(*uintptr)(unsafe.Add(p, 80)) = __ccgo_fp(_TextToArea) *(*uintptr)(unsafe.Add(p, 88)) = __ccgo_fp(_TextToPostscript) *(*uintptr)(unsafe.Add(p, 96)) = __ccgo_fp(_ScaleText) *(*uintptr)(unsafe.Add(p, 104)) = __ccgo_fp(_TranslateText) *(*uintptr)(unsafe.Add(p, 112)) = __ccgo_fp(_GetTextIndex) *(*uintptr)(unsafe.Add(p, 120)) = __ccgo_fp(_SetTextCursor) *(*uintptr)(unsafe.Add(p, 128)) = __ccgo_fp(_GetSelText) *(*uintptr)(unsafe.Add(p, 136)) = __ccgo_fp(_TextInsert) *(*uintptr)(unsafe.Add(p, 144)) = __ccgo_fp(_TextDeleteChars) *(*uintptr)(unsafe.Add(p, 160)) = __ccgo_fp(_RotateText) } /* *-------------------------------------------------------------- * * CreateText -- * * This function is invoked to create a new text item in a canvas. * * Results: * A standard Tcl return value. If an error occurred in creating the item * then an error message is left in the interp's result; in this case * itemPtr is left uninitialized so it can be safely freed by the caller. * * Side effects: * A new text item is created. * *-------------------------------------------------------------- */ func _CreateText(tls *libc.TLS, interp uintptr, canvas TTk_Canvas, itemPtr uintptr, objc TTcl_Size, objv uintptr) (r int32) { /* Arguments describing rectangle. */ var arg, textPtr uintptr var i TTcl_Size var v1 float64 _, _, _, _ = arg, i, textPtr, v1 textPtr = itemPtr if objc == 0 { libtcl9_0.XTcl_Panic(tls, __ccgo_ts+28901, 0) } /* * Carry out initialization that is needed in order to clean up after * errors during the the remainder of this function. */ (*TTextItem)(unsafe.Pointer(textPtr)).FtextInfoPtr = XTk_CanvasGetTextInfo(tls, canvas) (*TTextItem)(unsafe.Pointer(textPtr)).FinsertPos = 0 (*TTextItem)(unsafe.Pointer(textPtr)).Fanchor = int32(TK_ANCHOR_CENTER) (*TTextItem)(unsafe.Pointer(textPtr)).Ftsoffset.Fflags = 0 (*TTextItem)(unsafe.Pointer(textPtr)).Ftsoffset.Fxoffset = 0 (*TTextItem)(unsafe.Pointer(textPtr)).Ftsoffset.Fyoffset = 0 (*TTextItem)(unsafe.Pointer(textPtr)).Fcolor = libc.UintptrFromInt32(0) (*TTextItem)(unsafe.Pointer(textPtr)).FactiveColor = libc.UintptrFromInt32(0) (*TTextItem)(unsafe.Pointer(textPtr)).FdisabledColor = libc.UintptrFromInt32(0) (*TTextItem)(unsafe.Pointer(textPtr)).Ftkfont = libc.UintptrFromInt32(0) (*TTextItem)(unsafe.Pointer(textPtr)).Fjustify = int32(TK_JUSTIFY_LEFT) (*TTextItem)(unsafe.Pointer(textPtr)).Fstipple = uint64(0) (*TTextItem)(unsafe.Pointer(textPtr)).FactiveStipple = uint64(0) (*TTextItem)(unsafe.Pointer(textPtr)).FdisabledStipple = uint64(0) (*TTextItem)(unsafe.Pointer(textPtr)).FtextObj = libc.UintptrFromInt32(0) (*TTextItem)(unsafe.Pointer(textPtr)).FwidthObj = libc.UintptrFromInt32(0) (*TTextItem)(unsafe.Pointer(textPtr)).Funderline = -libc.Int32FromInt32(1) - libc.Int32FromInt32(0x7fffffff) (*TTextItem)(unsafe.Pointer(textPtr)).Fangle = float64(0) (*TTextItem)(unsafe.Pointer(textPtr)).FtextLayout = libc.UintptrFromInt32(0) (*TTextItem)(unsafe.Pointer(textPtr)).FactualWidth = 0 v1 = libc.Float64FromFloat64(0) *(*float64)(unsafe.Pointer(textPtr + 280 + 1*8)) = v1 *(*float64)(unsafe.Pointer(textPtr + 280)) = v1 (*TTextItem)(unsafe.Pointer(textPtr)).Fgc = libc.UintptrFromInt32(0) (*TTextItem)(unsafe.Pointer(textPtr)).FselTextGC = libc.UintptrFromInt32(0) (*TTextItem)(unsafe.Pointer(textPtr)).FcursorOffGC = libc.UintptrFromInt32(0) (*TTextItem)(unsafe.Pointer(textPtr)).Fsine = float64(0) (*TTextItem)(unsafe.Pointer(textPtr)).Fcosine = float64(1) /* * Process the arguments to fill in the item record. Only 1 (list) or 2 (x * y) coords are allowed. */ if objc == int64(1) { i = int64(1) } else { arg = libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8)), libc.UintptrFromInt32(0)) i = int64(2) if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(arg))) == int32('-') && libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(arg + 1))) >= int32('a') && libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(arg + 1))) <= int32('z') { i = int64(1) } } if _TextCoords(tls, interp, canvas, itemPtr, i, objv) != TCL_OK { goto error } if _ConfigureText(tls, interp, canvas, itemPtr, objc-i, objv+uintptr(i)*8, 0) == TCL_OK { return TCL_OK } goto error error: ; _DeleteText(tls, canvas, itemPtr, (*TTk_FakeWin)(unsafe.Pointer(XTk_CanvasTkwin(tls, canvas))).Fdisplay) return int32(TCL_ERROR) } /* *-------------------------------------------------------------- * * TextCoords -- * * This function is invoked to process the "coords" widget command on * text items. See the user documentation for details on what it does. * * Results: * Returns TCL_OK or TCL_ERROR, and sets the interp's result. * * Side effects: * The coordinates for the given item may be changed. * *-------------------------------------------------------------- */ func _TextCoords(tls *libc.TLS, interp uintptr, canvas TTk_Canvas, itemPtr uintptr, _objc TTcl_Size, _objv uintptr) (r int32) { bp := tls.Alloc(64) defer tls.Free(64) *(*TTcl_Size)(unsafe.Pointer(bp)) = _objc *(*uintptr)(unsafe.Pointer(bp + 8)) = _objv /* Array of coordinates: x1, y1, x2, y2, ... */ var obj, subobj, textPtr uintptr _, _, _ = obj, subobj, textPtr textPtr = itemPtr if *(*TTcl_Size)(unsafe.Pointer(bp)) == 0 { obj = libtcl9_0.XTcl_NewObj(tls) subobj = libtcl9_0.XTcl_NewDoubleObj(tls, (*TTextItem)(unsafe.Pointer(textPtr)).Fx) libtcl9_0.XTcl_ListObjAppendElement(tls, interp, obj, subobj) subobj = libtcl9_0.XTcl_NewDoubleObj(tls, (*TTextItem)(unsafe.Pointer(textPtr)).Fy) libtcl9_0.XTcl_ListObjAppendElement(tls, interp, obj, subobj) libtcl9_0.XTcl_SetObjResult(tls, interp, obj) return TCL_OK } else { if *(*TTcl_Size)(unsafe.Pointer(bp)) > int64(2) { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+29369, libc.VaList(bp+24, *(*TTcl_Size)(unsafe.Pointer(bp))))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+24, __ccgo_ts+179, __ccgo_ts+27003, __ccgo_ts+28973, __ccgo_ts+16417, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) } } if *(*TTcl_Size)(unsafe.Pointer(bp)) == int64(1) { if libtcl9_0.XTcl_ListObjGetElements(tls, interp, *(*uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 8)))), bp, bp+8) != TCL_OK { return int32(TCL_ERROR) } else { if *(*TTcl_Size)(unsafe.Pointer(bp)) != int64(2) { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+29328, libc.VaList(bp+24, *(*TTcl_Size)(unsafe.Pointer(bp))))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+24, __ccgo_ts+179, __ccgo_ts+27003, __ccgo_ts+28973, __ccgo_ts+16417, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) } } } if XTk_CanvasGetCoordFromObj(tls, interp, canvas, *(*uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 8)))), textPtr+128) != TCL_OK || XTk_CanvasGetCoordFromObj(tls, interp, canvas, *(*uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 8)) + 1*8)), textPtr+136) != TCL_OK { return int32(TCL_ERROR) } _ComputeTextBbox(tls, canvas, textPtr) return TCL_OK } /* *-------------------------------------------------------------- * * ConfigureText -- * * This function is invoked to configure various aspects of a text item, * such as its border and background colors. * * Results: * A standard Tcl result code. If an error occurs, then an error message * is left in the interp's result. * * Side effects: * Configuration information, such as colors and stipple patterns, may be * set for itemPtr. * *-------------------------------------------------------------- */ func _ConfigureText(tls *libc.TLS, interp uintptr, canvas TTk_Canvas, itemPtr uintptr, objc TTcl_Size, objv uintptr, flags int32) (r int32) { bp := tls.Alloc(128) defer tls.Free(128) /* Flags to pass to Tk_ConfigureWidget. */ var color, selBgColorPtr, textInfoPtr, textPtr uintptr var mask uint64 var newGC, newSelGC, v1 TGC var numChars TTcl_Size var state TTk_State var stipple TPixmap var tkwin TTk_Window var v2 int64 var _ /* gcValues at bp+0 */ TXGCValues _, _, _, _, _, _, _, _, _, _, _, _, _ = color, mask, newGC, newSelGC, numChars, selBgColorPtr, state, stipple, textInfoPtr, textPtr, tkwin, v1, v2 textPtr = itemPtr textInfoPtr = (*TTextItem)(unsafe.Pointer(textPtr)).FtextInfoPtr tkwin = XTk_CanvasTkwin(tls, canvas) if TCL_OK != XTk_ConfigureWidget(tls, interp, tkwin, uintptr(unsafe.Pointer(&_configSpecs8)), objc, objv, textPtr, flags) { return int32(TCL_ERROR) } /* * A few of the options require additional processing, such as graphics * contexts. */ state = (*TTk_Item)(unsafe.Pointer(itemPtr)).Fstate if (*TTextItem)(unsafe.Pointer(textPtr)).FactiveColor != libc.UintptrFromInt32(0) || (*TTextItem)(unsafe.Pointer(textPtr)).FactiveStipple != uint64(0) { *(*int32)(unsafe.Pointer(itemPtr + 112)) |= int32(TK_ITEM_STATE_DEPENDANT) } else { *(*int32)(unsafe.Pointer(itemPtr + 112)) &= ^libc.Int32FromInt32(TK_ITEM_STATE_DEPENDANT) } if state == int32(TK_STATE_NULL) { state = (*TTkCanvas)(unsafe.Pointer(canvas)).Fcanvas_state } color = (*TTextItem)(unsafe.Pointer(textPtr)).Fcolor stipple = (*TTextItem)(unsafe.Pointer(textPtr)).Fstipple if (*TTkCanvas)(unsafe.Pointer(canvas)).FcurrentItemPtr == itemPtr { if (*TTextItem)(unsafe.Pointer(textPtr)).FactiveColor != libc.UintptrFromInt32(0) { color = (*TTextItem)(unsafe.Pointer(textPtr)).FactiveColor } if (*TTextItem)(unsafe.Pointer(textPtr)).FactiveStipple != uint64(0) { stipple = (*TTextItem)(unsafe.Pointer(textPtr)).FactiveStipple } } else { if state == int32(TK_STATE_DISABLED) { if (*TTextItem)(unsafe.Pointer(textPtr)).FdisabledColor != libc.UintptrFromInt32(0) { color = (*TTextItem)(unsafe.Pointer(textPtr)).FdisabledColor } if (*TTextItem)(unsafe.Pointer(textPtr)).FdisabledStipple != uint64(0) { stipple = (*TTextItem)(unsafe.Pointer(textPtr)).FdisabledStipple } } } v1 = libc.UintptrFromInt32(0) newSelGC = v1 newGC = v1 if (*TTextItem)(unsafe.Pointer(textPtr)).Ftkfont != libc.UintptrFromInt32(0) { (*(*TXGCValues)(unsafe.Pointer(bp))).Ffont = XTk_FontId(tls, (*TTextItem)(unsafe.Pointer(textPtr)).Ftkfont) mask = libc.Uint64FromInt64(libc.Int64FromInt64(1) << libc.Int32FromInt32(14)) if color != libc.UintptrFromInt32(0) { (*(*TXGCValues)(unsafe.Pointer(bp))).Fforeground = (*TXColor)(unsafe.Pointer(color)).Fpixel mask |= libc.Uint64FromInt64(libc.Int64FromInt64(1) << libc.Int32FromInt32(2)) if stipple != uint64(0) { (*(*TXGCValues)(unsafe.Pointer(bp))).Fstipple = stipple (*(*TXGCValues)(unsafe.Pointer(bp))).Ffill_style = int32(FillStippled) mask |= libc.Uint64FromInt64(libc.Int64FromInt64(1)<= numChars { (*TTk_CanvasTextInfo)(unsafe.Pointer(textInfoPtr)).FselItemPtr = libc.UintptrFromInt32(0) } else { if (*TTk_CanvasTextInfo)(unsafe.Pointer(textInfoPtr)).FselectLast >= numChars { (*TTk_CanvasTextInfo)(unsafe.Pointer(textInfoPtr)).FselectLast = numChars - int64(1) } if (*TTk_CanvasTextInfo)(unsafe.Pointer(textInfoPtr)).FanchorItemPtr == itemPtr && (*TTk_CanvasTextInfo)(unsafe.Pointer(textInfoPtr)).FselectAnchor >= numChars { (*TTk_CanvasTextInfo)(unsafe.Pointer(textInfoPtr)).FselectAnchor = numChars - int64(1) } } } if (*TTextItem)(unsafe.Pointer(textPtr)).FinsertPos >= numChars { (*TTextItem)(unsafe.Pointer(textPtr)).FinsertPos = numChars } /* * Restrict so that 0.0 <= angle < 360.0, and then recompute the cached * sine and cosine of the angle. Note that fmod() can produce negative * results, and we try to avoid negative zero as well. */ (*TTextItem)(unsafe.Pointer(textPtr)).Fangle = libc.Xfmod(tls, (*TTextItem)(unsafe.Pointer(textPtr)).Fangle, float64(360)) if (*TTextItem)(unsafe.Pointer(textPtr)).Fangle < float64(0) { *(*float64)(unsafe.Pointer(textPtr + 256)) += float64(360) } if (*TTextItem)(unsafe.Pointer(textPtr)).Fangle == float64(0) { (*TTextItem)(unsafe.Pointer(textPtr)).Fangle = float64(0) } (*TTextItem)(unsafe.Pointer(textPtr)).Fsine = libc.Xsin(tls, float64((*TTextItem)(unsafe.Pointer(textPtr)).Fangle*float64(3.141592653589793))/float64(180)) (*TTextItem)(unsafe.Pointer(textPtr)).Fcosine = libc.Xcos(tls, float64((*TTextItem)(unsafe.Pointer(textPtr)).Fangle*float64(3.141592653589793))/float64(180)) _ComputeTextBbox(tls, canvas, textPtr) return TCL_OK } /* *-------------------------------------------------------------- * * DeleteText -- * * This function is called to clean up the data structure associated with * a text item. * * Results: * None. * * Side effects: * Resources associated with itemPtr are released. * *-------------------------------------------------------------- */ func _DeleteText(tls *libc.TLS, dummy646 TTk_Canvas, itemPtr uintptr, display uintptr) { /* Display containing window for canvas. */ var _objPtr, textPtr, v2 uintptr var v1 TTcl_Size _, _, _, _ = _objPtr, textPtr, v1, v2 textPtr = itemPtr if (*TTextItem)(unsafe.Pointer(textPtr)).Fcolor != libc.UintptrFromInt32(0) { XTk_FreeColor(tls, (*TTextItem)(unsafe.Pointer(textPtr)).Fcolor) } if (*TTextItem)(unsafe.Pointer(textPtr)).FactiveColor != libc.UintptrFromInt32(0) { XTk_FreeColor(tls, (*TTextItem)(unsafe.Pointer(textPtr)).FactiveColor) } if (*TTextItem)(unsafe.Pointer(textPtr)).FdisabledColor != libc.UintptrFromInt32(0) { XTk_FreeColor(tls, (*TTextItem)(unsafe.Pointer(textPtr)).FdisabledColor) } XTk_FreeFont(tls, (*TTextItem)(unsafe.Pointer(textPtr)).Ftkfont) if (*TTextItem)(unsafe.Pointer(textPtr)).Fstipple != uint64(0) { XTk_FreeBitmap(tls, display, (*TTextItem)(unsafe.Pointer(textPtr)).Fstipple) } if (*TTextItem)(unsafe.Pointer(textPtr)).FactiveStipple != uint64(0) { XTk_FreeBitmap(tls, display, (*TTextItem)(unsafe.Pointer(textPtr)).FactiveStipple) } if (*TTextItem)(unsafe.Pointer(textPtr)).FdisabledStipple != uint64(0) { XTk_FreeBitmap(tls, display, (*TTextItem)(unsafe.Pointer(textPtr)).FdisabledStipple) } if (*TTextItem)(unsafe.Pointer(textPtr)).FtextObj != libc.UintptrFromInt32(0) { _objPtr = (*TTextItem)(unsafe.Pointer(textPtr)).FtextObj v2 = _objPtr v1 = *(*TTcl_Size)(unsafe.Pointer(v2)) *(*TTcl_Size)(unsafe.Pointer(v2))-- if v1 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr) } } XTk_FreeTextLayout(tls, (*TTextItem)(unsafe.Pointer(textPtr)).FtextLayout) if (*TTextItem)(unsafe.Pointer(textPtr)).Fgc != libc.UintptrFromInt32(0) { XTk_FreeGC(tls, display, (*TTextItem)(unsafe.Pointer(textPtr)).Fgc) } if (*TTextItem)(unsafe.Pointer(textPtr)).FselTextGC != libc.UintptrFromInt32(0) { XTk_FreeGC(tls, display, (*TTextItem)(unsafe.Pointer(textPtr)).FselTextGC) } if (*TTextItem)(unsafe.Pointer(textPtr)).FcursorOffGC != libc.UintptrFromInt32(0) { XTk_FreeGC(tls, display, (*TTextItem)(unsafe.Pointer(textPtr)).FcursorOffGC) } } /* *-------------------------------------------------------------- * * ComputeTextBbox -- * * This function is invoked to compute the bounding box of all the pixels * that may be drawn as part of a text item. In addition, it recomputes * all of the geometry information used to display a text item or check * for mouse hits. * * Results: * None. * * Side effects: * The fields x1, y1, x2, and y2 are updated in the header for itemPtr, * and the linePtr structure is regenerated for itemPtr. * *-------------------------------------------------------------- */ func _ComputeTextBbox(tls *libc.TLS, canvas TTk_Canvas, textPtr uintptr) { bp := tls.Alloc(80) defer tls.Free(80) /* Item whose bbox is to be recomputed. */ var cosA, sinA, tmp, v5 float64 var fudge, i, v3 int32 var numChars TTcl_Size var state TTk_State var textInfoPtr, v2 uintptr var x, y [4]float64 var v1 int64 var _ /* dx at bp+8 */ [4]float64 var _ /* dy at bp+40 */ [4]float64 var _ /* height at bp+4 */ int32 var _ /* width at bp+0 */ int32 _, _, _, _, _, _, _, _, _, _, _, _, _, _ = cosA, fudge, i, numChars, sinA, state, textInfoPtr, tmp, x, y, v1, v2, v3, v5 state = (*TTextItem)(unsafe.Pointer(textPtr)).Fheader.Fstate if state == int32(TK_STATE_NULL) { state = (*TTkCanvas)(unsafe.Pointer(canvas)).Fcanvas_state } XTk_FreeTextLayout(tls, (*TTextItem)(unsafe.Pointer(textPtr)).FtextLayout) *(*int32)(unsafe.Pointer(bp)) = 0 if (*TTextItem)(unsafe.Pointer(textPtr)).FwidthObj != 0 { XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), XTk_CanvasTkwin(tls, canvas), (*TTextItem)(unsafe.Pointer(textPtr)).FwidthObj, bp) } if (*TTextItem)(unsafe.Pointer(textPtr)).FtextObj != 0 { v1 = libtcl9_0.XTcl_GetCharLength(tls, (*TTextItem)(unsafe.Pointer(textPtr)).FtextObj) } else { v1 = 0 } numChars = v1 if (*TTextItem)(unsafe.Pointer(textPtr)).FtextObj != 0 { v2 = libtcl9_0.XTcl_GetStringFromObj(tls, (*TTextItem)(unsafe.Pointer(textPtr)).FtextObj, libc.UintptrFromInt32(0)) } else { v2 = __ccgo_ts + 195 } (*TTextItem)(unsafe.Pointer(textPtr)).FtextLayout = XTk_ComputeTextLayout(tls, (*TTextItem)(unsafe.Pointer(textPtr)).Ftkfont, v2, numChars, *(*int32)(unsafe.Pointer(bp)), (*TTextItem)(unsafe.Pointer(textPtr)).Fjustify, 0, bp, bp+4) if state == int32(TK_STATE_HIDDEN) || (*TTextItem)(unsafe.Pointer(textPtr)).Fcolor == libc.UintptrFromInt32(0) { v3 = libc.Int32FromInt32(0) *(*int32)(unsafe.Pointer(bp + 4)) = v3 *(*int32)(unsafe.Pointer(bp)) = v3 } /* * Use overall geometry information to compute the top-left corner of the * bounding box for the text item. */ i = 0 for { if !(i < int32(4)) { break } v5 = libc.Float64FromFloat64(0) (*(*[4]float64)(unsafe.Pointer(bp + 40)))[i] = v5 (*(*[4]float64)(unsafe.Pointer(bp + 8)))[i] = v5 goto _4 _4: ; i++ } switch (*TTextItem)(unsafe.Pointer(textPtr)).Fanchor { case int32(TK_ANCHOR_NE): goto _6 case int32(TK_ANCHOR_N): goto _7 case int32(TK_ANCHOR_NW): goto _8 case int32(TK_ANCHOR_SE): goto _9 case int32(TK_ANCHOR_S): goto _10 case int32(TK_ANCHOR_SW): goto _11 default: goto _12 } goto _13 _8: ; _7: ; _6: ; goto _13 _11: ; _10: ; _9: ; i = 0 _16: ; if !(i < int32(4)) { goto _14 } (*(*[4]float64)(unsafe.Pointer(bp + 40)))[i] = float64(-*(*int32)(unsafe.Pointer(bp + 4))) goto _15 _15: ; i++ goto _16 goto _14 _14: ; goto _13 _12: ; i = 0 for { if !(i < int32(4)) { break } (*(*[4]float64)(unsafe.Pointer(bp + 40)))[i] = float64(-*(*int32)(unsafe.Pointer(bp + 4)) / int32(2)) goto _17 _17: ; i++ } goto _13 _13: ; switch (*TTextItem)(unsafe.Pointer(textPtr)).Fanchor { case int32(TK_ANCHOR_SW): goto _18 case int32(TK_ANCHOR_W): goto _19 case int32(TK_ANCHOR_NW): goto _20 case int32(TK_ANCHOR_SE): goto _21 case int32(TK_ANCHOR_E): goto _22 case int32(TK_ANCHOR_NE): goto _23 default: goto _24 } goto _25 _20: ; _19: ; _18: ; goto _25 _23: ; _22: ; _21: ; i = 0 _28: ; if !(i < int32(4)) { goto _26 } (*(*[4]float64)(unsafe.Pointer(bp + 8)))[i] = float64(-*(*int32)(unsafe.Pointer(bp))) goto _27 _27: ; i++ goto _28 goto _26 _26: ; goto _25 _24: ; i = 0 for { if !(i < int32(4)) { break } (*(*[4]float64)(unsafe.Pointer(bp + 8)))[i] = float64(-*(*int32)(unsafe.Pointer(bp)) / int32(2)) goto _29 _29: ; i++ } goto _25 _25: ; (*TTextItem)(unsafe.Pointer(textPtr)).FactualWidth = *(*int32)(unsafe.Pointer(bp)) sinA = (*TTextItem)(unsafe.Pointer(textPtr)).Fsine cosA = (*TTextItem)(unsafe.Pointer(textPtr)).Fcosine *(*float64)(unsafe.Pointer(textPtr + 280)) = (*TTextItem)(unsafe.Pointer(textPtr)).Fx + float64((*(*[4]float64)(unsafe.Pointer(bp + 8)))[0]*cosA) + float64((*(*[4]float64)(unsafe.Pointer(bp + 40)))[0]*sinA) *(*float64)(unsafe.Pointer(textPtr + 280 + 1*8)) = (*TTextItem)(unsafe.Pointer(textPtr)).Fy + float64((*(*[4]float64)(unsafe.Pointer(bp + 40)))[0]*cosA) - float64((*(*[4]float64)(unsafe.Pointer(bp + 8)))[0]*sinA) /* * Last of all, update the bounding box for the item. The item's bounding * box includes the bounding box of all its lines, plus an extra fudge * factor for the cursor border (which could potentially be quite large). */ textInfoPtr = (*TTextItem)(unsafe.Pointer(textPtr)).FtextInfoPtr XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), XTk_CanvasTkwin(tls, canvas), (*TTk_CanvasTextInfo)(unsafe.Pointer(textInfoPtr)).Freserved2, textInfoPtr+72) XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), XTk_CanvasTkwin(tls, canvas), (*TTk_CanvasTextInfo)(unsafe.Pointer(textInfoPtr)).Freserved3, textInfoPtr+8) fudge = ((*TTk_CanvasTextInfo)(unsafe.Pointer(textInfoPtr)).FinsertWidth + int32(1)) / int32(2) if (*TTk_CanvasTextInfo)(unsafe.Pointer(textInfoPtr)).FselBorderWidth > fudge { fudge = (*TTk_CanvasTextInfo)(unsafe.Pointer(textInfoPtr)).FselBorderWidth } /* * Apply the rotation before computing the bounding box. */ *(*float64)(unsafe.Pointer(bp + 8)) -= float64(fudge) *(*float64)(unsafe.Pointer(bp + 8 + 1*8)) += float64(*(*int32)(unsafe.Pointer(bp)) + fudge) *(*float64)(unsafe.Pointer(bp + 8 + 2*8)) += float64(*(*int32)(unsafe.Pointer(bp)) + fudge) *(*float64)(unsafe.Pointer(bp + 40 + 2*8)) += float64(*(*int32)(unsafe.Pointer(bp + 4))) *(*float64)(unsafe.Pointer(bp + 8 + 3*8)) -= float64(fudge) *(*float64)(unsafe.Pointer(bp + 40 + 3*8)) += float64(*(*int32)(unsafe.Pointer(bp + 4))) i = 0 for { if !(i < int32(4)) { break } x[i] = (*TTextItem)(unsafe.Pointer(textPtr)).Fx + float64((*(*[4]float64)(unsafe.Pointer(bp + 8)))[i]*cosA) + float64((*(*[4]float64)(unsafe.Pointer(bp + 40)))[i]*sinA) y[i] = (*TTextItem)(unsafe.Pointer(textPtr)).Fy + float64((*(*[4]float64)(unsafe.Pointer(bp + 40)))[i]*cosA) - float64((*(*[4]float64)(unsafe.Pointer(bp + 8)))[i]*sinA) goto _30 _30: ; i++ } /* * Convert to a rectilinear bounding box. */ i = int32(1) tmp = x[0] for { if !(i < int32(4)) { break } if x[i] < tmp { tmp = x[i] } goto _31 _31: ; i++ } (*TTextItem)(unsafe.Pointer(textPtr)).Fheader.Fx1 = int32(libc.Xfloor(tls, tmp+float64(0.5))) i = int32(1) tmp = y[0] for { if !(i < int32(4)) { break } if y[i] < tmp { tmp = y[i] } goto _32 _32: ; i++ } (*TTextItem)(unsafe.Pointer(textPtr)).Fheader.Fy1 = int32(libc.Xfloor(tls, tmp+float64(0.5))) i = int32(1) tmp = x[0] for { if !(i < int32(4)) { break } if x[i] > tmp { tmp = x[i] } goto _33 _33: ; i++ } (*TTextItem)(unsafe.Pointer(textPtr)).Fheader.Fx2 = int32(libc.Xfloor(tls, tmp+float64(0.5))) i = int32(1) tmp = y[0] for { if !(i < int32(4)) { break } if y[i] > tmp { tmp = y[i] } goto _34 _34: ; i++ } (*TTextItem)(unsafe.Pointer(textPtr)).Fheader.Fy2 = int32(libc.Xfloor(tls, tmp+float64(0.5))) } /* *-------------------------------------------------------------- * * DisplayCanvText -- * * This function is invoked to draw a text item in a given drawable. * * Results: * None. * * Side effects: * ItemPtr is drawn in drawable using the transformation information in * canvas. * *-------------------------------------------------------------- */ func _DisplayCanvText(tls *libc.TLS, canvas TTk_Canvas, itemPtr uintptr, display uintptr, drawable TDrawable, _x int32, _y int32, width int32, _height int32) { bp := tls.Alloc(80) defer tls.Free(80) *(*int32)(unsafe.Pointer(bp)) = _x *(*int32)(unsafe.Pointer(bp + 4)) = _y *(*int32)(unsafe.Pointer(bp + 8)) = _height /* Describes region of canvas that must be * redisplayed (not used). */ var c, c1, s, s1 float64 var dx1, dx11, dx2, dx21, dy1, dy11, dy2, dy21 int32 var numChars, selFirstChar, selLastChar TTcl_Size var state TTk_State var stipple TPixmap var textInfoPtr, textPtr uintptr var v1 int64 var _ /* drawableX at bp+12 */ int16 var _ /* drawableY at bp+14 */ int16 var _ /* hFirst at bp+24 */ int32 var _ /* points at bp+40 */ [4]TXPoint var _ /* points at bp+56 */ [4]TXPoint var _ /* wLast at bp+36 */ int32 var _ /* xFirst at bp+16 */ int32 var _ /* xLast at bp+28 */ int32 var _ /* yFirst at bp+20 */ int32 var _ /* yLast at bp+32 */ int32 _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = c, c1, dx1, dx11, dx2, dx21, dy1, dy11, dy2, dy21, numChars, s, s1, selFirstChar, selLastChar, state, stipple, textInfoPtr, textPtr, v1 state = (*TTk_Item)(unsafe.Pointer(itemPtr)).Fstate textPtr = itemPtr textInfoPtr = (*TTextItem)(unsafe.Pointer(textPtr)).FtextInfoPtr if state == int32(TK_STATE_NULL) { state = (*TTkCanvas)(unsafe.Pointer(canvas)).Fcanvas_state } stipple = (*TTextItem)(unsafe.Pointer(textPtr)).Fstipple if (*TTkCanvas)(unsafe.Pointer(canvas)).FcurrentItemPtr == itemPtr { if (*TTextItem)(unsafe.Pointer(textPtr)).FactiveStipple != uint64(0) { stipple = (*TTextItem)(unsafe.Pointer(textPtr)).FactiveStipple } } else { if state == int32(TK_STATE_DISABLED) { if (*TTextItem)(unsafe.Pointer(textPtr)).FdisabledStipple != uint64(0) { stipple = (*TTextItem)(unsafe.Pointer(textPtr)).FdisabledStipple } } } if (*TTextItem)(unsafe.Pointer(textPtr)).Fgc == libc.UintptrFromInt32(0) { return } /* * If we're stippling, then modify the stipple offset in the GC. Be sure * to reset the offset when done, since the GC is supposed to be * read-only. */ if stipple != uint64(0) { XTk_CanvasSetOffset(tls, canvas, (*TTextItem)(unsafe.Pointer(textPtr)).Fgc, textPtr+156) } selFirstChar = int64(-libc.Int32FromInt32(1)) selLastChar = 0 XTk_CanvasDrawableCoords(tls, canvas, *(*float64)(unsafe.Pointer(textPtr + 280)), *(*float64)(unsafe.Pointer(textPtr + 280 + 1*8)), bp+12, bp+14) if (*TTextItem)(unsafe.Pointer(textPtr)).FtextObj != 0 { v1 = libtcl9_0.XTcl_GetCharLength(tls, (*TTextItem)(unsafe.Pointer(textPtr)).FtextObj) } else { v1 = 0 } numChars = v1 if (*TTk_CanvasTextInfo)(unsafe.Pointer(textInfoPtr)).FselItemPtr == itemPtr { selFirstChar = (*TTk_CanvasTextInfo)(unsafe.Pointer(textInfoPtr)).FselectFirst selLastChar = (*TTk_CanvasTextInfo)(unsafe.Pointer(textInfoPtr)).FselectLast if selLastChar > numChars { selLastChar = numChars - int64(1) } if selFirstChar >= 0 && selFirstChar <= selLastChar { /* * Draw a special background under the selection. */ XTk_CharBbox(tls, (*TTextItem)(unsafe.Pointer(textPtr)).FtextLayout, selFirstChar, bp+16, bp+20, libc.UintptrFromInt32(0), bp+24) XTk_CharBbox(tls, (*TTextItem)(unsafe.Pointer(textPtr)).FtextLayout, selLastChar, bp+28, bp+32, bp+36, libc.UintptrFromInt32(0)) /* * If the selection spans the end of this line, then display * selection background all the way to the end of the line. * However, for the last line we only want to display up to the * last character, not the end of the line. */ *(*int32)(unsafe.Pointer(bp)) = *(*int32)(unsafe.Pointer(bp + 16)) *(*int32)(unsafe.Pointer(bp + 8)) = *(*int32)(unsafe.Pointer(bp + 24)) XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), XTk_CanvasTkwin(tls, canvas), (*TTk_CanvasTextInfo)(unsafe.Pointer(textInfoPtr)).Freserved3, textInfoPtr+8) *(*int32)(unsafe.Pointer(bp + 4)) = *(*int32)(unsafe.Pointer(bp + 20)) for { if !(*(*int32)(unsafe.Pointer(bp + 4)) <= *(*int32)(unsafe.Pointer(bp + 32))) { break } s = (*TTextItem)(unsafe.Pointer(textPtr)).Fsine c = (*TTextItem)(unsafe.Pointer(textPtr)).Fcosine if *(*int32)(unsafe.Pointer(bp + 4)) == *(*int32)(unsafe.Pointer(bp + 32)) { width = *(*int32)(unsafe.Pointer(bp + 28)) + *(*int32)(unsafe.Pointer(bp + 36)) - *(*int32)(unsafe.Pointer(bp)) } else { width = (*TTextItem)(unsafe.Pointer(textPtr)).FactualWidth - *(*int32)(unsafe.Pointer(bp)) } dx1 = *(*int32)(unsafe.Pointer(bp)) - (*TTk_CanvasTextInfo)(unsafe.Pointer(textInfoPtr)).FselBorderWidth dy1 = *(*int32)(unsafe.Pointer(bp + 4)) dx2 = width + int32(2)*(*TTk_CanvasTextInfo)(unsafe.Pointer(textInfoPtr)).FselBorderWidth dy2 = *(*int32)(unsafe.Pointer(bp + 8)) (*(*[4]TXPoint)(unsafe.Pointer(bp + 40)))[0].Fx = int16(float64(*(*int16)(unsafe.Pointer(bp + 12))) + float64(float64(dx1)*c) + float64(float64(dy1)*s)) (*(*[4]TXPoint)(unsafe.Pointer(bp + 40)))[0].Fy = int16(float64(*(*int16)(unsafe.Pointer(bp + 14))) + float64(float64(dy1)*c) - float64(float64(dx1)*s)) (*(*[4]TXPoint)(unsafe.Pointer(bp + 40)))[int32(1)].Fx = int16(float64(*(*int16)(unsafe.Pointer(bp + 12))) + float64(float64(dx1+dx2)*c) + float64(float64(dy1)*s)) (*(*[4]TXPoint)(unsafe.Pointer(bp + 40)))[int32(1)].Fy = int16(float64(*(*int16)(unsafe.Pointer(bp + 14))) + float64(float64(dy1)*c) - float64(float64(dx1+dx2)*s)) (*(*[4]TXPoint)(unsafe.Pointer(bp + 40)))[int32(2)].Fx = int16(float64(*(*int16)(unsafe.Pointer(bp + 12))) + float64(float64(dx1+dx2)*c) + float64(float64(dy1+dy2)*s)) (*(*[4]TXPoint)(unsafe.Pointer(bp + 40)))[int32(2)].Fy = int16(float64(*(*int16)(unsafe.Pointer(bp + 14))) + float64(float64(dy1+dy2)*c) - float64(float64(dx1+dx2)*s)) (*(*[4]TXPoint)(unsafe.Pointer(bp + 40)))[int32(3)].Fx = int16(float64(*(*int16)(unsafe.Pointer(bp + 12))) + float64(float64(dx1)*c) + float64(float64(dy1+dy2)*s)) (*(*[4]TXPoint)(unsafe.Pointer(bp + 40)))[int32(3)].Fy = int16(float64(*(*int16)(unsafe.Pointer(bp + 14))) + float64(float64(dy1+dy2)*c) - float64(float64(dx1)*s)) XTk_Fill3DPolygon(tls, XTk_CanvasTkwin(tls, canvas), drawable, (*TTk_CanvasTextInfo)(unsafe.Pointer(textInfoPtr)).FselBorder, bp+40, int64(4), (*TTk_CanvasTextInfo)(unsafe.Pointer(textInfoPtr)).FselBorderWidth, int32(TK_RELIEF_RAISED)) *(*int32)(unsafe.Pointer(bp)) = 0 goto _2 _2: ; *(*int32)(unsafe.Pointer(bp + 4)) += *(*int32)(unsafe.Pointer(bp + 8)) } } } /* * If the insertion point should be displayed, then draw a special * background for the cursor before drawing the text. Note: if we're the * cursor item but the cursor is turned off, then redraw background over * the area of the cursor. This guarantees that the selection won't make * the cursor invisible on mono displays, where both are drawn in the same * color. */ if (*TTk_CanvasTextInfo)(unsafe.Pointer(textInfoPtr)).FfocusItemPtr == itemPtr && (*TTk_CanvasTextInfo)(unsafe.Pointer(textInfoPtr)).FgotFocus != 0 { if XTk_CharBbox(tls, (*TTextItem)(unsafe.Pointer(textPtr)).FtextLayout, (*TTextItem)(unsafe.Pointer(textPtr)).FinsertPos, bp, bp+4, libc.UintptrFromInt32(0), bp+8) != 0 { s1 = (*TTextItem)(unsafe.Pointer(textPtr)).Fsine c1 = (*TTextItem)(unsafe.Pointer(textPtr)).Fcosine XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), XTk_CanvasTkwin(tls, canvas), (*TTk_CanvasTextInfo)(unsafe.Pointer(textInfoPtr)).Freserved2, textInfoPtr+72) dx11 = *(*int32)(unsafe.Pointer(bp)) - (*TTk_CanvasTextInfo)(unsafe.Pointer(textInfoPtr)).FinsertWidth/int32(2) dy11 = *(*int32)(unsafe.Pointer(bp + 4)) dx21 = (*TTk_CanvasTextInfo)(unsafe.Pointer(textInfoPtr)).FinsertWidth dy21 = *(*int32)(unsafe.Pointer(bp + 8)) (*(*[4]TXPoint)(unsafe.Pointer(bp + 56)))[0].Fx = int16(float64(*(*int16)(unsafe.Pointer(bp + 12))) + float64(float64(dx11)*c1) + float64(float64(dy11)*s1)) (*(*[4]TXPoint)(unsafe.Pointer(bp + 56)))[0].Fy = int16(float64(*(*int16)(unsafe.Pointer(bp + 14))) + float64(float64(dy11)*c1) - float64(float64(dx11)*s1)) (*(*[4]TXPoint)(unsafe.Pointer(bp + 56)))[int32(1)].Fx = int16(float64(*(*int16)(unsafe.Pointer(bp + 12))) + float64(float64(dx11+dx21)*c1) + float64(float64(dy11)*s1)) (*(*[4]TXPoint)(unsafe.Pointer(bp + 56)))[int32(1)].Fy = int16(float64(*(*int16)(unsafe.Pointer(bp + 14))) + float64(float64(dy11)*c1) - float64(float64(dx11+dx21)*s1)) (*(*[4]TXPoint)(unsafe.Pointer(bp + 56)))[int32(2)].Fx = int16(float64(*(*int16)(unsafe.Pointer(bp + 12))) + float64(float64(dx11+dx21)*c1) + float64(float64(dy11+dy21)*s1)) (*(*[4]TXPoint)(unsafe.Pointer(bp + 56)))[int32(2)].Fy = int16(float64(*(*int16)(unsafe.Pointer(bp + 14))) + float64(float64(dy11+dy21)*c1) - float64(float64(dx11+dx21)*s1)) (*(*[4]TXPoint)(unsafe.Pointer(bp + 56)))[int32(3)].Fx = int16(float64(*(*int16)(unsafe.Pointer(bp + 12))) + float64(float64(dx11)*c1) + float64(float64(dy11+dy21)*s1)) (*(*[4]TXPoint)(unsafe.Pointer(bp + 56)))[int32(3)].Fy = int16(float64(*(*int16)(unsafe.Pointer(bp + 14))) + float64(float64(dy11+dy21)*c1) - float64(float64(dx11)*s1)) XTk_SetCaretPos(tls, XTk_CanvasTkwin(tls, canvas), int32((*(*[4]TXPoint)(unsafe.Pointer(bp + 56)))[0].Fx), int32((*(*[4]TXPoint)(unsafe.Pointer(bp + 56)))[0].Fy), *(*int32)(unsafe.Pointer(bp + 8))) if (*TTk_CanvasTextInfo)(unsafe.Pointer(textInfoPtr)).FcursorOn != 0 { XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), XTk_CanvasTkwin(tls, canvas), (*TTk_CanvasTextInfo)(unsafe.Pointer(textInfoPtr)).Freserved1, textInfoPtr+76) XTk_Fill3DPolygon(tls, XTk_CanvasTkwin(tls, canvas), drawable, (*TTk_CanvasTextInfo)(unsafe.Pointer(textInfoPtr)).FinsertBorder, bp+56, int64(4), (*TTk_CanvasTextInfo)(unsafe.Pointer(textInfoPtr)).FinsertBorderWidth, int32(TK_RELIEF_RAISED)) } else { if (*TTextItem)(unsafe.Pointer(textPtr)).FcursorOffGC != libc.UintptrFromInt32(0) { /* * Redraw the background over the area of the cursor, even * though the cursor is turned off. This guarantees that the * selection won't make the cursor invisible on mono displays, * where both may be drawn in the same color. */ libx11.XXFillPolygon(tls, display, drawable, (*TTextItem)(unsafe.Pointer(textPtr)).FcursorOffGC, bp+56, int32(4), int32(Convex), CoordModeOrigin) } } } } /* * If there is no selected text or the selected text foreground is the * same as the regular text foreground, then draw one text string. If * there is selected text and the foregrounds differ, draw the regular * text up to the selection, draw the selection, then draw the rest of the * regular text. Drawing the regular text and then the selected text over * it would causes problems with anti-aliased text because the two * anti-aliasing colors would blend together. */ if selFirstChar != int64(-libc.Int32FromInt32(1)) && (*TTextItem)(unsafe.Pointer(textPtr)).FselTextGC != (*TTextItem)(unsafe.Pointer(textPtr)).Fgc { if 0 < selFirstChar { XTkDrawAngledTextLayout(tls, display, drawable, (*TTextItem)(unsafe.Pointer(textPtr)).Fgc, (*TTextItem)(unsafe.Pointer(textPtr)).FtextLayout, int32(*(*int16)(unsafe.Pointer(bp + 12))), int32(*(*int16)(unsafe.Pointer(bp + 14))), (*TTextItem)(unsafe.Pointer(textPtr)).Fangle, 0, selFirstChar) } XTkDrawAngledTextLayout(tls, display, drawable, (*TTextItem)(unsafe.Pointer(textPtr)).FselTextGC, (*TTextItem)(unsafe.Pointer(textPtr)).FtextLayout, int32(*(*int16)(unsafe.Pointer(bp + 12))), int32(*(*int16)(unsafe.Pointer(bp + 14))), (*TTextItem)(unsafe.Pointer(textPtr)).Fangle, selFirstChar, selLastChar+int64(1)) if selLastChar+int64(1) < numChars { XTkDrawAngledTextLayout(tls, display, drawable, (*TTextItem)(unsafe.Pointer(textPtr)).Fgc, (*TTextItem)(unsafe.Pointer(textPtr)).FtextLayout, int32(*(*int16)(unsafe.Pointer(bp + 12))), int32(*(*int16)(unsafe.Pointer(bp + 14))), (*TTextItem)(unsafe.Pointer(textPtr)).Fangle, selLastChar+int64(1), numChars) } } else { XTkDrawAngledTextLayout(tls, display, drawable, (*TTextItem)(unsafe.Pointer(textPtr)).Fgc, (*TTextItem)(unsafe.Pointer(textPtr)).FtextLayout, int32(*(*int16)(unsafe.Pointer(bp + 12))), int32(*(*int16)(unsafe.Pointer(bp + 14))), (*TTextItem)(unsafe.Pointer(textPtr)).Fangle, 0, numChars) } XTkUnderlineAngledTextLayout(tls, display, drawable, (*TTextItem)(unsafe.Pointer(textPtr)).Fgc, (*TTextItem)(unsafe.Pointer(textPtr)).FtextLayout, int32(*(*int16)(unsafe.Pointer(bp + 12))), int32(*(*int16)(unsafe.Pointer(bp + 14))), (*TTextItem)(unsafe.Pointer(textPtr)).Fangle, (*TTextItem)(unsafe.Pointer(textPtr)).Funderline) if stipple != uint64(0) { libx11.XXSetTSOrigin(tls, display, (*TTextItem)(unsafe.Pointer(textPtr)).Fgc, 0, 0) } } /* *---------------------------------------------------------------------- * * TextInsert -- * * Insert characters into a text item at a given position. * * Results: * None. * * Side effects: * The text in the given item is modified. The cursor and selection * positions are also modified to reflect the insertion. * *---------------------------------------------------------------------- */ func _TextInsert(tls *libc.TLS, canvas TTk_Canvas, itemPtr uintptr, index TTcl_Size, obj uintptr) { bp := tls.Alloc(240) defer tls.Free(240) /* New characters to be inserted. */ var _objPtr, string1, text, textInfoPtr, textPtr, v2, v4 uintptr var byteIndex, charsAdded int32 var numChars, v3 TTcl_Size var v1 int64 var _ /* byteCount at bp+0 */ TTcl_Size var _ /* ds at bp+8 */ TTcl_DString _, _, _, _, _, _, _, _, _, _, _, _ = _objPtr, byteIndex, charsAdded, numChars, string1, text, textInfoPtr, textPtr, v1, v2, v3, v4 textPtr = itemPtr textInfoPtr = (*TTextItem)(unsafe.Pointer(textPtr)).FtextInfoPtr string1 = libtcl9_0.XTcl_GetStringFromObj(tls, obj, bp) if index < 0 { index = 0 } if (*TTextItem)(unsafe.Pointer(textPtr)).FtextObj != 0 { v1 = libtcl9_0.XTcl_GetCharLength(tls, (*TTextItem)(unsafe.Pointer(textPtr)).FtextObj) } else { v1 = 0 } numChars = v1 if (*TTextItem)(unsafe.Pointer(textPtr)).FtextObj != 0 { v2 = libtcl9_0.XTcl_GetStringFromObj(tls, (*TTextItem)(unsafe.Pointer(textPtr)).FtextObj, libc.UintptrFromInt32(0)) } else { v2 = __ccgo_ts + 195 } text = v2 if index > numChars { index = numChars } byteIndex = int32(int64(libtcl9_0.XTcl_UtfAtIndex(tls, text, index)) - int64(text)) *(*TTcl_Size)(unsafe.Pointer(bp)) = libc.Int64FromUint64(libc.Xstrlen(tls, string1)) if *(*TTcl_Size)(unsafe.Pointer(bp)) == 0 { return } libtcl9_0.XTcl_DStringInit(tls, bp+8) libtcl9_0.XTcl_DStringAppend(tls, bp+8, text, int64(byteIndex)) libtcl9_0.XTcl_DStringAppend(tls, bp+8, string1, *(*TTcl_Size)(unsafe.Pointer(bp))) libtcl9_0.XTcl_DStringAppend(tls, bp+8, text+uintptr(byteIndex), int64(-libc.Int32FromInt32(1))) if (*TTextItem)(unsafe.Pointer(textPtr)).FtextObj != 0 { _objPtr = (*TTextItem)(unsafe.Pointer(textPtr)).FtextObj v4 = _objPtr v3 = *(*TTcl_Size)(unsafe.Pointer(v4)) *(*TTcl_Size)(unsafe.Pointer(v4))-- if v3 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr) } } (*TTextItem)(unsafe.Pointer(textPtr)).FtextObj = libtcl9_0.XTcl_DStringToObj(tls, bp+8) (*TTcl_Obj)(unsafe.Pointer((*TTextItem)(unsafe.Pointer(textPtr)).FtextObj)).FrefCount++ charsAdded = int32(libtcl9_0.XTcl_GetCharLength(tls, obj)) /* * Inserting characters invalidates indices such as those for the * selection and cursor. Update the indices appropriately. */ if (*TTk_CanvasTextInfo)(unsafe.Pointer(textInfoPtr)).FselItemPtr == itemPtr { if (*TTk_CanvasTextInfo)(unsafe.Pointer(textInfoPtr)).FselectFirst >= index { *(*TTcl_Size)(unsafe.Pointer(textInfoPtr + 32)) += int64(charsAdded) } if (*TTk_CanvasTextInfo)(unsafe.Pointer(textInfoPtr)).FselectLast >= index { *(*TTcl_Size)(unsafe.Pointer(textInfoPtr + 40)) += int64(charsAdded) } if (*TTk_CanvasTextInfo)(unsafe.Pointer(textInfoPtr)).FanchorItemPtr == itemPtr && (*TTk_CanvasTextInfo)(unsafe.Pointer(textInfoPtr)).FselectAnchor >= index { *(*TTcl_Size)(unsafe.Pointer(textInfoPtr + 56)) += int64(charsAdded) } } if (*TTextItem)(unsafe.Pointer(textPtr)).FinsertPos >= index { *(*TTcl_Size)(unsafe.Pointer(textPtr + 144)) += int64(charsAdded) } _ComputeTextBbox(tls, canvas, textPtr) } /* *-------------------------------------------------------------- * * TextDeleteChars -- * * Delete one or more characters from a text item. * * Results: * None. * * Side effects: * Characters between "first" and "last", inclusive, get deleted from * itemPtr, and things like the selection position get updated. * *-------------------------------------------------------------- */ func _TextDeleteChars(tls *libc.TLS, canvas TTk_Canvas, itemPtr uintptr, first TTcl_Size, last TTcl_Size) { bp := tls.Alloc(224) defer tls.Free(224) /* Character index of last character to delete * (inclusive). */ var _objPtr, text, textInfoPtr, textPtr, v3 uintptr var byteCount, byteIndex, charsRemoved int32 var numChars, v2 TTcl_Size var v1 int64 var _ /* ds at bp+0 */ TTcl_DString _, _, _, _, _, _, _, _, _, _, _ = _objPtr, byteCount, byteIndex, charsRemoved, numChars, text, textInfoPtr, textPtr, v1, v2, v3 textPtr = itemPtr textInfoPtr = (*TTextItem)(unsafe.Pointer(textPtr)).FtextInfoPtr if first < 0 { first = 0 } if (*TTextItem)(unsafe.Pointer(textPtr)).FtextObj != 0 { v1 = libtcl9_0.XTcl_GetCharLength(tls, (*TTextItem)(unsafe.Pointer(textPtr)).FtextObj) } else { v1 = 0 } numChars = v1 if last >= numChars { last = numChars - int64(1) } if first > last { return } charsRemoved = int32(last + int64(1) - first) text = libtcl9_0.XTcl_GetStringFromObj(tls, (*TTextItem)(unsafe.Pointer(textPtr)).FtextObj, libc.UintptrFromInt32(0)) byteIndex = int32(int64(libtcl9_0.XTcl_UtfAtIndex(tls, text, first)) - int64(text)) byteCount = int32(int64(libtcl9_0.XTcl_UtfAtIndex(tls, text+uintptr(byteIndex), int64(charsRemoved))) - int64(text+uintptr(byteIndex))) libtcl9_0.XTcl_DStringInit(tls, bp) libtcl9_0.XTcl_DStringAppend(tls, bp, text, int64(byteIndex)) libtcl9_0.XTcl_DStringAppend(tls, bp, text+uintptr(byteIndex)+uintptr(byteCount), int64(-libc.Int32FromInt32(1))) _objPtr = (*TTextItem)(unsafe.Pointer(textPtr)).FtextObj v3 = _objPtr v2 = *(*TTcl_Size)(unsafe.Pointer(v3)) *(*TTcl_Size)(unsafe.Pointer(v3))-- if v2 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr) } (*TTextItem)(unsafe.Pointer(textPtr)).FtextObj = libtcl9_0.XTcl_DStringToObj(tls, bp) (*TTcl_Obj)(unsafe.Pointer((*TTextItem)(unsafe.Pointer(textPtr)).FtextObj)).FrefCount++ /* * Update indexes for the selection and cursor to reflect the renumbering * of the remaining characters. */ if (*TTk_CanvasTextInfo)(unsafe.Pointer(textInfoPtr)).FselItemPtr == itemPtr { if (*TTk_CanvasTextInfo)(unsafe.Pointer(textInfoPtr)).FselectFirst > first { *(*TTcl_Size)(unsafe.Pointer(textInfoPtr + 32)) -= int64(charsRemoved) if (*TTk_CanvasTextInfo)(unsafe.Pointer(textInfoPtr)).FselectFirst < first { (*TTk_CanvasTextInfo)(unsafe.Pointer(textInfoPtr)).FselectFirst = first } } if (*TTk_CanvasTextInfo)(unsafe.Pointer(textInfoPtr)).FselectLast >= first { *(*TTcl_Size)(unsafe.Pointer(textInfoPtr + 40)) -= int64(charsRemoved) if (*TTk_CanvasTextInfo)(unsafe.Pointer(textInfoPtr)).FselectLast < first-int64(1) { (*TTk_CanvasTextInfo)(unsafe.Pointer(textInfoPtr)).FselectLast = first - int64(1) } } if (*TTk_CanvasTextInfo)(unsafe.Pointer(textInfoPtr)).FselectFirst > (*TTk_CanvasTextInfo)(unsafe.Pointer(textInfoPtr)).FselectLast { (*TTk_CanvasTextInfo)(unsafe.Pointer(textInfoPtr)).FselItemPtr = libc.UintptrFromInt32(0) } if (*TTk_CanvasTextInfo)(unsafe.Pointer(textInfoPtr)).FanchorItemPtr == itemPtr && (*TTk_CanvasTextInfo)(unsafe.Pointer(textInfoPtr)).FselectAnchor > first { *(*TTcl_Size)(unsafe.Pointer(textInfoPtr + 56)) -= int64(charsRemoved) if (*TTk_CanvasTextInfo)(unsafe.Pointer(textInfoPtr)).FselectAnchor < first { (*TTk_CanvasTextInfo)(unsafe.Pointer(textInfoPtr)).FselectAnchor = first } } } if (*TTextItem)(unsafe.Pointer(textPtr)).FinsertPos > first { *(*TTcl_Size)(unsafe.Pointer(textPtr + 144)) -= int64(charsRemoved) if (*TTextItem)(unsafe.Pointer(textPtr)).FinsertPos < first { (*TTextItem)(unsafe.Pointer(textPtr)).FinsertPos = first } } _ComputeTextBbox(tls, canvas, textPtr) return } /* *-------------------------------------------------------------- * * TextToPoint -- * * Computes the distance from a given point to a given text item, in * canvas units. * * Results: * The return value is 0 if the point whose x and y coordinates are * pointPtr[0] and pointPtr[1] is inside the text item. If the point * isn't inside the text item then the return value is the distance from * the point to the text item. * * Side effects: * None. * *-------------------------------------------------------------- */ func _TextToPoint(tls *libc.TLS, canvas TTk_Canvas, itemPtr uintptr, pointPtr uintptr) (r float64) { /* Pointer to x and y coordinates. */ var px, py, value float64 var state TTk_State var textPtr uintptr _, _, _, _, _ = px, py, state, textPtr, value state = (*TTk_Item)(unsafe.Pointer(itemPtr)).Fstate if state == int32(TK_STATE_NULL) { state = (*TTkCanvas)(unsafe.Pointer(canvas)).Fcanvas_state } textPtr = itemPtr px = *(*float64)(unsafe.Pointer(pointPtr)) - *(*float64)(unsafe.Pointer(textPtr + 280)) py = *(*float64)(unsafe.Pointer(pointPtr + 1*8)) - *(*float64)(unsafe.Pointer(textPtr + 280 + 1*8)) value = float64(XTk_DistanceToTextLayout(tls, (*TTextItem)(unsafe.Pointer(textPtr)).FtextLayout, int32(float64(px*(*TTextItem)(unsafe.Pointer(textPtr)).Fcosine)-float64(py*(*TTextItem)(unsafe.Pointer(textPtr)).Fsine)), int32(float64(py*(*TTextItem)(unsafe.Pointer(textPtr)).Fcosine)+float64(px*(*TTextItem)(unsafe.Pointer(textPtr)).Fsine)))) if state == int32(TK_STATE_HIDDEN) || (*TTextItem)(unsafe.Pointer(textPtr)).Fcolor == libc.UintptrFromInt32(0) || (*TTextItem)(unsafe.Pointer(textPtr)).FtextObj == libc.UintptrFromInt32(0) { value = float64(1e+36) } return value } /* *-------------------------------------------------------------- * * TextToArea -- * * This function is called to determine whether an item lies entirely * inside, entirely outside, or overlapping a given rectangle. * * Results: * -1 is returned if the item is entirely outside the area given by * rectPtr, 0 if it overlaps, and 1 if it is entirely inside the given * area. * * Side effects: * None. * *-------------------------------------------------------------- */ func _TextToArea(tls *libc.TLS, canvas TTk_Canvas, itemPtr uintptr, rectPtr uintptr) (r int32) { /* Pointer to array of four coordinates * (x1,y1,x2,y2) describing rectangular * area. */ var state TTk_State var textPtr uintptr _, _ = state, textPtr state = (*TTk_Item)(unsafe.Pointer(itemPtr)).Fstate if state == int32(TK_STATE_NULL) { state = (*TTkCanvas)(unsafe.Pointer(canvas)).Fcanvas_state } textPtr = itemPtr return XTkIntersectAngledTextLayout(tls, (*TTextItem)(unsafe.Pointer(textPtr)).FtextLayout, int32(*(*float64)(unsafe.Pointer(rectPtr))+libc.Float64FromFloat64(0.5)-*(*float64)(unsafe.Pointer(textPtr + 280))), int32(*(*float64)(unsafe.Pointer(rectPtr + 1*8))+libc.Float64FromFloat64(0.5)-*(*float64)(unsafe.Pointer(textPtr + 280 + 1*8))), int32(*(*float64)(unsafe.Pointer(rectPtr + 2*8))-*(*float64)(unsafe.Pointer(rectPtr))+libc.Float64FromFloat64(0.5)), int32(*(*float64)(unsafe.Pointer(rectPtr + 3*8))-*(*float64)(unsafe.Pointer(rectPtr + 1*8))+libc.Float64FromFloat64(0.5)), (*TTextItem)(unsafe.Pointer(textPtr)).Fangle) } /* *-------------------------------------------------------------- * * RotateText -- * * This function is called to rotate a text item by a given amount about a * point. Note that this does *not* rotate the text of the item. * * Results: * None. * * Side effects: * The position of the text anchor is rotated by angleRad about (originX, * originY), and the bounding box is updated in the generic part of the * item structure. * *-------------------------------------------------------------- */ func _RotateText(tls *libc.TLS, canvas TTk_Canvas, itemPtr uintptr, originX float64, originY float64, angleRad float64) { /* Amount by which item is to be rotated. */ var textPtr uintptr _ = textPtr textPtr = itemPtr XTkRotatePoint(tls, originX, originY, libc.Xsin(tls, angleRad), libc.Xcos(tls, angleRad), textPtr+128, textPtr+136) _ComputeTextBbox(tls, canvas, textPtr) } /* *-------------------------------------------------------------- * * ScaleText -- * * This function is invoked to rescale a text item. * * Results: * None. * * Side effects: * Scales the position of the text, but not the size of the font for the * text. * *-------------------------------------------------------------- */ func _ScaleText(tls *libc.TLS, canvas TTk_Canvas, itemPtr uintptr, originX float64, originY float64, scaleX float64, scaleY float64) { /* Amount to scale in Y direction. */ var textPtr uintptr _ = textPtr textPtr = itemPtr (*TTextItem)(unsafe.Pointer(textPtr)).Fx = originX + float64(scaleX*((*TTextItem)(unsafe.Pointer(textPtr)).Fx-originX)) (*TTextItem)(unsafe.Pointer(textPtr)).Fy = originY + float64(scaleY*((*TTextItem)(unsafe.Pointer(textPtr)).Fy-originY)) _ComputeTextBbox(tls, canvas, textPtr) return } /* *-------------------------------------------------------------- * * TranslateText -- * * This function is called to move a text item by a given amount. * * Results: * None. * * Side effects: * The position of the text item is offset by (xDelta, yDelta), and the * bounding box is updated in the generic part of the item structure. * *-------------------------------------------------------------- */ func _TranslateText(tls *libc.TLS, canvas TTk_Canvas, itemPtr uintptr, deltaX float64, deltaY float64) { /* Amount by which item is to be moved. */ var textPtr uintptr _ = textPtr textPtr = itemPtr *(*float64)(unsafe.Pointer(textPtr + 128)) += deltaX *(*float64)(unsafe.Pointer(textPtr + 136)) += deltaY _ComputeTextBbox(tls, canvas, textPtr) } /* *-------------------------------------------------------------- * * GetTextIndex -- * * Parse an index into a text item and return either its value or an * error. * * Results: * A standard Tcl result. If all went well, then *indexPtr is filled in * with the index (into itemPtr) corresponding to string. Otherwise an * error message is left in the interp's result. * * Side effects: * None. * *-------------------------------------------------------------- */ func _GetTextIndex(tls *libc.TLS, interp uintptr, dummy1455 TTk_Canvas, itemPtr uintptr, obj uintptr, indexPtr uintptr) (r int32) { bp := tls.Alloc(80) defer tls.Free(80) /* Where to store converted character * index. */ var c, x, y int32 var cs, s, v4, v5 float64 var numChars TTcl_Size var p, rest, string1, textInfoPtr, textPtr uintptr var v1 int64 var _ /* idx at bp+8 */ TTcl_Size var _ /* length at bp+0 */ TTcl_Size var _ /* tmp at bp+16 */ float64 _, _, _, _, _, _, _, _, _, _, _, _, _, _ = c, cs, numChars, p, rest, s, string1, textInfoPtr, textPtr, x, y, v1, v4, v5 textPtr = itemPtr textInfoPtr = (*TTextItem)(unsafe.Pointer(textPtr)).FtextInfoPtr if (*TTextItem)(unsafe.Pointer(textPtr)).FtextObj != 0 { v1 = libtcl9_0.XTcl_GetCharLength(tls, (*TTextItem)(unsafe.Pointer(textPtr)).FtextObj) } else { v1 = 0 } numChars = v1 if TCL_OK == XTkGetIntForIndex(tls, obj, numChars-int64(1), int32(1), bp+8) { if *(*TTcl_Size)(unsafe.Pointer(bp + 8)) < 0 { *(*TTcl_Size)(unsafe.Pointer(bp + 8)) = 0 } else { if *(*TTcl_Size)(unsafe.Pointer(bp + 8)) > numChars { *(*TTcl_Size)(unsafe.Pointer(bp + 8)) = numChars } } *(*TTcl_Size)(unsafe.Pointer(indexPtr)) = *(*TTcl_Size)(unsafe.Pointer(bp + 8)) return TCL_OK } string1 = libtcl9_0.XTcl_GetStringFromObj(tls, obj, bp) c = libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(string1))) if c == int32('i') && libc.Xstrncmp(tls, string1, __ccgo_ts+22158, libc.Uint64FromInt64(*(*TTcl_Size)(unsafe.Pointer(bp)))) == 0 { *(*TTcl_Size)(unsafe.Pointer(indexPtr)) = (*TTextItem)(unsafe.Pointer(textPtr)).FinsertPos } else { if c == int32('s') && *(*TTcl_Size)(unsafe.Pointer(bp)) >= int64(5) && libc.Xstrncmp(tls, string1, __ccgo_ts+22554, libc.Uint64FromInt64(*(*TTcl_Size)(unsafe.Pointer(bp)))) == 0 { if (*TTk_CanvasTextInfo)(unsafe.Pointer(textInfoPtr)).FselItemPtr != itemPtr { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+32096, int64(-libc.Int32FromInt32(1)))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+32, __ccgo_ts+179, __ccgo_ts+27003, __ccgo_ts+32120, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) } *(*TTcl_Size)(unsafe.Pointer(indexPtr)) = (*TTk_CanvasTextInfo)(unsafe.Pointer(textInfoPtr)).FselectFirst } else { if c == int32('s') && *(*TTcl_Size)(unsafe.Pointer(bp)) >= int64(5) && libc.Xstrncmp(tls, string1, __ccgo_ts+22564, libc.Uint64FromInt64(*(*TTcl_Size)(unsafe.Pointer(bp)))) == 0 { if (*TTk_CanvasTextInfo)(unsafe.Pointer(textInfoPtr)).FselItemPtr != itemPtr { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+32096, int64(-libc.Int32FromInt32(1)))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+32, __ccgo_ts+179, __ccgo_ts+27003, __ccgo_ts+32120, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) } *(*TTcl_Size)(unsafe.Pointer(indexPtr)) = (*TTk_CanvasTextInfo)(unsafe.Pointer(textInfoPtr)).FselectLast } else { if !(c == int32('@')) { goto _2 } cs = (*TTextItem)(unsafe.Pointer(textPtr)).Fcosine s = (*TTextItem)(unsafe.Pointer(textPtr)).Fsine p = string1 + uintptr(1) rest = libc.Xstrchr(tls, p, int32(',')) if !(rest != 0) { goto badIndex } *(*uint8)(unsafe.Pointer(rest)) = uint8('\000') if libtcl9_0.XTcl_GetDouble(tls, libc.UintptrFromInt32(0), p, bp+16) != TCL_OK { *(*uint8)(unsafe.Pointer(rest)) = uint8(',') goto badIndex } *(*uint8)(unsafe.Pointer(rest)) = uint8(',') if *(*float64)(unsafe.Pointer(bp + 16)) < libc.Float64FromInt32(0) { v4 = *(*float64)(unsafe.Pointer(bp + 16)) - float64(0.5) } else { v4 = *(*float64)(unsafe.Pointer(bp + 16)) + float64(0.5) } x = int32(v4) p = rest + uintptr(1) if libtcl9_0.XTcl_GetDouble(tls, libc.UintptrFromInt32(0), p, bp+16) != TCL_OK { goto badIndex } if *(*float64)(unsafe.Pointer(bp + 16)) < libc.Float64FromInt32(0) { v5 = *(*float64)(unsafe.Pointer(bp + 16)) - float64(0.5) } else { v5 = *(*float64)(unsafe.Pointer(bp + 16)) + float64(0.5) } y = int32(v5) x -= int32(*(*float64)(unsafe.Pointer(textPtr + 280))) y -= int32(*(*float64)(unsafe.Pointer(textPtr + 280 + 1*8))) *(*TTcl_Size)(unsafe.Pointer(indexPtr)) = int64(XTk_PointToChar(tls, (*TTextItem)(unsafe.Pointer(textPtr)).FtextLayout, int32(float64(float64(x)*cs)-float64(float64(y)*s)), int32(float64(float64(y)*cs)+float64(float64(x)*s)))) goto _3 _2: ; goto badIndex badIndex: ; libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+29867, libc.VaList(bp+32, string1))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+32, __ccgo_ts+179, __ccgo_ts+27003, __ccgo_ts+23800, __ccgo_ts+16417, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) _3: } } } return TCL_OK } /* *-------------------------------------------------------------- * * SetTextCursor -- * * Set the position of the insertion cursor in this item. * * Results: * None. * * Side effects: * The cursor position will change. * *-------------------------------------------------------------- */ func _SetTextCursor(tls *libc.TLS, dummy1558 TTk_Canvas, itemPtr uintptr, index TTcl_Size) { /* Character index of character just before * which cursor is to be positioned. */ var numChars TTcl_Size var textPtr uintptr var v1 int64 _, _, _ = numChars, textPtr, v1 textPtr = itemPtr if (*TTextItem)(unsafe.Pointer(textPtr)).FtextObj != 0 { v1 = libtcl9_0.XTcl_GetCharLength(tls, (*TTextItem)(unsafe.Pointer(textPtr)).FtextObj) } else { v1 = 0 } numChars = v1 if index < 0 { (*TTextItem)(unsafe.Pointer(textPtr)).FinsertPos = 0 } else { if index > numChars { (*TTextItem)(unsafe.Pointer(textPtr)).FinsertPos = numChars } else { (*TTextItem)(unsafe.Pointer(textPtr)).FinsertPos = index } } } /* *-------------------------------------------------------------- * * GetSelText -- * * This function is invoked to return the selected portion of a text * item. It is only called when this item has the selection. * * Results: * The return value is the number of non-NULL bytes stored at buffer. * Buffer is filled (or partially filled) with a NULL-terminated string * containing part or all of the selection, as given by offset and * maxBytes. * * Side effects: * None. * *-------------------------------------------------------------- */ func _GetSelText(tls *libc.TLS, dummy1598 TTk_Canvas, itemPtr uintptr, offset TTcl_Size, buffer uintptr, maxBytes TTcl_Size) (r TTcl_Size) { /* Maximum number of bytes to place at buffer, * not including terminating NULL * character. */ var byteCount TTcl_Size var selEnd, selStart, textInfoPtr, textPtr, v1 uintptr _, _, _, _, _, _ = byteCount, selEnd, selStart, textInfoPtr, textPtr, v1 textPtr = itemPtr textInfoPtr = (*TTextItem)(unsafe.Pointer(textPtr)).FtextInfoPtr if (*TTk_CanvasTextInfo)(unsafe.Pointer(textInfoPtr)).FselectFirst < 0 || (*TTk_CanvasTextInfo)(unsafe.Pointer(textInfoPtr)).FselectFirst > (*TTk_CanvasTextInfo)(unsafe.Pointer(textInfoPtr)).FselectLast { return 0 } if (*TTextItem)(unsafe.Pointer(textPtr)).FtextObj != 0 { v1 = libtcl9_0.XTcl_GetStringFromObj(tls, (*TTextItem)(unsafe.Pointer(textPtr)).FtextObj, libc.UintptrFromInt32(0)) } else { v1 = __ccgo_ts + 195 } selStart = libtcl9_0.XTcl_UtfAtIndex(tls, v1, (*TTk_CanvasTextInfo)(unsafe.Pointer(textInfoPtr)).FselectFirst) selEnd = libtcl9_0.XTcl_UtfAtIndex(tls, selStart, (*TTk_CanvasTextInfo)(unsafe.Pointer(textInfoPtr)).FselectLast+int64(1)-(*TTk_CanvasTextInfo)(unsafe.Pointer(textInfoPtr)).FselectFirst) if selEnd <= selStart+uintptr(offset) { return 0 } byteCount = int64(selEnd) - int64(selStart) - offset if byteCount > maxBytes { byteCount = maxBytes } libc.Xmemcpy(tls, buffer, selStart+uintptr(offset), libc.Uint64FromInt64(byteCount)) *(*uint8)(unsafe.Pointer(buffer + uintptr(byteCount))) = uint8('\000') return byteCount } /* *-------------------------------------------------------------- * * TextToPostscript -- * * This function is called to generate Postscript for text items. * * Results: * The return value is a standard Tcl result. If an error occurs in * generating Postscript then an error message is left in the interp's * result, replacing whatever used to be there. If no error occurs, then * Postscript for the item is appended to the result. * * Side effects: * None. * *-------------------------------------------------------------- */ func _TextToPostscript(tls *libc.TLS, interp uintptr, canvas TTk_Canvas, itemPtr uintptr, prepass int32) (r int32) { bp := tls.Alloc(64) defer tls.Free(64) /* 1 means this is a prepass to collect font * information; 0 means final Postscript is * being created. */ var _objPtr, _objPtr1, color, justify, psObj, textPtr, v1, v3, v5 uintptr var interpState TTcl_InterpState var state TTk_State var stipple TPixmap var x, y float64 var v2, v4 TTcl_Size var _ /* fm at bp+0 */ TTk_FontMetrics _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = _objPtr, _objPtr1, color, interpState, justify, psObj, state, stipple, textPtr, x, y, v1, v2, v3, v4, v5 textPtr = itemPtr state = (*TTk_Item)(unsafe.Pointer(itemPtr)).Fstate if state == int32(TK_STATE_NULL) { state = (*TTkCanvas)(unsafe.Pointer(canvas)).Fcanvas_state } color = (*TTextItem)(unsafe.Pointer(textPtr)).Fcolor stipple = (*TTextItem)(unsafe.Pointer(textPtr)).Fstipple if state == int32(TK_STATE_HIDDEN) || (*TTextItem)(unsafe.Pointer(textPtr)).Fcolor == libc.UintptrFromInt32(0) || (*TTextItem)(unsafe.Pointer(textPtr)).FtextObj == libc.UintptrFromInt32(0) { return TCL_OK } else { if (*TTkCanvas)(unsafe.Pointer(canvas)).FcurrentItemPtr == itemPtr { if (*TTextItem)(unsafe.Pointer(textPtr)).FactiveColor != libc.UintptrFromInt32(0) { color = (*TTextItem)(unsafe.Pointer(textPtr)).FactiveColor } if (*TTextItem)(unsafe.Pointer(textPtr)).FactiveStipple != uint64(0) { stipple = (*TTextItem)(unsafe.Pointer(textPtr)).FactiveStipple } } else { if state == int32(TK_STATE_DISABLED) { if (*TTextItem)(unsafe.Pointer(textPtr)).FdisabledColor != libc.UintptrFromInt32(0) { color = (*TTextItem)(unsafe.Pointer(textPtr)).FdisabledColor } if (*TTextItem)(unsafe.Pointer(textPtr)).FdisabledStipple != uint64(0) { stipple = (*TTextItem)(unsafe.Pointer(textPtr)).FdisabledStipple } } } } /* * Make our working space. */ psObj = libtcl9_0.XTcl_NewObj(tls) interpState = libtcl9_0.XTcl_SaveInterpState(tls, interp, TCL_OK) /* * Generate postscript. */ libtcl9_0.XTcl_ResetResult(tls, interp) if XTk_CanvasPsFont(tls, interp, canvas, (*TTextItem)(unsafe.Pointer(textPtr)).Ftkfont) != TCL_OK { goto error } libtcl9_0.XTcl_AppendObjToObj(tls, psObj, libtcl9_0.XTcl_GetObjResult(tls, interp)) if prepass != 0 { goto done } libtcl9_0.XTcl_ResetResult(tls, interp) XTk_CanvasPsColor(tls, interp, canvas, color) libtcl9_0.XTcl_AppendObjToObj(tls, psObj, libtcl9_0.XTcl_GetObjResult(tls, interp)) if stipple != uint64(0) { libtcl9_0.XTcl_ResetResult(tls, interp) XTk_CanvasPsStipple(tls, interp, canvas, stipple) libtcl9_0.XTcl_AppendPrintfToObj(tls, psObj, __ccgo_ts+32131, libc.VaList(bp+24, libtcl9_0.XTcl_GetStringFromObj(tls, libtcl9_0.XTcl_GetObjResult(tls, interp), libc.UintptrFromInt32(0)))) } switch (*TTextItem)(unsafe.Pointer(textPtr)).Fanchor { case int32(TK_ANCHOR_NW): x = libc.Float64FromInt32(0) y = libc.Float64FromInt32(0) case int32(TK_ANCHOR_N): x = libc.Float64FromInt32(1) y = libc.Float64FromInt32(0) case int32(TK_ANCHOR_NE): x = libc.Float64FromInt32(2) y = libc.Float64FromInt32(0) case int32(TK_ANCHOR_E): x = libc.Float64FromInt32(2) y = libc.Float64FromInt32(1) case int32(TK_ANCHOR_SE): x = libc.Float64FromInt32(2) y = libc.Float64FromInt32(2) case int32(TK_ANCHOR_S): x = libc.Float64FromInt32(1) y = libc.Float64FromInt32(2) case int32(TK_ANCHOR_SW): x = libc.Float64FromInt32(0) y = libc.Float64FromInt32(2) case int32(TK_ANCHOR_W): x = libc.Float64FromInt32(0) y = libc.Float64FromInt32(1) default: x = libc.Float64FromInt32(1) y = libc.Float64FromInt32(1) break } switch (*TTextItem)(unsafe.Pointer(textPtr)).Fjustify { case int32(TK_JUSTIFY_CENTER): justify = __ccgo_ts + 32164 case int32(TK_JUSTIFY_RIGHT): justify = __ccgo_ts + 14538 default: justify = __ccgo_ts + 10533 break } XTk_GetFontMetrics(tls, (*TTextItem)(unsafe.Pointer(textPtr)).Ftkfont, bp) libtcl9_0.XTcl_AppendPrintfToObj(tls, psObj, __ccgo_ts+32168, libc.VaList(bp+24, (*TTextItem)(unsafe.Pointer(textPtr)).Fangle, (*TTextItem)(unsafe.Pointer(textPtr)).Fx, XTk_CanvasPsY(tls, canvas, (*TTextItem)(unsafe.Pointer(textPtr)).Fy))) libtcl9_0.XTcl_ResetResult(tls, interp) XTk_TextLayoutToPostscript(tls, interp, (*TTextItem)(unsafe.Pointer(textPtr)).FtextLayout) libtcl9_0.XTcl_AppendObjToObj(tls, psObj, libtcl9_0.XTcl_GetObjResult(tls, interp)) if stipple == uint64(0) { v1 = __ccgo_ts + 32189 } else { v1 = __ccgo_ts + 29858 } libtcl9_0.XTcl_AppendPrintfToObj(tls, psObj, __ccgo_ts+32195, libc.VaList(bp+24, (*(*TTk_FontMetrics)(unsafe.Pointer(bp))).Flinespace, x/-libc.Float64FromFloat64(2), y/float64(2), justify, v1)) /* * Plug the accumulated postscript back into the result. */ goto done done: ; libtcl9_0.XTcl_RestoreInterpState(tls, interp, interpState) libtcl9_0.XTcl_AppendObjToObj(tls, libtcl9_0.XTcl_GetObjResult(tls, interp), psObj) _objPtr = psObj v3 = _objPtr v2 = *(*TTcl_Size)(unsafe.Pointer(v3)) *(*TTcl_Size)(unsafe.Pointer(v3))-- if v2 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr) } return TCL_OK goto error error: ; libtcl9_0.XTcl_DiscardInterpState(tls, interpState) _objPtr1 = psObj v5 = _objPtr1 v4 = *(*TTcl_Size)(unsafe.Pointer(v5)) *(*TTcl_Size)(unsafe.Pointer(v5))-- if v4 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr1) } return int32(TCL_ERROR) } const M_PI6 = 0 /* * Convenience macro. */ /* * Structures defined only in this file. */ type TSmoothAssocData = struct { FnextPtr uintptr Fsmooth TTk_SmoothMethod } func init() { p := unsafe.Pointer(&XtkBezierSmoothMethod) *(*uintptr)(unsafe.Add(p, 8)) = __ccgo_fp(XTkMakeBezierCurve) *(*uintptr)(unsafe.Add(p, 16)) = __ccgo_fp(XTkMakeBezierPostscript) } var _tkRawSmoothMethod = TTk_SmoothMethod{ Fname: __ccgo_ts + 29863, } func init() { p := unsafe.Pointer(&_tkRawSmoothMethod) *(*uintptr)(unsafe.Add(p, 8)) = __ccgo_fp(XTkMakeRawCurve) *(*uintptr)(unsafe.Add(p, 16)) = __ccgo_fp(XTkMakeRawCurvePostscript) } func _GetPostscriptBuffer1(tls *libc.TLS, interp uintptr) (r uintptr) { var psObj uintptr _ = psObj psObj = libtcl9_0.XTcl_GetObjResult(tls, interp) if (*TTcl_Obj)(unsafe.Pointer(psObj)).FrefCount > int64(1) { psObj = libtcl9_0.XTcl_DuplicateObj(tls, psObj) libtcl9_0.XTcl_SetObjResult(tls, interp, psObj) } return psObj } /* *---------------------------------------------------------------------- * * Tk_CanvasTkwin -- * * Given a token for a canvas, this function returns the widget that * represents the canvas. * * Results: * The return value is a handle for the widget. * * Side effects: * None. * *---------------------------------------------------------------------- */ func XTk_CanvasTkwin(tls *libc.TLS, canvas TTk_Canvas) (r TTk_Window) { /* Token for the canvas. */ return (*TTkCanvas)(unsafe.Pointer(canvas)).Ftkwin } /* *---------------------------------------------------------------------- * * Tk_CanvasDrawableCoords -- * * Given an (x,y) coordinate pair within a canvas, this function * returns the corresponding coordinates at which the point should * be drawn in the drawable used for display. * * Results: * There is no return value. The values at *drawableXPtr and * *drawableYPtr are filled in with the coordinates at which x and y * should be drawn. These coordinates are clipped to fit within a * "short", since this is what X uses in most cases for drawing. * * Side effects: * None. * *---------------------------------------------------------------------- */ func XTk_CanvasDrawableCoords(tls *libc.TLS, canvas TTk_Canvas, x float64, y float64, drawableXPtr uintptr, drawableYPtr uintptr) { var tmp float64 _ = tmp tmp = x - float64((*TTkCanvas)(unsafe.Pointer(canvas)).FdrawableXOrigin) if tmp > libc.Float64FromInt32(0) { tmp += float64(0.5) } else { tmp -= float64(0.5) } if tmp > libc.Float64FromInt32(32767) { *(*int16)(unsafe.Pointer(drawableXPtr)) = int16(32767) } else { if tmp < float64(-libc.Int32FromInt32(32768)) { *(*int16)(unsafe.Pointer(drawableXPtr)) = int16(-int32(32768)) } else { *(*int16)(unsafe.Pointer(drawableXPtr)) = int16(tmp) } } tmp = y - float64((*TTkCanvas)(unsafe.Pointer(canvas)).FdrawableYOrigin) if tmp > libc.Float64FromInt32(0) { tmp += float64(0.5) } else { tmp -= float64(0.5) } if tmp > libc.Float64FromInt32(32767) { *(*int16)(unsafe.Pointer(drawableYPtr)) = int16(32767) } else { if tmp < float64(-libc.Int32FromInt32(32768)) { *(*int16)(unsafe.Pointer(drawableYPtr)) = int16(-int32(32768)) } else { *(*int16)(unsafe.Pointer(drawableYPtr)) = int16(tmp) } } } /* *---------------------------------------------------------------------- * * Tk_CanvasWindowCoords -- * * Given an (x,y) coordinate pair within a canvas, this function returns * the corresponding coordinates in the canvas's window. * * Results: * There is no return value. The values at *screenXPtr and *screenYPtr * are filled in with the coordinates at which (x,y) appears in the * canvas's window. These coordinates are clipped to fit within a * "short", since this is what X uses in most cases for drawing. * * Side effects: * None. * *---------------------------------------------------------------------- */ func XTk_CanvasWindowCoords(tls *libc.TLS, canvas TTk_Canvas, x float64, y float64, screenXPtr uintptr, screenYPtr uintptr) { var tmp float64 _ = tmp tmp = x - float64((*TTkCanvas)(unsafe.Pointer(canvas)).FxOrigin) if tmp > libc.Float64FromInt32(0) { tmp += float64(0.5) } else { tmp -= float64(0.5) } if tmp > libc.Float64FromInt32(32767) { *(*int16)(unsafe.Pointer(screenXPtr)) = int16(32767) } else { if tmp < float64(-libc.Int32FromInt32(32768)) { *(*int16)(unsafe.Pointer(screenXPtr)) = int16(-int32(32768)) } else { *(*int16)(unsafe.Pointer(screenXPtr)) = int16(tmp) } } tmp = y - float64((*TTkCanvas)(unsafe.Pointer(canvas)).FyOrigin) if tmp > libc.Float64FromInt32(0) { tmp += float64(0.5) } else { tmp -= float64(0.5) } if tmp > libc.Float64FromInt32(32767) { *(*int16)(unsafe.Pointer(screenYPtr)) = int16(32767) } else { if tmp < float64(-libc.Int32FromInt32(32768)) { *(*int16)(unsafe.Pointer(screenYPtr)) = int16(-int32(32768)) } else { *(*int16)(unsafe.Pointer(screenYPtr)) = int16(tmp) } } } /* *-------------------------------------------------------------- * * Tk_CanvasGetCoord -- * * Given a string, returns a floating-point canvas coordinate * corresponding to that string. * * Results: * The return value is a standard Tcl return result. If TCL_OK is * returned, then everything went well and the canvas coordinate is * stored at *doublePtr; otherwise TCL_ERROR is returned and an error * message is left in the interp's result. * * Side effects: * None. * *-------------------------------------------------------------- */ func XTk_CanvasGetCoord(tls *libc.TLS, dummy238 uintptr, canvas TTk_Canvas, string1 uintptr, doublePtr uintptr) (r int32) { /* Place to store converted coordinate. */ if XTk_GetScreenMM(tls, (*TTkCanvas)(unsafe.Pointer(canvas)).Finterp, (*TTkCanvas)(unsafe.Pointer(canvas)).Ftkwin, string1, doublePtr) != TCL_OK { return int32(TCL_ERROR) } *(*float64)(unsafe.Pointer(doublePtr)) *= (*TTkCanvas)(unsafe.Pointer(canvas)).FpixelsPerMM return TCL_OK } /* *-------------------------------------------------------------- * * Tk_CanvasGetCoordFromObj -- * * Given a string, returns a floating-point canvas coordinate * corresponding to that string. * * Results: * The return value is a standard Tcl return result. If TCL_OK is * returned, then everything went well and the canvas coordinate is * stored at *doublePtr; otherwise TCL_ERROR is returned and an error * message is left in interp->result. * * Side effects: * None. * *-------------------------------------------------------------- */ func XTk_CanvasGetCoordFromObj(tls *libc.TLS, dummy274 uintptr, canvas TTk_Canvas, obj uintptr, doublePtr uintptr) (r int32) { /* Place to store converted coordinate. */ return XTk_GetDoublePixelsFromObj(tls, (*TTkCanvas)(unsafe.Pointer(canvas)).Finterp, (*TTkCanvas)(unsafe.Pointer(canvas)).Ftkwin, obj, doublePtr) } /* *---------------------------------------------------------------------- * * Tk_CanvasSetStippleOrigin -- * * This function sets the stipple origin in a graphics context so that * stipples drawn with the GC will line up with other stipples previously * drawn in the canvas. * * Results: * None. * * Side effects: * The graphics context is modified. * *---------------------------------------------------------------------- */ func XTk_CanvasSetStippleOrigin(tls *libc.TLS, canvas TTk_Canvas, gc TGC) { /* Graphics context that is about to be used * to draw a stippled pattern as part of * redisplaying the canvas. */ libx11.XXSetTSOrigin(tls, (*TTkCanvas)(unsafe.Pointer(canvas)).Fdisplay, gc, -(*TTkCanvas)(unsafe.Pointer(canvas)).FdrawableXOrigin, -(*TTkCanvas)(unsafe.Pointer(canvas)).FdrawableYOrigin) } /* *---------------------------------------------------------------------- * * Tk_CanvasSetOffset-- * * This function sets the stipple offset in a graphics context so that * stipples drawn with the GC will line up with other stipples with the * same offset. * * Results: * None. * * Side effects: * The graphics context is modified. * *---------------------------------------------------------------------- */ func XTk_CanvasSetOffset(tls *libc.TLS, canvas TTk_Canvas, gc TGC, offset uintptr) { /* Offset (may be NULL pointer)*/ var canvasPtr uintptr var flags, x, y int32 _, _, _, _ = canvasPtr, flags, x, y canvasPtr = canvas flags = 0 x = -(*TTkCanvas)(unsafe.Pointer(canvasPtr)).FdrawableXOrigin y = -(*TTkCanvas)(unsafe.Pointer(canvasPtr)).FdrawableYOrigin if offset != libc.UintptrFromInt32(0) { flags = (*TTk_TSOffset)(unsafe.Pointer(offset)).Fflags x += (*TTk_TSOffset)(unsafe.Pointer(offset)).Fxoffset y += (*TTk_TSOffset)(unsafe.Pointer(offset)).Fyoffset } if flags&int32(TK_OFFSET_RELATIVE) != 0 && !(flags&libc.Int32FromInt32(TK_OFFSET_INDEX) != 0) { XTk_SetTSOrigin(tls, (*TTkCanvas)(unsafe.Pointer(canvasPtr)).Ftkwin, gc, x-(*TTkCanvas)(unsafe.Pointer(canvasPtr)).FxOrigin, y-(*TTkCanvas)(unsafe.Pointer(canvasPtr)).FyOrigin) } else { libx11.XXSetTSOrigin(tls, (*TTkCanvas)(unsafe.Pointer(canvasPtr)).Fdisplay, gc, x, y) } } /* *---------------------------------------------------------------------- * * Tk_CanvasGetTextInfo -- * * This function returns a pointer to a structure containing information * about the selection and insertion cursor for a canvas widget. Items * such as text items save the pointer and use it to share access to the * information with the generic canvas code. * * Results: * The return value is a pointer to the structure holding text * information for the canvas. Most of the fields should not be modified * outside the generic canvas code; see the user documentation for * details. * * Side effects: * None. * *---------------------------------------------------------------------- */ func XTk_CanvasGetTextInfo(tls *libc.TLS, canvas TTk_Canvas) (r uintptr) { /* Token for the canvas widget. */ return canvas + 152 } /* *-------------------------------------------------------------- * * Tk_CanvasTagsParseProc -- * * This function is invoked during option processing to handle "-tags" * options for canvas items. * * Results: * A standard Tcl return value. * * Side effects: * The tags for a given item get replaced by those indicated in the value * argument. * *-------------------------------------------------------------- */ func XTk_CanvasTagsParseProc(tls *libc.TLS, dummy406 uintptr, interp uintptr, dummy408 TTk_Window, value uintptr, widgRec uintptr, dummy411 TTcl_Size) (r int32) { bp := tls.Alloc(16) defer tls.Free(16) /* Offset into item (ignored). */ var i TTcl_Size var itemPtr, newPtr uintptr var _ /* argc at bp+0 */ TTcl_Size var _ /* argv at bp+8 */ uintptr _, _, _ = i, itemPtr, newPtr itemPtr = widgRec /* * Break the value up into the individual tag names. */ if libtcl9_0.XTcl_SplitList(tls, interp, value, bp, bp+8) != TCL_OK { return int32(TCL_ERROR) } /* * Make sure that there's enough space in the item to hold the tag names. */ if (*TTk_Item)(unsafe.Pointer(itemPtr)).FtagSpace < *(*TTcl_Size)(unsafe.Pointer(bp)) { newPtr = libtcl9_0.XTcl_Alloc(tls, libc.Uint64FromInt64(*(*TTcl_Size)(unsafe.Pointer(bp)))*uint64(8)) i = (*TTk_Item)(unsafe.Pointer(itemPtr)).FnumTags - int64(1) for { if !(i != int64(-libc.Int32FromInt32(1))) { break } *(*TTk_Uid)(unsafe.Pointer(newPtr + uintptr(i)*8)) = *(*TTk_Uid)(unsafe.Pointer((*TTk_Item)(unsafe.Pointer(itemPtr)).FtagPtr + uintptr(i)*8)) goto _1 _1: ; i-- } if (*TTk_Item)(unsafe.Pointer(itemPtr)).FtagPtr != itemPtr+16 { libtcl9_0.XTcl_Free(tls, (*TTk_Item)(unsafe.Pointer(itemPtr)).FtagPtr) } (*TTk_Item)(unsafe.Pointer(itemPtr)).FtagPtr = newPtr (*TTk_Item)(unsafe.Pointer(itemPtr)).FtagSpace = *(*TTcl_Size)(unsafe.Pointer(bp)) } (*TTk_Item)(unsafe.Pointer(itemPtr)).FnumTags = *(*TTcl_Size)(unsafe.Pointer(bp)) i = 0 for { if !(i < *(*TTcl_Size)(unsafe.Pointer(bp))) { break } *(*TTk_Uid)(unsafe.Pointer((*TTk_Item)(unsafe.Pointer(itemPtr)).FtagPtr + uintptr(i)*8)) = XTk_GetUid(tls, *(*uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 8)) + uintptr(i)*8))) goto _2 _2: ; i++ } libtcl9_0.XTcl_Free(tls, *(*uintptr)(unsafe.Pointer(bp + 8))) return TCL_OK } /* *-------------------------------------------------------------- * * Tk_CanvasTagsPrintProc -- * * This function is invoked by the Tk configuration code to produce a * printable string for the "-tags" configuration option for canvas * items. * * Results: * The return value is a string describing all the tags for the item * referred to by "widgRec". In addition, *freeProcPtr is filled in with * the address of a function to call to free the result string when it's * no longer needed (or NULL to indicate that the string doesn't need to * be freed). * * Side effects: * None. * *-------------------------------------------------------------- */ func XTk_CanvasTagsPrintProc(tls *libc.TLS, dummy473 uintptr, dummy474 TTk_Window, widgRec uintptr, dummy476 TTcl_Size, freeProcPtr uintptr) (r uintptr) { /* Pointer to variable to fill in with * information about how to reclaim storage * for return string. */ var itemPtr uintptr _ = itemPtr itemPtr = widgRec if (*TTk_Item)(unsafe.Pointer(itemPtr)).FnumTags == 0 { *(*uintptr)(unsafe.Pointer(freeProcPtr)) = libc.UintptrFromInt32(0) return __ccgo_ts + 195 } if (*TTk_Item)(unsafe.Pointer(itemPtr)).FnumTags == int64(1) { *(*uintptr)(unsafe.Pointer(freeProcPtr)) = libc.UintptrFromInt32(0) return *(*TTk_Uid)(unsafe.Pointer((*TTk_Item)(unsafe.Pointer(itemPtr)).FtagPtr)) } *(*uintptr)(unsafe.Pointer(freeProcPtr)) = libc.UintptrFromInt32(3) return libtcl9_0.XTcl_Merge(tls, (*TTk_Item)(unsafe.Pointer(itemPtr)).FnumTags, (*TTk_Item)(unsafe.Pointer(itemPtr)).FtagPtr) } /* *-------------------------------------------------------------- * * TkCanvasDashParseProc -- * * This function is invoked during option processing to handle "-dash", * "-activedash" and "-disableddash" options for canvas objects. * * Results: * A standard Tcl return value. * * Side effects: * The dash list for a given canvas object gets replaced by those * indicated in the value argument. * *-------------------------------------------------------------- */ func XTkCanvasDashParseProc(tls *libc.TLS, dummy515 uintptr, interp uintptr, dummy517 TTk_Window, value uintptr, widgRec uintptr, offset TTcl_Size) (r int32) { /* Offset into item. */ return XTk_GetDash(tls, interp, value, widgRec+uintptr(offset)) } /* *-------------------------------------------------------------- * * TkCanvasDashPrintProc -- * * This function is invoked by the Tk configuration code to produce a * printable string for the "-dash", "-activedash" and "-disableddash" * configuration options for canvas items. * * Results: * The return value is a string describing all the dash list for the item * referred to by "widgRec"and "offset". In addition, *freeProcPtr is * filled in with the address of a function to call to free the result * string when it's no longer needed (or NULL to indicate that the string * doesn't need to be freed). * * Side effects: * None. * *-------------------------------------------------------------- */ func XTkCanvasDashPrintProc(tls *libc.TLS, dummy549 uintptr, dummy550 TTk_Window, widgRec uintptr, offset TTcl_Size, freeProcPtr uintptr) (r uintptr) { bp := tls.Alloc(16) defer tls.Free(16) /* Pointer to variable to fill in with * information about how to reclaim storage * for return string. */ var buffer, dash, p, v1, v2, v3, v5 uintptr var i, v4 int32 _, _, _, _, _, _, _, _, _ = buffer, dash, i, p, v1, v2, v3, v4, v5 dash = widgRec + uintptr(offset) i = (*TTk_Dash)(unsafe.Pointer(dash)).Fnumber if i < 0 { i = -i *(*uintptr)(unsafe.Pointer(freeProcPtr)) = libc.UintptrFromInt32(3) buffer = libtcl9_0.XTcl_Alloc(tls, libc.Uint64FromInt64(int64(i)+int64(1))) if i > libc.Int32FromInt64(8) { v1 = *(*uintptr)(unsafe.Pointer(dash + 8)) } else { v1 = dash + 8 } p = v1 libc.Xmemcpy(tls, buffer, p, uint64(libc.Uint32FromInt32(i))) *(*uint8)(unsafe.Pointer(buffer + uintptr(i))) = uint8(0) return buffer } else { if !(i != 0) { *(*uintptr)(unsafe.Pointer(freeProcPtr)) = libc.UintptrFromInt32(0) return __ccgo_ts + 195 } } buffer = libtcl9_0.XTcl_Alloc(tls, libc.Uint64FromInt64(int64(4)*int64(i))) *(*uintptr)(unsafe.Pointer(freeProcPtr)) = libc.UintptrFromInt32(3) if i > libc.Int32FromInt64(8) { v2 = *(*uintptr)(unsafe.Pointer(dash + 8)) } else { v2 = dash + 8 } p = v2 v3 = p p++ libc.X__builtin_snprintf(tls, buffer, uint64(4)*libc.Uint64FromInt32(i), __ccgo_ts+14540, libc.VaList(bp+8, libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(v3)))&int32(0xff))) for { i-- v4 = i if !(v4 != 0) { break } v5 = p p++ libc.X__builtin_snprintf(tls, buffer+uintptr(libc.Xstrlen(tls, buffer)), uint64(4)*libc.Uint64FromInt32(i)-libc.Xstrlen(tls, buffer), __ccgo_ts+32222, libc.VaList(bp+8, libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(v5)))&int32(0xff))) } return buffer } /* *-------------------------------------------------------------- * * InitSmoothMethods -- * * This function is invoked to set up the initial state of the list of * "-smooth" methods. It should only be called when the list installed * in the interpreter is NULL. * * Results: * Pointer to the start of the list of default smooth methods. * * Side effects: * A linked list of smooth methods is created and attached to the * interpreter's association key "smoothMethod" * *-------------------------------------------------------------- */ func _InitSmoothMethods(tls *libc.TLS, interp uintptr) (r uintptr) { var methods, ptr, v1 uintptr _, _, _ = methods, ptr, v1 methods = libtcl9_0.XTcl_Alloc(tls, uint64(32)) (*TSmoothAssocData)(unsafe.Pointer(methods)).Fsmooth.Fname = _tkRawSmoothMethod.Fname (*TSmoothAssocData)(unsafe.Pointer(methods)).Fsmooth.FcoordProc = _tkRawSmoothMethod.FcoordProc (*TSmoothAssocData)(unsafe.Pointer(methods)).Fsmooth.FpostscriptProc = _tkRawSmoothMethod.FpostscriptProc v1 = libtcl9_0.XTcl_Alloc(tls, uint64(32)) (*TSmoothAssocData)(unsafe.Pointer(methods)).FnextPtr = v1 ptr = v1 (*TSmoothAssocData)(unsafe.Pointer(ptr)).Fsmooth.Fname = XtkBezierSmoothMethod.Fname (*TSmoothAssocData)(unsafe.Pointer(ptr)).Fsmooth.FcoordProc = XtkBezierSmoothMethod.FcoordProc (*TSmoothAssocData)(unsafe.Pointer(ptr)).Fsmooth.FpostscriptProc = XtkBezierSmoothMethod.FpostscriptProc (*TSmoothAssocData)(unsafe.Pointer(ptr)).FnextPtr = libc.UintptrFromInt32(0) libtcl9_0.XTcl_SetAssocData(tls, interp, __ccgo_ts+32226, __ccgo_fp(_SmoothMethodCleanupProc), methods) return methods } /* *-------------------------------------------------------------- * * Tk_CreateSmoothMethod -- * * This function is invoked to add additional values for the "-smooth" * option to the list. * * Results: * A standard Tcl return value. * * Side effects: * In the future "-smooth " will be accepted as smooth method for * the line and polygon. * *-------------------------------------------------------------- */ func XTk_CreateSmoothMethod(tls *libc.TLS, interp uintptr, smooth uintptr) { var methods, prevPtr, ptr, typePtr2 uintptr _, _, _, _ = methods, prevPtr, ptr, typePtr2 methods = libtcl9_0.XTcl_GetAssocData(tls, interp, __ccgo_ts+32226, libc.UintptrFromInt32(0)) /* * Initialize if we were not previously initialized. */ if methods == libc.UintptrFromInt32(0) { methods = _InitSmoothMethods(tls, interp) } /* * If there's already a smooth method with the given name, remove it. */ typePtr2 = methods prevPtr = libc.UintptrFromInt32(0) for { if !(typePtr2 != libc.UintptrFromInt32(0)) { break } if !(libc.Xstrcmp(tls, (*TSmoothAssocData)(unsafe.Pointer(typePtr2)).Fsmooth.Fname, (*TTk_SmoothMethod)(unsafe.Pointer(smooth)).Fname) != 0) { if prevPtr == libc.UintptrFromInt32(0) { methods = (*TSmoothAssocData)(unsafe.Pointer(typePtr2)).FnextPtr } else { (*TSmoothAssocData)(unsafe.Pointer(prevPtr)).FnextPtr = (*TSmoothAssocData)(unsafe.Pointer(typePtr2)).FnextPtr } libtcl9_0.XTcl_Free(tls, typePtr2) break } goto _1 _1: ; prevPtr = typePtr2 typePtr2 = (*TSmoothAssocData)(unsafe.Pointer(typePtr2)).FnextPtr } ptr = libtcl9_0.XTcl_Alloc(tls, uint64(32)) (*TSmoothAssocData)(unsafe.Pointer(ptr)).Fsmooth.Fname = (*TTk_SmoothMethod)(unsafe.Pointer(smooth)).Fname (*TSmoothAssocData)(unsafe.Pointer(ptr)).Fsmooth.FcoordProc = (*TTk_SmoothMethod)(unsafe.Pointer(smooth)).FcoordProc (*TSmoothAssocData)(unsafe.Pointer(ptr)).Fsmooth.FpostscriptProc = (*TTk_SmoothMethod)(unsafe.Pointer(smooth)).FpostscriptProc (*TSmoothAssocData)(unsafe.Pointer(ptr)).FnextPtr = methods libtcl9_0.XTcl_SetAssocData(tls, interp, __ccgo_ts+32226, __ccgo_fp(_SmoothMethodCleanupProc), ptr) } /* *---------------------------------------------------------------------- * * SmoothMethodCleanupProc -- * * This function is invoked whenever an interpreter is deleted to * cleanup the smooth methods. * * Results: * None. * * Side effects: * Smooth methods are removed. * *---------------------------------------------------------------------- */ func _SmoothMethodCleanupProc(tls *libc.TLS, clientData uintptr, dummy703 uintptr) { /* Interpreter that is being deleted. */ var methods, ptr uintptr _, _ = methods, ptr methods = clientData for methods != libc.UintptrFromInt32(0) { ptr = methods methods = (*TSmoothAssocData)(unsafe.Pointer(methods)).FnextPtr libtcl9_0.XTcl_Free(tls, ptr) } } /* *-------------------------------------------------------------- * * TkSmoothParseProc -- * * This function is invoked during option processing to handle the * "-smooth" option. * * Results: * A standard Tcl return value. * * Side effects: * The smooth option for a given item gets replaced by the value * indicated in the value argument. * *-------------------------------------------------------------- */ func XTkSmoothParseProc(tls *libc.TLS, dummy733 uintptr, interp uintptr, dummy735 TTk_Window, value uintptr, widgRec uintptr, offset TTcl_Size) (r int32) { bp := tls.Alloc(64) defer tls.Free(64) /* Offset into item. */ var length Tsize_t var methods, smooth, smoothPtr, v1 uintptr var _ /* b at bp+0 */ int32 _, _, _, _, _ = length, methods, smooth, smoothPtr, v1 smoothPtr = widgRec + uintptr(offset) smooth = libc.UintptrFromInt32(0) if value == libc.UintptrFromInt32(0) || libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(value))) == 0 { *(*uintptr)(unsafe.Pointer(smoothPtr)) = libc.UintptrFromInt32(0) return TCL_OK } length = libc.Xstrlen(tls, value) methods = libtcl9_0.XTcl_GetAssocData(tls, interp, __ccgo_ts+32226, libc.UintptrFromInt32(0)) /* * Not initialized yet; fix that now. */ if methods == libc.UintptrFromInt32(0) { methods = _InitSmoothMethods(tls, interp) } /* * Backward compatibility hack. */ if libc.Xstrncmp(tls, value, __ccgo_ts+32239, length) == 0 { smooth = uintptr(unsafe.Pointer(&XtkBezierSmoothMethod)) } /* * Search the list of installed smooth methods. */ for methods != libc.UintptrFromInt32(0) { if libc.Xstrncmp(tls, value, (*TSmoothAssocData)(unsafe.Pointer(methods)).Fsmooth.Fname, length) == 0 { if smooth != libc.UintptrFromInt32(0) { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+32246, libc.VaList(bp+16, value))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+16, __ccgo_ts+179, __ccgo_ts+3058, __ccgo_ts+32275, value, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) } smooth = methods + 8 } methods = (*TSmoothAssocData)(unsafe.Pointer(methods)).FnextPtr } if smooth != 0 { *(*uintptr)(unsafe.Pointer(smoothPtr)) = smooth return TCL_OK } /* * Did not find it. Try parsing as a boolean instead. */ if libtcl9_0.XTcl_GetBool(tls, interp, value, (libc.Int32FromInt32(TCL_NULL_OK)-libc.Int32FromInt32(2))&libc.Int32FromInt64(4), bp) != TCL_OK { return int32(TCL_ERROR) } if *(*int32)(unsafe.Pointer(bp)) != 0 { v1 = uintptr(unsafe.Pointer(&XtkBezierSmoothMethod)) } else { v1 = libc.UintptrFromInt32(0) } *(*uintptr)(unsafe.Pointer(smoothPtr)) = v1 return TCL_OK } /* *-------------------------------------------------------------- * * TkSmoothPrintProc -- * * This function is invoked by the Tk configuration code to produce a * printable string for the "-smooth" configuration option. * * Results: * The return value is a string describing the smooth option for the item * referred to by "widgRec". In addition, *freeProcPtr is filled in with * the address of a function to call to free the result string when it's * no longer needed (or NULL to indicate that the string doesn't need to * be freed). * * Side effects: * None. * *-------------------------------------------------------------- */ func XTkSmoothPrintProc(tls *libc.TLS, dummy825 uintptr, dummy826 TTk_Window, widgRec uintptr, offset TTcl_Size, dummy829 uintptr) (r uintptr) { /* Pointer to variable to fill in with * information about how to reclaim storage * for return string. */ var smoothPtr, v1 uintptr _, _ = smoothPtr, v1 smoothPtr = *(*uintptr)(unsafe.Pointer(widgRec + uintptr(offset))) if smoothPtr != 0 { v1 = (*TTk_SmoothMethod)(unsafe.Pointer(smoothPtr)).Fname } else { v1 = __ccgo_ts + 10533 } return v1 } /* *-------------------------------------------------------------- * * Tk_GetDash * * This function is used to parse a string, assuming it is dash * information. * * Results: * The return value is a standard Tcl result: TCL_OK means that the dash * information was parsed ok, and TCL_ERROR means it couldn't be parsed. * * Side effects: * Dash information in the dash structure is updated. * *-------------------------------------------------------------- */ func XTk_GetDash(tls *libc.TLS, interp uintptr, value uintptr, dash uintptr) (r int32) { bp := tls.Alloc(64) defer tls.Free(64) /* Pointer to record in which to store dash * information. */ var largv, pt, v1, v3, v4 uintptr var v2, v5 int32 var _ /* argc at bp+0 */ TTcl_Size var _ /* argv at bp+16 */ uintptr var _ /* i at bp+8 */ int32 _, _, _, _, _, _, _ = largv, pt, v1, v2, v3, v4, v5 *(*uintptr)(unsafe.Pointer(bp + 16)) = libc.UintptrFromInt32(0) if value == libc.UintptrFromInt32(0) || libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(value))) == int32('\000') { (*TTk_Dash)(unsafe.Pointer(dash)).Fnumber = 0 return TCL_OK } /* * switch is usually compiled more efficiently than a chain of conditions. */ switch libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(value))) { case int32('.'): fallthrough case int32(','): fallthrough case int32('-'): fallthrough case int32('_'): *(*int32)(unsafe.Pointer(bp + 8)) = _DashConvert(tls, libc.UintptrFromInt32(0), value, -int32(1), float64(0)) if *(*int32)(unsafe.Pointer(bp + 8)) <= 0 { goto badDashList } *(*int32)(unsafe.Pointer(bp + 8)) = libc.Int32FromUint64(libc.Xstrlen(tls, value)) if *(*int32)(unsafe.Pointer(bp + 8)) > libc.Int32FromInt64(8) { v1 = libtcl9_0.XTcl_Alloc(tls, libc.Xstrlen(tls, value)) pt = v1 *(*uintptr)(unsafe.Pointer(dash + 8)) = v1 } else { pt = dash + 8 } libc.Xmemcpy(tls, pt, value, uint64(libc.Uint32FromInt32(*(*int32)(unsafe.Pointer(bp + 8))))) (*TTk_Dash)(unsafe.Pointer(dash)).Fnumber = -*(*int32)(unsafe.Pointer(bp + 8)) return TCL_OK } if libtcl9_0.XTcl_SplitList(tls, interp, value, bp, bp+16) != TCL_OK { libtcl9_0.XTcl_ResetResult(tls, interp) goto badDashList } if (*TTk_Dash)(unsafe.Pointer(dash)).Fnumber >= 0 { v2 = (*TTk_Dash)(unsafe.Pointer(dash)).Fnumber } else { v2 = -(*TTk_Dash)(unsafe.Pointer(dash)).Fnumber } if uint64(libc.Uint32FromInt32(v2)) > uint64(8) { libtcl9_0.XTcl_Free(tls, *(*uintptr)(unsafe.Pointer(dash + 8))) } if *(*TTcl_Size)(unsafe.Pointer(bp)) > int64(libc.Int32FromInt64(8)) { v3 = libtcl9_0.XTcl_Alloc(tls, libc.Uint64FromInt64(*(*TTcl_Size)(unsafe.Pointer(bp)))) pt = v3 *(*uintptr)(unsafe.Pointer(dash + 8)) = v3 } else { pt = dash + 8 } (*TTk_Dash)(unsafe.Pointer(dash)).Fnumber = int32(*(*TTcl_Size)(unsafe.Pointer(bp))) largv = *(*uintptr)(unsafe.Pointer(bp + 16)) for *(*TTcl_Size)(unsafe.Pointer(bp)) > 0 { if libtcl9_0.XTcl_GetInt(tls, interp, *(*uintptr)(unsafe.Pointer(largv)), bp+8) != TCL_OK || *(*int32)(unsafe.Pointer(bp + 8)) < int32(1) || *(*int32)(unsafe.Pointer(bp + 8)) > int32(255) { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+32282, libc.VaList(bp+32, *(*uintptr)(unsafe.Pointer(largv))))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+32, __ccgo_ts+179, __ccgo_ts+182, __ccgo_ts+32332, libc.UintptrFromInt32(0))) goto syntaxError } v4 = pt pt++ *(*uint8)(unsafe.Pointer(v4)) = libc.Uint8FromInt32(*(*int32)(unsafe.Pointer(bp + 8))) *(*TTcl_Size)(unsafe.Pointer(bp))-- largv += 8 } if *(*uintptr)(unsafe.Pointer(bp + 16)) != libc.UintptrFromInt32(0) { libtcl9_0.XTcl_Free(tls, *(*uintptr)(unsafe.Pointer(bp + 16))) } return TCL_OK /* * Something went wrong. Generate error message, clean up and return. */ goto badDashList badDashList: ; libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+32337, libc.VaList(bp+32, value))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+32, __ccgo_ts+179, __ccgo_ts+182, __ccgo_ts+32332, libc.UintptrFromInt32(0))) goto syntaxError syntaxError: ; if *(*uintptr)(unsafe.Pointer(bp + 16)) != libc.UintptrFromInt32(0) { libtcl9_0.XTcl_Free(tls, *(*uintptr)(unsafe.Pointer(bp + 16))) } if (*TTk_Dash)(unsafe.Pointer(dash)).Fnumber >= 0 { v5 = (*TTk_Dash)(unsafe.Pointer(dash)).Fnumber } else { v5 = -(*TTk_Dash)(unsafe.Pointer(dash)).Fnumber } if uint64(libc.Uint32FromInt32(v5)) > uint64(8) { libtcl9_0.XTcl_Free(tls, *(*uintptr)(unsafe.Pointer(dash + 8))) } (*TTk_Dash)(unsafe.Pointer(dash)).Fnumber = 0 return int32(TCL_ERROR) } /* *-------------------------------------------------------------- * * Tk_CreateOutline * * This function initializes the Tk_Outline structure with default * values. * * Results: * None * * Side effects: * None * *-------------------------------------------------------------- */ func XTk_CreateOutline(tls *libc.TLS, outline uintptr) { /* Outline structure to be filled in. */ (*TTk_Outline)(unsafe.Pointer(outline)).Fgc = libc.UintptrFromInt32(0) (*TTk_Outline)(unsafe.Pointer(outline)).Fwidth = float64(1) (*TTk_Outline)(unsafe.Pointer(outline)).FactiveWidth = float64(0) (*TTk_Outline)(unsafe.Pointer(outline)).FdisabledWidth = float64(0) (*TTk_Outline)(unsafe.Pointer(outline)).Foffset = 0 (*TTk_Outline)(unsafe.Pointer(outline)).FoffsetObj = libc.UintptrFromInt32(0) (*TTk_Outline)(unsafe.Pointer(outline)).Freserved2 = libc.UintptrFromInt32(0) (*TTk_Outline)(unsafe.Pointer(outline)).Freserved3 = libc.UintptrFromInt32(0) (*TTk_Outline)(unsafe.Pointer(outline)).Fdash.Fnumber = 0 (*TTk_Outline)(unsafe.Pointer(outline)).FactiveDash.Fnumber = 0 (*TTk_Outline)(unsafe.Pointer(outline)).FdisabledDash.Fnumber = 0 (*TTk_Outline)(unsafe.Pointer(outline)).Ftsoffset.Fflags = 0 (*TTk_Outline)(unsafe.Pointer(outline)).Ftsoffset.Fxoffset = 0 (*TTk_Outline)(unsafe.Pointer(outline)).Ftsoffset.Fyoffset = 0 (*TTk_Outline)(unsafe.Pointer(outline)).Fcolor = libc.UintptrFromInt32(0) (*TTk_Outline)(unsafe.Pointer(outline)).FactiveColor = libc.UintptrFromInt32(0) (*TTk_Outline)(unsafe.Pointer(outline)).FdisabledColor = libc.UintptrFromInt32(0) (*TTk_Outline)(unsafe.Pointer(outline)).Fstipple = uint64(0) (*TTk_Outline)(unsafe.Pointer(outline)).FactiveStipple = uint64(0) (*TTk_Outline)(unsafe.Pointer(outline)).FdisabledStipple = uint64(0) } /* *-------------------------------------------------------------- * * Tk_DeleteOutline * * This function frees all memory that might be allocated and referenced * in the Tk_Outline structure. * * Results: * None * * Side effects: * None * *-------------------------------------------------------------- */ func XTk_DeleteOutline(tls *libc.TLS, display uintptr, outline uintptr) { var v1, v2, v3 int32 _, _, _ = v1, v2, v3 if (*TTk_Outline)(unsafe.Pointer(outline)).Fgc != libc.UintptrFromInt32(0) { XTk_FreeGC(tls, display, (*TTk_Outline)(unsafe.Pointer(outline)).Fgc) } if (*TTk_Outline)(unsafe.Pointer(outline)).Fdash.Fnumber >= 0 { v1 = (*TTk_Outline)(unsafe.Pointer(outline)).Fdash.Fnumber } else { v1 = -(*TTk_Outline)(unsafe.Pointer(outline)).Fdash.Fnumber } if uint64(libc.Uint32FromInt32(v1)) > uint64(8) { libtcl9_0.XTcl_Free(tls, *(*uintptr)(unsafe.Pointer(outline + 40 + 8))) } if (*TTk_Outline)(unsafe.Pointer(outline)).FactiveDash.Fnumber >= 0 { v2 = (*TTk_Outline)(unsafe.Pointer(outline)).FactiveDash.Fnumber } else { v2 = -(*TTk_Outline)(unsafe.Pointer(outline)).FactiveDash.Fnumber } if uint64(libc.Uint32FromInt32(v2)) > uint64(8) { libtcl9_0.XTcl_Free(tls, *(*uintptr)(unsafe.Pointer(outline + 56 + 8))) } if (*TTk_Outline)(unsafe.Pointer(outline)).FdisabledDash.Fnumber >= 0 { v3 = (*TTk_Outline)(unsafe.Pointer(outline)).FdisabledDash.Fnumber } else { v3 = -(*TTk_Outline)(unsafe.Pointer(outline)).FdisabledDash.Fnumber } if uint64(libc.Uint32FromInt32(v3)) > uint64(8) { libtcl9_0.XTcl_Free(tls, *(*uintptr)(unsafe.Pointer(outline + 72 + 8))) } if (*TTk_Outline)(unsafe.Pointer(outline)).Fcolor != libc.UintptrFromInt32(0) { XTk_FreeColor(tls, (*TTk_Outline)(unsafe.Pointer(outline)).Fcolor) } if (*TTk_Outline)(unsafe.Pointer(outline)).FactiveColor != libc.UintptrFromInt32(0) { XTk_FreeColor(tls, (*TTk_Outline)(unsafe.Pointer(outline)).FactiveColor) } if (*TTk_Outline)(unsafe.Pointer(outline)).FdisabledColor != libc.UintptrFromInt32(0) { XTk_FreeColor(tls, (*TTk_Outline)(unsafe.Pointer(outline)).FdisabledColor) } if (*TTk_Outline)(unsafe.Pointer(outline)).Fstipple != uint64(0) { XTk_FreeBitmap(tls, display, (*TTk_Outline)(unsafe.Pointer(outline)).Fstipple) } if (*TTk_Outline)(unsafe.Pointer(outline)).FactiveStipple != uint64(0) { XTk_FreeBitmap(tls, display, (*TTk_Outline)(unsafe.Pointer(outline)).FactiveStipple) } if (*TTk_Outline)(unsafe.Pointer(outline)).FdisabledStipple != uint64(0) { XTk_FreeBitmap(tls, display, (*TTk_Outline)(unsafe.Pointer(outline)).FdisabledStipple) } } /* *-------------------------------------------------------------- * * Tk_ConfigOutlineGC * * This function should be called in the canvas object during the * configure command. The graphics context description in gcValues is * updated according to the information in the dash structure, as far as * possible. * * Results: * The return-value is a mask, indicating which elements of gcValues have * been updated. 0 means there is no outline. * * Side effects: * GC information in gcValues is updated. * *-------------------------------------------------------------- */ func XTk_ConfigOutlineGC(tls *libc.TLS, gcValues uintptr, canvas TTk_Canvas, item uintptr, outline uintptr) (r int32) { var color, dash uintptr var mask, v1 int32 var state TTk_State var stipple TPixmap var width float64 _, _, _, _, _, _, _ = color, dash, mask, state, stipple, width, v1 mask = 0 state = (*TTk_Item)(unsafe.Pointer(item)).Fstate if (*TTk_Outline)(unsafe.Pointer(outline)).Fwidth < float64(0) { (*TTk_Outline)(unsafe.Pointer(outline)).Fwidth = float64(0) } if (*TTk_Outline)(unsafe.Pointer(outline)).FactiveWidth < float64(0) { (*TTk_Outline)(unsafe.Pointer(outline)).FactiveWidth = float64(0) } if (*TTk_Outline)(unsafe.Pointer(outline)).FdisabledWidth < libc.Float64FromInt32(0) { (*TTk_Outline)(unsafe.Pointer(outline)).FdisabledWidth = float64(0) } if state == int32(TK_STATE_HIDDEN) { return 0 } width = (*TTk_Outline)(unsafe.Pointer(outline)).Fwidth if width < float64(1) { width = float64(1) } dash = outline + 40 color = (*TTk_Outline)(unsafe.Pointer(outline)).Fcolor stipple = (*TTk_Outline)(unsafe.Pointer(outline)).Fstipple if state == int32(TK_STATE_NULL) { state = (*TTkCanvas)(unsafe.Pointer(canvas)).Fcanvas_state } if (*TTkCanvas)(unsafe.Pointer(canvas)).FcurrentItemPtr == item { if (*TTk_Outline)(unsafe.Pointer(outline)).FactiveWidth > width { width = (*TTk_Outline)(unsafe.Pointer(outline)).FactiveWidth } if (*TTk_Outline)(unsafe.Pointer(outline)).FactiveDash.Fnumber != 0 { dash = outline + 56 } if (*TTk_Outline)(unsafe.Pointer(outline)).FactiveColor != libc.UintptrFromInt32(0) { color = (*TTk_Outline)(unsafe.Pointer(outline)).FactiveColor } if (*TTk_Outline)(unsafe.Pointer(outline)).FactiveStipple != uint64(0) { stipple = (*TTk_Outline)(unsafe.Pointer(outline)).FactiveStipple } } else { if state == int32(TK_STATE_DISABLED) { if (*TTk_Outline)(unsafe.Pointer(outline)).FdisabledWidth > libc.Float64FromInt32(0) { width = (*TTk_Outline)(unsafe.Pointer(outline)).FdisabledWidth } if (*TTk_Outline)(unsafe.Pointer(outline)).FdisabledDash.Fnumber != 0 { dash = outline + 72 } if (*TTk_Outline)(unsafe.Pointer(outline)).FdisabledColor != libc.UintptrFromInt32(0) { color = (*TTk_Outline)(unsafe.Pointer(outline)).FdisabledColor } if (*TTk_Outline)(unsafe.Pointer(outline)).FdisabledStipple != uint64(0) { stipple = (*TTk_Outline)(unsafe.Pointer(outline)).FdisabledStipple } } } if color == libc.UintptrFromInt32(0) { return 0 } (*TXGCValues)(unsafe.Pointer(gcValues)).Fline_width = int32(width + libc.Float64FromFloat64(0.5)) if color != libc.UintptrFromInt32(0) { (*TXGCValues)(unsafe.Pointer(gcValues)).Fforeground = (*TXColor)(unsafe.Pointer(color)).Fpixel mask = int32(libc.Int64FromInt64(1)<= 0 { v1 = (*TTk_Dash)(unsafe.Pointer(dash)).Fnumber } else { v1 = -(*TTk_Dash)(unsafe.Pointer(dash)).Fnumber } if uint64(libc.Uint32FromInt32(v1)) > uint64(8) { (*TXGCValues)(unsafe.Pointer(gcValues)).Fdashes = *(*uint8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(dash + 8)))) } else { if (*TTk_Dash)(unsafe.Pointer(dash)).Fnumber != 0 { (*TXGCValues)(unsafe.Pointer(gcValues)).Fdashes = *(*uint8)(unsafe.Pointer(dash + 8)) } else { (*TXGCValues)(unsafe.Pointer(gcValues)).Fdashes = uint8(float64(libc.Float64FromInt32(4)*width) + libc.Float64FromFloat64(0.5)) } } mask = int32(int64(mask) | (libc.Int64FromInt64(1)< width { width = (*TTk_Outline)(unsafe.Pointer(outline)).FactiveWidth } if (*TTk_Outline)(unsafe.Pointer(outline)).FactiveDash.Fnumber != 0 { dash = outline + 56 } if (*TTk_Outline)(unsafe.Pointer(outline)).FactiveColor != libc.UintptrFromInt32(0) { color = (*TTk_Outline)(unsafe.Pointer(outline)).FactiveColor } if (*TTk_Outline)(unsafe.Pointer(outline)).FactiveStipple != uint64(0) { stipple = (*TTk_Outline)(unsafe.Pointer(outline)).FactiveStipple } } else { if state == int32(TK_STATE_DISABLED) { if (*TTk_Outline)(unsafe.Pointer(outline)).FdisabledWidth > width { width = (*TTk_Outline)(unsafe.Pointer(outline)).FdisabledWidth } if (*TTk_Outline)(unsafe.Pointer(outline)).FdisabledDash.Fnumber != 0 { dash = outline + 72 } if (*TTk_Outline)(unsafe.Pointer(outline)).FdisabledColor != libc.UintptrFromInt32(0) { color = (*TTk_Outline)(unsafe.Pointer(outline)).FdisabledColor } if (*TTk_Outline)(unsafe.Pointer(outline)).FdisabledStipple != uint64(0) { stipple = (*TTk_Outline)(unsafe.Pointer(outline)).FdisabledStipple } } } if color == libc.UintptrFromInt32(0) { return 0 } if (*TTk_Dash)(unsafe.Pointer(dash)).Fnumber < -int32(1) || (*TTk_Dash)(unsafe.Pointer(dash)).Fnumber == -int32(1) && libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(dash + 8))) != int32(',') { i = -(*TTk_Dash)(unsafe.Pointer(dash)).Fnumber if i > libc.Int32FromInt64(8) { v1 = *(*uintptr)(unsafe.Pointer(dash + 8)) } else { v1 = dash + 8 } p = v1 q = libtcl9_0.XTcl_Alloc(tls, libc.Uint64FromInt32(int32(2)*i)) i = _DashConvert(tls, q, p, i, width) libx11.XXSetDashes(tls, (*TTkCanvas)(unsafe.Pointer(canvas)).Fdisplay, (*TTk_Outline)(unsafe.Pointer(outline)).Fgc, (*TTk_Outline)(unsafe.Pointer(outline)).Foffset, q, i) libtcl9_0.XTcl_Free(tls, q) } else { if (*TTk_Dash)(unsafe.Pointer(dash)).Fnumber > int32(2) || (*TTk_Dash)(unsafe.Pointer(dash)).Fnumber == int32(2) && libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(dash + 8))) != libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(dash + 8 + 1))) { if (*TTk_Dash)(unsafe.Pointer(dash)).Fnumber > libc.Int32FromInt64(8) { v2 = *(*uintptr)(unsafe.Pointer(dash + 8)) } else { v2 = dash + 8 } p = v2 libx11.XXSetDashes(tls, (*TTkCanvas)(unsafe.Pointer(canvas)).Fdisplay, (*TTk_Outline)(unsafe.Pointer(outline)).Fgc, (*TTk_Outline)(unsafe.Pointer(outline)).Foffset, p, (*TTk_Dash)(unsafe.Pointer(dash)).Fnumber) } } if stipple != uint64(0) { *(*int32)(unsafe.Pointer(bp)) = 0 *(*int32)(unsafe.Pointer(bp + 4)) = 0 tsoffset = outline + 112 flags = (*TTk_TSOffset)(unsafe.Pointer(tsoffset)).Fflags if !(flags&libc.Int32FromInt32(TK_OFFSET_INDEX) != 0) && flags&(libc.Int32FromInt32(TK_OFFSET_CENTER)|libc.Int32FromInt32(TK_OFFSET_MIDDLE)) != 0 { XTk_SizeOfBitmap(tls, (*TTkCanvas)(unsafe.Pointer(canvas)).Fdisplay, stipple, bp, bp+4) if flags&int32(TK_OFFSET_CENTER) != 0 { *(*int32)(unsafe.Pointer(bp)) /= int32(2) } else { *(*int32)(unsafe.Pointer(bp)) = 0 } if flags&int32(TK_OFFSET_MIDDLE) != 0 { *(*int32)(unsafe.Pointer(bp + 4)) /= int32(2) } else { *(*int32)(unsafe.Pointer(bp + 4)) = 0 } } *(*int32)(unsafe.Pointer(tsoffset + 4)) -= *(*int32)(unsafe.Pointer(bp)) *(*int32)(unsafe.Pointer(tsoffset + 8)) -= *(*int32)(unsafe.Pointer(bp + 4)) XTk_CanvasSetOffset(tls, canvas, (*TTk_Outline)(unsafe.Pointer(outline)).Fgc, tsoffset) *(*int32)(unsafe.Pointer(tsoffset + 4)) += *(*int32)(unsafe.Pointer(bp)) *(*int32)(unsafe.Pointer(tsoffset + 8)) += *(*int32)(unsafe.Pointer(bp + 4)) return int32(1) } return 0 } /* *-------------------------------------------------------------- * * Tk_ResetOutlineGC * * Restores the GC to the situation before Tk_ChangeOutlineGC() was * called. This function should be called just after the dashed item is * drawn, because the GC is supposed to be read-only. * * Results: * 1 if there is a stipple pattern, and 0 otherwise. * * Side effects: * GC is updated. * *-------------------------------------------------------------- */ func XTk_ResetOutlineGC(tls *libc.TLS, canvas TTk_Canvas, item uintptr, outline uintptr) (r int32) { bp := tls.Alloc(16) defer tls.Free(16) var color, dash uintptr var state TTk_State var stipple TPixmap var width float64 var v1 int32 var _ /* dashList at bp+0 */ uint8 _, _, _, _, _, _ = color, dash, state, stipple, width, v1 state = (*TTk_Item)(unsafe.Pointer(item)).Fstate width = (*TTk_Outline)(unsafe.Pointer(outline)).Fwidth if width < float64(1) { width = float64(1) } if (*TTk_Outline)(unsafe.Pointer(outline)).FoffsetObj != 0 && XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), (*TTkCanvas)(unsafe.Pointer(canvas)).Ftkwin, (*TTk_Outline)(unsafe.Pointer(outline)).FoffsetObj, outline+32) != TCL_OK { (*TTk_Outline)(unsafe.Pointer(outline)).Foffset = 0 } dash = outline + 40 color = (*TTk_Outline)(unsafe.Pointer(outline)).Fcolor stipple = (*TTk_Outline)(unsafe.Pointer(outline)).Fstipple if state == int32(TK_STATE_NULL) { state = (*TTkCanvas)(unsafe.Pointer(canvas)).Fcanvas_state } if (*TTkCanvas)(unsafe.Pointer(canvas)).FcurrentItemPtr == item { if (*TTk_Outline)(unsafe.Pointer(outline)).FactiveWidth > width { width = (*TTk_Outline)(unsafe.Pointer(outline)).FactiveWidth } if (*TTk_Outline)(unsafe.Pointer(outline)).FactiveDash.Fnumber != 0 { dash = outline + 56 } if (*TTk_Outline)(unsafe.Pointer(outline)).FactiveColor != libc.UintptrFromInt32(0) { color = (*TTk_Outline)(unsafe.Pointer(outline)).FactiveColor } if (*TTk_Outline)(unsafe.Pointer(outline)).FactiveStipple != uint64(0) { stipple = (*TTk_Outline)(unsafe.Pointer(outline)).FactiveStipple } } else { if state == int32(TK_STATE_DISABLED) { if (*TTk_Outline)(unsafe.Pointer(outline)).FdisabledWidth > width { width = (*TTk_Outline)(unsafe.Pointer(outline)).FdisabledWidth } if (*TTk_Outline)(unsafe.Pointer(outline)).FdisabledDash.Fnumber != 0 { dash = outline + 72 } if (*TTk_Outline)(unsafe.Pointer(outline)).FdisabledColor != libc.UintptrFromInt32(0) { color = (*TTk_Outline)(unsafe.Pointer(outline)).FdisabledColor } if (*TTk_Outline)(unsafe.Pointer(outline)).FdisabledStipple != uint64(0) { stipple = (*TTk_Outline)(unsafe.Pointer(outline)).FdisabledStipple } } } if color == libc.UintptrFromInt32(0) { return 0 } if (*TTk_Dash)(unsafe.Pointer(dash)).Fnumber > int32(2) || (*TTk_Dash)(unsafe.Pointer(dash)).Fnumber < -int32(1) || (*TTk_Dash)(unsafe.Pointer(dash)).Fnumber == int32(2) && libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(dash + 8))) != libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(dash + 8 + 1))) || (*TTk_Dash)(unsafe.Pointer(dash)).Fnumber == -int32(1) && libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(dash + 8))) != int32(',') { if (*TTk_Dash)(unsafe.Pointer(dash)).Fnumber >= 0 { v1 = (*TTk_Dash)(unsafe.Pointer(dash)).Fnumber } else { v1 = -(*TTk_Dash)(unsafe.Pointer(dash)).Fnumber } if uint64(libc.Uint32FromInt32(v1)) > uint64(8) { *(*uint8)(unsafe.Pointer(bp)) = *(*uint8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(dash + 8)))) } else { if (*TTk_Dash)(unsafe.Pointer(dash)).Fnumber != 0 { *(*uint8)(unsafe.Pointer(bp)) = *(*uint8)(unsafe.Pointer(dash + 8)) } else { *(*uint8)(unsafe.Pointer(bp)) = uint8(float64(libc.Float64FromInt32(4)*width) + libc.Float64FromFloat64(0.5)) } } libx11.XXSetDashes(tls, (*TTkCanvas)(unsafe.Pointer(canvas)).Fdisplay, (*TTk_Outline)(unsafe.Pointer(outline)).Fgc, (*TTk_Outline)(unsafe.Pointer(outline)).Foffset, bp, int32(1)) } if stipple != uint64(0) { libx11.XXSetTSOrigin(tls, (*TTkCanvas)(unsafe.Pointer(canvas)).Fdisplay, (*TTk_Outline)(unsafe.Pointer(outline)).Fgc, 0, 0) return int32(1) } return 0 } /* *-------------------------------------------------------------- * * Tk_CanvasPsOutline * * Creates the postscript command for the correct Outline-information * (width, dash, color and stipple). * * Results: * TCL_OK if succeeded, otherwise TCL_ERROR. * * Side effects: * canvas->interp->result contains the postscript string, or an error * message if the result was TCL_ERROR. * *-------------------------------------------------------------- */ func XTk_CanvasPsOutline(tls *libc.TLS, canvas TTk_Canvas, item uintptr, outline uintptr) (r int32) { bp := tls.Alloc(32) defer tls.Free(32) var _objPtr, color, converted, dash, interp, lptr, p, p1, psObj, ptr, v1, v11, v3, v5, v7, v8 uintptr var i, v10, v2 int32 var state TTk_State var stipple TPixmap var width float64 var v6 TTcl_Size var _ /* pattern at bp+0 */ [11]uint8 _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = _objPtr, color, converted, dash, i, interp, lptr, p, p1, psObj, ptr, state, stipple, width, v1, v10, v11, v2, v3, v5, v6, v7, v8 lptr = bp interp = (*TTkCanvas)(unsafe.Pointer(canvas)).Finterp width = (*TTk_Outline)(unsafe.Pointer(outline)).Fwidth dash = outline + 40 color = (*TTk_Outline)(unsafe.Pointer(outline)).Fcolor stipple = (*TTk_Outline)(unsafe.Pointer(outline)).Fstipple state = (*TTk_Item)(unsafe.Pointer(item)).Fstate psObj = _GetPostscriptBuffer1(tls, interp) if state == int32(TK_STATE_NULL) { state = (*TTkCanvas)(unsafe.Pointer(canvas)).Fcanvas_state } if (*TTkCanvas)(unsafe.Pointer(canvas)).FcurrentItemPtr == item { if (*TTk_Outline)(unsafe.Pointer(outline)).FactiveWidth > width { width = (*TTk_Outline)(unsafe.Pointer(outline)).FactiveWidth } if (*TTk_Outline)(unsafe.Pointer(outline)).FactiveDash.Fnumber > 0 { dash = outline + 56 } if (*TTk_Outline)(unsafe.Pointer(outline)).FactiveColor != libc.UintptrFromInt32(0) { color = (*TTk_Outline)(unsafe.Pointer(outline)).FactiveColor } if (*TTk_Outline)(unsafe.Pointer(outline)).FactiveStipple != uint64(0) { stipple = (*TTk_Outline)(unsafe.Pointer(outline)).FactiveStipple } } else { if state == int32(TK_STATE_DISABLED) { if (*TTk_Outline)(unsafe.Pointer(outline)).FdisabledWidth > libc.Float64FromInt32(0) { width = (*TTk_Outline)(unsafe.Pointer(outline)).FdisabledWidth } if (*TTk_Outline)(unsafe.Pointer(outline)).FdisabledDash.Fnumber > 0 { dash = outline + 72 } if (*TTk_Outline)(unsafe.Pointer(outline)).FdisabledColor != libc.UintptrFromInt32(0) { color = (*TTk_Outline)(unsafe.Pointer(outline)).FdisabledColor } if (*TTk_Outline)(unsafe.Pointer(outline)).FdisabledStipple != uint64(0) { stipple = (*TTk_Outline)(unsafe.Pointer(outline)).FdisabledStipple } } } if (*TTk_Outline)(unsafe.Pointer(outline)).FoffsetObj != 0 && XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), (*TTkCanvas)(unsafe.Pointer(canvas)).Ftkwin, (*TTk_Outline)(unsafe.Pointer(outline)).FoffsetObj, outline+32) != TCL_OK { (*TTk_Outline)(unsafe.Pointer(outline)).Foffset = 0 } libtcl9_0.XTcl_AppendPrintfToObj(tls, psObj, __ccgo_ts+32407, libc.VaList(bp+24, width)) if (*TTk_Dash)(unsafe.Pointer(dash)).Fnumber >= 0 { v2 = (*TTk_Dash)(unsafe.Pointer(dash)).Fnumber } else { v2 = -(*TTk_Dash)(unsafe.Pointer(dash)).Fnumber } if uint64(libc.Uint32FromInt32(v2)) > uint64(8) { v1 = *(*uintptr)(unsafe.Pointer(dash + 8)) } else { v1 = dash + 8 } ptr = v1 libtcl9_0.XTcl_AppendToObj(tls, psObj, __ccgo_ts+32427, int64(-libc.Int32FromInt32(1))) if (*TTk_Dash)(unsafe.Pointer(dash)).Fnumber > 0 { p = ptr v3 = p p++ converted = libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+14540, libc.VaList(bp+24, libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(v3)))&int32(0xff))) i = (*TTk_Dash)(unsafe.Pointer(dash)).Fnumber - int32(1) for { if !(i > 0) { break } v5 = p p++ libtcl9_0.XTcl_AppendPrintfToObj(tls, converted, __ccgo_ts+32222, libc.VaList(bp+24, libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(v5)))&int32(0xff))) goto _4 _4: ; i-- } libtcl9_0.XTcl_AppendObjToObj(tls, psObj, converted) if (*TTk_Dash)(unsafe.Pointer(dash)).Fnumber&int32(1) != 0 { libtcl9_0.XTcl_AppendToObj(tls, psObj, __ccgo_ts+634, int64(-libc.Int32FromInt32(1))) libtcl9_0.XTcl_AppendObjToObj(tls, psObj, converted) } _objPtr = converted v7 = _objPtr v6 = *(*TTcl_Size)(unsafe.Pointer(v7)) *(*TTcl_Size)(unsafe.Pointer(v7))-- if v6 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr) } libtcl9_0.XTcl_AppendPrintfToObj(tls, psObj, __ccgo_ts+32429, libc.VaList(bp+24, (*TTk_Outline)(unsafe.Pointer(outline)).Foffset)) } else { if (*TTk_Dash)(unsafe.Pointer(dash)).Fnumber < 0 { if (*TTk_Dash)(unsafe.Pointer(dash)).Fnumber < -int32(5) { lptr = libtcl9_0.XTcl_Alloc(tls, libc.Uint64FromInt32(int32(1)-int32(2)*(*TTk_Dash)(unsafe.Pointer(dash)).Fnumber)) } i = _DashConvert(tls, lptr, ptr, -(*TTk_Dash)(unsafe.Pointer(dash)).Fnumber, width) if i > 0 { p1 = lptr v8 = p1 p1++ libtcl9_0.XTcl_AppendPrintfToObj(tls, psObj, __ccgo_ts+14540, libc.VaList(bp+24, libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(v8)))&int32(0xff))) for { i-- v10 = i if !(v10 > 0) { break } v11 = p1 p1++ libtcl9_0.XTcl_AppendPrintfToObj(tls, psObj, __ccgo_ts+32222, libc.VaList(bp+24, libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(v11)))&int32(0xff))) goto _9 _9: } libtcl9_0.XTcl_AppendPrintfToObj(tls, psObj, __ccgo_ts+32429, libc.VaList(bp+24, (*TTk_Outline)(unsafe.Pointer(outline)).Foffset)) } else { libtcl9_0.XTcl_AppendToObj(tls, psObj, __ccgo_ts+32443, int64(-libc.Int32FromInt32(1))) } if lptr != bp { libtcl9_0.XTcl_Free(tls, lptr) } } else { libtcl9_0.XTcl_AppendToObj(tls, psObj, __ccgo_ts+32443, int64(-libc.Int32FromInt32(1))) } } XTk_CanvasPsColor(tls, interp, canvas, color) if stipple != uint64(0) { libtcl9_0.XTcl_AppendToObj(tls, _GetPostscriptBuffer1(tls, interp), __ccgo_ts+32456, int64(-libc.Int32FromInt32(1))) XTk_CanvasPsStipple(tls, interp, canvas, stipple) } else { libtcl9_0.XTcl_AppendToObj(tls, _GetPostscriptBuffer1(tls, interp), __ccgo_ts+32468, int64(-libc.Int32FromInt32(1))) } return TCL_OK } /* *-------------------------------------------------------------- * * DashConvert * * Converts a character-like dash-list (e.g. "-..") into an X11-style. l * must point to a string that holds room to at least 2*n characters. If * l == NULL, this function can be used for syntax checking only. * * Results: * The length of the resulting X11 compatible dash-list. -1 if failed. * * Side effects: * None * *-------------------------------------------------------------- */ func _DashConvert(tls *libc.TLS, l uintptr, p uintptr, n int32, width float64) (r int32) { /* Width of line. */ var intWidth, result, size, v1 int32 var v2, v4, v5, p3 uintptr _, _, _, _, _, _, _, _ = intWidth, result, size, v1, v2, v4, v5, p3 result = 0 if n < 0 { n = libc.Int32FromUint64(libc.Xstrlen(tls, p)) } intWidth = int32(width + libc.Float64FromFloat64(0.5)) if intWidth < int32(1) { intWidth = int32(1) } for { v1 = n n-- if !(v1 != 0 && *(*uint8)(unsafe.Pointer(p)) != 0) { break } v2 = p p++ switch libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(v2))) { case int32(' '): if result != 0 { if l != 0 { p3 = l + uintptr(-libc.Int32FromInt32(1)) *(*uint8)(unsafe.Pointer(p3)) = uint8(int32(*(*uint8)(unsafe.Pointer(p3))) + (intWidth + libc.Int32FromInt32(1))) } continue } return 0 case int32('_'): size = int32(8) case int32('-'): size = int32(6) case int32(','): size = int32(4) case int32('.'): size = int32(2) default: return -int32(1) } if l != 0 { v4 = l l++ *(*uint8)(unsafe.Pointer(v4)) = libc.Uint8FromInt32(size * intWidth) v5 = l l++ *(*uint8)(unsafe.Pointer(v5)) = libc.Uint8FromInt32(int32(4) * intWidth) } result += int32(2) } return result } /* *---------------------------------------------------------------------- * * TranslateAndAppendCoords -- * * This is a helper routine for TkCanvTranslatePath() below. * * Given an (x,y) coordinate pair within a canvas, this function computes * the corresponding coordinates at which the point should be drawn in * the drawable used for display. Those coordinates are then written into * outArr[numOut*2] and outArr[numOut*2+1]. * * Results: * There is no return value. * * Side effects: * None. * *---------------------------------------------------------------------- */ func _TranslateAndAppendCoords(tls *libc.TLS, canvPtr uintptr, x float64, y float64, outArr uintptr, numOut int32) { /* Num of prior entries in outArr[] */ var tmp float64 _ = tmp tmp = x - float64((*TTkCanvas)(unsafe.Pointer(canvPtr)).FdrawableXOrigin) if tmp > libc.Float64FromInt32(0) { tmp += float64(0.5) } else { tmp -= float64(0.5) } (*(*TXPoint)(unsafe.Pointer(outArr + uintptr(numOut)*4))).Fx = int16(tmp) tmp = y - float64((*TTkCanvas)(unsafe.Pointer(canvPtr)).FdrawableYOrigin) if tmp > libc.Float64FromInt32(0) { tmp += float64(0.5) } else { tmp -= float64(0.5) } (*(*TXPoint)(unsafe.Pointer(outArr + uintptr(numOut)*4))).Fy = int16(tmp) } /* *-------------------------------------------------------------- * * TkCanvTranslatePath * * Translate a line or polygon path so that all vertices are within a * rectangle that is 1000 pixels larger than the total size of the canvas * window. This will prevent pixel coordinates from overflowing the * 16-bit integer size limitation imposed by most windowing systems. * * coordPtr must point to an array of doubles, two doubles per vertex. * There are a total of numVertex vertices, or 2*numVertex entries in * coordPtr. The result vertices written into outArr have their * coordinate origin shifted to canvPtr->drawableXOrigin by * canvPtr->drawableYOrigin. There might be as many as 3 times more * output vertices than there are input vertices. The calling function * should allocate space accordingly. * * This routine limits the width and height of a canvas window to 31767 * pixels. At the highest resolution display devices available today (210 * ppi in Jan 2003) that's a window that is over 13 feet wide and tall. * Should be enough for the near future. * * Results: * Clipped and translated path vertices are written into outArr[]. There * might be as many as twice the vertices in outArr[] as there are in * coordPtr[]. The return value is the number of vertices actually * written into outArr[]. * * Side effects: * None * *-------------------------------------------------------------- */ func XTkCanvTranslatePath(tls *libc.TLS, canvPtr uintptr, numVertex int32, coordArr uintptr, dummy1667 int32, outArr uintptr) (r int32) { bp := tls.Alloc(3840) defer tls.Free(3840) /* Write results here, if not NULL */ var a, b, t, tempArr uintptr var btm, lft, priorY, rgh, top, x, x0, x01, x1, xClip, y, y0, y01, y1, yN, yN1 float64 var i, inside, j, numOutput, v2 int32 var limit [4]float64 var _ /* staticSpace at bp+0 */ [480]float64 _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = a, b, btm, i, inside, j, lft, limit, numOutput, priorY, rgh, t, tempArr, top, x, x0, x01, x1, xClip, y, y0, y01, y1, yN, yN1, v2 numOutput = 0 /* Temp space from the stack */ /* * Constrain all vertices of the path to be within a box that is no larger * than 32000 pixels wide or height. The top-left corner of this clipping * box is 1000 pixels above and to the left of the top left corner of the * window on which the canvas is displayed. * * This means that a canvas will not display properly on a canvas window * that is larger than 31000 pixels wide or high. That is not a problem * today, but might someday become a factor for ultra-high resolutions * displays. * * The X11 protocol allows us (in theory) to expand the size of the * clipping box to 32767 pixels. But we have found experimentally that * XFree86 sometimes fails to draw lines correctly if they are longer than * about 32500 pixels. So we have left a little margin in the size to mask * that bug. */ lft = float64((*TTkCanvas)(unsafe.Pointer(canvPtr)).FxOrigin) - float64(1000) top = float64((*TTkCanvas)(unsafe.Pointer(canvPtr)).FyOrigin) - float64(1000) rgh = lft + float64(32000) btm = top + float64(32000) /* * Try the common case first - no clipping. Loop over the input * coordinates and translate them into appropriate output coordinates. * But if a vertex outside of the bounding box is seen, break out of the * loop. * * Most of the time, no clipping is needed, so this one loop is sufficient * to do the translation. */ i = 0 for { if !(i < numVertex) { break } x = *(*float64)(unsafe.Pointer(coordArr + uintptr(i*int32(2))*8)) y = *(*float64)(unsafe.Pointer(coordArr + uintptr(i*int32(2)+int32(1))*8)) if x < lft || x > rgh || y < top || y > btm { break } v2 = numOutput numOutput++ _TranslateAndAppendCoords(tls, canvPtr, x, y, outArr, v2) goto _1 _1: ; i++ } if i == numVertex { return numOutput } /* * If we reach this point, it means that some clipping is required. Begin * by allocating some working storage - at least 6 times as much space as * coordArr[] requires. Divide this space into two separate arrays a[] and * b[]. Initialize a[] to be equal to coordArr[]. */ if numVertex*int32(12) <= libc.Int32FromUint64(libc.Uint64FromInt64(3840)/libc.Uint64FromInt64(8)) { tempArr = bp } else { tempArr = libtcl9_0.XTcl_Alloc(tls, libc.Uint64FromInt32(numVertex*int32(12))*uint64(8)) } i = 0 for { if !(i < numVertex*int32(2)) { break } *(*float64)(unsafe.Pointer(tempArr + uintptr(i)*8)) = *(*float64)(unsafe.Pointer(coordArr + uintptr(i)*8)) goto _3 _3: ; i++ } a = tempArr b = tempArr + uintptr(numVertex*int32(6))*8 /* * We will make four passes through the input data. On each pass, we copy * the contents of a[] over into b[]. As we copy, we clip any line * segments that extend to the right past xClip then we rotate the * coordinate system 90 degrees clockwise. After each pass is complete, we * interchange a[] and b[] in preparation for the next pass. * * Each pass clips line segments that extend beyond a single side of the * bounding box, and four passes rotate the coordinate system back to its * original value. I'm not an expert on graphics algorithms, but I think * this is called Cohen-Sutherland polygon clipping. * * The limit[] array contains the xClip value used for each of the four * passes. */ limit[0] = rgh limit[int32(1)] = -top limit[int32(2)] = -lft limit[int32(3)] = btm /* * This is the loop that makes the four passes through the data. */ j = 0 for { if !(j < int32(4)) { break } xClip = limit[j] inside = libc.BoolInt32(*(*float64)(unsafe.Pointer(a)) < xClip) priorY = *(*float64)(unsafe.Pointer(a + 1*8)) numOutput = 0 /* * Clip everything to the right of xClip. Store the results in b[] * rotated by 90 degrees clockwise. */ i = 0 for { if !(i < numVertex) { break } x1 = *(*float64)(unsafe.Pointer(a + uintptr(i*int32(2))*8)) y1 = *(*float64)(unsafe.Pointer(a + uintptr(i*int32(2)+int32(1))*8)) if x1 >= xClip { /* * The current vertex is to the right of xClip. */ if inside != 0 { x0 = *(*float64)(unsafe.Pointer(a + uintptr(i*int32(2)-int32(2))*8)) y0 = *(*float64)(unsafe.Pointer(a + uintptr(i*int32(2)-int32(1))*8)) yN = y0 + float64((y1-y0)*(xClip-x0))/(x1-x0) *(*float64)(unsafe.Pointer(b + uintptr(numOutput*int32(2))*8)) = -yN *(*float64)(unsafe.Pointer(b + uintptr(numOutput*int32(2)+int32(1))*8)) = xClip numOutput++ priorY = yN inside = 0 } else { if i == 0 { /* * If the first vertex is to the right of xClip, add a * vertex that is the projection of the first vertex onto * the vertical xClip line. */ *(*float64)(unsafe.Pointer(b)) = -y1 *(*float64)(unsafe.Pointer(b + 1*8)) = xClip numOutput = int32(1) priorY = y1 } } } else { /* * The current vertex is to the left of xClip */ if !(inside != 0) { x01 = *(*float64)(unsafe.Pointer(a + uintptr(i*int32(2)-int32(2))*8)) y01 = *(*float64)(unsafe.Pointer(a + uintptr(i*int32(2)-int32(1))*8)) yN1 = y01 + float64((y1-y01)*(xClip-x01))/(x1-x01) if yN1 != priorY { *(*float64)(unsafe.Pointer(b + uintptr(numOutput*int32(2))*8)) = -yN1 *(*float64)(unsafe.Pointer(b + uintptr(numOutput*int32(2)+int32(1))*8)) = xClip numOutput++ } inside = int32(1) } *(*float64)(unsafe.Pointer(b + uintptr(numOutput*int32(2))*8)) = -y1 *(*float64)(unsafe.Pointer(b + uintptr(numOutput*int32(2)+int32(1))*8)) = x1 numOutput++ } goto _5 _5: ; i++ } /* * Interchange a[] and b[] in preparation for the next pass. */ t = a a = b b = t numVertex = numOutput goto _4 _4: ; j++ } /* * All clipping is now finished. Convert the coordinates from doubles into * XPoints and translate the origin for the drawable. */ i = 0 for { if !(i < numVertex) { break } _TranslateAndAppendCoords(tls, canvPtr, *(*float64)(unsafe.Pointer(a + uintptr(i*int32(2))*8)), *(*float64)(unsafe.Pointer(a + uintptr(i*int32(2)+int32(1))*8)), outArr, i) goto _6 _6: ; i++ } if tempArr != bp { libtcl9_0.XTcl_Free(tls, tempArr) } return numOutput } /* *-------------------------------------------------------------- * * TkRotatePoint -- * * Rotate a point about another point. The angle should be converted into * its sine and cosine before calling this function. * * Results: * None * * Side effects: * The point in (*xPtr,*yPtr) is updated to be rotated about * (originX,originY) by the amount given by the sine and cosine of the * angle to rotate. * *-------------------------------------------------------------- */ func XTkRotatePoint(tls *libc.TLS, originX float64, originY float64, sine float64, cosine float64, xPtr uintptr, yPtr uintptr) { /* The point to be rotated. (INOUT) */ var x, y float64 _, _ = x, y x = *(*float64)(unsafe.Pointer(xPtr)) - originX y = *(*float64)(unsafe.Pointer(yPtr)) - originY /* * Beware! The canvas coordinate space is flipped vertically, so rotations * go the "wrong" way with respect to mathematics. */ *(*float64)(unsafe.Pointer(xPtr)) = originX + float64(x*cosine) + float64(y*sine) *(*float64)(unsafe.Pointer(yPtr)) = originY - float64(x*sine) + float64(y*cosine) } /* * Convenience macro. */ /* * The structure below defines the record for each window item. */ type TWindowItem = struct { Fheader TTk_Item Fx float64 Fy float64 Ftkwin TTk_Window Fwidth int32 Fheight int32 Fanchor TTk_Anchor Fcanvas TTk_Canvas } /* * Information used for parsing configuration specs: */ var _stateOption7 = TTk_CustomOption{ FclientData: uintptr(int64(libc.Int32FromInt32(2))), } func init() { p := unsafe.Pointer(&_stateOption7) *(*uintptr)(unsafe.Add(p, 0)) = __ccgo_fp(XTkStateParseProc) *(*uintptr)(unsafe.Add(p, 8)) = __ccgo_fp(XTkStatePrintProc) } var _tagsOption6 = TTk_CustomOption{} func init() { p := unsafe.Pointer(&_tagsOption6) *(*uintptr)(unsafe.Add(p, 0)) = __ccgo_fp(XTk_CanvasTagsParseProc) *(*uintptr)(unsafe.Add(p, 8)) = __ccgo_fp(XTk_CanvasTagsPrintProc) } var _configSpecs9 = [7]TTk_ConfigSpec{ 0: { Ftype1: int32(TK_CONFIG_ANCHOR), FargvName: __ccgo_ts + 15168, FdefValue: __ccgo_ts + 10959, Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 152)), FspecFlags: libc.Int32FromInt32(1) << libc.Int32FromInt32(3), }, 1: { Ftype1: int32(TK_CONFIG_PIXELS), FargvName: __ccgo_ts + 2870, FdefValue: __ccgo_ts + 10533, Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 148)), FspecFlags: libc.Int32FromInt32(1) << libc.Int32FromInt32(3), }, 2: { Ftype1: int32(TK_CONFIG_CUSTOM), FargvName: __ccgo_ts + 2957, Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 96)), FspecFlags: int32(TCL_NULL_OK), FcustomPtr: uintptr(unsafe.Pointer(&_stateOption7)), }, 3: { Ftype1: int32(TK_CONFIG_CUSTOM), FargvName: __ccgo_ts + 28895, FspecFlags: int32(TCL_NULL_OK), FcustomPtr: uintptr(unsafe.Pointer(&_tagsOption6)), }, 4: { Ftype1: int32(TK_CONFIG_PIXELS), FargvName: __ccgo_ts + 2987, FdefValue: __ccgo_ts + 10533, Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 144)), FspecFlags: libc.Int32FromInt32(1) << libc.Int32FromInt32(3), }, 5: { Ftype1: int32(TK_CONFIG_WINDOW), FargvName: __ccgo_ts + 2994, Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 136)), FspecFlags: int32(TCL_NULL_OK), }, 6: { Ftype1: int32(TK_CONFIG_END), }, } func init() { p := unsafe.Pointer(&XtkWindowType) *(*uintptr)(unsafe.Add(p, 16)) = __ccgo_fp(_CreateWinItem) *(*uintptr)(unsafe.Add(p, 32)) = __ccgo_fp(_ConfigureWinItem) *(*uintptr)(unsafe.Add(p, 40)) = __ccgo_fp(_WinItemCoords) *(*uintptr)(unsafe.Add(p, 48)) = __ccgo_fp(_DeleteWinItem) *(*uintptr)(unsafe.Add(p, 56)) = __ccgo_fp(_DisplayWinItem) *(*uintptr)(unsafe.Add(p, 72)) = __ccgo_fp(_WinItemToPoint) *(*uintptr)(unsafe.Add(p, 80)) = __ccgo_fp(_WinItemToArea) *(*uintptr)(unsafe.Add(p, 88)) = __ccgo_fp(_WinItemToPostscript) *(*uintptr)(unsafe.Add(p, 96)) = __ccgo_fp(_ScaleWinItem) *(*uintptr)(unsafe.Add(p, 104)) = __ccgo_fp(_TranslateWinItem) *(*uintptr)(unsafe.Add(p, 160)) = __ccgo_fp(_RotateWinItem) } /* * The structure below defines the official type record for the canvas (as * geometry manager): */ var _canvasGeomType = TTk_GeomMgr{ Fname: __ccgo_ts + 17868, } func init() { p := unsafe.Pointer(&_canvasGeomType) *(*uintptr)(unsafe.Add(p, 8)) = __ccgo_fp(_WinItemRequestProc) *(*uintptr)(unsafe.Add(p, 16)) = __ccgo_fp(_WinItemLostContentProc) } /* *-------------------------------------------------------------- * * CreateWinItem -- * * This function is invoked to create a new window item in a canvas. * * Results: * A standard Tcl return value. If an error occurred in creating the * item, then an error message is left in the interp's result; in this * case itemPtr is left uninitialized, so it can be safely freed by the * caller. * * Side effects: * A new window item is created. * *-------------------------------------------------------------- */ func _CreateWinItem(tls *libc.TLS, interp uintptr, canvas TTk_Canvas, itemPtr uintptr, objc TTcl_Size, objv uintptr) (r int32) { /* Arguments describing window. */ var arg, winItemPtr uintptr var i TTcl_Size _, _, _ = arg, i, winItemPtr winItemPtr = itemPtr if objc == 0 { libtcl9_0.XTcl_Panic(tls, __ccgo_ts+28901, 0) } /* * Initialize item's record. */ (*TWindowItem)(unsafe.Pointer(winItemPtr)).Ftkwin = libc.UintptrFromInt32(0) (*TWindowItem)(unsafe.Pointer(winItemPtr)).Fwidth = 0 (*TWindowItem)(unsafe.Pointer(winItemPtr)).Fheight = 0 (*TWindowItem)(unsafe.Pointer(winItemPtr)).Fanchor = int32(TK_ANCHOR_CENTER) (*TWindowItem)(unsafe.Pointer(winItemPtr)).Fcanvas = canvas /* * Process the arguments to fill in the item record. Only 1 (list) or 2 (x * y) coords are allowed. */ if objc == int64(1) { i = int64(1) } else { arg = libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8)), libc.UintptrFromInt32(0)) i = int64(2) if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(arg))) == int32('-') && libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(arg + 1))) >= int32('a') && libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(arg + 1))) <= int32('z') { i = int64(1) } } if _WinItemCoords(tls, interp, canvas, itemPtr, i, objv) != TCL_OK { goto error } if _ConfigureWinItem(tls, interp, canvas, itemPtr, objc-i, objv+uintptr(i)*8, 0) == TCL_OK { return TCL_OK } goto error error: ; _DeleteWinItem(tls, canvas, itemPtr, (*TTk_FakeWin)(unsafe.Pointer(XTk_CanvasTkwin(tls, canvas))).Fdisplay) return int32(TCL_ERROR) } /* *-------------------------------------------------------------- * * WinItemCoords -- * * This function is invoked to process the "coords" widget command on * window items. See the user documentation for details on what it does. * * Results: * Returns TCL_OK or TCL_ERROR, and sets the interp's result. * * Side effects: * The coordinates for the given item may be changed. * *-------------------------------------------------------------- */ func _WinItemCoords(tls *libc.TLS, interp uintptr, canvas TTk_Canvas, itemPtr uintptr, _objc TTcl_Size, _objv uintptr) (r int32) { bp := tls.Alloc(80) defer tls.Free(80) *(*TTcl_Size)(unsafe.Pointer(bp)) = _objc *(*uintptr)(unsafe.Pointer(bp + 8)) = _objv /* Array of coordinates: x1, y1, x2, y2, ... */ var winItemPtr uintptr var _ /* objs at bp+16 */ [2]uintptr _ = winItemPtr winItemPtr = itemPtr if *(*TTcl_Size)(unsafe.Pointer(bp)) == 0 { (*(*[2]uintptr)(unsafe.Pointer(bp + 16)))[0] = libtcl9_0.XTcl_NewDoubleObj(tls, (*TWindowItem)(unsafe.Pointer(winItemPtr)).Fx) (*(*[2]uintptr)(unsafe.Pointer(bp + 16)))[int32(1)] = libtcl9_0.XTcl_NewDoubleObj(tls, (*TWindowItem)(unsafe.Pointer(winItemPtr)).Fy) libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewListObj(tls, int64(2), bp+16)) } else { if *(*TTcl_Size)(unsafe.Pointer(bp)) < int64(3) { if *(*TTcl_Size)(unsafe.Pointer(bp)) == int64(1) { if libtcl9_0.XTcl_ListObjGetElements(tls, interp, *(*uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 8)))), bp, bp+8) != TCL_OK { return int32(TCL_ERROR) } else { if *(*TTcl_Size)(unsafe.Pointer(bp)) != int64(2) { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+29328, libc.VaList(bp+40, *(*TTcl_Size)(unsafe.Pointer(bp))))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+40, __ccgo_ts+179, __ccgo_ts+27003, __ccgo_ts+28973, __ccgo_ts+1064, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) } } } if XTk_CanvasGetCoordFromObj(tls, interp, canvas, *(*uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 8)))), winItemPtr+120) != TCL_OK || XTk_CanvasGetCoordFromObj(tls, interp, canvas, *(*uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 8)) + 1*8)), winItemPtr+128) != TCL_OK { return int32(TCL_ERROR) } _ComputeWindowBbox(tls, canvas, winItemPtr) } else { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+29369, libc.VaList(bp+40, *(*TTcl_Size)(unsafe.Pointer(bp))))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+40, __ccgo_ts+179, __ccgo_ts+27003, __ccgo_ts+28973, __ccgo_ts+1064, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) } } return TCL_OK } /* *-------------------------------------------------------------- * * ConfigureWinItem -- * * This function is invoked to configure various aspects of a window * item, such as its anchor position. * * Results: * A standard Tcl result code. If an error occurs, then an error message * is left in the interp's result. * * Side effects: * Configuration information may be set for itemPtr. * *-------------------------------------------------------------- */ func _ConfigureWinItem(tls *libc.TLS, interp uintptr, canvas TTk_Canvas, itemPtr uintptr, objc TTcl_Size, objv uintptr, flags int32) (r int32) { bp := tls.Alloc(48) defer tls.Free(48) /* Flags to pass to Tk_ConfigureWidget. */ var ancestor, canvasTkwin, oldWindow, parent TTk_Window var winItemPtr uintptr _, _, _, _, _ = ancestor, canvasTkwin, oldWindow, parent, winItemPtr winItemPtr = itemPtr oldWindow = (*TWindowItem)(unsafe.Pointer(winItemPtr)).Ftkwin canvasTkwin = XTk_CanvasTkwin(tls, canvas) if TCL_OK != XTk_ConfigureWidget(tls, interp, canvasTkwin, uintptr(unsafe.Pointer(&_configSpecs9)), objc, objv, winItemPtr, flags) { return int32(TCL_ERROR) } /* * A few of the options require additional processing. */ if oldWindow != (*TWindowItem)(unsafe.Pointer(winItemPtr)).Ftkwin { if oldWindow != libc.UintptrFromInt32(0) { XTk_DeleteEventHandler(tls, oldWindow, libc.Uint64FromInt64(libc.Int64FromInt64(1)<= libc.Float64FromInt32(0) { v1 = float64(0.5) } else { v1 = -libc.Float64FromFloat64(0.5) } x = int32((*TWindowItem)(unsafe.Pointer(winItemPtr)).Fx + v1) if (*TWindowItem)(unsafe.Pointer(winItemPtr)).Fy >= libc.Float64FromInt32(0) { v2 = float64(0.5) } else { v2 = -libc.Float64FromFloat64(0.5) } y = int32((*TWindowItem)(unsafe.Pointer(winItemPtr)).Fy + v2) if state == int32(TK_STATE_NULL) { state = (*TTkCanvas)(unsafe.Pointer(canvas)).Fcanvas_state } if (*TWindowItem)(unsafe.Pointer(winItemPtr)).Ftkwin == libc.UintptrFromInt32(0) || state == int32(TK_STATE_HIDDEN) { /* * There is no window for this item yet. Just give it a 1x1 bounding * box. Don't give it a 0x0 bounding box; there are strange cases * where this bounding box might be used as the dimensions of the * window, and 0x0 causes problems under X. */ (*TWindowItem)(unsafe.Pointer(winItemPtr)).Fheader.Fx1 = x (*TWindowItem)(unsafe.Pointer(winItemPtr)).Fheader.Fx2 = (*TWindowItem)(unsafe.Pointer(winItemPtr)).Fheader.Fx1 + int32(1) (*TWindowItem)(unsafe.Pointer(winItemPtr)).Fheader.Fy1 = y (*TWindowItem)(unsafe.Pointer(winItemPtr)).Fheader.Fy2 = (*TWindowItem)(unsafe.Pointer(winItemPtr)).Fheader.Fy1 + int32(1) return } /* * Compute dimensions of window. */ width = (*TWindowItem)(unsafe.Pointer(winItemPtr)).Fwidth if width <= 0 { width = (*TTk_FakeWin)(unsafe.Pointer((*TWindowItem)(unsafe.Pointer(winItemPtr)).Ftkwin)).FreqWidth if width <= 0 { width = int32(1) } } height = (*TWindowItem)(unsafe.Pointer(winItemPtr)).Fheight if height <= 0 { height = (*TTk_FakeWin)(unsafe.Pointer((*TWindowItem)(unsafe.Pointer(winItemPtr)).Ftkwin)).FreqHeight if height <= 0 { height = int32(1) } } /* * Compute location of window, using anchor information. */ switch (*TWindowItem)(unsafe.Pointer(winItemPtr)).Fanchor { case int32(TK_ANCHOR_N): x -= width / int32(2) case int32(TK_ANCHOR_NE): x -= width case int32(TK_ANCHOR_E): x -= width y -= height / int32(2) case int32(TK_ANCHOR_SE): x -= width y -= height case int32(TK_ANCHOR_S): x -= width / int32(2) y -= height case int32(TK_ANCHOR_SW): y -= height case int32(TK_ANCHOR_W): y -= height / int32(2) case int32(TK_ANCHOR_NW): default: x -= width / int32(2) y -= height / int32(2) break } /* * Store the information in the item header. */ (*TWindowItem)(unsafe.Pointer(winItemPtr)).Fheader.Fx1 = x (*TWindowItem)(unsafe.Pointer(winItemPtr)).Fheader.Fy1 = y (*TWindowItem)(unsafe.Pointer(winItemPtr)).Fheader.Fx2 = x + width (*TWindowItem)(unsafe.Pointer(winItemPtr)).Fheader.Fy2 = y + height } /* *-------------------------------------------------------------- * * DisplayWinItem -- * * This function is invoked to "draw" a window item in a given drawable. * Since the window draws itself, we needn't do any actual redisplay * here. However, this function takes care of actually repositioning the * child window so that it occupies the correct screen position. * * Results: * None. * * Side effects: * The child window's position may get changed. Note: this function gets * called both when a window needs to be displayed and when it ceases to * be visible on the screen (e.g. it was scrolled or moved off-screen or * the enclosing canvas is unmapped). * *-------------------------------------------------------------- */ func _DisplayWinItem(tls *libc.TLS, canvas TTk_Canvas, itemPtr uintptr, dummy562 uintptr, drawable TDrawable, dummy564 int32, dummy565 int32, dummy566 int32, dummy567 int32) { bp := tls.Alloc(16) defer tls.Free(16) var canvasTkwin TTk_Window var height, width int32 var state TTk_State var winItemPtr uintptr var _ /* x at bp+0 */ int16 var _ /* y at bp+2 */ int16 _, _, _, _, _ = canvasTkwin, height, state, width, winItemPtr winItemPtr = itemPtr canvasTkwin = XTk_CanvasTkwin(tls, canvas) state = (*TTk_Item)(unsafe.Pointer(itemPtr)).Fstate if (*TWindowItem)(unsafe.Pointer(winItemPtr)).Ftkwin == libc.UintptrFromInt32(0) { return } libtcl9_0.XTcl_Preserve(tls, canvas) if state == int32(TK_STATE_NULL) { state = (*TTkCanvas)(unsafe.Pointer(canvas)).Fcanvas_state } /* * A drawable of None is used by the canvas UnmapNotify handler * to indicate that we should no longer display ourselves. */ if state == int32(TK_STATE_HIDDEN) || drawable == uint64(0) { if canvasTkwin == (*TTk_FakeWin)(unsafe.Pointer((*TWindowItem)(unsafe.Pointer(winItemPtr)).Ftkwin)).FparentPtr { XTk_UnmapWindow(tls, (*TWindowItem)(unsafe.Pointer(winItemPtr)).Ftkwin) } else { XTk_UnmaintainGeometry(tls, (*TWindowItem)(unsafe.Pointer(winItemPtr)).Ftkwin, canvasTkwin) } libtcl9_0.XTcl_Release(tls, canvas) return } XTk_CanvasWindowCoords(tls, canvas, float64((*TWindowItem)(unsafe.Pointer(winItemPtr)).Fheader.Fx1), float64((*TWindowItem)(unsafe.Pointer(winItemPtr)).Fheader.Fy1), bp, bp+2) width = (*TWindowItem)(unsafe.Pointer(winItemPtr)).Fheader.Fx2 - (*TWindowItem)(unsafe.Pointer(winItemPtr)).Fheader.Fx1 height = (*TWindowItem)(unsafe.Pointer(winItemPtr)).Fheader.Fy2 - (*TWindowItem)(unsafe.Pointer(winItemPtr)).Fheader.Fy1 /* * If the window is completely out of the visible area of the canvas then * unmap it. This code used not to be present (why unmap the window if it * isn't visible anyway?) but this could cause the window to suddenly * reappear if the canvas window got resized. */ if int32(*(*int16)(unsafe.Pointer(bp)))+width <= 0 || int32(*(*int16)(unsafe.Pointer(bp + 2)))+height <= 0 || int32(*(*int16)(unsafe.Pointer(bp))) >= (*TTk_FakeWin)(unsafe.Pointer(canvasTkwin)).Fchanges.Fwidth || int32(*(*int16)(unsafe.Pointer(bp + 2))) >= (*TTk_FakeWin)(unsafe.Pointer(canvasTkwin)).Fchanges.Fheight { if canvasTkwin == (*TTk_FakeWin)(unsafe.Pointer((*TWindowItem)(unsafe.Pointer(winItemPtr)).Ftkwin)).FparentPtr { XTk_UnmapWindow(tls, (*TWindowItem)(unsafe.Pointer(winItemPtr)).Ftkwin) } else { XTk_UnmaintainGeometry(tls, (*TWindowItem)(unsafe.Pointer(winItemPtr)).Ftkwin, canvasTkwin) } libtcl9_0.XTcl_Release(tls, canvas) return } /* * Reposition and map the window (but in different ways depending on * whether the canvas is the window's parent). */ if canvasTkwin == (*TTk_FakeWin)(unsafe.Pointer((*TWindowItem)(unsafe.Pointer(winItemPtr)).Ftkwin)).FparentPtr { if int32(*(*int16)(unsafe.Pointer(bp))) != (*TTk_FakeWin)(unsafe.Pointer((*TWindowItem)(unsafe.Pointer(winItemPtr)).Ftkwin)).Fchanges.Fx || int32(*(*int16)(unsafe.Pointer(bp + 2))) != (*TTk_FakeWin)(unsafe.Pointer((*TWindowItem)(unsafe.Pointer(winItemPtr)).Ftkwin)).Fchanges.Fy || width != (*TTk_FakeWin)(unsafe.Pointer((*TWindowItem)(unsafe.Pointer(winItemPtr)).Ftkwin)).Fchanges.Fwidth || height != (*TTk_FakeWin)(unsafe.Pointer((*TWindowItem)(unsafe.Pointer(winItemPtr)).Ftkwin)).Fchanges.Fheight { XTk_MoveResizeWindow(tls, (*TWindowItem)(unsafe.Pointer(winItemPtr)).Ftkwin, int32(*(*int16)(unsafe.Pointer(bp))), int32(*(*int16)(unsafe.Pointer(bp + 2))), width, height) } if (*TWindowItem)(unsafe.Pointer(winItemPtr)).Ftkwin != 0 { XTk_MapWindow(tls, (*TWindowItem)(unsafe.Pointer(winItemPtr)).Ftkwin) } } else { XTk_MaintainGeometry(tls, (*TWindowItem)(unsafe.Pointer(winItemPtr)).Ftkwin, canvasTkwin, int32(*(*int16)(unsafe.Pointer(bp))), int32(*(*int16)(unsafe.Pointer(bp + 2))), width, height) } libtcl9_0.XTcl_Release(tls, canvas) } /* *-------------------------------------------------------------- * * WinItemToPoint -- * * Computes the distance from a given point to a given window, in canvas * units. * * Results: * The return value is 0 if the point whose x and y coordinates are * coordPtr[0] and coordPtr[1] is inside the window. If the point isn't * inside the window then the return value is the distance from the point * to the window. * * Side effects: * None. * *-------------------------------------------------------------- */ func _WinItemToPoint(tls *libc.TLS, dummy666 TTk_Canvas, itemPtr uintptr, pointPtr uintptr) (r float64) { /* Pointer to x and y coordinates. */ var winItemPtr uintptr var x1, x2, xDiff, y1, y2, yDiff float64 _, _, _, _, _, _, _ = winItemPtr, x1, x2, xDiff, y1, y2, yDiff winItemPtr = itemPtr x1 = float64((*TWindowItem)(unsafe.Pointer(winItemPtr)).Fheader.Fx1) y1 = float64((*TWindowItem)(unsafe.Pointer(winItemPtr)).Fheader.Fy1) x2 = float64((*TWindowItem)(unsafe.Pointer(winItemPtr)).Fheader.Fx2) y2 = float64((*TWindowItem)(unsafe.Pointer(winItemPtr)).Fheader.Fy2) /* * Point is outside window. */ if *(*float64)(unsafe.Pointer(pointPtr)) < x1 { xDiff = x1 - *(*float64)(unsafe.Pointer(pointPtr)) } else { if *(*float64)(unsafe.Pointer(pointPtr)) >= x2 { xDiff = *(*float64)(unsafe.Pointer(pointPtr)) + libc.Float64FromInt32(1) - x2 } else { xDiff = libc.Float64FromInt32(0) } } if *(*float64)(unsafe.Pointer(pointPtr + 1*8)) < y1 { yDiff = y1 - *(*float64)(unsafe.Pointer(pointPtr + 1*8)) } else { if *(*float64)(unsafe.Pointer(pointPtr + 1*8)) >= y2 { yDiff = *(*float64)(unsafe.Pointer(pointPtr + 1*8)) + libc.Float64FromInt32(1) - y2 } else { yDiff = libc.Float64FromInt32(0) } } return libc.X__builtin_hypot(tls, xDiff, yDiff) } /* *-------------------------------------------------------------- * * WinItemToArea -- * * This function is called to determine whether an item lies entirely * inside, entirely outside, or overlapping a given rectangle. * * Results: * -1 is returned if the item is entirely outside the area given by * rectPtr, 0 if it overlaps, and 1 if it is entirely inside the given * area. * * Side effects: * None. * *-------------------------------------------------------------- */ func _WinItemToArea(tls *libc.TLS, dummy722 TTk_Canvas, itemPtr uintptr, rectPtr uintptr) (r int32) { /* Pointer to array of four coordinates * (x1,y1,x2,y2) describing rectangular * area. */ var winItemPtr uintptr _ = winItemPtr winItemPtr = itemPtr if *(*float64)(unsafe.Pointer(rectPtr + 2*8)) <= float64((*TWindowItem)(unsafe.Pointer(winItemPtr)).Fheader.Fx1) || *(*float64)(unsafe.Pointer(rectPtr)) >= float64((*TWindowItem)(unsafe.Pointer(winItemPtr)).Fheader.Fx2) || *(*float64)(unsafe.Pointer(rectPtr + 3*8)) <= float64((*TWindowItem)(unsafe.Pointer(winItemPtr)).Fheader.Fy1) || *(*float64)(unsafe.Pointer(rectPtr + 1*8)) >= float64((*TWindowItem)(unsafe.Pointer(winItemPtr)).Fheader.Fy2) { return -int32(1) } if *(*float64)(unsafe.Pointer(rectPtr)) <= float64((*TWindowItem)(unsafe.Pointer(winItemPtr)).Fheader.Fx1) && *(*float64)(unsafe.Pointer(rectPtr + 1*8)) <= float64((*TWindowItem)(unsafe.Pointer(winItemPtr)).Fheader.Fy1) && *(*float64)(unsafe.Pointer(rectPtr + 2*8)) >= float64((*TWindowItem)(unsafe.Pointer(winItemPtr)).Fheader.Fx2) && *(*float64)(unsafe.Pointer(rectPtr + 3*8)) >= float64((*TWindowItem)(unsafe.Pointer(winItemPtr)).Fheader.Fy2) { return int32(1) } return 0 } /* *-------------------------------------------------------------- * * xerrorhandler -- * * This is a dummy function to catch X11 errors during an attempt to * print a canvas window. * * Results: * None. * * Side effects: * None. * *-------------------------------------------------------------- */ func _xerrorhandler(tls *libc.TLS, dummy765 uintptr, dummy766 uintptr) (r int32) { return 0 } /* *-------------------------------------------------------------- * * WinItemToPostscript -- * * This function is called to generate Postscript for window items. * * Results: * The return value is a standard Tcl result. If an error occurs in * generating Postscript then an error message is left in interp->result, * replacing whatever used to be there. If no error occurs, then * Postscript for the item is appended to the result. * * Side effects: * None. * *-------------------------------------------------------------- */ func _WinItemToPostscript(tls *libc.TLS, interp uintptr, canvas TTk_Canvas, itemPtr uintptr, prepass int32) (r int32) { /* 1 means this is a prepass to collect font * information; 0 means final Postscript is * being created. */ var height, width int32 var tkwin TTk_Window var winItemPtr uintptr var x, y float64 _, _, _, _, _, _ = height, tkwin, width, winItemPtr, x, y winItemPtr = itemPtr tkwin = (*TWindowItem)(unsafe.Pointer(winItemPtr)).Ftkwin if prepass != 0 || (*TWindowItem)(unsafe.Pointer(winItemPtr)).Ftkwin == libc.UintptrFromInt32(0) { return TCL_OK } width = (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fchanges.Fwidth height = (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fchanges.Fheight /* * Compute the coordinates of the lower-left corner of the window, taking * into account the anchor position for the window. */ x = (*TWindowItem)(unsafe.Pointer(winItemPtr)).Fx y = XTk_CanvasPsY(tls, canvas, (*TWindowItem)(unsafe.Pointer(winItemPtr)).Fy) switch (*TWindowItem)(unsafe.Pointer(winItemPtr)).Fanchor { case int32(TK_ANCHOR_NW): y -= float64(height) case int32(TK_ANCHOR_N): x -= float64(width) / float64(2) y -= float64(height) case int32(TK_ANCHOR_NE): x -= float64(width) y -= float64(height) case int32(TK_ANCHOR_E): x -= float64(width) y -= float64(height) / float64(2) case int32(TK_ANCHOR_SE): x -= float64(width) case int32(TK_ANCHOR_S): x -= float64(width) / float64(2) case int32(TK_ANCHOR_SW): case int32(TK_ANCHOR_W): y -= float64(height) / float64(2) default: x -= float64(width) / float64(2) y -= float64(height) / float64(2) break } return _CanvasPsWindow(tls, interp, tkwin, canvas, x, y, width, height) } func _CanvasPsWindow(tls *libc.TLS, interp uintptr, tkwin TTk_Window, canvas TTk_Canvas, x float64, y float64, width int32, height int32) (r int32) { bp := tls.Alloc(64) defer tls.Free(64) /* width/height of window. */ var _objPtr, _objPtr1, cmdObj, psObj, ximage, v2, v4 uintptr var handle TTk_ErrorHandler var interpState TTcl_InterpState var result int32 var v1, v3 TTcl_Size _, _, _, _, _, _, _, _, _, _, _, _ = _objPtr, _objPtr1, cmdObj, handle, interpState, psObj, result, ximage, v1, v2, v3, v4 interpState = libtcl9_0.XTcl_SaveInterpState(tls, interp, TCL_OK) /* * Locate the subwindow within the wider window. */ psObj = libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+32521, libc.VaList(bp+8, (*TTk_FakeWin)(unsafe.Pointer(tkwin)).FclassUid, (*TTk_FakeWin)(unsafe.Pointer(tkwin)).FpathName, width, height, x, y)) /* * First try if the widget has its own "postscript" command. If it exists, * this will produce much better postscript than when a pixmap is used. */ libtcl9_0.XTcl_ResetResult(tls, interp) cmdObj = libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+32572, libc.VaList(bp+8, (*TTk_FakeWin)(unsafe.Pointer(tkwin)).FpathName)) (*TTcl_Obj)(unsafe.Pointer(cmdObj)).FrefCount++ result = libtcl9_0.XTcl_EvalObjEx(tls, interp, cmdObj, 0) _objPtr = cmdObj v2 = _objPtr v1 = *(*TTcl_Size)(unsafe.Pointer(v2)) *(*TTcl_Size)(unsafe.Pointer(v2))-- if v1 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr) } if result == TCL_OK { libtcl9_0.XTcl_AppendPrintfToObj(tls, psObj, __ccgo_ts+32596, libc.VaList(bp+8, height, width, height, width)) libtcl9_0.XTcl_AppendObjToObj(tls, psObj, libtcl9_0.XTcl_GetObjResult(tls, interp)) libtcl9_0.XTcl_AppendToObj(tls, psObj, __ccgo_ts+32741, int64(-libc.Int32FromInt32(1))) goto done } /* * If the window is off the screen it will generate a BadMatch/XError. We * catch any BadMatch errors here */ handle = XTk_CreateErrorHandler(tls, (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fdisplay, int32(BadMatch), int32(X_GetImage), -int32(1), __ccgo_fp(_xerrorhandler), tkwin) /* * Generate an XImage from the window. We can then read pixel values out * of the XImage. */ ximage = libx11.XXGetImage(tls, (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fdisplay, (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fwindow, 0, 0, libc.Uint32FromInt32(width), libc.Uint32FromInt32(height), libc.Uint64FromInt64(^libc.Int64FromInt64(0)), int32(ZPixmap)) XTk_DeleteErrorHandler(tls, handle) if ximage == libc.UintptrFromInt32(0) { result = TCL_OK } else { libtcl9_0.XTcl_ResetResult(tls, interp) result = XTkPostscriptImage(tls, interp, tkwin, (*TTkCanvas)(unsafe.Pointer(canvas)).FpsInfo, ximage, 0, 0, width, height) libtcl9_0.XTcl_AppendObjToObj(tls, psObj, libtcl9_0.XTcl_GetObjResult(tls, interp)) (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*TXImage)(unsafe.Pointer(ximage)).Ff.Fdestroy_image})))(tls, ximage) } /* * Plug the accumulated postscript back into the result. */ goto done done: ; if result == TCL_OK { libtcl9_0.XTcl_RestoreInterpState(tls, interp, interpState) libtcl9_0.XTcl_AppendObjToObj(tls, libtcl9_0.XTcl_GetObjResult(tls, interp), psObj) } else { libtcl9_0.XTcl_DiscardInterpState(tls, interpState) } _objPtr1 = psObj v4 = _objPtr1 v3 = *(*TTcl_Size)(unsafe.Pointer(v4)) *(*TTcl_Size)(unsafe.Pointer(v4))-- if v3 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr1) } return result } /* *-------------------------------------------------------------- * * RotateWinItem -- * * This function is called to rotate a window item by a given amount * about a point. Note that this does *not* rotate the window of the * item. * * Results: * None. * * Side effects: * The position of the window anchor is rotated by angleRad about (originX, * originY), and the bounding box is updated in the generic part of the * item structure. * *-------------------------------------------------------------- */ func _RotateWinItem(tls *libc.TLS, canvas TTk_Canvas, itemPtr uintptr, originX float64, originY float64, angleRad float64) { /* Amount by which item is to be rotated. */ var winItemPtr uintptr _ = winItemPtr winItemPtr = itemPtr XTkRotatePoint(tls, originX, originY, libc.Xsin(tls, angleRad), libc.Xcos(tls, angleRad), winItemPtr+120, winItemPtr+128) _ComputeWindowBbox(tls, canvas, winItemPtr) } /* *-------------------------------------------------------------- * * ScaleWinItem -- * * This function is invoked to rescale a window item. * * Results: * None. * * Side effects: * The window referred to by itemPtr is rescaled so that the following * transformation is applied to all point coordinates: * x' = originX + scaleX*(x-originX) * y' = originY + scaleY*(y-originY) * *-------------------------------------------------------------- */ func _ScaleWinItem(tls *libc.TLS, canvas TTk_Canvas, itemPtr uintptr, originX float64, originY float64, scaleX float64, scaleY float64) { /* Amount to scale in Y direction. */ var winItemPtr uintptr _ = winItemPtr winItemPtr = itemPtr (*TWindowItem)(unsafe.Pointer(winItemPtr)).Fx = originX + float64(scaleX*((*TWindowItem)(unsafe.Pointer(winItemPtr)).Fx-originX)) (*TWindowItem)(unsafe.Pointer(winItemPtr)).Fy = originY + float64(scaleY*((*TWindowItem)(unsafe.Pointer(winItemPtr)).Fy-originY)) if (*TWindowItem)(unsafe.Pointer(winItemPtr)).Fwidth > 0 { (*TWindowItem)(unsafe.Pointer(winItemPtr)).Fwidth = int32(float64(scaleX * float64((*TWindowItem)(unsafe.Pointer(winItemPtr)).Fwidth))) } if (*TWindowItem)(unsafe.Pointer(winItemPtr)).Fheight > 0 { (*TWindowItem)(unsafe.Pointer(winItemPtr)).Fheight = int32(float64(scaleY * float64((*TWindowItem)(unsafe.Pointer(winItemPtr)).Fheight))) } _ComputeWindowBbox(tls, canvas, winItemPtr) } /* *-------------------------------------------------------------- * * TranslateWinItem -- * * This function is called to move a window by a given amount. * * Results: * None. * * Side effects: * The position of the window is offset by (xDelta, yDelta), and the * bounding box is updated in the generic part of the item structure. * *-------------------------------------------------------------- */ func _TranslateWinItem(tls *libc.TLS, canvas TTk_Canvas, itemPtr uintptr, deltaX float64, deltaY float64) { /* Amount by which item is to be moved. */ var winItemPtr uintptr _ = winItemPtr winItemPtr = itemPtr *(*float64)(unsafe.Pointer(winItemPtr + 120)) += deltaX *(*float64)(unsafe.Pointer(winItemPtr + 128)) += deltaY _ComputeWindowBbox(tls, canvas, winItemPtr) } /* *-------------------------------------------------------------- * * WinItemStructureProc -- * * This function is invoked whenever StructureNotify events occur for a * window that's managed as part of a canvas window item. This function's * only purpose is to clean up when windows are deleted. * * Results: * None. * * Side effects: * The window is disassociated from the window item when it is deleted. * *-------------------------------------------------------------- */ func _WinItemStructureProc(tls *libc.TLS, clientData uintptr, eventPtr uintptr) { /* Describes what just happened. */ var winItemPtr uintptr _ = winItemPtr winItemPtr = clientData if (*TXEvent)(unsafe.Pointer(eventPtr)).Ftype1 == int32(DestroyNotify) { (*TWindowItem)(unsafe.Pointer(winItemPtr)).Ftkwin = libc.UintptrFromInt32(0) } } /* *-------------------------------------------------------------- * * WinItemRequestProc -- * * This function is invoked whenever a window that's associated with a * window canvas item changes its requested dimensions. * * Results: * None. * * Side effects: * The size and location on the screen of the window may change, * depending on the options specified for the window item. * *-------------------------------------------------------------- */ func _WinItemRequestProc(tls *libc.TLS, clientData uintptr, dummy1086 TTk_Window) { /* Window that changed its desired size. */ var winItemPtr uintptr _ = winItemPtr winItemPtr = clientData _ComputeWindowBbox(tls, (*TWindowItem)(unsafe.Pointer(winItemPtr)).Fcanvas, winItemPtr) /* * A drawable argument of None to DisplayWinItem is used by the canvas * UnmapNotify handler to indicate that we should no longer display * ourselves, so need to pass a (bogus) non-zero drawable value here. */ _DisplayWinItem(tls, (*TWindowItem)(unsafe.Pointer(winItemPtr)).Fcanvas, winItemPtr, libc.UintptrFromInt32(0), libc.Uint64FromInt32(-libc.Int32FromInt32(1)), 0, 0, 0, 0) } /* *-------------------------------------------------------------- * * WinItemLostContentProc -- * * This function is invoked by Tk whenever some other geometry claims * control over a content window that used to be managed by us. * * Results: * None. * * Side effects: * Forgets all canvas-related information about the content window. * *-------------------------------------------------------------- */ func _WinItemLostContentProc(tls *libc.TLS, clientData uintptr, dummy1122 TTk_Window) { /* Tk's handle for the content window. */ var canvasTkwin TTk_Window var winItemPtr uintptr _, _ = canvasTkwin, winItemPtr winItemPtr = clientData canvasTkwin = XTk_CanvasTkwin(tls, (*TWindowItem)(unsafe.Pointer(winItemPtr)).Fcanvas) XTk_DeleteEventHandler(tls, (*TWindowItem)(unsafe.Pointer(winItemPtr)).Ftkwin, libc.Uint64FromInt64(libc.Int64FromInt64(1)<= int32('a') && libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(arg + 1))) <= int32('z') { break } goto _1 _1: ; i++ } if _RectOvalCoords(tls, interp, canvas, itemPtr, i, objv) != TCL_OK { goto error } if _ConfigureRectOval(tls, interp, canvas, itemPtr, objc-i, objv+uintptr(i)*8, 0) == TCL_OK { return TCL_OK } goto error error: ; _DeleteRectOval(tls, canvas, itemPtr, (*TTk_FakeWin)(unsafe.Pointer(XTk_CanvasTkwin(tls, canvas))).Fdisplay) return int32(TCL_ERROR) } /* *-------------------------------------------------------------- * * RectOvalCoords -- * * This function is invoked to process the "coords" widget command on * rectangles and ovals. See the user documentation for details on what * it does. * * Results: * Returns TCL_OK or TCL_ERROR, and sets the interp's result. * * Side effects: * The coordinates for the given item may be changed. * *-------------------------------------------------------------- */ func _RectOvalCoords(tls *libc.TLS, interp uintptr, canvas TTk_Canvas, itemPtr uintptr, _objc TTcl_Size, _objv uintptr) (r int32) { bp := tls.Alloc(96) defer tls.Free(96) *(*TTcl_Size)(unsafe.Pointer(bp)) = _objc *(*uintptr)(unsafe.Pointer(bp + 8)) = _objv /* Array of coordinates: x1,y1,x2,y2,... */ var rectOvalPtr, v1 uintptr var _ /* bbox at bp+16 */ [4]uintptr _, _ = rectOvalPtr, v1 rectOvalPtr = itemPtr /* * If no coordinates, return the current coordinates (i.e. bounding box). */ if *(*TTcl_Size)(unsafe.Pointer(bp)) == 0 { (*(*[4]uintptr)(unsafe.Pointer(bp + 16)))[0] = libtcl9_0.XTcl_NewDoubleObj(tls, *(*float64)(unsafe.Pointer(rectOvalPtr + 296))) (*(*[4]uintptr)(unsafe.Pointer(bp + 16)))[int32(1)] = libtcl9_0.XTcl_NewDoubleObj(tls, *(*float64)(unsafe.Pointer(rectOvalPtr + 296 + 1*8))) (*(*[4]uintptr)(unsafe.Pointer(bp + 16)))[int32(2)] = libtcl9_0.XTcl_NewDoubleObj(tls, *(*float64)(unsafe.Pointer(rectOvalPtr + 296 + 2*8))) (*(*[4]uintptr)(unsafe.Pointer(bp + 16)))[int32(3)] = libtcl9_0.XTcl_NewDoubleObj(tls, *(*float64)(unsafe.Pointer(rectOvalPtr + 296 + 3*8))) libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewListObj(tls, int64(4), bp+16)) return TCL_OK } /* * If one "coordinate", treat as list of coordinates. */ if *(*TTcl_Size)(unsafe.Pointer(bp)) == int64(1) { if libtcl9_0.XTcl_ListObjGetElements(tls, interp, *(*uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 8)))), bp, bp+8) != TCL_OK { return int32(TCL_ERROR) } } /* * Better have four coordinates now. Spit out an error message otherwise. */ if *(*TTcl_Size)(unsafe.Pointer(bp)) != int64(4) { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+28980, libc.VaList(bp+56, *(*TTcl_Size)(unsafe.Pointer(bp))))) if (*TRectOvalItem)(unsafe.Pointer(rectOvalPtr)).Fheader.FtypePtr == uintptr(unsafe.Pointer(&XtkRectangleType)) { v1 = __ccgo_ts + 926 } else { v1 = __ccgo_ts + 32772 } libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+56, __ccgo_ts+179, __ccgo_ts+27003, __ccgo_ts+28973, v1, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) } /* * Parse the coordinates and update our bounding box. */ if XTk_CanvasGetCoordFromObj(tls, interp, canvas, *(*uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 8)))), rectOvalPtr+296) != TCL_OK || XTk_CanvasGetCoordFromObj(tls, interp, canvas, *(*uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 8)) + 1*8)), rectOvalPtr+296+1*8) != TCL_OK || XTk_CanvasGetCoordFromObj(tls, interp, canvas, *(*uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 8)) + 2*8)), rectOvalPtr+296+2*8) != TCL_OK || XTk_CanvasGetCoordFromObj(tls, interp, canvas, *(*uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 8)) + 3*8)), rectOvalPtr+296+3*8) != TCL_OK { return int32(TCL_ERROR) } _ComputeRectOvalBbox(tls, canvas, rectOvalPtr) return TCL_OK } /* *-------------------------------------------------------------- * * ConfigureRectOval -- * * This function is invoked to configure various aspects of a rectangle * or oval item, such as its border and background colors. * * Results: * A standard Tcl result code. If an error occurs, then an error message * is left in the interp's result. * * Side effects: * Configuration information, such as colors and stipple patterns, may be * set for itemPtr. * *-------------------------------------------------------------- */ func _ConfigureRectOval(tls *libc.TLS, interp uintptr, canvas TTk_Canvas, itemPtr uintptr, objc TTcl_Size, objv uintptr, flags int32) (r int32) { bp := tls.Alloc(128) defer tls.Free(128) /* Flags to pass to Tk_ConfigureWidget. */ var color, rectOvalPtr, tsoffset uintptr var mask uint64 var newGC TGC var state TTk_State var stipple TPixmap var tkwin TTk_Window var _ /* gcValues at bp+0 */ TXGCValues _, _, _, _, _, _, _, _ = color, mask, newGC, rectOvalPtr, state, stipple, tkwin, tsoffset rectOvalPtr = itemPtr tkwin = XTk_CanvasTkwin(tls, canvas) if TCL_OK != XTk_ConfigureWidget(tls, interp, tkwin, uintptr(unsafe.Pointer(&_configSpecs10)), objc, objv, rectOvalPtr, flags) { return int32(TCL_ERROR) } state = (*TTk_Item)(unsafe.Pointer(itemPtr)).Fstate /* * A few of the options require additional processing, such as graphics * contexts. */ if (*TRectOvalItem)(unsafe.Pointer(rectOvalPtr)).Foutline.FactiveWidth > (*TRectOvalItem)(unsafe.Pointer(rectOvalPtr)).Foutline.Fwidth || (*TRectOvalItem)(unsafe.Pointer(rectOvalPtr)).Foutline.FactiveDash.Fnumber != 0 || (*TRectOvalItem)(unsafe.Pointer(rectOvalPtr)).Foutline.FactiveColor != libc.UintptrFromInt32(0) || (*TRectOvalItem)(unsafe.Pointer(rectOvalPtr)).Foutline.FactiveStipple != uint64(0) || (*TRectOvalItem)(unsafe.Pointer(rectOvalPtr)).FactiveFillColor != libc.UintptrFromInt32(0) || (*TRectOvalItem)(unsafe.Pointer(rectOvalPtr)).FactiveFillStipple != uint64(0) { *(*int32)(unsafe.Pointer(itemPtr + 112)) |= int32(TK_ITEM_STATE_DEPENDANT) } else { *(*int32)(unsafe.Pointer(itemPtr + 112)) &= ^libc.Int32FromInt32(TK_ITEM_STATE_DEPENDANT) } tsoffset = rectOvalPtr + 120 + 112 flags = (*TTk_TSOffset)(unsafe.Pointer(tsoffset)).Fflags if flags&int32(TK_OFFSET_LEFT) != 0 { (*TTk_TSOffset)(unsafe.Pointer(tsoffset)).Fxoffset = int32(*(*float64)(unsafe.Pointer(rectOvalPtr + 296)) + libc.Float64FromFloat64(0.5)) } else { if flags&int32(TK_OFFSET_CENTER) != 0 { (*TTk_TSOffset)(unsafe.Pointer(tsoffset)).Fxoffset = int32((*(*float64)(unsafe.Pointer(rectOvalPtr + 296)) + *(*float64)(unsafe.Pointer(rectOvalPtr + 296 + 2*8)) + libc.Float64FromInt32(1)) / libc.Float64FromInt32(2)) } else { if flags&int32(TK_OFFSET_RIGHT) != 0 { (*TTk_TSOffset)(unsafe.Pointer(tsoffset)).Fxoffset = int32(*(*float64)(unsafe.Pointer(rectOvalPtr + 296 + 2*8)) + libc.Float64FromFloat64(0.5)) } } } if flags&int32(TK_OFFSET_TOP) != 0 { (*TTk_TSOffset)(unsafe.Pointer(tsoffset)).Fyoffset = int32(*(*float64)(unsafe.Pointer(rectOvalPtr + 296 + 1*8)) + libc.Float64FromFloat64(0.5)) } else { if flags&int32(TK_OFFSET_MIDDLE) != 0 { (*TTk_TSOffset)(unsafe.Pointer(tsoffset)).Fyoffset = int32((*(*float64)(unsafe.Pointer(rectOvalPtr + 296 + 1*8)) + *(*float64)(unsafe.Pointer(rectOvalPtr + 296 + 3*8)) + libc.Float64FromInt32(1)) / libc.Float64FromInt32(2)) } else { if flags&int32(TK_OFFSET_BOTTOM) != 0 { (*TTk_TSOffset)(unsafe.Pointer(tsoffset)).Fyoffset = int32(*(*float64)(unsafe.Pointer(rectOvalPtr + 296 + 2*8)) + libc.Float64FromFloat64(0.5)) } } } /* * Configure the outline graphics context. If mask is non-zero, the gc has * changed and must be reallocated, provided that the new settings specify * a valid outline (non-zero width and non-NULL color) */ mask = libc.Uint64FromInt32(XTk_ConfigOutlineGC(tls, bp, canvas, itemPtr, rectOvalPtr+120)) if mask != 0 && (*TRectOvalItem)(unsafe.Pointer(rectOvalPtr)).Foutline.Fwidth != libc.Float64FromInt32(0) && (*TRectOvalItem)(unsafe.Pointer(rectOvalPtr)).Foutline.Fcolor != libc.UintptrFromInt32(0) { (*(*TXGCValues)(unsafe.Pointer(bp))).Fcap_style = int32(CapProjecting) mask |= libc.Uint64FromInt64(libc.Int64FromInt64(1) << libc.Int32FromInt32(6)) newGC = XTk_GetGC(tls, tkwin, mask, bp) } else { newGC = libc.UintptrFromInt32(0) } if (*TRectOvalItem)(unsafe.Pointer(rectOvalPtr)).Foutline.Fgc != libc.UintptrFromInt32(0) { XTk_FreeGC(tls, (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fdisplay, (*TRectOvalItem)(unsafe.Pointer(rectOvalPtr)).Foutline.Fgc) } (*TRectOvalItem)(unsafe.Pointer(rectOvalPtr)).Foutline.Fgc = newGC if state == int32(TK_STATE_NULL) { state = (*TTkCanvas)(unsafe.Pointer(canvas)).Fcanvas_state } if state == int32(TK_STATE_HIDDEN) { _ComputeRectOvalBbox(tls, canvas, rectOvalPtr) return TCL_OK } color = (*TRectOvalItem)(unsafe.Pointer(rectOvalPtr)).FfillColor stipple = (*TRectOvalItem)(unsafe.Pointer(rectOvalPtr)).FfillStipple if (*TTkCanvas)(unsafe.Pointer(canvas)).FcurrentItemPtr == itemPtr { if (*TRectOvalItem)(unsafe.Pointer(rectOvalPtr)).FactiveFillColor != libc.UintptrFromInt32(0) { color = (*TRectOvalItem)(unsafe.Pointer(rectOvalPtr)).FactiveFillColor } if (*TRectOvalItem)(unsafe.Pointer(rectOvalPtr)).FactiveFillStipple != uint64(0) { stipple = (*TRectOvalItem)(unsafe.Pointer(rectOvalPtr)).FactiveFillStipple } } else { if state == int32(TK_STATE_DISABLED) { if (*TRectOvalItem)(unsafe.Pointer(rectOvalPtr)).FdisabledFillColor != libc.UintptrFromInt32(0) { color = (*TRectOvalItem)(unsafe.Pointer(rectOvalPtr)).FdisabledFillColor } if (*TRectOvalItem)(unsafe.Pointer(rectOvalPtr)).FdisabledFillStipple != uint64(0) { stipple = (*TRectOvalItem)(unsafe.Pointer(rectOvalPtr)).FdisabledFillStipple } } } if color == libc.UintptrFromInt32(0) { newGC = libc.UintptrFromInt32(0) } else { (*(*TXGCValues)(unsafe.Pointer(bp))).Fforeground = (*TXColor)(unsafe.Pointer(color)).Fpixel if stipple != uint64(0) { (*(*TXGCValues)(unsafe.Pointer(bp))).Fstipple = stipple (*(*TXGCValues)(unsafe.Pointer(bp))).Ffill_style = int32(FillStippled) mask = libc.Uint64FromInt64(libc.Int64FromInt64(1)< width { width = (*TRectOvalItem)(unsafe.Pointer(rectOvalPtr)).Foutline.FactiveWidth } } else { if state == int32(TK_STATE_DISABLED) { if (*TRectOvalItem)(unsafe.Pointer(rectOvalPtr)).Foutline.FdisabledWidth > libc.Float64FromInt32(0) { width = (*TRectOvalItem)(unsafe.Pointer(rectOvalPtr)).Foutline.FdisabledWidth } } } /* * Make sure that the first coordinates are the lowest ones. */ if *(*float64)(unsafe.Pointer(rectOvalPtr + 296 + 1*8)) > *(*float64)(unsafe.Pointer(rectOvalPtr + 296 + 3*8)) { tmpY = *(*float64)(unsafe.Pointer(rectOvalPtr + 296 + 3*8)) *(*float64)(unsafe.Pointer(rectOvalPtr + 296 + 3*8)) = *(*float64)(unsafe.Pointer(rectOvalPtr + 296 + 1*8)) *(*float64)(unsafe.Pointer(rectOvalPtr + 296 + 1*8)) = tmpY } if *(*float64)(unsafe.Pointer(rectOvalPtr + 296)) > *(*float64)(unsafe.Pointer(rectOvalPtr + 296 + 2*8)) { tmpX = *(*float64)(unsafe.Pointer(rectOvalPtr + 296 + 2*8)) *(*float64)(unsafe.Pointer(rectOvalPtr + 296 + 2*8)) = *(*float64)(unsafe.Pointer(rectOvalPtr + 296)) *(*float64)(unsafe.Pointer(rectOvalPtr + 296)) = tmpX } if (*TRectOvalItem)(unsafe.Pointer(rectOvalPtr)).Foutline.Fgc == libc.UintptrFromInt32(0) { /* * The Win32 switch was added for 8.3 to solve a problem with ovals * leaving traces on bottom and right of 1 pixel. This may not be the * correct place to solve it, but it works. */ bloat = 0 } else { bloat = int32(width+libc.Float64FromInt32(1)) / int32(2) } /* * Special note: the rectangle is always drawn at least 1x1 in size, so * round up the upper coordinates to be at least 1 unit greater than the * lower ones. */ if *(*float64)(unsafe.Pointer(rectOvalPtr + 296)) >= libc.Float64FromInt32(0) { v4 = *(*float64)(unsafe.Pointer(rectOvalPtr + 296)) + float64(0.5) } else { v4 = *(*float64)(unsafe.Pointer(rectOvalPtr + 296)) - float64(0.5) } tmp = int32(v4) (*TRectOvalItem)(unsafe.Pointer(rectOvalPtr)).Fheader.Fx1 = tmp - bloat if *(*float64)(unsafe.Pointer(rectOvalPtr + 296 + 1*8)) >= libc.Float64FromInt32(0) { v5 = *(*float64)(unsafe.Pointer(rectOvalPtr + 296 + 1*8)) + float64(0.5) } else { v5 = *(*float64)(unsafe.Pointer(rectOvalPtr + 296 + 1*8)) - float64(0.5) } tmp = int32(v5) (*TRectOvalItem)(unsafe.Pointer(rectOvalPtr)).Fheader.Fy1 = tmp - bloat dtmp = *(*float64)(unsafe.Pointer(rectOvalPtr + 296 + 2*8)) if dtmp < *(*float64)(unsafe.Pointer(rectOvalPtr + 296))+libc.Float64FromInt32(1) { dtmp = *(*float64)(unsafe.Pointer(rectOvalPtr + 296)) + libc.Float64FromInt32(1) } if dtmp >= libc.Float64FromInt32(0) { v6 = dtmp + float64(0.5) } else { v6 = dtmp - float64(0.5) } tmp = int32(v6) (*TRectOvalItem)(unsafe.Pointer(rectOvalPtr)).Fheader.Fx2 = tmp + bloat dtmp = *(*float64)(unsafe.Pointer(rectOvalPtr + 296 + 3*8)) if dtmp < *(*float64)(unsafe.Pointer(rectOvalPtr + 296 + 1*8))+libc.Float64FromInt32(1) { dtmp = *(*float64)(unsafe.Pointer(rectOvalPtr + 296 + 1*8)) + libc.Float64FromInt32(1) } if dtmp >= libc.Float64FromInt32(0) { v7 = dtmp + float64(0.5) } else { v7 = dtmp - float64(0.5) } tmp = int32(v7) (*TRectOvalItem)(unsafe.Pointer(rectOvalPtr)).Fheader.Fy2 = tmp + bloat } /* *-------------------------------------------------------------- * * DisplayRectOval -- * * This function is invoked to draw a rectangle or oval item in a given * drawable. * * Results: * None. * * Side effects: * ItemPtr is drawn in drawable using the transformation information in * canvas. * *-------------------------------------------------------------- */ func _DisplayRectOval(tls *libc.TLS, canvas TTk_Canvas, itemPtr uintptr, display uintptr, drawable TDrawable, dummy746 int32, dummy747 int32, dummy748 int32, dummy749 int32) { bp := tls.Alloc(16) defer tls.Free(16) var fillStipple TPixmap var flags int32 var ix1, ix2, iy1, iy2 int16 var rectOvalPtr, tsoffset uintptr var state TTk_State var _ /* h at bp+12 */ int32 var _ /* w at bp+8 */ int32 var _ /* x1 at bp+0 */ int16 var _ /* x2 at bp+4 */ int16 var _ /* y1 at bp+2 */ int16 var _ /* y2 at bp+6 */ int16 _, _, _, _, _, _, _, _, _ = fillStipple, flags, ix1, ix2, iy1, iy2, rectOvalPtr, state, tsoffset rectOvalPtr = itemPtr state = (*TTk_Item)(unsafe.Pointer(itemPtr)).Fstate /* * Compute the screen coordinates of the bounding box for the item. Make * sure that the bbox is at least one pixel large, since some X servers * will die if it isn't. */ XTk_CanvasDrawableCoords(tls, canvas, *(*float64)(unsafe.Pointer(rectOvalPtr + 296)), *(*float64)(unsafe.Pointer(rectOvalPtr + 296 + 1*8)), bp, bp+2) XTk_CanvasDrawableCoords(tls, canvas, *(*float64)(unsafe.Pointer(rectOvalPtr + 296 + 2*8)), *(*float64)(unsafe.Pointer(rectOvalPtr + 296 + 3*8)), bp+4, bp+6) if int32(*(*int16)(unsafe.Pointer(bp + 4))) == int32(*(*int16)(unsafe.Pointer(bp))) { /* * The width of the bounding box corresponds to less than one pixel * on screen. Adjustment is needed to avoid drawing attempts with zero * width items (which would draw nothing). The bounding box spans * either 1 or 2 pixels. Select which pixel will be drawn. */ ix1 = int16(*(*float64)(unsafe.Pointer(rectOvalPtr + 296))) ix2 = int16(*(*float64)(unsafe.Pointer(rectOvalPtr + 296 + 2*8))) if int32(ix1) == int32(ix2) { /* * x1 and x2 are "within the same pixel". Use this pixel. * Note: the degenerated case (bbox[0]==bbox[2]) of a completely * flat box results in arbitrary selection of the pixel at the * right (with positive coordinate) or left (with negative * coordinate) of the box. There is no "best choice" here. */ if int32(ix1) > 0 { *(*int16)(unsafe.Pointer(bp + 4)) = int16(int32(*(*int16)(unsafe.Pointer(bp + 4))) + libc.Int32FromInt32(1)) } else { *(*int16)(unsafe.Pointer(bp)) = int16(int32(*(*int16)(unsafe.Pointer(bp))) - libc.Int32FromInt32(1)) } } else { /* * (x1,x2) span two pixels. Select the one with the larger * covered "area". */ if int32(ix1) > 0 { if *(*float64)(unsafe.Pointer(rectOvalPtr + 296 + 2*8))-float64(ix2) > float64(ix2)-*(*float64)(unsafe.Pointer(rectOvalPtr + 296)) { *(*int16)(unsafe.Pointer(bp + 4)) = int16(int32(*(*int16)(unsafe.Pointer(bp + 4))) + libc.Int32FromInt32(1)) } else { *(*int16)(unsafe.Pointer(bp)) = int16(int32(*(*int16)(unsafe.Pointer(bp))) - libc.Int32FromInt32(1)) } } else { if *(*float64)(unsafe.Pointer(rectOvalPtr + 296 + 2*8))-float64(ix1) > float64(ix1)-*(*float64)(unsafe.Pointer(rectOvalPtr + 296)) { *(*int16)(unsafe.Pointer(bp + 4)) = int16(int32(*(*int16)(unsafe.Pointer(bp + 4))) + libc.Int32FromInt32(1)) } else { *(*int16)(unsafe.Pointer(bp)) = int16(int32(*(*int16)(unsafe.Pointer(bp))) - libc.Int32FromInt32(1)) } } } } if int32(*(*int16)(unsafe.Pointer(bp + 6))) == int32(*(*int16)(unsafe.Pointer(bp + 2))) { /* * The height of the bounding box corresponds to less than one pixel * on screen. Adjustment is needed to avoid drawing attempts with zero * height items (which would draw nothing). The bounding box spans * either 1 or 2 pixels. Select which pixel will be drawn. */ iy1 = int16(*(*float64)(unsafe.Pointer(rectOvalPtr + 296 + 1*8))) iy2 = int16(*(*float64)(unsafe.Pointer(rectOvalPtr + 296 + 3*8))) if int32(iy1) == int32(iy2) { /* * y1 and y2 are "within the same pixel". Use this pixel. * Note: the degenerated case (bbox[1]==bbox[3]) of a completely * flat box results in arbitrary selection of the pixel below * (with positive coordinate) or above (with negative coordinate) * the box. There is no "best choice" here. */ if int32(iy1) > 0 { *(*int16)(unsafe.Pointer(bp + 6)) = int16(int32(*(*int16)(unsafe.Pointer(bp + 6))) + libc.Int32FromInt32(1)) } else { *(*int16)(unsafe.Pointer(bp + 2)) = int16(int32(*(*int16)(unsafe.Pointer(bp + 2))) - libc.Int32FromInt32(1)) } } else { /* * (y1,y2) span two pixels. Select the one with the larger * covered "area". */ if int32(iy1) > 0 { if *(*float64)(unsafe.Pointer(rectOvalPtr + 296 + 3*8))-float64(iy2) > float64(iy2)-*(*float64)(unsafe.Pointer(rectOvalPtr + 296 + 1*8)) { *(*int16)(unsafe.Pointer(bp + 6)) = int16(int32(*(*int16)(unsafe.Pointer(bp + 6))) + libc.Int32FromInt32(1)) } else { *(*int16)(unsafe.Pointer(bp + 2)) = int16(int32(*(*int16)(unsafe.Pointer(bp + 2))) - libc.Int32FromInt32(1)) } } else { if *(*float64)(unsafe.Pointer(rectOvalPtr + 296 + 3*8))-float64(iy1) > float64(iy1)-*(*float64)(unsafe.Pointer(rectOvalPtr + 296 + 1*8)) { *(*int16)(unsafe.Pointer(bp + 6)) = int16(int32(*(*int16)(unsafe.Pointer(bp + 6))) + libc.Int32FromInt32(1)) } else { *(*int16)(unsafe.Pointer(bp + 2)) = int16(int32(*(*int16)(unsafe.Pointer(bp + 2))) - libc.Int32FromInt32(1)) } } } } /* * Display filled part first (if wanted), then outline. If we're * stippling, then modify the stipple offset in the GC. Be sure to reset * the offset when done, since the GC is supposed to be read-only. */ if state == int32(TK_STATE_NULL) { state = (*TTkCanvas)(unsafe.Pointer(canvas)).Fcanvas_state } fillStipple = (*TRectOvalItem)(unsafe.Pointer(rectOvalPtr)).FfillStipple if (*TTkCanvas)(unsafe.Pointer(canvas)).FcurrentItemPtr == rectOvalPtr { if (*TRectOvalItem)(unsafe.Pointer(rectOvalPtr)).FactiveFillStipple != uint64(0) { fillStipple = (*TRectOvalItem)(unsafe.Pointer(rectOvalPtr)).FactiveFillStipple } } else { if state == int32(TK_STATE_DISABLED) { if (*TRectOvalItem)(unsafe.Pointer(rectOvalPtr)).FdisabledFillStipple != uint64(0) { fillStipple = (*TRectOvalItem)(unsafe.Pointer(rectOvalPtr)).FdisabledFillStipple } } } if (*TRectOvalItem)(unsafe.Pointer(rectOvalPtr)).FfillGC != libc.UintptrFromInt32(0) { if fillStipple != uint64(0) { *(*int32)(unsafe.Pointer(bp + 8)) = 0 *(*int32)(unsafe.Pointer(bp + 12)) = 0 tsoffset = rectOvalPtr + 328 if tsoffset != 0 { flags = (*TTk_TSOffset)(unsafe.Pointer(tsoffset)).Fflags if flags&(libc.Int32FromInt32(TK_OFFSET_CENTER)|libc.Int32FromInt32(TK_OFFSET_MIDDLE)) != 0 { XTk_SizeOfBitmap(tls, display, fillStipple, bp+8, bp+12) if flags&int32(TK_OFFSET_CENTER) != 0 { *(*int32)(unsafe.Pointer(bp + 8)) /= int32(2) } else { *(*int32)(unsafe.Pointer(bp + 8)) = 0 } if flags&int32(TK_OFFSET_MIDDLE) != 0 { *(*int32)(unsafe.Pointer(bp + 12)) /= int32(2) } else { *(*int32)(unsafe.Pointer(bp + 12)) = 0 } } *(*int32)(unsafe.Pointer(tsoffset + 4)) -= *(*int32)(unsafe.Pointer(bp + 8)) *(*int32)(unsafe.Pointer(tsoffset + 8)) -= *(*int32)(unsafe.Pointer(bp + 12)) } XTk_CanvasSetOffset(tls, canvas, (*TRectOvalItem)(unsafe.Pointer(rectOvalPtr)).FfillGC, tsoffset) if tsoffset != 0 { *(*int32)(unsafe.Pointer(tsoffset + 4)) += *(*int32)(unsafe.Pointer(bp + 8)) *(*int32)(unsafe.Pointer(tsoffset + 8)) += *(*int32)(unsafe.Pointer(bp + 12)) } } if (*TRectOvalItem)(unsafe.Pointer(rectOvalPtr)).Fheader.FtypePtr == uintptr(unsafe.Pointer(&XtkRectangleType)) { libx11.XXFillRectangle(tls, display, drawable, (*TRectOvalItem)(unsafe.Pointer(rectOvalPtr)).FfillGC, int32(*(*int16)(unsafe.Pointer(bp))), int32(*(*int16)(unsafe.Pointer(bp + 2))), libc.Uint32FromInt32(int32(*(*int16)(unsafe.Pointer(bp + 4)))-int32(*(*int16)(unsafe.Pointer(bp)))), libc.Uint32FromInt32(int32(*(*int16)(unsafe.Pointer(bp + 6)))-int32(*(*int16)(unsafe.Pointer(bp + 2))))) } else { libx11.XXFillArc(tls, display, drawable, (*TRectOvalItem)(unsafe.Pointer(rectOvalPtr)).FfillGC, int32(*(*int16)(unsafe.Pointer(bp))), int32(*(*int16)(unsafe.Pointer(bp + 2))), libc.Uint32FromInt32(int32(*(*int16)(unsafe.Pointer(bp + 4)))-int32(*(*int16)(unsafe.Pointer(bp)))), libc.Uint32FromInt32(int32(*(*int16)(unsafe.Pointer(bp + 6)))-int32(*(*int16)(unsafe.Pointer(bp + 2)))), 0, libc.Int32FromInt32(360)*libc.Int32FromInt32(64)) } if fillStipple != uint64(0) { libx11.XXSetTSOrigin(tls, display, (*TRectOvalItem)(unsafe.Pointer(rectOvalPtr)).FfillGC, 0, 0) } } if (*TRectOvalItem)(unsafe.Pointer(rectOvalPtr)).Foutline.Fgc != libc.UintptrFromInt32(0) { XTk_ChangeOutlineGC(tls, canvas, itemPtr, rectOvalPtr+120) if (*TRectOvalItem)(unsafe.Pointer(rectOvalPtr)).Fheader.FtypePtr == uintptr(unsafe.Pointer(&XtkRectangleType)) { libx11.XXDrawRectangle(tls, display, drawable, (*TRectOvalItem)(unsafe.Pointer(rectOvalPtr)).Foutline.Fgc, int32(*(*int16)(unsafe.Pointer(bp))), int32(*(*int16)(unsafe.Pointer(bp + 2))), libc.Uint32FromInt32(int32(*(*int16)(unsafe.Pointer(bp + 4)))-int32(*(*int16)(unsafe.Pointer(bp)))), libc.Uint32FromInt32(int32(*(*int16)(unsafe.Pointer(bp + 6)))-int32(*(*int16)(unsafe.Pointer(bp + 2))))) } else { libx11.XXDrawArc(tls, display, drawable, (*TRectOvalItem)(unsafe.Pointer(rectOvalPtr)).Foutline.Fgc, int32(*(*int16)(unsafe.Pointer(bp))), int32(*(*int16)(unsafe.Pointer(bp + 2))), libc.Uint32FromInt32(int32(*(*int16)(unsafe.Pointer(bp + 4)))-int32(*(*int16)(unsafe.Pointer(bp)))), libc.Uint32FromInt32(int32(*(*int16)(unsafe.Pointer(bp + 6)))-int32(*(*int16)(unsafe.Pointer(bp + 2)))), 0, libc.Int32FromInt32(360)*libc.Int32FromInt32(64)) } XTk_ResetOutlineGC(tls, canvas, itemPtr, rectOvalPtr+120) } } /* *-------------------------------------------------------------- * * RectToPoint -- * * Computes the distance from a given point to a given rectangle, in * canvas units. * * Results: * The return value is 0 if the point whose x and y coordinates are * coordPtr[0] and coordPtr[1] is inside the rectangle. If the point * isn't inside the rectangle then the return value is the distance from * the point to the rectangle. If itemPtr is filled, then anywhere in the * interior is considered "inside"; if itemPtr isn't filled, then * "inside" means only the area occupied by the outline. * * Side effects: * None. * *-------------------------------------------------------------- */ func _RectToPoint(tls *libc.TLS, canvas TTk_Canvas, itemPtr uintptr, pointPtr uintptr) (r float64) { /* Pointer to x and y coordinates. */ var inc, tmp, width, x1, x2, xDiff, y1, y2, yDiff float64 var rectPtr uintptr var state TTk_State _, _, _, _, _, _, _, _, _, _, _ = inc, rectPtr, state, tmp, width, x1, x2, xDiff, y1, y2, yDiff rectPtr = itemPtr state = (*TTk_Item)(unsafe.Pointer(itemPtr)).Fstate if state == int32(TK_STATE_NULL) { state = (*TTkCanvas)(unsafe.Pointer(canvas)).Fcanvas_state } width = (*TRectOvalItem)(unsafe.Pointer(rectPtr)).Foutline.Fwidth if (*TTkCanvas)(unsafe.Pointer(canvas)).FcurrentItemPtr == itemPtr { if (*TRectOvalItem)(unsafe.Pointer(rectPtr)).Foutline.FactiveWidth > width { width = (*TRectOvalItem)(unsafe.Pointer(rectPtr)).Foutline.FactiveWidth } } else { if state == int32(TK_STATE_DISABLED) { if (*TRectOvalItem)(unsafe.Pointer(rectPtr)).Foutline.FdisabledWidth > libc.Float64FromInt32(0) { width = (*TRectOvalItem)(unsafe.Pointer(rectPtr)).Foutline.FdisabledWidth } } } /* * Generate a new larger rectangle that includes the border width, if * there is one. */ x1 = *(*float64)(unsafe.Pointer(rectPtr + 296)) y1 = *(*float64)(unsafe.Pointer(rectPtr + 296 + 1*8)) x2 = *(*float64)(unsafe.Pointer(rectPtr + 296 + 2*8)) y2 = *(*float64)(unsafe.Pointer(rectPtr + 296 + 3*8)) if (*TRectOvalItem)(unsafe.Pointer(rectPtr)).Foutline.Fgc != libc.UintptrFromInt32(0) { inc = width / float64(2) x1 -= inc y1 -= inc x2 += inc y2 += inc } /* * If the point is inside the rectangle, handle specially: distance is 0 * if rectangle is filled, otherwise compute distance to nearest edge of * rectangle and subtract width of edge. */ if *(*float64)(unsafe.Pointer(pointPtr)) >= x1 && *(*float64)(unsafe.Pointer(pointPtr)) < x2 && *(*float64)(unsafe.Pointer(pointPtr + 1*8)) >= y1 && *(*float64)(unsafe.Pointer(pointPtr + 1*8)) < y2 { if (*TRectOvalItem)(unsafe.Pointer(rectPtr)).FfillGC != libc.UintptrFromInt32(0) || (*TRectOvalItem)(unsafe.Pointer(rectPtr)).Foutline.Fgc == libc.UintptrFromInt32(0) { return float64(0) } xDiff = *(*float64)(unsafe.Pointer(pointPtr)) - x1 tmp = x2 - *(*float64)(unsafe.Pointer(pointPtr)) if tmp < xDiff { xDiff = tmp } yDiff = *(*float64)(unsafe.Pointer(pointPtr + 1*8)) - y1 tmp = y2 - *(*float64)(unsafe.Pointer(pointPtr + 1*8)) if tmp < yDiff { yDiff = tmp } if yDiff < xDiff { xDiff = yDiff } xDiff -= width if xDiff < float64(0) { return float64(0) } return xDiff } /* * Point is outside rectangle. */ if *(*float64)(unsafe.Pointer(pointPtr)) < x1 { xDiff = x1 - *(*float64)(unsafe.Pointer(pointPtr)) } else { if *(*float64)(unsafe.Pointer(pointPtr)) > x2 { xDiff = *(*float64)(unsafe.Pointer(pointPtr)) - x2 } else { xDiff = libc.Float64FromInt32(0) } } if *(*float64)(unsafe.Pointer(pointPtr + 1*8)) < y1 { yDiff = y1 - *(*float64)(unsafe.Pointer(pointPtr + 1*8)) } else { if *(*float64)(unsafe.Pointer(pointPtr + 1*8)) > y2 { yDiff = *(*float64)(unsafe.Pointer(pointPtr + 1*8)) - y2 } else { yDiff = libc.Float64FromInt32(0) } } return libc.X__builtin_hypot(tls, xDiff, yDiff) } /* *-------------------------------------------------------------- * * OvalToPoint -- * * Computes the distance from a given point to a given oval, in canvas * units. * * Results: * The return value is 0 if the point whose x and y coordinates are * coordPtr[0] and coordPtr[1] is inside the oval. If the point isn't * inside the oval then the return value is the distance from the point * to the oval. If itemPtr is filled, then anywhere in the interior is * considered "inside"; if itemPtr isn't filled, then "inside" means only * the area occupied by the outline. * * Side effects: * None. * *-------------------------------------------------------------- */ func _OvalToPoint(tls *libc.TLS, canvas TTk_Canvas, itemPtr uintptr, pointPtr uintptr) (r float64) { /* Pointer to x and y coordinates. */ var filled int32 var ovalPtr uintptr var state TTk_State var width float64 _, _, _, _ = filled, ovalPtr, state, width ovalPtr = itemPtr state = (*TTk_Item)(unsafe.Pointer(itemPtr)).Fstate if state == int32(TK_STATE_NULL) { state = (*TTkCanvas)(unsafe.Pointer(canvas)).Fcanvas_state } width = (*TRectOvalItem)(unsafe.Pointer(ovalPtr)).Foutline.Fwidth if (*TTkCanvas)(unsafe.Pointer(canvas)).FcurrentItemPtr == itemPtr { if (*TRectOvalItem)(unsafe.Pointer(ovalPtr)).Foutline.FactiveWidth > width { width = (*TRectOvalItem)(unsafe.Pointer(ovalPtr)).Foutline.FactiveWidth } } else { if state == int32(TK_STATE_DISABLED) { if (*TRectOvalItem)(unsafe.Pointer(ovalPtr)).Foutline.FdisabledWidth > libc.Float64FromInt32(0) { width = (*TRectOvalItem)(unsafe.Pointer(ovalPtr)).Foutline.FdisabledWidth } } } filled = libc.BoolInt32((*TRectOvalItem)(unsafe.Pointer(ovalPtr)).FfillGC != libc.UintptrFromInt32(0)) if (*TRectOvalItem)(unsafe.Pointer(ovalPtr)).Foutline.Fgc == libc.UintptrFromInt32(0) { width = float64(0) filled = int32(1) } return XTkOvalToPoint(tls, ovalPtr+296, width, filled, pointPtr) } /* *-------------------------------------------------------------- * * RectToArea -- * * This function is called to determine whether an item lies entirely * inside, entirely outside, or overlapping a given rectangle. * * Results: * -1 is returned if the item is entirely outside the area given by * rectPtr, 0 if it overlaps, and 1 if it is entirely inside the given * area. * * Side effects: * None. * *-------------------------------------------------------------- */ func _RectToArea(tls *libc.TLS, canvas TTk_Canvas, itemPtr uintptr, areaPtr uintptr) (r int32) { /* Pointer to array of four coordinates (x1, * y1, x2, y2) describing rectangular area. */ var halfWidth, width float64 var rectPtr uintptr var state TTk_State _, _, _, _ = halfWidth, rectPtr, state, width rectPtr = itemPtr state = (*TTk_Item)(unsafe.Pointer(itemPtr)).Fstate if state == int32(TK_STATE_NULL) { state = (*TTkCanvas)(unsafe.Pointer(canvas)).Fcanvas_state } width = (*TRectOvalItem)(unsafe.Pointer(rectPtr)).Foutline.Fwidth if (*TTkCanvas)(unsafe.Pointer(canvas)).FcurrentItemPtr == itemPtr { if (*TRectOvalItem)(unsafe.Pointer(rectPtr)).Foutline.FactiveWidth > width { width = (*TRectOvalItem)(unsafe.Pointer(rectPtr)).Foutline.FactiveWidth } } else { if state == int32(TK_STATE_DISABLED) { if (*TRectOvalItem)(unsafe.Pointer(rectPtr)).Foutline.FdisabledWidth > libc.Float64FromInt32(0) { width = (*TRectOvalItem)(unsafe.Pointer(rectPtr)).Foutline.FdisabledWidth } } } halfWidth = width / float64(2) if (*TRectOvalItem)(unsafe.Pointer(rectPtr)).Foutline.Fgc == libc.UintptrFromInt32(0) { halfWidth = float64(0) } if *(*float64)(unsafe.Pointer(areaPtr + 2*8)) <= *(*float64)(unsafe.Pointer(rectPtr + 296))-halfWidth || *(*float64)(unsafe.Pointer(areaPtr)) >= *(*float64)(unsafe.Pointer(rectPtr + 296 + 2*8))+halfWidth || *(*float64)(unsafe.Pointer(areaPtr + 3*8)) <= *(*float64)(unsafe.Pointer(rectPtr + 296 + 1*8))-halfWidth || *(*float64)(unsafe.Pointer(areaPtr + 1*8)) >= *(*float64)(unsafe.Pointer(rectPtr + 296 + 3*8))+halfWidth { return -int32(1) } if (*TRectOvalItem)(unsafe.Pointer(rectPtr)).FfillGC == libc.UintptrFromInt32(0) && (*TRectOvalItem)(unsafe.Pointer(rectPtr)).Foutline.Fgc != libc.UintptrFromInt32(0) && *(*float64)(unsafe.Pointer(areaPtr)) >= *(*float64)(unsafe.Pointer(rectPtr + 296))+halfWidth && *(*float64)(unsafe.Pointer(areaPtr + 1*8)) >= *(*float64)(unsafe.Pointer(rectPtr + 296 + 1*8))+halfWidth && *(*float64)(unsafe.Pointer(areaPtr + 2*8)) <= *(*float64)(unsafe.Pointer(rectPtr + 296 + 2*8))-halfWidth && *(*float64)(unsafe.Pointer(areaPtr + 3*8)) <= *(*float64)(unsafe.Pointer(rectPtr + 296 + 3*8))-halfWidth { return -int32(1) } if *(*float64)(unsafe.Pointer(areaPtr)) <= *(*float64)(unsafe.Pointer(rectPtr + 296))-halfWidth && *(*float64)(unsafe.Pointer(areaPtr + 1*8)) <= *(*float64)(unsafe.Pointer(rectPtr + 296 + 1*8))-halfWidth && *(*float64)(unsafe.Pointer(areaPtr + 2*8)) >= *(*float64)(unsafe.Pointer(rectPtr + 296 + 2*8))+halfWidth && *(*float64)(unsafe.Pointer(areaPtr + 3*8)) >= *(*float64)(unsafe.Pointer(rectPtr + 296 + 3*8))+halfWidth { return int32(1) } return 0 } /* *-------------------------------------------------------------- * * OvalToArea -- * * This function is called to determine whether an item lies entirely * inside, entirely outside, or overlapping a given rectangular area. * * Results: * -1 is returned if the item is entirely outside the area given by * rectPtr, 0 if it overlaps, and 1 if it is entirely inside the given * area. * * Side effects: * None. * *-------------------------------------------------------------- */ func _OvalToArea(tls *libc.TLS, canvas TTk_Canvas, itemPtr uintptr, areaPtr uintptr) (r int32) { bp := tls.Alloc(32) defer tls.Free(32) /* Pointer to array of four coordinates (x1, * y1, x2, y2) describing rectangular area. */ var centerX, centerY, halfWidth, height, width, xDelta1, xDelta2, yDelta1, yDelta2 float64 var ovalPtr uintptr var result int32 var state TTk_State var _ /* oval at bp+0 */ [4]float64 _, _, _, _, _, _, _, _, _, _, _, _ = centerX, centerY, halfWidth, height, ovalPtr, result, state, width, xDelta1, xDelta2, yDelta1, yDelta2 ovalPtr = itemPtr state = (*TTk_Item)(unsafe.Pointer(itemPtr)).Fstate if state == int32(TK_STATE_NULL) { state = (*TTkCanvas)(unsafe.Pointer(canvas)).Fcanvas_state } width = (*TRectOvalItem)(unsafe.Pointer(ovalPtr)).Foutline.Fwidth if (*TTkCanvas)(unsafe.Pointer(canvas)).FcurrentItemPtr == itemPtr { if (*TRectOvalItem)(unsafe.Pointer(ovalPtr)).Foutline.FactiveWidth > width { width = (*TRectOvalItem)(unsafe.Pointer(ovalPtr)).Foutline.FactiveWidth } } else { if state == int32(TK_STATE_DISABLED) { if (*TRectOvalItem)(unsafe.Pointer(ovalPtr)).Foutline.FdisabledWidth > libc.Float64FromInt32(0) { width = (*TRectOvalItem)(unsafe.Pointer(ovalPtr)).Foutline.FdisabledWidth } } } /* * Expand the oval to include the width of the outline, if any. */ halfWidth = width / float64(2) if (*TRectOvalItem)(unsafe.Pointer(ovalPtr)).Foutline.Fgc == libc.UintptrFromInt32(0) { halfWidth = float64(0) } (*(*[4]float64)(unsafe.Pointer(bp)))[0] = *(*float64)(unsafe.Pointer(ovalPtr + 296)) - halfWidth (*(*[4]float64)(unsafe.Pointer(bp)))[int32(1)] = *(*float64)(unsafe.Pointer(ovalPtr + 296 + 1*8)) - halfWidth (*(*[4]float64)(unsafe.Pointer(bp)))[int32(2)] = *(*float64)(unsafe.Pointer(ovalPtr + 296 + 2*8)) + halfWidth (*(*[4]float64)(unsafe.Pointer(bp)))[int32(3)] = *(*float64)(unsafe.Pointer(ovalPtr + 296 + 3*8)) + halfWidth result = XTkOvalToArea(tls, bp, areaPtr) /* * If the rectangle appears to overlap the oval and the oval isn't filled, * do one more check to see if perhaps all four of the rectangle's corners * are totally inside the oval's unfilled center, in which case we should * return "outside". */ if result == 0 && (*TRectOvalItem)(unsafe.Pointer(ovalPtr)).Foutline.Fgc != libc.UintptrFromInt32(0) && (*TRectOvalItem)(unsafe.Pointer(ovalPtr)).FfillGC == libc.UintptrFromInt32(0) { centerX = (*(*float64)(unsafe.Pointer(ovalPtr + 296)) + *(*float64)(unsafe.Pointer(ovalPtr + 296 + 2*8))) / float64(2) centerY = (*(*float64)(unsafe.Pointer(ovalPtr + 296 + 1*8)) + *(*float64)(unsafe.Pointer(ovalPtr + 296 + 3*8))) / float64(2) width = (*(*float64)(unsafe.Pointer(ovalPtr + 296 + 2*8))-*(*float64)(unsafe.Pointer(ovalPtr + 296)))/float64(2) - halfWidth height = (*(*float64)(unsafe.Pointer(ovalPtr + 296 + 3*8))-*(*float64)(unsafe.Pointer(ovalPtr + 296 + 1*8)))/float64(2) - halfWidth xDelta1 = (*(*float64)(unsafe.Pointer(areaPtr)) - centerX) / width xDelta1 *= xDelta1 yDelta1 = (*(*float64)(unsafe.Pointer(areaPtr + 1*8)) - centerY) / height yDelta1 *= yDelta1 xDelta2 = (*(*float64)(unsafe.Pointer(areaPtr + 2*8)) - centerX) / width xDelta2 *= xDelta2 yDelta2 = (*(*float64)(unsafe.Pointer(areaPtr + 3*8)) - centerY) / height yDelta2 *= yDelta2 if xDelta1+yDelta1 < float64(1) && xDelta1+yDelta2 < float64(1) && xDelta2+yDelta1 < float64(1) && xDelta2+yDelta2 < float64(1) { return -int32(1) } } return result } /* *-------------------------------------------------------------- * * RotateRectOval -- * * This function is invoked to rotate a rectangle or oval item's * coordinates. It works by rotating a computed point in the centre of * the bounding box, NOT by rotating the corners of the bounding box. * * Results: * None. * * Side effects: * The position of the rectangle or oval is rotated by angleRad about * (originX, originY), and the bounding box is updated in the generic * part of the item structure. * *-------------------------------------------------------------- */ func _RotateRectOval(tls *libc.TLS, canvas TTk_Canvas, itemPtr uintptr, originX float64, originY float64, angleRad float64) { bp := tls.Alloc(16) defer tls.Free(16) /* Amount to scale in X direction. */ var oldX, oldY, v1, v2 float64 var rectOvalPtr uintptr var _ /* newX at bp+0 */ float64 var _ /* newY at bp+8 */ float64 _, _, _, _, _ = oldX, oldY, rectOvalPtr, v1, v2 rectOvalPtr = itemPtr /* * Compute the centre of the box, then rotate that about the origin. */ v1 = (*(*float64)(unsafe.Pointer(rectOvalPtr + 296)) + *(*float64)(unsafe.Pointer(rectOvalPtr + 296 + 2*8))) / libc.Float64FromFloat64(2) oldX = v1 *(*float64)(unsafe.Pointer(bp)) = v1 v2 = (*(*float64)(unsafe.Pointer(rectOvalPtr + 296 + 1*8)) + *(*float64)(unsafe.Pointer(rectOvalPtr + 296 + 3*8))) / libc.Float64FromFloat64(2) oldY = v2 *(*float64)(unsafe.Pointer(bp + 8)) = v2 XTkRotatePoint(tls, originX, originY, libc.Xsin(tls, angleRad), libc.Xcos(tls, angleRad), bp, bp+8) /* * Apply the translation to the box. */ *(*float64)(unsafe.Pointer(rectOvalPtr + 296)) += *(*float64)(unsafe.Pointer(bp)) - oldX *(*float64)(unsafe.Pointer(rectOvalPtr + 296 + 1*8)) += *(*float64)(unsafe.Pointer(bp + 8)) - oldY *(*float64)(unsafe.Pointer(rectOvalPtr + 296 + 2*8)) += *(*float64)(unsafe.Pointer(bp)) - oldX *(*float64)(unsafe.Pointer(rectOvalPtr + 296 + 3*8)) += *(*float64)(unsafe.Pointer(bp + 8)) - oldY _ComputeRectOvalBbox(tls, canvas, rectOvalPtr) } /* *-------------------------------------------------------------- * * ScaleRectOval -- * * This function is invoked to rescale a rectangle or oval item. * * Results: * None. * * Side effects: * The rectangle or oval referred to by itemPtr is rescaled so that the * following transformation is applied to all point coordinates: * x' = originX + scaleX*(x-originX) * y' = originY + scaleY*(y-originY) * *-------------------------------------------------------------- */ func _ScaleRectOval(tls *libc.TLS, canvas TTk_Canvas, itemPtr uintptr, originX float64, originY float64, scaleX float64, scaleY float64) { /* Amount to scale in Y direction. */ var rectOvalPtr uintptr _ = rectOvalPtr rectOvalPtr = itemPtr *(*float64)(unsafe.Pointer(rectOvalPtr + 296)) = originX + float64(scaleX*(*(*float64)(unsafe.Pointer(rectOvalPtr + 296))-originX)) *(*float64)(unsafe.Pointer(rectOvalPtr + 296 + 1*8)) = originY + float64(scaleY*(*(*float64)(unsafe.Pointer(rectOvalPtr + 296 + 1*8))-originY)) *(*float64)(unsafe.Pointer(rectOvalPtr + 296 + 2*8)) = originX + float64(scaleX*(*(*float64)(unsafe.Pointer(rectOvalPtr + 296 + 2*8))-originX)) *(*float64)(unsafe.Pointer(rectOvalPtr + 296 + 3*8)) = originY + float64(scaleY*(*(*float64)(unsafe.Pointer(rectOvalPtr + 296 + 3*8))-originY)) _ComputeRectOvalBbox(tls, canvas, rectOvalPtr) } /* *-------------------------------------------------------------- * * TranslateRectOval -- * * This function is called to move a rectangle or oval by a given amount. * * Results: * None. * * Side effects: * The position of the rectangle or oval is offset by (xDelta, yDelta), * and the bounding box is updated in the generic part of the item * structure. * *-------------------------------------------------------------- */ func _TranslateRectOval(tls *libc.TLS, canvas TTk_Canvas, itemPtr uintptr, deltaX float64, deltaY float64) { /* Amount by which item is to be moved. */ var rectOvalPtr uintptr _ = rectOvalPtr rectOvalPtr = itemPtr *(*float64)(unsafe.Pointer(rectOvalPtr + 296)) += deltaX *(*float64)(unsafe.Pointer(rectOvalPtr + 296 + 1*8)) += deltaY *(*float64)(unsafe.Pointer(rectOvalPtr + 296 + 2*8)) += deltaX *(*float64)(unsafe.Pointer(rectOvalPtr + 296 + 3*8)) += deltaY _ComputeRectOvalBbox(tls, canvas, rectOvalPtr) } /* *-------------------------------------------------------------- * * RectOvalToPostscript -- * * This function is called to generate Postscript for rectangle and oval * items. * * Results: * The return value is a standard Tcl result. If an error occurs in * generating Postscript then an error message is left in the interp's * result, replacing whatever used to be there. If no error occurs, then * Postscript for the rectangle is appended to the result. * * Side effects: * None. * *-------------------------------------------------------------- */ func _RectOvalToPostscript(tls *libc.TLS, interp uintptr, canvas TTk_Canvas, itemPtr uintptr, dummy1433 int32) (r int32) { bp := tls.Alloc(48) defer tls.Free(48) /* 1 means this is a prepass to collect font * information; 0 means final Postscript is * being created. */ var _objPtr, _objPtr1, color, fillColor, pathObj, psObj, rectOvalPtr, v2, v4 uintptr var fillStipple TPixmap var interpState TTcl_InterpState var state TTk_State var y1, y2 float64 var v1, v3 TTcl_Size _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = _objPtr, _objPtr1, color, fillColor, fillStipple, interpState, pathObj, psObj, rectOvalPtr, state, y1, y2, v1, v2, v3, v4 rectOvalPtr = itemPtr state = (*TTk_Item)(unsafe.Pointer(itemPtr)).Fstate y1 = XTk_CanvasPsY(tls, canvas, *(*float64)(unsafe.Pointer(rectOvalPtr + 296 + 1*8))) y2 = XTk_CanvasPsY(tls, canvas, *(*float64)(unsafe.Pointer(rectOvalPtr + 296 + 3*8))) /* * Generate a string that creates a path for the rectangle or oval. This * is the only part of the function's code that is type-specific. */ if (*TRectOvalItem)(unsafe.Pointer(rectOvalPtr)).Fheader.FtypePtr == uintptr(unsafe.Pointer(&XtkRectangleType)) { pathObj = libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+32777, libc.VaList(bp+8, *(*float64)(unsafe.Pointer(rectOvalPtr + 296)), y1, *(*float64)(unsafe.Pointer(rectOvalPtr + 296 + 2*8))-*(*float64)(unsafe.Pointer(rectOvalPtr + 296)), y2-y1, *(*float64)(unsafe.Pointer(rectOvalPtr + 296))-*(*float64)(unsafe.Pointer(rectOvalPtr + 296 + 2*8)))) } else { pathObj = libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+30216, libc.VaList(bp+8, (*(*float64)(unsafe.Pointer(rectOvalPtr + 296))+*(*float64)(unsafe.Pointer(rectOvalPtr + 296 + 2*8)))/libc.Float64FromInt32(2), (y1+y2)/libc.Float64FromInt32(2), (*(*float64)(unsafe.Pointer(rectOvalPtr + 296 + 2*8))-*(*float64)(unsafe.Pointer(rectOvalPtr + 296)))/libc.Float64FromInt32(2), (y1-y2)/libc.Float64FromInt32(2))) } if state == int32(TK_STATE_NULL) { state = (*TTkCanvas)(unsafe.Pointer(canvas)).Fcanvas_state } color = (*TRectOvalItem)(unsafe.Pointer(rectOvalPtr)).Foutline.Fcolor fillColor = (*TRectOvalItem)(unsafe.Pointer(rectOvalPtr)).FfillColor fillStipple = (*TRectOvalItem)(unsafe.Pointer(rectOvalPtr)).FfillStipple if (*TTkCanvas)(unsafe.Pointer(canvas)).FcurrentItemPtr == itemPtr { if (*TRectOvalItem)(unsafe.Pointer(rectOvalPtr)).Foutline.FactiveColor != libc.UintptrFromInt32(0) { color = (*TRectOvalItem)(unsafe.Pointer(rectOvalPtr)).Foutline.FactiveColor } if (*TRectOvalItem)(unsafe.Pointer(rectOvalPtr)).FactiveFillColor != libc.UintptrFromInt32(0) { fillColor = (*TRectOvalItem)(unsafe.Pointer(rectOvalPtr)).FactiveFillColor } if (*TRectOvalItem)(unsafe.Pointer(rectOvalPtr)).FactiveFillStipple != uint64(0) { fillStipple = (*TRectOvalItem)(unsafe.Pointer(rectOvalPtr)).FactiveFillStipple } } else { if state == int32(TK_STATE_DISABLED) { if (*TRectOvalItem)(unsafe.Pointer(rectOvalPtr)).Foutline.FdisabledColor != libc.UintptrFromInt32(0) { color = (*TRectOvalItem)(unsafe.Pointer(rectOvalPtr)).Foutline.FdisabledColor } if (*TRectOvalItem)(unsafe.Pointer(rectOvalPtr)).FdisabledFillColor != libc.UintptrFromInt32(0) { fillColor = (*TRectOvalItem)(unsafe.Pointer(rectOvalPtr)).FdisabledFillColor } if (*TRectOvalItem)(unsafe.Pointer(rectOvalPtr)).FdisabledFillStipple != uint64(0) { fillStipple = (*TRectOvalItem)(unsafe.Pointer(rectOvalPtr)).FdisabledFillStipple } } } /* * Make our working space. */ psObj = libtcl9_0.XTcl_NewObj(tls) interpState = libtcl9_0.XTcl_SaveInterpState(tls, interp, TCL_OK) /* * First draw the filled area of the rectangle. */ if fillColor != libc.UintptrFromInt32(0) { libtcl9_0.XTcl_AppendObjToObj(tls, psObj, pathObj) libtcl9_0.XTcl_ResetResult(tls, interp) XTk_CanvasPsColor(tls, interp, canvas, fillColor) libtcl9_0.XTcl_AppendObjToObj(tls, psObj, libtcl9_0.XTcl_GetObjResult(tls, interp)) if fillStipple != uint64(0) { libtcl9_0.XTcl_AppendToObj(tls, psObj, __ccgo_ts+29143, int64(-libc.Int32FromInt32(1))) libtcl9_0.XTcl_ResetResult(tls, interp) XTk_CanvasPsStipple(tls, interp, canvas, fillStipple) libtcl9_0.XTcl_AppendObjToObj(tls, psObj, libtcl9_0.XTcl_GetObjResult(tls, interp)) if color != libc.UintptrFromInt32(0) { libtcl9_0.XTcl_AppendToObj(tls, psObj, __ccgo_ts+29149, int64(-libc.Int32FromInt32(1))) } } else { libtcl9_0.XTcl_AppendToObj(tls, psObj, __ccgo_ts+29165, int64(-libc.Int32FromInt32(1))) } } /* * Now draw the outline, if there is one. */ if color != libc.UintptrFromInt32(0) { libtcl9_0.XTcl_AppendObjToObj(tls, psObj, pathObj) libtcl9_0.XTcl_AppendToObj(tls, psObj, __ccgo_ts+32855, int64(-libc.Int32FromInt32(1))) libtcl9_0.XTcl_ResetResult(tls, interp) XTk_CanvasPsOutline(tls, canvas, itemPtr, rectOvalPtr+120) libtcl9_0.XTcl_AppendObjToObj(tls, psObj, libtcl9_0.XTcl_GetObjResult(tls, interp)) } /* * Plug the accumulated postscript back into the result. */ libtcl9_0.XTcl_RestoreInterpState(tls, interp, interpState) libtcl9_0.XTcl_AppendObjToObj(tls, libtcl9_0.XTcl_GetObjResult(tls, interp), psObj) _objPtr = psObj v2 = _objPtr v1 = *(*TTcl_Size)(unsafe.Pointer(v2)) *(*TTcl_Size)(unsafe.Pointer(v2))-- if v1 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr) } _objPtr1 = pathObj v4 = _objPtr1 v3 = *(*TTcl_Size)(unsafe.Pointer(v4)) *(*TTcl_Size)(unsafe.Pointer(v4))-- if v3 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr1) } return TCL_OK } const M_PI7 = 3.141592653589793 /* * Convenience macro. */ /* *-------------------------------------------------------------- * * TkLineToPoint -- * * Compute the distance from a point to a finite line segment. * * Results: * The return value is the distance from the line segment whose * end-points are *end1Ptr and *end2Ptr to the point given by *pointPtr. * * Side effects: * None. * *-------------------------------------------------------------- */ func XTkLineToPoint(tls *libc.TLS, end1Ptr uintptr, end2Ptr uintptr, pointPtr uintptr) (r float64) { /* Points to coords for point. */ var b1, b2, m1, m2, x, y, v1, v2, v3, v4, v5, v6, v7, v8 float64 _, _, _, _, _, _, _, _, _, _, _, _, _, _ = b1, b2, m1, m2, x, y, v1, v2, v3, v4, v5, v6, v7, v8 /* * Compute the point on the line that is closest to the point. This must * be done separately for vertical edges, horizontal edges, and other * edges. */ if *(*float64)(unsafe.Pointer(end1Ptr)) == *(*float64)(unsafe.Pointer(end2Ptr)) { /* * Vertical edge. */ x = *(*float64)(unsafe.Pointer(end1Ptr)) if *(*float64)(unsafe.Pointer(end1Ptr + 1*8)) >= *(*float64)(unsafe.Pointer(end2Ptr + 1*8)) { if *(*float64)(unsafe.Pointer(end1Ptr + 1*8)) < *(*float64)(unsafe.Pointer(pointPtr + 1*8)) { v1 = *(*float64)(unsafe.Pointer(end1Ptr + 1*8)) } else { v1 = *(*float64)(unsafe.Pointer(pointPtr + 1*8)) } y = v1 if y > *(*float64)(unsafe.Pointer(end2Ptr + 1*8)) { v2 = y } else { v2 = *(*float64)(unsafe.Pointer(end2Ptr + 1*8)) } y = v2 } else { if *(*float64)(unsafe.Pointer(end2Ptr + 1*8)) < *(*float64)(unsafe.Pointer(pointPtr + 1*8)) { v3 = *(*float64)(unsafe.Pointer(end2Ptr + 1*8)) } else { v3 = *(*float64)(unsafe.Pointer(pointPtr + 1*8)) } y = v3 if y > *(*float64)(unsafe.Pointer(end1Ptr + 1*8)) { v4 = y } else { v4 = *(*float64)(unsafe.Pointer(end1Ptr + 1*8)) } y = v4 } } else { if *(*float64)(unsafe.Pointer(end1Ptr + 1*8)) == *(*float64)(unsafe.Pointer(end2Ptr + 1*8)) { /* * Horizontal edge. */ y = *(*float64)(unsafe.Pointer(end1Ptr + 1*8)) if *(*float64)(unsafe.Pointer(end1Ptr)) >= *(*float64)(unsafe.Pointer(end2Ptr)) { if *(*float64)(unsafe.Pointer(end1Ptr)) < *(*float64)(unsafe.Pointer(pointPtr)) { v5 = *(*float64)(unsafe.Pointer(end1Ptr)) } else { v5 = *(*float64)(unsafe.Pointer(pointPtr)) } x = v5 if x > *(*float64)(unsafe.Pointer(end2Ptr)) { v6 = x } else { v6 = *(*float64)(unsafe.Pointer(end2Ptr)) } x = v6 } else { if *(*float64)(unsafe.Pointer(end2Ptr)) < *(*float64)(unsafe.Pointer(pointPtr)) { v7 = *(*float64)(unsafe.Pointer(end2Ptr)) } else { v7 = *(*float64)(unsafe.Pointer(pointPtr)) } x = v7 if x > *(*float64)(unsafe.Pointer(end1Ptr)) { v8 = x } else { v8 = *(*float64)(unsafe.Pointer(end1Ptr)) } x = v8 } } else { /* * The edge is neither horizontal nor vertical. Convert the edge to a * line equation of the form y = m1*x + b1. Then compute a line * perpendicular to this edge but passing through the point, also in * the form y = m2*x + b2. */ m1 = (*(*float64)(unsafe.Pointer(end2Ptr + 1*8)) - *(*float64)(unsafe.Pointer(end1Ptr + 1*8))) / (*(*float64)(unsafe.Pointer(end2Ptr)) - *(*float64)(unsafe.Pointer(end1Ptr))) b1 = *(*float64)(unsafe.Pointer(end1Ptr + 1*8)) - float64(m1**(*float64)(unsafe.Pointer(end1Ptr))) m2 = -libc.Float64FromFloat64(1) / m1 b2 = *(*float64)(unsafe.Pointer(pointPtr + 1*8)) - float64(m2**(*float64)(unsafe.Pointer(pointPtr))) x = (b2 - b1) / (m1 - m2) y = float64(m1*x) + b1 if *(*float64)(unsafe.Pointer(end1Ptr)) > *(*float64)(unsafe.Pointer(end2Ptr)) { if x > *(*float64)(unsafe.Pointer(end1Ptr)) { x = *(*float64)(unsafe.Pointer(end1Ptr)) y = *(*float64)(unsafe.Pointer(end1Ptr + 1*8)) } else { if x < *(*float64)(unsafe.Pointer(end2Ptr)) { x = *(*float64)(unsafe.Pointer(end2Ptr)) y = *(*float64)(unsafe.Pointer(end2Ptr + 1*8)) } } } else { if x > *(*float64)(unsafe.Pointer(end2Ptr)) { x = *(*float64)(unsafe.Pointer(end2Ptr)) y = *(*float64)(unsafe.Pointer(end2Ptr + 1*8)) } else { if x < *(*float64)(unsafe.Pointer(end1Ptr)) { x = *(*float64)(unsafe.Pointer(end1Ptr)) y = *(*float64)(unsafe.Pointer(end1Ptr + 1*8)) } } } } } /* * Compute the distance to the closest point. */ return libc.X__builtin_hypot(tls, *(*float64)(unsafe.Pointer(pointPtr))-x, *(*float64)(unsafe.Pointer(pointPtr + 1*8))-y) } /* *-------------------------------------------------------------- * * TkLineToArea -- * * Determine whether a line lies entirely inside, entirely outside, or * overlapping a given rectangular area. * * Results: * -1 is returned if the line given by end1Ptr and end2Ptr is entirely * outside the rectangle given by rectPtr. 0 is returned if the polygon * overlaps the rectangle, and 1 is returned if the polygon is entirely * inside the rectangle. * * Side effects: * None. * *-------------------------------------------------------------- */ func XTkLineToArea(tls *libc.TLS, end1Ptr uintptr, end2Ptr uintptr, rectPtr uintptr) (r int32) { /* Points to coords for rectangle, in the * order x1, y1, x2, y2. X1 must be no larger * than x2, and y1 no larger than y2. */ var high, low, m, x, y float64 var inside1, inside2 int32 _, _, _, _, _, _, _ = high, inside1, inside2, low, m, x, y /* * First check the two points individually to see whether they are inside * the rectangle or not. */ inside1 = libc.BoolInt32(*(*float64)(unsafe.Pointer(end1Ptr)) >= *(*float64)(unsafe.Pointer(rectPtr)) && *(*float64)(unsafe.Pointer(end1Ptr)) <= *(*float64)(unsafe.Pointer(rectPtr + 2*8)) && *(*float64)(unsafe.Pointer(end1Ptr + 1*8)) >= *(*float64)(unsafe.Pointer(rectPtr + 1*8)) && *(*float64)(unsafe.Pointer(end1Ptr + 1*8)) <= *(*float64)(unsafe.Pointer(rectPtr + 3*8))) inside2 = libc.BoolInt32(*(*float64)(unsafe.Pointer(end2Ptr)) >= *(*float64)(unsafe.Pointer(rectPtr)) && *(*float64)(unsafe.Pointer(end2Ptr)) <= *(*float64)(unsafe.Pointer(rectPtr + 2*8)) && *(*float64)(unsafe.Pointer(end2Ptr + 1*8)) >= *(*float64)(unsafe.Pointer(rectPtr + 1*8)) && *(*float64)(unsafe.Pointer(end2Ptr + 1*8)) <= *(*float64)(unsafe.Pointer(rectPtr + 3*8))) if inside1 != inside2 { return 0 } if inside1&inside2 != 0 { return int32(1) } /* * Both points are outside the rectangle, but still need to check for * intersections between the line and the rectangle. Horizontal and * vertical lines are particularly easy, so handle them separately. */ if *(*float64)(unsafe.Pointer(end1Ptr)) == *(*float64)(unsafe.Pointer(end2Ptr)) { /* * Vertical line. */ if libc.BoolInt32(*(*float64)(unsafe.Pointer(end1Ptr + 1*8)) >= *(*float64)(unsafe.Pointer(rectPtr + 1*8)))^libc.BoolInt32(*(*float64)(unsafe.Pointer(end2Ptr + 1*8)) >= *(*float64)(unsafe.Pointer(rectPtr + 1*8))) != 0 && *(*float64)(unsafe.Pointer(end1Ptr)) >= *(*float64)(unsafe.Pointer(rectPtr)) && *(*float64)(unsafe.Pointer(end1Ptr)) <= *(*float64)(unsafe.Pointer(rectPtr + 2*8)) { return 0 } } else { if *(*float64)(unsafe.Pointer(end1Ptr + 1*8)) == *(*float64)(unsafe.Pointer(end2Ptr + 1*8)) { /* * Horizontal line. */ if libc.BoolInt32(*(*float64)(unsafe.Pointer(end1Ptr)) >= *(*float64)(unsafe.Pointer(rectPtr)))^libc.BoolInt32(*(*float64)(unsafe.Pointer(end2Ptr)) >= *(*float64)(unsafe.Pointer(rectPtr))) != 0 && *(*float64)(unsafe.Pointer(end1Ptr + 1*8)) >= *(*float64)(unsafe.Pointer(rectPtr + 1*8)) && *(*float64)(unsafe.Pointer(end1Ptr + 1*8)) <= *(*float64)(unsafe.Pointer(rectPtr + 3*8)) { return 0 } } else { /* * Diagonal line. Compute slope of line and use for intersection * checks against each of the sides of the rectangle: left, right, * bottom, top. */ m = (*(*float64)(unsafe.Pointer(end2Ptr + 1*8)) - *(*float64)(unsafe.Pointer(end1Ptr + 1*8))) / (*(*float64)(unsafe.Pointer(end2Ptr)) - *(*float64)(unsafe.Pointer(end1Ptr))) if *(*float64)(unsafe.Pointer(end1Ptr)) < *(*float64)(unsafe.Pointer(end2Ptr)) { low = *(*float64)(unsafe.Pointer(end1Ptr)) high = *(*float64)(unsafe.Pointer(end2Ptr)) } else { low = *(*float64)(unsafe.Pointer(end2Ptr)) high = *(*float64)(unsafe.Pointer(end1Ptr)) } /* * Left edge. */ y = *(*float64)(unsafe.Pointer(end1Ptr + 1*8)) + float64((*(*float64)(unsafe.Pointer(rectPtr))-*(*float64)(unsafe.Pointer(end1Ptr)))*m) if *(*float64)(unsafe.Pointer(rectPtr)) >= low && *(*float64)(unsafe.Pointer(rectPtr)) <= high && y >= *(*float64)(unsafe.Pointer(rectPtr + 1*8)) && y <= *(*float64)(unsafe.Pointer(rectPtr + 3*8)) { return 0 } /* * Right edge. */ y += float64((*(*float64)(unsafe.Pointer(rectPtr + 2*8)) - *(*float64)(unsafe.Pointer(rectPtr))) * m) if y >= *(*float64)(unsafe.Pointer(rectPtr + 1*8)) && y <= *(*float64)(unsafe.Pointer(rectPtr + 3*8)) && *(*float64)(unsafe.Pointer(rectPtr + 2*8)) >= low && *(*float64)(unsafe.Pointer(rectPtr + 2*8)) <= high { return 0 } /* * Bottom edge. */ if *(*float64)(unsafe.Pointer(end1Ptr + 1*8)) < *(*float64)(unsafe.Pointer(end2Ptr + 1*8)) { low = *(*float64)(unsafe.Pointer(end1Ptr + 1*8)) high = *(*float64)(unsafe.Pointer(end2Ptr + 1*8)) } else { low = *(*float64)(unsafe.Pointer(end2Ptr + 1*8)) high = *(*float64)(unsafe.Pointer(end1Ptr + 1*8)) } x = *(*float64)(unsafe.Pointer(end1Ptr)) + (*(*float64)(unsafe.Pointer(rectPtr + 1*8))-*(*float64)(unsafe.Pointer(end1Ptr + 1*8)))/m if x >= *(*float64)(unsafe.Pointer(rectPtr)) && x <= *(*float64)(unsafe.Pointer(rectPtr + 2*8)) && *(*float64)(unsafe.Pointer(rectPtr + 1*8)) >= low && *(*float64)(unsafe.Pointer(rectPtr + 1*8)) <= high { return 0 } /* * Top edge. */ x += (*(*float64)(unsafe.Pointer(rectPtr + 3*8)) - *(*float64)(unsafe.Pointer(rectPtr + 1*8))) / m if x >= *(*float64)(unsafe.Pointer(rectPtr)) && x <= *(*float64)(unsafe.Pointer(rectPtr + 2*8)) && *(*float64)(unsafe.Pointer(rectPtr + 3*8)) >= low && *(*float64)(unsafe.Pointer(rectPtr + 3*8)) <= high { return 0 } } } return -int32(1) } /* *-------------------------------------------------------------- * * TkThickPolyLineToArea -- * * This function is called to determine whether a connected series of * line segments lies entirely inside, entirely outside, or overlapping a * given rectangular area. * * Results: * -1 is returned if the lines are entirely outside the area, 0 if they * overlap, and 1 if they are entirely inside the given area. * * Side effects: * None. * *-------------------------------------------------------------- */ func XTkThickPolyLineToArea(tls *libc.TLS, coordPtr uintptr, numPoints int32, width float64, capStyle int32, joinStyle int32, rectPtr uintptr) (r int32) { bp := tls.Alloc(80) defer tls.Free(80) /* Rectangular area to check against. */ var changedMiterToBevel, count, inside int32 var radius float64 var _ /* poly at bp+0 */ [10]float64 _, _, _, _ = changedMiterToBevel, count, inside, radius /* Tentative guess about what to return, based * on all points seen so far: one means * everything seen so far was inside the area; * -1 means everything was outside the area. * 0 means overlap has been found. */ radius = width / float64(2) inside = -int32(1) if *(*float64)(unsafe.Pointer(coordPtr)) >= *(*float64)(unsafe.Pointer(rectPtr)) && *(*float64)(unsafe.Pointer(coordPtr)) <= *(*float64)(unsafe.Pointer(rectPtr + 2*8)) && *(*float64)(unsafe.Pointer(coordPtr + 1*8)) >= *(*float64)(unsafe.Pointer(rectPtr + 1*8)) && *(*float64)(unsafe.Pointer(coordPtr + 1*8)) <= *(*float64)(unsafe.Pointer(rectPtr + 3*8)) { inside = int32(1) } /* * Iterate through all of the edges of the line, computing a polygon for * each edge and testing the area against that polygon. In addition, there * are additional tests to deal with rounded joints and caps. */ changedMiterToBevel = 0 count = numPoints for { if !(count >= int32(2)) { break } /* * If rounding is done around the first point of the edge then test a * circular region around the point with the area. */ if capStyle == int32(CapRound) && count == numPoints || joinStyle == int32(JoinRound) && count != numPoints { (*(*[10]float64)(unsafe.Pointer(bp)))[0] = *(*float64)(unsafe.Pointer(coordPtr)) - radius (*(*[10]float64)(unsafe.Pointer(bp)))[int32(1)] = *(*float64)(unsafe.Pointer(coordPtr + 1*8)) - radius (*(*[10]float64)(unsafe.Pointer(bp)))[int32(2)] = *(*float64)(unsafe.Pointer(coordPtr)) + radius (*(*[10]float64)(unsafe.Pointer(bp)))[int32(3)] = *(*float64)(unsafe.Pointer(coordPtr + 1*8)) + radius if XTkOvalToArea(tls, bp, rectPtr) != inside { return 0 } } /* * Compute the polygonal shape corresponding to this edge, consisting * of two points for the first point of the edge and two points for * the last point of the edge. */ if count == numPoints { XTkGetButtPoints(tls, coordPtr+uintptr(2)*8, coordPtr, width, libc.BoolInt32(capStyle == int32(CapProjecting)), bp, bp+uintptr(2)*8) } else { if joinStyle == JoinMiter && !(changedMiterToBevel != 0) { (*(*[10]float64)(unsafe.Pointer(bp)))[0] = (*(*[10]float64)(unsafe.Pointer(bp)))[int32(6)] (*(*[10]float64)(unsafe.Pointer(bp)))[int32(1)] = (*(*[10]float64)(unsafe.Pointer(bp)))[int32(7)] (*(*[10]float64)(unsafe.Pointer(bp)))[int32(2)] = (*(*[10]float64)(unsafe.Pointer(bp)))[int32(4)] (*(*[10]float64)(unsafe.Pointer(bp)))[int32(3)] = (*(*[10]float64)(unsafe.Pointer(bp)))[int32(5)] } else { XTkGetButtPoints(tls, coordPtr+uintptr(2)*8, coordPtr, width, 0, bp, bp+uintptr(2)*8) /* * If the last joint was beveled, then also check a polygon * comprising the last two points of the previous polygon and the * first two from this polygon; this checks the wedges that fill * the beveled joint. */ if joinStyle == int32(JoinBevel) || changedMiterToBevel != 0 { (*(*[10]float64)(unsafe.Pointer(bp)))[int32(8)] = (*(*[10]float64)(unsafe.Pointer(bp)))[0] (*(*[10]float64)(unsafe.Pointer(bp)))[int32(9)] = (*(*[10]float64)(unsafe.Pointer(bp)))[int32(1)] if XTkPolygonToArea(tls, bp, int32(5), rectPtr) != inside { return 0 } changedMiterToBevel = 0 } } } if count == int32(2) { XTkGetButtPoints(tls, coordPtr, coordPtr+uintptr(2)*8, width, libc.BoolInt32(capStyle == int32(CapProjecting)), bp+uintptr(4)*8, bp+uintptr(6)*8) } else { if joinStyle == JoinMiter { if XTkGetMiterPoints(tls, coordPtr, coordPtr+uintptr(2)*8, coordPtr+uintptr(4)*8, width, bp+uintptr(4)*8, bp+uintptr(6)*8) == 0 { changedMiterToBevel = int32(1) XTkGetButtPoints(tls, coordPtr, coordPtr+uintptr(2)*8, width, 0, bp+uintptr(4)*8, bp+uintptr(6)*8) } } else { XTkGetButtPoints(tls, coordPtr, coordPtr+uintptr(2)*8, width, 0, bp+uintptr(4)*8, bp+uintptr(6)*8) } } (*(*[10]float64)(unsafe.Pointer(bp)))[int32(8)] = (*(*[10]float64)(unsafe.Pointer(bp)))[0] (*(*[10]float64)(unsafe.Pointer(bp)))[int32(9)] = (*(*[10]float64)(unsafe.Pointer(bp)))[int32(1)] if XTkPolygonToArea(tls, bp, int32(5), rectPtr) != inside { return 0 } goto _1 _1: ; count-- coordPtr += uintptr(2) * 8 } /* * If caps are rounded, check the cap around the final point of the line. */ if capStyle == int32(CapRound) { (*(*[10]float64)(unsafe.Pointer(bp)))[0] = *(*float64)(unsafe.Pointer(coordPtr)) - radius (*(*[10]float64)(unsafe.Pointer(bp)))[int32(1)] = *(*float64)(unsafe.Pointer(coordPtr + 1*8)) - radius (*(*[10]float64)(unsafe.Pointer(bp)))[int32(2)] = *(*float64)(unsafe.Pointer(coordPtr)) + radius (*(*[10]float64)(unsafe.Pointer(bp)))[int32(3)] = *(*float64)(unsafe.Pointer(coordPtr + 1*8)) + radius if XTkOvalToArea(tls, bp, rectPtr) != inside { return 0 } } return inside } /* *-------------------------------------------------------------- * * TkPolygonToPoint -- * * Compute the distance from a point to a polygon. * * Results: * The return value is 0.0 if the point referred to by pointPtr is within * the polygon referred to by polyPtr and numPoints. Otherwise the return * value is the distance of the point from the polygon. * * Side effects: * None. * *-------------------------------------------------------------- */ func XTkPolygonToPoint(tls *libc.TLS, polyPtr uintptr, numPoints int32, pointPtr uintptr) (r float64) { /* Points to coords for point. */ var b1, b2, bestDist, dist, m1, m2, x, y, v10, v12, v2, v3, v4, v5, v6, v7, v8, v9 float64 var count, intersections, lower int32 var pPtr uintptr var v11, v13 bool _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = b1, b2, bestDist, count, dist, intersections, lower, m1, m2, pPtr, x, y, v10, v11, v12, v13, v2, v3, v4, v5, v6, v7, v8, v9 /* * Iterate through all of the edges in the polygon, updating bestDist and * intersections. * * TRICKY POINT: when computing intersections, include left x-coordinate * of line within its range, but not y-coordinate. Otherwise if the point * lies exactly below a vertex we'll count it as two intersections. */ bestDist = float64(1e+36) intersections = 0 count = numPoints pPtr = polyPtr for { if !(count > int32(1)) { break } /* * Compute the point on the current edge closest to the point and * update the intersection count. This must be done separately for * vertical edges, horizontal edges, and other edges. */ if *(*float64)(unsafe.Pointer(pPtr + 2*8)) == *(*float64)(unsafe.Pointer(pPtr)) { /* * Vertical edge. */ x = *(*float64)(unsafe.Pointer(pPtr)) if *(*float64)(unsafe.Pointer(pPtr + 1*8)) >= *(*float64)(unsafe.Pointer(pPtr + 3*8)) { if *(*float64)(unsafe.Pointer(pPtr + 1*8)) < *(*float64)(unsafe.Pointer(pointPtr + 1*8)) { v2 = *(*float64)(unsafe.Pointer(pPtr + 1*8)) } else { v2 = *(*float64)(unsafe.Pointer(pointPtr + 1*8)) } y = v2 if y > *(*float64)(unsafe.Pointer(pPtr + 3*8)) { v3 = y } else { v3 = *(*float64)(unsafe.Pointer(pPtr + 3*8)) } y = v3 } else { if *(*float64)(unsafe.Pointer(pPtr + 3*8)) < *(*float64)(unsafe.Pointer(pointPtr + 1*8)) { v4 = *(*float64)(unsafe.Pointer(pPtr + 3*8)) } else { v4 = *(*float64)(unsafe.Pointer(pointPtr + 1*8)) } y = v4 if y > *(*float64)(unsafe.Pointer(pPtr + 1*8)) { v5 = y } else { v5 = *(*float64)(unsafe.Pointer(pPtr + 1*8)) } y = v5 } } else { if *(*float64)(unsafe.Pointer(pPtr + 3*8)) == *(*float64)(unsafe.Pointer(pPtr + 1*8)) { /* * Horizontal edge. */ y = *(*float64)(unsafe.Pointer(pPtr + 1*8)) if *(*float64)(unsafe.Pointer(pPtr)) >= *(*float64)(unsafe.Pointer(pPtr + 2*8)) { if *(*float64)(unsafe.Pointer(pPtr)) < *(*float64)(unsafe.Pointer(pointPtr)) { v6 = *(*float64)(unsafe.Pointer(pPtr)) } else { v6 = *(*float64)(unsafe.Pointer(pointPtr)) } x = v6 if x > *(*float64)(unsafe.Pointer(pPtr + 2*8)) { v7 = x } else { v7 = *(*float64)(unsafe.Pointer(pPtr + 2*8)) } x = v7 if *(*float64)(unsafe.Pointer(pointPtr + 1*8)) < y && *(*float64)(unsafe.Pointer(pointPtr)) < *(*float64)(unsafe.Pointer(pPtr)) && *(*float64)(unsafe.Pointer(pointPtr)) >= *(*float64)(unsafe.Pointer(pPtr + 2*8)) { intersections++ } } else { if *(*float64)(unsafe.Pointer(pPtr + 2*8)) < *(*float64)(unsafe.Pointer(pointPtr)) { v8 = *(*float64)(unsafe.Pointer(pPtr + 2*8)) } else { v8 = *(*float64)(unsafe.Pointer(pointPtr)) } x = v8 if x > *(*float64)(unsafe.Pointer(pPtr)) { v9 = x } else { v9 = *(*float64)(unsafe.Pointer(pPtr)) } x = v9 if *(*float64)(unsafe.Pointer(pointPtr + 1*8)) < y && *(*float64)(unsafe.Pointer(pointPtr)) < *(*float64)(unsafe.Pointer(pPtr + 2*8)) && *(*float64)(unsafe.Pointer(pointPtr)) >= *(*float64)(unsafe.Pointer(pPtr)) { intersections++ } } } else { /* Non-zero means point below line. */ /* * The edge is neither horizontal nor vertical. Convert the edge * to a line equation of the form y = m1*x + b1. Then compute a * line perpendicular to this edge but passing through the point, * also in the form y = m2*x + b2. */ m1 = (*(*float64)(unsafe.Pointer(pPtr + 3*8)) - *(*float64)(unsafe.Pointer(pPtr + 1*8))) / (*(*float64)(unsafe.Pointer(pPtr + 2*8)) - *(*float64)(unsafe.Pointer(pPtr))) b1 = *(*float64)(unsafe.Pointer(pPtr + 1*8)) - float64(m1**(*float64)(unsafe.Pointer(pPtr))) m2 = -libc.Float64FromFloat64(1) / m1 b2 = *(*float64)(unsafe.Pointer(pointPtr + 1*8)) - float64(m2**(*float64)(unsafe.Pointer(pointPtr))) x = (b2 - b1) / (m1 - m2) y = float64(m1*x) + b1 if *(*float64)(unsafe.Pointer(pPtr)) > *(*float64)(unsafe.Pointer(pPtr + 2*8)) { if x > *(*float64)(unsafe.Pointer(pPtr)) { x = *(*float64)(unsafe.Pointer(pPtr)) y = *(*float64)(unsafe.Pointer(pPtr + 1*8)) } else { if x < *(*float64)(unsafe.Pointer(pPtr + 2*8)) { x = *(*float64)(unsafe.Pointer(pPtr + 2*8)) y = *(*float64)(unsafe.Pointer(pPtr + 3*8)) } } } else { if x > *(*float64)(unsafe.Pointer(pPtr + 2*8)) { x = *(*float64)(unsafe.Pointer(pPtr + 2*8)) y = *(*float64)(unsafe.Pointer(pPtr + 3*8)) } else { if x < *(*float64)(unsafe.Pointer(pPtr)) { x = *(*float64)(unsafe.Pointer(pPtr)) y = *(*float64)(unsafe.Pointer(pPtr + 1*8)) } } } lower = libc.BoolInt32(float64(m1**(*float64)(unsafe.Pointer(pointPtr)))+b1 > *(*float64)(unsafe.Pointer(pointPtr + 1*8))) if v11 = lower != 0; v11 { if *(*float64)(unsafe.Pointer(pPtr)) < *(*float64)(unsafe.Pointer(pPtr + 2*8)) { v10 = *(*float64)(unsafe.Pointer(pPtr)) } else { v10 = *(*float64)(unsafe.Pointer(pPtr + 2*8)) } } if v13 = v11 && *(*float64)(unsafe.Pointer(pointPtr)) >= v10; v13 { if *(*float64)(unsafe.Pointer(pPtr)) > *(*float64)(unsafe.Pointer(pPtr + 2*8)) { v12 = *(*float64)(unsafe.Pointer(pPtr)) } else { v12 = *(*float64)(unsafe.Pointer(pPtr + 2*8)) } } if v13 && *(*float64)(unsafe.Pointer(pointPtr)) < v12 { intersections++ } } } /* * Compute the distance to the closest point, and see if that is the * best distance seen so far. */ dist = libc.X__builtin_hypot(tls, *(*float64)(unsafe.Pointer(pointPtr))-x, *(*float64)(unsafe.Pointer(pointPtr + 1*8))-y) if dist < bestDist { bestDist = dist } goto _1 _1: ; count-- pPtr += uintptr(2) * 8 } /* * We've processed all of the points. If the number of intersections is * odd, the point is inside the polygon. */ if intersections&int32(0x1) != 0 { return float64(0) } return bestDist } /* *-------------------------------------------------------------- * * TkPolygonToArea -- * * Determine whether a polygon lies entirely inside, entirely outside, or * overlapping a given rectangular area. * * Results: * -1 is returned if the polygon given by polyPtr and numPoints is * entirely outside the rectangle given by rectPtr. 0 is returned if the * polygon overlaps the rectangle, and 1 is returned if the polygon is * entirely inside the rectangle. * * Side effects: * None. * *-------------------------------------------------------------- */ func XTkPolygonToArea(tls *libc.TLS, polyPtr uintptr, numPoints int32, rectPtr uintptr) (r int32) { /* Points to coords for rectangle, in the * order x1, y1, x2, y2. X1 and y1 must be * lower-left corner. */ var count, state int32 var pPtr uintptr _, _, _ = count, pPtr, state /* * Iterate over all of the edges of the polygon and test them against the * rectangle. Can quit as soon as the state becomes "intersecting". */ state = XTkLineToArea(tls, polyPtr, polyPtr+uintptr(2)*8, rectPtr) if state == 0 { return 0 } pPtr = polyPtr + uintptr(2)*8 count = numPoints - libc.Int32FromInt32(1) for { if !(count >= int32(2)) { break } if XTkLineToArea(tls, pPtr, pPtr+uintptr(2)*8, rectPtr) != state { return 0 } goto _1 _1: ; pPtr += uintptr(2) * 8 count-- } /* * If all of the edges were inside the rectangle we're done. If all of the * edges were outside, then the rectangle could still intersect the * polygon (if it's entirely enclosed). Call TkPolygonToPoint to figure * this out. */ if state == int32(1) { return int32(1) } if XTkPolygonToPoint(tls, polyPtr, numPoints, rectPtr) == float64(0) { return 0 } return -int32(1) } /* *-------------------------------------------------------------- * * TkOvalToPoint -- * * Computes the distance from a given point to a given oval, in canvas * units. * * Results: * The return value is 0 if the point given by *pointPtr is inside the * oval. If the point isn't inside the oval then the return value is * approximately the distance from the point to the oval. If the oval is * filled, then anywhere in the interior is considered "inside"; if the * oval isn't filled, then "inside" means only the area occupied by the * outline. * * Side effects: * None. * *-------------------------------------------------------------- */ func XTkOvalToPoint(tls *libc.TLS, ovalPtr uintptr, width float64, filled int32, pointPtr uintptr) (r float64) { /* Coordinates of point. */ var distToCenter, distToOutline, scaledDistance, xDelta, xDiam, yDelta, yDiam float64 _, _, _, _, _, _, _ = distToCenter, distToOutline, scaledDistance, xDelta, xDiam, yDelta, yDiam /* * Compute the distance between the center of the oval and the point in * question, using a coordinate system where the oval has been transformed * to a circle with unit radius. */ xDelta = *(*float64)(unsafe.Pointer(pointPtr)) - (*(*float64)(unsafe.Pointer(ovalPtr))+*(*float64)(unsafe.Pointer(ovalPtr + 2*8)))/float64(2) yDelta = *(*float64)(unsafe.Pointer(pointPtr + 1*8)) - (*(*float64)(unsafe.Pointer(ovalPtr + 1*8))+*(*float64)(unsafe.Pointer(ovalPtr + 3*8)))/float64(2) distToCenter = libc.X__builtin_hypot(tls, xDelta, yDelta) scaledDistance = libc.X__builtin_hypot(tls, xDelta/((*(*float64)(unsafe.Pointer(ovalPtr + 2*8))+width-*(*float64)(unsafe.Pointer(ovalPtr)))/float64(2)), yDelta/((*(*float64)(unsafe.Pointer(ovalPtr + 3*8))+width-*(*float64)(unsafe.Pointer(ovalPtr + 1*8)))/float64(2))) /* * If the scaled distance is greater than 1 then it means no hit. Compute * the distance from the point to the edge of the circle, then scale this * distance back to the original coordinate system. * * Note: this distance isn't completely accurate. It's only an * approximation, and it can overestimate the correct distance when the * oval is eccentric. */ if scaledDistance > float64(1) { return float64(distToCenter / scaledDistance * (scaledDistance - float64(1))) } /* * Scaled distance less than 1 means the point is inside the outer edge of * the oval. If this is a filled oval, then we have a hit. Otherwise, do * the same computation as above (scale back to original coordinate * system), but also check to see if the point is within the width of the * outline. */ if filled != 0 { return float64(0) } if scaledDistance > float64(1e-10) { distToOutline = float64(distToCenter/scaledDistance*(float64(1)-scaledDistance)) - width } else { /* * Avoid dividing by a very small number (it could cause an arithmetic * overflow). This problem occurs if the point is very close to the * center of the oval. */ xDiam = *(*float64)(unsafe.Pointer(ovalPtr + 2*8)) - *(*float64)(unsafe.Pointer(ovalPtr)) yDiam = *(*float64)(unsafe.Pointer(ovalPtr + 3*8)) - *(*float64)(unsafe.Pointer(ovalPtr + 1*8)) if xDiam < yDiam { distToOutline = (xDiam - width) / libc.Float64FromInt32(2) } else { distToOutline = (yDiam - width) / libc.Float64FromInt32(2) } } if distToOutline < float64(0) { return float64(0) } return distToOutline } /* *-------------------------------------------------------------- * * TkOvalToArea -- * * Determine whether an oval lies entirely inside, entirely outside, or * overlapping a given rectangular area. * * Results: * -1 is returned if the oval described by ovalPtr is entirely outside * the rectangle given by rectPtr. 0 is returned if the oval overlaps the * rectangle, and 1 is returned if the oval is entirely inside the * rectangle. * * Side effects: * None. * *-------------------------------------------------------------- */ func XTkOvalToArea(tls *libc.TLS, ovalPtr uintptr, rectPtr uintptr) (r int32) { /* Points to coords for rectangle, in the * order x1, y1, x2, y2. X1 and y1 must be * lower-left corner. */ var centerX, centerY, deltaX, deltaY, radX, radY float64 _, _, _, _, _, _ = centerX, centerY, deltaX, deltaY, radX, radY /* * First, see if oval is entirely inside rectangle or entirely outside * rectangle. */ if *(*float64)(unsafe.Pointer(rectPtr)) <= *(*float64)(unsafe.Pointer(ovalPtr)) && *(*float64)(unsafe.Pointer(rectPtr + 2*8)) >= *(*float64)(unsafe.Pointer(ovalPtr + 2*8)) && *(*float64)(unsafe.Pointer(rectPtr + 1*8)) <= *(*float64)(unsafe.Pointer(ovalPtr + 1*8)) && *(*float64)(unsafe.Pointer(rectPtr + 3*8)) >= *(*float64)(unsafe.Pointer(ovalPtr + 3*8)) { return int32(1) } if *(*float64)(unsafe.Pointer(rectPtr + 2*8)) < *(*float64)(unsafe.Pointer(ovalPtr)) || *(*float64)(unsafe.Pointer(rectPtr)) > *(*float64)(unsafe.Pointer(ovalPtr + 2*8)) || *(*float64)(unsafe.Pointer(rectPtr + 3*8)) < *(*float64)(unsafe.Pointer(ovalPtr + 1*8)) || *(*float64)(unsafe.Pointer(rectPtr + 1*8)) > *(*float64)(unsafe.Pointer(ovalPtr + 3*8)) { return -int32(1) } /* * Next, go through the rectangle side by side. For each side of the * rectangle, find the point on the side that is closest to the oval's * center, and see if that point is inside the oval. If at least one such * point is inside the oval, then the rectangle intersects the oval. */ centerX = (*(*float64)(unsafe.Pointer(ovalPtr)) + *(*float64)(unsafe.Pointer(ovalPtr + 2*8))) / libc.Float64FromInt32(2) centerY = (*(*float64)(unsafe.Pointer(ovalPtr + 1*8)) + *(*float64)(unsafe.Pointer(ovalPtr + 3*8))) / libc.Float64FromInt32(2) radX = (*(*float64)(unsafe.Pointer(ovalPtr + 2*8)) - *(*float64)(unsafe.Pointer(ovalPtr))) / libc.Float64FromInt32(2) radY = (*(*float64)(unsafe.Pointer(ovalPtr + 3*8)) - *(*float64)(unsafe.Pointer(ovalPtr + 1*8))) / libc.Float64FromInt32(2) deltaY = *(*float64)(unsafe.Pointer(rectPtr + 1*8)) - centerY if deltaY < float64(0) { deltaY = centerY - *(*float64)(unsafe.Pointer(rectPtr + 3*8)) if deltaY < float64(0) { deltaY = libc.Float64FromInt32(0) } } deltaY /= radY deltaY *= deltaY /* * Left side: */ deltaX = (*(*float64)(unsafe.Pointer(rectPtr)) - centerX) / radX deltaX *= deltaX if deltaX+deltaY <= float64(1) { return 0 } /* * Right side: */ deltaX = (*(*float64)(unsafe.Pointer(rectPtr + 2*8)) - centerX) / radX deltaX *= deltaX if deltaX+deltaY <= float64(1) { return 0 } deltaX = *(*float64)(unsafe.Pointer(rectPtr)) - centerX if deltaX < float64(0) { deltaX = centerX - *(*float64)(unsafe.Pointer(rectPtr + 2*8)) if deltaX < float64(0) { deltaX = libc.Float64FromInt32(0) } } deltaX /= radX deltaX *= deltaX /* * Bottom side: */ deltaY = (*(*float64)(unsafe.Pointer(rectPtr + 1*8)) - centerY) / radY deltaY *= deltaY if deltaX+deltaY < float64(1) { return 0 } /* * Top side: */ deltaY = (*(*float64)(unsafe.Pointer(rectPtr + 3*8)) - centerY) / radY deltaY *= deltaY if deltaX+deltaY < float64(1) { return 0 } return -int32(1) } /* *-------------------------------------------------------------- * * TkIncludePoint -- * * Given a point and a generic canvas item header, expand the item's * bounding box if needed to include the point. * * Results: * None. * * Side effects: * The boudn. * *-------------------------------------------------------------- */ func XTkIncludePoint(tls *libc.TLS, itemPtr uintptr, pointPtr uintptr) { /* Address of two doubles giving x and y * coordinates of point. */ var tmp int32 _ = tmp tmp = int32(*(*float64)(unsafe.Pointer(pointPtr)) + libc.Float64FromFloat64(0.5)) if tmp < (*TTk_Item)(unsafe.Pointer(itemPtr)).Fx1 { (*TTk_Item)(unsafe.Pointer(itemPtr)).Fx1 = tmp } if tmp > (*TTk_Item)(unsafe.Pointer(itemPtr)).Fx2 { (*TTk_Item)(unsafe.Pointer(itemPtr)).Fx2 = tmp } tmp = int32(*(*float64)(unsafe.Pointer(pointPtr + 1*8)) + libc.Float64FromFloat64(0.5)) if tmp < (*TTk_Item)(unsafe.Pointer(itemPtr)).Fy1 { (*TTk_Item)(unsafe.Pointer(itemPtr)).Fy1 = tmp } if tmp > (*TTk_Item)(unsafe.Pointer(itemPtr)).Fy2 { (*TTk_Item)(unsafe.Pointer(itemPtr)).Fy2 = tmp } } /* *-------------------------------------------------------------- * * TkBezierScreenPoints -- * * Given four control points, create a larger set of XPoints for a Bezier * curve based on the points. * * Results: * The array at *xPointPtr gets filled in with numSteps XPoints * corresponding to the Bezier spline defined by the four control points. * Note: no output point is generated for the first input point, but an * output point *is* generated for the last input point. * * Side effects: * None. * *-------------------------------------------------------------- */ func XTkBezierScreenPoints(tls *libc.TLS, canvas TTk_Canvas, control uintptr, numSteps int32, xPointPtr uintptr) { /* Where to put new points. */ var i int32 var t, t2, t3, u, u2, u3 float64 _, _, _, _, _, _, _ = i, t, t2, t3, u, u2, u3 i = int32(1) for { if !(i <= numSteps) { break } t = float64(i) / float64(numSteps) t2 = float64(t * t) t3 = float64(t2 * t) u = float64(1) - t u2 = float64(u * u) u3 = float64(u2 * u) XTk_CanvasDrawableCoords(tls, canvas, float64(*(*float64)(unsafe.Pointer(control))*u3)+float64(float64(3)*(float64(float64(*(*float64)(unsafe.Pointer(control + 2*8))*t)*u2)+float64(float64(*(*float64)(unsafe.Pointer(control + 4*8))*t2)*u)))+float64(*(*float64)(unsafe.Pointer(control + 6*8))*t3), float64(*(*float64)(unsafe.Pointer(control + 1*8))*u3)+float64(float64(3)*(float64(float64(*(*float64)(unsafe.Pointer(control + 3*8))*t)*u2)+float64(float64(*(*float64)(unsafe.Pointer(control + 5*8))*t2)*u)))+float64(*(*float64)(unsafe.Pointer(control + 7*8))*t3), xPointPtr, xPointPtr+2) goto _1 _1: ; i++ xPointPtr += 4 } } /* *-------------------------------------------------------------- * * TkBezierPoints -- * * Given four control points, create a larger set of points for a Bezier * curve based on the points. * * Results: * The array at *coordPtr gets filled in with 2*numSteps coordinates, * which correspond to the Bezier spline defined by the four control * points. Note: no output point is generated for the first input point, * but an output point *is* generated for the last input point. * * Side effects: * None. * *-------------------------------------------------------------- */ func XTkBezierPoints(tls *libc.TLS, control uintptr, numSteps int32, coordPtr uintptr) { /* Where to put new points. */ var i int32 var t, t2, t3, u, u2, u3 float64 _, _, _, _, _, _, _ = i, t, t2, t3, u, u2, u3 i = int32(1) for { if !(i <= numSteps) { break } t = float64(i) / float64(numSteps) t2 = float64(t * t) t3 = float64(t2 * t) u = float64(1) - t u2 = float64(u * u) u3 = float64(u2 * u) *(*float64)(unsafe.Pointer(coordPtr)) = float64(*(*float64)(unsafe.Pointer(control))*u3) + float64(float64(3)*(float64(float64(*(*float64)(unsafe.Pointer(control + 2*8))*t)*u2)+float64(float64(*(*float64)(unsafe.Pointer(control + 4*8))*t2)*u))) + float64(*(*float64)(unsafe.Pointer(control + 6*8))*t3) *(*float64)(unsafe.Pointer(coordPtr + 1*8)) = float64(*(*float64)(unsafe.Pointer(control + 1*8))*u3) + float64(float64(3)*(float64(float64(*(*float64)(unsafe.Pointer(control + 3*8))*t)*u2)+float64(float64(*(*float64)(unsafe.Pointer(control + 5*8))*t2)*u))) + float64(*(*float64)(unsafe.Pointer(control + 7*8))*t3) goto _1 _1: ; i++ coordPtr += uintptr(2) * 8 } } /* *-------------------------------------------------------------- * * TkMakeBezierCurve -- * * Given a set of points, create a new set of points that fit parabolic * splines to the line segments connecting the original points. Produces * output points in either of two forms. * * Note: the name of this function should *not* be taken to mean that it * interprets the input points as directly defining Bezier curves. * Rather, it internally computes a Bezier curve representation of each * parabolic spline segment. (These Bezier curves are then flattened to * produce the points filled into the output arrays.) * * Results: * Either or both of the xPoints or dblPoints arrays are filled in. The * return value is the number of points placed in the arrays. Note: if * the first and last points are the same, then a closed curve is * generated. * * Side effects: * None. * *-------------------------------------------------------------- */ func XTkMakeBezierCurve(tls *libc.TLS, canvas TTk_Canvas, pointPtr uintptr, numPoints int32, numSteps int32, xPoints uintptr, dblPoints uintptr) (r int32) { bp := tls.Alloc(64) defer tls.Free(64) /* Array of points to fill in as doubles, in * the form x0, y0, x1, y1, .... NULL means * don't fill in anything in this form. Caller * must make sure that this array has enough * space. */ var closed, i, numCoords, outputPoints int32 var _ /* control at bp+0 */ [8]float64 _, _, _, _ = closed, i, numCoords, outputPoints numCoords = numPoints * int32(2) /* * If the curve is a closed one then generate a special spline that spans * the last points and the first ones. Otherwise just put the first point * into the output. */ if !(pointPtr != 0) { /* * Of pointPtr == NULL, this function returns an upper limit of the * array size to store the coordinates. This can be used to allocate * storage, before the actual coordinates are calculated. */ return int32(1) + numPoints*numSteps } outputPoints = 0 if *(*float64)(unsafe.Pointer(pointPtr)) == *(*float64)(unsafe.Pointer(pointPtr + uintptr(numCoords-int32(2))*8)) && *(*float64)(unsafe.Pointer(pointPtr + 1*8)) == *(*float64)(unsafe.Pointer(pointPtr + uintptr(numCoords-int32(1))*8)) { closed = int32(1) (*(*[8]float64)(unsafe.Pointer(bp)))[0] = float64(float64(0.5)**(*float64)(unsafe.Pointer(pointPtr + uintptr(numCoords-int32(4))*8))) + float64(float64(0.5)**(*float64)(unsafe.Pointer(pointPtr))) (*(*[8]float64)(unsafe.Pointer(bp)))[int32(1)] = float64(float64(0.5)**(*float64)(unsafe.Pointer(pointPtr + uintptr(numCoords-int32(3))*8))) + float64(float64(0.5)**(*float64)(unsafe.Pointer(pointPtr + 1*8))) (*(*[8]float64)(unsafe.Pointer(bp)))[int32(2)] = float64(float64(0.167)**(*float64)(unsafe.Pointer(pointPtr + uintptr(numCoords-int32(4))*8))) + float64(float64(0.833)**(*float64)(unsafe.Pointer(pointPtr))) (*(*[8]float64)(unsafe.Pointer(bp)))[int32(3)] = float64(float64(0.167)**(*float64)(unsafe.Pointer(pointPtr + uintptr(numCoords-int32(3))*8))) + float64(float64(0.833)**(*float64)(unsafe.Pointer(pointPtr + 1*8))) (*(*[8]float64)(unsafe.Pointer(bp)))[int32(4)] = float64(float64(0.833)**(*float64)(unsafe.Pointer(pointPtr))) + float64(float64(0.167)**(*float64)(unsafe.Pointer(pointPtr + 2*8))) (*(*[8]float64)(unsafe.Pointer(bp)))[int32(5)] = float64(float64(0.833)**(*float64)(unsafe.Pointer(pointPtr + 1*8))) + float64(float64(0.167)**(*float64)(unsafe.Pointer(pointPtr + 3*8))) (*(*[8]float64)(unsafe.Pointer(bp)))[int32(6)] = float64(float64(0.5)**(*float64)(unsafe.Pointer(pointPtr))) + float64(float64(0.5)**(*float64)(unsafe.Pointer(pointPtr + 2*8))) (*(*[8]float64)(unsafe.Pointer(bp)))[int32(7)] = float64(float64(0.5)**(*float64)(unsafe.Pointer(pointPtr + 1*8))) + float64(float64(0.5)**(*float64)(unsafe.Pointer(pointPtr + 3*8))) if xPoints != libc.UintptrFromInt32(0) { XTk_CanvasDrawableCoords(tls, canvas, (*(*[8]float64)(unsafe.Pointer(bp)))[0], (*(*[8]float64)(unsafe.Pointer(bp)))[int32(1)], xPoints, xPoints+2) XTkBezierScreenPoints(tls, canvas, bp, numSteps, xPoints+uintptr(1)*4) xPoints += uintptr(numSteps+int32(1)) * 4 } if dblPoints != libc.UintptrFromInt32(0) { *(*float64)(unsafe.Pointer(dblPoints)) = (*(*[8]float64)(unsafe.Pointer(bp)))[0] *(*float64)(unsafe.Pointer(dblPoints + 1*8)) = (*(*[8]float64)(unsafe.Pointer(bp)))[int32(1)] XTkBezierPoints(tls, bp, numSteps, dblPoints+uintptr(2)*8) dblPoints += uintptr(int32(2)*(numSteps+int32(1))) * 8 } outputPoints += numSteps + int32(1) } else { closed = 0 if xPoints != libc.UintptrFromInt32(0) { XTk_CanvasDrawableCoords(tls, canvas, *(*float64)(unsafe.Pointer(pointPtr)), *(*float64)(unsafe.Pointer(pointPtr + 1*8)), xPoints, xPoints+2) xPoints += uintptr(1) * 4 } if dblPoints != libc.UintptrFromInt32(0) { *(*float64)(unsafe.Pointer(dblPoints)) = *(*float64)(unsafe.Pointer(pointPtr)) *(*float64)(unsafe.Pointer(dblPoints + 1*8)) = *(*float64)(unsafe.Pointer(pointPtr + 1*8)) dblPoints += uintptr(2) * 8 } outputPoints += int32(1) } i = int32(2) for { if !(i < numPoints) { break } /* * Set up the first two control points. This is done differently for * the first spline of an open curve than for other cases. */ if i == int32(2) && !(closed != 0) { (*(*[8]float64)(unsafe.Pointer(bp)))[0] = *(*float64)(unsafe.Pointer(pointPtr)) (*(*[8]float64)(unsafe.Pointer(bp)))[int32(1)] = *(*float64)(unsafe.Pointer(pointPtr + 1*8)) (*(*[8]float64)(unsafe.Pointer(bp)))[int32(2)] = float64(float64(0.333)**(*float64)(unsafe.Pointer(pointPtr))) + float64(float64(0.667)**(*float64)(unsafe.Pointer(pointPtr + 2*8))) (*(*[8]float64)(unsafe.Pointer(bp)))[int32(3)] = float64(float64(0.333)**(*float64)(unsafe.Pointer(pointPtr + 1*8))) + float64(float64(0.667)**(*float64)(unsafe.Pointer(pointPtr + 3*8))) } else { (*(*[8]float64)(unsafe.Pointer(bp)))[0] = float64(float64(0.5)**(*float64)(unsafe.Pointer(pointPtr))) + float64(float64(0.5)**(*float64)(unsafe.Pointer(pointPtr + 2*8))) (*(*[8]float64)(unsafe.Pointer(bp)))[int32(1)] = float64(float64(0.5)**(*float64)(unsafe.Pointer(pointPtr + 1*8))) + float64(float64(0.5)**(*float64)(unsafe.Pointer(pointPtr + 3*8))) (*(*[8]float64)(unsafe.Pointer(bp)))[int32(2)] = float64(float64(0.167)**(*float64)(unsafe.Pointer(pointPtr))) + float64(float64(0.833)**(*float64)(unsafe.Pointer(pointPtr + 2*8))) (*(*[8]float64)(unsafe.Pointer(bp)))[int32(3)] = float64(float64(0.167)**(*float64)(unsafe.Pointer(pointPtr + 1*8))) + float64(float64(0.833)**(*float64)(unsafe.Pointer(pointPtr + 3*8))) } /* * Set up the last two control points. This is done differently for * the last spline of an open curve than for other cases. */ if i == numPoints-int32(1) && !(closed != 0) { (*(*[8]float64)(unsafe.Pointer(bp)))[int32(4)] = float64(float64(0.667)**(*float64)(unsafe.Pointer(pointPtr + 2*8))) + float64(float64(0.333)**(*float64)(unsafe.Pointer(pointPtr + 4*8))) (*(*[8]float64)(unsafe.Pointer(bp)))[int32(5)] = float64(float64(0.667)**(*float64)(unsafe.Pointer(pointPtr + 3*8))) + float64(float64(0.333)**(*float64)(unsafe.Pointer(pointPtr + 5*8))) (*(*[8]float64)(unsafe.Pointer(bp)))[int32(6)] = *(*float64)(unsafe.Pointer(pointPtr + 4*8)) (*(*[8]float64)(unsafe.Pointer(bp)))[int32(7)] = *(*float64)(unsafe.Pointer(pointPtr + 5*8)) } else { (*(*[8]float64)(unsafe.Pointer(bp)))[int32(4)] = float64(float64(0.833)**(*float64)(unsafe.Pointer(pointPtr + 2*8))) + float64(float64(0.167)**(*float64)(unsafe.Pointer(pointPtr + 4*8))) (*(*[8]float64)(unsafe.Pointer(bp)))[int32(5)] = float64(float64(0.833)**(*float64)(unsafe.Pointer(pointPtr + 3*8))) + float64(float64(0.167)**(*float64)(unsafe.Pointer(pointPtr + 5*8))) (*(*[8]float64)(unsafe.Pointer(bp)))[int32(6)] = float64(float64(0.5)**(*float64)(unsafe.Pointer(pointPtr + 2*8))) + float64(float64(0.5)**(*float64)(unsafe.Pointer(pointPtr + 4*8))) (*(*[8]float64)(unsafe.Pointer(bp)))[int32(7)] = float64(float64(0.5)**(*float64)(unsafe.Pointer(pointPtr + 3*8))) + float64(float64(0.5)**(*float64)(unsafe.Pointer(pointPtr + 5*8))) } /* * If the first two points coincide, or if the last two points * coincide, then generate a single straight-line segment by * outputting the last control point. */ if *(*float64)(unsafe.Pointer(pointPtr)) == *(*float64)(unsafe.Pointer(pointPtr + 2*8)) && *(*float64)(unsafe.Pointer(pointPtr + 1*8)) == *(*float64)(unsafe.Pointer(pointPtr + 3*8)) || *(*float64)(unsafe.Pointer(pointPtr + 2*8)) == *(*float64)(unsafe.Pointer(pointPtr + 4*8)) && *(*float64)(unsafe.Pointer(pointPtr + 3*8)) == *(*float64)(unsafe.Pointer(pointPtr + 5*8)) { if xPoints != libc.UintptrFromInt32(0) { XTk_CanvasDrawableCoords(tls, canvas, (*(*[8]float64)(unsafe.Pointer(bp)))[int32(6)], (*(*[8]float64)(unsafe.Pointer(bp)))[int32(7)], xPoints, xPoints+2) xPoints += 4 } if dblPoints != libc.UintptrFromInt32(0) { *(*float64)(unsafe.Pointer(dblPoints)) = (*(*[8]float64)(unsafe.Pointer(bp)))[int32(6)] *(*float64)(unsafe.Pointer(dblPoints + 1*8)) = (*(*[8]float64)(unsafe.Pointer(bp)))[int32(7)] dblPoints += uintptr(2) * 8 } outputPoints += int32(1) goto _1 } /* * Generate a Bezier spline using the control points. */ if xPoints != libc.UintptrFromInt32(0) { XTkBezierScreenPoints(tls, canvas, bp, numSteps, xPoints) xPoints += uintptr(numSteps) * 4 } if dblPoints != libc.UintptrFromInt32(0) { XTkBezierPoints(tls, bp, numSteps, dblPoints) dblPoints += uintptr(int32(2)*numSteps) * 8 } outputPoints += numSteps goto _1 _1: ; i++ pointPtr += uintptr(2) * 8 } return outputPoints } /* *-------------------------------------------------------------- * * TkMakeRawCurve -- * * Interpret the given set of points as the raw knots and control points * defining a sequence of cubic Bezier curves. Create a new set of points * that fit these Bezier curves. Output points are produced in either of * two forms. * * Results: * Either or both of the xPoints or dblPoints arrays are filled in. The * return value is the number of points placed in the arrays. * * Side effects: * None. * *-------------------------------------------------------------- */ func XTkMakeRawCurve(tls *libc.TLS, canvas TTk_Canvas, pointPtr uintptr, numPoints int32, numSteps int32, xPoints uintptr, dblPoints uintptr) (r int32) { bp := tls.Alloc(64) defer tls.Free(64) /* Array of points to fill in as doubles, in * the form x0, y0, x1, y1, .... NULL means * don't fill in anything in this form. * Caller must make sure that this array has * enough space. */ var i, j, numSegments, outputPoints int32 var segPtr uintptr var _ /* control at bp+0 */ [8]float64 _, _, _, _, _ = i, j, numSegments, outputPoints, segPtr numSegments = (numPoints + int32(1)) / int32(3) /* * The input describes a curve with s Bezier curve segments if there are * 3s+1, 3s, or 3s-1 input points. In the last two cases, 1 or 2 initial * points from the first curve segment are reused as defining points also * for the last curve segment. In the case of 3s input points, this will * automatically close the curve. */ if !(pointPtr != 0) { /* * If pointPtr == NULL, this function returns an upper limit of the * array size to store the coordinates. This can be used to allocate * storage, before the actual coordinates are calculated. */ return int32(1) + numSegments*numSteps } outputPoints = 0 if xPoints != libc.UintptrFromInt32(0) { XTk_CanvasDrawableCoords(tls, canvas, *(*float64)(unsafe.Pointer(pointPtr)), *(*float64)(unsafe.Pointer(pointPtr + 1*8)), xPoints, xPoints+2) xPoints += uintptr(1) * 4 } if dblPoints != libc.UintptrFromInt32(0) { *(*float64)(unsafe.Pointer(dblPoints)) = *(*float64)(unsafe.Pointer(pointPtr)) *(*float64)(unsafe.Pointer(dblPoints + 1*8)) = *(*float64)(unsafe.Pointer(pointPtr + 1*8)) dblPoints += uintptr(2) * 8 } outputPoints += int32(1) /* * The next loop handles all curve segments except one that overlaps the * end of the list of coordinates. */ i = numPoints segPtr = pointPtr for { if !(i >= int32(4)) { break } if *(*float64)(unsafe.Pointer(segPtr)) == *(*float64)(unsafe.Pointer(segPtr + 2*8)) && *(*float64)(unsafe.Pointer(segPtr + 1*8)) == *(*float64)(unsafe.Pointer(segPtr + 3*8)) && *(*float64)(unsafe.Pointer(segPtr + 4*8)) == *(*float64)(unsafe.Pointer(segPtr + 6*8)) && *(*float64)(unsafe.Pointer(segPtr + 5*8)) == *(*float64)(unsafe.Pointer(segPtr + 7*8)) { /* * The control points on this segment are equal to their * neighbouring knots, so this segment is just a straight line. A * single point is sufficient. */ if xPoints != libc.UintptrFromInt32(0) { XTk_CanvasDrawableCoords(tls, canvas, *(*float64)(unsafe.Pointer(segPtr + 6*8)), *(*float64)(unsafe.Pointer(segPtr + 7*8)), xPoints, xPoints+2) xPoints += uintptr(1) * 4 } if dblPoints != libc.UintptrFromInt32(0) { *(*float64)(unsafe.Pointer(dblPoints)) = *(*float64)(unsafe.Pointer(segPtr + 6*8)) *(*float64)(unsafe.Pointer(dblPoints + 1*8)) = *(*float64)(unsafe.Pointer(segPtr + 7*8)) dblPoints += uintptr(2) * 8 } outputPoints += int32(1) } else { /* * This is a generic Bezier curve segment. */ if xPoints != libc.UintptrFromInt32(0) { XTkBezierScreenPoints(tls, canvas, segPtr, numSteps, xPoints) xPoints += uintptr(numSteps) * 4 } if dblPoints != libc.UintptrFromInt32(0) { XTkBezierPoints(tls, segPtr, numSteps, dblPoints) dblPoints += uintptr(int32(2)*numSteps) * 8 } outputPoints += numSteps } goto _1 _1: ; i -= int32(3) segPtr += uintptr(6) * 8 } /* * If at this point i>1, then there is some point which has not yet been * used. Make another curve segment. */ if i > int32(1) { /* * Copy the relevant coordinates to control[], so that it can be * passed as a unit to e.g. TkBezierPoints. */ j = 0 for { if !(j < int32(2)*i) { break } (*(*[8]float64)(unsafe.Pointer(bp)))[j] = *(*float64)(unsafe.Pointer(segPtr + uintptr(j)*8)) goto _2 _2: ; j++ } for { if !(j < int32(8)) { break } (*(*[8]float64)(unsafe.Pointer(bp)))[j] = *(*float64)(unsafe.Pointer(pointPtr + uintptr(j-int32(2)*i)*8)) goto _3 _3: ; j++ } /* * Then we just do the same things as above. */ if (*(*[8]float64)(unsafe.Pointer(bp)))[0] == (*(*[8]float64)(unsafe.Pointer(bp)))[int32(2)] && (*(*[8]float64)(unsafe.Pointer(bp)))[int32(1)] == (*(*[8]float64)(unsafe.Pointer(bp)))[int32(3)] && (*(*[8]float64)(unsafe.Pointer(bp)))[int32(4)] == (*(*[8]float64)(unsafe.Pointer(bp)))[int32(6)] && (*(*[8]float64)(unsafe.Pointer(bp)))[int32(5)] == (*(*[8]float64)(unsafe.Pointer(bp)))[int32(7)] { /* * The control points on this segment are equal to their * neighbouring knots, so this segment is just a straight line. A * single point is sufficient. */ if xPoints != libc.UintptrFromInt32(0) { XTk_CanvasDrawableCoords(tls, canvas, (*(*[8]float64)(unsafe.Pointer(bp)))[int32(6)], (*(*[8]float64)(unsafe.Pointer(bp)))[int32(7)], xPoints, xPoints+2) xPoints += uintptr(1) * 4 } if dblPoints != libc.UintptrFromInt32(0) { *(*float64)(unsafe.Pointer(dblPoints)) = (*(*[8]float64)(unsafe.Pointer(bp)))[int32(6)] *(*float64)(unsafe.Pointer(dblPoints + 1*8)) = (*(*[8]float64)(unsafe.Pointer(bp)))[int32(7)] dblPoints += uintptr(2) * 8 } outputPoints += int32(1) } else { /* * This is a generic Bezier curve segment. */ if xPoints != libc.UintptrFromInt32(0) { XTkBezierScreenPoints(tls, canvas, bp, numSteps, xPoints) xPoints += uintptr(numSteps) * 4 } if dblPoints != libc.UintptrFromInt32(0) { XTkBezierPoints(tls, bp, numSteps, dblPoints) dblPoints += uintptr(int32(2)*numSteps) * 8 } outputPoints += numSteps } } return outputPoints } /* *-------------------------------------------------------------- * * TkMakeBezierPostscript -- * * This function generates Postscript commands that create a path * corresponding to a given Bezier curve. * * Results: * None. Postscript commands to generate the path are appended to the * interp's result. * * Side effects: * None. * *-------------------------------------------------------------- */ func XTkMakeBezierPostscript(tls *libc.TLS, interp uintptr, canvas TTk_Canvas, pointPtr uintptr, numPoints int32) { bp := tls.Alloc(80) defer tls.Free(80) /* Number of points at pointPtr. */ var _objPtr, psObj, v3 uintptr var closed, i, numCoords int32 var control [8]float64 var v2 TTcl_Size _, _, _, _, _, _, _, _ = _objPtr, closed, control, i, numCoords, psObj, v2, v3 numCoords = numPoints * int32(2) /* * If the curve is a closed one then generate a special spline that spans * the last points and the first ones. Otherwise just put the first point * into the path. */ if *(*float64)(unsafe.Pointer(pointPtr)) == *(*float64)(unsafe.Pointer(pointPtr + uintptr(numCoords-int32(2))*8)) && *(*float64)(unsafe.Pointer(pointPtr + 1*8)) == *(*float64)(unsafe.Pointer(pointPtr + uintptr(numCoords-int32(1))*8)) { closed = int32(1) control[0] = float64(float64(0.5)**(*float64)(unsafe.Pointer(pointPtr + uintptr(numCoords-int32(4))*8))) + float64(float64(0.5)**(*float64)(unsafe.Pointer(pointPtr))) control[int32(1)] = float64(float64(0.5)**(*float64)(unsafe.Pointer(pointPtr + uintptr(numCoords-int32(3))*8))) + float64(float64(0.5)**(*float64)(unsafe.Pointer(pointPtr + 1*8))) control[int32(2)] = float64(float64(0.167)**(*float64)(unsafe.Pointer(pointPtr + uintptr(numCoords-int32(4))*8))) + float64(float64(0.833)**(*float64)(unsafe.Pointer(pointPtr))) control[int32(3)] = float64(float64(0.167)**(*float64)(unsafe.Pointer(pointPtr + uintptr(numCoords-int32(3))*8))) + float64(float64(0.833)**(*float64)(unsafe.Pointer(pointPtr + 1*8))) control[int32(4)] = float64(float64(0.833)**(*float64)(unsafe.Pointer(pointPtr))) + float64(float64(0.167)**(*float64)(unsafe.Pointer(pointPtr + 2*8))) control[int32(5)] = float64(float64(0.833)**(*float64)(unsafe.Pointer(pointPtr + 1*8))) + float64(float64(0.167)**(*float64)(unsafe.Pointer(pointPtr + 3*8))) control[int32(6)] = float64(float64(0.5)**(*float64)(unsafe.Pointer(pointPtr))) + float64(float64(0.5)**(*float64)(unsafe.Pointer(pointPtr + 2*8))) control[int32(7)] = float64(float64(0.5)**(*float64)(unsafe.Pointer(pointPtr + 1*8))) + float64(float64(0.5)**(*float64)(unsafe.Pointer(pointPtr + 3*8))) psObj = libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+32883, libc.VaList(bp+8, control[0], XTk_CanvasPsY(tls, canvas, control[int32(1)]), control[int32(2)], XTk_CanvasPsY(tls, canvas, control[int32(3)]), control[int32(4)], XTk_CanvasPsY(tls, canvas, control[int32(5)]), control[int32(6)], XTk_CanvasPsY(tls, canvas, control[int32(7)]))) } else { closed = 0 control[int32(6)] = *(*float64)(unsafe.Pointer(pointPtr)) control[int32(7)] = *(*float64)(unsafe.Pointer(pointPtr + 1*8)) psObj = libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+31580, libc.VaList(bp+8, control[int32(6)], XTk_CanvasPsY(tls, canvas, control[int32(7)]))) } /* * Cycle through all the remaining points in the curve, generating a curve * section for each vertex in the linear path. */ i = numPoints - int32(2) pointPtr += uintptr(2) * 8 for { if !(i > 0) { break } control[int32(2)] = float64(float64(0.333)*control[int32(6)]) + float64(float64(0.667)**(*float64)(unsafe.Pointer(pointPtr))) control[int32(3)] = float64(float64(0.333)*control[int32(7)]) + float64(float64(0.667)**(*float64)(unsafe.Pointer(pointPtr + 1*8))) /* * Set up the last two control points. This is done differently for * the last spline of an open curve than for other cases. */ if i == int32(1) && !(closed != 0) { control[int32(6)] = *(*float64)(unsafe.Pointer(pointPtr + 2*8)) control[int32(7)] = *(*float64)(unsafe.Pointer(pointPtr + 3*8)) } else { control[int32(6)] = float64(float64(0.5)**(*float64)(unsafe.Pointer(pointPtr))) + float64(float64(0.5)**(*float64)(unsafe.Pointer(pointPtr + 2*8))) control[int32(7)] = float64(float64(0.5)**(*float64)(unsafe.Pointer(pointPtr + 1*8))) + float64(float64(0.5)**(*float64)(unsafe.Pointer(pointPtr + 3*8))) } control[int32(4)] = float64(float64(0.333)*control[int32(6)]) + float64(float64(0.667)**(*float64)(unsafe.Pointer(pointPtr))) control[int32(5)] = float64(float64(0.333)*control[int32(7)]) + float64(float64(0.667)**(*float64)(unsafe.Pointer(pointPtr + 1*8))) libtcl9_0.XTcl_AppendPrintfToObj(tls, psObj, __ccgo_ts+32947, libc.VaList(bp+8, control[int32(2)], XTk_CanvasPsY(tls, canvas, control[int32(3)]), control[int32(4)], XTk_CanvasPsY(tls, canvas, control[int32(5)]), control[int32(6)], XTk_CanvasPsY(tls, canvas, control[int32(7)]))) goto _1 _1: ; i-- pointPtr += uintptr(2) * 8 } libtcl9_0.XTcl_AppendObjToObj(tls, libtcl9_0.XTcl_GetObjResult(tls, interp), psObj) _objPtr = psObj v3 = _objPtr v2 = *(*TTcl_Size)(unsafe.Pointer(v3)) *(*TTcl_Size)(unsafe.Pointer(v3))-- if v2 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr) } } /* *-------------------------------------------------------------- * * TkMakeRawCurvePostscript -- * * This function interprets the input points as the raw knot and control * points for a curve composed of Bezier curve segments, just like * TkMakeRawCurve. It generates Postscript commands that create a path * corresponding to this given curve. * * Results: * None. Postscript commands to generate the path are appended to the * interp's result. * * Side effects: * None. * *-------------------------------------------------------------- */ func XTkMakeRawCurvePostscript(tls *libc.TLS, interp uintptr, canvas TTk_Canvas, pointPtr uintptr, numPoints int32) { bp := tls.Alloc(64) defer tls.Free(64) /* Number of points at pointPtr. */ var _objPtr, psObj, segPtr, v5 uintptr var control [8]float64 var i, j int32 var v4 TTcl_Size _, _, _, _, _, _, _, _ = _objPtr, control, i, j, psObj, segPtr, v4, v5 /* * Put the first point into the path. */ psObj = libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+31580, libc.VaList(bp+8, *(*float64)(unsafe.Pointer(pointPtr)), XTk_CanvasPsY(tls, canvas, *(*float64)(unsafe.Pointer(pointPtr + 1*8))))) /* * Loop through all the remaining points in the curve, generating a * straight line or curve section for every three of them. */ i = numPoints - int32(1) segPtr = pointPtr for { if !(i >= int32(3)) { break } if *(*float64)(unsafe.Pointer(segPtr)) == *(*float64)(unsafe.Pointer(segPtr + 2*8)) && *(*float64)(unsafe.Pointer(segPtr + 1*8)) == *(*float64)(unsafe.Pointer(segPtr + 3*8)) && *(*float64)(unsafe.Pointer(segPtr + 4*8)) == *(*float64)(unsafe.Pointer(segPtr + 6*8)) && *(*float64)(unsafe.Pointer(segPtr + 5*8)) == *(*float64)(unsafe.Pointer(segPtr + 7*8)) { /* * The control points on this segment are equal to their * neighbouring knots, so this segment is just a straight line. */ libtcl9_0.XTcl_AppendPrintfToObj(tls, psObj, __ccgo_ts+31600, libc.VaList(bp+8, *(*float64)(unsafe.Pointer(segPtr + 6*8)), XTk_CanvasPsY(tls, canvas, *(*float64)(unsafe.Pointer(segPtr + 7*8))))) } else { /* * This is a generic Bezier curve segment. */ libtcl9_0.XTcl_AppendPrintfToObj(tls, psObj, __ccgo_ts+32947, libc.VaList(bp+8, *(*float64)(unsafe.Pointer(segPtr + 2*8)), XTk_CanvasPsY(tls, canvas, *(*float64)(unsafe.Pointer(segPtr + 3*8))), *(*float64)(unsafe.Pointer(segPtr + 4*8)), XTk_CanvasPsY(tls, canvas, *(*float64)(unsafe.Pointer(segPtr + 5*8))), *(*float64)(unsafe.Pointer(segPtr + 6*8)), XTk_CanvasPsY(tls, canvas, *(*float64)(unsafe.Pointer(segPtr + 7*8))))) } goto _1 _1: ; i -= int32(3) segPtr += uintptr(6) * 8 } /* * If there are any points left that haven't been used, then build the * last segment and generate Postscript in the same way for that. */ if i > 0 { j = 0 for { if !(j < int32(2)*i+int32(2)) { break } control[j] = *(*float64)(unsafe.Pointer(segPtr + uintptr(j)*8)) goto _2 _2: ; j++ } for { if !(j < int32(8)) { break } control[j] = *(*float64)(unsafe.Pointer(pointPtr + uintptr(j-int32(2)*i-int32(2))*8)) goto _3 _3: ; j++ } if control[0] == control[int32(2)] && control[int32(1)] == control[int32(3)] && control[int32(4)] == control[int32(6)] && control[int32(5)] == control[int32(7)] { /* * Straight line. */ libtcl9_0.XTcl_AppendPrintfToObj(tls, psObj, __ccgo_ts+31600, libc.VaList(bp+8, control[int32(6)], XTk_CanvasPsY(tls, canvas, control[int32(7)]))) } else { /* * Bezier curve segment. */ libtcl9_0.XTcl_AppendPrintfToObj(tls, psObj, __ccgo_ts+32947, libc.VaList(bp+8, control[int32(2)], XTk_CanvasPsY(tls, canvas, control[int32(3)]), control[int32(4)], XTk_CanvasPsY(tls, canvas, control[int32(5)]), control[int32(6)], XTk_CanvasPsY(tls, canvas, control[int32(7)]))) } } libtcl9_0.XTcl_AppendObjToObj(tls, libtcl9_0.XTcl_GetObjResult(tls, interp), psObj) _objPtr = psObj v5 = _objPtr v4 = *(*TTcl_Size)(unsafe.Pointer(v5)) *(*TTcl_Size)(unsafe.Pointer(v5))-- if v4 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr) } } /* *-------------------------------------------------------------- * * TkGetMiterPoints -- * * Given three points forming an angle, compute the coordinates of the * inside and outside points of the mitered corner formed by a line of a * given width at that angle. * * Results: * If the angle formed by the three points is less than 11 degrees then 0 * is returned and m1 and m2 aren't modified. Otherwise 1 is returned and * the points at m1 and m2 are filled in with the positions of the points * of the mitered corner. * * Side effects: * None. * *-------------------------------------------------------------- */ func XTkGetMiterPoints(tls *libc.TLS, p1 uintptr, p2 uintptr, p3 uintptr, width float64, m1 uintptr, m2 uintptr) (r int32) { /* Points to place to put "right" vertex * point. */ var deltaX, deltaY, dist, p1x, p1y, p2x, p2y, p3x, p3y, theta, theta1, theta2, theta3, v1, v2, v3, v4 float64 _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = deltaX, deltaY, dist, p1x, p1y, p2x, p2y, p3x, p3y, theta, theta1, theta2, theta3, v1, v2, v3, v4 /* * Round the coordinates to integers to mimic what happens when the line * segments are displayed; without this code, the bounding box of a * mitered line can be miscomputed greatly. */ p1x = libc.Xfloor(tls, *(*float64)(unsafe.Pointer(p1))+float64(0.5)) p1y = libc.Xfloor(tls, *(*float64)(unsafe.Pointer(p1 + 1*8))+float64(0.5)) p2x = libc.Xfloor(tls, *(*float64)(unsafe.Pointer(p2))+float64(0.5)) p2y = libc.Xfloor(tls, *(*float64)(unsafe.Pointer(p2 + 1*8))+float64(0.5)) p3x = libc.Xfloor(tls, *(*float64)(unsafe.Pointer(p3))+float64(0.5)) p3y = libc.Xfloor(tls, *(*float64)(unsafe.Pointer(p3 + 1*8))+float64(0.5)) if p2y == p1y { if p2x < p1x { v1 = libc.Float64FromInt32(0) } else { v1 = float64(3.141592653589793) } theta1 = v1 } else { if p2x == p1x { if p2y < p1y { v2 = libc.Float64FromFloat64(3.141592653589793) / libc.Float64FromFloat64(2) } else { v2 = -libc.Float64FromFloat64(3.141592653589793) / float64(2) } theta1 = v2 } else { theta1 = libc.Xatan2(tls, p1y-p2y, p1x-p2x) } } if p3y == p2y { if p3x > p2x { v3 = libc.Float64FromInt32(0) } else { v3 = float64(3.141592653589793) } theta2 = v3 } else { if p3x == p2x { if p3y > p2y { v4 = libc.Float64FromFloat64(3.141592653589793) / libc.Float64FromFloat64(2) } else { v4 = -libc.Float64FromFloat64(3.141592653589793) / float64(2) } theta2 = v4 } else { theta2 = libc.Xatan2(tls, p3y-p2y, p3x-p2x) } } theta = theta1 - theta2 if theta > float64(3.141592653589793) { theta -= float64(libc.Float64FromInt32(2) * libc.Float64FromFloat64(3.141592653589793)) } else { if theta < -libc.Float64FromFloat64(3.141592653589793) { theta += float64(libc.Float64FromInt32(2) * libc.Float64FromFloat64(3.141592653589793)) } } if theta < _elevenDegrees && theta > -_elevenDegrees { return 0 } dist = float64(float64(0.5)*width) / libc.Xsin(tls, float64(float64(0.5)*theta)) if dist < float64(0) { dist = -dist } /* * Compute theta3 (make sure that it points to the left when looking from * p1 to p2). */ theta3 = (theta1 + theta2) / float64(2) if libc.Xsin(tls, theta3-(theta1+float64(3.141592653589793))) < float64(0) { theta3 += float64(3.141592653589793) } deltaX = float64(dist * libc.Xcos(tls, theta3)) *(*float64)(unsafe.Pointer(m1)) = p2x + deltaX *(*float64)(unsafe.Pointer(m2)) = p2x - deltaX deltaY = float64(dist * libc.Xsin(tls, theta3)) *(*float64)(unsafe.Pointer(m1 + 1*8)) = p2y + deltaY *(*float64)(unsafe.Pointer(m2 + 1*8)) = p2y - deltaY return int32(1) } var _elevenDegrees = float64(float64(libc.Float64FromFloat64(11)*libc.Float64FromFloat64(2))*float64(3.141592653589793)) / float64(360) /* *-------------------------------------------------------------- * * TkGetButtPoints -- * * Given two points forming a line segment, compute the coordinates of * two endpoints of a rectangle formed by bloating the line segment until * it is width units wide. * * Results: * There is no return value. M1 and m2 are filled in to correspond to m1 * and m2 in the diagram below: * * ----------------* m1 * | * p1 *---------------* p2 * | * ----------------* m2 * * M1 and m2 will be W units apart, with p2 centered between them and * m1-m2 perpendicular to p1-p2. However, if "project" is true then m1 * and m2 will be as follows: * * -------------------* m1 * p2 | * p1 *---------------* | * | * -------------------* m2 * * In this case p2 will be width/2 units from the segment m1-m2. * * Side effects: * None. * *-------------------------------------------------------------- */ func XTkGetButtPoints(tls *libc.TLS, p1 uintptr, p2 uintptr, width float64, project int32, m1 uintptr, m2 uintptr) { /* Points to place to put "right" result * point. */ var deltaX, deltaY, length, v1, v2 float64 _, _, _, _, _ = deltaX, deltaY, length, v1, v2 /* Increments in coords. */ width *= float64(0.5) length = libc.X__builtin_hypot(tls, *(*float64)(unsafe.Pointer(p2))-*(*float64)(unsafe.Pointer(p1)), *(*float64)(unsafe.Pointer(p2 + 1*8))-*(*float64)(unsafe.Pointer(p1 + 1*8))) if length == float64(0) { v1 = *(*float64)(unsafe.Pointer(p2)) *(*float64)(unsafe.Pointer(m2)) = v1 *(*float64)(unsafe.Pointer(m1)) = v1 v2 = *(*float64)(unsafe.Pointer(p2 + 1*8)) *(*float64)(unsafe.Pointer(m2 + 1*8)) = v2 *(*float64)(unsafe.Pointer(m1 + 1*8)) = v2 } else { deltaX = float64(-width*(*(*float64)(unsafe.Pointer(p2 + 1*8))-*(*float64)(unsafe.Pointer(p1 + 1*8)))) / length deltaY = float64(width*(*(*float64)(unsafe.Pointer(p2))-*(*float64)(unsafe.Pointer(p1)))) / length *(*float64)(unsafe.Pointer(m1)) = *(*float64)(unsafe.Pointer(p2)) + deltaX *(*float64)(unsafe.Pointer(m2)) = *(*float64)(unsafe.Pointer(p2)) - deltaX *(*float64)(unsafe.Pointer(m1 + 1*8)) = *(*float64)(unsafe.Pointer(p2 + 1*8)) + deltaY *(*float64)(unsafe.Pointer(m2 + 1*8)) = *(*float64)(unsafe.Pointer(p2 + 1*8)) - deltaY if project != 0 { *(*float64)(unsafe.Pointer(m1)) += deltaY *(*float64)(unsafe.Pointer(m2)) += deltaY *(*float64)(unsafe.Pointer(m1 + 1*8)) -= deltaX *(*float64)(unsafe.Pointer(m2 + 1*8)) -= deltaX } } } const M_PI8 = 0 /* * Local Variables: * mode: c * c-basic-offset: 4 * fill-column: 78 * End: */ /* * Each call to Tk_GetImage returns a pointer to one of the following * structures, which is used as a token by clients (widgets) that display * images. */ type TImage = struct { Ftkwin TTk_Window Fdisplay uintptr FmodelPtr uintptr FinstanceData uintptr FchangeProc uintptr FwidgetClientData uintptr FnextPtr uintptr FprevPtr uintptr } /* * For each image model there is one of the following structures, which * represents a name in the image table and all of the images instantiated * from it. Entries in mainPtr->imageTable point to these structures. */ type TImageModel = struct { FtypePtr uintptr FmodelData uintptr Fwidth int32 Fheight int32 FtablePtr uintptr FhPtr uintptr FinstancePtr uintptr Fdeleted int32 FwinPtr uintptr } type TThreadSpecificData12 = struct { FimageTypeList uintptr FoldImageTypeList uintptr Finitialized int32 } var _dataKey13 TTcl_ThreadDataKey /* *---------------------------------------------------------------------- * * ImageTypeThreadExitProc -- * * Clean up the registered list of image types. * * Results: * None. * * Side effects: * The thread's linked lists of photo image formats is deleted. * *---------------------------------------------------------------------- */ func _ImageTypeThreadExitProc(tls *libc.TLS, dummy113 uintptr) { var freePtr, tsdPtr uintptr _, _ = freePtr, tsdPtr tsdPtr = libtcl9_0.XTcl_GetThreadData(tls, uintptr(unsafe.Pointer(&_dataKey13)), int64(24)) for (*TThreadSpecificData12)(unsafe.Pointer(tsdPtr)).FoldImageTypeList != libc.UintptrFromInt32(0) { freePtr = (*TThreadSpecificData12)(unsafe.Pointer(tsdPtr)).FoldImageTypeList (*TThreadSpecificData12)(unsafe.Pointer(tsdPtr)).FoldImageTypeList = (*TTk_ImageType)(unsafe.Pointer((*TThreadSpecificData12)(unsafe.Pointer(tsdPtr)).FoldImageTypeList)).FnextPtr libtcl9_0.XTcl_Free(tls, freePtr) } for (*TThreadSpecificData12)(unsafe.Pointer(tsdPtr)).FimageTypeList != libc.UintptrFromInt32(0) { freePtr = (*TThreadSpecificData12)(unsafe.Pointer(tsdPtr)).FimageTypeList (*TThreadSpecificData12)(unsafe.Pointer(tsdPtr)).FimageTypeList = (*TTk_ImageType)(unsafe.Pointer((*TThreadSpecificData12)(unsafe.Pointer(tsdPtr)).FimageTypeList)).FnextPtr libtcl9_0.XTcl_Free(tls, freePtr) } } /* *---------------------------------------------------------------------- * * Tk_CreateImageType -- * * This function is invoked by an image manager to tell Tk about a new * kind of image and the functions that manage the new type. The function * is typically invoked during Tcl_AppInit. * * Results: * None. * * Side effects: * The new image type is entered into a table used in the "image create" * command. * *---------------------------------------------------------------------- */ func XTk_CreateImageType(tls *libc.TLS, typePtr uintptr) { /* Structure describing the type. All of the * fields except "nextPtr" must be filled in * by caller. */ var copyPtr, tsdPtr uintptr _, _ = copyPtr, tsdPtr tsdPtr = libtcl9_0.XTcl_GetThreadData(tls, uintptr(unsafe.Pointer(&_dataKey13)), int64(24)) if !((*TThreadSpecificData12)(unsafe.Pointer(tsdPtr)).Finitialized != 0) { (*TThreadSpecificData12)(unsafe.Pointer(tsdPtr)).Finitialized = int32(1) libtcl9_0.XTcl_CreateThreadExitHandler(tls, __ccgo_fp(_ImageTypeThreadExitProc), libc.UintptrFromInt32(0)) } copyPtr = libtcl9_0.XTcl_Alloc(tls, uint64(72)) *(*TTk_ImageType)(unsafe.Pointer(copyPtr)) = *(*TTk_ImageType)(unsafe.Pointer(typePtr)) (*TTk_ImageType)(unsafe.Pointer(copyPtr)).FnextPtr = (*TThreadSpecificData12)(unsafe.Pointer(tsdPtr)).FimageTypeList (*TThreadSpecificData12)(unsafe.Pointer(tsdPtr)).FimageTypeList = copyPtr } /* *---------------------------------------------------------------------- * * Tk_ImageObjCmd -- * * This function is invoked to process the "image" Tcl command. See the * user documentation for details on what it does. * * Results: * A standard Tcl result. * * Side effects: * See the user documentation. * *---------------------------------------------------------------------- */ func XTk_ImageObjCmd(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) (r int32) { bp := tls.Alloc(128) defer tls.Free(128) /* Argument strings. */ var arg, args, dispPtr, hPtr, imagePtr, modelPtr, name, resultObj, topWin, tsdPtr, typePtr, winPtr, v12, v18, v23 uintptr var firstOption, i, oldimage, v14 int32 var v13 bool var _ /* idString at bp+32 */ [40]uint8 var _ /* index at bp+4 */ int32 var _ /* isNew at bp+0 */ int32 var _ /* search at bp+8 */ TTcl_HashSearch _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = arg, args, dispPtr, firstOption, hPtr, i, imagePtr, modelPtr, name, oldimage, resultObj, topWin, tsdPtr, typePtr, winPtr, v12, v13, v14, v18, v23 winPtr = clientData dispPtr = (*TTkWindow)(unsafe.Pointer(winPtr)).FdispPtr tsdPtr = libtcl9_0.XTcl_GetThreadData(tls, uintptr(unsafe.Pointer(&_dataKey13)), int64(24)) if objc < int32(2) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(1), objv, __ccgo_ts+33004) return int32(TCL_ERROR) } if libtcl9_0.XTcl_GetIndexFromObjStruct(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 1*8)), uintptr(unsafe.Pointer(&_imageOptions)), libc.Int64FromUint64(libc.Uint64FromInt64(8)), __ccgo_ts+2689, libc.Int32FromInt32(0)|libc.Int32FromUint64(libc.Uint64FromInt64(4)< (*TImageModel1)(unsafe.Pointer((*TImage)(unsafe.Pointer(imagePtr)).FmodelPtr)).Fwidth { width = (*TImageModel1)(unsafe.Pointer((*TImage)(unsafe.Pointer(imagePtr)).FmodelPtr)).Fwidth - imageX } if imageY+height > (*TImageModel1)(unsafe.Pointer((*TImage)(unsafe.Pointer(imagePtr)).FmodelPtr)).Fheight { height = (*TImageModel1)(unsafe.Pointer((*TImage)(unsafe.Pointer(imagePtr)).FmodelPtr)).Fheight - imageY } (*(*func(*libc.TLS, uintptr, uintptr, TDrawable, int32, int32, int32, int32, int32, int32))(unsafe.Pointer(&struct{ uintptr }{(*TTk_ImageType)(unsafe.Pointer((*TImageModel1)(unsafe.Pointer((*TImage)(unsafe.Pointer(imagePtr)).FmodelPtr)).FtypePtr)).FdisplayProc})))(tls, (*TImage)(unsafe.Pointer(imagePtr)).FinstanceData, (*TImage)(unsafe.Pointer(imagePtr)).Fdisplay, drawable, imageX, imageY, width, height, drawableX, drawableY) } /* *---------------------------------------------------------------------- * * Tk_SizeOfImage -- * * This function returns the current dimensions of an image. * * Results: * The width and height of the image are returned in *widthPtr and * *heightPtr. * * Side effects: * None. * *---------------------------------------------------------------------- */ func XTk_SizeOfImage(tls *libc.TLS, image TTk_Image, widthPtr uintptr, heightPtr uintptr) { /* Return height of image here. */ var imagePtr uintptr _ = imagePtr imagePtr = image *(*int32)(unsafe.Pointer(widthPtr)) = (*TImageModel1)(unsafe.Pointer((*TImage)(unsafe.Pointer(imagePtr)).FmodelPtr)).Fwidth *(*int32)(unsafe.Pointer(heightPtr)) = (*TImageModel1)(unsafe.Pointer((*TImage)(unsafe.Pointer(imagePtr)).FmodelPtr)).Fheight } /* *---------------------------------------------------------------------- * * Tk_DeleteImage -- * * Given the name of an image, this function destroys the image. * * Results: * None. * * Side effects: * The image is destroyed; existing instances will display as blank * areas. If no such image exists then the function does nothing. * *---------------------------------------------------------------------- */ func XTk_DeleteImage(tls *libc.TLS, interp uintptr, name uintptr) { /* Name of image. */ var hPtr, winPtr uintptr _, _ = hPtr, winPtr winPtr = XTk_MainWindow(tls, interp) if winPtr == libc.UintptrFromInt32(0) { return } hPtr = (*(*func(*libc.TLS, uintptr, uintptr) uintptr)(unsafe.Pointer(&struct{ uintptr }{(*TTcl_HashTable)(unsafe.Pointer((*TTkWindow)(unsafe.Pointer(winPtr)).FmainPtr + 184)).FfindProc})))(tls, (*TTkWindow)(unsafe.Pointer(winPtr)).FmainPtr+184, name) if hPtr == libc.UintptrFromInt32(0) { return } _DeleteImage1(tls, (*TTcl_HashEntry)(unsafe.Pointer(hPtr)).FclientData) } /* *---------------------------------------------------------------------- * * DeleteImage -- * * This function is responsible for deleting an image. * * Results: * None. * * Side effects: * The connection is dropped between instances of this image and an image * model. Image instances will redisplay themselves as empty areas, but * existing instances will not be deleted. * *---------------------------------------------------------------------- */ func _DeleteImage1(tls *libc.TLS, blockPtr uintptr) { /* Pointer to main data structure for image. */ var imagePtr, modelPtr, typePtr uintptr _, _, _ = imagePtr, modelPtr, typePtr modelPtr = blockPtr typePtr = (*TImageModel)(unsafe.Pointer(modelPtr)).FtypePtr (*TImageModel)(unsafe.Pointer(modelPtr)).FtypePtr = libc.UintptrFromInt32(0) if typePtr != libc.UintptrFromInt32(0) { imagePtr = (*TImageModel)(unsafe.Pointer(modelPtr)).FinstancePtr for { if !(imagePtr != libc.UintptrFromInt32(0)) { break } (*(*func(*libc.TLS, uintptr, uintptr))(unsafe.Pointer(&struct{ uintptr }{(*TTk_ImageType)(unsafe.Pointer(typePtr)).FfreeProc})))(tls, (*TImage)(unsafe.Pointer(imagePtr)).FinstanceData, (*TImage)(unsafe.Pointer(imagePtr)).Fdisplay) (*(*func(*libc.TLS, uintptr, int32, int32, int32, int32, int32, int32))(unsafe.Pointer(&struct{ uintptr }{(*TImage)(unsafe.Pointer(imagePtr)).FchangeProc})))(tls, (*TImage)(unsafe.Pointer(imagePtr)).FwidgetClientData, 0, 0, (*TImageModel)(unsafe.Pointer(modelPtr)).Fwidth, (*TImageModel)(unsafe.Pointer(modelPtr)).Fheight, (*TImageModel)(unsafe.Pointer(modelPtr)).Fwidth, (*TImageModel)(unsafe.Pointer(modelPtr)).Fheight) goto _1 _1: ; imagePtr = (*TImage)(unsafe.Pointer(imagePtr)).FnextPtr } (*(*func(*libc.TLS, uintptr))(unsafe.Pointer(&struct{ uintptr }{(*TTk_ImageType)(unsafe.Pointer(typePtr)).FdeleteProc})))(tls, (*TImageModel)(unsafe.Pointer(modelPtr)).FmodelData) } if (*TImageModel)(unsafe.Pointer(modelPtr)).FinstancePtr == libc.UintptrFromInt32(0) { if (*TImageModel)(unsafe.Pointer(modelPtr)).FhPtr != libc.UintptrFromInt32(0) { libtcl9_0.XTcl_DeleteHashEntry(tls, (*TImageModel)(unsafe.Pointer(modelPtr)).FhPtr) } libtcl9_0.XTcl_Release(tls, (*TImageModel)(unsafe.Pointer(modelPtr)).FwinPtr) libtcl9_0.XTcl_Free(tls, modelPtr) } else { (*TImageModel)(unsafe.Pointer(modelPtr)).Fdeleted = int32(1) } } /* *---------------------------------------------------------------------- * * EventuallyDeleteImage -- * * Arrange for an image to be deleted when it is safe to do so. * * Results: * None. * * Side effects: * Image will get freed, though not until it is no longer Tcl_Preserve()d * by anything. May be called multiple times on the same image without * ill effects. * *---------------------------------------------------------------------- */ func _EventuallyDeleteImage(tls *libc.TLS, modelPtr uintptr, forgetImageHashNow int32) { /* Flag to say whether the hash table is about * to vanish. */ if forgetImageHashNow != 0 { (*TImageModel)(unsafe.Pointer(modelPtr)).FhPtr = libc.UintptrFromInt32(0) } if !((*TImageModel)(unsafe.Pointer(modelPtr)).Fdeleted != 0) { (*TImageModel)(unsafe.Pointer(modelPtr)).Fdeleted = int32(1) libtcl9_0.XTcl_EventuallyFree(tls, modelPtr, __ccgo_fp(_DeleteImage1)) } } /* *---------------------------------------------------------------------- * * TkDeleteAllImages -- * * This function is called when an application is deleted. It calls back * all of the managers for all images so that they can cleanup, then it * deletes all of Tk's internal information about images. * * Results: * None. * * Side effects: * All information for all images gets deleted. * *---------------------------------------------------------------------- */ func XTkDeleteAllImages(tls *libc.TLS, mainPtr uintptr) { bp := tls.Alloc(32) defer tls.Free(32) /* Structure describing application that is * going away. */ var hPtr uintptr var _ /* search at bp+0 */ TTcl_HashSearch _ = hPtr hPtr = libtcl9_0.XTcl_FirstHashEntry(tls, mainPtr+184, bp) for { if !(hPtr != libc.UintptrFromInt32(0)) { break } _EventuallyDeleteImage(tls, (*TTcl_HashEntry)(unsafe.Pointer(hPtr)).FclientData, int32(1)) goto _1 _1: ; hPtr = libtcl9_0.XTcl_NextHashEntry(tls, bp) } libtcl9_0.XTcl_DeleteHashTable(tls, mainPtr+184) } /* *---------------------------------------------------------------------- * * Tk_GetImageModelData -- * * Given the name of an image, this function returns the type of the * image and the clientData associated with its model. * * Results: * If there is no image by the given name, then NULL is returned and a * NULL value is stored at *typePtrPtr. Otherwise the return value is the * clientData returned by the createProc when the image was created and a * pointer to the type structure for the image is stored at *typePtrPtr. * * Side effects: * None. * *---------------------------------------------------------------------- */ func XTk_GetImageModelData(tls *libc.TLS, interp uintptr, name uintptr, typePtrPtr uintptr) (r uintptr) { /* Points to location to fill in with pointer * to type information for image. */ var hPtr, modelPtr, winPtr uintptr _, _, _ = hPtr, modelPtr, winPtr winPtr = XTk_MainWindow(tls, interp) hPtr = (*(*func(*libc.TLS, uintptr, uintptr) uintptr)(unsafe.Pointer(&struct{ uintptr }{(*TTcl_HashTable)(unsafe.Pointer((*TTkWindow)(unsafe.Pointer(winPtr)).FmainPtr + 184)).FfindProc})))(tls, (*TTkWindow)(unsafe.Pointer(winPtr)).FmainPtr+184, name) if hPtr == libc.UintptrFromInt32(0) { *(*uintptr)(unsafe.Pointer(typePtrPtr)) = libc.UintptrFromInt32(0) return libc.UintptrFromInt32(0) } modelPtr = (*TTcl_HashEntry)(unsafe.Pointer(hPtr)).FclientData if (*TImageModel)(unsafe.Pointer(modelPtr)).Fdeleted != 0 { *(*uintptr)(unsafe.Pointer(typePtrPtr)) = libc.UintptrFromInt32(0) return libc.UintptrFromInt32(0) } *(*uintptr)(unsafe.Pointer(typePtrPtr)) = (*TImageModel)(unsafe.Pointer(modelPtr)).FtypePtr return (*TImageModel)(unsafe.Pointer(modelPtr)).FmodelData } /* *---------------------------------------------------------------------- * * Tk_SetTSOrigin -- * * Set the pattern origin of the tile to a common point (i.e. the origin * (0,0) of the top level window) so that tiles from two different * widgets will match up. This done by setting the GCTileStipOrigin field * is set to the translated origin of the toplevel window in the * hierarchy. * * Results: * None. * * Side Effects: * The GCTileStipOrigin is reset in the GC. This will cause the tile * origin to change when the GC is used for drawing. * *---------------------------------------------------------------------- */ func XTk_SetTSOrigin(tls *libc.TLS, tkwin TTk_Window, gc TGC, x int32, y int32) { for !((*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fflags&libc.Uint32FromInt32(TK_TOP_HIERARCHY) != 0) { x -= (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fchanges.Fx + (*TXWindowChanges)(unsafe.Pointer(tkwin+112)).Fborder_width y -= (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fchanges.Fy + (*TXWindowChanges)(unsafe.Pointer(tkwin+112)).Fborder_width tkwin = (*TTk_FakeWin)(unsafe.Pointer(tkwin)).FparentPtr } libx11.XXSetTSOrigin(tls, (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fdisplay, gc, x, y) } type TImage1 = struct { Ftkwin TTk_Window Fdisplay uintptr FmodelPtr uintptr FinstanceData uintptr FchangeProc uintptr FwidgetClientData uintptr FnextPtr uintptr FprevPtr uintptr } type TImageModel1 = struct { FtypePtr uintptr FmodelData uintptr Fwidth int32 Fheight int32 FtablePtr uintptr FhPtr uintptr FinstancePtr uintptr Fdeleted int32 FwinPtr uintptr } const MAX_WORD_LENGTH = 100 /* * Local Variables: * mode: c * c-basic-offset: 4 * fill-column: 78 * End: */ /* * The following data structure represents the model for a bitmap * image: */ type TBitmapModel = struct { FtkModel TTk_ImageModel Finterp uintptr FimageCmd TTcl_Command Fwidth int32 Fheight int32 Fdata uintptr FmaskData uintptr FfgUid TTk_Uid FbgUid TTk_Uid FfileString uintptr FdataString uintptr FmaskFileString uintptr FmaskDataString uintptr FinstancePtr uintptr } /* * The following data structure represents all of the instances of an image * that lie within a particular window: */ type TBitmapInstance = struct { FrefCount Tsize_t FmodelPtr uintptr Ftkwin TTk_Window Ffg uintptr Fbg uintptr Fbitmap TPixmap Fmask TPixmap Fgc TGC FnextPtr uintptr } func init() { p := unsafe.Pointer(&XtkBitmapImageType) *(*uintptr)(unsafe.Add(p, 8)) = __ccgo_fp(_ImgBmapCreate) *(*uintptr)(unsafe.Add(p, 16)) = __ccgo_fp(_ImgBmapGet) *(*uintptr)(unsafe.Add(p, 24)) = __ccgo_fp(_ImgBmapDisplay) *(*uintptr)(unsafe.Add(p, 32)) = __ccgo_fp(_ImgBmapFree) *(*uintptr)(unsafe.Add(p, 40)) = __ccgo_fp(_ImgBmapDelete) *(*uintptr)(unsafe.Add(p, 48)) = __ccgo_fp(_ImgBmapPostscript) } /* * Information used for parsing configuration specs: */ var _configSpecs11 = [7]TTk_ConfigSpec{ 0: { Ftype1: int32(TK_CONFIG_UID), FargvName: __ccgo_ts + 19898, FdefValue: __ccgo_ts + 195, Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 56)), }, 1: { Ftype1: int32(TK_CONFIG_STRING), FargvName: __ccgo_ts + 2842, Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 72)), FspecFlags: int32(TCL_NULL_OK), }, 2: { Ftype1: int32(TK_CONFIG_STRING), FargvName: __ccgo_ts + 30371, Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 64)), FspecFlags: int32(TCL_NULL_OK), }, 3: { Ftype1: int32(TK_CONFIG_UID), FargvName: __ccgo_ts + 20085, FdefValue: __ccgo_ts + 19829, Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 48)), }, 4: { Ftype1: int32(TK_CONFIG_STRING), FargvName: __ccgo_ts + 33202, Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 88)), FspecFlags: int32(TCL_NULL_OK), }, 5: { Ftype1: int32(TK_CONFIG_STRING), FargvName: __ccgo_ts + 33212, Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 80)), FspecFlags: int32(TCL_NULL_OK), }, 6: { Ftype1: int32(TK_CONFIG_END), }, } /* * The following data structure is used to describe the state of parsing a * bitmap file or string. It is used for communication between TkGetBitmapData * and NextBitmapWord. */ type TParseInfo = struct { Fstring1 uintptr Fchan1 TTcl_Channel Fword [101]uint8 FwordLength int32 } /* *---------------------------------------------------------------------- * * ImgBmapCreate -- * * This procedure is called by the Tk image code to create "test" images. * * Results: * A standard Tcl result. * * Side effects: * The data structure for a new image is allocated. * *---------------------------------------------------------------------- */ func _ImgBmapCreate(tls *libc.TLS, interp uintptr, name uintptr, objc TTcl_Size, objv uintptr, dummy180 uintptr, model TTk_ImageModel, clientDataPtr uintptr) (r int32) { /* Store manager's token for image here; it * will be returned in later callbacks. */ var modelPtr uintptr var v1 int32 _, _ = modelPtr, v1 modelPtr = libtcl9_0.XTcl_Alloc(tls, uint64(104)) (*TBitmapModel)(unsafe.Pointer(modelPtr)).FtkModel = model (*TBitmapModel)(unsafe.Pointer(modelPtr)).Finterp = interp (*TBitmapModel)(unsafe.Pointer(modelPtr)).FimageCmd = libtcl9_0.XTcl_CreateObjCommand(tls, interp, name, __ccgo_fp(_ImgBmapCmd), modelPtr, __ccgo_fp(_ImgBmapCmdDeletedProc)) v1 = libc.Int32FromInt32(0) (*TBitmapModel)(unsafe.Pointer(modelPtr)).Fheight = v1 (*TBitmapModel)(unsafe.Pointer(modelPtr)).Fwidth = v1 (*TBitmapModel)(unsafe.Pointer(modelPtr)).Fdata = libc.UintptrFromInt32(0) (*TBitmapModel)(unsafe.Pointer(modelPtr)).FmaskData = libc.UintptrFromInt32(0) (*TBitmapModel)(unsafe.Pointer(modelPtr)).FfgUid = libc.UintptrFromInt32(0) (*TBitmapModel)(unsafe.Pointer(modelPtr)).FbgUid = libc.UintptrFromInt32(0) (*TBitmapModel)(unsafe.Pointer(modelPtr)).FfileString = libc.UintptrFromInt32(0) (*TBitmapModel)(unsafe.Pointer(modelPtr)).FdataString = libc.UintptrFromInt32(0) (*TBitmapModel)(unsafe.Pointer(modelPtr)).FmaskFileString = libc.UintptrFromInt32(0) (*TBitmapModel)(unsafe.Pointer(modelPtr)).FmaskDataString = libc.UintptrFromInt32(0) (*TBitmapModel)(unsafe.Pointer(modelPtr)).FinstancePtr = libc.UintptrFromInt32(0) if _ImgBmapConfigureModel(tls, modelPtr, objc, objv, 0) != TCL_OK { _ImgBmapDelete(tls, modelPtr) return int32(TCL_ERROR) } *(*uintptr)(unsafe.Pointer(clientDataPtr)) = modelPtr return TCL_OK } /* *---------------------------------------------------------------------- * * ImgBmapConfigureModel -- * * This procedure is called when a bitmap image is created or * reconfigured. It process configuration options and resets any * instances of the image. * * Results: * A standard Tcl return value. If TCL_ERROR is returned then an error * message is left in the modelPtr->interp's result. * * Side effects: * Existing instances of the image will be redisplayed to match the new * configuration options. * *---------------------------------------------------------------------- */ func _ImgBmapConfigureModel(tls *libc.TLS, modelPtr uintptr, objc TTcl_Size, objv uintptr, flags int32) (r int32) { bp := tls.Alloc(64) defer tls.Free(64) /* Flags to pass to Tk_ConfigureWidget, such * as TK_CONFIG_ARGV_ONLY. */ var instancePtr uintptr var _ /* dummy1 at bp+8 */ int32 var _ /* dummy2 at bp+12 */ int32 var _ /* maskHeight at bp+4 */ int32 var _ /* maskWidth at bp+0 */ int32 _ = instancePtr if XTk_ConfigureWidget(tls, (*TBitmapModel)(unsafe.Pointer(modelPtr)).Finterp, XTk_MainWindow(tls, (*TBitmapModel)(unsafe.Pointer(modelPtr)).Finterp), uintptr(unsafe.Pointer(&_configSpecs11)), objc, objv, modelPtr, flags) != TCL_OK { return int32(TCL_ERROR) } /* * Parse the bitmap and/or mask to create binary data. Make sure that the * bitmap and mask have the same dimensions. */ if (*TBitmapModel)(unsafe.Pointer(modelPtr)).Fdata != libc.UintptrFromInt32(0) { libtcl9_0.XTcl_Free(tls, (*TBitmapModel)(unsafe.Pointer(modelPtr)).Fdata) (*TBitmapModel)(unsafe.Pointer(modelPtr)).Fdata = libc.UintptrFromInt32(0) } if (*TBitmapModel)(unsafe.Pointer(modelPtr)).FfileString != libc.UintptrFromInt32(0) || (*TBitmapModel)(unsafe.Pointer(modelPtr)).FdataString != libc.UintptrFromInt32(0) { (*TBitmapModel)(unsafe.Pointer(modelPtr)).Fdata = XTkGetBitmapData(tls, (*TBitmapModel)(unsafe.Pointer(modelPtr)).Finterp, (*TBitmapModel)(unsafe.Pointer(modelPtr)).FdataString, (*TBitmapModel)(unsafe.Pointer(modelPtr)).FfileString, modelPtr+24, modelPtr+28, bp+8, bp+12) if (*TBitmapModel)(unsafe.Pointer(modelPtr)).Fdata == libc.UintptrFromInt32(0) { return int32(TCL_ERROR) } } if (*TBitmapModel)(unsafe.Pointer(modelPtr)).FmaskData != libc.UintptrFromInt32(0) { libtcl9_0.XTcl_Free(tls, (*TBitmapModel)(unsafe.Pointer(modelPtr)).FmaskData) (*TBitmapModel)(unsafe.Pointer(modelPtr)).FmaskData = libc.UintptrFromInt32(0) } if (*TBitmapModel)(unsafe.Pointer(modelPtr)).FmaskFileString != libc.UintptrFromInt32(0) || (*TBitmapModel)(unsafe.Pointer(modelPtr)).FmaskDataString != libc.UintptrFromInt32(0) { if (*TBitmapModel)(unsafe.Pointer(modelPtr)).Fdata == libc.UintptrFromInt32(0) { libtcl9_0.XTcl_SetObjResult(tls, (*TBitmapModel)(unsafe.Pointer(modelPtr)).Finterp, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+33222, int64(-libc.Int32FromInt32(1)))) libtcl9_0.XTcl_SetErrorCode(tls, (*TBitmapModel)(unsafe.Pointer(modelPtr)).Finterp, libc.VaList(bp+24, __ccgo_ts+179, __ccgo_ts+29667, __ccgo_ts+763, __ccgo_ts+33258, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) } (*TBitmapModel)(unsafe.Pointer(modelPtr)).FmaskData = XTkGetBitmapData(tls, (*TBitmapModel)(unsafe.Pointer(modelPtr)).Finterp, (*TBitmapModel)(unsafe.Pointer(modelPtr)).FmaskDataString, (*TBitmapModel)(unsafe.Pointer(modelPtr)).FmaskFileString, bp, bp+4, bp+8, bp+12) if (*TBitmapModel)(unsafe.Pointer(modelPtr)).FmaskData == libc.UintptrFromInt32(0) { return int32(TCL_ERROR) } if *(*int32)(unsafe.Pointer(bp)) != (*TBitmapModel)(unsafe.Pointer(modelPtr)).Fwidth || *(*int32)(unsafe.Pointer(bp + 4)) != (*TBitmapModel)(unsafe.Pointer(modelPtr)).Fheight { libtcl9_0.XTcl_Free(tls, (*TBitmapModel)(unsafe.Pointer(modelPtr)).FmaskData) (*TBitmapModel)(unsafe.Pointer(modelPtr)).FmaskData = libc.UintptrFromInt32(0) libtcl9_0.XTcl_SetObjResult(tls, (*TBitmapModel)(unsafe.Pointer(modelPtr)).Finterp, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+33268, int64(-libc.Int32FromInt32(1)))) libtcl9_0.XTcl_SetErrorCode(tls, (*TBitmapModel)(unsafe.Pointer(modelPtr)).Finterp, libc.VaList(bp+24, __ccgo_ts+179, __ccgo_ts+29667, __ccgo_ts+763, __ccgo_ts+33305, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) } } /* * Cycle through all of the instances of this image, regenerating the * information for each instance. Then force the image to be redisplayed * everywhere that it is used. */ instancePtr = (*TBitmapModel)(unsafe.Pointer(modelPtr)).FinstancePtr for { if !(instancePtr != libc.UintptrFromInt32(0)) { break } _ImgBmapConfigureInstance(tls, instancePtr) goto _1 _1: ; instancePtr = (*TBitmapInstance)(unsafe.Pointer(instancePtr)).FnextPtr } XTk_ImageChanged(tls, (*TBitmapModel)(unsafe.Pointer(modelPtr)).FtkModel, 0, 0, (*TBitmapModel)(unsafe.Pointer(modelPtr)).Fwidth, (*TBitmapModel)(unsafe.Pointer(modelPtr)).Fheight, (*TBitmapModel)(unsafe.Pointer(modelPtr)).Fwidth, (*TBitmapModel)(unsafe.Pointer(modelPtr)).Fheight) return TCL_OK } /* *---------------------------------------------------------------------- * * ImgBmapConfigureInstance -- * * This procedure is called to create displaying information for a bitmap * image instance based on the configuration information in the model. * It is invoked both when new instances are created and when the model * is reconfigured. * * Results: * None. * * Side effects: * Generates errors via Tcl_BackgroundException if there are problems in * setting up the instance. * *---------------------------------------------------------------------- */ func _ImgBmapConfigureInstance(tls *libc.TLS, instancePtr uintptr) { bp := tls.Alloc(144) defer tls.Free(144) /* Instance to reconfigure. */ var colorPtr, modelPtr uintptr var gc TGC var mask uint32 var oldBitmap, oldMask TPixmap var _ /* gcValues at bp+0 */ TXGCValues _, _, _, _, _, _ = colorPtr, gc, mask, modelPtr, oldBitmap, oldMask modelPtr = (*TBitmapInstance)(unsafe.Pointer(instancePtr)).FmodelPtr /* * For each of the options in modelPtr, translate the string form into an * internal form appropriate for instancePtr. */ if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer((*TBitmapModel)(unsafe.Pointer(modelPtr)).FbgUid))) != 0 { colorPtr = XTk_GetColor(tls, (*TBitmapModel)(unsafe.Pointer(modelPtr)).Finterp, (*TBitmapInstance)(unsafe.Pointer(instancePtr)).Ftkwin, (*TBitmapModel)(unsafe.Pointer(modelPtr)).FbgUid) if colorPtr == libc.UintptrFromInt32(0) { goto error } } else { colorPtr = libc.UintptrFromInt32(0) } if (*TBitmapInstance)(unsafe.Pointer(instancePtr)).Fbg != libc.UintptrFromInt32(0) { XTk_FreeColor(tls, (*TBitmapInstance)(unsafe.Pointer(instancePtr)).Fbg) } (*TBitmapInstance)(unsafe.Pointer(instancePtr)).Fbg = colorPtr colorPtr = XTk_GetColor(tls, (*TBitmapModel)(unsafe.Pointer(modelPtr)).Finterp, (*TBitmapInstance)(unsafe.Pointer(instancePtr)).Ftkwin, (*TBitmapModel)(unsafe.Pointer(modelPtr)).FfgUid) if colorPtr == libc.UintptrFromInt32(0) { goto error } if (*TBitmapInstance)(unsafe.Pointer(instancePtr)).Ffg != libc.UintptrFromInt32(0) { XTk_FreeColor(tls, (*TBitmapInstance)(unsafe.Pointer(instancePtr)).Ffg) } (*TBitmapInstance)(unsafe.Pointer(instancePtr)).Ffg = colorPtr /* * Careful: We have to allocate new Pixmaps before deleting the old ones. * Otherwise, The XID allocator will always return the same XID for the * new Pixmaps as was used for the old Pixmaps. And that will prevent the * data and/or mask from changing in the GC below. */ oldBitmap = (*TBitmapInstance)(unsafe.Pointer(instancePtr)).Fbitmap (*TBitmapInstance)(unsafe.Pointer(instancePtr)).Fbitmap = uint64(0) oldMask = (*TBitmapInstance)(unsafe.Pointer(instancePtr)).Fmask (*TBitmapInstance)(unsafe.Pointer(instancePtr)).Fmask = uint64(0) if (*TBitmapModel)(unsafe.Pointer(modelPtr)).Fdata != libc.UintptrFromInt32(0) { (*TBitmapInstance)(unsafe.Pointer(instancePtr)).Fbitmap = libx11.XXCreateBitmapFromData(tls, (*TTk_FakeWin)(unsafe.Pointer((*TBitmapInstance)(unsafe.Pointer(instancePtr)).Ftkwin)).Fdisplay, (*TScreen)(unsafe.Pointer((*struct { Fext_data uintptr Fprivate1 uintptr Ffd int32 Fprivate2 int32 Fproto_major_version int32 Fproto_minor_version int32 Fvendor uintptr Fprivate3 TXID Fprivate4 TXID Fprivate5 TXID Fprivate6 int32 Fresource_alloc uintptr Fbyte_order int32 Fbitmap_unit int32 Fbitmap_pad int32 Fbitmap_bit_order int32 Fnformats int32 Fpixmap_format uintptr Fprivate8 int32 Frelease int32 Fprivate9 uintptr Fprivate10 uintptr Fqlen int32 Flast_request_read uint64 Frequest uint64 Fprivate11 TXPointer Fprivate12 TXPointer Fprivate13 TXPointer Fprivate14 TXPointer Fmax_request_size uint32 Fdb uintptr Fprivate15 uintptr Fdisplay_name uintptr Fdefault_screen int32 Fnscreens int32 Fscreens uintptr Fmotion_buffer uint64 Fprivate16 uint64 Fmin_keycode int32 Fmax_keycode int32 Fprivate17 TXPointer Fprivate18 TXPointer Fprivate19 int32 Fxdefaults uintptr })(unsafe.Pointer((*TTk_FakeWin)(unsafe.Pointer((*TBitmapInstance)(unsafe.Pointer(instancePtr)).Ftkwin)).Fdisplay)).Fscreens+uintptr((*TTk_FakeWin)(unsafe.Pointer((*TBitmapInstance)(unsafe.Pointer(instancePtr)).Ftkwin)).FscreenNum)*128)).Froot, (*TBitmapModel)(unsafe.Pointer(modelPtr)).Fdata, libc.Uint32FromInt32((*TBitmapModel)(unsafe.Pointer(modelPtr)).Fwidth), libc.Uint32FromInt32((*TBitmapModel)(unsafe.Pointer(modelPtr)).Fheight)) } if (*TBitmapModel)(unsafe.Pointer(modelPtr)).FmaskData != libc.UintptrFromInt32(0) { (*TBitmapInstance)(unsafe.Pointer(instancePtr)).Fmask = libx11.XXCreateBitmapFromData(tls, (*TTk_FakeWin)(unsafe.Pointer((*TBitmapInstance)(unsafe.Pointer(instancePtr)).Ftkwin)).Fdisplay, (*TScreen)(unsafe.Pointer((*struct { Fext_data uintptr Fprivate1 uintptr Ffd int32 Fprivate2 int32 Fproto_major_version int32 Fproto_minor_version int32 Fvendor uintptr Fprivate3 TXID Fprivate4 TXID Fprivate5 TXID Fprivate6 int32 Fresource_alloc uintptr Fbyte_order int32 Fbitmap_unit int32 Fbitmap_pad int32 Fbitmap_bit_order int32 Fnformats int32 Fpixmap_format uintptr Fprivate8 int32 Frelease int32 Fprivate9 uintptr Fprivate10 uintptr Fqlen int32 Flast_request_read uint64 Frequest uint64 Fprivate11 TXPointer Fprivate12 TXPointer Fprivate13 TXPointer Fprivate14 TXPointer Fmax_request_size uint32 Fdb uintptr Fprivate15 uintptr Fdisplay_name uintptr Fdefault_screen int32 Fnscreens int32 Fscreens uintptr Fmotion_buffer uint64 Fprivate16 uint64 Fmin_keycode int32 Fmax_keycode int32 Fprivate17 TXPointer Fprivate18 TXPointer Fprivate19 int32 Fxdefaults uintptr })(unsafe.Pointer((*TTk_FakeWin)(unsafe.Pointer((*TBitmapInstance)(unsafe.Pointer(instancePtr)).Ftkwin)).Fdisplay)).Fscreens+uintptr((*TTk_FakeWin)(unsafe.Pointer((*TBitmapInstance)(unsafe.Pointer(instancePtr)).Ftkwin)).FscreenNum)*128)).Froot, (*TBitmapModel)(unsafe.Pointer(modelPtr)).FmaskData, libc.Uint32FromInt32((*TBitmapModel)(unsafe.Pointer(modelPtr)).Fwidth), libc.Uint32FromInt32((*TBitmapModel)(unsafe.Pointer(modelPtr)).Fheight)) } if oldMask != uint64(0) { XTk_FreePixmap(tls, (*TTk_FakeWin)(unsafe.Pointer((*TBitmapInstance)(unsafe.Pointer(instancePtr)).Ftkwin)).Fdisplay, oldMask) } if oldBitmap != uint64(0) { XTk_FreePixmap(tls, (*TTk_FakeWin)(unsafe.Pointer((*TBitmapInstance)(unsafe.Pointer(instancePtr)).Ftkwin)).Fdisplay, oldBitmap) } if (*TBitmapModel)(unsafe.Pointer(modelPtr)).Fdata != libc.UintptrFromInt32(0) { (*(*TXGCValues)(unsafe.Pointer(bp))).Fforeground = (*TXColor)(unsafe.Pointer((*TBitmapInstance)(unsafe.Pointer(instancePtr)).Ffg)).Fpixel (*(*TXGCValues)(unsafe.Pointer(bp))).Fgraphics_exposures = False mask = libc.Uint32FromInt64(libc.Int64FromInt64(1)<= int32(6) && libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(bp + 8 + 16 + uintptr((*(*TParseInfo)(unsafe.Pointer(bp + 8))).FwordLength-int32(6))))) == int32('_') && libc.Xstrcmp(tls, bp+8+16+uintptr((*(*TParseInfo)(unsafe.Pointer(bp + 8))).FwordLength)-uintptr(6), __ccgo_ts+33449) == 0 { if _NextBitmapWord(tls, bp+8) != TCL_OK { goto error } width = int32(libc.Xstrtol(tls, bp+8+16, bp, 0)) if *(*uintptr)(unsafe.Pointer(bp)) == bp+8+16 || libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp))))) != 0 { goto error } } else { if (*(*TParseInfo)(unsafe.Pointer(bp + 8))).FwordLength >= int32(7) && libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(bp + 8 + 16 + uintptr((*(*TParseInfo)(unsafe.Pointer(bp + 8))).FwordLength-int32(7))))) == int32('_') && libc.Xstrcmp(tls, bp+8+16+uintptr((*(*TParseInfo)(unsafe.Pointer(bp + 8))).FwordLength)-uintptr(7), __ccgo_ts+33456) == 0 { if _NextBitmapWord(tls, bp+8) != TCL_OK { goto error } height = int32(libc.Xstrtol(tls, bp+8+16, bp, 0)) if *(*uintptr)(unsafe.Pointer(bp)) == bp+8+16 || libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp))))) != 0 { goto error } } else { if (*(*TParseInfo)(unsafe.Pointer(bp + 8))).FwordLength >= int32(6) && libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(bp + 8 + 16 + uintptr((*(*TParseInfo)(unsafe.Pointer(bp + 8))).FwordLength-int32(6))))) == int32('_') && libc.Xstrcmp(tls, bp+8+16+uintptr((*(*TParseInfo)(unsafe.Pointer(bp + 8))).FwordLength)-uintptr(6), __ccgo_ts+33464) == 0 { if _NextBitmapWord(tls, bp+8) != TCL_OK { goto error } hotX = int32(libc.Xstrtol(tls, bp+8+16, bp, 0)) if *(*uintptr)(unsafe.Pointer(bp)) == bp+8+16 || libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp))))) != 0 { goto error } } else { if (*(*TParseInfo)(unsafe.Pointer(bp + 8))).FwordLength >= int32(6) && libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(bp + 8 + 16 + uintptr((*(*TParseInfo)(unsafe.Pointer(bp + 8))).FwordLength-int32(6))))) == int32('_') && libc.Xstrcmp(tls, bp+8+16+uintptr((*(*TParseInfo)(unsafe.Pointer(bp + 8))).FwordLength)-uintptr(6), __ccgo_ts+33471) == 0 { if _NextBitmapWord(tls, bp+8) != TCL_OK { goto error } hotY = int32(libc.Xstrtol(tls, bp+8+16, bp, 0)) if *(*uintptr)(unsafe.Pointer(bp)) == bp+8+16 || libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp))))) != 0 { goto error } } else { if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(bp + 8 + 16))) == int32('c') && libc.Xstrcmp(tls, bp+8+16, __ccgo_ts+33478) == 0 { for int32(1) != 0 { if _NextBitmapWord(tls, bp+8) != TCL_OK { goto error } if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(bp + 8 + 16))) == int32('{') && libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(bp + 8 + 16 + 1))) == 0 { goto getData } } } else { if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(bp + 8 + 16))) == int32('{') && libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(bp + 8 + 16 + 1))) == 0 { if interp != libc.UintptrFromInt32(0) { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+33483, int64(-libc.Int32FromInt32(1)))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+368, __ccgo_ts+179, __ccgo_ts+29667, __ccgo_ts+763, __ccgo_ts+33556, libc.UintptrFromInt32(0))) } goto errorCleanup } } } } } } } /* * Now we've read everything but the data. Allocate an array and read in * the data. */ goto getData getData: ; if width <= 0 || height <= 0 { goto error } numBytes = (width + int32(7)) / int32(8) * height data = libtcl9_0.XTcl_Alloc(tls, libc.Uint64FromInt32(numBytes)) p = data for { if !(numBytes > 0) { break } if _NextBitmapWord(tls, bp+8) != TCL_OK { goto error } *(*uint8)(unsafe.Pointer(p)) = libc.Uint8FromInt64(libc.Xstrtol(tls, bp+8+16, bp, 0)) if *(*uintptr)(unsafe.Pointer(bp)) == bp+8+16 { goto error } goto _4 _4: ; p++ numBytes-- } /* * All done. Clean up and return. */ if (*(*TParseInfo)(unsafe.Pointer(bp + 8))).Fchan1 != libc.UintptrFromInt32(0) { libtcl9_0.XTcl_CloseEx(tls, libc.UintptrFromInt32(0), (*(*TParseInfo)(unsafe.Pointer(bp + 8))).Fchan1, 0) } *(*int32)(unsafe.Pointer(widthPtr)) = width *(*int32)(unsafe.Pointer(heightPtr)) = height *(*int32)(unsafe.Pointer(hotXPtr)) = hotX *(*int32)(unsafe.Pointer(hotYPtr)) = hotY return data goto error error: ; if interp != libc.UintptrFromInt32(0) { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+33565, int64(-libc.Int32FromInt32(1)))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+368, __ccgo_ts+179, __ccgo_ts+29667, __ccgo_ts+763, __ccgo_ts+33593, libc.UintptrFromInt32(0))) } goto errorCleanup errorCleanup: ; if data != libc.UintptrFromInt32(0) { libtcl9_0.XTcl_Free(tls, data) } if (*(*TParseInfo)(unsafe.Pointer(bp + 8))).Fchan1 != libc.UintptrFromInt32(0) { libtcl9_0.XTcl_CloseEx(tls, libc.UintptrFromInt32(0), (*(*TParseInfo)(unsafe.Pointer(bp + 8))).Fchan1, 0) } return libc.UintptrFromInt32(0) } /* *---------------------------------------------------------------------- * * NextBitmapWord -- * * This procedure retrieves the next word of information (stuff between * commas or white space) from a bitmap description. * * Results: * Returns TCL_OK if all went well. In this case the next word, and its * length, will be availble in *parseInfoPtr. If the end of the bitmap * description was reached then TCL_ERROR is returned. * * Side effects: * None. * *---------------------------------------------------------------------- */ func _NextBitmapWord(tls *libc.TLS, parseInfoPtr uintptr) (r int32) { /* Describes what we're reading and where we * are in it. */ var c, v10, v11, v14, v15, v2, v3, v6, v7 int32 var dst, src uintptr _, _, _, _, _, _, _, _, _, _, _ = c, dst, src, v10, v11, v14, v15, v2, v3, v6, v7 (*TParseInfo)(unsafe.Pointer(parseInfoPtr)).FwordLength = 0 dst = parseInfoPtr + 16 if (*TParseInfo)(unsafe.Pointer(parseInfoPtr)).Fstring1 != libc.UintptrFromInt32(0) { src = (*TParseInfo)(unsafe.Pointer(parseInfoPtr)).Fstring1 for { v2 = libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(src))) v3 = libc.BoolInt32(v2 == int32(' ') || libc.Uint32FromInt32(v2)-uint32('\t') < uint32(5)) goto _4 _4: ; if !(v3 != 0 || libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(src))) == int32(',')) { break } if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(src))) == 0 { return int32(TCL_ERROR) } goto _1 _1: ; src++ } for { v6 = libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(src))) v7 = libc.BoolInt32(v6 == int32(' ') || libc.Uint32FromInt32(v6)-uint32('\t') < uint32(5)) goto _8 _8: ; if !(!(v7 != 0) && libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(src))) != int32(',') && libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(src))) != 0) { break } *(*uint8)(unsafe.Pointer(dst)) = *(*uint8)(unsafe.Pointer(src)) dst++ (*TParseInfo)(unsafe.Pointer(parseInfoPtr)).FwordLength++ if (*TParseInfo)(unsafe.Pointer(parseInfoPtr)).FwordLength > int32(MAX_WORD_LENGTH) { return int32(TCL_ERROR) } goto _5 _5: ; src++ } (*TParseInfo)(unsafe.Pointer(parseInfoPtr)).Fstring1 = src } else { c = _GetByte(tls, (*TParseInfo)(unsafe.Pointer(parseInfoPtr)).Fchan1) for { v10 = libc.Int32FromUint8(libc.Uint8FromInt32(c)) v11 = libc.BoolInt32(v10 == int32(' ') || libc.Uint32FromInt32(v10)-uint32('\t') < uint32(5)) goto _12 _12: ; if !(v11 != 0 || c == int32(',')) { break } if c == -int32(1) { return int32(TCL_ERROR) } goto _9 _9: ; c = _GetByte(tls, (*TParseInfo)(unsafe.Pointer(parseInfoPtr)).Fchan1) } for { v14 = libc.Int32FromUint8(libc.Uint8FromInt32(c)) v15 = libc.BoolInt32(v14 == int32(' ') || libc.Uint32FromInt32(v14)-uint32('\t') < uint32(5)) goto _16 _16: ; if !(!(v15 != 0) && c != int32(',') && c != -int32(1)) { break } *(*uint8)(unsafe.Pointer(dst)) = libc.Uint8FromInt32(c) dst++ (*TParseInfo)(unsafe.Pointer(parseInfoPtr)).FwordLength++ if (*TParseInfo)(unsafe.Pointer(parseInfoPtr)).FwordLength > int32(MAX_WORD_LENGTH) { return int32(TCL_ERROR) } goto _13 _13: ; c = _GetByte(tls, (*TParseInfo)(unsafe.Pointer(parseInfoPtr)).Fchan1) } } if (*TParseInfo)(unsafe.Pointer(parseInfoPtr)).FwordLength == 0 { return int32(TCL_ERROR) } *(*uint8)(unsafe.Pointer(parseInfoPtr + 16 + uintptr((*TParseInfo)(unsafe.Pointer(parseInfoPtr)).FwordLength))) = uint8(0) return TCL_OK } /* *-------------------------------------------------------------- * * ImgBmapCmd -- * * This procedure is invoked to process the Tcl command that corresponds * to an image managed by this module. See the user documentation for * details on what it does. * * Results: * A standard Tcl result. * * Side effects: * See the user documentation. * *-------------------------------------------------------------- */ func _ImgBmapCmd(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) (r int32) { bp := tls.Alloc(16) defer tls.Free(16) /* Argument objects. */ var modelPtr uintptr var _ /* index at bp+0 */ int32 _ = modelPtr modelPtr = clientData if objc < int32(2) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(1), objv, __ccgo_ts+4953) return int32(TCL_ERROR) } if libtcl9_0.XTcl_GetIndexFromObjStruct(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 1*8)), uintptr(unsafe.Pointer(&_bmapOptions)), libc.Int64FromUint64(libc.Uint64FromInt64(8)), __ccgo_ts+2689, libc.Int32FromInt32(0)|libc.Int32FromUint64(libc.Uint64FromInt64(4)< uint64(1) { return } /* * There are no more uses of the image within this widget. Free the * instance structure. */ if (*TBitmapInstance)(unsafe.Pointer(instancePtr)).Ffg != libc.UintptrFromInt32(0) { XTk_FreeColor(tls, (*TBitmapInstance)(unsafe.Pointer(instancePtr)).Ffg) } if (*TBitmapInstance)(unsafe.Pointer(instancePtr)).Fbg != libc.UintptrFromInt32(0) { XTk_FreeColor(tls, (*TBitmapInstance)(unsafe.Pointer(instancePtr)).Fbg) } if (*TBitmapInstance)(unsafe.Pointer(instancePtr)).Fbitmap != uint64(0) { XTk_FreePixmap(tls, display, (*TBitmapInstance)(unsafe.Pointer(instancePtr)).Fbitmap) } if (*TBitmapInstance)(unsafe.Pointer(instancePtr)).Fmask != uint64(0) { XTk_FreePixmap(tls, display, (*TBitmapInstance)(unsafe.Pointer(instancePtr)).Fmask) } if (*TBitmapInstance)(unsafe.Pointer(instancePtr)).Fgc != libc.UintptrFromInt32(0) { XTk_FreeGC(tls, display, (*TBitmapInstance)(unsafe.Pointer(instancePtr)).Fgc) } if (*TBitmapModel)(unsafe.Pointer((*TBitmapInstance)(unsafe.Pointer(instancePtr)).FmodelPtr)).FinstancePtr == instancePtr { (*TBitmapModel)(unsafe.Pointer((*TBitmapInstance)(unsafe.Pointer(instancePtr)).FmodelPtr)).FinstancePtr = (*TBitmapInstance)(unsafe.Pointer(instancePtr)).FnextPtr } else { prevPtr = (*TBitmapModel)(unsafe.Pointer((*TBitmapInstance)(unsafe.Pointer(instancePtr)).FmodelPtr)).FinstancePtr for { if !((*TBitmapInstance)(unsafe.Pointer(prevPtr)).FnextPtr != instancePtr) { break } /* Empty loop body */ goto _3 _3: ; prevPtr = (*TBitmapInstance)(unsafe.Pointer(prevPtr)).FnextPtr } (*TBitmapInstance)(unsafe.Pointer(prevPtr)).FnextPtr = (*TBitmapInstance)(unsafe.Pointer(instancePtr)).FnextPtr } libtcl9_0.XTcl_Free(tls, instancePtr) } /* *---------------------------------------------------------------------- * * ImgBmapDelete -- * * This procedure is called by the image code to delete the model * structure for an image. * * Results: * None. * * Side effects: * Resources associated with the image get freed. * *---------------------------------------------------------------------- */ func _ImgBmapDelete(tls *libc.TLS, modelData uintptr) { /* Pointer to BitmapModel structure for * image. Must not have any more instances. */ var modelPtr uintptr _ = modelPtr modelPtr = modelData if (*TBitmapModel)(unsafe.Pointer(modelPtr)).FinstancePtr != libc.UintptrFromInt32(0) { libtcl9_0.XTcl_Panic(tls, __ccgo_ts+33647, 0) } (*TBitmapModel)(unsafe.Pointer(modelPtr)).FtkModel = libc.UintptrFromInt32(0) if (*TBitmapModel)(unsafe.Pointer(modelPtr)).FimageCmd != libc.UintptrFromInt32(0) { libtcl9_0.XTcl_DeleteCommandFromToken(tls, (*TBitmapModel)(unsafe.Pointer(modelPtr)).Finterp, (*TBitmapModel)(unsafe.Pointer(modelPtr)).FimageCmd) } if (*TBitmapModel)(unsafe.Pointer(modelPtr)).Fdata != libc.UintptrFromInt32(0) { libtcl9_0.XTcl_Free(tls, (*TBitmapModel)(unsafe.Pointer(modelPtr)).Fdata) } if (*TBitmapModel)(unsafe.Pointer(modelPtr)).FmaskData != libc.UintptrFromInt32(0) { libtcl9_0.XTcl_Free(tls, (*TBitmapModel)(unsafe.Pointer(modelPtr)).FmaskData) } XTk_FreeOptions(tls, uintptr(unsafe.Pointer(&_configSpecs11)), modelPtr, libc.UintptrFromInt32(0), 0) libtcl9_0.XTcl_Free(tls, modelPtr) } /* *---------------------------------------------------------------------- * * ImgBmapCmdDeletedProc -- * * This procedure is invoked when the image command for an image is * deleted. It deletes the image. * * Results: * None. * * Side effects: * The image is deleted. * *---------------------------------------------------------------------- */ func _ImgBmapCmdDeletedProc(tls *libc.TLS, clientData uintptr) { /* Pointer to BitmapModel structure for * image. */ var modelPtr uintptr _ = modelPtr modelPtr = clientData (*TBitmapModel)(unsafe.Pointer(modelPtr)).FimageCmd = libc.UintptrFromInt32(0) if (*TBitmapModel)(unsafe.Pointer(modelPtr)).FtkModel != libc.UintptrFromInt32(0) { XTk_DeleteImage(tls, (*TBitmapModel)(unsafe.Pointer(modelPtr)).Finterp, XTk_NameOfImage(tls, (*TBitmapModel)(unsafe.Pointer(modelPtr)).FtkModel)) } } /* *---------------------------------------------------------------------- * * GetByte -- * * Get the next byte from the open channel. * * Results: * The next byte or EOF. * * Side effects: * We read from the channel. * *---------------------------------------------------------------------- */ func _GetByte(tls *libc.TLS, chan1 TTcl_Channel) (r int32) { bp := tls.Alloc(16) defer tls.Free(16) /* The channel we read from. */ var _ /* buffer at bp+0 */ uint8 if libtcl9_0.XTcl_Read(tls, chan1, bp, int64(1)) != int64(1) { return -int32(1) } else { return libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(bp))) } return r } /* *---------------------------------------------------------------------- * * ImgBmapPsImagemask -- * * This procedure generates postscript suitable for rendering a single * bitmap of an image. A single bitmap image might contain both a * foreground and a background bitmap. This routine is called once for * each such bitmap in a bitmap image. * * Prior to invoking this routine, the following setup has occurred: * * 1. The postscript foreground color has been set to the color used * to render the bitmap. * * 2. The origin of the postscript coordinate system is set to the * lower left corner of the bitmap. * * 3. The postscript coordinate system has been scaled so that the * entire bitmap is one unit squared. * * Results: * None. * * Side effects: * Postscript code is appended to psObj. * *---------------------------------------------------------------------- */ func _ImgBmapPsImagemask(tls *libc.TLS, psObj uintptr, width int32, height int32, data uintptr) { bp := tls.Alloc(48) defer tls.Free(48) /* Data for the bitmap. */ var i, j, nBytePerRow int32 _, _, _ = i, j, nBytePerRow libtcl9_0.XTcl_AppendPrintfToObj(tls, psObj, __ccgo_ts+33703, libc.VaList(bp+8, width, height, width, -height, height)) nBytePerRow = (width + int32(7)) / int32(8) i = 0 for { if !(i < height) { break } j = 0 for { if !(j < nBytePerRow) { break } libtcl9_0.XTcl_AppendPrintfToObj(tls, psObj, __ccgo_ts+33746, libc.VaList(bp+8, libc.Int32FromUint8(_bit_reverse[int32(0xff)&libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(data + uintptr(i*nBytePerRow+j))))]))) goto _2 _2: ; j++ } libtcl9_0.XTcl_AppendToObj(tls, psObj, __ccgo_ts+14046, int64(-libc.Int32FromInt32(1))) goto _1 _1: ; i++ } libtcl9_0.XTcl_AppendToObj(tls, psObj, __ccgo_ts+33752, int64(-libc.Int32FromInt32(1))) } /* * The bit order of bitmaps in Tk is the opposite of the bit order that * postscript uses. (In Tk, the least significant bit is on the right side * of the bitmap and in postscript the least significant bit is shown on * the left.) The following array is used to reverse the order of bits * within a byte so that the bits will be in the order postscript expects. */ var _bit_reverse = [256]uint8{ 1: uint8(128), 2: uint8(64), 3: uint8(192), 4: uint8(32), 5: uint8(160), 6: uint8(96), 7: uint8(224), 8: uint8(16), 9: uint8(144), 10: uint8(80), 11: uint8(208), 12: uint8(48), 13: uint8(176), 14: uint8(112), 15: uint8(240), 16: uint8(8), 17: uint8(136), 18: uint8(72), 19: uint8(200), 20: uint8(40), 21: uint8(168), 22: uint8(104), 23: uint8(232), 24: uint8(24), 25: uint8(152), 26: uint8(88), 27: uint8(216), 28: uint8(56), 29: uint8(184), 30: uint8(120), 31: uint8(248), 32: uint8(4), 33: uint8(132), 34: uint8(68), 35: uint8(196), 36: uint8(36), 37: uint8(164), 38: uint8(100), 39: uint8(228), 40: uint8(20), 41: uint8(148), 42: uint8(84), 43: uint8(212), 44: uint8(52), 45: uint8(180), 46: uint8(116), 47: uint8(244), 48: uint8(12), 49: uint8(140), 50: uint8(76), 51: uint8(204), 52: uint8(44), 53: uint8(172), 54: uint8(108), 55: uint8(236), 56: uint8(28), 57: uint8(156), 58: uint8(92), 59: uint8(220), 60: uint8(60), 61: uint8(188), 62: uint8(124), 63: uint8(252), 64: uint8(2), 65: uint8(130), 66: uint8(66), 67: uint8(194), 68: uint8(34), 69: uint8(162), 70: uint8(98), 71: uint8(226), 72: uint8(18), 73: uint8(146), 74: uint8(82), 75: uint8(210), 76: uint8(50), 77: uint8(178), 78: uint8(114), 79: uint8(242), 80: uint8(10), 81: uint8(138), 82: uint8(74), 83: uint8(202), 84: uint8(42), 85: uint8(170), 86: uint8(106), 87: uint8(234), 88: uint8(26), 89: uint8(154), 90: uint8(90), 91: uint8(218), 92: uint8(58), 93: uint8(186), 94: uint8(122), 95: uint8(250), 96: uint8(6), 97: uint8(134), 98: uint8(70), 99: uint8(198), 100: uint8(38), 101: uint8(166), 102: uint8(102), 103: uint8(230), 104: uint8(22), 105: uint8(150), 106: uint8(86), 107: uint8(214), 108: uint8(54), 109: uint8(182), 110: uint8(118), 111: uint8(246), 112: uint8(14), 113: uint8(142), 114: uint8(78), 115: uint8(206), 116: uint8(46), 117: uint8(174), 118: uint8(110), 119: uint8(238), 120: uint8(30), 121: uint8(158), 122: uint8(94), 123: uint8(222), 124: uint8(62), 125: uint8(190), 126: uint8(126), 127: uint8(254), 128: uint8(1), 129: uint8(129), 130: uint8(65), 131: uint8(193), 132: uint8(33), 133: uint8(161), 134: uint8(97), 135: uint8(225), 136: uint8(17), 137: uint8(145), 138: uint8(81), 139: uint8(209), 140: uint8(49), 141: uint8(177), 142: uint8(113), 143: uint8(241), 144: uint8(9), 145: uint8(137), 146: uint8(73), 147: uint8(201), 148: uint8(41), 149: uint8(169), 150: uint8(105), 151: uint8(233), 152: uint8(25), 153: uint8(153), 154: uint8(89), 155: uint8(217), 156: uint8(57), 157: uint8(185), 158: uint8(121), 159: uint8(249), 160: uint8(5), 161: uint8(133), 162: uint8(69), 163: uint8(197), 164: uint8(37), 165: uint8(165), 166: uint8(101), 167: uint8(229), 168: uint8(21), 169: uint8(149), 170: uint8(85), 171: uint8(213), 172: uint8(53), 173: uint8(181), 174: uint8(117), 175: uint8(245), 176: uint8(13), 177: uint8(141), 178: uint8(77), 179: uint8(205), 180: uint8(45), 181: uint8(173), 182: uint8(109), 183: uint8(237), 184: uint8(29), 185: uint8(157), 186: uint8(93), 187: uint8(221), 188: uint8(61), 189: uint8(189), 190: uint8(125), 191: uint8(253), 192: uint8(3), 193: uint8(131), 194: uint8(67), 195: uint8(195), 196: uint8(35), 197: uint8(163), 198: uint8(99), 199: uint8(227), 200: uint8(19), 201: uint8(147), 202: uint8(83), 203: uint8(211), 204: uint8(51), 205: uint8(179), 206: uint8(115), 207: uint8(243), 208: uint8(11), 209: uint8(139), 210: uint8(75), 211: uint8(203), 212: uint8(43), 213: uint8(171), 214: uint8(107), 215: uint8(235), 216: uint8(27), 217: uint8(155), 218: uint8(91), 219: uint8(219), 220: uint8(59), 221: uint8(187), 222: uint8(123), 223: uint8(251), 224: uint8(7), 225: uint8(135), 226: uint8(71), 227: uint8(199), 228: uint8(39), 229: uint8(167), 230: uint8(103), 231: uint8(231), 232: uint8(23), 233: uint8(151), 234: uint8(87), 235: uint8(215), 236: uint8(55), 237: uint8(183), 238: uint8(119), 239: uint8(247), 240: uint8(15), 241: uint8(143), 242: uint8(79), 243: uint8(207), 244: uint8(47), 245: uint8(175), 246: uint8(111), 247: uint8(239), 248: uint8(31), 249: uint8(159), 250: uint8(95), 251: uint8(223), 252: uint8(63), 253: uint8(191), 254: uint8(127), 255: uint8(255), } /* *---------------------------------------------------------------------- * * ImgBmapPostscript -- * * This procedure generates postscript for rendering a bitmap image. * * Results: * On success, this routine writes postscript code into interp->result * and returns TCL_OK TCL_ERROR is returned and an error message is left * in interp->result if anything goes wrong. * * Side effects: * None. * *---------------------------------------------------------------------- */ func _ImgBmapPostscript(tls *libc.TLS, clientData uintptr, interp uintptr, tkwin TTk_Window, psinfo TTk_PostscriptInfo, x int32, y int32, width int32, height int32, prepass int32) (r int32) { bp := tls.Alloc(80) defer tls.Free(80) var _objPtr, _objPtr1, modelPtr, psObj, v2, v4 uintptr var interpState TTcl_InterpState var v1, v3 TTcl_Size var _ /* color at bp+0 */ TXColor var _ /* color at bp+16 */ TXColor _, _, _, _, _, _, _, _, _ = _objPtr, _objPtr1, interpState, modelPtr, psObj, v1, v2, v3, v4 modelPtr = clientData if prepass != 0 { return TCL_OK } /* * There is nothing to do for bitmaps with zero width or height. */ if width <= 0 || height <= 0 || (*TBitmapModel)(unsafe.Pointer(modelPtr)).Fwidth <= 0 || (*TBitmapModel)(unsafe.Pointer(modelPtr)).Fheight <= 0 { return TCL_OK } /* * Some postscript implementations cannot handle bitmap strings longer * than about 60k characters. If the bitmap data is that big or bigger, * we bail out. */ if (*TBitmapModel)(unsafe.Pointer(modelPtr)).Fwidth*(*TBitmapModel)(unsafe.Pointer(modelPtr)).Fheight > int32(60000) { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+33767, int64(-libc.Int32FromInt32(1)))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+40, __ccgo_ts+179, __ccgo_ts+27003, __ccgo_ts+29550, __ccgo_ts+29553, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) } /* * Make our working space. */ psObj = libtcl9_0.XTcl_NewObj(tls) interpState = libtcl9_0.XTcl_SaveInterpState(tls, interp, TCL_OK) /* * Translate the origin of the coordinate system to be the lower-left * corner of the bitmap and adjust the scale of the coordinate system so * that entire bitmap covers one square unit of the page. The calling * function put a "gsave" into the postscript and will add a "grestore" at * after this routine returns, so it is safe to make whatever changes are * necessary here. */ if x != 0 || y != 0 { libtcl9_0.XTcl_AppendPrintfToObj(tls, psObj, __ccgo_ts+33834, libc.VaList(bp+40, x, y)) } if width != int32(1) || height != int32(1) { libtcl9_0.XTcl_AppendPrintfToObj(tls, psObj, __ccgo_ts+33848, libc.VaList(bp+40, width, height)) } /* * Color the background, if there is one. This step is skipped if the * background is transparent. If the background is not transparent and * there is no background mask, then color the complete rectangle that * encloses the bitmap. If there is a background mask, then only apply * color to the bits specified by the mask. */ if (*TBitmapModel)(unsafe.Pointer(modelPtr)).FbgUid != libc.UintptrFromInt32(0) && libc.Int32FromUint8(*(*uint8)(unsafe.Pointer((*TBitmapModel)(unsafe.Pointer(modelPtr)).FbgUid))) != int32('\000') { XTkParseColor(tls, (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fdisplay, (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fatts.Fcolormap, (*TBitmapModel)(unsafe.Pointer(modelPtr)).FbgUid, bp) libtcl9_0.XTcl_ResetResult(tls, interp) if XTk_PostscriptColor(tls, interp, psinfo, bp) != TCL_OK { goto error } libtcl9_0.XTcl_AppendObjToObj(tls, psObj, libtcl9_0.XTcl_GetObjResult(tls, interp)) if (*TBitmapModel)(unsafe.Pointer(modelPtr)).FmaskData == libc.UintptrFromInt32(0) { libtcl9_0.XTcl_AppendToObj(tls, psObj, __ccgo_ts+33861, int64(-libc.Int32FromInt32(1))) } else { _ImgBmapPsImagemask(tls, psObj, (*TBitmapModel)(unsafe.Pointer(modelPtr)).Fwidth, (*TBitmapModel)(unsafe.Pointer(modelPtr)).Fheight, (*TBitmapModel)(unsafe.Pointer(modelPtr)).FmaskData) } } /* * Draw the bitmap foreground, assuming there is one. */ if (*TBitmapModel)(unsafe.Pointer(modelPtr)).FfgUid != libc.UintptrFromInt32(0) && (*TBitmapModel)(unsafe.Pointer(modelPtr)).Fdata != libc.UintptrFromInt32(0) { XTkParseColor(tls, (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fdisplay, (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fatts.Fcolormap, (*TBitmapModel)(unsafe.Pointer(modelPtr)).FfgUid, bp+16) libtcl9_0.XTcl_ResetResult(tls, interp) if XTk_PostscriptColor(tls, interp, psinfo, bp+16) != TCL_OK { goto error } libtcl9_0.XTcl_AppendObjToObj(tls, psObj, libtcl9_0.XTcl_GetObjResult(tls, interp)) _ImgBmapPsImagemask(tls, psObj, (*TBitmapModel)(unsafe.Pointer(modelPtr)).Fwidth, (*TBitmapModel)(unsafe.Pointer(modelPtr)).Fheight, (*TBitmapModel)(unsafe.Pointer(modelPtr)).Fdata) } /* * Plug the accumulated postscript back into the result. */ libtcl9_0.XTcl_RestoreInterpState(tls, interp, interpState) libtcl9_0.XTcl_AppendObjToObj(tls, libtcl9_0.XTcl_GetObjResult(tls, interp), psObj) _objPtr = psObj v2 = _objPtr v1 = *(*TTcl_Size)(unsafe.Pointer(v2)) *(*TTcl_Size)(unsafe.Pointer(v2))-- if v1 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr) } return TCL_OK goto error error: ; libtcl9_0.XTcl_DiscardInterpState(tls, interpState) _objPtr1 = psObj v4 = _objPtr1 v3 = *(*TTcl_Size)(unsafe.Pointer(v4)) *(*TTcl_Size)(unsafe.Pointer(v4))-- if v3 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr1) } return int32(TCL_ERROR) } const CM_ALPHA = 3 const CM_BLUE = 2 const CM_GREEN = 1 const CM_RED = 0 const DEFAULT_BACKGROUND_VALUE = 217 const GIFBITS = 12 const GIF_BAD = 259 const GIF_DONE = 260 const GIF_EXTENSION = 33 const GIF_PAD = 257 const GIF_SPACE = 258 const GIF_SPECIAL = 256 const GIF_START = 44 const GIF_TERMINATOR = 59 const HSIZE = 5003 const INTERLACE = 64 const LOCALCOLORMAP = 128 const MAXCOLORMAPSIZE = 256 const MAX_LWZ_BITS = 12 /* * Local Variables: * mode: c * c-basic-offset: 4 * fill-column: 78 * End: */ /* * GIF's are represented as data in either binary or base64 format. base64 * strings consist of 4 6-bit characters -> 3 8 bit bytes. A-Z, a-z, 0-9, + * and / represent the 64 values (in order). '=' is a trailing padding char * when the un-encoded data is not a multiple of 3 bytes. We'll ignore white * space when encountered. Any other invalid character is treated as an EOF */ /* * structure to hold the data of a Graphic Control Extension block. */ type TGIFGraphicControlExtensionBlock = struct { FblockPresent int32 Ftransparent int32 FdelayTime int32 FdisposalMethod int32 FuserInteraction int32 } /* * structure to "mimic" FILE for Mread, so we can look like fread. The decoder * state keeps track of which byte we are about to read, or EOF. */ type TMFile = struct { Fdata uintptr Fc int32 Fstate int32 Flength TTcl_Size } /* * structure to "mimic" FILE for Mread, so we can look like fread. The decoder * state keeps track of which byte we are about to read, or EOF. */ type TmFile = TMFile /* * Non-ASCII encoding support: * Most data in a GIF image is binary and is treated as such. However, a few * key bits are stashed in ASCII. If we try to compare those pieces to the * char they represent, it will fail on any non-ASCII (eg, EBCDIC) system. To * accommodate these systems, we test against the numeric value of the ASCII * characters instead of the characters themselves. This is encoding * independent. */ var _GIF87a = [7]uint8{ 0: uint8(0x47), 1: uint8(0x49), 2: uint8(0x46), 3: uint8(0x38), 4: uint8(0x37), 5: uint8(0x61), } var _GIF89a = [7]uint8{ 0: uint8(0x47), 1: uint8(0x49), 2: uint8(0x46), 3: uint8(0x38), 4: uint8(0x39), 5: uint8(0x61), } /* * Flags used to notify that we've got inline data instead of a file to read * from. Note that we need to figure out which type of inline data we've got * before handing off to the GIF reading code; this is done in StringReadGIF. */ /* * HACK ALERT!! HACK ALERT!! HACK ALERT!! * This code is hard-wired for reading from files. In order to read from a * data stream, we'll trick fread so we can reuse the same code. 0==from file; * 1==from base64 encoded data; 2==from binary data */ type TGIFImageConfig = struct { FfromData uintptr FworkingBuffer [280]uint8 Freader struct { Fbytes int32 Fdone int32 Fwindow uint32 FbitsInWindow int32 Fc uintptr } } func init() { p := unsafe.Pointer(&XtkImgFmtGIF) *(*uintptr)(unsafe.Add(p, 8)) = __ccgo_fp(_FileMatchGIF) *(*uintptr)(unsafe.Add(p, 16)) = __ccgo_fp(_StringMatchGIF) *(*uintptr)(unsafe.Add(p, 24)) = __ccgo_fp(_FileReadGIF) *(*uintptr)(unsafe.Add(p, 32)) = __ccgo_fp(_StringReadGIF) *(*uintptr)(unsafe.Add(p, 40)) = __ccgo_fp(_FileWriteGIF) *(*uintptr)(unsafe.Add(p, 48)) = __ccgo_fp(_StringWriteGIF) } /* * Types, defines and variables needed to write and compress a GIF. */ type TGifWriterState = struct { Fssize int32 Fcsize int32 Frsize int32 FpixelOffset uintptr FpixelSize int32 FpixelPitch int32 FgreenOffset int32 FblueOffset int32 FalphaOffset int32 Fnum int32 Fmapa [256][3]uint8 } type Tifunptr = uintptr /* * Support for compression of GIFs. */ type TGIFState_t = struct { FnumBits int32 FmaxCode int64 FhashTable [5003]int32 FcodeTable [5003]uint32 FhSize int64 FfreeEntry int32 FclearFlag int32 Foffset int32 FinCount uint32 FoutCount uint32 FinitialBits int32 Fdestination uintptr FwriteProc uintptr FclearCode int32 FeofCode int32 FcurrentAccumulated uint64 FcurrentBits int32 FaccumulatedByteCount int32 FpacketAccumulator [256]uint8 } /* *---------------------------------------------------------------------- * * FileMatchGIF -- * * This function is invoked by the photo image type to see if a file * contains image data in GIF format. * * Results: * The return value is 1 if the first characters in file f look like GIF * data, and 0 otherwise. * * Side effects: * The access position in f may change. * *---------------------------------------------------------------------- */ func _FileMatchGIF(tls *libc.TLS, dummy373 uintptr, chan1 TTcl_Channel, dummy375 uintptr, dummy376 uintptr, dummy377 uintptr, widthPtr uintptr, heightPtr uintptr, dummy381 uintptr) (r int32) { bp := tls.Alloc(320) defer tls.Free(320) /* metadata return dict, may be NULL */ var _ /* gifConf at bp+0 */ TGIFImageConfig libc.Xmemset(tls, bp, 0, uint64(312)) return _ReadGIFHeader(tls, bp, chan1, widthPtr, heightPtr) } /* *---------------------------------------------------------------------- * * FileReadGIF -- * * This function is called by the photo image type to read GIF format * data from a file and write it into a given photo image. * * Results: * A standard TCL completion code. If TCL_ERROR is returned then an error * message is left in the interp's result. * * Side effects: * The access position in file f is changed, and new data is added to the * image given by imageHandle. * *---------------------------------------------------------------------- */ func _FileReadGIF(tls *libc.TLS, interp uintptr, chan1 TTcl_Channel, fileName uintptr, format uintptr, dummy414 uintptr, imageHandle TTk_PhotoHandle, destX int32, destY int32, width int32, height int32, srcX int32, srcY int32, metadataOutObj uintptr) (r int32) { bp := tls.Alloc(1616) defer tls.Free(1616) /* metadata return dict, may be NULL */ var bitPixel, gifLabel, imageHeight, imageWidth, result, transparent, v3, v4, v5, v6, v7, v8, v9 int32 var gifConfPtr, pixelPtr, trashBuffer uintptr var i, v2 TTcl_Size var nBytes uint32 var _ /* argc at bp+16 */ TTcl_Size var _ /* block at bp+1496 */ TTk_PhotoImageBlock var _ /* buf at bp+32 */ [100]uint8 var _ /* colorMap at bp+132 */ [256][4]uint8 var _ /* fileHeight at bp+4 */ int32 var _ /* fileWidth at bp+0 */ int32 var _ /* gifConf at bp+1176 */ TGIFImageConfig var _ /* gifGraphicControlExtensionBlock at bp+1156 */ TGIFGraphicControlExtensionBlock var _ /* index at bp+8 */ int32 var _ /* itemList at bp+1536 */ [4]uintptr var _ /* objv at bp+24 */ uintptr var _ /* optionIdx at bp+1488 */ int32 _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = bitPixel, gifConfPtr, gifLabel, i, imageHeight, imageWidth, nBytes, pixelPtr, result, transparent, trashBuffer, v2, v3, v4, v5, v6, v7, v8, v9 *(*int32)(unsafe.Pointer(bp + 8)) = 0 result = int32(TCL_ERROR) *(*TTcl_Size)(unsafe.Pointer(bp + 16)) = 0 trashBuffer = libc.UintptrFromInt32(0) gifConfPtr = bp + 1176 (*(*TGIFGraphicControlExtensionBlock)(unsafe.Pointer(bp + 1156))).FblockPresent = 0 /* * Decode the magic used to convey when we're sourcing data from a string * source and not a file. */ libc.Xmemset(tls, bp+132, 0, libc.Uint64FromInt32(libc.Int32FromInt32(MAXCOLORMAPSIZE)*libc.Int32FromInt32(4))) libc.Xmemset(tls, gifConfPtr, 0, uint64(312)) if fileName == libc.UintptrFromInt32(0x01) || fileName == libc.UintptrFromInt32(0x02) { (*TGIFImageConfig)(unsafe.Pointer(gifConfPtr)).FfromData = fileName fileName = __ccgo_ts + 33936 } /* * Parse the format string to get options. */ if format != 0 && libtcl9_0.XTcl_ListObjGetElements(tls, interp, format, bp+16, bp+24) != TCL_OK { return int32(TCL_ERROR) } i = int64(1) for { if !(i < *(*TTcl_Size)(unsafe.Pointer(bp + 16))) { break } if libtcl9_0.XTcl_GetIndexFromObjStruct(tls, interp, *(*uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 24)) + uintptr(i)*8)), uintptr(unsafe.Pointer(&_optionStrings21)), libc.Int64FromUint64(libc.Uint64FromInt64(8)), __ccgo_ts+33948, libc.Int32FromInt32(0)|libc.Int32FromUint64(libc.Uint64FromInt64(4)< *(*int32)(unsafe.Pointer(bp)) { width = *(*int32)(unsafe.Pointer(bp)) - srcX } if srcY+height > *(*int32)(unsafe.Pointer(bp + 4)) { height = *(*int32)(unsafe.Pointer(bp + 4)) - srcY } if width <= 0 || height <= 0 || srcX >= *(*int32)(unsafe.Pointer(bp)) || srcY >= *(*int32)(unsafe.Pointer(bp + 4)) { return TCL_OK } /* * Make sure we have enough space in the photo image to hold the data from * the GIF. */ if XTk_PhotoExpand(tls, interp, imageHandle, destX+width, destY+height) != TCL_OK { return int32(TCL_ERROR) } /* * ------------------------------------------------------------------------- * From here on, go to error to not leave memory leaks * ------------------------------------------------------------------------- */ /* * Search for the frame from the GIF to display. */ for int32(1) != 0 { v3 = _ReadOneByte(tls, interp, gifConfPtr, chan1) gifLabel = v3 if -int32(1) == v3 { goto error } switch gifLabel { case int32(GIF_TERMINATOR): libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+34168, int64(-libc.Int32FromInt32(1)))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+1576, __ccgo_ts+179, __ccgo_ts+29667, __ccgo_ts+33991, __ccgo_ts+34197, libc.UintptrFromInt32(0))) goto error case int32(GIF_EXTENSION): /* * This is a GIF extension. */ v4 = _ReadOneByte(tls, interp, gifConfPtr, chan1) gifLabel = v4 if -int32(1) == v4 { goto error } if _DoExtension(tls, gifConfPtr, chan1, gifLabel, gifConfPtr+8, bp+1156, metadataOutObj) < 0 { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+34205, int64(-libc.Int32FromInt32(1)))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+1576, __ccgo_ts+179, __ccgo_ts+29667, __ccgo_ts+33991, __ccgo_ts+34242, libc.UintptrFromInt32(0))) goto error } continue case int32(GIF_START): if _Fread(tls, gifConfPtr, bp+32, int64(1), int64(9), chan1) != int64(9) { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+34250, int64(-int32(1)))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+1576, __ccgo_ts+179, __ccgo_ts+29667, __ccgo_ts+33991, __ccgo_ts+34299, libc.UintptrFromInt32(0))) goto error } default: /* * Not a valid start character; ignore it. */ continue } /* * We've read the header for a GIF frame. Work out what we are going * to do about it. */ imageWidth = libc.Int32FromUint8((*(*[100]uint8)(unsafe.Pointer(bp + 32)))[int32(5)])< libc.Int32FromUint32(libc.Uint32FromUint32(0xffffffff)/libc.Uint32FromInt32(3)/libc.Uint32FromInt32(*(*int32)(unsafe.Pointer(bp + 4)))) { goto error } nBytes = libc.Uint32FromInt32(*(*int32)(unsafe.Pointer(bp)) * *(*int32)(unsafe.Pointer(bp + 4)) * int32(3)) trashBuffer = libtcl9_0.XTcl_Alloc(tls, uint64(nBytes)) if trashBuffer != 0 { libc.Xmemset(tls, trashBuffer, 0, uint64(nBytes)) } } /* * Slurp! Process the data for this image and stuff it in a trash * buffer. * * Yes, it might be more efficient here to *not* store the data * (we're just going to throw it away later). However, I elected * to implement it this way for good reasons. First, I wanted to * avoid duplicating the (fairly complex) LWZ decoder in * ReadImage. Fine, you say, why didn't you just modify it to * allow the use of a NULL specifier for the output buffer? I * tried that, but it negatively impacted the performance of what * I think will be the common case: reading the first image in the * file. Rather than marginally improve the speed of the less * frequent case, I chose to maintain high performance for the * common case. */ if _ReadImage(tls, gifConfPtr, interp, trashBuffer, chan1, imageWidth, imageHeight, bp+132, 0, 0, 0, -int32(1)) != TCL_OK { goto error } /* * This extension starts a new scope, so Graphic control Extension * data should be cleared */ (*(*TGIFGraphicControlExtensionBlock)(unsafe.Pointer(bp + 1156))).FblockPresent = 0 continue } break } /* * Found the frame we want to read. Next, check for a local color map for * this frame. */ if libc.Int32FromUint8((*(*[100]uint8)(unsafe.Pointer(bp + 32)))[int32(8)])&int32(LOCALCOLORMAP) == int32(LOCALCOLORMAP) { if !(_ReadColorMap(tls, gifConfPtr, chan1, bitPixel, bp+132) != 0) { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+34134, int64(-libc.Int32FromInt32(1)))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+1576, __ccgo_ts+179, __ccgo_ts+29667, __ccgo_ts+33991, __ccgo_ts+34158, libc.UintptrFromInt32(0))) goto error } } /* * Extract the location within the overall visible image to put the data * in this frame, together with the size of this frame. */ *(*int32)(unsafe.Pointer(bp + 8)) = libc.Int32FromUint8((*(*[100]uint8)(unsafe.Pointer(bp + 32)))[int32(1)])< imageWidth { width = imageWidth } *(*int32)(unsafe.Pointer(bp + 8)) = libc.Int32FromUint8((*(*[100]uint8)(unsafe.Pointer(bp + 32)))[int32(3)])< srcY { destY -= srcY height += srcY srcY = 0 } if height > imageHeight { height = imageHeight } if width > 0 && height > 0 { transparent = -int32(1) if (*(*TGIFGraphicControlExtensionBlock)(unsafe.Pointer(bp + 1156))).FblockPresent != 0 { transparent = (*(*TGIFGraphicControlExtensionBlock)(unsafe.Pointer(bp + 1156))).Ftransparent } /* * Read the data and put it into the photo buffer for display by the * general image machinery. */ (*(*TTk_PhotoImageBlock)(unsafe.Pointer(bp + 1496))).Fwidth = width (*(*TTk_PhotoImageBlock)(unsafe.Pointer(bp + 1496))).Fheight = height if transparent >= 0 { v6 = int32(4) } else { v6 = int32(3) } (*(*TTk_PhotoImageBlock)(unsafe.Pointer(bp + 1496))).FpixelSize = v6 *(*int32)(unsafe.Pointer(bp + 1496 + 24)) = 0 *(*int32)(unsafe.Pointer(bp + 1496 + 24 + 1*4)) = int32(1) *(*int32)(unsafe.Pointer(bp + 1496 + 24 + 2*4)) = int32(2) if transparent >= 0 { v7 = int32(3) } else { v7 = 0 } *(*int32)(unsafe.Pointer(bp + 1496 + 24 + 3*4)) = v7 if imageWidth > int32(INT_MAX)/(*(*TTk_PhotoImageBlock)(unsafe.Pointer(bp + 1496))).FpixelSize { goto error } (*(*TTk_PhotoImageBlock)(unsafe.Pointer(bp + 1496))).Fpitch = (*(*TTk_PhotoImageBlock)(unsafe.Pointer(bp + 1496))).FpixelSize * imageWidth if imageHeight > libc.Int32FromUint32(libc.Uint32FromUint32(0xffffffff)/libc.Uint32FromInt32((*(*TTk_PhotoImageBlock)(unsafe.Pointer(bp + 1496))).Fpitch)) { goto error } nBytes = libc.Uint32FromInt32((*(*TTk_PhotoImageBlock)(unsafe.Pointer(bp + 1496))).Fpitch * imageHeight) pixelPtr = libtcl9_0.XTcl_Alloc(tls, uint64(nBytes)) if pixelPtr != 0 { libc.Xmemset(tls, pixelPtr, 0, uint64(nBytes)) } (*(*TTk_PhotoImageBlock)(unsafe.Pointer(bp + 1496))).FpixelPtr = pixelPtr if _ReadImage(tls, gifConfPtr, interp, (*(*TTk_PhotoImageBlock)(unsafe.Pointer(bp + 1496))).FpixelPtr, chan1, imageWidth, imageHeight, bp+132, srcX, srcY, libc.BoolInt32(libc.Int32FromUint8((*(*[100]uint8)(unsafe.Pointer(bp + 32)))[int32(8)])&int32(INTERLACE) == int32(INTERLACE)), transparent) != TCL_OK { libtcl9_0.XTcl_Free(tls, pixelPtr) goto error } (*(*TTk_PhotoImageBlock)(unsafe.Pointer(bp + 1496))).FpixelPtr += uintptr(srcX*(*(*TTk_PhotoImageBlock)(unsafe.Pointer(bp + 1496))).FpixelSize + srcY*(*(*TTk_PhotoImageBlock)(unsafe.Pointer(bp + 1496))).Fpitch) if XTk_PhotoPutBlock(tls, interp, imageHandle, bp+1496, destX, destY, width, height, int32(TK_PHOTO_COMPOSITE_SET)) != TCL_OK { libtcl9_0.XTcl_Free(tls, pixelPtr) goto error } libtcl9_0.XTcl_Free(tls, pixelPtr) } /* * Update the metadata dictionary with current image data */ if libc.UintptrFromInt32(0) != metadataOutObj { /* * Save the update box, if not the whole image */ if width != *(*int32)(unsafe.Pointer(bp)) || height != *(*int32)(unsafe.Pointer(bp + 4)) { (*(*[4]uintptr)(unsafe.Pointer(bp + 1536)))[0] = libtcl9_0.XTcl_NewWideIntObj(tls, int64(destX)) (*(*[4]uintptr)(unsafe.Pointer(bp + 1536)))[int32(1)] = libtcl9_0.XTcl_NewWideIntObj(tls, int64(destY)) (*(*[4]uintptr)(unsafe.Pointer(bp + 1536)))[int32(2)] = libtcl9_0.XTcl_NewWideIntObj(tls, int64(width)) (*(*[4]uintptr)(unsafe.Pointer(bp + 1536)))[int32(3)] = libtcl9_0.XTcl_NewWideIntObj(tls, int64(height)) if TCL_OK != libtcl9_0.XTcl_DictObjPut(tls, interp, metadataOutObj, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+34310, int64(-int32(1))), libtcl9_0.XTcl_NewListObj(tls, int64(4), bp+1536)) { result = int32(TCL_ERROR) goto error } } /* * Copy the Graphic Control Extension Block data to the metadata * dictionary */ if (*(*TGIFGraphicControlExtensionBlock)(unsafe.Pointer(bp + 1156))).FblockPresent != 0 { if (*(*TGIFGraphicControlExtensionBlock)(unsafe.Pointer(bp + 1156))).FdelayTime != 0 { if TCL_OK != libtcl9_0.XTcl_DictObjPut(tls, interp, metadataOutObj, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+34324, int64(-int32(1))), libtcl9_0.XTcl_NewWideIntObj(tls, int64((*(*TGIFGraphicControlExtensionBlock)(unsafe.Pointer(bp + 1156))).FdelayTime))) { result = int32(TCL_ERROR) goto error } } switch (*(*TGIFGraphicControlExtensionBlock)(unsafe.Pointer(bp + 1156))).FdisposalMethod { case int32(1): /* Do not dispose */ if TCL_OK != libtcl9_0.XTcl_DictObjPut(tls, interp, metadataOutObj, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+34335, int64(-int32(1))), libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+34351, int64(-int32(1)))) { result = int32(TCL_ERROR) goto error } case int32(2): /* Restore to background color */ if TCL_OK != libtcl9_0.XTcl_DictObjPut(tls, interp, metadataOutObj, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+34335, int64(-int32(1))), libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+34366, int64(-int32(1)))) { result = int32(TCL_ERROR) goto error } case int32(3): /* Restore to previous */ if TCL_OK != libtcl9_0.XTcl_DictObjPut(tls, interp, metadataOutObj, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+34335, int64(-int32(1))), libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+34394, int64(-int32(1)))) { result = int32(TCL_ERROR) goto error } break } if (*(*TGIFGraphicControlExtensionBlock)(unsafe.Pointer(bp + 1156))).FuserInteraction != 0 { if TCL_OK != libtcl9_0.XTcl_DictObjPut(tls, interp, metadataOutObj, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+34414, int64(-int32(1))), libtcl9_0.XTcl_NewWideIntObj(tls, libc.BoolInt64(int32(1) != 0))) { result = int32(TCL_ERROR) goto error } } } } /* * We've successfully read the GIF frame (or there was nothing to read, * which suits as well). We're done. */ for int32(1) != 0 { v8 = _ReadOneByte(tls, interp, gifConfPtr, chan1) gifLabel = v8 if -int32(1) == v8 { goto error } switch gifLabel { case int32(GIF_TERMINATOR): case int32(GIF_EXTENSION): /* * This is a GIF extension. */ v9 = _ReadOneByte(tls, interp, gifConfPtr, chan1) gifLabel = v9 if -int32(1) == v9 { goto error } if _DoExtension(tls, gifConfPtr, chan1, gifLabel, gifConfPtr+8, bp+1156, metadataOutObj) < 0 { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+34205, int64(-libc.Int32FromInt32(1)))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+1576, __ccgo_ts+179, __ccgo_ts+29667, __ccgo_ts+33991, __ccgo_ts+34242, libc.UintptrFromInt32(0))) goto error } continue case int32(GIF_START): /* * There should not be a second image block - bail out without error */ default: /* * Not a valid start character; ignore it. */ continue } break } libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewStringObj(tls, XtkImgFmtGIF.Fname, int64(-libc.Int32FromInt32(1)))) result = TCL_OK goto error error: ; /* * If a trash buffer has been allocated, free it now. */ if trashBuffer != libc.UintptrFromInt32(0) { libtcl9_0.XTcl_Free(tls, trashBuffer) } return result } var _optionStrings21 = [2]uintptr{ 0: __ccgo_ts + 33929, 1: libc.UintptrFromInt32(0), } /* *---------------------------------------------------------------------- * * Read one Byte -- * * Read one byte (label byte) from the image stream. * * Results: * The return value is 1 if the first characters in the data are like GIF * data, and 0 otherwise. * * Side effects: * The access position in the source is incremented. * *---------------------------------------------------------------------- */ func _ReadOneByte(tls *libc.TLS, interp uintptr, gifConfPtr uintptr, chan1 TTcl_Channel) (r int32) { bp := tls.Alloc(64) defer tls.Free(64) var _ /* buf at bp+0 */ [2]uint8 if _Fread(tls, gifConfPtr, bp, int64(1), int64(1), chan1) != int64(1) { /* * Premature end of image. */ libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+34431, int64(-libc.Int32FromInt32(1)))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+16, __ccgo_ts+179, __ccgo_ts+29667, __ccgo_ts+33991, __ccgo_ts+34459, libc.UintptrFromInt32(0))) return -int32(1) } return libc.Int32FromUint8((*(*[2]uint8)(unsafe.Pointer(bp)))[0]) } /* *---------------------------------------------------------------------- * * StringMatchGIF -- * * This function is invoked by the photo image type to see if an object * contains image data in GIF format. * * Results: * The return value is 1 if the first characters in the data are like GIF * data, and 0 otherwise. * * Side effects: * The size of the image is placed in widthPtr and heightPtr. * *---------------------------------------------------------------------- */ func _StringMatchGIF(tls *libc.TLS, dummy965 uintptr, dataObj uintptr, dummy967 uintptr, dummy968 uintptr, widthPtr uintptr, heightPtr uintptr, dummy971 uintptr) (r int32) { bp := tls.Alloc(48) defer tls.Free(48) /* metadata return dict, may be NULL */ var data uintptr var got TTcl_Size var _ /* handle at bp+24 */ TMFile var _ /* header at bp+0 */ [10]uint8 var _ /* length at bp+16 */ TTcl_Size _, _ = data, got data = libtcl9_0.XTcl_GetBytesFromObj(tls, libc.UintptrFromInt32(0), dataObj, bp+16) /* * Header is a minimum of 10 bytes. */ if *(*TTcl_Size)(unsafe.Pointer(bp + 16)) < int64(10) { return 0 } /* * Check whether the data is Base64 encoded. */ if libc.Xstrncmp(tls, uintptr(unsafe.Pointer(&_GIF87a)), data, uint64(6)) != 0 && libc.Xstrncmp(tls, uintptr(unsafe.Pointer(&_GIF89a)), data, uint64(6)) != 0 { /* * Try interpreting the data as Base64 encoded */ _mInit(tls, data, bp+24, *(*TTcl_Size)(unsafe.Pointer(bp + 16))) got = _Mread(tls, bp, int64(10), int64(1), bp+24) if got != int64(10) || libc.Xstrncmp(tls, uintptr(unsafe.Pointer(&_GIF87a)), bp, uint64(6)) != 0 && libc.Xstrncmp(tls, uintptr(unsafe.Pointer(&_GIF89a)), bp, uint64(6)) != 0 { return 0 } } else { libc.Xmemcpy(tls, bp, data, uint64(10)) } *(*int32)(unsafe.Pointer(widthPtr)) = libc.Int32FromUint8((*(*[10]uint8)(unsafe.Pointer(bp)))[int32(7)])<= 0 ok * * Side effects: * The gifGraphicControlExtensionBlock is set if present in current * extensions * The data of the following extensions are saved to the metadata dict: * - Application extension * - Comment extension in key "comment" * Plain text extensions are currently ignored. * *---------------------------------------------------------------------- */ func _DoExtension(tls *libc.TLS, gifConfPtr uintptr, chan1 TTcl_Channel, label int32, buf uintptr, gifGraphicControlExtensionBlock uintptr, metadataOutObj uintptr) (r int32) { bp := tls.Alloc(16) defer tls.Free(16) var ValueObj, bytePtr uintptr var count, length int32 var _ /* extensionStreamName at bp+0 */ [8]uint8 _, _, _, _ = ValueObj, bytePtr, count, length (*(*[8]uint8)(unsafe.Pointer(bp)))[0] = uint8('\000') switch label { case int32(0x01): /* Plain Text Extension */ /* * This extension starts a new scope, so Graphic control Extension * data should be cleared */ (*TGIFGraphicControlExtensionBlock)(unsafe.Pointer(gifGraphicControlExtensionBlock)).FblockPresent = 0 /* this extension is ignored, skip below */ case int32(0xf9): /* Graphic Control Extension */ count = _GetDataBlock(tls, gifConfPtr, chan1, buf) if count < 0 { return -int32(1) } (*TGIFGraphicControlExtensionBlock)(unsafe.Pointer(gifGraphicControlExtensionBlock)).FblockPresent = int32(1) /* save disposal method */ (*TGIFGraphicControlExtensionBlock)(unsafe.Pointer(gifGraphicControlExtensionBlock)).FdisposalMethod = libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(buf))) & int32(0x1C) >> int32(2) /* save disposal method */ (*TGIFGraphicControlExtensionBlock)(unsafe.Pointer(gifGraphicControlExtensionBlock)).FuserInteraction = libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(buf))) & int32(2) >> int32(1) /* save delay time */ (*TGIFGraphicControlExtensionBlock)(unsafe.Pointer(gifGraphicControlExtensionBlock)).FdelayTime = libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(buf + 2)))< 0 { if TCL_OK != libtcl9_0.XTcl_DictObjPut(tls, libc.UintptrFromInt32(0), metadataOutObj, libtcl9_0.XTcl_NewByteArrayObj(tls, bp, libc.Int64FromUint64(libc.Xstrlen(tls, bp))), ValueObj) { return -int32(1) } } /* return success */ return 0 default: /* block received */ if length == 0 { /* first block */ ValueObj = libtcl9_0.XTcl_NewByteArrayObj(tls, buf, int64(count)) length = count } else { bytePtr = libtcl9_0.XTcl_SetByteArrayLength(tls, ValueObj, int64(length+count)) libc.Xmemcpy(tls, bytePtr+uintptr(length), buf, libc.Uint64FromInt32(count)) length += count } break } goto _1 _1: } /* for */ } /* skip eventual remaining data block bytes */ for cond := true; cond; cond = count > 0 { count = _GetDataBlock(tls, gifConfPtr, chan1, buf) } return count /* this may be -1 for error or 0 */ } func _GetDataBlock(tls *libc.TLS, gifConfPtr uintptr, chan1 TTcl_Channel, buf uintptr) (r int32) { bp := tls.Alloc(16) defer tls.Free(16) var _ /* count at bp+0 */ uint8 if _Fread(tls, gifConfPtr, bp, int64(1), int64(1), chan1) <= 0 { return -int32(1) } if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(bp))) != 0 && _Fread(tls, gifConfPtr, buf, libc.Int64FromUint8(*(*uint8)(unsafe.Pointer(bp))), int64(1), chan1) <= 0 { return -int32(1) } return libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(bp))) } /* *---------------------------------------------------------------------- * * ReadImage -- * * Process a GIF image from a given source, with a given height, width, * transparency, etc. * * This code is based on the code found in the ImageMagick GIF decoder, * which is © 2000 ImageMagick Studio. * * Some thoughts on our implementation: * It sure would be nice if ReadImage didn't take 11 parameters! I think * that if we were smarter, we could avoid doing that. * * Possible further optimizations: we could pull the GetCode function * directly into ReadImage, which would improve our speed. * * Results: * Processes a GIF image and loads the pixel data into a memory array. * * Side effects: * None. * *---------------------------------------------------------------------- */ func _ReadImage(tls *libc.TLS, gifConfPtr uintptr, interp uintptr, imagePtr uintptr, chan1 TTcl_Channel, len1 int32, rows int32, cmap uintptr, dummy1322 int32, dummy1323 int32, interlace int32, transparent int32) (r int32) { bp := tls.Alloc(20544) defer tls.Free(20544) var clearCode, code, codeSize, count, endCode, firstCode, i, inCode, maxCode, oldCode, pass, v, xpos, ypos, v13, v14 int32 var pixelPtr, top, v10, v11, v12, v4, v5, v6, v7, v8, v9 uintptr var _ /* append at bp+8194 */ [4096]uint8 var _ /* initialCodeSize at bp+0 */ uint8 var _ /* prefix at bp+2 */ [4096]uint16 var _ /* stack at bp+12290 */ [8192]uint8 _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = clearCode, code, codeSize, count, endCode, firstCode, i, inCode, maxCode, oldCode, pass, pixelPtr, top, v, xpos, ypos, v10, v11, v12, v13, v14, v4, v5, v6, v7, v8, v9 xpos = 0 ypos = 0 pass = 0 /* * Initialize the decoder */ if _Fread(tls, gifConfPtr, bp, int64(1), int64(1), chan1) <= 0 { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+34481, libc.VaList(bp+20496, libtcl9_0.XTcl_PosixError(tls, interp)))) return int32(TCL_ERROR) } if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(bp))) > int32(MAX_LWZ_BITS) { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+34509, int64(-libc.Int32FromInt32(1)))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+20496, __ccgo_ts+179, __ccgo_ts+29667, __ccgo_ts+33991, __ccgo_ts+3419, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) } if transparent != -int32(1) { *(*uint8)(unsafe.Pointer(cmap + uintptr(transparent)*4)) = uint8(0) *(*uint8)(unsafe.Pointer(cmap + uintptr(transparent)*4 + 1)) = uint8(0) *(*uint8)(unsafe.Pointer(cmap + uintptr(transparent)*4 + 2)) = uint8(0) *(*uint8)(unsafe.Pointer(cmap + uintptr(transparent)*4 + 3)) = uint8(0) } pixelPtr = imagePtr /* * Initialize the decoder. * * Set values for "special" numbers: * clear code reset the decoder * end code stop decoding * code size size of the next code to retrieve * max code next available table position */ clearCode = int32(1) << libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(bp))) endCode = clearCode + int32(1) codeSize = libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(bp))) + int32(1) maxCode = clearCode + int32(2) oldCode = -int32(1) firstCode = -int32(1) libc.Xmemset(tls, bp+2, 0, libc.Uint64FromInt32(libc.Int32FromInt32(1)< maxCode || code == endCode { /* * If we're doing things right, we should never receive a * code that is greater than our current maximum code. If * we do, bail, because our decoder does not yet have that * code set up. * * If the code is the magic endCode value, quit. */ return TCL_OK } if code == clearCode { /* * Reset the decoder. */ codeSize = libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(bp))) + int32(1) maxCode = clearCode + int32(2) oldCode = -int32(1) goto _3 } if oldCode == -int32(1) { /* * Last pass reset the decoder, so the first code we see * must be a singleton. Seed the stack with it, and set up * the old/first code pointers for insertion into the * codes table. We can't just roll this into the clearCode * test above, because at that point we have not yet read * the next code. */ v4 = top top++ *(*uint8)(unsafe.Pointer(v4)) = (*(*[4096]uint8)(unsafe.Pointer(bp + 8194)))[code] oldCode = code firstCode = code goto _3 } inCode = code if code == maxCode && maxCode < libc.Int32FromInt32(1)< clearCode { /* * Populate the stack by tracing the code in the codes * table from its tail to its head */ v6 = top top++ *(*uint8)(unsafe.Pointer(v6)) = (*(*[4096]uint8)(unsafe.Pointer(bp + 8194)))[code] code = libc.Int32FromUint16((*(*[4096]uint16)(unsafe.Pointer(bp + 2)))[code]) } firstCode = libc.Int32FromUint8((*(*[4096]uint8)(unsafe.Pointer(bp + 8194)))[code]) /* * Push the head of the code onto the stack. */ v7 = top top++ *(*uint8)(unsafe.Pointer(v7)) = libc.Uint8FromInt32(firstCode) if maxCode < libc.Int32FromInt32(1)<= int32(1)<= 0 { v12 = pixelPtr pixelPtr++ *(*uint8)(unsafe.Pointer(v12)) = *(*uint8)(unsafe.Pointer(cmap + uintptr(v)*4 + 3)) } xpos++ goto _3 _3: } /* * If interlacing, the next ypos is not just +1. */ if interlace != 0 { ypos += _interlaceStep[pass] for ypos >= rows { pass++ if pass > int32(3) { return TCL_OK } ypos = _interlaceStart[pass] } } else { ypos++ } if transparent >= 0 { v13 = int32(4) } else { v13 = int32(3) } pixelPtr = imagePtr + uintptr(ypos*len1*v13) goto _2 _2: ; i++ } /* * Now read until the final zero byte. * It was observed that there might be 1 length blocks * (test imgPhoto-14.1) which are not read. * * The field "stack" is abused for temporary buffer. it has 4096 bytes * and we need 256. * * Loop until we hit a 0 length block which is the end sign. */ for { v14 = _GetDataBlock(tls, gifConfPtr, chan1, bp+12290) count = v14 if !(0 < v14) { break } if -int32(1) == count { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+34481, libc.VaList(bp+20496, libtcl9_0.XTcl_PosixError(tls, interp)))) return int32(TCL_ERROR) } } return TCL_OK } var _interlaceStep = [4]int32{ 0: int32(8), 1: int32(8), 2: int32(4), 3: int32(2), } var _interlaceStart = [4]int32{ 1: int32(4), 2: int32(2), 3: int32(1), } /* *---------------------------------------------------------------------- * * GetCode -- * * Extract the next compression code from the file. In GIF's, the * compression codes are between 3 and 12 bits long and are then packed * into 8 bit bytes, left to right, for example: * bbbaaaaa * dcccccbb * eeeedddd * ... * We use a byte buffer read from the file and a sliding window to unpack * the bytes. Thanks to ImageMagick for the sliding window idea. * args: chan the channel to read from * code_size size of the code to extract * flag boolean indicating whether the extractor should be * reset or not * * Results: * code the next compression code * * Side effects: * May consume more input from chan. * *---------------------------------------------------------------------- */ func _GetCode(tls *libc.TLS, chan1 TTcl_Channel, code_size int32, flag int32, gifConfPtr uintptr) (r int32) { var ret int32 _ = ret if flag != 0 { /* * Initialize the decoder. */ (*TGIFImageConfig)(unsafe.Pointer(gifConfPtr)).Freader.FbitsInWindow = 0 (*TGIFImageConfig)(unsafe.Pointer(gifConfPtr)).Freader.Fbytes = 0 (*TGIFImageConfig)(unsafe.Pointer(gifConfPtr)).Freader.Fwindow = uint32(0) (*TGIFImageConfig)(unsafe.Pointer(gifConfPtr)).Freader.Fdone = 0 (*TGIFImageConfig)(unsafe.Pointer(gifConfPtr)).Freader.Fc = libc.UintptrFromInt32(0) return 0 } for (*TGIFImageConfig)(unsafe.Pointer(gifConfPtr)).Freader.FbitsInWindow < code_size { /* * Not enough bits in our window to cover the request. */ if (*TGIFImageConfig)(unsafe.Pointer(gifConfPtr)).Freader.Fdone != 0 { return -int32(1) } if (*TGIFImageConfig)(unsafe.Pointer(gifConfPtr)).Freader.Fbytes == 0 { /* * Not enough bytes in our buffer to add to the window. */ (*TGIFImageConfig)(unsafe.Pointer(gifConfPtr)).Freader.Fbytes = _GetDataBlock(tls, gifConfPtr, chan1, gifConfPtr+8) (*TGIFImageConfig)(unsafe.Pointer(gifConfPtr)).Freader.Fc = gifConfPtr + 8 if (*TGIFImageConfig)(unsafe.Pointer(gifConfPtr)).Freader.Fbytes <= 0 { (*TGIFImageConfig)(unsafe.Pointer(gifConfPtr)).Freader.Fdone = int32(1) break } } /* * Tack another byte onto the window, see if that's enough. */ (*TGIFImageConfig)(unsafe.Pointer(gifConfPtr)).Freader.Fwindow += libc.Uint32FromInt32(libc.Int32FromUint8(*(*uint8)(unsafe.Pointer((*TGIFImageConfig)(unsafe.Pointer(gifConfPtr)).Freader.Fc))) << (*TGIFImageConfig)(unsafe.Pointer(gifConfPtr)).Freader.FbitsInWindow) (*TGIFImageConfig)(unsafe.Pointer(gifConfPtr)).Freader.Fc++ (*TGIFImageConfig)(unsafe.Pointer(gifConfPtr)).Freader.FbitsInWindow += int32(8) (*TGIFImageConfig)(unsafe.Pointer(gifConfPtr)).Freader.Fbytes-- } /* * The next code will always be the last code_size bits of the window. */ ret = libc.Int32FromUint32((*TGIFImageConfig)(unsafe.Pointer(gifConfPtr)).Freader.Fwindow & libc.Uint32FromInt32(libc.Int32FromInt32(1)<>= libc.Uint32FromInt32(code_size) (*TGIFImageConfig)(unsafe.Pointer(gifConfPtr)).Freader.FbitsInWindow -= code_size return ret } /* *---------------------------------------------------------------------- * * Minit -- -- * * This function initializes a base64 decoder handle * * Results: * None * * Side effects: * The base64 handle is initialized * *---------------------------------------------------------------------- */ func _mInit(tls *libc.TLS, string1 uintptr, handle uintptr, length TTcl_Size) { /* Number of bytes in string */ (*TMFile)(unsafe.Pointer(handle)).Fdata = string1 (*TMFile)(unsafe.Pointer(handle)).Fstate = 0 (*TMFile)(unsafe.Pointer(handle)).Fc = 0 (*TMFile)(unsafe.Pointer(handle)).Flength = length } /* *---------------------------------------------------------------------- * * Mread -- * * This function is invoked by the GIF file reader as a temporary * replacement for "fread", to get GIF data out of a string (using * Mgetc). * * Results: * The return value is the number of characters "read" * * Side effects: * The base64 handle will change state. * *---------------------------------------------------------------------- */ func _Mread(tls *libc.TLS, dst uintptr, chunkSize TTcl_Size, numChunks TTcl_Size, handle uintptr) (r TTcl_Size) { /* mmdecode "file" handle */ var c, v2 int32 var count, i TTcl_Size var v3 bool var v4 uintptr _, _, _, _, _, _ = c, count, i, v2, v3, v4 count = chunkSize * numChunks i = 0 for { if v3 = i < count; v3 { v2 = _Mgetc(tls, handle) c = v2 } if !(v3 && v2 != libc.Int32FromInt32(GIF_SPECIAL)+libc.Int32FromInt32(4)) { break } v4 = dst dst++ *(*uint8)(unsafe.Pointer(v4)) = libc.Uint8FromInt32(c) goto _1 _1: ; i++ } return i } /* *---------------------------------------------------------------------- * * Mgetc -- * * This function gets the next decoded character from an mmencode handle. * This causes at least 1 character to be "read" from the encoded string. * * Results: * The next byte (or GIF_DONE) is returned. * * Side effects: * The base64 handle will change state. * *---------------------------------------------------------------------- */ func _Mgetc(tls *libc.TLS, handle uintptr) (r int32) { /* Handle containing decoder data and state */ var c, result, v3 int32 var v1 TTcl_Size var v2, v4 uintptr _, _, _, _, _, _ = c, result, v1, v2, v3, v4 result = 0 /* Initialization needed only to prevent gcc * compiler warning. */ if (*TMFile)(unsafe.Pointer(handle)).Fstate == libc.Int32FromInt32(GIF_SPECIAL)+libc.Int32FromInt32(4) { return libc.Int32FromInt32(GIF_SPECIAL) + libc.Int32FromInt32(4) } for cond := true; cond; cond = c == libc.Int32FromInt32(GIF_SPECIAL)+libc.Int32FromInt32(2) { v2 = handle + 16 v1 = *(*TTcl_Size)(unsafe.Pointer(v2)) *(*TTcl_Size)(unsafe.Pointer(v2))-- if v1 <= 0 { return libc.Int32FromInt32(GIF_SPECIAL) + libc.Int32FromInt32(4) } c = _char64(tls, libc.Int32FromUint8(*(*uint8)(unsafe.Pointer((*TMFile)(unsafe.Pointer(handle)).Fdata)))) (*TMFile)(unsafe.Pointer(handle)).Fdata++ } if c > int32(GIF_SPECIAL) { (*TMFile)(unsafe.Pointer(handle)).Fstate = libc.Int32FromInt32(GIF_SPECIAL) + libc.Int32FromInt32(4) return (*TMFile)(unsafe.Pointer(handle)).Fc } v4 = handle + 12 v3 = *(*int32)(unsafe.Pointer(v4)) *(*int32)(unsafe.Pointer(v4))++ switch v3 { case 0: (*TMFile)(unsafe.Pointer(handle)).Fc = c << int32(2) result = _Mgetc(tls, handle) case int32(1): result = (*TMFile)(unsafe.Pointer(handle)).Fc | c>>int32(4) (*TMFile)(unsafe.Pointer(handle)).Fc = c & int32(0xF) << int32(4) case int32(2): result = (*TMFile)(unsafe.Pointer(handle)).Fc | c>>int32(2) (*TMFile)(unsafe.Pointer(handle)).Fc = c & int32(0x3) << int32(6) case int32(3): result = (*TMFile)(unsafe.Pointer(handle)).Fc | c (*TMFile)(unsafe.Pointer(handle)).Fstate = 0 break } return result } /* *---------------------------------------------------------------------- * * char64 -- * * This function converts a base64 ascii character into its binary * equivalent. This code is a slightly modified version of the char64 * function in N. Borenstein's metamail decoder. * * Results: * The binary value, or an error code. * * Side effects: * None. * *---------------------------------------------------------------------- */ func _char64(tls *libc.TLS, c int32) (r int32) { switch c { case int32('A'): return 0 case int32('B'): return int32(1) case int32('C'): return int32(2) case int32('D'): return int32(3) case int32('E'): return int32(4) case int32('F'): return int32(5) case int32('G'): return int32(6) case int32('H'): return int32(7) case int32('I'): return int32(8) case int32('J'): return int32(9) case int32('K'): return int32(10) case int32('L'): return int32(11) case int32('M'): return int32(12) case int32('N'): return int32(13) case int32('O'): return int32(14) case int32('P'): return int32(15) case int32('Q'): return int32(16) case int32('R'): return int32(17) case int32('S'): return int32(18) case int32('T'): return int32(19) case int32('U'): return int32(20) case int32('V'): return int32(21) case int32('W'): return int32(22) case int32('X'): return int32(23) case int32('Y'): return int32(24) case int32('Z'): return int32(25) case int32('a'): return int32(26) case int32('b'): return int32(27) case int32('c'): return int32(28) case int32('d'): return int32(29) case int32('e'): return int32(30) case int32('f'): return int32(31) case int32('g'): return int32(32) case int32('h'): return int32(33) case int32('i'): return int32(34) case int32('j'): return int32(35) case int32('k'): return int32(36) case int32('l'): return int32(37) case int32('m'): return int32(38) case int32('n'): return int32(39) case int32('o'): return int32(40) case int32('p'): return int32(41) case int32('q'): return int32(42) case int32('r'): return int32(43) case int32('s'): return int32(44) case int32('t'): return int32(45) case int32('u'): return int32(46) case int32('v'): return int32(47) case int32('w'): return int32(48) case int32('x'): return int32(49) case int32('y'): return int32(50) case int32('z'): return int32(51) case int32('0'): return int32(52) case int32('1'): return int32(53) case int32('2'): return int32(54) case int32('3'): return int32(55) case int32('4'): return int32(56) case int32('5'): return int32(57) case int32('6'): return int32(58) case int32('7'): return int32(59) case int32('8'): return int32(60) case int32('9'): return int32(61) case int32('+'): return int32(62) case int32('/'): return int32(63) case int32(' '): fallthrough case int32('\t'): fallthrough case int32('\n'): fallthrough case int32('\r'): fallthrough case int32('\f'): return libc.Int32FromInt32(GIF_SPECIAL) + libc.Int32FromInt32(2) case int32('='): return libc.Int32FromInt32(GIF_SPECIAL) + libc.Int32FromInt32(1) case int32('\000'): return libc.Int32FromInt32(GIF_SPECIAL) + libc.Int32FromInt32(4) default: return libc.Int32FromInt32(GIF_SPECIAL) + libc.Int32FromInt32(3) } return r } /* *---------------------------------------------------------------------- * * Fread -- * * This function calls either fread or Mread to read data from a file or * a base64 encoded string. * * Results: - same as POSIX fread() or Tcl Tcl_Read() * *---------------------------------------------------------------------- */ func _Fread(tls *libc.TLS, gifConfPtr uintptr, dst uintptr, hunk TTcl_Size, count TTcl_Size, chan1 TTcl_Channel) (r TTcl_Size) { var handle uintptr _ = handle if hunk < 0 || count < 0 { return int64(-int32(1)) } if (*TGIFImageConfig)(unsafe.Pointer(gifConfPtr)).FfromData == libc.UintptrFromInt32(0x02) { return _Mread(tls, dst, hunk, count, chan1) } if (*TGIFImageConfig)(unsafe.Pointer(gifConfPtr)).FfromData == libc.UintptrFromInt32(0x01) { handle = chan1 if (*TMFile)(unsafe.Pointer(handle)).Flength <= 0 || (*TMFile)(unsafe.Pointer(handle)).Flength < hunk*count { return int64(-int32(1)) } libc.Xmemcpy(tls, dst, (*TMFile)(unsafe.Pointer(handle)).Fdata, libc.Uint64FromInt64(hunk*count)) *(*uintptr)(unsafe.Pointer(handle)) += uintptr(hunk * count) *(*TTcl_Size)(unsafe.Pointer(handle + 16)) -= hunk * count return hunk * count } /* * Otherwise we've got a real file to read. */ return libtcl9_0.XTcl_Read(tls, chan1, dst, hunk*count) } /* * ChanWriteGIF - writes a image in GIF format. *------------------------------------------------------------------------- * Author: Lolo * Engeneering Projects Area * Department of Mining * University of Oviedo * e-mail zz11425958@zeus.etsimo.uniovi.es * lolo@pcsig22.etsimo.uniovi.es * Date: Fri September 20 1996 * * Modified for transparency handling (gif89a) * by Jan Nijtmans * *---------------------------------------------------------------------- * FileWriteGIF- * * This function is called by the photo image type to write GIF format * data from a photo image into a given file * * Results: * A standard TCL completion code. If TCL_ERROR is returned then an * error message is left in the interp's result. * *---------------------------------------------------------------------- */ func _FileWriteGIF(tls *libc.TLS, interp uintptr, filename uintptr, format uintptr, metadataInObj uintptr, blockPtr uintptr) (r int32) { var chan1 TTcl_Channel var result int32 _, _ = chan1, result chan1 = libc.UintptrFromInt32(0) chan1 = libtcl9_0.XTcl_OpenFileChannel(tls, interp, filename, __ccgo_ts+10954, int32(0644)) if !(chan1 != 0) { return int32(TCL_ERROR) } if libtcl9_0.XTcl_SetChannelOption(tls, interp, chan1, __ccgo_ts+8196, __ccgo_ts+33442) != TCL_OK { libtcl9_0.XTcl_CloseEx(tls, libc.UintptrFromInt32(0), chan1, 0) return int32(TCL_ERROR) } result = _CommonWriteGIF(tls, interp, chan1, __ccgo_fp(_WriteToChannel), format, metadataInObj, blockPtr) if libtcl9_0.XTcl_CloseEx(tls, interp, chan1, 0) == int32(TCL_ERROR) { return int32(TCL_ERROR) } return result } func _StringWriteGIF(tls *libc.TLS, interp uintptr, format uintptr, metadataInObj uintptr, blockPtr uintptr) (r int32) { var _objPtr, objPtr, v2 uintptr var result int32 var v1 TTcl_Size _, _, _, _, _ = _objPtr, objPtr, result, v1, v2 objPtr = libtcl9_0.XTcl_NewObj(tls) (*TTcl_Obj)(unsafe.Pointer(objPtr)).FrefCount++ result = _CommonWriteGIF(tls, interp, objPtr, __ccgo_fp(_WriteToByteArray), format, metadataInObj, blockPtr) if result == TCL_OK { libtcl9_0.XTcl_SetObjResult(tls, interp, objPtr) } _objPtr = objPtr v2 = _objPtr v1 = *(*TTcl_Size)(unsafe.Pointer(v2)) *(*TTcl_Size)(unsafe.Pointer(v2))-- if v1 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr) } return result } func _WriteToChannel(tls *libc.TLS, clientData uintptr, bytes uintptr, byteCount TTcl_Size) (r TTcl_Size) { var handle TTcl_Channel _ = handle handle = clientData return libtcl9_0.XTcl_Write(tls, handle, bytes, byteCount) } func _WriteToByteArray(tls *libc.TLS, clientData uintptr, bytes uintptr, byteCount TTcl_Size) (r TTcl_Size) { var _objPtr, objPtr, tmpObj, v2 uintptr var v1 TTcl_Size _, _, _, _, _ = _objPtr, objPtr, tmpObj, v1, v2 objPtr = clientData tmpObj = libtcl9_0.XTcl_NewByteArrayObj(tls, bytes, byteCount) (*TTcl_Obj)(unsafe.Pointer(tmpObj)).FrefCount++ libtcl9_0.XTcl_AppendObjToObj(tls, objPtr, tmpObj) _objPtr = tmpObj v2 = _objPtr v1 = *(*TTcl_Size)(unsafe.Pointer(v2)) *(*TTcl_Size)(unsafe.Pointer(v2))-- if v1 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr) } return byteCount } func _CommonWriteGIF(tls *libc.TLS, interp uintptr, handle uintptr, writeProc uintptr, dummy2006 uintptr, metadataInObj uintptr, blockPtr uintptr) (r int32) { bp := tls.Alloc(896) defer tls.Free(896) var blockLength, resolution, v1, v6 int32 var comment, v2, v3 uintptr var height, width, x int64 var left, top uint32 var _ /* blockLengthChar at bp+840 */ uint8 var _ /* c at bp+816 */ uint8 var _ /* itemData at bp+824 */ uintptr var _ /* length at bp+832 */ TTcl_Size var _ /* state at bp+0 */ TGifWriterState _, _, _, _, _, _, _, _, _, _, _, _ = blockLength, comment, height, left, resolution, top, width, x, v1, v2, v3, v6 top = uint32(0) left = uint32(0) libc.Xmemset(tls, bp, 0, uint64(816)) (*(*TGifWriterState)(unsafe.Pointer(bp))).FpixelSize = (*TTk_PhotoImageBlock)(unsafe.Pointer(blockPtr)).FpixelSize (*(*TGifWriterState)(unsafe.Pointer(bp))).FgreenOffset = *(*int32)(unsafe.Pointer(blockPtr + 24 + 1*4)) - *(*int32)(unsafe.Pointer(blockPtr + 24)) (*(*TGifWriterState)(unsafe.Pointer(bp))).FblueOffset = *(*int32)(unsafe.Pointer(blockPtr + 24 + 2*4)) - *(*int32)(unsafe.Pointer(blockPtr + 24)) (*(*TGifWriterState)(unsafe.Pointer(bp))).FalphaOffset = *(*int32)(unsafe.Pointer(blockPtr + 24)) if (*(*TGifWriterState)(unsafe.Pointer(bp))).FalphaOffset < *(*int32)(unsafe.Pointer(blockPtr + 24 + 2*4)) { (*(*TGifWriterState)(unsafe.Pointer(bp))).FalphaOffset = *(*int32)(unsafe.Pointer(blockPtr + 24 + 2*4)) } v2 = bp + 40 *(*int32)(unsafe.Pointer(v2))++ v1 = *(*int32)(unsafe.Pointer(v2)) if v1 < (*(*TGifWriterState)(unsafe.Pointer(bp))).FpixelSize { (*(*TGifWriterState)(unsafe.Pointer(bp))).FalphaOffset -= *(*int32)(unsafe.Pointer(blockPtr + 24)) } else { (*(*TGifWriterState)(unsafe.Pointer(bp))).FalphaOffset = 0 } if (*(*TGifWriterState)(unsafe.Pointer(bp))).FalphaOffset != 0 { v3 = uintptr(unsafe.Pointer(&_GIF89a)) } else { v3 = uintptr(unsafe.Pointer(&_GIF87a)) } (*(*func(*libc.TLS, uintptr, uintptr, TTcl_Size) TTcl_Size)(unsafe.Pointer(&struct{ uintptr }{writeProc})))(tls, handle, v3, int64(6)) x = 0 for { if !(x < int64(MAXCOLORMAPSIZE)) { break } *(*uint8)(unsafe.Pointer(bp + 48 + uintptr(x)*3)) = uint8(255) *(*uint8)(unsafe.Pointer(bp + 48 + uintptr(x)*3 + 1)) = uint8(255) *(*uint8)(unsafe.Pointer(bp + 48 + uintptr(x)*3 + 2)) = uint8(255) goto _4 _4: ; x++ } width = int64((*TTk_PhotoImageBlock)(unsafe.Pointer(blockPtr)).Fwidth) height = int64((*TTk_PhotoImageBlock)(unsafe.Pointer(blockPtr)).Fheight) (*(*TGifWriterState)(unsafe.Pointer(bp))).FpixelOffset = (*TTk_PhotoImageBlock)(unsafe.Pointer(blockPtr)).FpixelPtr + uintptr(*(*int32)(unsafe.Pointer(blockPtr + 24))) (*(*TGifWriterState)(unsafe.Pointer(bp))).FpixelPitch = (*TTk_PhotoImageBlock)(unsafe.Pointer(blockPtr)).Fpitch _SaveMap(tls, bp, blockPtr) if (*(*TGifWriterState)(unsafe.Pointer(bp))).Fnum >= int32(MAXCOLORMAPSIZE) { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+34525, int64(-libc.Int32FromInt32(1)))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+856, __ccgo_ts+179, __ccgo_ts+29667, __ccgo_ts+33991, __ccgo_ts+34541, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) } if (*(*TGifWriterState)(unsafe.Pointer(bp))).Fnum < int32(2) { (*(*TGifWriterState)(unsafe.Pointer(bp))).Fnum = int32(2) } *(*uint8)(unsafe.Pointer(bp + 816)) = libc.Uint8FromInt32(int32(int16(width)) & libc.Int32FromInt32(0x00FF)) (*(*func(*libc.TLS, uintptr, uintptr, TTcl_Size) TTcl_Size)(unsafe.Pointer(&struct{ uintptr }{writeProc})))(tls, handle, bp+816, int64(1)) *(*uint8)(unsafe.Pointer(bp + 816)) = libc.Uint8FromInt32(int32(int16(width)) >> libc.Int32FromInt32(8)) (*(*func(*libc.TLS, uintptr, uintptr, TTcl_Size) TTcl_Size)(unsafe.Pointer(&struct{ uintptr }{writeProc})))(tls, handle, bp+816, int64(1)) *(*uint8)(unsafe.Pointer(bp + 816)) = libc.Uint8FromInt32(int32(int16(height)) & libc.Int32FromInt32(0x00FF)) (*(*func(*libc.TLS, uintptr, uintptr, TTcl_Size) TTcl_Size)(unsafe.Pointer(&struct{ uintptr }{writeProc})))(tls, handle, bp+816, int64(1)) *(*uint8)(unsafe.Pointer(bp + 816)) = libc.Uint8FromInt32(int32(int16(height)) >> libc.Int32FromInt32(8)) (*(*func(*libc.TLS, uintptr, uintptr, TTcl_Size) TTcl_Size)(unsafe.Pointer(&struct{ uintptr }{writeProc})))(tls, handle, bp+816, int64(1)) resolution = 0 for (*(*TGifWriterState)(unsafe.Pointer(bp))).Fnum>>resolution != 0 { resolution++ } *(*uint8)(unsafe.Pointer(bp + 816)) = libc.Uint8FromInt32(int32(111) + resolution*int32(17)) (*(*func(*libc.TLS, uintptr, uintptr, TTcl_Size) TTcl_Size)(unsafe.Pointer(&struct{ uintptr }{writeProc})))(tls, handle, bp+816, int64(1)) (*(*TGifWriterState)(unsafe.Pointer(bp))).Fnum = int32(1) << resolution /* * Background color */ *(*uint8)(unsafe.Pointer(bp + 816)) = uint8(0) (*(*func(*libc.TLS, uintptr, uintptr, TTcl_Size) TTcl_Size)(unsafe.Pointer(&struct{ uintptr }{writeProc})))(tls, handle, bp+816, int64(1)) /* * Zero for future expansion. */ (*(*func(*libc.TLS, uintptr, uintptr, TTcl_Size) TTcl_Size)(unsafe.Pointer(&struct{ uintptr }{writeProc})))(tls, handle, bp+816, int64(1)) x = 0 for { if !(x < int64((*(*TGifWriterState)(unsafe.Pointer(bp))).Fnum)) { break } *(*uint8)(unsafe.Pointer(bp + 816)) = *(*uint8)(unsafe.Pointer(bp + 48 + uintptr(x)*3)) (*(*func(*libc.TLS, uintptr, uintptr, TTcl_Size) TTcl_Size)(unsafe.Pointer(&struct{ uintptr }{writeProc})))(tls, handle, bp+816, int64(1)) *(*uint8)(unsafe.Pointer(bp + 816)) = *(*uint8)(unsafe.Pointer(bp + 48 + uintptr(x)*3 + 1)) (*(*func(*libc.TLS, uintptr, uintptr, TTcl_Size) TTcl_Size)(unsafe.Pointer(&struct{ uintptr }{writeProc})))(tls, handle, bp+816, int64(1)) *(*uint8)(unsafe.Pointer(bp + 816)) = *(*uint8)(unsafe.Pointer(bp + 48 + uintptr(x)*3 + 2)) (*(*func(*libc.TLS, uintptr, uintptr, TTcl_Size) TTcl_Size)(unsafe.Pointer(&struct{ uintptr }{writeProc})))(tls, handle, bp+816, int64(1)) goto _5 _5: ; x++ } /* * Write out extension for transparent colour index, if necessary. */ if (*(*TGifWriterState)(unsafe.Pointer(bp))).FalphaOffset != 0 { *(*uint8)(unsafe.Pointer(bp + 816)) = uint8(GIF_EXTENSION) (*(*func(*libc.TLS, uintptr, uintptr, TTcl_Size) TTcl_Size)(unsafe.Pointer(&struct{ uintptr }{writeProc})))(tls, handle, bp+816, int64(1)) (*(*func(*libc.TLS, uintptr, uintptr, TTcl_Size) TTcl_Size)(unsafe.Pointer(&struct{ uintptr }{writeProc})))(tls, handle, __ccgo_ts+34550, int64(7)) } *(*uint8)(unsafe.Pointer(bp + 816)) = uint8(GIF_START) (*(*func(*libc.TLS, uintptr, uintptr, TTcl_Size) TTcl_Size)(unsafe.Pointer(&struct{ uintptr }{writeProc})))(tls, handle, bp+816, int64(1)) *(*uint8)(unsafe.Pointer(bp + 816)) = libc.Uint8FromInt32(int32(libc.Int16FromUint32(top)) & libc.Int32FromInt32(0x00FF)) (*(*func(*libc.TLS, uintptr, uintptr, TTcl_Size) TTcl_Size)(unsafe.Pointer(&struct{ uintptr }{writeProc})))(tls, handle, bp+816, int64(1)) *(*uint8)(unsafe.Pointer(bp + 816)) = libc.Uint8FromInt32(int32(libc.Int16FromUint32(top)) >> libc.Int32FromInt32(8)) (*(*func(*libc.TLS, uintptr, uintptr, TTcl_Size) TTcl_Size)(unsafe.Pointer(&struct{ uintptr }{writeProc})))(tls, handle, bp+816, int64(1)) *(*uint8)(unsafe.Pointer(bp + 816)) = libc.Uint8FromInt32(int32(libc.Int16FromUint32(left)) & libc.Int32FromInt32(0x00FF)) (*(*func(*libc.TLS, uintptr, uintptr, TTcl_Size) TTcl_Size)(unsafe.Pointer(&struct{ uintptr }{writeProc})))(tls, handle, bp+816, int64(1)) *(*uint8)(unsafe.Pointer(bp + 816)) = libc.Uint8FromInt32(int32(libc.Int16FromUint32(left)) >> libc.Int32FromInt32(8)) (*(*func(*libc.TLS, uintptr, uintptr, TTcl_Size) TTcl_Size)(unsafe.Pointer(&struct{ uintptr }{writeProc})))(tls, handle, bp+816, int64(1)) *(*uint8)(unsafe.Pointer(bp + 816)) = libc.Uint8FromInt32(int32(int16(width)) & libc.Int32FromInt32(0x00FF)) (*(*func(*libc.TLS, uintptr, uintptr, TTcl_Size) TTcl_Size)(unsafe.Pointer(&struct{ uintptr }{writeProc})))(tls, handle, bp+816, int64(1)) *(*uint8)(unsafe.Pointer(bp + 816)) = libc.Uint8FromInt32(int32(int16(width)) >> libc.Int32FromInt32(8)) (*(*func(*libc.TLS, uintptr, uintptr, TTcl_Size) TTcl_Size)(unsafe.Pointer(&struct{ uintptr }{writeProc})))(tls, handle, bp+816, int64(1)) *(*uint8)(unsafe.Pointer(bp + 816)) = libc.Uint8FromInt32(int32(int16(height)) & libc.Int32FromInt32(0x00FF)) (*(*func(*libc.TLS, uintptr, uintptr, TTcl_Size) TTcl_Size)(unsafe.Pointer(&struct{ uintptr }{writeProc})))(tls, handle, bp+816, int64(1)) *(*uint8)(unsafe.Pointer(bp + 816)) = libc.Uint8FromInt32(int32(int16(height)) >> libc.Int32FromInt32(8)) (*(*func(*libc.TLS, uintptr, uintptr, TTcl_Size) TTcl_Size)(unsafe.Pointer(&struct{ uintptr }{writeProc})))(tls, handle, bp+816, int64(1)) *(*uint8)(unsafe.Pointer(bp + 816)) = uint8(0) (*(*func(*libc.TLS, uintptr, uintptr, TTcl_Size) TTcl_Size)(unsafe.Pointer(&struct{ uintptr }{writeProc})))(tls, handle, bp+816, int64(1)) *(*uint8)(unsafe.Pointer(bp + 816)) = libc.Uint8FromInt32(resolution) (*(*func(*libc.TLS, uintptr, uintptr, TTcl_Size) TTcl_Size)(unsafe.Pointer(&struct{ uintptr }{writeProc})))(tls, handle, bp+816, int64(1)) v6 = (*TTk_PhotoImageBlock)(unsafe.Pointer(blockPtr)).Fwidth (*(*TGifWriterState)(unsafe.Pointer(bp))).Frsize = v6 (*(*TGifWriterState)(unsafe.Pointer(bp))).Fssize = v6 (*(*TGifWriterState)(unsafe.Pointer(bp))).Fcsize = (*TTk_PhotoImageBlock)(unsafe.Pointer(blockPtr)).Fheight _Compress(tls, resolution+int32(1), handle, writeProc, __ccgo_fp(_ReadValue), bp) *(*uint8)(unsafe.Pointer(bp + 816)) = uint8(0) (*(*func(*libc.TLS, uintptr, uintptr, TTcl_Size) TTcl_Size)(unsafe.Pointer(&struct{ uintptr }{writeProc})))(tls, handle, bp+816, int64(1)) /* * Check for metadata keys to add to file */ if libc.UintptrFromInt32(0) != metadataInObj { /* * Check and code comment block */ if int32(TCL_ERROR) == libtcl9_0.XTcl_DictObjGet(tls, interp, metadataInObj, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+34473, int64(-int32(1))), bp+824) { return int32(TCL_ERROR) } if *(*uintptr)(unsafe.Pointer(bp + 824)) != libc.UintptrFromInt32(0) { comment = libtcl9_0.XTcl_GetBytesFromObj(tls, libc.UintptrFromInt32(0), *(*uintptr)(unsafe.Pointer(bp + 824)), bp+832) if *(*TTcl_Size)(unsafe.Pointer(bp + 832)) > 0 { /* write comment header */ (*(*func(*libc.TLS, uintptr, uintptr, TTcl_Size) TTcl_Size)(unsafe.Pointer(&struct{ uintptr }{writeProc})))(tls, handle, __ccgo_ts+34557, int64(2)) /* write comment blocks */ for { if !(*(*TTcl_Size)(unsafe.Pointer(bp + 832)) > 0) { break } if *(*TTcl_Size)(unsafe.Pointer(bp + 832)) > int64(255) { *(*TTcl_Size)(unsafe.Pointer(bp + 832)) -= int64(255) blockLength = int32(255) } else { blockLength = int32(*(*TTcl_Size)(unsafe.Pointer(bp + 832))) *(*TTcl_Size)(unsafe.Pointer(bp + 832)) = 0 } *(*uint8)(unsafe.Pointer(bp + 840)) = libc.Uint8FromInt32(blockLength) (*(*func(*libc.TLS, uintptr, uintptr, TTcl_Size) TTcl_Size)(unsafe.Pointer(&struct{ uintptr }{writeProc})))(tls, handle, bp+840, int64(1)) (*(*func(*libc.TLS, uintptr, uintptr, TTcl_Size) TTcl_Size)(unsafe.Pointer(&struct{ uintptr }{writeProc})))(tls, handle, comment, int64(blockLength)) comment += uintptr(blockLength) goto _7 _7: } /* Block terminator */ *(*uint8)(unsafe.Pointer(bp + 816)) = uint8(0) (*(*func(*libc.TLS, uintptr, uintptr, TTcl_Size) TTcl_Size)(unsafe.Pointer(&struct{ uintptr }{writeProc})))(tls, handle, bp+816, int64(1)) } } } *(*uint8)(unsafe.Pointer(bp + 816)) = uint8(GIF_TERMINATOR) (*(*func(*libc.TLS, uintptr, uintptr, TTcl_Size) TTcl_Size)(unsafe.Pointer(&struct{ uintptr }{writeProc})))(tls, handle, bp+816, int64(1)) return TCL_OK } func _ColorNumber(tls *libc.TLS, statePtr uintptr, red int32, green int32, blue int32) (r int32) { var x int32 _ = x x = libc.BoolInt32((*TGifWriterState)(unsafe.Pointer(statePtr)).FalphaOffset != 0) for { if !(x <= int32(MAXCOLORMAPSIZE)) { break } if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(statePtr + 48 + uintptr(x)*3))) == red && libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(statePtr + 48 + uintptr(x)*3 + 1))) == green && libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(statePtr + 48 + uintptr(x)*3 + 2))) == blue { return x } goto _1 _1: ; x++ } return -int32(1) } func _IsNewColor(tls *libc.TLS, statePtr uintptr, red int32, green int32, blue int32) (r int32) { var x int32 _ = x x = libc.BoolInt32((*TGifWriterState)(unsafe.Pointer(statePtr)).FalphaOffset != 0) for { if !(x <= (*TGifWriterState)(unsafe.Pointer(statePtr)).Fnum) { break } if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(statePtr + 48 + uintptr(x)*3))) == red && libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(statePtr + 48 + uintptr(x)*3 + 1))) == green && libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(statePtr + 48 + uintptr(x)*3 + 2))) == blue { return 0 } goto _1 _1: ; x++ } return int32(1) } func _SaveMap(tls *libc.TLS, statePtr uintptr, blockPtr uintptr) { var blue, green, red uint8 var colores uintptr var x, y int32 _, _, _, _, _, _ = blue, colores, green, red, x, y if (*TGifWriterState)(unsafe.Pointer(statePtr)).FalphaOffset != 0 { (*TGifWriterState)(unsafe.Pointer(statePtr)).Fnum = 0 *(*uint8)(unsafe.Pointer(statePtr + 48)) = uint8(DEFAULT_BACKGROUND_VALUE) *(*uint8)(unsafe.Pointer(statePtr + 48 + 1)) = uint8(DEFAULT_BACKGROUND_VALUE) *(*uint8)(unsafe.Pointer(statePtr + 48 + 2)) = uint8(DEFAULT_BACKGROUND_VALUE) } else { (*TGifWriterState)(unsafe.Pointer(statePtr)).Fnum = -int32(1) } y = 0 for { if !(y < (*TTk_PhotoImageBlock)(unsafe.Pointer(blockPtr)).Fheight) { break } colores = (*TTk_PhotoImageBlock)(unsafe.Pointer(blockPtr)).FpixelPtr + uintptr(*(*int32)(unsafe.Pointer(blockPtr + 24))) + uintptr(y*(*TTk_PhotoImageBlock)(unsafe.Pointer(blockPtr)).Fpitch) x = 0 for { if !(x < (*TTk_PhotoImageBlock)(unsafe.Pointer(blockPtr)).Fwidth) { break } if !((*TGifWriterState)(unsafe.Pointer(statePtr)).FalphaOffset != 0) || libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(colores + uintptr((*TGifWriterState)(unsafe.Pointer(statePtr)).FalphaOffset)))) != 0 { red = *(*uint8)(unsafe.Pointer(colores)) green = *(*uint8)(unsafe.Pointer(colores + uintptr((*TGifWriterState)(unsafe.Pointer(statePtr)).FgreenOffset))) blue = *(*uint8)(unsafe.Pointer(colores + uintptr((*TGifWriterState)(unsafe.Pointer(statePtr)).FblueOffset))) if _IsNewColor(tls, statePtr, libc.Int32FromUint8(red), libc.Int32FromUint8(green), libc.Int32FromUint8(blue)) != 0 { (*TGifWriterState)(unsafe.Pointer(statePtr)).Fnum++ if (*TGifWriterState)(unsafe.Pointer(statePtr)).Fnum >= int32(MAXCOLORMAPSIZE) { return } *(*uint8)(unsafe.Pointer(statePtr + 48 + uintptr((*TGifWriterState)(unsafe.Pointer(statePtr)).Fnum)*3)) = red *(*uint8)(unsafe.Pointer(statePtr + 48 + uintptr((*TGifWriterState)(unsafe.Pointer(statePtr)).Fnum)*3 + 1)) = green *(*uint8)(unsafe.Pointer(statePtr + 48 + uintptr((*TGifWriterState)(unsafe.Pointer(statePtr)).Fnum)*3 + 2)) = blue } } colores += uintptr((*TGifWriterState)(unsafe.Pointer(statePtr)).FpixelSize) goto _2 _2: ; x++ } goto _1 _1: ; y++ } } func _ReadValue(tls *libc.TLS, statePtr uintptr) (r int32) { var col uint32 var v1 int32 var v2 uintptr _, _, _ = col, v1, v2 if (*TGifWriterState)(unsafe.Pointer(statePtr)).Fcsize == 0 { return -int32(1) } if (*TGifWriterState)(unsafe.Pointer(statePtr)).FalphaOffset != 0 && libc.Int32FromUint8(*(*uint8)(unsafe.Pointer((*TGifWriterState)(unsafe.Pointer(statePtr)).FpixelOffset + uintptr((*TGifWriterState)(unsafe.Pointer(statePtr)).FalphaOffset)))) == 0 { col = uint32(0) } else { col = libc.Uint32FromInt32(_ColorNumber(tls, statePtr, libc.Int32FromUint8(*(*uint8)(unsafe.Pointer((*TGifWriterState)(unsafe.Pointer(statePtr)).FpixelOffset))), libc.Int32FromUint8(*(*uint8)(unsafe.Pointer((*TGifWriterState)(unsafe.Pointer(statePtr)).FpixelOffset + uintptr((*TGifWriterState)(unsafe.Pointer(statePtr)).FgreenOffset)))), libc.Int32FromUint8(*(*uint8)(unsafe.Pointer((*TGifWriterState)(unsafe.Pointer(statePtr)).FpixelOffset + uintptr((*TGifWriterState)(unsafe.Pointer(statePtr)).FblueOffset)))))) } *(*uintptr)(unsafe.Pointer(statePtr + 16)) += uintptr((*TGifWriterState)(unsafe.Pointer(statePtr)).FpixelSize) v2 = statePtr *(*int32)(unsafe.Pointer(v2))-- v1 = *(*int32)(unsafe.Pointer(v2)) if v1 <= 0 { (*TGifWriterState)(unsafe.Pointer(statePtr)).Fssize = (*TGifWriterState)(unsafe.Pointer(statePtr)).Frsize (*TGifWriterState)(unsafe.Pointer(statePtr)).Fcsize-- *(*uintptr)(unsafe.Pointer(statePtr + 16)) += uintptr((*TGifWriterState)(unsafe.Pointer(statePtr)).FpixelPitch - (*TGifWriterState)(unsafe.Pointer(statePtr)).Frsize*(*TGifWriterState)(unsafe.Pointer(statePtr)).FpixelSize) } return libc.Int32FromUint32(col) } /* * GIF Image compression - modified 'Compress' * * Based on: compress.c - File compression ala IEEE Computer, June 1984. * * By Authors: Spencer W. Thomas (decvax!harpo!utah-cs!utah-gr!thomas) * Jim McKie (decvax!mcvax!jim) * Steve Davies (decvax!vax135!petsd!peora!srd) * Ken Turkowski (decvax!decwrl!turtlevax!ken) * James A. Woods (decvax!ihnp4!ames!jaw) * Joe Orost (decvax!vax135!petsd!joe) */ func _Compress(tls *libc.TLS, initialBits int32, handle uintptr, writeProc uintptr, readValue Tifunptr, statePtr uintptr) { bp := tls.Alloc(40368) defer tls.Free(40368) var c, hshift, v1, v3, v4 int32 var disp, ent, fcode, hSize, i int64 var v5 uintptr var _ /* state at bp+0 */ TGIFState_t _, _, _, _, _, _, _, _, _, _, _ = c, disp, ent, fcode, hSize, hshift, i, v1, v3, v4, v5 i = 0 libc.Xmemset(tls, bp, 0, uint64(40368)) /* * Set up the globals: initialBits - initial number of bits * outChannel - pointer to output file */ (*(*TGIFState_t)(unsafe.Pointer(bp))).FinitialBits = initialBits (*(*TGIFState_t)(unsafe.Pointer(bp))).Fdestination = handle (*(*TGIFState_t)(unsafe.Pointer(bp))).FwriteProc = writeProc /* * Set up the necessary values. */ (*(*TGIFState_t)(unsafe.Pointer(bp))).Foffset = 0 (*(*TGIFState_t)(unsafe.Pointer(bp))).FhSize = int64(HSIZE) (*(*TGIFState_t)(unsafe.Pointer(bp))).FoutCount = uint32(0) (*(*TGIFState_t)(unsafe.Pointer(bp))).FclearFlag = 0 (*(*TGIFState_t)(unsafe.Pointer(bp))).FinCount = uint32(1) v1 = (*(*TGIFState_t)(unsafe.Pointer(bp))).FinitialBits (*(*TGIFState_t)(unsafe.Pointer(bp))).FnumBits = v1 (*(*TGIFState_t)(unsafe.Pointer(bp))).FmaxCode = libc.Int64FromInt32(1)< 0 { goto probe } goto nomatch nomatch: ; _Output(tls, bp, ent) (*(*TGIFState_t)(unsafe.Pointer(bp))).FoutCount++ ent = int64(c) if int64((*(*TGIFState_t)(unsafe.Pointer(bp))).FfreeEntry) < libc.Int64FromInt32(1)< hashtable */ *(*int32)(unsafe.Pointer(bp + 16 + uintptr(i)*4)) = int32(fcode) } else { _ClearForBlock(tls, bp) } } /* * Put out the final code. */ _Output(tls, bp, ent) (*(*TGIFState_t)(unsafe.Pointer(bp))).FoutCount++ _Output(tls, bp, int64((*(*TGIFState_t)(unsafe.Pointer(bp))).FeofCode)) } /***************************************************************** * Output -- * Output the given code. * * Inputs: * code: A numBits-bit integer. If == -1, then EOF. This assumes that * numBits =< (long) wordsize - 1. * Outputs: * Outputs code to the file. * Assumptions: * Chars are 8 bits long. * Algorithm: * Maintain a GIFBITS character long buffer (so that 8 codes will fit in * it exactly). Use the VAX insv instruction to insert each code in turn. * When the buffer fills up empty it and start over. */ func _Output(tls *libc.TLS, statePtr uintptr, code int64) { var v1 int32 _ = v1 *(*uint64)(unsafe.Pointer(statePtr + 40096)) &= _masks[(*TGIFState_t)(unsafe.Pointer(statePtr)).FcurrentBits] if (*TGIFState_t)(unsafe.Pointer(statePtr)).FcurrentBits > 0 { *(*uint64)(unsafe.Pointer(statePtr + 40096)) |= libc.Uint64FromInt64(code << (*TGIFState_t)(unsafe.Pointer(statePtr)).FcurrentBits) } else { (*TGIFState_t)(unsafe.Pointer(statePtr)).FcurrentAccumulated = libc.Uint64FromInt64(code) } *(*int32)(unsafe.Pointer(statePtr + 40104)) += (*TGIFState_t)(unsafe.Pointer(statePtr)).FnumBits for (*TGIFState_t)(unsafe.Pointer(statePtr)).FcurrentBits >= int32(8) { _CharOut(tls, statePtr, libc.Int32FromUint32(uint32((*TGIFState_t)(unsafe.Pointer(statePtr)).FcurrentAccumulated&libc.Uint64FromInt32(0xff)))) *(*uint64)(unsafe.Pointer(statePtr + 40096)) >>= uint64(8) *(*int32)(unsafe.Pointer(statePtr + 40104)) -= int32(8) } /* * If the next entry is going to be too big for the code size, then * increase it, if possible. */ if int64((*TGIFState_t)(unsafe.Pointer(statePtr)).FfreeEntry) > (*TGIFState_t)(unsafe.Pointer(statePtr)).FmaxCode || (*TGIFState_t)(unsafe.Pointer(statePtr)).FclearFlag != 0 { if (*TGIFState_t)(unsafe.Pointer(statePtr)).FclearFlag != 0 { v1 = (*TGIFState_t)(unsafe.Pointer(statePtr)).FinitialBits (*TGIFState_t)(unsafe.Pointer(statePtr)).FnumBits = v1 (*TGIFState_t)(unsafe.Pointer(statePtr)).FmaxCode = libc.Int64FromInt32(1)< 0 { _CharOut(tls, statePtr, libc.Int32FromUint32(uint32((*TGIFState_t)(unsafe.Pointer(statePtr)).FcurrentAccumulated&libc.Uint64FromInt32(0xff)))) *(*uint64)(unsafe.Pointer(statePtr + 40096)) >>= uint64(8) *(*int32)(unsafe.Pointer(statePtr + 40104)) -= int32(8) } _FlushChar(tls, statePtr) } } var _masks = [17]uint64{ 1: uint64(0x0001), 2: uint64(0x0003), 3: uint64(0x0007), 4: uint64(0x000F), 5: uint64(0x001F), 6: uint64(0x003F), 7: uint64(0x007F), 8: uint64(0x00FF), 9: uint64(0x01FF), 10: uint64(0x03FF), 11: uint64(0x07FF), 12: uint64(0x0FFF), 13: uint64(0x1FFF), 14: uint64(0x3FFF), 15: uint64(0x7FFF), 16: uint64(0xFFFF), } /* * Clear out the hash table */ func _ClearForBlock(tls *libc.TLS, statePtr uintptr) { _ClearHashTable(tls, statePtr, int32((*TGIFState_t)(unsafe.Pointer(statePtr)).FhSize)) (*TGIFState_t)(unsafe.Pointer(statePtr)).FfreeEntry = (*TGIFState_t)(unsafe.Pointer(statePtr)).FclearCode + int32(2) (*TGIFState_t)(unsafe.Pointer(statePtr)).FclearFlag = int32(1) _Output(tls, statePtr, int64((*TGIFState_t)(unsafe.Pointer(statePtr)).FclearCode)) } func _ClearHashTable(tls *libc.TLS, statePtr uintptr, hSize int32) { var hashTablePtr, v3 uintptr var i, m1 int64 _, _, _, _ = hashTablePtr, i, m1, v3 hashTablePtr = statePtr + 16 + uintptr(hSize)*4 m1 = int64(-int32(1)) i = int64(hSize - int32(16)) for { /* might use Sys V memset(3) here */ *(*int32)(unsafe.Pointer(hashTablePtr - libc.UintptrFromInt32(16)*4)) = int32(m1) *(*int32)(unsafe.Pointer(hashTablePtr - libc.UintptrFromInt32(15)*4)) = int32(m1) *(*int32)(unsafe.Pointer(hashTablePtr - libc.UintptrFromInt32(14)*4)) = int32(m1) *(*int32)(unsafe.Pointer(hashTablePtr - libc.UintptrFromInt32(13)*4)) = int32(m1) *(*int32)(unsafe.Pointer(hashTablePtr - libc.UintptrFromInt32(12)*4)) = int32(m1) *(*int32)(unsafe.Pointer(hashTablePtr - libc.UintptrFromInt32(11)*4)) = int32(m1) *(*int32)(unsafe.Pointer(hashTablePtr - libc.UintptrFromInt32(10)*4)) = int32(m1) *(*int32)(unsafe.Pointer(hashTablePtr - libc.UintptrFromInt32(9)*4)) = int32(m1) *(*int32)(unsafe.Pointer(hashTablePtr - libc.UintptrFromInt32(8)*4)) = int32(m1) *(*int32)(unsafe.Pointer(hashTablePtr - libc.UintptrFromInt32(7)*4)) = int32(m1) *(*int32)(unsafe.Pointer(hashTablePtr - libc.UintptrFromInt32(6)*4)) = int32(m1) *(*int32)(unsafe.Pointer(hashTablePtr - libc.UintptrFromInt32(5)*4)) = int32(m1) *(*int32)(unsafe.Pointer(hashTablePtr - libc.UintptrFromInt32(4)*4)) = int32(m1) *(*int32)(unsafe.Pointer(hashTablePtr - libc.UintptrFromInt32(3)*4)) = int32(m1) *(*int32)(unsafe.Pointer(hashTablePtr - libc.UintptrFromInt32(2)*4)) = int32(m1) *(*int32)(unsafe.Pointer(hashTablePtr - libc.UintptrFromInt32(1)*4)) = int32(m1) hashTablePtr -= uintptr(16) * 4 goto _1 _1: ; i -= int64(16) if !(i >= 0) { break } } i += int64(16) for { if !(i > 0) { break } hashTablePtr -= 4 v3 = hashTablePtr *(*int32)(unsafe.Pointer(v3)) = int32(m1) goto _2 _2: ; i-- } } /* ***************************************************************************** * * GIF Specific routines * ***************************************************************************** */ /* * Set up the 'byte output' routine */ func _CharInit(tls *libc.TLS, statePtr uintptr) { (*TGIFState_t)(unsafe.Pointer(statePtr)).FaccumulatedByteCount = 0 (*TGIFState_t)(unsafe.Pointer(statePtr)).FcurrentAccumulated = uint64(0) (*TGIFState_t)(unsafe.Pointer(statePtr)).FcurrentBits = 0 } /* * Add a character to the end of the current packet, and if it is 254 * characters, flush the packet to disk. */ func _CharOut(tls *libc.TLS, statePtr uintptr, c int32) { var v1 int32 var v2 uintptr _, _ = v1, v2 v2 = statePtr + 40108 v1 = *(*int32)(unsafe.Pointer(v2)) *(*int32)(unsafe.Pointer(v2))++ *(*uint8)(unsafe.Pointer(statePtr + 40112 + uintptr(v1))) = libc.Uint8FromInt32(c) if (*TGIFState_t)(unsafe.Pointer(statePtr)).FaccumulatedByteCount >= int32(254) { _FlushChar(tls, statePtr) } } /* * Flush the packet to disk, and reset the accumulator */ func _FlushChar(tls *libc.TLS, statePtr uintptr) { bp := tls.Alloc(16) defer tls.Free(16) var _ /* c at bp+0 */ uint8 if (*TGIFState_t)(unsafe.Pointer(statePtr)).FaccumulatedByteCount > 0 { *(*uint8)(unsafe.Pointer(bp)) = libc.Uint8FromInt32((*TGIFState_t)(unsafe.Pointer(statePtr)).FaccumulatedByteCount) (*(*func(*libc.TLS, uintptr, uintptr, TTcl_Size) TTcl_Size)(unsafe.Pointer(&struct{ uintptr }{(*TGIFState_t)(unsafe.Pointer(statePtr)).FwriteProc})))(tls, (*TGIFState_t)(unsafe.Pointer(statePtr)).Fdestination, bp, int64(1)) (*(*func(*libc.TLS, uintptr, uintptr, TTcl_Size) TTcl_Size)(unsafe.Pointer(&struct{ uintptr }{(*TGIFState_t)(unsafe.Pointer(statePtr)).FwriteProc})))(tls, (*TGIFState_t)(unsafe.Pointer(statePtr)).Fdestination, statePtr+40112, int64((*TGIFState_t)(unsafe.Pointer(statePtr)).FaccumulatedByteCount)) (*TGIFState_t)(unsafe.Pointer(statePtr)).FaccumulatedByteCount = 0 } } const PNG64_BAD = 131 const PNG64_DONE = 130 const PNG64_PAD = 129 const PNG64_SPACE = 128 const PNG64_SPECIAL = 128 const PNG_BLOCK_SZ = 1024 const PNG_CF_ANCILLARY = 536870912 const PNG_CF_COPYSAFE = 16 const PNG_CF_PRIVATE = 1048576 const PNG_CF_RESERVED = 4096 const PNG_COLOR_ALPHA = 4 const PNG_COLOR_GRAY = 0 const PNG_COLOR_GRAYALPHA = 4 const PNG_COLOR_INDEXED = 1 const PNG_COLOR_PLTE = 3 const PNG_COLOR_RGB = 2 const PNG_COLOR_RGBA = 6 const PNG_COLOR_USED = 2 const PNG_COMPRESS_DEFLATE = 0 const PNG_FILTER_AVG = 3 const PNG_FILTER_NONE = 0 const PNG_FILTER_PAETH = 4 const PNG_FILTER_SUB = 1 const PNG_FILTER_UP = 2 const PNG_FILTMETH_STANDARD = 0 const PNG_INTERLACE_ADAM7 = 1 const PNG_INTERLACE_NONE = 0 const PNG_PLTE_MAXSZ = 768 const PNG_SIG_SZ = 8 const PNG_TRNS_MAXSZ = 256 /* * Local Variables: * mode: c * c-basic-offset: 4 * fill-column: 78 * End: */ /* * Every PNG image starts with the following 8-byte signature. */ var _pngSignature = [8]uint8{ 0: uint8(137), 1: uint8(80), 2: uint8(78), 3: uint8(71), 4: uint8(13), 5: uint8(10), 6: uint8(26), 7: uint8(10), } var _startLine = [8]int32{ 3: int32(4), 5: int32(2), 7: int32(1), } /* * Chunk type flags. */ /* * Chunk types, not all of which have support implemented. Note that there are * others in the official extension set which we will never support (as they * are officially deprecated). */ /* * Color flags. */ /* * Actual color types. */ /* * Compression Methods. */ /* * Filter Methods. */ /* * Interlacing Methods. */ /* * State information, used to store everything about the PNG image being * currently parsed or created. */ type TPNGImage = struct { Fchannel TTcl_Channel FobjDataPtr uintptr FstrDataBuf uintptr FstrDataLen TTcl_Size Fbase64Data uintptr Fbase64Bits uint8 Fbase64State uint8 Falpha float64 FbitDepth uint8 FcolorType uint8 Fcompression uint8 Ffilter uint8 Finterlace uint8 FnumChannels uint8 FbytesPerPixel uint8 FbitScale int32 FcurrentLine int32 Fphase uint8 Fblock TTk_PhotoImageBlock FblockLen int32 FpaletteLen int32 FuseTRNS int32 Fpalette [256]struct { Fred uint8 Fgreen uint8 Fblue uint8 Falpha uint8 } FtransVal [6]uint8 Fstream TTcl_ZlibStream FlastLineObj uintptr FthisLineObj uintptr FlineSize int32 FphaseSize int32 FDPI float64 Faspect float64 } func init() { p := unsafe.Pointer(&XtkImgFmtPNG) *(*uintptr)(unsafe.Add(p, 8)) = __ccgo_fp(_FileMatchPNG) *(*uintptr)(unsafe.Add(p, 16)) = __ccgo_fp(_StringMatchPNG) *(*uintptr)(unsafe.Add(p, 24)) = __ccgo_fp(_FileReadPNG) *(*uintptr)(unsafe.Add(p, 32)) = __ccgo_fp(_StringReadPNG) *(*uintptr)(unsafe.Add(p, 40)) = __ccgo_fp(_FileWritePNG) *(*uintptr)(unsafe.Add(p, 48)) = __ccgo_fp(_StringWritePNG) } /* *---------------------------------------------------------------------- * * InitPNGImage -- * * This function is invoked by each of the Tk image handler procs * (MatchStringProc, etc.) to initialize state information used during * the course of encoding or decoding a PNG image. * * Results: * TCL_OK, or TCL_ERROR if initialization failed. * * Side effects: * The reference count of the -data Tcl_Obj*, if any, is incremented. * *---------------------------------------------------------------------- */ func _InitPNGImage(tls *libc.TLS, interp uintptr, pngPtr uintptr, chan1 TTcl_Channel, objPtr uintptr, dir int32) (r int32) { bp := tls.Alloc(48) defer tls.Free(48) var _objPtr, v2 uintptr var v1 TTcl_Size _, _, _ = _objPtr, v1, v2 libc.Xmemset(tls, pngPtr, 0, uint64(1216)) (*TPNGImage)(unsafe.Pointer(pngPtr)).Fchannel = chan1 (*TPNGImage)(unsafe.Pointer(pngPtr)).Falpha = float64(1) /* * If decoding from a -data string object, increment its reference count * for the duration of the decode and get its length and byte array for * reading with ReadData(). */ if objPtr != 0 { (*TTcl_Obj)(unsafe.Pointer(objPtr)).FrefCount++ (*TPNGImage)(unsafe.Pointer(pngPtr)).FobjDataPtr = objPtr (*TPNGImage)(unsafe.Pointer(pngPtr)).FstrDataBuf = libtcl9_0.XTcl_GetBytesFromObj(tls, libc.UintptrFromInt32(0), objPtr, pngPtr+24) } /* * Initialize the palette transparency table to fully opaque. */ libc.Xmemset(tls, pngPtr+132, int32(255), uint64(1024)) /* * Initialize Zlib inflate/deflate stream. */ if libtcl9_0.XTcl_ZlibStreamInit(tls, libc.UintptrFromInt32(0), dir, int32(TCL_ZLIB_FORMAT_ZLIB), -int32(1), libc.UintptrFromInt32(0), pngPtr+1168) != TCL_OK { if interp != 0 { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+34564, int64(-libc.Int32FromInt32(1)))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+8, __ccgo_ts+179, __ccgo_ts+29667, __ccgo_ts+34591, __ccgo_ts+34595, libc.UintptrFromInt32(0))) } if objPtr != 0 { _objPtr = objPtr v2 = _objPtr v1 = *(*TTcl_Size)(unsafe.Pointer(v2)) *(*TTcl_Size)(unsafe.Pointer(v2))-- if v1 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr) } } return int32(TCL_ERROR) } /* * Initialize physical size pHYS values */ (*TPNGImage)(unsafe.Pointer(pngPtr)).FDPI = float64(-libc.Int32FromInt32(1)) (*TPNGImage)(unsafe.Pointer(pngPtr)).Faspect = float64(-libc.Int32FromInt32(1)) return TCL_OK } /* *---------------------------------------------------------------------- * * CleanupPNGImage -- * * This function is invoked by each of the Tk image handler procs * (MatchStringProc, etc.) prior to returning to Tcl in order to clean up * any allocated memory and call other cleanup handlers such as zlib's * inflateEnd/deflateEnd. * * Results: * None. * * Side effects: * The reference count of the -data Tcl_Obj*, if any, is decremented. * Buffers are freed, streams are closed. The PNGImage should not be used * for any purpose without being reinitialized post-cleanup. * *---------------------------------------------------------------------- */ func _CleanupPNGImage(tls *libc.TLS, pngPtr uintptr) { var _objPtr, _objPtr1, _objPtr2, v2, v4, v6 uintptr var v1, v3, v5 TTcl_Size _, _, _, _, _, _, _, _, _ = _objPtr, _objPtr1, _objPtr2, v1, v2, v3, v4, v5, v6 /* * Don't need the object containing the -data value anymore. */ if (*TPNGImage)(unsafe.Pointer(pngPtr)).FobjDataPtr != 0 { _objPtr = (*TPNGImage)(unsafe.Pointer(pngPtr)).FobjDataPtr v2 = _objPtr v1 = *(*TTcl_Size)(unsafe.Pointer(v2)) *(*TTcl_Size)(unsafe.Pointer(v2))-- if v1 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr) } } /* * Discard pixel buffer. */ if (*TPNGImage)(unsafe.Pointer(pngPtr)).Fstream != 0 { libtcl9_0.XTcl_ZlibStreamClose(tls, (*TPNGImage)(unsafe.Pointer(pngPtr)).Fstream) } if (*TPNGImage)(unsafe.Pointer(pngPtr)).Fblock.FpixelPtr != 0 { libtcl9_0.XTcl_Free(tls, (*TPNGImage)(unsafe.Pointer(pngPtr)).Fblock.FpixelPtr) } if (*TPNGImage)(unsafe.Pointer(pngPtr)).FthisLineObj != 0 { _objPtr1 = (*TPNGImage)(unsafe.Pointer(pngPtr)).FthisLineObj v4 = _objPtr1 v3 = *(*TTcl_Size)(unsafe.Pointer(v4)) *(*TTcl_Size)(unsafe.Pointer(v4))-- if v3 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr1) } } if (*TPNGImage)(unsafe.Pointer(pngPtr)).FlastLineObj != 0 { _objPtr2 = (*TPNGImage)(unsafe.Pointer(pngPtr)).FlastLineObj v6 = _objPtr2 v5 = *(*TTcl_Size)(unsafe.Pointer(v6)) *(*TTcl_Size)(unsafe.Pointer(v6))-- if v5 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr2) } } libc.Xmemset(tls, pngPtr, 0, uint64(1216)) } /* *---------------------------------------------------------------------- * * ReadBase64 -- * * This function is invoked to read the specified number of bytes from * base-64 encoded image data. * * Note: It would be better if the Tk_PhotoImage stuff handled this by * creating a channel from the -data value, which would take care of * base64 decoding and made the data readable as if it were coming from a * file. * * Results: * TCL_OK, or TCL_ERROR if an I/O error occurs. * * Side effects: * The file position will change. The running CRC is updated if a pointer * to it is provided. * *---------------------------------------------------------------------- */ func _ReadBase64(tls *libc.TLS, interp uintptr, pngPtr uintptr, destPtr uintptr, destSz TTcl_Size, crcPtr uintptr) (r int32) { bp := tls.Alloc(64) defer tls.Free(64) var c64, v3 uint8 var v1, v2, v4, v5 uintptr var _ /* c at bp+0 */ uint8 _, _, _, _, _, _ = c64, v1, v2, v3, v4, v5 /* * Definitions for the base-64 decoder. */ for destSz != 0 && (*TPNGImage)(unsafe.Pointer(pngPtr)).FstrDataLen != 0 { *(*uint8)(unsafe.Pointer(bp)) = uint8(0) v2 = pngPtr + 16 v1 = *(*uintptr)(unsafe.Pointer(v2)) *(*uintptr)(unsafe.Pointer(v2))++ c64 = _from64[*(*uint8)(unsafe.Pointer(v1))] (*TPNGImage)(unsafe.Pointer(pngPtr)).FstrDataLen-- if int32(PNG64_SPACE) == libc.Int32FromUint8(c64) { continue } if libc.Int32FromUint8(c64)&int32(PNG64_SPECIAL) != 0 { *(*uint8)(unsafe.Pointer(bp)) = (*TPNGImage)(unsafe.Pointer(pngPtr)).Fbase64Bits } else { v4 = pngPtr + 41 v3 = *(*uint8)(unsafe.Pointer(v4)) *(*uint8)(unsafe.Pointer(v4))++ switch libc.Int32FromUint8(v3) { case 0: (*TPNGImage)(unsafe.Pointer(pngPtr)).Fbase64Bits = libc.Uint8FromInt32(libc.Int32FromUint8(c64) << int32(2)) continue case int32(1): *(*uint8)(unsafe.Pointer(bp)) = libc.Uint8FromInt32(libc.Int32FromUint8((*TPNGImage)(unsafe.Pointer(pngPtr)).Fbase64Bits) | libc.Int32FromUint8(c64)>>libc.Int32FromInt32(4)) (*TPNGImage)(unsafe.Pointer(pngPtr)).Fbase64Bits = libc.Uint8FromInt32(libc.Int32FromUint8(c64) & int32(0xF) << int32(4)) case int32(2): *(*uint8)(unsafe.Pointer(bp)) = libc.Uint8FromInt32(libc.Int32FromUint8((*TPNGImage)(unsafe.Pointer(pngPtr)).Fbase64Bits) | libc.Int32FromUint8(c64)>>libc.Int32FromInt32(2)) (*TPNGImage)(unsafe.Pointer(pngPtr)).Fbase64Bits = libc.Uint8FromInt32(libc.Int32FromUint8(c64) & int32(0x3) << int32(6)) case int32(3): *(*uint8)(unsafe.Pointer(bp)) = libc.Uint8FromInt32(libc.Int32FromUint8((*TPNGImage)(unsafe.Pointer(pngPtr)).Fbase64Bits) | libc.Int32FromUint8(c64)) (*TPNGImage)(unsafe.Pointer(pngPtr)).Fbase64State = uint8(0) (*TPNGImage)(unsafe.Pointer(pngPtr)).Fbase64Bits = uint8(0) break } } if crcPtr != 0 { *(*uint64)(unsafe.Pointer(crcPtr)) = uint64(libtcl9_0.XTcl_ZlibCRC32(tls, uint32(*(*uint64)(unsafe.Pointer(crcPtr))), bp, int64(1))) } if destPtr != 0 { v5 = destPtr destPtr++ *(*uint8)(unsafe.Pointer(v5)) = *(*uint8)(unsafe.Pointer(bp)) } destSz-- if libc.Int32FromUint8(c64)&int32(PNG64_SPECIAL) != 0 { break } } if destSz != 0 { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+34605, int64(-libc.Int32FromInt32(1)))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+16, __ccgo_ts+179, __ccgo_ts+29667, __ccgo_ts+34591, __ccgo_ts+34634, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) } return TCL_OK } var _from64 = [256]uint8{ 0: uint8(0x82), 1: uint8(0x83), 2: uint8(0x83), 3: uint8(0x83), 4: uint8(0x83), 5: uint8(0x83), 6: uint8(0x83), 7: uint8(0x83), 8: uint8(0x83), 9: uint8(0x80), 10: uint8(0x80), 11: uint8(0x83), 12: uint8(0x80), 13: uint8(0x80), 14: uint8(0x83), 15: uint8(0x83), 16: uint8(0x83), 17: uint8(0x83), 18: uint8(0x83), 19: uint8(0x83), 20: uint8(0x83), 21: uint8(0x83), 22: uint8(0x83), 23: uint8(0x83), 24: uint8(0x83), 25: uint8(0x83), 26: uint8(0x83), 27: uint8(0x83), 28: uint8(0x83), 29: uint8(0x83), 30: uint8(0x83), 31: uint8(0x83), 32: uint8(0x80), 33: uint8(0x83), 34: uint8(0x83), 35: uint8(0x83), 36: uint8(0x83), 37: uint8(0x83), 38: uint8(0x83), 39: uint8(0x83), 40: uint8(0x83), 41: uint8(0x83), 42: uint8(0x83), 43: uint8(0x3e), 44: uint8(0x83), 45: uint8(0x83), 46: uint8(0x83), 47: uint8(0x3f), 48: uint8(0x34), 49: uint8(0x35), 50: uint8(0x36), 51: uint8(0x37), 52: uint8(0x38), 53: uint8(0x39), 54: uint8(0x3a), 55: uint8(0x3b), 56: uint8(0x3c), 57: uint8(0x3d), 58: uint8(0x83), 59: uint8(0x83), 60: uint8(0x83), 61: uint8(0x81), 62: uint8(0x83), 63: uint8(0x83), 64: uint8(0x83), 66: uint8(0x01), 67: uint8(0x02), 68: uint8(0x03), 69: uint8(0x04), 70: uint8(0x05), 71: uint8(0x06), 72: uint8(0x07), 73: uint8(0x08), 74: uint8(0x09), 75: uint8(0x0a), 76: uint8(0x0b), 77: uint8(0x0c), 78: uint8(0x0d), 79: uint8(0x0e), 80: uint8(0x0f), 81: uint8(0x10), 82: uint8(0x11), 83: uint8(0x12), 84: uint8(0x13), 85: uint8(0x14), 86: uint8(0x15), 87: uint8(0x16), 88: uint8(0x17), 89: uint8(0x18), 90: uint8(0x19), 91: uint8(0x83), 92: uint8(0x83), 93: uint8(0x83), 94: uint8(0x83), 95: uint8(0x83), 96: uint8(0x83), 97: uint8(0x1a), 98: uint8(0x1b), 99: uint8(0x1c), 100: uint8(0x1d), 101: uint8(0x1e), 102: uint8(0x1f), 103: uint8(0x20), 104: uint8(0x21), 105: uint8(0x22), 106: uint8(0x23), 107: uint8(0x24), 108: uint8(0x25), 109: uint8(0x26), 110: uint8(0x27), 111: uint8(0x28), 112: uint8(0x29), 113: uint8(0x2a), 114: uint8(0x2b), 115: uint8(0x2c), 116: uint8(0x2d), 117: uint8(0x2e), 118: uint8(0x2f), 119: uint8(0x30), 120: uint8(0x31), 121: uint8(0x32), 122: uint8(0x33), 123: uint8(0x83), 124: uint8(0x83), 125: uint8(0x83), 126: uint8(0x83), 127: uint8(0x83), 128: uint8(0x83), 129: uint8(0x83), 130: uint8(0x83), 131: uint8(0x83), 132: uint8(0x83), 133: uint8(0x83), 134: uint8(0x83), 135: uint8(0x83), 136: uint8(0x83), 137: uint8(0x83), 138: uint8(0x83), 139: uint8(0x83), 140: uint8(0x83), 141: uint8(0x83), 142: uint8(0x83), 143: uint8(0x83), 144: uint8(0x83), 145: uint8(0x83), 146: uint8(0x83), 147: uint8(0x83), 148: uint8(0x83), 149: uint8(0x83), 150: uint8(0x83), 151: uint8(0x83), 152: uint8(0x83), 153: uint8(0x83), 154: uint8(0x83), 155: uint8(0x83), 156: uint8(0x83), 157: uint8(0x83), 158: uint8(0x83), 159: uint8(0x83), 160: uint8(0x83), 161: uint8(0x83), 162: uint8(0x83), 163: uint8(0x83), 164: uint8(0x83), 165: uint8(0x83), 166: uint8(0x83), 167: uint8(0x83), 168: uint8(0x83), 169: uint8(0x83), 170: uint8(0x83), 171: uint8(0x83), 172: uint8(0x83), 173: uint8(0x83), 174: uint8(0x83), 175: uint8(0x83), 176: uint8(0x83), 177: uint8(0x83), 178: uint8(0x83), 179: uint8(0x83), 180: uint8(0x83), 181: uint8(0x83), 182: uint8(0x83), 183: uint8(0x83), 184: uint8(0x83), 185: uint8(0x83), 186: uint8(0x83), 187: uint8(0x83), 188: uint8(0x83), 189: uint8(0x83), 190: uint8(0x83), 191: uint8(0x83), 192: uint8(0x83), 193: uint8(0x83), 194: uint8(0x83), 195: uint8(0x83), 196: uint8(0x83), 197: uint8(0x83), 198: uint8(0x83), 199: uint8(0x83), 200: uint8(0x83), 201: uint8(0x83), 202: uint8(0x83), 203: uint8(0x83), 204: uint8(0x83), 205: uint8(0x83), 206: uint8(0x83), 207: uint8(0x83), 208: uint8(0x83), 209: uint8(0x83), 210: uint8(0x83), 211: uint8(0x83), 212: uint8(0x83), 213: uint8(0x83), 214: uint8(0x83), 215: uint8(0x83), 216: uint8(0x83), 217: uint8(0x83), 218: uint8(0x83), 219: uint8(0x83), 220: uint8(0x83), 221: uint8(0x83), 222: uint8(0x83), 223: uint8(0x83), 224: uint8(0x83), 225: uint8(0x83), 226: uint8(0x83), 227: uint8(0x83), 228: uint8(0x83), 229: uint8(0x83), 230: uint8(0x83), 231: uint8(0x83), 232: uint8(0x83), 233: uint8(0x83), 234: uint8(0x83), 235: uint8(0x83), 236: uint8(0x83), 237: uint8(0x83), 238: uint8(0x83), 239: uint8(0x83), 240: uint8(0x83), 241: uint8(0x83), 242: uint8(0x83), 243: uint8(0x83), 244: uint8(0x83), 245: uint8(0x83), 246: uint8(0x83), 247: uint8(0x83), 248: uint8(0x83), 249: uint8(0x83), 250: uint8(0x83), 251: uint8(0x83), 252: uint8(0x83), 253: uint8(0x83), 254: uint8(0x83), 255: uint8(0x83), } /* *---------------------------------------------------------------------- * * ReadByteArray -- * * This function is invoked to read the specified number of bytes from a * non-base64-encoded byte array provided via the -data option. * * Note: It would be better if the Tk_PhotoImage stuff handled this by * creating a channel from the -data value and made the data readable as * if it were coming from a file. * * Results: * TCL_OK, or TCL_ERROR if an I/O error occurs. * * Side effects: * The file position will change. The running CRC is updated if a pointer * to it is provided. * *---------------------------------------------------------------------- */ func _ReadByteArray(tls *libc.TLS, interp uintptr, pngPtr uintptr, destPtr uintptr, destSz TTcl_Size, crcPtr uintptr) (r int32) { bp := tls.Alloc(48) defer tls.Free(48) var blockSz TTcl_Size var v1 int64 _, _ = blockSz, v1 /* * Check to make sure the number of requested bytes are available. */ if (*TPNGImage)(unsafe.Pointer(pngPtr)).FstrDataLen < destSz { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+34605, int64(-libc.Int32FromInt32(1)))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+8, __ccgo_ts+179, __ccgo_ts+29667, __ccgo_ts+34591, __ccgo_ts+34634, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) } for destSz != 0 { if destSz < int64(libc.Int32FromInt32(PNG_BLOCK_SZ)) { v1 = destSz } else { v1 = int64(libc.Int32FromInt32(PNG_BLOCK_SZ)) } blockSz = v1 libc.Xmemcpy(tls, destPtr, (*TPNGImage)(unsafe.Pointer(pngPtr)).FstrDataBuf, libc.Uint64FromInt64(blockSz)) *(*uintptr)(unsafe.Pointer(pngPtr + 16)) += uintptr(blockSz) *(*TTcl_Size)(unsafe.Pointer(pngPtr + 24)) -= blockSz if crcPtr != 0 { *(*uint64)(unsafe.Pointer(crcPtr)) = uint64(libtcl9_0.XTcl_ZlibCRC32(tls, uint32(*(*uint64)(unsafe.Pointer(crcPtr))), destPtr, blockSz)) } destPtr += uintptr(blockSz) destSz -= blockSz } return TCL_OK } /* *---------------------------------------------------------------------- * * ReadData -- * * This function is invoked to read the specified number of bytes from * the image file or data. It is a wrapper around the choice of byte * array Tcl_Obj or Tcl_Channel which depends on whether the image data * is coming from a file or -data. * * Results: * TCL_OK, or TCL_ERROR if an I/O error occurs. * * Side effects: * The file position will change. The running CRC is updated if a pointer * to it is provided. * *---------------------------------------------------------------------- */ func _ReadData(tls *libc.TLS, interp uintptr, pngPtr uintptr, destPtr uintptr, destSz TTcl_Size, crcPtr uintptr) (r int32) { bp := tls.Alloc(48) defer tls.Free(48) var blockSz TTcl_Size var v1 int64 _, _ = blockSz, v1 if (*TPNGImage)(unsafe.Pointer(pngPtr)).Fbase64Data != 0 { return _ReadBase64(tls, interp, pngPtr, destPtr, destSz, crcPtr) } else { if (*TPNGImage)(unsafe.Pointer(pngPtr)).FstrDataBuf != 0 { return _ReadByteArray(tls, interp, pngPtr, destPtr, destSz, crcPtr) } } for destSz != 0 { if destSz < int64(libc.Int32FromInt32(PNG_BLOCK_SZ)) { v1 = destSz } else { v1 = int64(libc.Int32FromInt32(PNG_BLOCK_SZ)) } blockSz = v1 blockSz = libtcl9_0.XTcl_Read(tls, (*TPNGImage)(unsafe.Pointer(pngPtr)).Fchannel, destPtr, blockSz) if blockSz == int64(-libc.Int32FromInt32(1)) { /* TODO: failure info... */ libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+34644, libc.VaList(bp+8, libtcl9_0.XTcl_PosixError(tls, interp)))) return int32(TCL_ERROR) } /* * Update CRC, pointer, and remaining count if anything was read. */ if blockSz != 0 { if crcPtr != 0 { *(*uint64)(unsafe.Pointer(crcPtr)) = uint64(libtcl9_0.XTcl_ZlibCRC32(tls, uint32(*(*uint64)(unsafe.Pointer(crcPtr))), destPtr, blockSz)) } destPtr += uintptr(blockSz) destSz -= blockSz } /* * Check for EOF before all desired data was read. */ if destSz != 0 && libtcl9_0.XTcl_Eof(tls, (*TPNGImage)(unsafe.Pointer(pngPtr)).Fchannel) != 0 { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+34668, int64(-libc.Int32FromInt32(1)))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+8, __ccgo_ts+179, __ccgo_ts+29667, __ccgo_ts+34591, __ccgo_ts+34691, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) } } return TCL_OK } /* *---------------------------------------------------------------------- * * ReadInt32 -- * * This function is invoked to read a 32-bit integer in network byte * order from the image data and return the value in host byte order. * This is used, for example, to read the 32-bit CRC value for a chunk * stored in the image file for comparison with the calculated CRC value. * * Results: * TCL_OK, or TCL_ERROR if an I/O error occurs. * * Side effects: * The file position will change. The running CRC is updated if a pointer * to it is provided. * *---------------------------------------------------------------------- */ func _ReadInt32(tls *libc.TLS, interp uintptr, pngPtr uintptr, resultPtr uintptr, crcPtr uintptr) (r int32) { bp := tls.Alloc(16) defer tls.Free(16) var _ /* p at bp+0 */ [4]uint8 if _ReadData(tls, interp, pngPtr, bp, int64(4), crcPtr) == int32(TCL_ERROR) { return int32(TCL_ERROR) } *(*uint64)(unsafe.Pointer(resultPtr)) = uint64((*(*[4]uint8)(unsafe.Pointer(bp)))[0])< uint64(INT_MAX) { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+34716, int64(-int32(1)))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+32, __ccgo_ts+179, __ccgo_ts+29667, __ccgo_ts+34591, __ccgo_ts+34774, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) } chunkSz = libc.Int32FromUint64(temp) *(*uint64)(unsafe.Pointer(bp)) = uint64(libtcl9_0.XTcl_ZlibCRC32(tls, uint32(0), libc.UintptrFromInt32(0), 0)) /* * Read the 4-byte chunk type. */ if _ReadData(tls, interp, pngPtr, bp+8, int64(4), bp) == int32(TCL_ERROR) { return int32(TCL_ERROR) } /* * Convert it to a host-order integer for simple comparison. */ chunkType = uint64((*(*[4]uint8)(unsafe.Pointer(bp + 8)))[0])<> libc.Int32FromInt32(24) & libc.Uint64FromInt32(255)) (*(*[5]uint8)(unsafe.Pointer(bp + 15)))[int32(1)] = uint8(chunkType >> libc.Int32FromInt32(16) & libc.Uint64FromInt32(255)) (*(*[5]uint8)(unsafe.Pointer(bp + 15)))[int32(2)] = uint8(chunkType >> libc.Int32FromInt32(8) & libc.Uint64FromInt32(255)) (*(*[5]uint8)(unsafe.Pointer(bp + 15)))[int32(3)] = uint8(chunkType & libc.Uint64FromInt32(255)) (*(*[5]uint8)(unsafe.Pointer(bp + 15)))[int32(4)] = uint8('\000') libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+34829, libc.VaList(bp+32, bp+15))) } libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+32, __ccgo_ts+179, __ccgo_ts+29667, __ccgo_ts+34591, __ccgo_ts+34881, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) } /* * Check to see if the chunk type has legal bytes. */ i = 0 for { if !(i < int32(4)) { break } if libc.Int32FromUint8((*(*[4]uint8)(unsafe.Pointer(bp + 8)))[i]) < int32(65) || libc.Int32FromUint8((*(*[4]uint8)(unsafe.Pointer(bp + 8)))[i]) > int32(122) || libc.Int32FromUint8((*(*[4]uint8)(unsafe.Pointer(bp + 8)))[i]) > int32(90) && libc.Int32FromUint8((*(*[4]uint8)(unsafe.Pointer(bp + 8)))[i]) < int32(97) { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+34902, int64(-libc.Int32FromInt32(1)))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+32, __ccgo_ts+179, __ccgo_ts+29667, __ccgo_ts+34591, __ccgo_ts+34921, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) } goto _1 _1: ; i++ } /* * It seems to be an otherwise legally labelled ancillary chunk * that we don't want, so skip it after at least checking its CRC. */ if _SkipChunk(tls, interp, pngPtr, chunkSz, *(*uint64)(unsafe.Pointer(bp))) == int32(TCL_ERROR) { return int32(TCL_ERROR) } chunkType = uint64(0) } } /* * Found a known chunk type that's handled, albiet possibly not in the * right order. Send back the chunk type (for further checking or * handling), the chunk size and the current CRC for the rest of the * calculation. */ *(*uint64)(unsafe.Pointer(typePtr)) = chunkType *(*TTcl_Size)(unsafe.Pointer(sizePtr)) = int64(chunkSz) *(*uint64)(unsafe.Pointer(crcPtr)) = *(*uint64)(unsafe.Pointer(bp)) return TCL_OK } /* *---------------------------------------------------------------------- * * CheckColor -- * * Do validation on color type, depth, and related information, and * calculates storage requirements and offsets based on image dimensions * and color. * * Results: * TCL_OK, or TCL_ERROR if color information is invalid or some other * failure occurs. * * Side effects: * None * *---------------------------------------------------------------------- */ func _CheckColor(tls *libc.TLS, interp uintptr, pngPtr uintptr) (r int32) { bp := tls.Alloc(48) defer tls.Free(48) var offset, v10, v11, v12, v13, v9 int32 _, _, _, _, _, _ = offset, v10, v11, v12, v13, v9 /* * Verify the color type is valid and the bit depth is allowed. */ switch libc.Int32FromUint8((*TPNGImage)(unsafe.Pointer(pngPtr)).FcolorType) { case PNG_COLOR_GRAY: goto _1 case int32(PNG_COLOR_USED): goto _2 case libc.Int32FromInt32(PNG_COLOR_USED) | libc.Int32FromInt32(PNG_COLOR_INDEXED): goto _3 case libc.Int32FromInt32(PNG_COLOR_GRAY) | libc.Int32FromInt32(PNG_COLOR_ALPHA): goto _4 case libc.Int32FromInt32(PNG_COLOR_USED) | libc.Int32FromInt32(PNG_COLOR_ALPHA): goto _5 default: goto _6 } goto _7 _1: ; (*TPNGImage)(unsafe.Pointer(pngPtr)).FnumChannels = uint8(1) if int32(1) != libc.Int32FromUint8((*TPNGImage)(unsafe.Pointer(pngPtr)).FbitDepth) && int32(2) != libc.Int32FromUint8((*TPNGImage)(unsafe.Pointer(pngPtr)).FbitDepth) && int32(4) != libc.Int32FromUint8((*TPNGImage)(unsafe.Pointer(pngPtr)).FbitDepth) && int32(8) != libc.Int32FromUint8((*TPNGImage)(unsafe.Pointer(pngPtr)).FbitDepth) && int32(16) != libc.Int32FromUint8((*TPNGImage)(unsafe.Pointer(pngPtr)).FbitDepth) { goto unsupportedDepth } goto _7 _2: ; (*TPNGImage)(unsafe.Pointer(pngPtr)).FnumChannels = uint8(3) if int32(8) != libc.Int32FromUint8((*TPNGImage)(unsafe.Pointer(pngPtr)).FbitDepth) && int32(16) != libc.Int32FromUint8((*TPNGImage)(unsafe.Pointer(pngPtr)).FbitDepth) { goto unsupportedDepth } goto _7 _3: ; (*TPNGImage)(unsafe.Pointer(pngPtr)).FnumChannels = uint8(1) if int32(1) != libc.Int32FromUint8((*TPNGImage)(unsafe.Pointer(pngPtr)).FbitDepth) && int32(2) != libc.Int32FromUint8((*TPNGImage)(unsafe.Pointer(pngPtr)).FbitDepth) && int32(4) != libc.Int32FromUint8((*TPNGImage)(unsafe.Pointer(pngPtr)).FbitDepth) && int32(8) != libc.Int32FromUint8((*TPNGImage)(unsafe.Pointer(pngPtr)).FbitDepth) { goto unsupportedDepth } goto _7 _4: ; (*TPNGImage)(unsafe.Pointer(pngPtr)).FnumChannels = uint8(2) if int32(8) != libc.Int32FromUint8((*TPNGImage)(unsafe.Pointer(pngPtr)).FbitDepth) && int32(16) != libc.Int32FromUint8((*TPNGImage)(unsafe.Pointer(pngPtr)).FbitDepth) { goto unsupportedDepth } goto _7 _5: ; (*TPNGImage)(unsafe.Pointer(pngPtr)).FnumChannels = uint8(4) if !(int32(8) != libc.Int32FromUint8((*TPNGImage)(unsafe.Pointer(pngPtr)).FbitDepth) && int32(16) != libc.Int32FromUint8((*TPNGImage)(unsafe.Pointer(pngPtr)).FbitDepth)) { goto _8 } goto unsupportedDepth unsupportedDepth: ; libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+34935, int64(-libc.Int32FromInt32(1)))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+8, __ccgo_ts+179, __ccgo_ts+29667, __ccgo_ts+34591, __ccgo_ts+34981, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) _8: ; goto _7 _6: ; libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+34991, libc.VaList(bp+8, libc.Int32FromUint8((*TPNGImage)(unsafe.Pointer(pngPtr)).FcolorType)))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+8, __ccgo_ts+179, __ccgo_ts+29667, __ccgo_ts+34591, __ccgo_ts+35019, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) _7: ; /* * Set up the Tk photo block's pixel size and channel offsets. offset * array elements should already be 0 from the memset during InitPNGImage. */ if libc.Int32FromUint8((*TPNGImage)(unsafe.Pointer(pngPtr)).FbitDepth) > int32(8) { v9 = int32(2) } else { v9 = int32(1) } offset = v9 if libc.Int32FromUint8((*TPNGImage)(unsafe.Pointer(pngPtr)).FcolorType)&int32(PNG_COLOR_USED) != 0 { (*TPNGImage)(unsafe.Pointer(pngPtr)).Fblock.FpixelSize = offset * int32(4) *(*int32)(unsafe.Pointer(pngPtr + 80 + 24 + 1*4)) = offset *(*int32)(unsafe.Pointer(pngPtr + 80 + 24 + 2*4)) = offset * int32(2) *(*int32)(unsafe.Pointer(pngPtr + 80 + 24 + 3*4)) = offset * int32(3) } else { (*TPNGImage)(unsafe.Pointer(pngPtr)).Fblock.FpixelSize = offset * int32(2) *(*int32)(unsafe.Pointer(pngPtr + 80 + 24 + 3*4)) = offset } /* * Calculate the block pitch, which is the number of bytes per line in the * image, given image width and depth of color. Make sure that it it isn't * larger than Tk can handle. */ if (*TPNGImage)(unsafe.Pointer(pngPtr)).Fblock.Fwidth > int32(INT_MAX)/(*TPNGImage)(unsafe.Pointer(pngPtr)).Fblock.FpixelSize { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+35033, int64(-int32(1)))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+8, __ccgo_ts+179, __ccgo_ts+29667, __ccgo_ts+34591, __ccgo_ts+35092, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) } (*TPNGImage)(unsafe.Pointer(pngPtr)).Fblock.Fpitch = (*TPNGImage)(unsafe.Pointer(pngPtr)).Fblock.FpixelSize * (*TPNGImage)(unsafe.Pointer(pngPtr)).Fblock.Fwidth /* * Calculate the total size of the image as represented to Tk given pitch * and image height. Make sure that it isn't larger than Tk can handle. */ if (*TPNGImage)(unsafe.Pointer(pngPtr)).Fblock.Fheight > int32(INT_MAX)/(*TPNGImage)(unsafe.Pointer(pngPtr)).Fblock.Fpitch { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+35098, int64(-int32(1)))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+8, __ccgo_ts+179, __ccgo_ts+29667, __ccgo_ts+34591, __ccgo_ts+35162, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) } (*TPNGImage)(unsafe.Pointer(pngPtr)).FblockLen = (*TPNGImage)(unsafe.Pointer(pngPtr)).Fblock.Fheight * (*TPNGImage)(unsafe.Pointer(pngPtr)).Fblock.Fpitch /* * Determine number of bytes per pixel in the source for later use. */ switch libc.Int32FromUint8((*TPNGImage)(unsafe.Pointer(pngPtr)).FcolorType) { case PNG_COLOR_GRAY: if libc.Int32FromUint8((*TPNGImage)(unsafe.Pointer(pngPtr)).FbitDepth) > int32(8) { v10 = int32(2) } else { v10 = int32(1) } (*TPNGImage)(unsafe.Pointer(pngPtr)).FbytesPerPixel = libc.Uint8FromInt32(v10) case int32(PNG_COLOR_USED): if libc.Int32FromUint8((*TPNGImage)(unsafe.Pointer(pngPtr)).FbitDepth) > int32(8) { v11 = int32(6) } else { v11 = int32(3) } (*TPNGImage)(unsafe.Pointer(pngPtr)).FbytesPerPixel = libc.Uint8FromInt32(v11) case libc.Int32FromInt32(PNG_COLOR_USED) | libc.Int32FromInt32(PNG_COLOR_INDEXED): (*TPNGImage)(unsafe.Pointer(pngPtr)).FbytesPerPixel = uint8(1) case libc.Int32FromInt32(PNG_COLOR_GRAY) | libc.Int32FromInt32(PNG_COLOR_ALPHA): if libc.Int32FromUint8((*TPNGImage)(unsafe.Pointer(pngPtr)).FbitDepth) > int32(8) { v12 = int32(4) } else { v12 = int32(2) } (*TPNGImage)(unsafe.Pointer(pngPtr)).FbytesPerPixel = libc.Uint8FromInt32(v12) case libc.Int32FromInt32(PNG_COLOR_USED) | libc.Int32FromInt32(PNG_COLOR_ALPHA): if libc.Int32FromUint8((*TPNGImage)(unsafe.Pointer(pngPtr)).FbitDepth) > int32(8) { v13 = int32(8) } else { v13 = int32(4) } (*TPNGImage)(unsafe.Pointer(pngPtr)).FbytesPerPixel = libc.Uint8FromInt32(v13) default: libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+35167, libc.VaList(bp+8, libc.Int32FromUint8((*TPNGImage)(unsafe.Pointer(pngPtr)).FcolorType)))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+8, __ccgo_ts+179, __ccgo_ts+29667, __ccgo_ts+34591, __ccgo_ts+35019, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) } /* * Calculate scale factor for bit depths less than 8, in order to adjust * them to a minimum of 8 bits per pixel in the Tk image. */ if libc.Int32FromUint8((*TPNGImage)(unsafe.Pointer(pngPtr)).FbitDepth) < int32(8) { (*TPNGImage)(unsafe.Pointer(pngPtr)).FbitScale = int32(255) / int32(libc.Xpow(tls, libc.Float64FromInt32(2), float64((*TPNGImage)(unsafe.Pointer(pngPtr)).FbitDepth))-libc.Float64FromInt32(1)) } else { (*TPNGImage)(unsafe.Pointer(pngPtr)).FbitScale = int32(1) } return TCL_OK } /* *---------------------------------------------------------------------- * * ReadIHDR -- * * This function reads the PNG header from the beginning of a PNG file * and returns the dimensions of the image. * * Results: * The return value is 1 if file "f" appears to start with a valid PNG * header, 0 otherwise. If the header is valid, then *widthPtr and * *heightPtr are modified to hold the dimensions of the image. * * Side effects: * The access position in f advances. * *---------------------------------------------------------------------- */ func _ReadIHDR(tls *libc.TLS, interp uintptr, pngPtr uintptr) (r int32) { bp := tls.Alloc(96) defer tls.Free(96) var mismatch int32 var _ /* chunkSz at bp+16 */ TTcl_Size var _ /* chunkType at bp+8 */ uint64 var _ /* crc at bp+24 */ uint64 var _ /* height at bp+40 */ uint64 var _ /* sigBuf at bp+0 */ [8]uint8 var _ /* width at bp+32 */ uint64 _ = mismatch /* * Read the appropriate number of bytes for the PNG signature. */ if _ReadData(tls, interp, pngPtr, bp, int64(PNG_SIG_SZ), libc.UintptrFromInt32(0)) == int32(TCL_ERROR) { return int32(TCL_ERROR) } /* * Compare the read bytes to the expected signature. */ mismatch = libc.Xmemcmp(tls, bp, uintptr(unsafe.Pointer(&_pngSignature)), uint64(PNG_SIG_SZ)) /* * If reading from string, reset position and try base64 decode. */ if mismatch != 0 && (*TPNGImage)(unsafe.Pointer(pngPtr)).FstrDataBuf != 0 { (*TPNGImage)(unsafe.Pointer(pngPtr)).FstrDataBuf = libtcl9_0.XTcl_GetBytesFromObj(tls, libc.UintptrFromInt32(0), (*TPNGImage)(unsafe.Pointer(pngPtr)).FobjDataPtr, pngPtr+24) (*TPNGImage)(unsafe.Pointer(pngPtr)).Fbase64Data = (*TPNGImage)(unsafe.Pointer(pngPtr)).FstrDataBuf if _ReadData(tls, interp, pngPtr, bp, int64(PNG_SIG_SZ), libc.UintptrFromInt32(0)) == int32(TCL_ERROR) { return int32(TCL_ERROR) } mismatch = libc.Xmemcmp(tls, bp, uintptr(unsafe.Pointer(&_pngSignature)), uint64(PNG_SIG_SZ)) } if mismatch != 0 { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+35189, int64(-libc.Int32FromInt32(1)))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+56, __ccgo_ts+179, __ccgo_ts+29667, __ccgo_ts+34591, __ccgo_ts+35231, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) } if _ReadChunkHeader(tls, interp, pngPtr, bp+16, bp+8, bp+24) == int32(TCL_ERROR) { return int32(TCL_ERROR) } /* * Read in the IHDR (header) chunk for width, height, etc. * * The first chunk in the file must be the IHDR (headr) chunk. */ if *(*uint64)(unsafe.Pointer(bp + 8)) != libc.Uint64FromInt32(libc.Int32FromUint8('I'))< uint64(INT_MAX) || *(*uint64)(unsafe.Pointer(bp + 40)) > uint64(INT_MAX) { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+35304, int64(-int32(1)))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+56, __ccgo_ts+179, __ccgo_ts+29667, __ccgo_ts+34591, __ccgo_ts+34299, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) } /* * Set height and width for the Tk photo block. */ (*TPNGImage)(unsafe.Pointer(pngPtr)).Fblock.Fwidth = libc.Int32FromUint64(*(*uint64)(unsafe.Pointer(bp + 32))) (*TPNGImage)(unsafe.Pointer(pngPtr)).Fblock.Fheight = libc.Int32FromUint64(*(*uint64)(unsafe.Pointer(bp + 40))) /* * Read and the Bit Depth and Color Type. */ if _ReadData(tls, interp, pngPtr, pngPtr+56, int64(1), bp+24) == int32(TCL_ERROR) { return int32(TCL_ERROR) } if _ReadData(tls, interp, pngPtr, pngPtr+57, int64(1), bp+24) == int32(TCL_ERROR) { return int32(TCL_ERROR) } /* * Verify that the color type is valid, the bit depth is allowed for the * color type, and calculate the number of channels and pixel depth (bits * per pixel * channels). Also set up offsets and sizes in the Tk photo * block for the pixel data. */ if _CheckColor(tls, interp, pngPtr) == int32(TCL_ERROR) { return int32(TCL_ERROR) } /* * Only one compression method is currently defined by the standard. */ if _ReadData(tls, interp, pngPtr, pngPtr+58, int64(1), bp+24) == int32(TCL_ERROR) { return int32(TCL_ERROR) } if libc.Int32FromUint8((*TPNGImage)(unsafe.Pointer(pngPtr)).Fcompression) != PNG_COMPRESS_DEFLATE { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+35363, libc.VaList(bp+56, libc.Int32FromUint8((*TPNGImage)(unsafe.Pointer(pngPtr)).Fcompression)))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+56, __ccgo_ts+179, __ccgo_ts+29667, __ccgo_ts+34591, __ccgo_ts+35393, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) } /* * Only one filter method is currently defined by the standard; the method * has five actual filter types associated with it. */ if _ReadData(tls, interp, pngPtr, pngPtr+59, int64(1), bp+24) == int32(TCL_ERROR) { return int32(TCL_ERROR) } if libc.Int32FromUint8((*TPNGImage)(unsafe.Pointer(pngPtr)).Ffilter) != PNG_FILTMETH_STANDARD { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+35406, libc.VaList(bp+56, libc.Int32FromUint8((*TPNGImage)(unsafe.Pointer(pngPtr)).Ffilter)))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+56, __ccgo_ts+179, __ccgo_ts+29667, __ccgo_ts+34591, __ccgo_ts+35431, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) } if _ReadData(tls, interp, pngPtr, pngPtr+60, int64(1), bp+24) == int32(TCL_ERROR) { return int32(TCL_ERROR) } switch libc.Int32FromUint8((*TPNGImage)(unsafe.Pointer(pngPtr)).Finterlace) { case PNG_INTERLACE_NONE: fallthrough case int32(PNG_INTERLACE_ADAM7): default: libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+35442, libc.VaList(bp+56, libc.Int32FromUint8((*TPNGImage)(unsafe.Pointer(pngPtr)).Finterlace)))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+56, __ccgo_ts+179, __ccgo_ts+29667, __ccgo_ts+34591, __ccgo_ts+35470, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) } return _CheckCRC(tls, interp, pngPtr, *(*uint64)(unsafe.Pointer(bp + 24))) } /* *---------------------------------------------------------------------- * * ReadPLTE -- * * This function reads the PLTE (indexed color palette) chunk data from * the PNG file and populates the palette table in the PNGImage * structure. * * Results: * TCL_OK, or TCL_ERROR if an I/O error occurs or the PLTE chunk is * invalid. * * Side effects: * The access position in f advances. * *---------------------------------------------------------------------- */ func _ReadPLTE(tls *libc.TLS, interp uintptr, pngPtr uintptr, chunkSz int32, _crc uint64) (r int32) { bp := tls.Alloc(832) defer tls.Free(832) *(*uint64)(unsafe.Pointer(bp)) = _crc var c, i, v2, v3, v4 int32 var _ /* buffer at bp+8 */ [768]uint8 _, _, _, _, _ = c, i, v2, v3, v4 /* * This chunk is mandatory for color type 3 and forbidden for 2 and 6. */ switch libc.Int32FromUint8((*TPNGImage)(unsafe.Pointer(pngPtr)).FcolorType) { case PNG_COLOR_GRAY: fallthrough case libc.Int32FromInt32(PNG_COLOR_GRAY) | libc.Int32FromInt32(PNG_COLOR_ALPHA): libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+35484, int64(-libc.Int32FromInt32(1)))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+784, __ccgo_ts+179, __ccgo_ts+29667, __ccgo_ts+34591, __ccgo_ts+35524, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) default: break } /* * The palette chunk contains from 1 to 256 palette entries. Each entry * consists of a 3-byte RGB value. It must therefore contain a non-zero * multiple of 3 bytes, up to 768. */ if !(chunkSz != 0) || chunkSz > int32(PNG_PLTE_MAXSZ) || chunkSz%int32(3) != 0 { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+35540, int64(-libc.Int32FromInt32(1)))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+784, __ccgo_ts+179, __ccgo_ts+29667, __ccgo_ts+34591, __ccgo_ts+35567, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) } /* * Read the palette contents and stash them for later, possibly. */ if _ReadData(tls, interp, pngPtr, bp+8, int64(chunkSz), bp) == int32(TCL_ERROR) { return int32(TCL_ERROR) } if _CheckCRC(tls, interp, pngPtr, *(*uint64)(unsafe.Pointer(bp))) == int32(TCL_ERROR) { return int32(TCL_ERROR) } /* * Stash away the palette entries and entry count for later mapping each * pixel's palette index to its color. */ i = 0 c = libc.Int32FromInt32(0) for { if !(c < chunkSz) { break } v2 = c c++ (*(*struct { Fred uint8 Fgreen uint8 Fblue uint8 Falpha uint8 })(unsafe.Pointer(pngPtr + 132 + uintptr(i)*4))).Fred = (*(*[768]uint8)(unsafe.Pointer(bp + 8)))[v2] v3 = c c++ (*(*struct { Fred uint8 Fgreen uint8 Fblue uint8 Falpha uint8 })(unsafe.Pointer(pngPtr + 132 + uintptr(i)*4))).Fgreen = (*(*[768]uint8)(unsafe.Pointer(bp + 8)))[v3] v4 = c c++ (*(*struct { Fred uint8 Fgreen uint8 Fblue uint8 Falpha uint8 })(unsafe.Pointer(pngPtr + 132 + uintptr(i)*4))).Fblue = (*(*[768]uint8)(unsafe.Pointer(bp + 8)))[v4] goto _1 _1: ; i++ } (*TPNGImage)(unsafe.Pointer(pngPtr)).FpaletteLen = i return TCL_OK } /* *---------------------------------------------------------------------- * * ReadTRNS -- * * This function reads the tRNS (transparency) chunk data from the PNG * file and populates the alpha field of the palette table in the * PNGImage structure or the single color transparency, as appropriate * for the color type. * * Results: * TCL_OK, or TCL_ERROR if an I/O error occurs or the tRNS chunk is * invalid. * * Side effects: * The access position in f advances. * *---------------------------------------------------------------------- */ func _ReadTRNS(tls *libc.TLS, interp uintptr, pngPtr uintptr, chunkSz int32, _crc uint64) (r int32) { bp := tls.Alloc(320) defer tls.Free(320) *(*uint64)(unsafe.Pointer(bp)) = _crc var i int32 var _ /* buffer at bp+8 */ [256]uint8 _ = i if libc.Int32FromUint8((*TPNGImage)(unsafe.Pointer(pngPtr)).FcolorType)&int32(PNG_COLOR_ALPHA) != 0 { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+35576, int64(-int32(1)))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+272, __ccgo_ts+179, __ccgo_ts+29667, __ccgo_ts+34591, __ccgo_ts+35637, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) } /* * For indexed color, there is up to one single-byte transparency value * per palette entry (thus a max of 256). */ if chunkSz > int32(PNG_TRNS_MAXSZ) { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+35650, int64(-libc.Int32FromInt32(1)))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+272, __ccgo_ts+179, __ccgo_ts+29667, __ccgo_ts+34591, __ccgo_ts+35674, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) } /* * Read in the raw transparency information. */ if _ReadData(tls, interp, pngPtr, bp+8, int64(chunkSz), bp) == int32(TCL_ERROR) { return int32(TCL_ERROR) } if _CheckCRC(tls, interp, pngPtr, *(*uint64)(unsafe.Pointer(bp))) == int32(TCL_ERROR) { return int32(TCL_ERROR) } switch libc.Int32FromUint8((*TPNGImage)(unsafe.Pointer(pngPtr)).FcolorType) { case libc.Int32FromInt32(PNG_COLOR_GRAY) | libc.Int32FromInt32(PNG_COLOR_ALPHA): fallthrough case libc.Int32FromInt32(PNG_COLOR_USED) | libc.Int32FromInt32(PNG_COLOR_ALPHA): case libc.Int32FromInt32(PNG_COLOR_USED) | libc.Int32FromInt32(PNG_COLOR_INDEXED): /* * The number of tRNS entries must be less than or equal to the number * of PLTE entries, and consists of a single-byte alpha level for the * corresponding PLTE entry. */ if chunkSz > (*TPNGImage)(unsafe.Pointer(pngPtr)).FpaletteLen { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+35683, int64(-libc.Int32FromInt32(1)))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+272, __ccgo_ts+179, __ccgo_ts+29667, __ccgo_ts+34591, __ccgo_ts+35731, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) } i = 0 for { if !(i < chunkSz) { break } (*(*struct { Fred uint8 Fgreen uint8 Fblue uint8 Falpha uint8 })(unsafe.Pointer(pngPtr + 132 + uintptr(i)*4))).Falpha = (*(*[256]uint8)(unsafe.Pointer(bp + 8)))[i] goto _1 _1: ; i++ } case PNG_COLOR_GRAY: /* * Grayscale uses a single 2-byte gray level, which we'll store in * palette index 0, since we're not using the palette. */ if chunkSz != int32(2) { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+35741, int64(-int32(1)))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+272, __ccgo_ts+179, __ccgo_ts+29667, __ccgo_ts+34591, __ccgo_ts+35674, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) } /* * According to the PNG specs, if the bit depth is less than 16, then * only the lower byte is used. */ if int32(16) == libc.Int32FromUint8((*TPNGImage)(unsafe.Pointer(pngPtr)).FbitDepth) { *(*uint8)(unsafe.Pointer(pngPtr + 1156)) = (*(*[256]uint8)(unsafe.Pointer(bp + 8)))[0] *(*uint8)(unsafe.Pointer(pngPtr + 1156 + 1)) = (*(*[256]uint8)(unsafe.Pointer(bp + 8)))[int32(1)] } else { *(*uint8)(unsafe.Pointer(pngPtr + 1156)) = (*(*[256]uint8)(unsafe.Pointer(bp + 8)))[int32(1)] } (*TPNGImage)(unsafe.Pointer(pngPtr)).FuseTRNS = int32(1) case int32(PNG_COLOR_USED): /* * TrueColor uses a single RRGGBB triplet. */ if chunkSz != int32(6) { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+35794, int64(-libc.Int32FromInt32(1)))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+272, __ccgo_ts+179, __ccgo_ts+29667, __ccgo_ts+34591, __ccgo_ts+35674, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) } /* * According to the PNG specs, if the bit depth is less than 16, then * only the lower byte is used. But the tRNS chunk still contains two * bytes per channel. */ if int32(16) == libc.Int32FromUint8((*TPNGImage)(unsafe.Pointer(pngPtr)).FbitDepth) { libc.Xmemcpy(tls, pngPtr+1156, bp+8, uint64(6)) } else { *(*uint8)(unsafe.Pointer(pngPtr + 1156)) = (*(*[256]uint8)(unsafe.Pointer(bp + 8)))[int32(1)] *(*uint8)(unsafe.Pointer(pngPtr + 1156 + 1)) = (*(*[256]uint8)(unsafe.Pointer(bp + 8)))[int32(3)] *(*uint8)(unsafe.Pointer(pngPtr + 1156 + 2)) = (*(*[256]uint8)(unsafe.Pointer(bp + 8)))[int32(5)] } (*TPNGImage)(unsafe.Pointer(pngPtr)).FuseTRNS = int32(1) break } return TCL_OK } /* *---------------------------------------------------------------------- * * ReadPHYS -- * * This function reads the PHYS (physical size) chunk data from * the PNG file and populates the fields in the PNGImage * structure. * * Results: * TCL_OK, or TCL_ERROR if an I/O error occurs or the PHYS chunk is * invalid. * * Side effects: * The access position in f advances. * *---------------------------------------------------------------------- */ func _ReadPHYS(tls *libc.TLS, interp uintptr, pngPtr uintptr, chunkSz int32, _crc uint64) (r int32) { bp := tls.Alloc(80) defer tls.Free(80) *(*uint64)(unsafe.Pointer(bp)) = _crc var _ /* PPUx at bp+8 */ uint64 var _ /* PPUy at bp+16 */ uint64 var _ /* unitSpecifier at bp+24 */ uint8 /* * Check chunk size equal 9 bytes */ if chunkSz != int32(9) { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+35841, int64(-libc.Int32FromInt32(1)))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+40, __ccgo_ts+179, __ccgo_ts+29667, __ccgo_ts+34591, __ccgo_ts+35869, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) } /* * Read the chunk data * 4 bytes: Pixels per unit, x axis * 4 bytes: Pixels per unit, y axis * 1 byte: unit specifier */ if _ReadInt32(tls, interp, pngPtr, bp+8, bp) == int32(TCL_ERROR) { return int32(TCL_ERROR) } if _ReadInt32(tls, interp, pngPtr, bp+16, bp) == int32(TCL_ERROR) { return int32(TCL_ERROR) } if _ReadData(tls, interp, pngPtr, bp+24, int64(1), bp) == int32(TCL_ERROR) { return int32(TCL_ERROR) } if _CheckCRC(tls, interp, pngPtr, *(*uint64)(unsafe.Pointer(bp))) == int32(TCL_ERROR) { return int32(TCL_ERROR) } if *(*uint64)(unsafe.Pointer(bp + 8)) > uint64(2147483647) || *(*uint64)(unsafe.Pointer(bp + 16)) > uint64(2147483647) || libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(bp + 24))) > int32(1) { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+35878, int64(-libc.Int32FromInt32(1)))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+40, __ccgo_ts+179, __ccgo_ts+29667, __ccgo_ts+34591, __ccgo_ts+35869, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) } if *(*uint64)(unsafe.Pointer(bp + 8)) > uint64(0) { (*TPNGImage)(unsafe.Pointer(pngPtr)).Faspect = float64(*(*uint64)(unsafe.Pointer(bp + 16))) / float64(*(*uint64)(unsafe.Pointer(bp + 8))) } if int32(1) == libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(bp + 24))) { (*TPNGImage)(unsafe.Pointer(pngPtr)).FDPI = float64(float64(*(*uint64)(unsafe.Pointer(bp + 8))) * float64(0.0254)) } return TCL_OK } /* *---------------------------------------------------------------------- * * Paeth -- * * Utility function for applying the Paeth filter to a pixel. The Paeth * filter is a linear function of the pixel to be filtered and the pixels * to the left, above, and above-left of the pixel to be unfiltered. * * Results: * Result of the Paeth function for the left, above, and above-left * pixels. * * Side effects: * None * *---------------------------------------------------------------------- */ func _Paeth(tls *libc.TLS, a int32, b int32, c int32) (r uint8) { var pa, pb, pc int32 _, _, _ = pa, pb, pc pa = libc.Xabs(tls, b-c) pb = libc.Xabs(tls, a-c) pc = libc.Xabs(tls, a+b-c-c) if pa <= pb && pa <= pc { return libc.Uint8FromInt32(a) } if pb <= pc { return libc.Uint8FromInt32(b) } return libc.Uint8FromInt32(c) } /* *---------------------------------------------------------------------- * * UnfilterLine -- * * Applies the filter algorithm specified in first byte of a line to the * line of pixels being read from a PNG image. * * PNG specifies four filter algorithms (Sub, Up, Average, and Paeth) * that combine a pixel's value with those of other pixels in the same * and/or previous lines. Filtering is intended to make an image more * compressible. * * Results: * TCL_OK, or TCL_ERROR if the filter type is not recognized. * * Side effects: * Pixel data in thisLineObj are modified. * *---------------------------------------------------------------------- */ func _UnfilterLine(tls *libc.TLS, interp uintptr, pngPtr uintptr) (r int32) { bp := tls.Alloc(48) defer tls.Free(48) var end, end1, end2, end21, end22, end3, end4, end5, lastLine, prior, prior1, prior2, priorBpp, raw, raw1, raw2, raw3, raw4, raw5, rawBpp, rawBpp1, rawBpp2, rawBpp3, rawBpp4, thisLine, v11, v12, v13, v15, v16, v18, v19, v2, v21, v22, v23, v24, v26, v27, v3, v5, v6, v8, v9, p1, p10, p14, p17, p20, p25, p4, p7 uintptr _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = end, end1, end2, end21, end22, end3, end4, end5, lastLine, prior, prior1, prior2, priorBpp, raw, raw1, raw2, raw3, raw4, raw5, rawBpp, rawBpp1, rawBpp2, rawBpp3, rawBpp4, thisLine, v11, v12, v13, v15, v16, v18, v19, v2, v21, v22, v23, v24, v26, v27, v3, v5, v6, v8, v9, p1, p10, p14, p17, p20, p25, p4, p7 thisLine = libtcl9_0.XTcl_GetBytesFromObj(tls, libc.UintptrFromInt32(0), (*TPNGImage)(unsafe.Pointer(pngPtr)).FthisLineObj, libc.UintptrFromInt32(0)) lastLine = libtcl9_0.XTcl_GetBytesFromObj(tls, libc.UintptrFromInt32(0), (*TPNGImage)(unsafe.Pointer(pngPtr)).FlastLineObj, libc.UintptrFromInt32(0)) switch libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(thisLine))) { case PNG_FILTER_NONE: /* Nothing to do */ case int32(PNG_FILTER_SUB): /* Sub(x) = Raw(x) - Raw(x-bpp) */ rawBpp = thisLine + uintptr(1) raw = rawBpp + uintptr((*TPNGImage)(unsafe.Pointer(pngPtr)).FbytesPerPixel) end = thisLine + uintptr((*TPNGImage)(unsafe.Pointer(pngPtr)).FphaseSize) for raw < end { v2 = raw raw++ p1 = v2 v3 = rawBpp rawBpp++ *(*uint8)(unsafe.Pointer(p1)) = uint8(int32(*(*uint8)(unsafe.Pointer(p1))) + libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(v3)))) } case int32(PNG_FILTER_UP): /* Up(x) = Raw(x) - Prior(x) */ if (*TPNGImage)(unsafe.Pointer(pngPtr)).FcurrentLine > _startLine[(*TPNGImage)(unsafe.Pointer(pngPtr)).Fphase] { prior = lastLine + uintptr(1) raw1 = thisLine + uintptr(1) end1 = thisLine + uintptr((*TPNGImage)(unsafe.Pointer(pngPtr)).FphaseSize) for raw1 < end1 { v5 = raw1 raw1++ p4 = v5 v6 = prior prior++ *(*uint8)(unsafe.Pointer(p4)) = uint8(int32(*(*uint8)(unsafe.Pointer(p4))) + libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(v6)))) } } case int32(PNG_FILTER_AVG): /* Avg(x) = Raw(x) - floor((Raw(x-bpp)+Prior(x))/2) */ if (*TPNGImage)(unsafe.Pointer(pngPtr)).FcurrentLine > _startLine[(*TPNGImage)(unsafe.Pointer(pngPtr)).Fphase] { prior1 = lastLine + uintptr(1) rawBpp1 = thisLine + uintptr(1) raw2 = rawBpp1 end2 = thisLine + uintptr((*TPNGImage)(unsafe.Pointer(pngPtr)).FphaseSize) end21 = raw2 + uintptr((*TPNGImage)(unsafe.Pointer(pngPtr)).FbytesPerPixel) for raw2 < end21 && raw2 < end2 { v8 = raw2 raw2++ p7 = v8 v9 = prior1 prior1++ *(*uint8)(unsafe.Pointer(p7)) = uint8(int32(*(*uint8)(unsafe.Pointer(p7))) + libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(v9)))/libc.Int32FromInt32(2)) } for raw2 < end2 { v11 = raw2 raw2++ p10 = v11 v12 = rawBpp1 rawBpp1++ v13 = prior1 prior1++ *(*uint8)(unsafe.Pointer(p10)) = uint8(int32(*(*uint8)(unsafe.Pointer(p10))) + libc.Int32FromUint8(libc.Uint8FromInt32((libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(v12)))+libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(v13))))/libc.Int32FromInt32(2)))) } } else { rawBpp2 = thisLine + uintptr(1) raw3 = rawBpp2 + uintptr((*TPNGImage)(unsafe.Pointer(pngPtr)).FbytesPerPixel) end3 = thisLine + uintptr((*TPNGImage)(unsafe.Pointer(pngPtr)).FphaseSize) for raw3 < end3 { v15 = raw3 raw3++ p14 = v15 v16 = rawBpp2 rawBpp2++ *(*uint8)(unsafe.Pointer(p14)) = uint8(int32(*(*uint8)(unsafe.Pointer(p14))) + libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(v16)))/libc.Int32FromInt32(2)) } } case int32(PNG_FILTER_PAETH): /* Paeth(x) = Raw(x) - PaethPredictor(Raw(x-bpp), Prior(x), Prior(x-bpp)) */ if (*TPNGImage)(unsafe.Pointer(pngPtr)).FcurrentLine > _startLine[(*TPNGImage)(unsafe.Pointer(pngPtr)).Fphase] { priorBpp = lastLine + uintptr(1) prior2 = priorBpp rawBpp3 = thisLine + uintptr(1) raw4 = rawBpp3 end4 = thisLine + uintptr((*TPNGImage)(unsafe.Pointer(pngPtr)).FphaseSize) end22 = rawBpp3 + uintptr((*TPNGImage)(unsafe.Pointer(pngPtr)).FbytesPerPixel) for raw4 < end4 && raw4 < end22 { v18 = raw4 raw4++ p17 = v18 v19 = prior2 prior2++ *(*uint8)(unsafe.Pointer(p17)) = uint8(int32(*(*uint8)(unsafe.Pointer(p17))) + libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(v19)))) } for raw4 < end4 { v21 = raw4 raw4++ p20 = v21 v22 = rawBpp3 rawBpp3++ v23 = prior2 prior2++ v24 = priorBpp priorBpp++ *(*uint8)(unsafe.Pointer(p20)) = uint8(int32(*(*uint8)(unsafe.Pointer(p20))) + libc.Int32FromUint8(_Paeth(tls, libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(v22))), libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(v23))), libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(v24)))))) } } else { rawBpp4 = thisLine + uintptr(1) raw5 = rawBpp4 + uintptr((*TPNGImage)(unsafe.Pointer(pngPtr)).FbytesPerPixel) end5 = thisLine + uintptr((*TPNGImage)(unsafe.Pointer(pngPtr)).FphaseSize) for raw5 < end5 { v26 = raw5 raw5++ p25 = v26 v27 = rawBpp4 rawBpp4++ *(*uint8)(unsafe.Pointer(p25)) = uint8(int32(*(*uint8)(unsafe.Pointer(p25))) + libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(v27)))) } } default: libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+35906, libc.VaList(bp+8, libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(thisLine)))))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+8, __ccgo_ts+179, __ccgo_ts+29667, __ccgo_ts+34591, __ccgo_ts+35431, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) } return TCL_OK } /* *---------------------------------------------------------------------- * * DecodeLine -- * * Unfilters a line of pixels from the PNG source data and decodes the * data into the Tk_PhotoImageBlock for later copying into the Tk image. * * Results: * TCL_OK, or TCL_ERROR if the filter type is not recognized. * * Side effects: * Pixel data in thisLine and block are modified and state information * updated. * *---------------------------------------------------------------------- */ func _DecodeLine(tls *libc.TLS, interp uintptr, pngPtr uintptr) (r int32) { bp := tls.Alloc(64) defer tls.Free(64) var alpha, chan1, pixBits, readByte uint8 var colNum, colStep, haveBits, offset, pixStep, shifts, v10, v11, v12, v13, v4, v6, v7, v8, v9 int32 var p, pixelPtr, v3, v5 uintptr var pixels uint64 var _ /* lastPixel at bp+0 */ [6]uint8 _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = alpha, chan1, colNum, colStep, haveBits, offset, p, pixBits, pixStep, pixelPtr, pixels, readByte, shifts, v10, v11, v12, v13, v3, v4, v5, v6, v7, v8, v9 pixelPtr = (*TPNGImage)(unsafe.Pointer(pngPtr)).Fblock.FpixelPtr colNum = 0 /* Current pixel column */ chan1 = uint8(0) /* Current channel (0..3) = (R, G, B, A) */ readByte = uint8(0) /* Current scan line byte */ haveBits = 0 /* Number of bits remaining in current byte */ pixBits = uint8(0) /* Extracted bits for current channel */ shifts = 0 /* Number of channels extracted from byte */ offset = 0 /* Current offset into pixelPtr */ colStep = int32(1) /* Column increment each pass */ pixStep = 0 p = libtcl9_0.XTcl_GetBytesFromObj(tls, libc.UintptrFromInt32(0), (*TPNGImage)(unsafe.Pointer(pngPtr)).FthisLineObj, libc.UintptrFromInt32(0)) p++ if _UnfilterLine(tls, interp, pngPtr) == int32(TCL_ERROR) { return int32(TCL_ERROR) } if (*TPNGImage)(unsafe.Pointer(pngPtr)).FcurrentLine >= (*TPNGImage)(unsafe.Pointer(pngPtr)).Fblock.Fheight { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+35929, 0)) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+16, __ccgo_ts+179, __ccgo_ts+29667, __ccgo_ts+34591, __ccgo_ts+35953, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) } if (*TPNGImage)(unsafe.Pointer(pngPtr)).Finterlace != 0 { switch libc.Int32FromUint8((*TPNGImage)(unsafe.Pointer(pngPtr)).Fphase) { case int32(1): /* Phase 1: */ colStep = int32(8) /* 1 pixel per block of 8 per line */ case int32(2): /* Phase 2: */ colStep = int32(8) /* 1 pixels per block of 8 per line */ colNum = int32(4) /* Start at column 4 */ case int32(3): /* Phase 3: */ colStep = int32(4) /* 2 pixels per block of 8 per line */ case int32(4): /* Phase 4: */ colStep = int32(4) /* 2 pixels per block of 8 per line */ colNum = int32(2) /* Start at column 2 */ case int32(5): /* Phase 5: */ colStep = int32(2) /* 4 pixels per block of 8 per line */ case int32(6): /* Phase 6: */ colStep = int32(2) /* 4 pixels per block of 8 per line */ colNum = int32(1) /* Start at column 1 */ break /* Phase 7: */ /* 8 pixels per block of 8 per line */ /* Start at column 0 */ } } /* * Calculate offset into pixelPtr for the first pixel of the line. */ offset = (*TPNGImage)(unsafe.Pointer(pngPtr)).FcurrentLine * (*TPNGImage)(unsafe.Pointer(pngPtr)).Fblock.Fpitch /* * Adjust up for the starting pixel of the line. */ offset += colNum * (*TPNGImage)(unsafe.Pointer(pngPtr)).Fblock.FpixelSize /* * Calculate the extra number of bytes to skip between columns. */ pixStep = (colStep - int32(1)) * (*TPNGImage)(unsafe.Pointer(pngPtr)).Fblock.FpixelSize for { if !(colNum < (*TPNGImage)(unsafe.Pointer(pngPtr)).Fblock.Fwidth) { break } if haveBits < libc.Int32FromUint8((*TPNGImage)(unsafe.Pointer(pngPtr)).FbitDepth)*libc.Int32FromUint8((*TPNGImage)(unsafe.Pointer(pngPtr)).FnumChannels) { haveBits = 0 } chan1 = uint8(0) for { if !(libc.Int32FromUint8(chan1) < libc.Int32FromUint8((*TPNGImage)(unsafe.Pointer(pngPtr)).FnumChannels)) { break } if !(haveBits != 0) { shifts = 0 v3 = p p++ readByte = *(*uint8)(unsafe.Pointer(v3)) haveBits += int32(8) } if int32(16) == libc.Int32FromUint8((*TPNGImage)(unsafe.Pointer(pngPtr)).FbitDepth) { v4 = offset offset++ *(*uint8)(unsafe.Pointer((*TPNGImage)(unsafe.Pointer(pngPtr)).Fblock.FpixelPtr + uintptr(v4))) = readByte if (*TPNGImage)(unsafe.Pointer(pngPtr)).FuseTRNS != 0 { (*(*[6]uint8)(unsafe.Pointer(bp)))[libc.Int32FromUint8(chan1)*int32(2)] = readByte } v5 = p p++ readByte = *(*uint8)(unsafe.Pointer(v5)) if (*TPNGImage)(unsafe.Pointer(pngPtr)).FuseTRNS != 0 { (*(*[6]uint8)(unsafe.Pointer(bp)))[libc.Int32FromUint8(chan1)*int32(2)+int32(1)] = readByte } v6 = offset offset++ *(*uint8)(unsafe.Pointer((*TPNGImage)(unsafe.Pointer(pngPtr)).Fblock.FpixelPtr + uintptr(v6))) = readByte haveBits = 0 goto _2 } switch libc.Int32FromUint8((*TPNGImage)(unsafe.Pointer(pngPtr)).FbitDepth) { case int32(1): pixBits = libc.Uint8FromInt32(libc.Int32FromUint8(readByte) >> (libc.Int32FromInt32(7) - shifts) & libc.Int32FromInt32(0x01)) case int32(2): pixBits = libc.Uint8FromInt32(libc.Int32FromUint8(readByte) >> (libc.Int32FromInt32(6) - shifts*libc.Int32FromInt32(2)) & libc.Int32FromInt32(0x03)) case int32(4): pixBits = libc.Uint8FromInt32(libc.Int32FromUint8(readByte) >> (libc.Int32FromInt32(4) - shifts*libc.Int32FromInt32(4)) & libc.Int32FromInt32(0x0f)) case int32(8): pixBits = readByte break } if libc.Int32FromInt32(PNG_COLOR_USED)|libc.Int32FromInt32(PNG_COLOR_INDEXED) == libc.Int32FromUint8((*TPNGImage)(unsafe.Pointer(pngPtr)).FcolorType) { v7 = offset offset++ *(*uint8)(unsafe.Pointer(pixelPtr + uintptr(v7))) = (*(*struct { Fred uint8 Fgreen uint8 Fblue uint8 Falpha uint8 })(unsafe.Pointer(pngPtr + 132 + uintptr(pixBits)*4))).Fred v8 = offset offset++ *(*uint8)(unsafe.Pointer(pixelPtr + uintptr(v8))) = (*(*struct { Fred uint8 Fgreen uint8 Fblue uint8 Falpha uint8 })(unsafe.Pointer(pngPtr + 132 + uintptr(pixBits)*4))).Fgreen v9 = offset offset++ *(*uint8)(unsafe.Pointer(pixelPtr + uintptr(v9))) = (*(*struct { Fred uint8 Fgreen uint8 Fblue uint8 Falpha uint8 })(unsafe.Pointer(pngPtr + 132 + uintptr(pixBits)*4))).Fblue v10 = offset offset++ *(*uint8)(unsafe.Pointer(pixelPtr + uintptr(v10))) = (*(*struct { Fred uint8 Fgreen uint8 Fblue uint8 Falpha uint8 })(unsafe.Pointer(pngPtr + 132 + uintptr(pixBits)*4))).Falpha chan1 = uint8(int32(chan1) + libc.Int32FromInt32(2)) } else { v11 = offset offset++ *(*uint8)(unsafe.Pointer(pixelPtr + uintptr(v11))) = libc.Uint8FromInt32(libc.Int32FromUint8(pixBits) * (*TPNGImage)(unsafe.Pointer(pngPtr)).FbitScale) if (*TPNGImage)(unsafe.Pointer(pngPtr)).FuseTRNS != 0 { (*(*[6]uint8)(unsafe.Pointer(bp)))[chan1] = pixBits } } haveBits -= libc.Int32FromUint8((*TPNGImage)(unsafe.Pointer(pngPtr)).FbitDepth) shifts++ goto _2 _2: ; chan1++ } /* * Apply boolean transparency via tRNS data if necessary (where * necessary means a tRNS chunk was provided and we're not using an * alpha channel or indexed alpha). */ if libc.Int32FromInt32(PNG_COLOR_USED)|libc.Int32FromInt32(PNG_COLOR_INDEXED) != libc.Int32FromUint8((*TPNGImage)(unsafe.Pointer(pngPtr)).FcolorType) && !(libc.Int32FromUint8((*TPNGImage)(unsafe.Pointer(pngPtr)).FcolorType)&libc.Int32FromInt32(PNG_COLOR_ALPHA) != 0) { if (*TPNGImage)(unsafe.Pointer(pngPtr)).FuseTRNS != 0 { if libc.Xmemcmp(tls, bp, pngPtr+1156, uint64((*TPNGImage)(unsafe.Pointer(pngPtr)).FbytesPerPixel)) == 0 { alpha = uint8(0x00) } else { alpha = uint8(0xff) } } else { alpha = uint8(0xff) } v12 = offset offset++ *(*uint8)(unsafe.Pointer(pixelPtr + uintptr(v12))) = alpha if int32(16) == libc.Int32FromUint8((*TPNGImage)(unsafe.Pointer(pngPtr)).FbitDepth) { v13 = offset offset++ *(*uint8)(unsafe.Pointer(pixelPtr + uintptr(v13))) = alpha } } offset += pixStep goto _1 _1: ; colNum += colStep } if (*TPNGImage)(unsafe.Pointer(pngPtr)).Finterlace != 0 { /* Skip lines */ switch libc.Int32FromUint8((*TPNGImage)(unsafe.Pointer(pngPtr)).Fphase) { case int32(1): fallthrough case int32(2): fallthrough case int32(3): *(*int32)(unsafe.Pointer(pngPtr + 68)) += int32(8) case int32(4): fallthrough case int32(5): *(*int32)(unsafe.Pointer(pngPtr + 68)) += int32(4) case int32(6): fallthrough case int32(7): *(*int32)(unsafe.Pointer(pngPtr + 68)) += int32(2) break } /* * Start the next phase if there are no more lines to do. */ if (*TPNGImage)(unsafe.Pointer(pngPtr)).FcurrentLine >= (*TPNGImage)(unsafe.Pointer(pngPtr)).Fblock.Fheight { pixels = uint64(0) for (!(pixels != 0) || (*TPNGImage)(unsafe.Pointer(pngPtr)).FcurrentLine >= (*TPNGImage)(unsafe.Pointer(pngPtr)).Fblock.Fheight) && libc.Int32FromUint8((*TPNGImage)(unsafe.Pointer(pngPtr)).Fphase) < int32(7) { (*TPNGImage)(unsafe.Pointer(pngPtr)).Fphase++ switch libc.Int32FromUint8((*TPNGImage)(unsafe.Pointer(pngPtr)).Fphase) { case int32(2): pixels = libc.Uint64FromInt32(((*TPNGImage)(unsafe.Pointer(pngPtr)).Fblock.Fwidth + int32(3)) >> int32(3)) (*TPNGImage)(unsafe.Pointer(pngPtr)).FcurrentLine = 0 case int32(3): pixels = libc.Uint64FromInt32(((*TPNGImage)(unsafe.Pointer(pngPtr)).Fblock.Fwidth + int32(3)) >> int32(2)) (*TPNGImage)(unsafe.Pointer(pngPtr)).FcurrentLine = int32(4) case int32(4): pixels = libc.Uint64FromInt32(((*TPNGImage)(unsafe.Pointer(pngPtr)).Fblock.Fwidth + int32(1)) >> int32(2)) (*TPNGImage)(unsafe.Pointer(pngPtr)).FcurrentLine = 0 case int32(5): pixels = libc.Uint64FromInt32(((*TPNGImage)(unsafe.Pointer(pngPtr)).Fblock.Fwidth + int32(1)) >> int32(1)) (*TPNGImage)(unsafe.Pointer(pngPtr)).FcurrentLine = int32(2) case int32(6): pixels = libc.Uint64FromInt32((*TPNGImage)(unsafe.Pointer(pngPtr)).Fblock.Fwidth >> int32(1)) (*TPNGImage)(unsafe.Pointer(pngPtr)).FcurrentLine = 0 case int32(7): (*TPNGImage)(unsafe.Pointer(pngPtr)).FcurrentLine = int32(1) pixels = libc.Uint64FromInt32((*TPNGImage)(unsafe.Pointer(pngPtr)).Fblock.Fwidth) break } } if int32(16) == libc.Int32FromUint8((*TPNGImage)(unsafe.Pointer(pngPtr)).FbitDepth) { (*TPNGImage)(unsafe.Pointer(pngPtr)).FphaseSize = libc.Int32FromUint64(uint64(1) + uint64((*TPNGImage)(unsafe.Pointer(pngPtr)).FnumChannels)*pixels*uint64(2)) } else { (*TPNGImage)(unsafe.Pointer(pngPtr)).FphaseSize = libc.Int32FromUint64(uint64(1) + (uint64((*TPNGImage)(unsafe.Pointer(pngPtr)).FnumChannels)*pixels*uint64((*TPNGImage)(unsafe.Pointer(pngPtr)).FbitDepth)+uint64(7))>>int32(3)) } } } else { (*TPNGImage)(unsafe.Pointer(pngPtr)).FcurrentLine++ } return TCL_OK } /* *---------------------------------------------------------------------- * * ReadIDAT -- * * This function reads the IDAT (pixel data) chunk from the PNG file to * build the image. It will continue reading until all IDAT chunks have * been processed or an error occurs. * * Results: * TCL_OK, or TCL_ERROR if an I/O error occurs or an IDAT chunk is * invalid. * * Side effects: * The access position in f advances. Memory may be allocated by zlib * through PNGZAlloc. * *---------------------------------------------------------------------- */ func _ReadIDAT(tls *libc.TLS, interp uintptr, pngPtr uintptr, chunkSz int32, _crc uint64) (r int32) { bp := tls.Alloc(80) defer tls.Free(80) *(*uint64)(unsafe.Pointer(bp)) = _crc var _objPtr, _objPtr1, inputObj, inputPtr, temp, v3, v5 uintptr var blockSz, v1 int32 var v2, v4 TTcl_Size var _ /* len1 at bp+8 */ TTcl_Size var _ /* len2 at bp+16 */ TTcl_Size _, _, _, _, _, _, _, _, _, _, _ = _objPtr, _objPtr1, blockSz, inputObj, inputPtr, temp, v1, v2, v3, v4, v5 /* * Process IDAT contents until there is no more in this chunk. */ for chunkSz != 0 && !(libtcl9_0.XTcl_ZlibStreamEof(tls, (*TPNGImage)(unsafe.Pointer(pngPtr)).Fstream) != 0) { /* * Read another block of input into the zlib stream if data remains. */ if chunkSz != 0 { inputObj = libc.UintptrFromInt32(0) if chunkSz < int32(PNG_BLOCK_SZ) { v1 = chunkSz } else { v1 = int32(PNG_BLOCK_SZ) } blockSz = v1 inputPtr = libc.UintptrFromInt32(0) /* * Check for end of zlib stream. */ if libtcl9_0.XTcl_ZlibStreamEof(tls, (*TPNGImage)(unsafe.Pointer(pngPtr)).Fstream) != 0 { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+35967, int64(-libc.Int32FromInt32(1)))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+32, __ccgo_ts+179, __ccgo_ts+29667, __ccgo_ts+34591, __ccgo_ts+36003, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) } inputObj = libtcl9_0.XTcl_NewObj(tls) (*TTcl_Obj)(unsafe.Pointer(inputObj)).FrefCount++ inputPtr = libtcl9_0.XTcl_SetByteArrayLength(tls, inputObj, int64(blockSz)) /* * Read the next bit of IDAT chunk data, up to read buffer size. */ if _ReadData(tls, interp, pngPtr, inputPtr, int64(blockSz), bp) == int32(TCL_ERROR) { _objPtr = inputObj v3 = _objPtr v2 = *(*TTcl_Size)(unsafe.Pointer(v3)) *(*TTcl_Size)(unsafe.Pointer(v3))-- if v2 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr) } return int32(TCL_ERROR) } chunkSz -= blockSz libtcl9_0.XTcl_ZlibStreamPut(tls, (*TPNGImage)(unsafe.Pointer(pngPtr)).Fstream, inputObj, TCL_ZLIB_NO_FLUSH) _objPtr1 = inputObj v5 = _objPtr1 v4 = *(*TTcl_Size)(unsafe.Pointer(v5)) *(*TTcl_Size)(unsafe.Pointer(v5))-- if v4 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr1) } } /* * Inflate, processing each output buffer's worth as a line of pixels, * until we cannot fill the buffer any more. */ goto getNextLine getNextLine: ; libtcl9_0.XTcl_GetBytesFromObj(tls, libc.UintptrFromInt32(0), (*TPNGImage)(unsafe.Pointer(pngPtr)).FthisLineObj, bp+8) if libtcl9_0.XTcl_ZlibStreamGet(tls, (*TPNGImage)(unsafe.Pointer(pngPtr)).Fstream, (*TPNGImage)(unsafe.Pointer(pngPtr)).FthisLineObj, int64((*TPNGImage)(unsafe.Pointer(pngPtr)).FphaseSize)-*(*TTcl_Size)(unsafe.Pointer(bp + 8))) == int32(TCL_ERROR) { return int32(TCL_ERROR) } libtcl9_0.XTcl_GetBytesFromObj(tls, libc.UintptrFromInt32(0), (*TPNGImage)(unsafe.Pointer(pngPtr)).FthisLineObj, bp+16) if *(*TTcl_Size)(unsafe.Pointer(bp + 16)) == int64((*TPNGImage)(unsafe.Pointer(pngPtr)).FphaseSize) { if libc.Int32FromUint8((*TPNGImage)(unsafe.Pointer(pngPtr)).Fphase) > int32(7) { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+36014, int64(-int32(1)))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+32, __ccgo_ts+179, __ccgo_ts+29667, __ccgo_ts+34591, __ccgo_ts+36003, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) } if _DecodeLine(tls, interp, pngPtr) == int32(TCL_ERROR) { return int32(TCL_ERROR) } /* * Swap the current/last lines so that we always have the last * line processed available, which is necessary for filtering. */ temp = (*TPNGImage)(unsafe.Pointer(pngPtr)).FlastLineObj (*TPNGImage)(unsafe.Pointer(pngPtr)).FlastLineObj = (*TPNGImage)(unsafe.Pointer(pngPtr)).FthisLineObj (*TPNGImage)(unsafe.Pointer(pngPtr)).FthisLineObj = temp libtcl9_0.XTcl_SetByteArrayLength(tls, (*TPNGImage)(unsafe.Pointer(pngPtr)).FthisLineObj, 0) /* * Try to read another line of pixels out of the buffer * immediately, but don't allow write past end of block. */ if (*TPNGImage)(unsafe.Pointer(pngPtr)).FcurrentLine < (*TPNGImage)(unsafe.Pointer(pngPtr)).Fblock.Fheight { goto getNextLine } } /* * Got less than a whole buffer-load of pixels. Either we're going to * be getting more data from the next IDAT, or we've done what we can * here. */ } /* * Ensure that if we've got to the end of the compressed data, we've * also got to the end of the compressed stream. This sanity check is * enforced by most PNG readers. */ if chunkSz != 0 { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+36062, int64(-libc.Int32FromInt32(1)))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+32, __ccgo_ts+179, __ccgo_ts+29667, __ccgo_ts+34591, __ccgo_ts+36003, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) } return _CheckCRC(tls, interp, pngPtr, *(*uint64)(unsafe.Pointer(bp))) } /* *---------------------------------------------------------------------- * * ApplyAlpha -- * * Applies an overall alpha value to a complete image that has been read. * This alpha value is specified using the -format option to [image * create photo]. * * Results: * N/A * * Side effects: * The access position in f may change. * *---------------------------------------------------------------------- */ func _ApplyAlpha(tls *libc.TLS, pngPtr uintptr) { var channel uint32 var endPtr, p, v1, v2 uintptr var offset int32 _, _, _, _, _, _ = channel, endPtr, offset, p, v1, v2 if (*TPNGImage)(unsafe.Pointer(pngPtr)).Falpha != float64(1) { p = (*TPNGImage)(unsafe.Pointer(pngPtr)).Fblock.FpixelPtr endPtr = p + uintptr((*TPNGImage)(unsafe.Pointer(pngPtr)).FblockLen) offset = *(*int32)(unsafe.Pointer(pngPtr + 80 + 24 + 3*4)) p += uintptr(offset) if int32(16) == libc.Int32FromUint8((*TPNGImage)(unsafe.Pointer(pngPtr)).FbitDepth) { for p < endPtr { channel = uint32(float64(float64(libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(p)))<> libc.Int32FromInt32(8)) v2 = p p++ *(*uint8)(unsafe.Pointer(v2)) = uint8(channel & libc.Uint32FromInt32(0xff)) p += uintptr(offset) } } else { for p < endPtr { *(*uint8)(unsafe.Pointer(p)) = uint8(float64((*TPNGImage)(unsafe.Pointer(pngPtr)).Falpha * float64(*(*uint8)(unsafe.Pointer(p))))) p += uintptr(int32(1) + offset) } } } } /* *---------------------------------------------------------------------- * * ParseFormat -- * * This function parses the -format string that can be specified to the * [image create photo] command to extract options for postprocessing of * loaded images. Currently, this just allows specifying and applying an * overall alpha value to the loaded image (for example, to make it * entirely 50% as transparent as the actual image file). * * Results: * TCL_OK, or TCL_ERROR if the format specification is invalid. * * Side effects: * None * *---------------------------------------------------------------------- */ func _ParseFormat(tls *libc.TLS, interp uintptr, fmtObj uintptr, pngPtr uintptr) (r int32) { bp := tls.Alloc(80) defer tls.Free(80) var _ /* objc at bp+8 */ TTcl_Size var _ /* objv at bp+0 */ uintptr var _ /* optIndex at bp+16 */ int32 *(*uintptr)(unsafe.Pointer(bp)) = libc.UintptrFromInt32(0) *(*TTcl_Size)(unsafe.Pointer(bp + 8)) = 0 /* * Extract elements of format specification as a list. */ if fmtObj != 0 && libtcl9_0.XTcl_ListObjGetElements(tls, interp, fmtObj, bp+8, bp) != TCL_OK { return int32(TCL_ERROR) } for { if !(*(*TTcl_Size)(unsafe.Pointer(bp + 8)) > 0) { break } /* * Ignore the "png" part of the format specification. */ if !(libc.Xstrcasecmp(tls, libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp)))), libc.UintptrFromInt32(0)), __ccgo_ts+34560) != 0) { goto _1 } if libtcl9_0.XTcl_GetIndexFromObjStruct(tls, interp, *(*uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp)))), uintptr(unsafe.Pointer(&_fmtOptions)), libc.Int64FromUint64(libc.Uint64FromInt64(8)), __ccgo_ts+2689, libc.Int32FromInt32(0)|libc.Int32FromUint64(libc.Uint64FromInt64(4)< float64(1) { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+36119, int64(-libc.Int32FromInt32(1)))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+32, __ccgo_ts+179, __ccgo_ts+29667, __ccgo_ts+34591, __ccgo_ts+36160, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) } break } goto _1 _1: ; *(*TTcl_Size)(unsafe.Pointer(bp + 8))-- *(*uintptr)(unsafe.Pointer(bp)) += 8 } return TCL_OK } var _fmtOptions = [2]uintptr{ 0: __ccgo_ts + 36112, 1: libc.UintptrFromInt32(0), } /* *---------------------------------------------------------------------- * * DecodePNG -- * * This function handles the entirety of reading a PNG file (or data) * from the first byte to the last. * * Results: * TCL_OK, or TCL_ERROR if an I/O error occurs or any problems are * detected in the PNG file. * * Side effects: * The access position in f advances. Memory may be allocated and image * dimensions and contents may change. * *---------------------------------------------------------------------- */ func _DecodePNG(tls *libc.TLS, interp uintptr, pngPtr uintptr, fmtObj uintptr, imageHandle TTk_PhotoHandle, destX int32, destY int32, width int32, height int32, srcX int32, srcY int32) (r int32) { bp := tls.Alloc(80) defer tls.Free(80) /* Coordinates of top-left pixel to be used in * image being read. */ var pixels uint32 var result int32 var _ /* chunkSz at bp+8 */ TTcl_Size var _ /* chunkType at bp+0 */ uint64 var _ /* crc at bp+16 */ uint64 _, _ = pixels, result /* * Parse the PNG signature and IHDR (header) chunk. */ if _ReadIHDR(tls, interp, pngPtr) == int32(TCL_ERROR) { return int32(TCL_ERROR) } /* * Extract alpha value from -format object, if specified. */ if _ParseFormat(tls, interp, fmtObj, pngPtr) == int32(TCL_ERROR) { return int32(TCL_ERROR) } /* * The next chunk may either be a PLTE (Palette) chunk or the first of at * least one IDAT (data) chunks. It could also be one of a number of * ancillary chunks, but those are skipped for us by the switch in * ReadChunkHeader(). * * PLTE is mandatory for color type 3 and forbidden for 2 and 6 */ if _ReadChunkHeader(tls, interp, pngPtr, bp+8, bp, bp+16) == int32(TCL_ERROR) { return int32(TCL_ERROR) } /* * Physical header may be present here so try to parse it */ if libc.Uint64FromInt32(libc.Int32FromUint8('p'))< (libc.Int32FromInt32(INT_MAX)-libc.Int32FromInt32(1))/(libc.Int32FromUint8((*TPNGImage)(unsafe.Pointer(pngPtr)).FnumChannels)*int32(2)) { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+36264, int64(-int32(1)))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+32, __ccgo_ts+179, __ccgo_ts+29667, __ccgo_ts+34591, __ccgo_ts+36321, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) } if int32(16) == libc.Int32FromUint8((*TPNGImage)(unsafe.Pointer(pngPtr)).FbitDepth) { (*TPNGImage)(unsafe.Pointer(pngPtr)).FlineSize = int32(1) + libc.Int32FromUint8((*TPNGImage)(unsafe.Pointer(pngPtr)).FnumChannels)*(*TPNGImage)(unsafe.Pointer(pngPtr)).Fblock.Fwidth*int32(2) } else { (*TPNGImage)(unsafe.Pointer(pngPtr)).FlineSize = int32(1) + libc.Int32FromUint8((*TPNGImage)(unsafe.Pointer(pngPtr)).FnumChannels)*(*TPNGImage)(unsafe.Pointer(pngPtr)).Fblock.Fwidth/(int32(8)/libc.Int32FromUint8((*TPNGImage)(unsafe.Pointer(pngPtr)).FbitDepth)) if (*TPNGImage)(unsafe.Pointer(pngPtr)).Fblock.Fwidth%(int32(8)/libc.Int32FromUint8((*TPNGImage)(unsafe.Pointer(pngPtr)).FbitDepth)) != 0 { (*TPNGImage)(unsafe.Pointer(pngPtr)).FlineSize++ } } /* * Allocate space for decoding the scan lines. */ (*TPNGImage)(unsafe.Pointer(pngPtr)).FlastLineObj = libtcl9_0.XTcl_NewObj(tls) (*TTcl_Obj)(unsafe.Pointer((*TPNGImage)(unsafe.Pointer(pngPtr)).FlastLineObj)).FrefCount++ (*TPNGImage)(unsafe.Pointer(pngPtr)).FthisLineObj = libtcl9_0.XTcl_NewObj(tls) (*TTcl_Obj)(unsafe.Pointer((*TPNGImage)(unsafe.Pointer(pngPtr)).FthisLineObj)).FrefCount++ (*TPNGImage)(unsafe.Pointer(pngPtr)).Fblock.FpixelPtr = libtcl9_0.XTcl_AttemptAlloc(tls, libc.Uint64FromInt32((*TPNGImage)(unsafe.Pointer(pngPtr)).FblockLen)) if !((*TPNGImage)(unsafe.Pointer(pngPtr)).Fblock.FpixelPtr != 0) { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+36331, int64(-libc.Int32FromInt32(1)))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+32, __ccgo_ts+179, __ccgo_ts+36356, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) } /* * Determine size of the first phase if interlaced. Phase size should * always be <= line size, so probably not necessary to check for * arithmetic overflow here: should be covered by line size check. */ if (*TPNGImage)(unsafe.Pointer(pngPtr)).Finterlace != 0 { /* * Only one pixel per block of 8 per line in the first phase. */ pixels = libc.Uint32FromInt32(((*TPNGImage)(unsafe.Pointer(pngPtr)).Fblock.Fwidth + int32(7)) >> int32(3)) (*TPNGImage)(unsafe.Pointer(pngPtr)).Fphase = uint8(1) if int32(16) == libc.Int32FromUint8((*TPNGImage)(unsafe.Pointer(pngPtr)).FbitDepth) { (*TPNGImage)(unsafe.Pointer(pngPtr)).FphaseSize = libc.Int32FromUint32(uint32(1) + uint32((*TPNGImage)(unsafe.Pointer(pngPtr)).FnumChannels)*pixels*uint32(2)) } else { (*TPNGImage)(unsafe.Pointer(pngPtr)).FphaseSize = libc.Int32FromUint32(uint32(1) + (uint32((*TPNGImage)(unsafe.Pointer(pngPtr)).FnumChannels)*pixels*uint32((*TPNGImage)(unsafe.Pointer(pngPtr)).FbitDepth)+uint32(7))>>int32(3)) } } else { (*TPNGImage)(unsafe.Pointer(pngPtr)).FphaseSize = (*TPNGImage)(unsafe.Pointer(pngPtr)).FlineSize } /* * All of the IDAT (data) chunks must be consecutive. */ for libc.Uint64FromInt32(libc.Int32FromUint8('I'))< int64(INT_MAX) { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+36446, int64(-libc.Int32FromInt32(1)))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+16, __ccgo_ts+179, __ccgo_ts+29667, __ccgo_ts+34591, __ccgo_ts+36496, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) } destPtr = libtcl9_0.XTcl_SetByteArrayLength(tls, (*TPNGImage)(unsafe.Pointer(pngPtr)).FobjDataPtr, *(*TTcl_Size)(unsafe.Pointer(bp))+srcSz) if !(destPtr != 0) { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+36331, int64(-libc.Int32FromInt32(1)))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+16, __ccgo_ts+179, __ccgo_ts+36356, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) } libc.Xmemcpy(tls, destPtr+uintptr(*(*TTcl_Size)(unsafe.Pointer(bp))), srcPtr, libc.Uint64FromInt64(srcSz)) } else { if libtcl9_0.XTcl_Write(tls, (*TPNGImage)(unsafe.Pointer(pngPtr)).Fchannel, srcPtr, srcSz) == int64(-libc.Int32FromInt32(1)) { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+36506, libc.VaList(bp+16, libtcl9_0.XTcl_PosixError(tls, interp)))) return int32(TCL_ERROR) } } return TCL_OK } func _WriteByte(tls *libc.TLS, interp uintptr, pngPtr uintptr, _c uint8, crcPtr uintptr) (r int32) { bp := tls.Alloc(16) defer tls.Free(16) *(*uint8)(unsafe.Pointer(bp)) = _c return _WriteData(tls, interp, pngPtr, bp, int64(1), crcPtr) } /* *---------------------------------------------------------------------- * * LongToInt32 -- * * This function transforms to a 32-bit integer value as * four bytes in network byte order. * * Results: * None * * Side effects: * Buffer will be modified. * *---------------------------------------------------------------------- */ func _LongToInt32(tls *libc.TLS, l uint64, pc uintptr) { *(*uint8)(unsafe.Pointer(pc)) = uint8(l & libc.Uint64FromUint32(0xff000000) >> libc.Int32FromInt32(24)) *(*uint8)(unsafe.Pointer(pc + 1)) = uint8(l & libc.Uint64FromInt32(0x00ff0000) >> libc.Int32FromInt32(16)) *(*uint8)(unsafe.Pointer(pc + 2)) = uint8(l & libc.Uint64FromInt32(0x0000ff00) >> libc.Int32FromInt32(8)) *(*uint8)(unsafe.Pointer(pc + 3)) = uint8(l & libc.Uint64FromInt32(0x000000ff) >> libc.Int32FromInt32(0)) } /* *---------------------------------------------------------------------- * * WriteInt32 -- * * This function writes a 32-bit integer value out to the PNG image as * four bytes in network byte order. * * Results: * TCL_OK, or TCL_ERROR if the write fails. * * Side effects: * File or buffer will be modified. * *---------------------------------------------------------------------- */ func _WriteInt32(tls *libc.TLS, interp uintptr, pngPtr uintptr, l uint64, crcPtr uintptr) (r int32) { bp := tls.Alloc(16) defer tls.Free(16) var _ /* pc at bp+0 */ [4]uint8 _LongToInt32(tls, l, bp) return _WriteData(tls, interp, pngPtr, bp, int64(4), crcPtr) } /* *---------------------------------------------------------------------- * * WriteChunk -- * * Writes a complete chunk to the PNG image, including chunk type, * length, contents, and CRC. * * Results: * TCL_OK, or TCL_ERROR if the write fails. * * Side effects: * None * *---------------------------------------------------------------------- */ func _WriteChunk(tls *libc.TLS, interp uintptr, pngPtr uintptr, chunkType uint64, dataPtr uintptr, dataSize TTcl_Size) (r int32) { bp := tls.Alloc(16) defer tls.Free(16) var result int32 var _ /* crc at bp+0 */ uint64 _ = result *(*uint64)(unsafe.Pointer(bp)) = uint64(libtcl9_0.XTcl_ZlibCRC32(tls, uint32(0), libc.UintptrFromInt32(0), 0)) result = TCL_OK /* * Write the length field for the chunk. */ result = _WriteInt32(tls, interp, pngPtr, libc.Uint64FromInt64(dataSize), libc.UintptrFromInt32(0)) /* * Write the Chunk Type. */ if TCL_OK == result { result = _WriteInt32(tls, interp, pngPtr, chunkType, bp) } /* * Write the contents (if any). */ if TCL_OK == result { result = _WriteData(tls, interp, pngPtr, dataPtr, dataSize, bp) } /* * Write out the CRC at the end of the chunk. */ if TCL_OK == result { result = _WriteInt32(tls, interp, pngPtr, *(*uint64)(unsafe.Pointer(bp)), libc.UintptrFromInt32(0)) } return result } /* *---------------------------------------------------------------------- * * WriteIHDR -- * * This function writes the PNG header at the beginning of a PNG file, * which includes information such as dimensions and color type. * * Results: * TCL_OK, or TCL_ERROR if the write fails. * * Side effects: * File or buffer will be modified. * *---------------------------------------------------------------------- */ func _WriteIHDR(tls *libc.TLS, interp uintptr, pngPtr uintptr, blockPtr uintptr) (r int32) { bp := tls.Alloc(16) defer tls.Free(16) var result int32 var _ /* crc at bp+0 */ uint64 _ = result *(*uint64)(unsafe.Pointer(bp)) = uint64(libtcl9_0.XTcl_ZlibCRC32(tls, uint32(0), libc.UintptrFromInt32(0), 0)) result = TCL_OK /* * The IHDR (header) chunk has a fixed size of 13 bytes. */ result = _WriteInt32(tls, interp, pngPtr, uint64(13), libc.UintptrFromInt32(0)) /* * Write the IHDR Chunk Type. */ if TCL_OK == result { result = _WriteInt32(tls, interp, pngPtr, libc.Uint64FromInt32(libc.Int32FromUint8('I'))< uint64(2147483647) || PPUy > uint64(2147483647) { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+36589, int64(-libc.Int32FromInt32(1)))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+280, __ccgo_ts+179, __ccgo_ts+29667, __ccgo_ts+34591, __ccgo_ts+36616, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) } _LongToInt32(tls, PPUx, bp+256) _LongToInt32(tls, PPUy, bp+256+uintptr(4)) (*(*[9]uint8)(unsafe.Pointer(bp + 256)))[int32(8)] = unitSpecifier if _WriteChunk(tls, interp, pngPtr, libc.Uint64FromInt32(libc.Int32FromUint8('p'))<= (*TTk_PhotoImageBlock)(unsafe.Pointer(blockPtr)).FpixelSize || alphaOffset < 0 { alphaOffset = 0 } else { alphaOffset -= *(*int32)(unsafe.Pointer(blockPtr + 24)) } if greenOffset != 0 || blueOffset != 0 { if alphaOffset != 0 { (*TPNGImage)(unsafe.Pointer(pngPtr)).FcolorType = libc.Uint8FromInt32(libc.Int32FromInt32(PNG_COLOR_USED) | libc.Int32FromInt32(PNG_COLOR_ALPHA)) (*TPNGImage)(unsafe.Pointer(pngPtr)).FbytesPerPixel = uint8(4) } else { (*TPNGImage)(unsafe.Pointer(pngPtr)).FcolorType = libc.Uint8FromInt32(libc.Int32FromInt32(PNG_COLOR_USED)) (*TPNGImage)(unsafe.Pointer(pngPtr)).FbytesPerPixel = uint8(3) } } else { if alphaOffset != 0 { (*TPNGImage)(unsafe.Pointer(pngPtr)).FcolorType = libc.Uint8FromInt32(libc.Int32FromInt32(PNG_COLOR_GRAY) | libc.Int32FromInt32(PNG_COLOR_ALPHA)) (*TPNGImage)(unsafe.Pointer(pngPtr)).FbytesPerPixel = uint8(2) } else { (*TPNGImage)(unsafe.Pointer(pngPtr)).FcolorType = uint8(PNG_COLOR_GRAY) (*TPNGImage)(unsafe.Pointer(pngPtr)).FbytesPerPixel = uint8(1) } } /* * Allocate buffers for lines for filtering and compressed data. */ (*TPNGImage)(unsafe.Pointer(pngPtr)).FlineSize = int32(1) + libc.Int32FromUint8((*TPNGImage)(unsafe.Pointer(pngPtr)).FbytesPerPixel)*(*TTk_PhotoImageBlock)(unsafe.Pointer(blockPtr)).Fwidth (*TPNGImage)(unsafe.Pointer(pngPtr)).FblockLen = (*TPNGImage)(unsafe.Pointer(pngPtr)).FlineSize * (*TTk_PhotoImageBlock)(unsafe.Pointer(blockPtr)).Fheight if (*TTk_PhotoImageBlock)(unsafe.Pointer(blockPtr)).Fwidth > (libc.Int32FromInt32(INT_MAX)-libc.Int32FromInt32(1))/libc.Int32FromUint8((*TPNGImage)(unsafe.Pointer(pngPtr)).FbytesPerPixel) || (*TTk_PhotoImageBlock)(unsafe.Pointer(blockPtr)).Fheight > int32(INT_MAX)/(*TPNGImage)(unsafe.Pointer(pngPtr)).FlineSize { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+36621, int64(-libc.Int32FromInt32(1)))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+8, __ccgo_ts+179, __ccgo_ts+29667, __ccgo_ts+34591, __ccgo_ts+36496, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) } (*TPNGImage)(unsafe.Pointer(pngPtr)).FlastLineObj = libtcl9_0.XTcl_NewObj(tls) (*TTcl_Obj)(unsafe.Pointer((*TPNGImage)(unsafe.Pointer(pngPtr)).FlastLineObj)).FrefCount++ (*TPNGImage)(unsafe.Pointer(pngPtr)).FthisLineObj = libtcl9_0.XTcl_NewObj(tls) (*TTcl_Obj)(unsafe.Pointer((*TPNGImage)(unsafe.Pointer(pngPtr)).FthisLineObj)).FrefCount++ /* * Write out the PNG Signature that all PNGs begin with. */ if _WriteData(tls, interp, pngPtr, uintptr(unsafe.Pointer(&_pngSignature)), int64(PNG_SIG_SZ), libc.UintptrFromInt32(0)) == int32(TCL_ERROR) { return int32(TCL_ERROR) } /* * Write out the IHDR (header) chunk containing image dimensions, color * type, etc. */ if _WriteIHDR(tls, interp, pngPtr, blockPtr) == int32(TCL_ERROR) { return int32(TCL_ERROR) } /* * Write out the extra chunks containing metadata that is of interest to * other programs more than us. */ if _WriteExtraChunks(tls, interp, pngPtr, metadataInObj) == int32(TCL_ERROR) { return int32(TCL_ERROR) } /* * Write out the image pixels in the IDAT (data) chunk. */ if _WriteIDAT(tls, interp, pngPtr, blockPtr) == int32(TCL_ERROR) { return int32(TCL_ERROR) } /* * Write out the IEND chunk that all PNGs end with. */ return _WriteChunk(tls, interp, pngPtr, libc.Uint64FromInt32(libc.Int32FromUint8('I'))<0 if the first characters in file "f" look like * PPM data, and 0 otherwise. * * Side effects: * The access position in f may change. * *---------------------------------------------------------------------- */ func _FileMatchPPM(tls *libc.TLS, chan1 TTcl_Channel, dummy101 uintptr, dummy102 uintptr, widthPtr uintptr, heightPtr uintptr, dummy107 uintptr) (r int32) { bp := tls.Alloc(16) defer tls.Free(16) /* unused */ var _ /* dummy at bp+0 */ int32 return _ReadPPMFileHeader(tls, chan1, widthPtr, heightPtr, bp) } /* *---------------------------------------------------------------------- * * FileReadPPM -- * * This function is called by the photo image type to read PPM format * data from a file and write it into a given photo image. * * Results: * A standard TCL completion code. If TCL_ERROR is returned then an error * message is left in the interp's result. * * Side effects: * The access position in file f is changed, and new data is added to the * image given by imageHandle. * *---------------------------------------------------------------------- */ func _FileReadPPM(tls *libc.TLS, interp uintptr, chan1 TTcl_Channel, fileName uintptr, dummy138 uintptr, imageHandle TTk_PhotoHandle, destX int32, destY int32, width int32, height int32, srcX int32, srcY int32) (r int32) { bp := tls.Alloc(112) defer tls.Free(112) /* Coordinates of top-left pixel to be used in * image being read. */ var bytesPerChannel, h, nLines, type1 int32 var count, nBytes Tsize_t var p, p1, pixelPtr, v2 uintptr var value uint32 var v5 uint8 var _ /* block at bp+16 */ TTk_PhotoImageBlock var _ /* fileHeight at bp+4 */ int32 var _ /* fileWidth at bp+0 */ int32 var _ /* maxIntensity at bp+8 */ int32 _, _, _, _, _, _, _, _, _, _, _, _ = bytesPerChannel, count, h, nBytes, nLines, p, p1, pixelPtr, type1, value, v2, v5 bytesPerChannel = int32(1) type1 = _ReadPPMFileHeader(tls, chan1, bp, bp+4, bp+8) if type1 == 0 { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+36665, libc.VaList(bp+64, fileName))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+64, __ccgo_ts+179, __ccgo_ts+29667, __ccgo_ts+36709, __ccgo_ts+36713, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) } if *(*int32)(unsafe.Pointer(bp)) <= 0 || *(*int32)(unsafe.Pointer(bp + 4)) <= 0 { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+36723, libc.VaList(bp+64, fileName))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+64, __ccgo_ts+179, __ccgo_ts+29667, __ccgo_ts+36709, __ccgo_ts+34299, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) } if *(*int32)(unsafe.Pointer(bp + 8)) <= 0 || *(*int32)(unsafe.Pointer(bp + 8)) > int32(0xffff) { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+36765, libc.VaList(bp+64, fileName, *(*int32)(unsafe.Pointer(bp + 8))))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+64, __ccgo_ts+179, __ccgo_ts+29667, __ccgo_ts+36709, __ccgo_ts+36820, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) } else { if *(*int32)(unsafe.Pointer(bp + 8)) > int32(0x00ff) { bytesPerChannel = int32(2) } } if srcX+width > *(*int32)(unsafe.Pointer(bp)) { width = *(*int32)(unsafe.Pointer(bp)) - srcX } if srcY+height > *(*int32)(unsafe.Pointer(bp + 4)) { height = *(*int32)(unsafe.Pointer(bp + 4)) - srcY } if width <= 0 || height <= 0 || srcX >= *(*int32)(unsafe.Pointer(bp)) || srcY >= *(*int32)(unsafe.Pointer(bp + 4)) { return TCL_OK } if type1 == int32(PGM) { (*(*TTk_PhotoImageBlock)(unsafe.Pointer(bp + 16))).FpixelSize = int32(1) * bytesPerChannel *(*int32)(unsafe.Pointer(bp + 16 + 24)) = 0 *(*int32)(unsafe.Pointer(bp + 16 + 24 + 1*4)) = 0 *(*int32)(unsafe.Pointer(bp + 16 + 24 + 2*4)) = 0 } else { (*(*TTk_PhotoImageBlock)(unsafe.Pointer(bp + 16))).FpixelSize = int32(3) * bytesPerChannel *(*int32)(unsafe.Pointer(bp + 16 + 24)) = 0 *(*int32)(unsafe.Pointer(bp + 16 + 24 + 1*4)) = int32(1) * bytesPerChannel *(*int32)(unsafe.Pointer(bp + 16 + 24 + 2*4)) = int32(2) * bytesPerChannel } *(*int32)(unsafe.Pointer(bp + 16 + 24 + 3*4)) = 0 (*(*TTk_PhotoImageBlock)(unsafe.Pointer(bp + 16))).Fwidth = width (*(*TTk_PhotoImageBlock)(unsafe.Pointer(bp + 16))).Fpitch = (*(*TTk_PhotoImageBlock)(unsafe.Pointer(bp + 16))).FpixelSize * *(*int32)(unsafe.Pointer(bp)) if XTk_PhotoExpand(tls, interp, imageHandle, destX+width, destY+height) != TCL_OK { return int32(TCL_ERROR) } if srcY > 0 { libtcl9_0.XTcl_Seek(tls, chan1, int64(srcY)*int64((*(*TTk_PhotoImageBlock)(unsafe.Pointer(bp + 16))).Fpitch), int32(1)) } nLines = (int32(MAX_MEMORY) + (*(*TTk_PhotoImageBlock)(unsafe.Pointer(bp + 16))).Fpitch - int32(1)) / (*(*TTk_PhotoImageBlock)(unsafe.Pointer(bp + 16))).Fpitch if nLines > height { nLines = height } if nLines <= 0 { nLines = int32(1) } nBytes = libc.Uint64FromInt32(nLines * (*(*TTk_PhotoImageBlock)(unsafe.Pointer(bp + 16))).Fpitch) pixelPtr = libtcl9_0.XTcl_Alloc(tls, nBytes) (*(*TTk_PhotoImageBlock)(unsafe.Pointer(bp + 16))).FpixelPtr = pixelPtr + uintptr(srcX*(*(*TTk_PhotoImageBlock)(unsafe.Pointer(bp + 16))).FpixelSize) h = height for { if !(h > 0) { break } if nLines > h { nLines = h nBytes = libc.Uint64FromInt32(nLines * (*(*TTk_PhotoImageBlock)(unsafe.Pointer(bp + 16))).Fpitch) } count = libc.Uint64FromInt64(libtcl9_0.XTcl_Read(tls, chan1, pixelPtr, libc.Int64FromUint64(nBytes))) if count != nBytes { if libtcl9_0.XTcl_Eof(tls, chan1) != 0 { v2 = __ccgo_ts + 36830 } else { v2 = libtcl9_0.XTcl_PosixError(tls, interp) } libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+36846, libc.VaList(bp+64, fileName, v2))) if libtcl9_0.XTcl_Eof(tls, chan1) != 0 { libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+64, __ccgo_ts+179, __ccgo_ts+29667, __ccgo_ts+36709, __ccgo_ts+34691, libc.UintptrFromInt32(0))) } libtcl9_0.XTcl_Free(tls, pixelPtr) return int32(TCL_ERROR) } if *(*int32)(unsafe.Pointer(bp + 8)) < int32(0x00ff) { p = pixelPtr for { if !(count > uint64(0)) { break } *(*uint8)(unsafe.Pointer(p)) = libc.Uint8FromInt32(libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(p))) * int32(255) / *(*int32)(unsafe.Pointer(bp + 8))) goto _3 _3: ; count-- p++ } } else { if *(*int32)(unsafe.Pointer(bp + 8)) > int32(0x00ff) { p1 = pixelPtr for { if !(count > uint64(0)) { break } value = uint32(*(*uint8)(unsafe.Pointer(p1)))*uint32(256) + uint32(*(*uint8)(unsafe.Pointer(p1 + 1))) value = value * uint32(255) / libc.Uint32FromInt32(*(*int32)(unsafe.Pointer(bp + 8))) v5 = uint8(value) *(*uint8)(unsafe.Pointer(p1 + 1)) = v5 *(*uint8)(unsafe.Pointer(p1)) = v5 goto _4 _4: ; count -= uint64(2) p1 += uintptr(2) } } } (*(*TTk_PhotoImageBlock)(unsafe.Pointer(bp + 16))).Fheight = nLines if XTk_PhotoPutBlock(tls, interp, imageHandle, bp+16, destX, destY, width, nLines, int32(TK_PHOTO_COMPOSITE_SET)) != TCL_OK { libtcl9_0.XTcl_Free(tls, pixelPtr) return int32(TCL_ERROR) } destY += nLines goto _1 _1: ; h -= nLines } libtcl9_0.XTcl_Free(tls, pixelPtr) return TCL_OK } /* *---------------------------------------------------------------------- * * FileWritePPM -- * * This function is invoked to write image data to a file in PPM format * (although we can read PGM files, we never write them). * * Results: * A standard TCL completion code. If TCL_ERROR is returned then an error * message is left in the interp's result. * * Side effects: * Data is written to the file given by "fileName". * *---------------------------------------------------------------------- */ func _FileWritePPM(tls *libc.TLS, interp uintptr, fileName uintptr, dummy289 uintptr, blockPtr uintptr) (r int32) { bp := tls.Alloc(96) defer tls.Free(96) var blueOffset, greenOffset, h, w int32 var chan1 TTcl_Channel var nBytes Tsize_t var pixLinePtr, pixelPtr uintptr var _ /* header at bp+0 */ [64]uint8 _, _, _, _, _, _, _, _ = blueOffset, chan1, greenOffset, h, nBytes, pixLinePtr, pixelPtr, w chan1 = libtcl9_0.XTcl_OpenFileChannel(tls, interp, fileName, __ccgo_ts+10954, int32(0666)) if chan1 == libc.UintptrFromInt32(0) { return int32(TCL_ERROR) } if libtcl9_0.XTcl_SetChannelOption(tls, interp, chan1, __ccgo_ts+8196, __ccgo_ts+33442) != TCL_OK { libtcl9_0.XTcl_CloseEx(tls, libc.UintptrFromInt32(0), chan1, 0) return int32(TCL_ERROR) } libc.X__builtin_snprintf(tls, bp, uint64(64), __ccgo_ts+36884, libc.VaList(bp+72, (*TTk_PhotoImageBlock)(unsafe.Pointer(blockPtr)).Fwidth, (*TTk_PhotoImageBlock)(unsafe.Pointer(blockPtr)).Fheight)) libtcl9_0.XTcl_Write(tls, chan1, bp, int64(-libc.Int32FromInt32(1))) pixLinePtr = (*TTk_PhotoImageBlock)(unsafe.Pointer(blockPtr)).FpixelPtr + uintptr(*(*int32)(unsafe.Pointer(blockPtr + 24))) greenOffset = *(*int32)(unsafe.Pointer(blockPtr + 24 + 1*4)) - *(*int32)(unsafe.Pointer(blockPtr + 24)) blueOffset = *(*int32)(unsafe.Pointer(blockPtr + 24 + 2*4)) - *(*int32)(unsafe.Pointer(blockPtr + 24)) if greenOffset == int32(1) && blueOffset == int32(2) && (*TTk_PhotoImageBlock)(unsafe.Pointer(blockPtr)).FpixelSize == int32(3) && (*TTk_PhotoImageBlock)(unsafe.Pointer(blockPtr)).Fpitch == (*TTk_PhotoImageBlock)(unsafe.Pointer(blockPtr)).Fwidth*int32(3) { nBytes = libc.Uint64FromInt32((*TTk_PhotoImageBlock)(unsafe.Pointer(blockPtr)).Fheight * (*TTk_PhotoImageBlock)(unsafe.Pointer(blockPtr)).Fpitch) if libc.Uint64FromInt64(libtcl9_0.XTcl_Write(tls, chan1, pixLinePtr, libc.Int64FromUint64(nBytes))) != nBytes { goto writeerror } } else { h = (*TTk_PhotoImageBlock)(unsafe.Pointer(blockPtr)).Fheight for { if !(h > 0) { break } pixelPtr = pixLinePtr w = (*TTk_PhotoImageBlock)(unsafe.Pointer(blockPtr)).Fwidth for { if !(w > 0) { break } if libtcl9_0.XTcl_Write(tls, chan1, pixelPtr, int64(1)) == int64(-libc.Int32FromInt32(1)) || libtcl9_0.XTcl_Write(tls, chan1, pixelPtr+uintptr(greenOffset), int64(1)) == int64(-libc.Int32FromInt32(1)) || libtcl9_0.XTcl_Write(tls, chan1, pixelPtr+uintptr(blueOffset), int64(1)) == int64(-libc.Int32FromInt32(1)) { goto writeerror } pixelPtr += uintptr((*TTk_PhotoImageBlock)(unsafe.Pointer(blockPtr)).FpixelSize) goto _2 _2: ; w-- } pixLinePtr += uintptr((*TTk_PhotoImageBlock)(unsafe.Pointer(blockPtr)).Fpitch) goto _1 _1: ; h-- } } if libtcl9_0.XTcl_CloseEx(tls, libc.UintptrFromInt32(0), chan1, 0) == 0 { return TCL_OK } chan1 = libc.UintptrFromInt32(0) goto writeerror writeerror: ; libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+36898, libc.VaList(bp+72, fileName, libtcl9_0.XTcl_PosixError(tls, interp)))) if chan1 != libc.UintptrFromInt32(0) { libtcl9_0.XTcl_CloseEx(tls, libc.UintptrFromInt32(0), chan1, 0) } return int32(TCL_ERROR) } /* *---------------------------------------------------------------------- * * StringWritePPM -- * * This function is invoked to write image data to a string in PPM * format. * * Results: * A standard TCL completion code. If TCL_ERROR is returned then an error * message is left in the interp's result. * * Side effects: * None. * *---------------------------------------------------------------------- */ func _StringWritePPM(tls *libc.TLS, interp uintptr, dummy372 uintptr, blockPtr uintptr) (r int32) { bp := tls.Alloc(96) defer tls.Free(96) var blueOffset, greenOffset, h, size, w int32 var byteArray, byteArrayObj, pixLinePtr, pixelPtr, v3, v4, v5 uintptr var _ /* header at bp+0 */ [64]uint8 _, _, _, _, _, _, _, _, _, _, _, _ = blueOffset, byteArray, byteArrayObj, greenOffset, h, pixLinePtr, pixelPtr, size, w, v3, v4, v5 libc.X__builtin_snprintf(tls, bp, uint64(64), __ccgo_ts+36884, libc.VaList(bp+72, (*TTk_PhotoImageBlock)(unsafe.Pointer(blockPtr)).Fwidth, (*TTk_PhotoImageBlock)(unsafe.Pointer(blockPtr)).Fheight)) /* * Construct a byte array of the right size with the header and * get a pointer to the data part of it. */ size = libc.Int32FromUint64(libc.Xstrlen(tls, bp)) byteArrayObj = libtcl9_0.XTcl_NewByteArrayObj(tls, bp, int64(size)) byteArray = libtcl9_0.XTcl_SetByteArrayLength(tls, byteArrayObj, int64(size+int32(3)*(*TTk_PhotoImageBlock)(unsafe.Pointer(blockPtr)).Fwidth*(*TTk_PhotoImageBlock)(unsafe.Pointer(blockPtr)).Fheight)) byteArray += uintptr(size) pixLinePtr = (*TTk_PhotoImageBlock)(unsafe.Pointer(blockPtr)).FpixelPtr + uintptr(*(*int32)(unsafe.Pointer(blockPtr + 24))) greenOffset = *(*int32)(unsafe.Pointer(blockPtr + 24 + 1*4)) - *(*int32)(unsafe.Pointer(blockPtr + 24)) blueOffset = *(*int32)(unsafe.Pointer(blockPtr + 24 + 2*4)) - *(*int32)(unsafe.Pointer(blockPtr + 24)) /* * Check if we can do the data move in single action. */ if greenOffset == int32(1) && blueOffset == int32(2) && (*TTk_PhotoImageBlock)(unsafe.Pointer(blockPtr)).FpixelSize == int32(3) && (*TTk_PhotoImageBlock)(unsafe.Pointer(blockPtr)).Fpitch == (*TTk_PhotoImageBlock)(unsafe.Pointer(blockPtr)).Fwidth*int32(3) { libc.Xmemcpy(tls, byteArray, pixLinePtr, uint64(libc.Uint32FromInt32((*TTk_PhotoImageBlock)(unsafe.Pointer(blockPtr)).Fheight)*libc.Uint32FromInt32((*TTk_PhotoImageBlock)(unsafe.Pointer(blockPtr)).Fpitch))) } else { h = (*TTk_PhotoImageBlock)(unsafe.Pointer(blockPtr)).Fheight for { if !(h > 0) { break } pixelPtr = pixLinePtr w = (*TTk_PhotoImageBlock)(unsafe.Pointer(blockPtr)).Fwidth for { if !(w > 0) { break } v3 = byteArray byteArray++ *(*uint8)(unsafe.Pointer(v3)) = *(*uint8)(unsafe.Pointer(pixelPtr)) v4 = byteArray byteArray++ *(*uint8)(unsafe.Pointer(v4)) = *(*uint8)(unsafe.Pointer(pixelPtr + uintptr(greenOffset))) v5 = byteArray byteArray++ *(*uint8)(unsafe.Pointer(v5)) = *(*uint8)(unsafe.Pointer(pixelPtr + uintptr(blueOffset))) pixelPtr += uintptr((*TTk_PhotoImageBlock)(unsafe.Pointer(blockPtr)).FpixelSize) goto _2 _2: ; w-- } pixLinePtr += uintptr((*TTk_PhotoImageBlock)(unsafe.Pointer(blockPtr)).Fpitch) goto _1 _1: ; h-- } } /* * Return the object in the interpreter result. */ libtcl9_0.XTcl_SetObjResult(tls, interp, byteArrayObj) return TCL_OK } /* *---------------------------------------------------------------------- * * StringMatchPPM -- * * This function is invoked by the photo image type to see if a string * contains image data in PPM format. * * Results: * The return value is >0 if the first characters in file "f" look like * PPM data, and 0 otherwise. * * Side effects: * The access position in f may change. * *---------------------------------------------------------------------- */ func _StringMatchPPM(tls *libc.TLS, dataObj uintptr, dummy448 uintptr, widthPtr uintptr, heightPtr uintptr, dummy453 uintptr) (r int32) { bp := tls.Alloc(16) defer tls.Free(16) /* unused */ var _ /* dummy at bp+0 */ int32 return _ReadPPMStringHeader(tls, dataObj, widthPtr, heightPtr, bp, libc.UintptrFromInt32(0), libc.UintptrFromInt32(0)) } /* *---------------------------------------------------------------------- * * StringReadPPM -- * * This function is called by the photo image type to read PPM format * data from a string and write it into a given photo image. * * Results: * A standard TCL completion code. If TCL_ERROR is returned then an error * message is left in the interp's result. * * Side effects: * New data is added to the image given by imageHandle. * *---------------------------------------------------------------------- */ func _StringReadPPM(tls *libc.TLS, interp uintptr, dataObj uintptr, dummy483 uintptr, imageHandle TTk_PhotoHandle, destX int32, destY int32, width int32, height int32, srcX int32, srcY int32) (r int32) { bp := tls.Alloc(112) defer tls.Free(112) /* Coordinates of top-left pixel to be used in * image being read. */ var bytesPerChannel, count, h, nBytes, nLines, type1 int32 var p, pixelPtr uintptr var value uint32 var v4 uint8 var _ /* block at bp+24 */ TTk_PhotoImageBlock var _ /* dataBuffer at bp+16 */ uintptr var _ /* dataSize at bp+12 */ int32 var _ /* fileHeight at bp+4 */ int32 var _ /* fileWidth at bp+0 */ int32 var _ /* maxIntensity at bp+8 */ int32 _, _, _, _, _, _, _, _, _, _ = bytesPerChannel, count, h, nBytes, nLines, p, pixelPtr, type1, value, v4 bytesPerChannel = int32(1) type1 = _ReadPPMStringHeader(tls, dataObj, bp, bp+4, bp+8, bp+16, bp+12) if type1 == 0 { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+36921, int64(-libc.Int32FromInt32(1)))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+72, __ccgo_ts+179, __ccgo_ts+29667, __ccgo_ts+36709, __ccgo_ts+36713, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) } if *(*int32)(unsafe.Pointer(bp)) <= 0 || *(*int32)(unsafe.Pointer(bp + 4)) <= 0 { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+36962, int64(-libc.Int32FromInt32(1)))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+72, __ccgo_ts+179, __ccgo_ts+29667, __ccgo_ts+36709, __ccgo_ts+34299, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) } if *(*int32)(unsafe.Pointer(bp + 8)) <= 0 || *(*int32)(unsafe.Pointer(bp + 8)) > int32(0xffff) { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+36999, libc.VaList(bp+72, *(*int32)(unsafe.Pointer(bp + 8))))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+72, __ccgo_ts+179, __ccgo_ts+29667, __ccgo_ts+36709, __ccgo_ts+36820, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) } else { if *(*int32)(unsafe.Pointer(bp + 8)) > int32(0x00ff) { bytesPerChannel = int32(2) } } if srcX+width > *(*int32)(unsafe.Pointer(bp)) { width = *(*int32)(unsafe.Pointer(bp)) - srcX } if srcY+height > *(*int32)(unsafe.Pointer(bp + 4)) { height = *(*int32)(unsafe.Pointer(bp + 4)) - srcY } if width <= 0 || height <= 0 || srcX >= *(*int32)(unsafe.Pointer(bp)) || srcY >= *(*int32)(unsafe.Pointer(bp + 4)) { return TCL_OK } if type1 == int32(PGM) { (*(*TTk_PhotoImageBlock)(unsafe.Pointer(bp + 24))).FpixelSize = int32(1) * bytesPerChannel *(*int32)(unsafe.Pointer(bp + 24 + 24)) = 0 *(*int32)(unsafe.Pointer(bp + 24 + 24 + 1*4)) = 0 *(*int32)(unsafe.Pointer(bp + 24 + 24 + 2*4)) = 0 } else { (*(*TTk_PhotoImageBlock)(unsafe.Pointer(bp + 24))).FpixelSize = int32(3) * bytesPerChannel *(*int32)(unsafe.Pointer(bp + 24 + 24)) = 0 *(*int32)(unsafe.Pointer(bp + 24 + 24 + 1*4)) = int32(1) * bytesPerChannel *(*int32)(unsafe.Pointer(bp + 24 + 24 + 2*4)) = int32(2) * bytesPerChannel } *(*int32)(unsafe.Pointer(bp + 24 + 24 + 3*4)) = 0 (*(*TTk_PhotoImageBlock)(unsafe.Pointer(bp + 24))).Fwidth = width (*(*TTk_PhotoImageBlock)(unsafe.Pointer(bp + 24))).Fpitch = (*(*TTk_PhotoImageBlock)(unsafe.Pointer(bp + 24))).FpixelSize * *(*int32)(unsafe.Pointer(bp)) if srcY > 0 { *(*uintptr)(unsafe.Pointer(bp + 16)) += uintptr(srcY * (*(*TTk_PhotoImageBlock)(unsafe.Pointer(bp + 24))).Fpitch) *(*int32)(unsafe.Pointer(bp + 12)) -= srcY * (*(*TTk_PhotoImageBlock)(unsafe.Pointer(bp + 24))).Fpitch } if *(*int32)(unsafe.Pointer(bp + 8)) == int32(0x00ff) { /* * We have all the data in memory, so write everything in one go. */ if (*(*TTk_PhotoImageBlock)(unsafe.Pointer(bp + 24))).Fpitch*height > *(*int32)(unsafe.Pointer(bp + 12)) { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+37049, int64(-libc.Int32FromInt32(1)))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+72, __ccgo_ts+179, __ccgo_ts+29667, __ccgo_ts+36709, __ccgo_ts+34124, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) } (*(*TTk_PhotoImageBlock)(unsafe.Pointer(bp + 24))).FpixelPtr = *(*uintptr)(unsafe.Pointer(bp + 16)) + uintptr(srcX*(*(*TTk_PhotoImageBlock)(unsafe.Pointer(bp + 24))).FpixelSize) (*(*TTk_PhotoImageBlock)(unsafe.Pointer(bp + 24))).Fheight = height return XTk_PhotoPutBlock(tls, interp, imageHandle, bp+24, destX, destY, width, height, int32(TK_PHOTO_COMPOSITE_SET)) } if XTk_PhotoExpand(tls, interp, imageHandle, destX+width, destY+height) != TCL_OK { return int32(TCL_ERROR) } nLines = (int32(MAX_MEMORY) + (*(*TTk_PhotoImageBlock)(unsafe.Pointer(bp + 24))).Fpitch - int32(1)) / (*(*TTk_PhotoImageBlock)(unsafe.Pointer(bp + 24))).Fpitch if nLines > height { nLines = height } if nLines <= 0 { nLines = int32(1) } nBytes = nLines * (*(*TTk_PhotoImageBlock)(unsafe.Pointer(bp + 24))).Fpitch pixelPtr = libtcl9_0.XTcl_Alloc(tls, libc.Uint64FromInt32(nBytes)) (*(*TTk_PhotoImageBlock)(unsafe.Pointer(bp + 24))).FpixelPtr = pixelPtr + uintptr(srcX*(*(*TTk_PhotoImageBlock)(unsafe.Pointer(bp + 24))).FpixelSize) h = height for { if !(h > 0) { break } if nLines > h { nLines = h nBytes = nLines * (*(*TTk_PhotoImageBlock)(unsafe.Pointer(bp + 24))).Fpitch } if *(*int32)(unsafe.Pointer(bp + 12)) < nBytes { libtcl9_0.XTcl_Free(tls, pixelPtr) libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+37049, int64(-libc.Int32FromInt32(1)))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+72, __ccgo_ts+179, __ccgo_ts+29667, __ccgo_ts+36709, __ccgo_ts+34124, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) } if *(*int32)(unsafe.Pointer(bp + 8)) < int32(0x00ff) { p = pixelPtr count = nBytes for { if !(count > 0) { break } *(*uint8)(unsafe.Pointer(p)) = libc.Uint8FromInt32(libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 16))))) * int32(255) / *(*int32)(unsafe.Pointer(bp + 8))) goto _2 _2: ; count-- p++ *(*uintptr)(unsafe.Pointer(bp + 16))++ } } else { p = pixelPtr count = nBytes for { if !(count > int32(1)) { break } value = uint32(*(*uint8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 16)))))*uint32(256) + uint32(*(*uint8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 16)) + 1))) value = value * uint32(255) / libc.Uint32FromInt32(*(*int32)(unsafe.Pointer(bp + 8))) v4 = uint8(value) *(*uint8)(unsafe.Pointer(p + 1)) = v4 *(*uint8)(unsafe.Pointer(p)) = v4 goto _3 _3: ; count -= int32(2) p += uintptr(2) *(*uintptr)(unsafe.Pointer(bp + 16)) += uintptr(2) } } *(*int32)(unsafe.Pointer(bp + 12)) -= nBytes (*(*TTk_PhotoImageBlock)(unsafe.Pointer(bp + 24))).Fheight = nLines if XTk_PhotoPutBlock(tls, interp, imageHandle, bp+24, destX, destY, width, nLines, int32(TK_PHOTO_COMPOSITE_SET)) != TCL_OK { libtcl9_0.XTcl_Free(tls, pixelPtr) return int32(TCL_ERROR) } destY += nLines goto _1 _1: ; h -= nLines } libtcl9_0.XTcl_Free(tls, pixelPtr) return TCL_OK } /* *---------------------------------------------------------------------- * * ReadPPMFileHeader -- * * This function reads the PPM header from the beginning of a PPM file * and returns information from the header. * * Results: * The return value is PGM if file "f" appears to start with a valid PGM * header, PPM if "f" appears to start with a valid PPM header, and 0 * otherwise. If the header is valid, then *widthPtr and *heightPtr are * modified to hold the dimensions of the image and *maxIntensityPtr is * modified to hold the value of a "fully on" intensity value. * * Side effects: * The access position in f advances. * *---------------------------------------------------------------------- */ func _ReadPPMFileHeader(tls *libc.TLS, chan1 TTcl_Channel, widthPtr uintptr, heightPtr uintptr, maxIntensityPtr uintptr) (r int32) { bp := tls.Alloc(1040) defer tls.Free(1040) /* The maximum intensity value for the image * is stored here. */ var i, numFields, type1, v2, v3, v5, v6 int32 var _ /* buffer at bp+0 */ [1000]uint8 var _ /* c at bp+1000 */ uint8 _, _, _, _, _, _, _ = i, numFields, type1, v2, v3, v5, v6 type1 = 0 /* * Read 4 space-separated fields from the file, ignoring comments (any * line that starts with "#"). */ if libtcl9_0.XTcl_Read(tls, chan1, bp+1000, int64(1)) != int64(1) { return 0 } i = 0 numFields = 0 for { if !(numFields < int32(4)) { break } /* * Skip comments and white space. */ for int32(1) != 0 { for { v2 = libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(bp + 1000))) v3 = libc.BoolInt32(v2 == int32(' ') || libc.Uint32FromInt32(v2)-uint32('\t') < uint32(5)) goto _4 _4: if !(v3 != 0) { break } if libtcl9_0.XTcl_Read(tls, chan1, bp+1000, int64(1)) != int64(1) { return 0 } } if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(bp + 1000))) != int32('#') { break } for cond := true; cond; cond = libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(bp + 1000))) != int32('\n') { if libtcl9_0.XTcl_Read(tls, chan1, bp+1000, int64(1)) != int64(1) { return 0 } } } /* * Read a field (everything up to the next white space). */ for { v5 = libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(bp + 1000))) v6 = libc.BoolInt32(v5 == int32(' ') || libc.Uint32FromInt32(v5)-uint32('\t') < uint32(5)) goto _7 _7: if !!(v6 != 0) { break } if i < libc.Int32FromInt32(BUFFER_SIZE)-libc.Int32FromInt32(2) { (*(*[1000]uint8)(unsafe.Pointer(bp)))[i] = *(*uint8)(unsafe.Pointer(bp + 1000)) i++ } if libtcl9_0.XTcl_Read(tls, chan1, bp+1000, int64(1)) != int64(1) { goto done } } if i < libc.Int32FromInt32(BUFFER_SIZE)-libc.Int32FromInt32(1) { (*(*[1000]uint8)(unsafe.Pointer(bp)))[i] = uint8(' ') i++ } goto _1 _1: ; numFields++ } goto done done: ; (*(*[1000]uint8)(unsafe.Pointer(bp)))[i] = uint8(0) /* * Parse the fields, which are: id, width, height, maxIntensity. */ if libc.Xstrncmp(tls, bp, __ccgo_ts+37068, uint64(3)) == 0 { type1 = int32(PPM) } else { if libc.Xstrncmp(tls, bp, __ccgo_ts+37072, uint64(3)) == 0 { type1 = int32(PGM) } else { return 0 } } if libc.Xsscanf(tls, bp+uintptr(3), __ccgo_ts+6711, libc.VaList(bp+1016, widthPtr, heightPtr, maxIntensityPtr)) != int32(3) { return 0 } return type1 } /* *---------------------------------------------------------------------- * * ReadPPMStringHeader -- * * This function reads the PPM header from the beginning of a PPM-format * string and returns information from the header. * * Results: * The return value is PGM if the string appears to start with a valid * PGM header, PPM if the string appears to start with a valid PPM * header, and 0 otherwise. If the header is valid, then *widthPtr and * *heightPtr are modified to hold the dimensions of the image and * *maxIntensityPtr is modified to hold the value of a "fully on" * intensity value. * * Side effects: * None * *---------------------------------------------------------------------- */ func _ReadPPMStringHeader(tls *libc.TLS, dataPtr uintptr, widthPtr uintptr, heightPtr uintptr, maxIntensityPtr uintptr, dataBufferPtr uintptr, dataSizePtr uintptr) (r int32) { bp := tls.Alloc(1040) defer tls.Free(1040) var c uint8 var dataBuffer, v10, v15, v2, v8 uintptr var i, numFields, type1, v11, v12, v4, v5 int32 var v1, v14, v7, v9 TTcl_Size var _ /* buffer at bp+0 */ [1000]uint8 var _ /* dataSize at bp+1000 */ TTcl_Size _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = c, dataBuffer, i, numFields, type1, v1, v10, v11, v12, v14, v15, v2, v4, v5, v7, v8, v9 type1 = 0 dataBuffer = libtcl9_0.XTcl_GetBytesFromObj(tls, libc.UintptrFromInt32(0), dataPtr, bp+1000) /* * Read 4 space-separated fields from the string, ignoring comments (any * line that starts with "#"). */ v1 = *(*TTcl_Size)(unsafe.Pointer(bp + 1000)) *(*TTcl_Size)(unsafe.Pointer(bp + 1000))-- if v1 < int64(1) { return 0 } v2 = dataBuffer dataBuffer++ c = *(*uint8)(unsafe.Pointer(v2)) i = 0 numFields = 0 for { if !(numFields < int32(4)) { break } /* * Skip comments and white space. */ for int32(1) != 0 { for { v4 = libc.Int32FromUint8(c) v5 = libc.BoolInt32(v4 == int32(' ') || libc.Uint32FromInt32(v4)-uint32('\t') < uint32(5)) goto _6 _6: if !(v5 != 0) { break } v7 = *(*TTcl_Size)(unsafe.Pointer(bp + 1000)) *(*TTcl_Size)(unsafe.Pointer(bp + 1000))-- if v7 < int64(1) { return 0 } v8 = dataBuffer dataBuffer++ c = *(*uint8)(unsafe.Pointer(v8)) } if libc.Int32FromUint8(c) != int32('#') { break } for cond := true; cond; cond = libc.Int32FromUint8(c) != int32('\n') { v9 = *(*TTcl_Size)(unsafe.Pointer(bp + 1000)) *(*TTcl_Size)(unsafe.Pointer(bp + 1000))-- if v9 < int64(1) { return 0 } v10 = dataBuffer dataBuffer++ c = *(*uint8)(unsafe.Pointer(v10)) } } /* * Read a field (everything up to the next white space). */ for { v11 = libc.Int32FromUint8(c) v12 = libc.BoolInt32(v11 == int32(' ') || libc.Uint32FromInt32(v11)-uint32('\t') < uint32(5)) goto _13 _13: if !!(v12 != 0) { break } if i < libc.Int32FromInt32(BUFFER_SIZE)-libc.Int32FromInt32(2) { (*(*[1000]uint8)(unsafe.Pointer(bp)))[i] = c i++ } v14 = *(*TTcl_Size)(unsafe.Pointer(bp + 1000)) *(*TTcl_Size)(unsafe.Pointer(bp + 1000))-- if v14 < int64(1) { goto done } v15 = dataBuffer dataBuffer++ c = *(*uint8)(unsafe.Pointer(v15)) } if i < libc.Int32FromInt32(BUFFER_SIZE)-libc.Int32FromInt32(1) { (*(*[1000]uint8)(unsafe.Pointer(bp)))[i] = uint8(' ') i++ } goto _3 _3: ; numFields++ } goto done done: ; (*(*[1000]uint8)(unsafe.Pointer(bp)))[i] = uint8(0) /* * Parse the fields, which are: id, width, height, maxIntensity. */ if libc.Xstrncmp(tls, bp, __ccgo_ts+37068, uint64(3)) == 0 { type1 = int32(PPM) } else { if libc.Xstrncmp(tls, bp, __ccgo_ts+37072, uint64(3)) == 0 { type1 = int32(PGM) } else { return 0 } } if libc.Xsscanf(tls, bp+uintptr(3), __ccgo_ts+6711, libc.VaList(bp+1016, widthPtr, heightPtr, maxIntensityPtr)) != int32(3) { return 0 } if dataBufferPtr != libc.UintptrFromInt32(0) { *(*uintptr)(unsafe.Pointer(dataBufferPtr)) = dataBuffer *(*int32)(unsafe.Pointer(dataSizePtr)) = int32(*(*TTcl_Size)(unsafe.Pointer(bp + 1000))) } return type1 } const BLACK_AND_WHITE = 1 const COLOR_IMAGE = 1 const COLOR_WINDOW = 2 const COMPLEX_ALPHA = 4 const DEF_PHOTO_GAMMA = "1" const DEF_PHOTO_HEIGHT = "0" const DEF_PHOTO_PALETTE = "" const DEF_PHOTO_WIDTH = "0" const DISPOSE_PENDING = 4 const IMAGE_CHANGED = 2 const MAP_COLORS = 8 const MAX_PIXELS = 65536 const OPT_ALPHA = 1 const OPT_BACKGROUND = 2 const OPT_COMPOSITE = 4 const OPT_FORMAT = 8 const OPT_FROM = 16 const OPT_GRAYSCALE = 32 const OPT_METADATA = 64 const OPT_SHRINK = 128 const OPT_SUBSAMPLE = 256 const OPT_TO = 512 const OPT_WITHALPHA = 1024 const OPT_ZOOM = 2048 const PhotoMaster = 0 const SOURCE_IS_SIMPLE_ALPHA_PHOTO = 268435456 const TK_PHOTO_ALLOC_FAILURE_MESSAGE = "not enough free memory for image buffer" type TColorTableId = struct { Fdisplay uintptr Fcolormap TColormap Fgamma float64 Fpalette TTk_Uid } type TColorTable = struct { Fid TColorTableId FrefCount Tsize_t FliveRefCount Tsize_t Fflags int32 FnumColors int32 FvisualInfo TXVisualInfo FredValues [256]uint32 FgreenValues [256]uint32 FblueValues [256]uint32 FpixelMap uintptr FcolorQuant [3][256]uint8 } type TPhotoInstance = struct { FmodelPtr uintptr Fdisplay uintptr Fcolormap TColormap FnextPtr uintptr FrefCount Tsize_t Fpalette TTk_Uid Fgamma float64 FdefaultPalette TTk_Uid FcolorTablePtr uintptr Fpixels TPixmap Fwidth int32 Fheight int32 Ferror1 uintptr FimagePtr uintptr FvisualInfo TXVisualInfo Fgc TGC } type TPhotoModel = struct { FtkModel TTk_ImageModel Finterp uintptr FimageCmd TTcl_Command Fflags int32 Fwidth int32 Fheight int32 FuserWidth int32 FuserHeight int32 Fpalette TTk_Uid Fgamma float64 FfileObj uintptr FdataObj uintptr Fformat uintptr Fmetadata uintptr Fpix32 uintptr FditherX int32 FditherY int32 FvalidRegion TRegion FinstancePtr uintptr } type Tschar = int8 type TColorTableId1 = struct { Fdisplay uintptr Fcolormap TColormap Fgamma float64 Fpalette TTk_Uid } type TColorTable1 = struct { Fid TColorTableId FrefCount Tsize_t FliveRefCount Tsize_t Fflags int32 FnumColors int32 FvisualInfo TXVisualInfo FredValues [256]uint32 FgreenValues [256]uint32 FblueValues [256]uint32 FpixelMap uintptr FcolorQuant [3][256]uint8 } type TPhotoModel1 = struct { FtkModel TTk_ImageModel Finterp uintptr FimageCmd TTcl_Command Fflags int32 Fwidth int32 Fheight int32 FuserWidth int32 FuserHeight int32 Fpalette TTk_Uid Fgamma float64 FfileObj uintptr FdataObj uintptr Fformat uintptr Fmetadata uintptr Fpix32 uintptr FditherX int32 FditherY int32 FvalidRegion TRegion FinstancePtr uintptr } type TPhotoInstance1 = struct { FmodelPtr uintptr Fdisplay uintptr Fcolormap TColormap FnextPtr uintptr FrefCount Tsize_t Fpalette TTk_Uid Fgamma float64 FdefaultPalette TTk_Uid FcolorTablePtr uintptr Fpixels TPixmap Fwidth int32 Fheight int32 Ferror1 uintptr FimagePtr uintptr FvisualInfo TXVisualInfo Fgc TGC } /* * Local Variables: * mode: c * c-basic-offset: 4 * fill-column: 78 * End: */ /* * The following data structure is used to return information from * ParseSubcommandOptions: */ type TSubcommandOptions = struct { Foptions int32 Fname uintptr FfromX int32 FfromY int32 FfromX2 int32 FfromY2 int32 FtoX int32 FtoY int32 FtoX2 int32 FtoY2 int32 FzoomX int32 FzoomY int32 FsubsampleX int32 FsubsampleY int32 Fformat uintptr Fbackground uintptr FcompositingRule int32 Fmetadata uintptr } /* * Bit definitions for use with ParseSubcommandOptions: each bit is set in the * allowedOptions parameter on a call to ParseSubcommandOptions if that option * is allowed for the current photo image subcommand. On return, the bit is * set in the options field of the SubcommandOptions structure if that option * was specified. * * OPT_ALPHA: Set if -alpha option allowed/specified. * OPT_BACKGROUND: Set if -format option allowed/specified. * OPT_COMPOSITE: Set if -compositingrule option allowed/spec'd. * OPT_FORMAT: Set if -format option allowed/specified. * OPT_FROM: Set if -from option allowed/specified. * OPT_GRAYSCALE: Set if -grayscale option allowed/specified. * OPT_METADATA: Set if -metadata option allowed/specified. * OPT_SHRINK: Set if -shrink option allowed/specified. * OPT_SUBSAMPLE: Set if -subsample option allowed/spec'd. * OPT_TO: Set if -to option allowed/specified. * OPT_WITHALPHA: Set if -withalpha option allowed/specified. * OPT_ZOOM: Set if -zoom option allowed/specified. */ /* * List of option names. The order here must match the order of declarations * of the OPT_* constants above. */ var _optionNames = [13]uintptr{ 0: __ccgo_ts + 36112, 1: __ccgo_ts + 19898, 2: __ccgo_ts + 37082, 3: __ccgo_ts + 4981, 4: __ccgo_ts + 22037, 5: __ccgo_ts + 37099, 6: __ccgo_ts + 37110, 7: __ccgo_ts + 37120, 8: __ccgo_ts + 37128, 9: __ccgo_ts + 22096, 10: __ccgo_ts + 37139, 11: __ccgo_ts + 37150, 12: libc.UintptrFromInt32(0), } func init() { p := unsafe.Pointer(&XtkPhotoImageType) *(*uintptr)(unsafe.Add(p, 8)) = __ccgo_fp(_ImgPhotoCreate) *(*uintptr)(unsafe.Add(p, 16)) = __ccgo_fp(XTkImgPhotoGet) *(*uintptr)(unsafe.Add(p, 24)) = __ccgo_fp(XTkImgPhotoDisplay) *(*uintptr)(unsafe.Add(p, 32)) = __ccgo_fp(XTkImgPhotoFree) *(*uintptr)(unsafe.Add(p, 40)) = __ccgo_fp(_ImgPhotoDelete) *(*uintptr)(unsafe.Add(p, 48)) = __ccgo_fp(_ImgPhotoPostscript) } type TThreadSpecificData13 = struct { FformatList uintptr FformatListVersion3 uintptr Finitialized int32 } var _dataKey14 TTcl_ThreadDataKey /* * Default configuration */ /* * Information used for parsing configuration specifications: */ var _configSpecs12 = [9]TTk_ConfigSpec{ 0: { Ftype1: int32(TK_CONFIG_STRING), FargvName: __ccgo_ts + 2842, Foffset: int64(-libc.Int32FromInt32(1)), FspecFlags: libc.Int32FromInt32(TK_CONFIG_OBJS) | libc.Int32FromInt32(TCL_NULL_OK), }, 1: { Ftype1: int32(TK_CONFIG_STRING), FargvName: __ccgo_ts + 30371, Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 64)), FspecFlags: libc.Int32FromInt32(TK_CONFIG_OBJS) | libc.Int32FromInt32(TCL_NULL_OK), }, 2: { Ftype1: int32(TK_CONFIG_STRING), FargvName: __ccgo_ts + 4981, Foffset: int64(-libc.Int32FromInt32(1)), FspecFlags: libc.Int32FromInt32(TK_CONFIG_OBJS) | libc.Int32FromInt32(TCL_NULL_OK), }, 3: { Ftype1: int32(TK_CONFIG_DOUBLE), FargvName: __ccgo_ts + 37156, FdefValue: __ccgo_ts + 14538, Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 56)), }, 4: { Ftype1: int32(TK_CONFIG_INT), FargvName: __ccgo_ts + 2870, FdefValue: __ccgo_ts + 10533, Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 40)), }, 5: { Ftype1: int32(TK_CONFIG_STRING), FargvName: __ccgo_ts + 37110, Foffset: int64(-libc.Int32FromInt32(1)), FspecFlags: libc.Int32FromInt32(TK_CONFIG_OBJS) | libc.Int32FromInt32(TCL_NULL_OK), }, 6: { Ftype1: int32(TK_CONFIG_UID), FargvName: __ccgo_ts + 37163, FdefValue: __ccgo_ts + 195, Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 48)), }, 7: { Ftype1: int32(TK_CONFIG_INT), FargvName: __ccgo_ts + 2987, FdefValue: __ccgo_ts + 10533, Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 36)), }, 8: { Ftype1: int32(TK_CONFIG_END), }, } /* *---------------------------------------------------------------------- * * PhotoFormatThreadExitProc -- * * Clean up the registered list of photo formats. * * Results: * None. * * Side effects: * The thread's linked lists of photo image formats is deleted. * *---------------------------------------------------------------------- */ func _PhotoFormatThreadExitProc(tls *libc.TLS, dummy238 uintptr) { /* not used */ var freePtr, freePtrVersion3, tsdPtr uintptr _, _, _ = freePtr, freePtrVersion3, tsdPtr tsdPtr = libtcl9_0.XTcl_GetThreadData(tls, uintptr(unsafe.Pointer(&_dataKey14)), int64(24)) for (*TThreadSpecificData13)(unsafe.Pointer(tsdPtr)).FformatList != libc.UintptrFromInt32(0) { freePtr = (*TThreadSpecificData13)(unsafe.Pointer(tsdPtr)).FformatList (*TThreadSpecificData13)(unsafe.Pointer(tsdPtr)).FformatList = (*TTk_PhotoImageFormat)(unsafe.Pointer((*TThreadSpecificData13)(unsafe.Pointer(tsdPtr)).FformatList)).FnextPtr libtcl9_0.XTcl_Free(tls, (*TTk_PhotoImageFormat)(unsafe.Pointer(freePtr)).Fname) libtcl9_0.XTcl_Free(tls, freePtr) } for (*TThreadSpecificData13)(unsafe.Pointer(tsdPtr)).FformatListVersion3 != libc.UintptrFromInt32(0) { freePtrVersion3 = (*TThreadSpecificData13)(unsafe.Pointer(tsdPtr)).FformatListVersion3 (*TThreadSpecificData13)(unsafe.Pointer(tsdPtr)).FformatListVersion3 = (*TTk_PhotoImageFormatVersion3)(unsafe.Pointer((*TThreadSpecificData13)(unsafe.Pointer(tsdPtr)).FformatListVersion3)).FnextPtr libtcl9_0.XTcl_Free(tls, (*TTk_PhotoImageFormatVersion3)(unsafe.Pointer(freePtrVersion3)).Fname) libtcl9_0.XTcl_Free(tls, freePtrVersion3) } } /* *---------------------------------------------------------------------- * * Tk_CreatePhotoImageFormat, * Tk_CreatePhotoImageFormatVersion3 -- * * This function is invoked by an image file handler to register a new * photo image format and the functions that handle the new format. The * function is typically invoked during Tcl_AppInit. * * Results: * None. * * Side effects: * The new image file format is entered into a table used in the photo * image "read" and "write" subcommands. * *---------------------------------------------------------------------- */ func XTk_CreatePhotoImageFormat(tls *libc.TLS, formatPtr uintptr) { /* Structure describing the format. All of the * fields except "nextPtr" must be filled in * by caller. */ var copyPtr, name, tsdPtr uintptr _, _, _ = copyPtr, name, tsdPtr tsdPtr = libtcl9_0.XTcl_GetThreadData(tls, uintptr(unsafe.Pointer(&_dataKey14)), int64(24)) if !((*TThreadSpecificData13)(unsafe.Pointer(tsdPtr)).Finitialized != 0) { (*TThreadSpecificData13)(unsafe.Pointer(tsdPtr)).Finitialized = int32(1) libtcl9_0.XTcl_CreateThreadExitHandler(tls, __ccgo_fp(_PhotoFormatThreadExitProc), libc.UintptrFromInt32(0)) } copyPtr = libtcl9_0.XTcl_Alloc(tls, uint64(64)) *(*TTk_PhotoImageFormat)(unsafe.Pointer(copyPtr)) = *(*TTk_PhotoImageFormat)(unsafe.Pointer(formatPtr)) /* for compatibility with aMSN: make a copy of formatPtr->name */ name = libtcl9_0.XTcl_Alloc(tls, libc.Xstrlen(tls, (*TTk_PhotoImageFormat)(unsafe.Pointer(formatPtr)).Fname)+uint64(1)) libc.Xstrcpy(tls, name, (*TTk_PhotoImageFormat)(unsafe.Pointer(formatPtr)).Fname) (*TTk_PhotoImageFormat)(unsafe.Pointer(copyPtr)).Fname = name (*TTk_PhotoImageFormat)(unsafe.Pointer(copyPtr)).FnextPtr = (*TThreadSpecificData13)(unsafe.Pointer(tsdPtr)).FformatList (*TThreadSpecificData13)(unsafe.Pointer(tsdPtr)).FformatList = copyPtr } func XTk_CreatePhotoImageFormatVersion3(tls *libc.TLS, formatPtr uintptr) { /* Structure describing the format. All of the * fields except "nextPtr" must be filled in * by caller. */ var copyPtr, name, tsdPtr uintptr _, _, _ = copyPtr, name, tsdPtr tsdPtr = libtcl9_0.XTcl_GetThreadData(tls, uintptr(unsafe.Pointer(&_dataKey14)), int64(24)) if !((*TThreadSpecificData13)(unsafe.Pointer(tsdPtr)).Finitialized != 0) { (*TThreadSpecificData13)(unsafe.Pointer(tsdPtr)).Finitialized = int32(1) libtcl9_0.XTcl_CreateThreadExitHandler(tls, __ccgo_fp(_PhotoFormatThreadExitProc), libc.UintptrFromInt32(0)) } copyPtr = libtcl9_0.XTcl_Alloc(tls, uint64(64)) *(*TTk_PhotoImageFormatVersion3)(unsafe.Pointer(copyPtr)) = *(*TTk_PhotoImageFormatVersion3)(unsafe.Pointer(formatPtr)) /* for compatibility with aMSN: make a copy of formatPtr->name */ name = libtcl9_0.XTcl_Alloc(tls, libc.Xstrlen(tls, (*TTk_PhotoImageFormatVersion3)(unsafe.Pointer(formatPtr)).Fname)+uint64(1)) libc.Xstrcpy(tls, name, (*TTk_PhotoImageFormatVersion3)(unsafe.Pointer(formatPtr)).Fname) (*TTk_PhotoImageFormatVersion3)(unsafe.Pointer(copyPtr)).Fname = name (*TTk_PhotoImageFormatVersion3)(unsafe.Pointer(copyPtr)).FnextPtr = (*TThreadSpecificData13)(unsafe.Pointer(tsdPtr)).FformatListVersion3 (*TThreadSpecificData13)(unsafe.Pointer(tsdPtr)).FformatListVersion3 = copyPtr } /* *---------------------------------------------------------------------- * * ImgPhotoCreate -- * * This function is called by the Tk image code to create a new photo * image. * * Results: * A standard Tcl result. * * Side effects: * The data structure for a new photo image is allocated and initialized. * *---------------------------------------------------------------------- */ func _ImgPhotoCreate(tls *libc.TLS, interp uintptr, name uintptr, objc TTcl_Size, objv uintptr, dummy357 uintptr, model TTk_ImageModel, clientDataPtr uintptr) (r int32) { /* Store manager's token for image here; it * will be returned in later callbacks. */ var modelPtr uintptr _ = modelPtr /* * Allocate and initialize the photo image model record. */ modelPtr = libtcl9_0.XTcl_Alloc(tls, uint64(128)) libc.Xmemset(tls, modelPtr, 0, uint64(128)) (*TPhotoModel)(unsafe.Pointer(modelPtr)).FtkModel = model (*TPhotoModel)(unsafe.Pointer(modelPtr)).Finterp = interp (*TPhotoModel)(unsafe.Pointer(modelPtr)).FimageCmd = libtcl9_0.XTcl_CreateObjCommand(tls, interp, name, __ccgo_fp(_ImgPhotoCmd), modelPtr, __ccgo_fp(_ImgPhotoCmdDeletedProc)) (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fpalette = libc.UintptrFromInt32(0) (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fpix32 = libc.UintptrFromInt32(0) (*TPhotoModel)(unsafe.Pointer(modelPtr)).FinstancePtr = libc.UintptrFromInt32(0) (*TPhotoModel)(unsafe.Pointer(modelPtr)).FvalidRegion = libx11.XXCreateRegion(tls) /* * Process configuration options given in the image create command. */ if _ImgPhotoConfigureModel(tls, interp, modelPtr, objc, objv, 0) != TCL_OK { _ImgPhotoDelete(tls, modelPtr) return int32(TCL_ERROR) } *(*uintptr)(unsafe.Pointer(clientDataPtr)) = modelPtr return TCL_OK } /* *---------------------------------------------------------------------- * * ImgPhotoCmd -- * * This function is invoked to process the Tcl command that corresponds * to a photo image. See the user documentation for details on what it * does. * * Results: * A standard Tcl result. * * Side effects: * See the user documentation. * *---------------------------------------------------------------------- */ func _ImgPhotoCmd(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) (r int32) { bp := tls.Alloc(512) defer tls.Free(512) /* Argument objects. */ var _objPtr, _objPtr1, arg, arg1, data, data1, data2, fmtString, format, format1, format2, freeObj, metadataIn, metadataIn1, modelPtr, obj, pixelPtr, stringWriteProc, stringWriteProcVersion3, subobj, tsdPtr, v17, v19, v21 uintptr var boolMode, boolMode1, channelCount, height, i, matched, result, usedExt, width, v13, v14, v23 int32 var chan1 TTcl_Channel var modRegion TRegion var srcHandle TTk_PhotoHandle var v18, v20 TTcl_Size var _ /* block at bp+112 */ TTk_PhotoImageBlock var _ /* buffer at bp+192 */ TTcl_DString var _ /* channels at bp+416 */ [4]uintptr var _ /* imageFormat at bp+152 */ uintptr var _ /* imageFormatVersion3 at bp+160 */ uintptr var _ /* imageHeight at bp+180 */ int32 var _ /* imageWidth at bp+176 */ int32 var _ /* index at bp+8 */ TTcl_Size var _ /* length at bp+168 */ TTcl_Size var _ /* newVal at bp+448 */ int32 var _ /* oldformat at bp+184 */ int32 var _ /* options at bp+16 */ TSubcommandOptions var _ /* setBox at bp+456 */ TXRectangle var _ /* x at bp+0 */ int32 var _ /* y at bp+4 */ int32 _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = _objPtr, _objPtr1, arg, arg1, boolMode, boolMode1, chan1, channelCount, data, data1, data2, fmtString, format, format1, format2, freeObj, height, i, matched, metadataIn, metadataIn1, modRegion, modelPtr, obj, pixelPtr, result, srcHandle, stringWriteProc, stringWriteProcVersion3, subobj, tsdPtr, usedExt, width, v13, v14, v17, v18, v19, v20, v21, v23 modelPtr = clientData *(*int32)(unsafe.Pointer(bp + 184)) = 0 tsdPtr = libtcl9_0.XTcl_GetThreadData(tls, uintptr(unsafe.Pointer(&_dataKey14)), int64(24)) if objc < int32(2) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(1), objv, __ccgo_ts+4953) return int32(TCL_ERROR) } if libtcl9_0.XTcl_GetIndexFromObjStruct(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 1*8)), uintptr(unsafe.Pointer(&_photoOptions)), libc.Int64FromUint64(libc.Uint64FromInt64(8)), __ccgo_ts+2689, libc.Int32FromInt32(0)|libc.Int32FromUint64(libc.Uint64FromInt64(8)< int64(1) && !(libc.Xstrncmp(tls, arg1, __ccgo_ts+2842, libc.Uint64FromInt64(*(*TTcl_Size)(unsafe.Pointer(bp + 168)))) != 0) { libtcl9_0.XTcl_AppendResult(tls, interp, libc.VaList(bp+472, __ccgo_ts+37225, libc.UintptrFromInt32(0))) if (*TPhotoModel)(unsafe.Pointer(modelPtr)).FdataObj != 0 { /* * TODO: Modifying result is bad! */ libtcl9_0.XTcl_ListObjAppendElement(tls, libc.UintptrFromInt32(0), libtcl9_0.XTcl_GetObjResult(tls, interp), (*TPhotoModel)(unsafe.Pointer(modelPtr)).FdataObj) } else { libtcl9_0.XTcl_AppendResult(tls, interp, libc.VaList(bp+472, __ccgo_ts+37240, libc.UintptrFromInt32(0))) } return TCL_OK } else { if *(*TTcl_Size)(unsafe.Pointer(bp + 168)) > int64(1) && !(libc.Xstrncmp(tls, arg1, __ccgo_ts+4981, libc.Uint64FromInt64(*(*TTcl_Size)(unsafe.Pointer(bp + 168)))) != 0) { libtcl9_0.XTcl_AppendResult(tls, interp, libc.VaList(bp+472, __ccgo_ts+37244, libc.UintptrFromInt32(0))) if (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fformat != 0 { /* * TODO: Modifying result is bad! */ libtcl9_0.XTcl_ListObjAppendElement(tls, libc.UintptrFromInt32(0), libtcl9_0.XTcl_GetObjResult(tls, interp), (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fformat) } else { libtcl9_0.XTcl_AppendResult(tls, interp, libc.VaList(bp+472, __ccgo_ts+37240, libc.UintptrFromInt32(0))) } return TCL_OK } else { if *(*TTcl_Size)(unsafe.Pointer(bp + 168)) > int64(1) && !(libc.Xstrncmp(tls, arg1, __ccgo_ts+37110, libc.Uint64FromInt64(*(*TTcl_Size)(unsafe.Pointer(bp + 168)))) != 0) { libtcl9_0.XTcl_AppendResult(tls, interp, libc.VaList(bp+472, __ccgo_ts+37261, libc.UintptrFromInt32(0))) if (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fmetadata != 0 { /* * TODO: Modifying result is bad! */ libtcl9_0.XTcl_ListObjAppendElement(tls, libc.UintptrFromInt32(0), libtcl9_0.XTcl_GetObjResult(tls, interp), (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fmetadata) } else { libtcl9_0.XTcl_AppendResult(tls, interp, libc.VaList(bp+472, __ccgo_ts+37240, libc.UintptrFromInt32(0))) } return TCL_OK } else { return XTk_ConfigureInfo(tls, interp, XTk_MainWindow(tls, interp), uintptr(unsafe.Pointer(&_configSpecs12)), modelPtr, arg1, 0) } } } } else { return _ImgPhotoConfigureModel(tls, interp, modelPtr, int64(objc-int32(2)), objv+uintptr(2)*8, int32(TK_CONFIG_ARGV_ONLY)) } } _4: ; /* * photo copy command - first parse options. */ *(*TTcl_Size)(unsafe.Pointer(bp + 8)) = int64(2) libc.Xmemset(tls, bp+16, 0, uint64(96)) v13 = libc.Int32FromInt32(1) (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).FzoomY = v13 (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).FzoomX = v13 v14 = libc.Int32FromInt32(1) (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).FsubsampleY = v14 (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).FsubsampleX = v14 (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).Fname = libc.UintptrFromInt32(0) (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).FcompositingRule = TK_PHOTO_COMPOSITE_OVERLAY if _ParseSubcommandOptions(tls, bp+16, interp, libc.Int32FromInt32(OPT_FROM)|libc.Int32FromInt32(OPT_TO)|libc.Int32FromInt32(OPT_ZOOM)|libc.Int32FromInt32(OPT_SUBSAMPLE)|libc.Int32FromInt32(OPT_SHRINK)|libc.Int32FromInt32(OPT_COMPOSITE), bp+8, int64(objc), objv) != TCL_OK { return int32(TCL_ERROR) } if (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).Fname == libc.UintptrFromInt32(0) || *(*TTcl_Size)(unsafe.Pointer(bp + 8)) < int64(objc) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(2), objv, __ccgo_ts+37280) return int32(TCL_ERROR) } /* * Look for the source image and get a pointer to its image data. * Check the values given for the -from option. */ srcHandle = XTk_FindPhoto(tls, interp, libtcl9_0.XTcl_GetStringFromObj(tls, (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).Fname, libc.UintptrFromInt32(0))) if srcHandle == libc.UintptrFromInt32(0) { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+37384, libc.VaList(bp+472, libtcl9_0.XTcl_GetStringFromObj(tls, (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).Fname, libc.UintptrFromInt32(0))))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+472, __ccgo_ts+179, __ccgo_ts+3058, __ccgo_ts+37434, libtcl9_0.XTcl_GetStringFromObj(tls, (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).Fname, libc.UintptrFromInt32(0)), libc.UintptrFromInt32(0))) return int32(TCL_ERROR) } XTk_PhotoGetImage(tls, srcHandle, bp+112) if (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).FfromX > (*(*TTk_PhotoImageBlock)(unsafe.Pointer(bp + 112))).Fwidth || (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).FfromY > (*(*TTk_PhotoImageBlock)(unsafe.Pointer(bp + 112))).Fheight || (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).FfromX2 > (*(*TTk_PhotoImageBlock)(unsafe.Pointer(bp + 112))).Fwidth || (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).FfromY2 > (*(*TTk_PhotoImageBlock)(unsafe.Pointer(bp + 112))).Fheight { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+37440, int64(-int32(1)))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+472, __ccgo_ts+179, __ccgo_ts+29667, __ccgo_ts+37434, __ccgo_ts+37497, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) } /* * Hack to pass through the message that the place we're coming from * has a simple alpha channel. */ if !((*TPhotoModel)(unsafe.Pointer(srcHandle)).Fflags&libc.Int32FromInt32(COMPLEX_ALPHA) != 0) { (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).FcompositingRule |= int32(SOURCE_IS_SIMPLE_ALPHA_PHOTO) } /* * Fill in default values for unspecified parameters. */ if !((*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).Foptions&libc.Int32FromInt32(OPT_FROM) != 0) || (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).FfromX2 < 0 { (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).FfromX2 = (*(*TTk_PhotoImageBlock)(unsafe.Pointer(bp + 112))).Fwidth (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).FfromY2 = (*(*TTk_PhotoImageBlock)(unsafe.Pointer(bp + 112))).Fheight } if !((*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).Foptions&libc.Int32FromInt32(OPT_TO) != 0) || (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).FtoX2 < 0 { width = (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).FfromX2 - (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).FfromX if (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).FsubsampleX > 0 { width = (width + (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).FsubsampleX - int32(1)) / (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).FsubsampleX } else { if (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).FsubsampleX == 0 { width = 0 } else { width = (width - (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).FsubsampleX - int32(1)) / -(*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).FsubsampleX } } (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).FtoX2 = (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).FtoX + width*(*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).FzoomX height = (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).FfromY2 - (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).FfromY if (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).FsubsampleY > 0 { height = (height + (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).FsubsampleY - int32(1)) / (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).FsubsampleY } else { if (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).FsubsampleY == 0 { height = 0 } else { height = (height - (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).FsubsampleY - int32(1)) / -(*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).FsubsampleY } } (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).FtoY2 = (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).FtoY + height*(*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).FzoomY } /* * Copy the image data over using Tk_PhotoPutZoomedBlock. */ if (*(*TTk_PhotoImageBlock)(unsafe.Pointer(bp + 112))).FpixelPtr != 0 { (*(*TTk_PhotoImageBlock)(unsafe.Pointer(bp + 112))).FpixelPtr += uintptr((*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).FfromX*(*(*TTk_PhotoImageBlock)(unsafe.Pointer(bp + 112))).FpixelSize + (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).FfromY*(*(*TTk_PhotoImageBlock)(unsafe.Pointer(bp + 112))).Fpitch) (*(*TTk_PhotoImageBlock)(unsafe.Pointer(bp + 112))).Fwidth = (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).FfromX2 - (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).FfromX (*(*TTk_PhotoImageBlock)(unsafe.Pointer(bp + 112))).Fheight = (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).FfromY2 - (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).FfromY result = XTk_PhotoPutZoomedBlock(tls, interp, modelPtr, bp+112, (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).FtoX, (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).FtoY, (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).FtoX2-(*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).FtoX, (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).FtoY2-(*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).FtoY, (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).FzoomX, (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).FzoomY, (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).FsubsampleX, (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).FsubsampleY, (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).FcompositingRule) } else { result = TCL_OK } /* * Set the destination image size if the -shrink option was specified. * This has to be done _after_ copying the data. Otherwise, if source * and destination are the same image, block.pixelPtr would point to * an invalid memory block (bug [5239fd749b]). */ if (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).Foptions&int32(OPT_SHRINK) != 0 { if _ImgPhotoSetSize(tls, modelPtr, (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).FtoX2, (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).FtoY2) != TCL_OK { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+37506, int64(-libc.Int32FromInt32(1)))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+472, __ccgo_ts+179, __ccgo_ts+36356, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) } } if (*(*TTk_PhotoImageBlock)(unsafe.Pointer(bp + 112))).FpixelPtr != 0 || (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).Foptions&int32(OPT_SHRINK) != 0 { XTk_ImageChanged(tls, (*TPhotoModel)(unsafe.Pointer(modelPtr)).FtkModel, 0, 0, 0, 0, (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fwidth, (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fheight) } return result _5: ; data = libc.UintptrFromInt32(0) freeObj = libc.UintptrFromInt32(0) /* * photo data command - first parse and check any options given. */ stringWriteProc = libc.UintptrFromInt32(0) stringWriteProcVersion3 = libc.UintptrFromInt32(0) *(*TTcl_Size)(unsafe.Pointer(bp + 8)) = int64(1) libc.Xmemset(tls, bp+16, 0, uint64(96)) (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).Fname = libc.UintptrFromInt32(0) (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).Fformat = libc.UintptrFromInt32(0) (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).Fmetadata = libc.UintptrFromInt32(0) (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).FfromX = 0 (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).FfromY = 0 if _ParseSubcommandOptions(tls, bp+16, interp, libc.Int32FromInt32(OPT_FORMAT)|libc.Int32FromInt32(OPT_FROM)|libc.Int32FromInt32(OPT_GRAYSCALE)|libc.Int32FromInt32(OPT_BACKGROUND)|libc.Int32FromInt32(OPT_METADATA), bp+8, int64(objc), objv) != TCL_OK { return int32(TCL_ERROR) } if (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).Fname == libc.UintptrFromInt32(0) || *(*TTcl_Size)(unsafe.Pointer(bp + 8)) < int64(objc) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(2), objv, __ccgo_ts+5040) if (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).Fbackground != 0 { XTk_FreeColor(tls, (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).Fbackground) } return int32(TCL_ERROR) } if (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).FfromX > (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fwidth || (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).FfromY > (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fheight || (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).FfromX2 > (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fwidth || (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).FfromY2 > (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fheight { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+37546, int64(-libc.Int32FromInt32(1)))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+472, __ccgo_ts+179, __ccgo_ts+29667, __ccgo_ts+37434, __ccgo_ts+37497, libc.UintptrFromInt32(0))) if (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).Fbackground != 0 { XTk_FreeColor(tls, (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).Fbackground) } return int32(TCL_ERROR) } /* * Fill in default values for unspecified parameters. */ if !((*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).Foptions&libc.Int32FromInt32(OPT_FROM) != 0) || (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).FfromX2 < 0 { (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).FfromX2 = (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fwidth (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).FfromY2 = (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fheight } if !((*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).Foptions&libc.Int32FromInt32(OPT_FORMAT) != 0) { (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).Fformat = libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+17388, int64(-libc.Int32FromInt32(1))) freeObj = (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).Fformat } /* * Use argument metadata if specified, otherwise the master metadata */ if libc.UintptrFromInt32(0) != (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).Fmetadata { metadataIn = (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).Fmetadata } else { metadataIn = (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fmetadata } /* * Search for an appropriate image string format handler. */ matched = 0 *(*uintptr)(unsafe.Pointer(bp + 152)) = (*TThreadSpecificData13)(unsafe.Pointer(tsdPtr)).FformatList for { if !(*(*uintptr)(unsafe.Pointer(bp + 152)) != libc.UintptrFromInt32(0)) { break } if libc.Xstrncasecmp(tls, libtcl9_0.XTcl_GetStringFromObj(tls, (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).Fformat, libc.UintptrFromInt32(0)), (*TTk_PhotoImageFormat)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 152)))).Fname, libc.Xstrlen(tls, (*TTk_PhotoImageFormat)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 152)))).Fname)) == 0 { matched = int32(1) if (*TTk_PhotoImageFormat)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 152)))).FstringWriteProc != libc.UintptrFromInt32(0) { stringWriteProc = (*TTk_PhotoImageFormat)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 152)))).FstringWriteProc break } } goto _15 _15: ; *(*uintptr)(unsafe.Pointer(bp + 152)) = (*TTk_PhotoImageFormat)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 152)))).FnextPtr } if stringWriteProc == libc.UintptrFromInt32(0) { *(*int32)(unsafe.Pointer(bp + 184)) = 0 *(*uintptr)(unsafe.Pointer(bp + 160)) = (*TThreadSpecificData13)(unsafe.Pointer(tsdPtr)).FformatListVersion3 for { if !(*(*uintptr)(unsafe.Pointer(bp + 160)) != libc.UintptrFromInt32(0)) { break } if libc.Xstrncasecmp(tls, libtcl9_0.XTcl_GetStringFromObj(tls, (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).Fformat, libc.UintptrFromInt32(0)), (*TTk_PhotoImageFormatVersion3)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 160)))).Fname, libc.Xstrlen(tls, (*TTk_PhotoImageFormatVersion3)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 160)))).Fname)) == 0 { matched = int32(1) if (*TTk_PhotoImageFormatVersion3)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 160)))).FstringWriteProc != libc.UintptrFromInt32(0) { stringWriteProcVersion3 = (*TTk_PhotoImageFormatVersion3)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 160)))).FstringWriteProc break } } goto _16 _16: ; *(*uintptr)(unsafe.Pointer(bp + 160)) = (*TTk_PhotoImageFormatVersion3)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 160)))).FnextPtr } } if stringWriteProc == libc.UintptrFromInt32(0) && stringWriteProcVersion3 == libc.UintptrFromInt32(0) { if matched != 0 { v17 = __ccgo_ts + 37596 } else { v17 = __ccgo_ts + 6559 } libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+37610, libc.VaList(bp+472, libtcl9_0.XTcl_GetStringFromObj(tls, (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).Fformat, libc.UintptrFromInt32(0)), v17))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+472, __ccgo_ts+179, __ccgo_ts+3058, __ccgo_ts+37641, libtcl9_0.XTcl_GetStringFromObj(tls, (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).Fformat, libc.UintptrFromInt32(0)), libc.UintptrFromInt32(0))) goto dataErrorExit } /* * Call the handler's string write function to write out the image. */ data = _ImgGetPhoto(tls, modelPtr, bp+112, bp+16) if stringWriteProc == libc.UintptrFromInt32(0) { result = (*(*func(*libc.TLS, uintptr, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{stringWriteProcVersion3})))(tls, interp, (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).Fformat, metadataIn, bp+112) } else { if *(*int32)(unsafe.Pointer(bp + 184)) != 0 { libtcl9_0.XTcl_DStringInit(tls, bp+192) result = (*(*func(*libc.TLS, uintptr, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{stringWriteProc})))(tls, interp, bp+192, libtcl9_0.XTcl_GetStringFromObj(tls, (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).Fformat, libc.UintptrFromInt32(0)), bp+112) if result == TCL_OK { libtcl9_0.XTcl_DStringResult(tls, interp, bp+192) } else { libtcl9_0.XTcl_DStringFree(tls, bp+192) } } else { result = (*(*func(*libc.TLS, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{stringWriteProc})))(tls, interp, (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).Fformat, bp+112) } } if (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).Fbackground != 0 { XTk_FreeColor(tls, (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).Fbackground) } if data != 0 { libtcl9_0.XTcl_Free(tls, data) } if freeObj != libc.UintptrFromInt32(0) { _objPtr = freeObj v19 = _objPtr v18 = *(*TTcl_Size)(unsafe.Pointer(v19)) *(*TTcl_Size)(unsafe.Pointer(v19))-- if v18 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr) } } return result goto dataErrorExit dataErrorExit: ; if (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).Fbackground != 0 { XTk_FreeColor(tls, (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).Fbackground) } if data != 0 { libtcl9_0.XTcl_Free(tls, data) } if freeObj != libc.UintptrFromInt32(0) { _objPtr1 = freeObj v21 = _objPtr1 v20 = *(*TTcl_Size)(unsafe.Pointer(v21)) *(*TTcl_Size)(unsafe.Pointer(v21))-- if v20 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr1) } } return int32(TCL_ERROR) _6: ; channelCount = int32(3) *(*TTcl_Size)(unsafe.Pointer(bp + 8)) = int64(3) libc.Xmemset(tls, bp+16, 0, uint64(96)) (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).Fname = libc.UintptrFromInt32(0) if _ParseSubcommandOptions(tls, bp+16, interp, int32(OPT_WITHALPHA), bp+8, int64(objc), objv) != TCL_OK { return int32(TCL_ERROR) } if (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).Fname == libc.UintptrFromInt32(0) || *(*TTcl_Size)(unsafe.Pointer(bp + 8)) < int64(objc) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(2), objv, __ccgo_ts+37654) return int32(TCL_ERROR) } if (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).Foptions&int32(OPT_WITHALPHA) != 0 { channelCount = int32(4) } if libtcl9_0.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp) != TCL_OK || libtcl9_0.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 3*8)), bp+4) != TCL_OK { return int32(TCL_ERROR) } if *(*int32)(unsafe.Pointer(bp)) < 0 || *(*int32)(unsafe.Pointer(bp)) >= (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fwidth || *(*int32)(unsafe.Pointer(bp + 4)) < 0 || *(*int32)(unsafe.Pointer(bp + 4)) >= (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fheight { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+37671, libc.VaList(bp+472, libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv)), libc.UintptrFromInt32(0))))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+472, __ccgo_ts+179, __ccgo_ts+29667, __ccgo_ts+37434, __ccgo_ts+37704, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) } /* * Extract the value of the desired pixel and format it as a list. */ pixelPtr = (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fpix32 + uintptr((*(*int32)(unsafe.Pointer(bp + 4))*(*TPhotoModel)(unsafe.Pointer(modelPtr)).Fwidth+*(*int32)(unsafe.Pointer(bp)))*int32(4)) i = 0 for { if !(i < channelCount) { break } (*(*[4]uintptr)(unsafe.Pointer(bp + 416)))[i] = libtcl9_0.XTcl_NewWideIntObj(tls, libc.Int64FromUint8(*(*uint8)(unsafe.Pointer(pixelPtr + uintptr(i))))) goto _22 _22: ; i++ } libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewListObj(tls, int64(channelCount), bp+416)) return TCL_OK _7: ; /* * photo put command - first parse the options. */ *(*TTcl_Size)(unsafe.Pointer(bp + 8)) = int64(2) libc.Xmemset(tls, bp+16, 0, uint64(96)) (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).Fname = libc.UintptrFromInt32(0) (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).Fformat = libc.UintptrFromInt32(0) (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).Fmetadata = libc.UintptrFromInt32(0) if _ParseSubcommandOptions(tls, bp+16, interp, libc.Int32FromInt32(OPT_TO)|libc.Int32FromInt32(OPT_FORMAT)|libc.Int32FromInt32(OPT_METADATA), bp+8, int64(objc), objv) != TCL_OK { return int32(TCL_ERROR) } if (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).Fname == libc.UintptrFromInt32(0) || *(*TTcl_Size)(unsafe.Pointer(bp + 8)) < int64(objc) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(2), objv, __ccgo_ts+37716) return int32(TCL_ERROR) } /* * See if there's a format that can read the data */ if _MatchStringFormat(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).Fformat, (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).Fmetadata, libc.UintptrFromInt32(0), bp+152, bp+160, bp+176, bp+180, bp+184) != TCL_OK { return int32(TCL_ERROR) } if !((*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).Foptions&libc.Int32FromInt32(OPT_TO) != 0) || (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).FtoX2 < 0 { (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).FtoX2 = (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).FtoX + *(*int32)(unsafe.Pointer(bp + 176)) (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).FtoY2 = (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).FtoY + *(*int32)(unsafe.Pointer(bp + 180)) } if *(*int32)(unsafe.Pointer(bp + 176)) > (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).FtoX2-(*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).FtoX { *(*int32)(unsafe.Pointer(bp + 176)) = (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).FtoX2 - (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).FtoX } if *(*int32)(unsafe.Pointer(bp + 180)) > (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).FtoY2-(*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).FtoY { *(*int32)(unsafe.Pointer(bp + 180)) = (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).FtoY2 - (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).FtoY } format = (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).Fformat data1 = *(*uintptr)(unsafe.Pointer(objv + 2*8)) if *(*int32)(unsafe.Pointer(bp + 184)) != 0 { if format != 0 { format = libtcl9_0.XTcl_GetStringFromObj(tls, format, libc.UintptrFromInt32(0)) } data1 = libtcl9_0.XTcl_GetStringFromObj(tls, data1, libc.UintptrFromInt32(0)) } if *(*uintptr)(unsafe.Pointer(bp + 152)) != libc.UintptrFromInt32(0) { if (*(*func(*libc.TLS, uintptr, uintptr, uintptr, TTk_PhotoHandle, int32, int32, int32, int32, int32, int32) int32)(unsafe.Pointer(&struct{ uintptr }{(*TTk_PhotoImageFormat)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 152)))).FstringReadProc})))(tls, interp, data1, format, modelPtr, (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).FtoX, (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).FtoY, (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).FtoX2-(*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).FtoX, (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).FtoY2-(*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).FtoY, 0, 0) != TCL_OK { return int32(TCL_ERROR) } } else { if (*(*func(*libc.TLS, uintptr, uintptr, uintptr, uintptr, TTk_PhotoHandle, int32, int32, int32, int32, int32, int32, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*TTk_PhotoImageFormatVersion3)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 160)))).FstringReadProc})))(tls, interp, data1, format, (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).Fmetadata, modelPtr, (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).FtoX, (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).FtoY, (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).FtoX2-(*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).FtoX, (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).FtoY2-(*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).FtoY, 0, 0, libc.UintptrFromInt32(0)) != TCL_OK { return int32(TCL_ERROR) } } /* * SB: is the next line really needed? The stringReadProc * writes image data with Tk_PhotoPutBlock(), which in turn * takes care to notify the changed image and to set/unset the * IMAGE_CHANGED bit. */ *(*int32)(unsafe.Pointer(modelPtr + 24)) |= int32(IMAGE_CHANGED) return TCL_OK _8: ; /* * photo read command - first parse the options specified. */ *(*TTcl_Size)(unsafe.Pointer(bp + 8)) = int64(2) libc.Xmemset(tls, bp+16, 0, uint64(96)) (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).Fname = libc.UintptrFromInt32(0) (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).Fformat = libc.UintptrFromInt32(0) (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).Fmetadata = libc.UintptrFromInt32(0) if _ParseSubcommandOptions(tls, bp+16, interp, libc.Int32FromInt32(OPT_FORMAT)|libc.Int32FromInt32(OPT_FROM)|libc.Int32FromInt32(OPT_TO)|libc.Int32FromInt32(OPT_SHRINK)|libc.Int32FromInt32(OPT_METADATA), bp+8, int64(objc), objv) != TCL_OK { return int32(TCL_ERROR) } if (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).Fname == libc.UintptrFromInt32(0) || *(*TTcl_Size)(unsafe.Pointer(bp + 8)) < int64(objc) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(2), objv, __ccgo_ts+37741) return int32(TCL_ERROR) } /* * Prevent file system access in safe interpreters. */ if libtcl9_0.XTcl_IsSafe(tls, interp) != 0 { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+37770, int64(-libc.Int32FromInt32(1)))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+472, __ccgo_ts+179, __ccgo_ts+4089, __ccgo_ts+37820, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) } /* * Open the image file and look for a handler for it. */ chan1 = libtcl9_0.XTcl_OpenFileChannel(tls, interp, libtcl9_0.XTcl_GetStringFromObj(tls, (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).Fname, libc.UintptrFromInt32(0)), __ccgo_ts+9441, 0) if chan1 == libc.UintptrFromInt32(0) { return int32(TCL_ERROR) } if libtcl9_0.XTcl_SetChannelOption(tls, interp, chan1, __ccgo_ts+8196, __ccgo_ts+33442) != TCL_OK { libtcl9_0.XTcl_CloseEx(tls, libc.UintptrFromInt32(0), chan1, 0) return int32(TCL_ERROR) } if _MatchFileFormat(tls, interp, chan1, libtcl9_0.XTcl_GetStringFromObj(tls, (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).Fname, libc.UintptrFromInt32(0)), (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).Fformat, (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).Fmetadata, libc.UintptrFromInt32(0), bp+152, bp+160, bp+176, bp+180, bp+184) != TCL_OK { result = int32(TCL_ERROR) goto readCleanup } /* * Check the values given for the -from option. */ if (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).FfromX > *(*int32)(unsafe.Pointer(bp + 176)) || (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).FfromY > *(*int32)(unsafe.Pointer(bp + 180)) || (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).FfromX2 > *(*int32)(unsafe.Pointer(bp + 176)) || (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).FfromY2 > *(*int32)(unsafe.Pointer(bp + 180)) { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+37440, int64(-int32(1)))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+472, __ccgo_ts+179, __ccgo_ts+29667, __ccgo_ts+37434, __ccgo_ts+37497, libc.UintptrFromInt32(0))) result = int32(TCL_ERROR) goto readCleanup } if !((*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).Foptions&libc.Int32FromInt32(OPT_FROM) != 0) || (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).FfromX2 < 0 { width = *(*int32)(unsafe.Pointer(bp + 176)) - (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).FfromX height = *(*int32)(unsafe.Pointer(bp + 180)) - (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).FfromY } else { width = (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).FfromX2 - (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).FfromX height = (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).FfromY2 - (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).FfromY } /* * If the -shrink option was specified, set the size of the image. */ if (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).Foptions&int32(OPT_SHRINK) != 0 { if _ImgPhotoSetSize(tls, modelPtr, (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).FtoX+width, (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).FtoY+height) != TCL_OK { libtcl9_0.XTcl_ResetResult(tls, interp) libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+37506, int64(-libc.Int32FromInt32(1)))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+472, __ccgo_ts+179, __ccgo_ts+36356, libc.UintptrFromInt32(0))) result = int32(TCL_ERROR) goto readCleanup } } /* * Call the handler's file read function to read the data into the * image. */ format1 = (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).Fformat if *(*int32)(unsafe.Pointer(bp + 184)) != 0 && format1 != 0 { format1 = libtcl9_0.XTcl_GetStringFromObj(tls, format1, libc.UintptrFromInt32(0)) } if *(*uintptr)(unsafe.Pointer(bp + 152)) != libc.UintptrFromInt32(0) { result = (*(*func(*libc.TLS, uintptr, TTcl_Channel, uintptr, uintptr, TTk_PhotoHandle, int32, int32, int32, int32, int32, int32) int32)(unsafe.Pointer(&struct{ uintptr }{(*TTk_PhotoImageFormat)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 152)))).FfileReadProc})))(tls, interp, chan1, libtcl9_0.XTcl_GetStringFromObj(tls, (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).Fname, libc.UintptrFromInt32(0)), format1, modelPtr, (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).FtoX, (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).FtoY, width, height, (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).FfromX, (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).FfromY) } else { result = (*(*func(*libc.TLS, uintptr, TTcl_Channel, uintptr, uintptr, uintptr, TTk_PhotoHandle, int32, int32, int32, int32, int32, int32, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*TTk_PhotoImageFormatVersion3)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 160)))).FfileReadProc})))(tls, interp, chan1, libtcl9_0.XTcl_GetStringFromObj(tls, (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).Fname, libc.UintptrFromInt32(0)), format1, (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).Fmetadata, modelPtr, (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).FtoX, (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).FtoY, width, height, (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).FfromX, (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).FfromY, libc.UintptrFromInt32(0)) } goto readCleanup readCleanup: ; if chan1 != libc.UintptrFromInt32(0) { libtcl9_0.XTcl_CloseEx(tls, libc.UintptrFromInt32(0), chan1, 0) } return result _9: ; if objc != int32(2) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(2), objv, libc.UintptrFromInt32(0)) return int32(TCL_ERROR) } /* * Call Dither if any part of the image is not correctly dithered at * present. */ *(*int32)(unsafe.Pointer(bp)) = (*TPhotoModel)(unsafe.Pointer(modelPtr)).FditherX *(*int32)(unsafe.Pointer(bp + 4)) = (*TPhotoModel)(unsafe.Pointer(modelPtr)).FditherY if (*TPhotoModel)(unsafe.Pointer(modelPtr)).FditherX != 0 { XTk_DitherPhoto(tls, modelPtr, *(*int32)(unsafe.Pointer(bp)), *(*int32)(unsafe.Pointer(bp + 4)), (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fwidth-*(*int32)(unsafe.Pointer(bp)), int32(1)) } if (*TPhotoModel)(unsafe.Pointer(modelPtr)).FditherY < (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fheight { *(*int32)(unsafe.Pointer(bp)) = 0 XTk_DitherPhoto(tls, modelPtr, 0, (*TPhotoModel)(unsafe.Pointer(modelPtr)).FditherY, (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fwidth, (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fheight-(*TPhotoModel)(unsafe.Pointer(modelPtr)).FditherY) } if *(*int32)(unsafe.Pointer(bp + 4)) < (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fheight { /* * Tell the core image code that part of the image has changed. */ XTk_ImageChanged(tls, (*TPhotoModel)(unsafe.Pointer(modelPtr)).FtkModel, *(*int32)(unsafe.Pointer(bp)), *(*int32)(unsafe.Pointer(bp + 4)), (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fwidth-*(*int32)(unsafe.Pointer(bp)), (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fheight-*(*int32)(unsafe.Pointer(bp + 4)), (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fwidth, (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fheight) } return TCL_OK _10: ; if objc < int32(3) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(2), objv, __ccgo_ts+4953) return int32(TCL_ERROR) } if libtcl9_0.XTcl_GetIndexFromObjStruct(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), uintptr(unsafe.Pointer(&_photoTransOptions)), libc.Int64FromUint64(libc.Uint64FromInt64(8)), __ccgo_ts+2689, libc.Int32FromInt32(0)|libc.Int32FromUint64(libc.Uint64FromInt64(8)< int32(6) || objc < int32(5) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(3), objv, __ccgo_ts+37831) return int32(TCL_ERROR) } if libtcl9_0.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 3*8)), bp) != TCL_OK || libtcl9_0.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 4*8)), bp+4) != TCL_OK { return int32(TCL_ERROR) } *(*TTcl_Size)(unsafe.Pointer(bp + 8)) = int64(4) libc.Xmemset(tls, bp+16, 0, uint64(96)) if _ParseSubcommandOptions(tls, bp+16, interp, int32(OPT_ALPHA), bp+8, int64(objc), objv) != TCL_OK { return int32(TCL_ERROR) } if *(*TTcl_Size)(unsafe.Pointer(bp + 8)) < int64(objc) { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+37845, libc.VaList(bp+472, libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(*(*TTcl_Size)(unsafe.Pointer(bp + 8)))*8)), libc.UintptrFromInt32(0))))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+472, __ccgo_ts+179, __ccgo_ts+29667, __ccgo_ts+37434, __ccgo_ts+3323, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) } boolMode = int32(1) if (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).Foptions&int32(OPT_ALPHA) != 0 { boolMode = 0 } if *(*int32)(unsafe.Pointer(bp)) < 0 || *(*int32)(unsafe.Pointer(bp)) >= (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fwidth || *(*int32)(unsafe.Pointer(bp + 4)) < 0 || *(*int32)(unsafe.Pointer(bp + 4)) >= (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fheight { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+37881, libc.VaList(bp+472, libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv)), libc.UintptrFromInt32(0))))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+472, __ccgo_ts+179, __ccgo_ts+29667, __ccgo_ts+37434, __ccgo_ts+37704, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) } /* * Extract and return the desired value */ pixelPtr = (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fpix32 + uintptr((*(*int32)(unsafe.Pointer(bp + 4))*(*TPhotoModel)(unsafe.Pointer(modelPtr)).Fwidth+*(*int32)(unsafe.Pointer(bp)))*int32(4)) if boolMode != 0 { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewWideIntObj(tls, libc.BoolInt64(libc.BoolInt32(libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(pixelPtr + 3))) == 0) != 0))) } else { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewWideIntObj(tls, libc.Int64FromUint8(*(*uint8)(unsafe.Pointer(pixelPtr + 3))))) } return TCL_OK case 1: /* * Parse args and option, check for valid values */ if objc < int32(6) || objc > int32(7) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(3), objv, __ccgo_ts+37927) return int32(TCL_ERROR) } if libtcl9_0.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 3*8)), bp) != TCL_OK || libtcl9_0.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 4*8)), bp+4) != TCL_OK { return int32(TCL_ERROR) } *(*TTcl_Size)(unsafe.Pointer(bp + 8)) = int64(5) libc.Xmemset(tls, bp+16, 0, uint64(96)) if _ParseSubcommandOptions(tls, bp+16, interp, int32(OPT_ALPHA), bp+8, int64(objc), objv) != TCL_OK { return int32(TCL_ERROR) } if *(*TTcl_Size)(unsafe.Pointer(bp + 8)) < int64(objc) { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+37845, libc.VaList(bp+472, libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(*(*TTcl_Size)(unsafe.Pointer(bp + 8)))*8)), libc.UintptrFromInt32(0))))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+472, __ccgo_ts+179, __ccgo_ts+29667, __ccgo_ts+37434, __ccgo_ts+3323, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) } boolMode1 = int32(1) if (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).Foptions&int32(OPT_ALPHA) != 0 { boolMode1 = 0 } if *(*int32)(unsafe.Pointer(bp)) < 0 || *(*int32)(unsafe.Pointer(bp)) >= (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fwidth || *(*int32)(unsafe.Pointer(bp + 4)) < 0 || *(*int32)(unsafe.Pointer(bp + 4)) >= (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fheight { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+37948, libc.VaList(bp+472, libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv)), libc.UintptrFromInt32(0))))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+472, __ccgo_ts+179, __ccgo_ts+29667, __ccgo_ts+37434, __ccgo_ts+37704, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) } if boolMode1 != 0 { if libtcl9_0.XTcl_GetBoolFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 5*8)), (libc.Int32FromInt32(TCL_NULL_OK)-libc.Int32FromInt32(2))&libc.Int32FromInt64(4), bp+448) != TCL_OK { return int32(TCL_ERROR) } } else { if libtcl9_0.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 5*8)), bp+448) != TCL_OK { return int32(TCL_ERROR) } if *(*int32)(unsafe.Pointer(bp + 448)) < 0 || *(*int32)(unsafe.Pointer(bp + 448)) > int32(255) { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+37994, libc.VaList(bp+472, *(*int32)(unsafe.Pointer(bp + 448))))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+472, __ccgo_ts+179, __ccgo_ts+29667, __ccgo_ts+37434, __ccgo_ts+38054, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) } } /* * Set new alpha value for the pixel */ pixelPtr = (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fpix32 + uintptr((*(*int32)(unsafe.Pointer(bp + 4))*(*TPhotoModel)(unsafe.Pointer(modelPtr)).Fwidth+*(*int32)(unsafe.Pointer(bp)))*int32(4)) if boolMode1 != 0 { if *(*int32)(unsafe.Pointer(bp + 448)) != 0 { v23 = 0 } else { v23 = int32(255) } *(*uint8)(unsafe.Pointer(pixelPtr + 3)) = libc.Uint8FromInt32(v23) } else { *(*uint8)(unsafe.Pointer(pixelPtr + 3)) = libc.Uint8FromInt32(*(*int32)(unsafe.Pointer(bp + 448))) } /* * Update the validRegion of the image */ (*(*TXRectangle)(unsafe.Pointer(bp + 456))).Fx = int16(*(*int32)(unsafe.Pointer(bp))) (*(*TXRectangle)(unsafe.Pointer(bp + 456))).Fy = int16(*(*int32)(unsafe.Pointer(bp + 4))) (*(*TXRectangle)(unsafe.Pointer(bp + 456))).Fwidth = uint16(1) (*(*TXRectangle)(unsafe.Pointer(bp + 456))).Fheight = uint16(1) modRegion = libx11.XXCreateRegion(tls) libx11.XXUnionRectWithRegion(tls, bp+456, modRegion, modRegion) if *(*uint8)(unsafe.Pointer(pixelPtr + 3)) != 0 { libx11.XXUnionRectWithRegion(tls, bp+456, (*TPhotoModel)(unsafe.Pointer(modelPtr)).FvalidRegion, (*TPhotoModel)(unsafe.Pointer(modelPtr)).FvalidRegion) } else { libx11.XXSubtractRegion(tls, (*TPhotoModel)(unsafe.Pointer(modelPtr)).FvalidRegion, modRegion, (*TPhotoModel)(unsafe.Pointer(modelPtr)).FvalidRegion) } libx11.XXDestroyRegion(tls, modRegion) /* * Inform the generic image code that the image * has (potentially) changed. */ XTk_ImageChanged(tls, (*TPhotoModel)(unsafe.Pointer(modelPtr)).FtkModel, *(*int32)(unsafe.Pointer(bp)), *(*int32)(unsafe.Pointer(bp + 4)), int32(1), int32(1), (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fwidth, (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fheight) *(*int32)(unsafe.Pointer(modelPtr + 24)) &= ^libc.Int32FromInt32(IMAGE_CHANGED) return TCL_OK } libtcl9_0.XTcl_Panic(tls, __ccgo_ts+38064, 0) goto _12 _11: ; /* * Prevent file system access in safe interpreters. */ if libtcl9_0.XTcl_IsSafe(tls, interp) != 0 { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+38087, int64(-libc.Int32FromInt32(1)))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+472, __ccgo_ts+179, __ccgo_ts+4089, __ccgo_ts+37820, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) } /* * photo write command - first parse and check any options given. */ *(*TTcl_Size)(unsafe.Pointer(bp + 8)) = int64(2) libc.Xmemset(tls, bp+16, 0, uint64(96)) (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).Fname = libc.UintptrFromInt32(0) (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).Fformat = libc.UintptrFromInt32(0) (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).Fmetadata = libc.UintptrFromInt32(0) if _ParseSubcommandOptions(tls, bp+16, interp, libc.Int32FromInt32(OPT_FORMAT)|libc.Int32FromInt32(OPT_FROM)|libc.Int32FromInt32(OPT_GRAYSCALE)|libc.Int32FromInt32(OPT_BACKGROUND)|libc.Int32FromInt32(OPT_METADATA), bp+8, int64(objc), objv) != TCL_OK { return int32(TCL_ERROR) } if (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).Fname == libc.UintptrFromInt32(0) || *(*TTcl_Size)(unsafe.Pointer(bp + 8)) < int64(objc) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(2), objv, __ccgo_ts+37741) if (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).Fbackground != 0 { XTk_FreeColor(tls, (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).Fbackground) } return int32(TCL_ERROR) } if (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).FfromX > (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fwidth || (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).FfromY > (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fheight || (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).FfromX2 > (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fwidth || (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).FfromY2 > (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fheight { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+37546, int64(-libc.Int32FromInt32(1)))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+472, __ccgo_ts+179, __ccgo_ts+29667, __ccgo_ts+37434, __ccgo_ts+37497, libc.UintptrFromInt32(0))) if (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).Fbackground != 0 { XTk_FreeColor(tls, (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).Fbackground) } return int32(TCL_ERROR) } /* * Fill in default values for unspecified parameters. Note that a * missing -format flag results in us having a guess from the file * extension. [Bug 2983824] */ if !((*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).Foptions&libc.Int32FromInt32(OPT_FROM) != 0) || (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).FfromX2 < 0 { (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).FfromX2 = (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fwidth (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).FfromY2 = (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fheight } if (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).Fformat == libc.UintptrFromInt32(0) { fmtString = _GetExtension(tls, libtcl9_0.XTcl_GetStringFromObj(tls, (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).Fname, libc.UintptrFromInt32(0))) usedExt = libc.BoolInt32(fmtString != libc.UintptrFromInt32(0)) } else { fmtString = libtcl9_0.XTcl_GetStringFromObj(tls, (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).Fformat, libc.UintptrFromInt32(0)) usedExt = 0 } /* * Use argument metadata if specified, otherwise the master metadata */ if libc.UintptrFromInt32(0) != (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).Fmetadata { metadataIn1 = (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).Fmetadata } else { metadataIn1 = (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fmetadata } /* * Search for an appropriate image file format handler, and give an * error if none is found. */ matched = 0 goto redoFormatLookup redoFormatLookup: ; *(*uintptr)(unsafe.Pointer(bp + 160)) = libc.UintptrFromInt32(0) *(*uintptr)(unsafe.Pointer(bp + 152)) = (*TThreadSpecificData13)(unsafe.Pointer(tsdPtr)).FformatList for { if !(*(*uintptr)(unsafe.Pointer(bp + 152)) != libc.UintptrFromInt32(0)) { break } if fmtString == libc.UintptrFromInt32(0) || libc.Xstrncasecmp(tls, fmtString, (*TTk_PhotoImageFormat)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 152)))).Fname, libc.Xstrlen(tls, (*TTk_PhotoImageFormat)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 152)))).Fname)) == 0 { matched = int32(1) if (*TTk_PhotoImageFormat)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 152)))).FfileWriteProc != libc.UintptrFromInt32(0) { break } } goto _24 _24: ; *(*uintptr)(unsafe.Pointer(bp + 152)) = (*TTk_PhotoImageFormat)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 152)))).FnextPtr } if *(*uintptr)(unsafe.Pointer(bp + 152)) == libc.UintptrFromInt32(0) { *(*int32)(unsafe.Pointer(bp + 184)) = 0 *(*uintptr)(unsafe.Pointer(bp + 160)) = (*TThreadSpecificData13)(unsafe.Pointer(tsdPtr)).FformatListVersion3 for { if !(*(*uintptr)(unsafe.Pointer(bp + 160)) != libc.UintptrFromInt32(0)) { break } if fmtString == libc.UintptrFromInt32(0) || libc.Xstrncasecmp(tls, fmtString, (*TTk_PhotoImageFormatVersion3)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 160)))).Fname, libc.Xstrlen(tls, (*TTk_PhotoImageFormatVersion3)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 160)))).Fname)) == 0 { matched = int32(1) if (*TTk_PhotoImageFormatVersion3)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 160)))).FfileWriteProc != libc.UintptrFromInt32(0) { break } } goto _25 _25: ; *(*uintptr)(unsafe.Pointer(bp + 160)) = (*TTk_PhotoImageFormatVersion3)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 160)))).FnextPtr } } if usedExt != 0 && !(matched != 0) { /* * If we didn't find one and we're using file extensions as the * basis for the guessing, go back and look again without * prejudice. Supports old broken code. */ usedExt = 0 fmtString = libc.UintptrFromInt32(0) goto redoFormatLookup } if *(*uintptr)(unsafe.Pointer(bp + 152)) == libc.UintptrFromInt32(0) && *(*uintptr)(unsafe.Pointer(bp + 160)) == libc.UintptrFromInt32(0) { if fmtString == libc.UintptrFromInt32(0) { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+38137, int64(-libc.Int32FromInt32(1)))) } else { if !(matched != 0) { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+38196, libc.VaList(bp+472, fmtString))) } else { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+38230, libc.VaList(bp+472, fmtString))) } } libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+472, __ccgo_ts+179, __ccgo_ts+3058, __ccgo_ts+37641, fmtString, libc.UintptrFromInt32(0))) if (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).Fbackground != 0 { XTk_FreeColor(tls, (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).Fbackground) } return int32(TCL_ERROR) } /* * Call the handler's file write function to write out the image. */ data2 = _ImgGetPhoto(tls, modelPtr, bp+112, bp+16) format2 = (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).Fformat if *(*int32)(unsafe.Pointer(bp + 184)) != 0 && format2 != 0 { format2 = libtcl9_0.XTcl_GetStringFromObj(tls, (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).Fformat, libc.UintptrFromInt32(0)) } if *(*uintptr)(unsafe.Pointer(bp + 152)) != libc.UintptrFromInt32(0) { result = (*(*func(*libc.TLS, uintptr, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*TTk_PhotoImageFormat)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 152)))).FfileWriteProc})))(tls, interp, libtcl9_0.XTcl_GetStringFromObj(tls, (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).Fname, libc.UintptrFromInt32(0)), format2, bp+112) } else { result = (*(*func(*libc.TLS, uintptr, uintptr, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*TTk_PhotoImageFormatVersion3)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 160)))).FfileWriteProc})))(tls, interp, libtcl9_0.XTcl_GetStringFromObj(tls, (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).Fname, libc.UintptrFromInt32(0)), format2, metadataIn1, bp+112) } if (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).Fbackground != 0 { XTk_FreeColor(tls, (*(*TSubcommandOptions)(unsafe.Pointer(bp + 16))).Fbackground) } if data2 != 0 { libtcl9_0.XTcl_Free(tls, data2) } return result _12: ; libtcl9_0.XTcl_Panic(tls, __ccgo_ts+38064, 0) return int32(TCL_ERROR) /* NOT REACHED */ } var _photoOptions = [12]uintptr{ 0: __ccgo_ts + 37172, 1: __ccgo_ts + 4735, 2: __ccgo_ts + 4740, 3: __ccgo_ts + 37178, 4: __ccgo_ts + 37183, 5: __ccgo_ts + 4949, 6: __ccgo_ts + 37188, 7: __ccgo_ts + 37192, 8: __ccgo_ts + 37197, 9: __ccgo_ts + 37206, 10: __ccgo_ts + 37219, 11: libc.UintptrFromInt32(0), } var _photoTransOptions = [3]uintptr{ 0: __ccgo_ts + 4949, 1: __ccgo_ts + 11726, 2: libc.UintptrFromInt32(0), } /* *---------------------------------------------------------------------- * * GetExtension -- * * Return the extension part of a path, or NULL if there is no extension. * The returned string will be a substring of the argument string, so * should not be ckfree()d directly. No side effects. * *---------------------------------------------------------------------- */ func _GetExtension(tls *libc.TLS, path uintptr) (r uintptr) { var c, v2 uint8 var extension, v3 uintptr _, _, _, _ = c, extension, v2, v3 extension = libc.UintptrFromInt32(0) for { v3 = path path++ v2 = *(*uint8)(unsafe.Pointer(v3)) c = v2 if !(libc.Int32FromUint8(v2) != int32('\000')) { break } if libc.Int32FromUint8(c) == int32('.') { extension = path } goto _1 _1: } if extension != libc.UintptrFromInt32(0) && libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(extension))) == int32('\000') { extension = libc.UintptrFromInt32(0) } return extension } /* *---------------------------------------------------------------------- * * ParseSubcommandOptions -- * * This function is invoked to process one of the options which may be * specified for the photo image subcommands, namely, -from, -to, -zoom, * -subsample, -format, -shrink, -compositingrule, -alpha, -boolean, * -withalpha and -metadata. * Parsing starts at the index in *optIndexPtr and stops at the end of * objv[] or at the first value that does not belong to an option. * * Results: * A standard Tcl result. * * Side effects: * Fields in *optPtr get filled in. The value of optIndexPtr is updated * to contain the index of the first element in argv[] that was not * parsed, or argc if the end of objv[] was reached. * *---------------------------------------------------------------------- */ func _ParseSubcommandOptions(tls *libc.TLS, optPtr uintptr, interp uintptr, allowedOptions int32, optIndexPtr uintptr, objc TTcl_Size, objv uintptr) (r int32) { bp := tls.Alloc(80) defer tls.Free(80) /* Arguments to be parsed. */ var argIndex, index, v17, v4, v5, v6 TTcl_Size var bit, c, currentBit, maxValues, numValues, v10, v11, v12, v13, v14, v15, v16, v7, v9 int32 var expandedOption, listPtr, msgObj, needed, option, val, v18, v2 uintptr var _ /* length at bp+0 */ TTcl_Size var _ /* values at bp+8 */ [4]int32 _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = argIndex, bit, c, currentBit, expandedOption, index, listPtr, maxValues, msgObj, needed, numValues, option, val, v10, v11, v12, v13, v14, v15, v16, v17, v18, v2, v4, v5, v6, v7, v9 index = *(*TTcl_Size)(unsafe.Pointer(optIndexPtr)) for { if !(index < objc) { break } /* * We can have one value specified without an option; it goes into * optPtr->name. */ v2 = libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(index)*8)), bp) option = v2 expandedOption = v2 if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(option))) != int32('-') { if (*TSubcommandOptions)(unsafe.Pointer(optPtr)).Fname == libc.UintptrFromInt32(0) { (*TSubcommandOptions)(unsafe.Pointer(optPtr)).Fname = *(*uintptr)(unsafe.Pointer(objv + uintptr(index)*8)) goto _1 } break } /* * Work out which option this is. */ c = libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(option))) bit = 0 currentBit = int32(1) listPtr = uintptr(unsafe.Pointer(&_optionNames)) for { if !(*(*uintptr)(unsafe.Pointer(listPtr)) != libc.UintptrFromInt32(0)) { break } if c == libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(listPtr))))) && libc.Xstrncmp(tls, option, *(*uintptr)(unsafe.Pointer(listPtr)), libc.Uint64FromInt64(*(*TTcl_Size)(unsafe.Pointer(bp)))) == 0 { expandedOption = *(*uintptr)(unsafe.Pointer(listPtr)) if bit != 0 { goto unknownOrAmbiguousOption } bit = currentBit } currentBit <<= int32(1) goto _3 _3: ; listPtr += 8 } /* * If this option is not recognized and allowed, put an error message * in the interpreter and return. */ if !(allowedOptions&bit != 0) { if (*TSubcommandOptions)(unsafe.Pointer(optPtr)).Fname != libc.UintptrFromInt32(0) { goto unknownOrAmbiguousOption } (*TSubcommandOptions)(unsafe.Pointer(optPtr)).Fname = *(*uintptr)(unsafe.Pointer(objv + uintptr(index)*8)) goto _1 } /* * For the -from, -to, -zoom and -subsample options, parse the values * given. Report an error if too few or too many values are given. */ if bit == int32(OPT_BACKGROUND) { /* * The -background option takes a single XColor value. */ if index+int64(1) >= objc { goto oneValueRequired } index++ v4 = index *(*TTcl_Size)(unsafe.Pointer(optIndexPtr)) = v4 (*TSubcommandOptions)(unsafe.Pointer(optPtr)).Fbackground = XTk_AllocColorFromObj(tls, interp, XTk_MainWindow(tls, interp), *(*uintptr)(unsafe.Pointer(objv + uintptr(index)*8))) if !((*TSubcommandOptions)(unsafe.Pointer(optPtr)).Fbackground != 0) { return int32(TCL_ERROR) } } else { if bit == int32(OPT_FORMAT) { /* * The -format option takes a single string value. Note that * parsing this is outside the scope of this function. */ if index+int64(1) >= objc { goto oneValueRequired } index++ v5 = index *(*TTcl_Size)(unsafe.Pointer(optIndexPtr)) = v5 (*TSubcommandOptions)(unsafe.Pointer(optPtr)).Fformat = *(*uintptr)(unsafe.Pointer(objv + uintptr(index)*8)) } else { if bit == int32(OPT_METADATA) { /* * The -metadata option takes a single dict value. Note that * parsing this is outside the scope of this function. */ if index+int64(1) >= objc { goto oneValueRequired } index++ v6 = index *(*TTcl_Size)(unsafe.Pointer(optIndexPtr)) = v6 (*TSubcommandOptions)(unsafe.Pointer(optPtr)).Fmetadata = *(*uintptr)(unsafe.Pointer(objv + uintptr(index)*8)) } else { if bit == int32(OPT_COMPOSITE) { /* * The -compositingrule option takes a single value from a * well-known set. */ if index+int64(1) >= objc { goto oneValueRequired } index++ if libtcl9_0.XTcl_GetIndexFromObjStruct(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(index)*8)), uintptr(unsafe.Pointer(&_compositingRules)), libc.Int64FromUint64(libc.Uint64FromInt64(8)), __ccgo_ts+38292, libc.Int32FromInt32(0)|libc.Int32FromUint64(libc.Uint64FromInt64(4)<= objc { break } val = libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(argIndex)*8)), libc.UintptrFromInt32(0)) if argIndex < objc && (libc.BoolInt32(uint32(*(*uint8)(unsafe.Pointer(val)))-uint32('0') < uint32(10)) != 0 || libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(val))) == int32('-') && libc.BoolInt32(uint32(*(*uint8)(unsafe.Pointer(val + 1)))-uint32('0') < uint32(10)) != 0) { if libtcl9_0.XTcl_GetInt(tls, interp, val, bp+8+uintptr(numValues)*4) != TCL_OK { return int32(TCL_ERROR) } } else { break } argIndex++ goto _8 _8: ; numValues++ } if numValues == 0 { goto manyValuesRequired } index += int64(numValues) *(*TTcl_Size)(unsafe.Pointer(optIndexPtr)) = index /* * Y values default to the corresponding X value if not specified. */ if numValues == int32(1) { (*(*[4]int32)(unsafe.Pointer(bp + 8)))[int32(1)] = (*(*[4]int32)(unsafe.Pointer(bp + 8)))[0] } if numValues == int32(3) { (*(*[4]int32)(unsafe.Pointer(bp + 8)))[int32(3)] = (*(*[4]int32)(unsafe.Pointer(bp + 8)))[int32(2)] } /* * Check the values given and put them in the appropriate field of * the SubcommandOptions structure. */ switch bit { case int32(OPT_FROM): if (*(*[4]int32)(unsafe.Pointer(bp + 8)))[0] < 0 || (*(*[4]int32)(unsafe.Pointer(bp + 8)))[int32(1)] < 0 || numValues > int32(2) && ((*(*[4]int32)(unsafe.Pointer(bp + 8)))[int32(2)] < 0 || (*(*[4]int32)(unsafe.Pointer(bp + 8)))[int32(3)] < 0) { needed = __ccgo_ts + 38309 goto numberOutOfRange } if numValues <= int32(2) { (*TSubcommandOptions)(unsafe.Pointer(optPtr)).FfromX = (*(*[4]int32)(unsafe.Pointer(bp + 8)))[0] (*TSubcommandOptions)(unsafe.Pointer(optPtr)).FfromY = (*(*[4]int32)(unsafe.Pointer(bp + 8)))[int32(1)] (*TSubcommandOptions)(unsafe.Pointer(optPtr)).FfromX2 = -int32(1) (*TSubcommandOptions)(unsafe.Pointer(optPtr)).FfromY2 = -int32(1) } else { if (*(*[4]int32)(unsafe.Pointer(bp + 8)))[0] < (*(*[4]int32)(unsafe.Pointer(bp + 8)))[int32(2)] { v9 = (*(*[4]int32)(unsafe.Pointer(bp + 8)))[0] } else { v9 = (*(*[4]int32)(unsafe.Pointer(bp + 8)))[int32(2)] } (*TSubcommandOptions)(unsafe.Pointer(optPtr)).FfromX = v9 if (*(*[4]int32)(unsafe.Pointer(bp + 8)))[int32(1)] < (*(*[4]int32)(unsafe.Pointer(bp + 8)))[int32(3)] { v10 = (*(*[4]int32)(unsafe.Pointer(bp + 8)))[int32(1)] } else { v10 = (*(*[4]int32)(unsafe.Pointer(bp + 8)))[int32(3)] } (*TSubcommandOptions)(unsafe.Pointer(optPtr)).FfromY = v10 if (*(*[4]int32)(unsafe.Pointer(bp + 8)))[0] > (*(*[4]int32)(unsafe.Pointer(bp + 8)))[int32(2)] { v11 = (*(*[4]int32)(unsafe.Pointer(bp + 8)))[0] } else { v11 = (*(*[4]int32)(unsafe.Pointer(bp + 8)))[int32(2)] } (*TSubcommandOptions)(unsafe.Pointer(optPtr)).FfromX2 = v11 if (*(*[4]int32)(unsafe.Pointer(bp + 8)))[int32(1)] > (*(*[4]int32)(unsafe.Pointer(bp + 8)))[int32(3)] { v12 = (*(*[4]int32)(unsafe.Pointer(bp + 8)))[int32(1)] } else { v12 = (*(*[4]int32)(unsafe.Pointer(bp + 8)))[int32(3)] } (*TSubcommandOptions)(unsafe.Pointer(optPtr)).FfromY2 = v12 } case int32(OPT_SUBSAMPLE): (*TSubcommandOptions)(unsafe.Pointer(optPtr)).FsubsampleX = (*(*[4]int32)(unsafe.Pointer(bp + 8)))[0] (*TSubcommandOptions)(unsafe.Pointer(optPtr)).FsubsampleY = (*(*[4]int32)(unsafe.Pointer(bp + 8)))[int32(1)] case int32(OPT_TO): if (*(*[4]int32)(unsafe.Pointer(bp + 8)))[0] < 0 || (*(*[4]int32)(unsafe.Pointer(bp + 8)))[int32(1)] < 0 || numValues > int32(2) && ((*(*[4]int32)(unsafe.Pointer(bp + 8)))[int32(2)] < 0 || (*(*[4]int32)(unsafe.Pointer(bp + 8)))[int32(3)] < 0) { needed = __ccgo_ts + 38309 goto numberOutOfRange } if numValues <= int32(2) { (*TSubcommandOptions)(unsafe.Pointer(optPtr)).FtoX = (*(*[4]int32)(unsafe.Pointer(bp + 8)))[0] (*TSubcommandOptions)(unsafe.Pointer(optPtr)).FtoY = (*(*[4]int32)(unsafe.Pointer(bp + 8)))[int32(1)] (*TSubcommandOptions)(unsafe.Pointer(optPtr)).FtoX2 = -int32(1) (*TSubcommandOptions)(unsafe.Pointer(optPtr)).FtoY2 = -int32(1) } else { if (*(*[4]int32)(unsafe.Pointer(bp + 8)))[0] < (*(*[4]int32)(unsafe.Pointer(bp + 8)))[int32(2)] { v13 = (*(*[4]int32)(unsafe.Pointer(bp + 8)))[0] } else { v13 = (*(*[4]int32)(unsafe.Pointer(bp + 8)))[int32(2)] } (*TSubcommandOptions)(unsafe.Pointer(optPtr)).FtoX = v13 if (*(*[4]int32)(unsafe.Pointer(bp + 8)))[int32(1)] < (*(*[4]int32)(unsafe.Pointer(bp + 8)))[int32(3)] { v14 = (*(*[4]int32)(unsafe.Pointer(bp + 8)))[int32(1)] } else { v14 = (*(*[4]int32)(unsafe.Pointer(bp + 8)))[int32(3)] } (*TSubcommandOptions)(unsafe.Pointer(optPtr)).FtoY = v14 if (*(*[4]int32)(unsafe.Pointer(bp + 8)))[0] > (*(*[4]int32)(unsafe.Pointer(bp + 8)))[int32(2)] { v15 = (*(*[4]int32)(unsafe.Pointer(bp + 8)))[0] } else { v15 = (*(*[4]int32)(unsafe.Pointer(bp + 8)))[int32(2)] } (*TSubcommandOptions)(unsafe.Pointer(optPtr)).FtoX2 = v15 if (*(*[4]int32)(unsafe.Pointer(bp + 8)))[int32(1)] > (*(*[4]int32)(unsafe.Pointer(bp + 8)))[int32(3)] { v16 = (*(*[4]int32)(unsafe.Pointer(bp + 8)))[int32(1)] } else { v16 = (*(*[4]int32)(unsafe.Pointer(bp + 8)))[int32(3)] } (*TSubcommandOptions)(unsafe.Pointer(optPtr)).FtoY2 = v16 } case int32(OPT_ZOOM): if (*(*[4]int32)(unsafe.Pointer(bp + 8)))[0] <= 0 || (*(*[4]int32)(unsafe.Pointer(bp + 8)))[int32(1)] <= 0 { needed = __ccgo_ts + 38322 goto numberOutOfRange } (*TSubcommandOptions)(unsafe.Pointer(optPtr)).FzoomX = (*(*[4]int32)(unsafe.Pointer(bp + 8)))[0] (*TSubcommandOptions)(unsafe.Pointer(optPtr)).FzoomY = (*(*[4]int32)(unsafe.Pointer(bp + 8)))[int32(1)] break } } } } } } /* * Remember that we saw this option. */ *(*int32)(unsafe.Pointer(optPtr)) |= bit goto _1 _1: ; index++ v17 = index *(*TTcl_Size)(unsafe.Pointer(optIndexPtr)) = v17 } return TCL_OK /* * Exception generation. */ goto oneValueRequired oneValueRequired: ; libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+38331, libc.VaList(bp+32, expandedOption))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+32, __ccgo_ts+179, __ccgo_ts+29667, __ccgo_ts+37434, __ccgo_ts+3203, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) goto manyValuesRequired manyValuesRequired: ; if maxValues == int32(2) { v18 = __ccgo_ts + 38364 } else { v18 = __ccgo_ts + 38371 } libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+38379, libc.VaList(bp+32, expandedOption, v18))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+32, __ccgo_ts+179, __ccgo_ts+29667, __ccgo_ts+37434, __ccgo_ts+3203, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) goto numberOutOfRange numberOutOfRange: ; libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+38426, libc.VaList(bp+32, expandedOption, needed))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+32, __ccgo_ts+179, __ccgo_ts+29667, __ccgo_ts+37434, __ccgo_ts+38054, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) goto unknownOrAmbiguousOption unknownOrAmbiguousOption: ; msgObj = libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+38464, libc.VaList(bp+32, option)) bit = int32(1) listPtr = uintptr(unsafe.Pointer(&_optionNames)) for { if !(*(*uintptr)(unsafe.Pointer(listPtr)) != libc.UintptrFromInt32(0)) { break } if allowedOptions&bit != 0 { if allowedOptions&(bit-int32(1)) != 0 { if allowedOptions & ^(bit<interp's result. * * Side effects: * Existing instances of the image will be redisplayed to match the new * configuration options. * *---------------------------------------------------------------------- */ func _ImgPhotoConfigureModel(tls *libc.TLS, interp uintptr, modelPtr uintptr, objc TTcl_Size, objv uintptr, flags int32) (r int32) { bp := tls.Alloc(160) defer tls.Free(160) /* Flags to pass to Tk_ConfigureWidget, such * as TK_CONFIG_ARGV_ONLY. */ var _objPtr, _objPtr1, _objPtr10, _objPtr2, _objPtr3, _objPtr4, _objPtr5, _objPtr6, _objPtr7, _objPtr8, _objPtr9, arg, data, format, instancePtr, metadataInObj, metadataOutObj, oldData, oldFileObj, oldFormat, oldPaletteString, tempdata, tempformat, v10, v12, v13, v14, v15, v17, v21, v23, v25, v27, v29, v31, v6, v8 uintptr var chan1 TTcl_Channel var i, v11, v16, v2, v20, v22, v24, v26, v28, v3, v30, v4, v5, v7, v9 TTcl_Size var oldGamma float64 var result int32 var _ /* bytesize at bp+40 */ TTcl_Size var _ /* dictSize at bp+48 */ TTcl_Size var _ /* dictSize at bp+56 */ TTcl_Size var _ /* done at bp+104 */ int32 var _ /* imageFormat at bp+24 */ uintptr var _ /* imageFormatVersion3 at bp+32 */ uintptr var _ /* imageHeight at bp+12 */ int32 var _ /* imageWidth at bp+8 */ int32 var _ /* key at bp+88 */ uintptr var _ /* length at bp+0 */ TTcl_Size var _ /* oldformat at bp+16 */ int32 var _ /* search at bp+64 */ TTcl_DictSearch var _ /* value at bp+96 */ uintptr _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = _objPtr, _objPtr1, _objPtr10, _objPtr2, _objPtr3, _objPtr4, _objPtr5, _objPtr6, _objPtr7, _objPtr8, _objPtr9, arg, chan1, data, format, i, instancePtr, metadataInObj, metadataOutObj, oldData, oldFileObj, oldFormat, oldGamma, oldPaletteString, result, tempdata, tempformat, v10, v11, v12, v13, v14, v15, v16, v17, v2, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v3, v30, v31, v4, v5, v6, v7, v8, v9 data = libc.UintptrFromInt32(0) format = libc.UintptrFromInt32(0) metadataInObj = libc.UintptrFromInt32(0) metadataOutObj = libc.UintptrFromInt32(0) i = 0 for { if !(i < objc) { break } arg = libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(i)*8)), bp) if *(*TTcl_Size)(unsafe.Pointer(bp)) > int64(1) && libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(arg))) == int32('-') { if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(arg + 1))) == int32('d') && !(libc.Xstrncmp(tls, arg, __ccgo_ts+2842, libc.Uint64FromInt64(*(*TTcl_Size)(unsafe.Pointer(bp)))) != 0) { i++ v2 = i if v2 < objc { data = *(*uintptr)(unsafe.Pointer(objv + uintptr(i)*8)) } else { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+38508, int64(-libc.Int32FromInt32(1)))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+120, __ccgo_ts+179, __ccgo_ts+29667, __ccgo_ts+37434, __ccgo_ts+3203, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) } } else { if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(arg + 1))) == int32('f') && !(libc.Xstrncmp(tls, arg, __ccgo_ts+4981, libc.Uint64FromInt64(*(*TTcl_Size)(unsafe.Pointer(bp)))) != 0) { i++ v3 = i if v3 < objc { format = *(*uintptr)(unsafe.Pointer(objv + uintptr(i)*8)) } else { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+38534, int64(-libc.Int32FromInt32(1)))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+120, __ccgo_ts+179, __ccgo_ts+29667, __ccgo_ts+37434, __ccgo_ts+3203, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) } } else { if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(arg + 1))) == int32('m') && !(libc.Xstrncmp(tls, arg, __ccgo_ts+37110, libc.Uint64FromInt64(*(*TTcl_Size)(unsafe.Pointer(bp)))) != 0) { i++ v4 = i if v4 < objc { metadataInObj = *(*uintptr)(unsafe.Pointer(objv + uintptr(i)*8)) } else { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+38562, int64(-libc.Int32FromInt32(1)))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+120, __ccgo_ts+179, __ccgo_ts+29667, __ccgo_ts+37434, __ccgo_ts+3203, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) } } } } } goto _1 _1: ; i++ } /* * Save the current values for fileString and dataString, so we can tell * if the user specifies them anew. IMPORTANT: if the format changes we * have to interpret "-file" and "-data" again as well! It might be that * the format string influences how "-data" or "-file" is interpreted. */ oldFileObj = (*TPhotoModel)(unsafe.Pointer(modelPtr)).FfileObj if oldFileObj == libc.UintptrFromInt32(0) { oldData = (*TPhotoModel)(unsafe.Pointer(modelPtr)).FdataObj if oldData != libc.UintptrFromInt32(0) { (*TTcl_Obj)(unsafe.Pointer(oldData)).FrefCount++ } } else { oldData = libc.UintptrFromInt32(0) } oldFormat = (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fformat if oldFormat != libc.UintptrFromInt32(0) { (*TTcl_Obj)(unsafe.Pointer(oldFormat)).FrefCount++ } oldPaletteString = (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fpalette oldGamma = (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fgamma /* * Process the configuration options specified. */ if XTk_ConfigureWidget(tls, interp, XTk_MainWindow(tls, interp), uintptr(unsafe.Pointer(&_configSpecs12)), objc, objv, modelPtr, flags) != TCL_OK { goto errorExit } /* * Regard the empty string for -file, -data, -format or -metadata as the null value. */ if (*TPhotoModel)(unsafe.Pointer(modelPtr)).FfileObj != libc.UintptrFromInt32(0) && libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(libtcl9_0.XTcl_GetStringFromObj(tls, (*TPhotoModel)(unsafe.Pointer(modelPtr)).FfileObj, libc.UintptrFromInt32(0))))) == 0 { _objPtr = (*TPhotoModel)(unsafe.Pointer(modelPtr)).FfileObj v6 = _objPtr v5 = *(*TTcl_Size)(unsafe.Pointer(v6)) *(*TTcl_Size)(unsafe.Pointer(v6))-- if v5 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr) } (*TPhotoModel)(unsafe.Pointer(modelPtr)).FfileObj = libc.UintptrFromInt32(0) } if data != 0 { libtcl9_0.XTcl_GetBytesFromObj(tls, libc.UintptrFromInt32(0), data, bp+40) if *(*TTcl_Size)(unsafe.Pointer(bp + 40)) != 0 { (*TTcl_Obj)(unsafe.Pointer(data)).FrefCount++ } else { data = libc.UintptrFromInt32(0) } if (*TPhotoModel)(unsafe.Pointer(modelPtr)).FdataObj != 0 { _objPtr1 = (*TPhotoModel)(unsafe.Pointer(modelPtr)).FdataObj v8 = _objPtr1 v7 = *(*TTcl_Size)(unsafe.Pointer(v8)) *(*TTcl_Size)(unsafe.Pointer(v8))-- if v7 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr1) } } (*TPhotoModel)(unsafe.Pointer(modelPtr)).FdataObj = data } if format != 0 { /* * Stringify to ignore -format "". It may come in as a list or other * object. */ libtcl9_0.XTcl_GetStringFromObj(tls, format, libc.UintptrFromInt32(0)) if (*TTcl_Obj)(unsafe.Pointer(format)).Flength != 0 { (*TTcl_Obj)(unsafe.Pointer(format)).FrefCount++ } else { format = libc.UintptrFromInt32(0) } if (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fformat != 0 { _objPtr2 = (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fformat v10 = _objPtr2 v9 = *(*TTcl_Size)(unsafe.Pointer(v10)) *(*TTcl_Size)(unsafe.Pointer(v10))-- if v9 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr2) } } (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fformat = format } if metadataInObj != 0 { if TCL_OK != libtcl9_0.XTcl_DictObjSize(tls, interp, metadataInObj, bp+48) { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+38592, int64(-libc.Int32FromInt32(1)))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+120, __ccgo_ts+179, __ccgo_ts+29667, __ccgo_ts+37434, __ccgo_ts+38625, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) } if *(*TTcl_Size)(unsafe.Pointer(bp + 48)) > 0 { (*TTcl_Obj)(unsafe.Pointer(metadataInObj)).FrefCount++ } else { metadataInObj = libc.UintptrFromInt32(0) } if (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fmetadata != 0 { _objPtr3 = (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fmetadata v12 = _objPtr3 v11 = *(*TTcl_Size)(unsafe.Pointer(v12)) *(*TTcl_Size)(unsafe.Pointer(v12))-- if v11 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr3) } } (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fmetadata = metadataInObj } /* * Set the image to the user-requested size, if any, and make sure storage * is correctly allocated for this image. */ if _ImgPhotoSetSize(tls, modelPtr, (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fwidth, (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fheight) != TCL_OK { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+37506, int64(-libc.Int32FromInt32(1)))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+120, __ccgo_ts+179, __ccgo_ts+36356, libc.UintptrFromInt32(0))) goto errorExit } /* * Read in the image from the file or string if the user has specified the * -file or -data option. */ if (*TPhotoModel)(unsafe.Pointer(modelPtr)).FfileObj != libc.UintptrFromInt32(0) && ((*TPhotoModel)(unsafe.Pointer(modelPtr)).FfileObj != oldFileObj || (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fformat != oldFormat) { /* * Prevent file system access in a safe interpreter. */ if libtcl9_0.XTcl_IsSafe(tls, interp) != 0 { libtcl9_0.XTcl_ResetResult(tls, interp) libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+37770, int64(-int32(1)))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+120, __ccgo_ts+179, __ccgo_ts+4089, __ccgo_ts+37820, libc.UintptrFromInt32(0))) goto errorExit } chan1 = libtcl9_0.XTcl_OpenFileChannel(tls, interp, libtcl9_0.XTcl_GetStringFromObj(tls, (*TPhotoModel)(unsafe.Pointer(modelPtr)).FfileObj, libc.UintptrFromInt32(0)), __ccgo_ts+38643, 0) if chan1 == libc.UintptrFromInt32(0) { goto errorExit } /* * Flag that we want the metadata result dict */ metadataOutObj = libtcl9_0.XTcl_NewDictObj(tls) (*TTcl_Obj)(unsafe.Pointer(metadataOutObj)).FrefCount++ if (*TPhotoModel)(unsafe.Pointer(modelPtr)).FfileObj != 0 { v13 = libtcl9_0.XTcl_GetStringFromObj(tls, (*TPhotoModel)(unsafe.Pointer(modelPtr)).FfileObj, libc.UintptrFromInt32(0)) } else { v13 = libc.UintptrFromInt32(0) } if _MatchFileFormat(tls, interp, chan1, v13, (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fformat, (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fmetadata, metadataOutObj, bp+24, bp+32, bp+8, bp+12, bp+16) != TCL_OK { libtcl9_0.XTcl_CloseEx(tls, libc.UintptrFromInt32(0), chan1, 0) goto errorExit } result = _ImgPhotoSetSize(tls, modelPtr, *(*int32)(unsafe.Pointer(bp + 8)), *(*int32)(unsafe.Pointer(bp + 12))) if result != TCL_OK { libtcl9_0.XTcl_CloseEx(tls, libc.UintptrFromInt32(0), chan1, 0) libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+37506, int64(-libc.Int32FromInt32(1)))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+120, __ccgo_ts+179, __ccgo_ts+36356, libc.UintptrFromInt32(0))) goto errorExit } tempformat = (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fformat if *(*int32)(unsafe.Pointer(bp + 16)) != 0 && tempformat != 0 { tempformat = libtcl9_0.XTcl_GetStringFromObj(tls, tempformat, libc.UintptrFromInt32(0)) } if *(*uintptr)(unsafe.Pointer(bp + 24)) != libc.UintptrFromInt32(0) { if (*TPhotoModel)(unsafe.Pointer(modelPtr)).FfileObj != 0 { v14 = libtcl9_0.XTcl_GetStringFromObj(tls, (*TPhotoModel)(unsafe.Pointer(modelPtr)).FfileObj, libc.UintptrFromInt32(0)) } else { v14 = libc.UintptrFromInt32(0) } result = (*(*func(*libc.TLS, uintptr, TTcl_Channel, uintptr, uintptr, TTk_PhotoHandle, int32, int32, int32, int32, int32, int32) int32)(unsafe.Pointer(&struct{ uintptr }{(*TTk_PhotoImageFormat)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 24)))).FfileReadProc})))(tls, interp, chan1, v14, tempformat, modelPtr, 0, 0, *(*int32)(unsafe.Pointer(bp + 8)), *(*int32)(unsafe.Pointer(bp + 12)), 0, 0) } else { if (*TPhotoModel)(unsafe.Pointer(modelPtr)).FfileObj != 0 { v15 = libtcl9_0.XTcl_GetStringFromObj(tls, (*TPhotoModel)(unsafe.Pointer(modelPtr)).FfileObj, libc.UintptrFromInt32(0)) } else { v15 = libc.UintptrFromInt32(0) } result = (*(*func(*libc.TLS, uintptr, TTcl_Channel, uintptr, uintptr, uintptr, TTk_PhotoHandle, int32, int32, int32, int32, int32, int32, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*TTk_PhotoImageFormatVersion3)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 32)))).FfileReadProc})))(tls, interp, chan1, v15, tempformat, (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fmetadata, modelPtr, 0, 0, *(*int32)(unsafe.Pointer(bp + 8)), *(*int32)(unsafe.Pointer(bp + 12)), 0, 0, metadataOutObj) } libtcl9_0.XTcl_CloseEx(tls, libc.UintptrFromInt32(0), chan1, 0) if result != TCL_OK { goto errorExit } libtcl9_0.XTcl_ResetResult(tls, interp) *(*int32)(unsafe.Pointer(modelPtr + 24)) |= int32(IMAGE_CHANGED) } if (*TPhotoModel)(unsafe.Pointer(modelPtr)).FfileObj == libc.UintptrFromInt32(0) && (*TPhotoModel)(unsafe.Pointer(modelPtr)).FdataObj != libc.UintptrFromInt32(0) && ((*TPhotoModel)(unsafe.Pointer(modelPtr)).FdataObj != oldData || (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fformat != oldFormat) { /* * Flag that we want the metadata result dict */ metadataOutObj = libtcl9_0.XTcl_NewDictObj(tls) (*TTcl_Obj)(unsafe.Pointer(metadataOutObj)).FrefCount++ if _MatchStringFormat(tls, interp, (*TPhotoModel)(unsafe.Pointer(modelPtr)).FdataObj, (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fformat, (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fmetadata, metadataOutObj, bp+24, bp+32, bp+8, bp+12, bp+16) != TCL_OK { goto errorExit } if _ImgPhotoSetSize(tls, modelPtr, *(*int32)(unsafe.Pointer(bp + 8)), *(*int32)(unsafe.Pointer(bp + 12))) != TCL_OK { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+37506, int64(-libc.Int32FromInt32(1)))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+120, __ccgo_ts+179, __ccgo_ts+36356, libc.UintptrFromInt32(0))) goto errorExit } tempformat = (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fformat tempdata = (*TPhotoModel)(unsafe.Pointer(modelPtr)).FdataObj if *(*int32)(unsafe.Pointer(bp + 16)) != 0 { if tempformat != 0 { tempformat = libtcl9_0.XTcl_GetStringFromObj(tls, tempformat, libc.UintptrFromInt32(0)) } tempdata = libtcl9_0.XTcl_GetStringFromObj(tls, tempdata, libc.UintptrFromInt32(0)) } if *(*uintptr)(unsafe.Pointer(bp + 24)) != libc.UintptrFromInt32(0) { if (*(*func(*libc.TLS, uintptr, uintptr, uintptr, TTk_PhotoHandle, int32, int32, int32, int32, int32, int32) int32)(unsafe.Pointer(&struct{ uintptr }{(*TTk_PhotoImageFormat)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 24)))).FstringReadProc})))(tls, interp, tempdata, tempformat, modelPtr, 0, 0, *(*int32)(unsafe.Pointer(bp + 8)), *(*int32)(unsafe.Pointer(bp + 12)), 0, 0) != TCL_OK { goto errorExit } } else { if (*(*func(*libc.TLS, uintptr, uintptr, uintptr, uintptr, TTk_PhotoHandle, int32, int32, int32, int32, int32, int32, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*TTk_PhotoImageFormatVersion3)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 32)))).FstringReadProc})))(tls, interp, tempdata, tempformat, (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fmetadata, modelPtr, 0, 0, *(*int32)(unsafe.Pointer(bp + 8)), *(*int32)(unsafe.Pointer(bp + 12)), 0, 0, metadataOutObj) != TCL_OK { goto errorExit } } libtcl9_0.XTcl_ResetResult(tls, interp) *(*int32)(unsafe.Pointer(modelPtr + 24)) |= int32(IMAGE_CHANGED) } /* * Merge driver returned metadata and master metadata */ if metadataOutObj != libc.UintptrFromInt32(0) { if TCL_OK != libtcl9_0.XTcl_DictObjSize(tls, interp, metadataOutObj, bp+56) { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+38646, int64(-libc.Int32FromInt32(1)))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+120, __ccgo_ts+179, __ccgo_ts+29667, __ccgo_ts+37434, __ccgo_ts+38625, libc.UintptrFromInt32(0))) goto errorExit } if *(*TTcl_Size)(unsafe.Pointer(bp + 56)) > 0 { /* * We have driver return metadata */ if (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fmetadata == libc.UintptrFromInt32(0) { (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fmetadata = metadataOutObj metadataOutObj = libc.UintptrFromInt32(0) } else { if (*TTcl_Obj)(unsafe.Pointer((*TPhotoModel)(unsafe.Pointer(modelPtr)).Fmetadata)).FrefCount > int64(1) { _objPtr4 = (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fmetadata v17 = _objPtr4 v16 = *(*TTcl_Size)(unsafe.Pointer(v17)) *(*TTcl_Size)(unsafe.Pointer(v17))-- if v16 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr4) } (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fmetadata = libtcl9_0.XTcl_DuplicateObj(tls, (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fmetadata) (*TTcl_Obj)(unsafe.Pointer((*TPhotoModel)(unsafe.Pointer(modelPtr)).Fmetadata)).FrefCount++ } if libtcl9_0.XTcl_DictObjFirst(tls, interp, metadataOutObj, bp+64, bp+88, bp+96, bp+104) != TCL_OK { goto errorExit } for { if !!(*(*int32)(unsafe.Pointer(bp + 104)) != 0) { break } libtcl9_0.XTcl_DictObjPut(tls, interp, (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fmetadata, *(*uintptr)(unsafe.Pointer(bp + 88)), *(*uintptr)(unsafe.Pointer(bp + 96))) goto _18 _18: ; libtcl9_0.XTcl_DictObjNext(tls, bp+64, bp+88, bp+96, bp+104) } } } } /* * Enforce a reasonable value for gamma. */ if (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fgamma <= libc.Float64FromInt32(0) { (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fgamma = float64(1) } if (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fgamma != oldGamma || (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fpalette != oldPaletteString { *(*int32)(unsafe.Pointer(modelPtr + 24)) |= int32(IMAGE_CHANGED) } /* * Cycle through all of the instances of this image, regenerating the * information for each instance. Then force the image to be redisplayed * everywhere that it is used. */ instancePtr = (*TPhotoModel)(unsafe.Pointer(modelPtr)).FinstancePtr for { if !(instancePtr != libc.UintptrFromInt32(0)) { break } XTkImgPhotoConfigureInstance(tls, instancePtr) goto _19 _19: ; instancePtr = (*TPhotoInstance)(unsafe.Pointer(instancePtr)).FnextPtr } /* * Inform the generic image code that the image has (potentially) changed. */ XTk_ImageChanged(tls, (*TPhotoModel)(unsafe.Pointer(modelPtr)).FtkModel, 0, 0, (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fwidth, (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fheight, (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fwidth, (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fheight) *(*int32)(unsafe.Pointer(modelPtr + 24)) &= ^libc.Int32FromInt32(IMAGE_CHANGED) if oldData != libc.UintptrFromInt32(0) { _objPtr5 = oldData v21 = _objPtr5 v20 = *(*TTcl_Size)(unsafe.Pointer(v21)) *(*TTcl_Size)(unsafe.Pointer(v21))-- if v20 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr5) } } if oldFormat != libc.UintptrFromInt32(0) { _objPtr6 = oldFormat v23 = _objPtr6 v22 = *(*TTcl_Size)(unsafe.Pointer(v23)) *(*TTcl_Size)(unsafe.Pointer(v23))-- if v22 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr6) } } if metadataOutObj != libc.UintptrFromInt32(0) { _objPtr7 = metadataOutObj v25 = _objPtr7 v24 = *(*TTcl_Size)(unsafe.Pointer(v25)) *(*TTcl_Size)(unsafe.Pointer(v25))-- if v24 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr7) } } _ToggleComplexAlphaIfNeeded(tls, modelPtr) return TCL_OK goto errorExit errorExit: ; if oldData != libc.UintptrFromInt32(0) { _objPtr8 = oldData v27 = _objPtr8 v26 = *(*TTcl_Size)(unsafe.Pointer(v27)) *(*TTcl_Size)(unsafe.Pointer(v27))-- if v26 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr8) } } if oldFormat != libc.UintptrFromInt32(0) { _objPtr9 = oldFormat v29 = _objPtr9 v28 = *(*TTcl_Size)(unsafe.Pointer(v29)) *(*TTcl_Size)(unsafe.Pointer(v29))-- if v28 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr9) } } if metadataOutObj != libc.UintptrFromInt32(0) { _objPtr10 = metadataOutObj v31 = _objPtr10 v30 = *(*TTcl_Size)(unsafe.Pointer(v31)) *(*TTcl_Size)(unsafe.Pointer(v31))-- if v30 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr10) } } return int32(TCL_ERROR) } /* *---------------------------------------------------------------------- * * ToggleComplexAlphaIfNeeded -- * * This function is called when an image is modified to check if any * partially transparent pixels exist, which requires blending instead of * straight copy. * * Results: * None. * * Side effects: * (Re)sets COMPLEX_ALPHA flag of model. * *---------------------------------------------------------------------- */ func _ToggleComplexAlphaIfNeeded(tls *libc.TLS, mPtr uintptr) (r int32) { var c, end uintptr var len1 Tsize_t var v1, v2 int32 _, _, _, _, _ = c, end, len1, v1, v2 if (*TPhotoModel)(unsafe.Pointer(mPtr)).FuserWidth > (*TPhotoModel)(unsafe.Pointer(mPtr)).Fwidth { v1 = (*TPhotoModel)(unsafe.Pointer(mPtr)).FuserWidth } else { v1 = (*TPhotoModel)(unsafe.Pointer(mPtr)).Fwidth } if (*TPhotoModel)(unsafe.Pointer(mPtr)).FuserHeight > (*TPhotoModel)(unsafe.Pointer(mPtr)).Fheight { v2 = (*TPhotoModel)(unsafe.Pointer(mPtr)).FuserHeight } else { v2 = (*TPhotoModel)(unsafe.Pointer(mPtr)).Fheight } len1 = libc.Uint64FromInt32(v1) * libc.Uint64FromInt32(v2) * uint64(4) c = (*TPhotoModel)(unsafe.Pointer(mPtr)).Fpix32 /* * Set the COMPLEX_ALPHA flag if we have an image with partially * transparent bits. */ *(*int32)(unsafe.Pointer(mPtr + 24)) &= ^libc.Int32FromInt32(COMPLEX_ALPHA) if c == libc.UintptrFromInt32(0) { return 0 } end = c + uintptr(len1) c += uintptr(3) /* Start at first alpha byte. */ for { if !(c < end) { break } if *(*uint8)(unsafe.Pointer(c)) != 0 && libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(c))) != int32(255) { *(*int32)(unsafe.Pointer(mPtr + 24)) |= int32(COMPLEX_ALPHA) break } goto _3 _3: ; c += uintptr(4) } return (*TPhotoModel)(unsafe.Pointer(mPtr)).Fflags & int32(COMPLEX_ALPHA) } /* *---------------------------------------------------------------------- * * ImgPhotoDelete -- * * This function is called by the image code to delete the model * structure for an image. * * Results: * None. * * Side effects: * Resources associated with the image get freed. * *---------------------------------------------------------------------- */ func _ImgPhotoDelete(tls *libc.TLS, modelData uintptr) { /* Pointer to PhotoModel structure for image. * Must not have any more instances. */ var _objPtr, _objPtr1, _objPtr2, instancePtr, modelPtr, v1, v3, v5, v7 uintptr var v2, v4, v6 TTcl_Size _, _, _, _, _, _, _, _, _, _, _, _ = _objPtr, _objPtr1, _objPtr2, instancePtr, modelPtr, v1, v2, v3, v4, v5, v6, v7 modelPtr = modelData for { v1 = (*TPhotoModel)(unsafe.Pointer(modelPtr)).FinstancePtr instancePtr = v1 if !(v1 != libc.UintptrFromInt32(0)) { break } if (*TPhotoInstance)(unsafe.Pointer(instancePtr)).FrefCount > uint64(0) { libtcl9_0.XTcl_Panic(tls, __ccgo_ts+38673, 0) } libtcl9_0.XTcl_CancelIdleCall(tls, __ccgo_fp(XTkImgDisposeInstance), instancePtr) XTkImgDisposeInstance(tls, instancePtr) } (*TPhotoModel)(unsafe.Pointer(modelPtr)).FtkModel = libc.UintptrFromInt32(0) if (*TPhotoModel)(unsafe.Pointer(modelPtr)).FimageCmd != libc.UintptrFromInt32(0) { libtcl9_0.XTcl_DeleteCommandFromToken(tls, (*TPhotoModel)(unsafe.Pointer(modelPtr)).Finterp, (*TPhotoModel)(unsafe.Pointer(modelPtr)).FimageCmd) } if (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fpix32 != libc.UintptrFromInt32(0) { libtcl9_0.XTcl_Free(tls, (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fpix32) } if (*TPhotoModel)(unsafe.Pointer(modelPtr)).FvalidRegion != libc.UintptrFromInt32(0) { libx11.XXDestroyRegion(tls, (*TPhotoModel)(unsafe.Pointer(modelPtr)).FvalidRegion) } if (*TPhotoModel)(unsafe.Pointer(modelPtr)).FdataObj != libc.UintptrFromInt32(0) { _objPtr = (*TPhotoModel)(unsafe.Pointer(modelPtr)).FdataObj v3 = _objPtr v2 = *(*TTcl_Size)(unsafe.Pointer(v3)) *(*TTcl_Size)(unsafe.Pointer(v3))-- if v2 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr) } } if (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fformat != libc.UintptrFromInt32(0) { _objPtr1 = (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fformat v5 = _objPtr1 v4 = *(*TTcl_Size)(unsafe.Pointer(v5)) *(*TTcl_Size)(unsafe.Pointer(v5))-- if v4 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr1) } } if (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fmetadata != libc.UintptrFromInt32(0) { _objPtr2 = (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fmetadata v7 = _objPtr2 v6 = *(*TTcl_Size)(unsafe.Pointer(v7)) *(*TTcl_Size)(unsafe.Pointer(v7))-- if v6 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr2) } } XTk_FreeOptions(tls, uintptr(unsafe.Pointer(&_configSpecs12)), modelPtr, libc.UintptrFromInt32(0), 0) libtcl9_0.XTcl_Free(tls, modelPtr) } /* *---------------------------------------------------------------------- * * ImgPhotoCmdDeletedProc -- * * This function is invoked when the image command for an image is * deleted. It deletes the image. * * Results: * None. * * Side effects: * The image is deleted. * *---------------------------------------------------------------------- */ func _ImgPhotoCmdDeletedProc(tls *libc.TLS, clientData uintptr) { /* Pointer to PhotoModel structure for * image. */ var modelPtr uintptr _ = modelPtr modelPtr = clientData (*TPhotoModel)(unsafe.Pointer(modelPtr)).FimageCmd = libc.UintptrFromInt32(0) if (*TPhotoModel)(unsafe.Pointer(modelPtr)).FtkModel != libc.UintptrFromInt32(0) { XTk_DeleteImage(tls, (*TPhotoModel)(unsafe.Pointer(modelPtr)).Finterp, XTk_NameOfImage(tls, (*TPhotoModel)(unsafe.Pointer(modelPtr)).FtkModel)) } } /* *---------------------------------------------------------------------- * * ImgPhotoSetSize -- * * This function reallocates the image storage and instance pixmaps for a * photo image, as necessary, to change the image's size to `width' x * `height' pixels. * * Results: * TCL_OK if successful, TCL_ERROR if failure occurred (currently just * with memory allocation.) * * Side effects: * Storage gets reallocated, for the model and all its instances. * *---------------------------------------------------------------------- */ func _ImgPhotoSetSize(tls *libc.TLS, modelPtr uintptr, width int32, height int32) (r int32) { bp := tls.Alloc(16) defer tls.Free(16) var clipRegion TRegion var destPtr, instancePtr, newPix32, srcPtr uintptr var h, offset, pitch int32 var newPixSize uint32 var _ /* clipBox at bp+8 */ TXRectangle var _ /* validBox at bp+0 */ TXRectangle _, _, _, _, _, _, _, _, _ = clipRegion, destPtr, h, instancePtr, newPix32, newPixSize, offset, pitch, srcPtr newPix32 = libc.UintptrFromInt32(0) if (*TPhotoModel)(unsafe.Pointer(modelPtr)).FuserWidth > 0 { width = (*TPhotoModel)(unsafe.Pointer(modelPtr)).FuserWidth } if (*TPhotoModel)(unsafe.Pointer(modelPtr)).FuserHeight > 0 { height = (*TPhotoModel)(unsafe.Pointer(modelPtr)).FuserHeight } if width > libc.Int32FromInt32(INT_MAX)/libc.Int32FromInt32(4) { /* Pitch overflows int */ return int32(TCL_ERROR) } pitch = width * int32(4) /* * Test if we're going to (re)allocate the main buffer now, so that any * failures will leave the photo unchanged. */ if width != (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fwidth || height != (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fheight || (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fpix32 == libc.UintptrFromInt32(0) { if pitch != 0 && height > libc.Int32FromUint32(libc.Uint32FromUint32(0xffffffff)/libc.Uint32FromInt32(pitch)) { return int32(TCL_ERROR) } newPixSize = libc.Uint32FromInt32(height * pitch) /* * Some mallocs() really hate allocating zero bytes. [Bug 619544] */ if newPixSize == uint32(0) { newPix32 = libc.UintptrFromInt32(0) } else { newPix32 = libtcl9_0.XTcl_AttemptAlloc(tls, uint64(newPixSize)) if newPix32 == libc.UintptrFromInt32(0) { return int32(TCL_ERROR) } } } /* * We have to trim the valid region if it is currently larger than the new * image size. */ libx11.XXClipBox(tls, (*TPhotoModel)(unsafe.Pointer(modelPtr)).FvalidRegion, bp) if int32((*(*TXRectangle)(unsafe.Pointer(bp))).Fx)+libc.Int32FromUint16((*(*TXRectangle)(unsafe.Pointer(bp))).Fwidth) > width || int32((*(*TXRectangle)(unsafe.Pointer(bp))).Fy)+libc.Int32FromUint16((*(*TXRectangle)(unsafe.Pointer(bp))).Fheight) > height { (*(*TXRectangle)(unsafe.Pointer(bp + 8))).Fx = 0 (*(*TXRectangle)(unsafe.Pointer(bp + 8))).Fy = 0 (*(*TXRectangle)(unsafe.Pointer(bp + 8))).Fwidth = libc.Uint16FromInt32(width) (*(*TXRectangle)(unsafe.Pointer(bp + 8))).Fheight = libc.Uint16FromInt32(height) clipRegion = libx11.XXCreateRegion(tls) libx11.XXUnionRectWithRegion(tls, bp+8, clipRegion, clipRegion) libx11.XXIntersectRegion(tls, (*TPhotoModel)(unsafe.Pointer(modelPtr)).FvalidRegion, clipRegion, (*TPhotoModel)(unsafe.Pointer(modelPtr)).FvalidRegion) libx11.XXDestroyRegion(tls, clipRegion) libx11.XXClipBox(tls, (*TPhotoModel)(unsafe.Pointer(modelPtr)).FvalidRegion, bp) } /* * Use the reallocated storage (allocation above) for the 32-bit image and * copy over valid regions. Note that this test is true precisely when the * allocation has already been done. */ if newPix32 != libc.UintptrFromInt32(0) { /* * Zero the new array. The dithering code shouldn't read the areas * outside validBox, but they might be copied to another photo image * or written to a file. */ if (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fpix32 != libc.UintptrFromInt32(0) && (width == (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fwidth || width == libc.Int32FromUint16((*(*TXRectangle)(unsafe.Pointer(bp))).Fwidth)) { if int32((*(*TXRectangle)(unsafe.Pointer(bp))).Fy) > 0 { libc.Xmemset(tls, newPix32, 0, libc.Uint64FromInt16((*(*TXRectangle)(unsafe.Pointer(bp))).Fy)*libc.Uint64FromInt32(pitch)) } h = int32((*(*TXRectangle)(unsafe.Pointer(bp))).Fy) + libc.Int32FromUint16((*(*TXRectangle)(unsafe.Pointer(bp))).Fheight) if h < height { libc.Xmemset(tls, newPix32+uintptr(h*pitch), 0, libc.Uint64FromInt32(height-h)*libc.Uint64FromInt32(pitch)) } } else { libc.Xmemset(tls, newPix32, 0, libc.Uint64FromInt32(height)*libc.Uint64FromInt32(pitch)) } if (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fpix32 != libc.UintptrFromInt32(0) { /* * Copy the common area over to the new array array and free the * old array. */ if width == (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fwidth { /* * The region to be copied is contiguous. */ offset = int32((*(*TXRectangle)(unsafe.Pointer(bp))).Fy) * pitch libc.Xmemcpy(tls, newPix32+uintptr(offset), (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fpix32+uintptr(offset), uint64((*(*TXRectangle)(unsafe.Pointer(bp))).Fheight)*libc.Uint64FromInt32(pitch)) } else { if libc.Int32FromUint16((*(*TXRectangle)(unsafe.Pointer(bp))).Fwidth) > 0 && libc.Int32FromUint16((*(*TXRectangle)(unsafe.Pointer(bp))).Fheight) > 0 { /* * Area to be copied is not contiguous - copy line by line. */ destPtr = newPix32 + uintptr((int32((*(*TXRectangle)(unsafe.Pointer(bp))).Fy)*width+int32((*(*TXRectangle)(unsafe.Pointer(bp))).Fx))*int32(4)) srcPtr = (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fpix32 + uintptr((int32((*(*TXRectangle)(unsafe.Pointer(bp))).Fy)*(*TPhotoModel)(unsafe.Pointer(modelPtr)).Fwidth+int32((*(*TXRectangle)(unsafe.Pointer(bp))).Fx))*int32(4)) h = libc.Int32FromUint16((*(*TXRectangle)(unsafe.Pointer(bp))).Fheight) for { if !(h > 0) { break } libc.Xmemcpy(tls, destPtr, srcPtr, uint64((*(*TXRectangle)(unsafe.Pointer(bp))).Fwidth)*libc.Uint64FromInt32(4)) destPtr += uintptr(width * int32(4)) srcPtr += uintptr((*TPhotoModel)(unsafe.Pointer(modelPtr)).Fwidth * int32(4)) goto _1 _1: ; h-- } } } libtcl9_0.XTcl_Free(tls, (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fpix32) } (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fpix32 = newPix32 (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fwidth = width (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fheight = height /* * Dithering will be correct up to the end of the last pre-existing * complete scanline. */ if int32((*(*TXRectangle)(unsafe.Pointer(bp))).Fx) > 0 || int32((*(*TXRectangle)(unsafe.Pointer(bp))).Fy) > 0 { (*TPhotoModel)(unsafe.Pointer(modelPtr)).FditherX = 0 (*TPhotoModel)(unsafe.Pointer(modelPtr)).FditherY = 0 } else { if libc.Int32FromUint16((*(*TXRectangle)(unsafe.Pointer(bp))).Fwidth) == width { if libc.Int32FromUint16((*(*TXRectangle)(unsafe.Pointer(bp))).Fheight) < (*TPhotoModel)(unsafe.Pointer(modelPtr)).FditherY { (*TPhotoModel)(unsafe.Pointer(modelPtr)).FditherX = 0 (*TPhotoModel)(unsafe.Pointer(modelPtr)).FditherY = libc.Int32FromUint16((*(*TXRectangle)(unsafe.Pointer(bp))).Fheight) } } else { if (*TPhotoModel)(unsafe.Pointer(modelPtr)).FditherY > 0 || libc.Int32FromUint16((*(*TXRectangle)(unsafe.Pointer(bp))).Fwidth) < (*TPhotoModel)(unsafe.Pointer(modelPtr)).FditherX { (*TPhotoModel)(unsafe.Pointer(modelPtr)).FditherX = libc.Int32FromUint16((*(*TXRectangle)(unsafe.Pointer(bp))).Fwidth) (*TPhotoModel)(unsafe.Pointer(modelPtr)).FditherY = 0 } } } } _ToggleComplexAlphaIfNeeded(tls, modelPtr) /* * Now adjust the sizes of the pixmaps for all of the instances. */ instancePtr = (*TPhotoModel)(unsafe.Pointer(modelPtr)).FinstancePtr for { if !(instancePtr != libc.UintptrFromInt32(0)) { break } XTkImgPhotoInstanceSetSize(tls, instancePtr) goto _2 _2: ; instancePtr = (*TPhotoInstance)(unsafe.Pointer(instancePtr)).FnextPtr } return TCL_OK } /* *---------------------------------------------------------------------- * * MatchFileFormat -- * * This function is called to find a photo image file format handler * which can parse the image data in the given file. If a user-specified * format string is provided, only handlers whose names match a prefix of * the format string are tried. * * Results: * A standard TCL return value. If the return value is TCL_OK, a pointer * to the image format record is returned in *imageFormatPtr or * *imageFormatVersion3Ptr, and the width and height of the image are * returned in *widthPtr and *heightPtr. * * Side effects: * None. * *---------------------------------------------------------------------- */ func _MatchFileFormat(tls *libc.TLS, interp uintptr, chan1 TTcl_Channel, fileName uintptr, formatObj uintptr, metadataInObj uintptr, metadataOutObj uintptr, imageFormatPtr uintptr, imageFormatVersion3Ptr uintptr, widthPtr uintptr, heightPtr uintptr, oldformat uintptr) (r int32) { bp := tls.Alloc(64) defer tls.Free(64) /* Returns 1 if the old image API is used. */ var _objPtr, formatPtr, formatString, formatVersion3Ptr, tsdPtr, v4 uintptr var matched, useoldformat int32 var v3 TTcl_Size var _ /* dictSize at bp+0 */ TTcl_Size _, _, _, _, _, _, _, _, _ = _objPtr, formatPtr, formatString, formatVersion3Ptr, matched, tsdPtr, useoldformat, v3, v4 matched = 0 useoldformat = 0 tsdPtr = libtcl9_0.XTcl_GetThreadData(tls, uintptr(unsafe.Pointer(&_dataKey14)), int64(24)) formatString = libc.UintptrFromInt32(0) if formatObj != 0 { formatString = libtcl9_0.XTcl_GetStringFromObj(tls, formatObj, libc.UintptrFromInt32(0)) } /* * Scan through the table of file format handlers to find one which can * handle the image. */ formatPtr = (*TThreadSpecificData13)(unsafe.Pointer(tsdPtr)).FformatList for { if !(formatPtr != libc.UintptrFromInt32(0)) { break } if formatObj != libc.UintptrFromInt32(0) { if libc.Xstrncasecmp(tls, formatString, (*TTk_PhotoImageFormat)(unsafe.Pointer(formatPtr)).Fname, libc.Xstrlen(tls, (*TTk_PhotoImageFormat)(unsafe.Pointer(formatPtr)).Fname)) != 0 { goto _1 } matched = int32(1) if (*TTk_PhotoImageFormat)(unsafe.Pointer(formatPtr)).FfileMatchProc == libc.UintptrFromInt32(0) { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+38728, libc.VaList(bp+16, formatString))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+16, __ccgo_ts+179, __ccgo_ts+29667, __ccgo_ts+37434, __ccgo_ts+38771, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) } } if (*TTk_PhotoImageFormat)(unsafe.Pointer(formatPtr)).FfileMatchProc != libc.UintptrFromInt32(0) { libtcl9_0.XTcl_Seek(tls, chan1, int64(libc.Int64FromInt64(0)), 0) if (*(*func(*libc.TLS, TTcl_Channel, uintptr, uintptr, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*TTk_PhotoImageFormat)(unsafe.Pointer(formatPtr)).FfileMatchProc})))(tls, chan1, fileName, formatObj, widthPtr, heightPtr, interp) != 0 { if *(*int32)(unsafe.Pointer(widthPtr)) < int32(1) { *(*int32)(unsafe.Pointer(widthPtr)) = int32(1) } if *(*int32)(unsafe.Pointer(heightPtr)) < int32(1) { *(*int32)(unsafe.Pointer(heightPtr)) = int32(1) } break } } goto _1 _1: ; formatPtr = (*TTk_PhotoImageFormat)(unsafe.Pointer(formatPtr)).FnextPtr } /* * For old and not version 3 format, exit now with success */ if formatPtr != libc.UintptrFromInt32(0) { *(*uintptr)(unsafe.Pointer(imageFormatPtr)) = formatPtr *(*uintptr)(unsafe.Pointer(imageFormatVersion3Ptr)) = libc.UintptrFromInt32(0) *(*int32)(unsafe.Pointer(oldformat)) = useoldformat libtcl9_0.XTcl_Seek(tls, chan1, int64(libc.Int64FromInt64(0)), 0) return TCL_OK } /* * Scan through the table of file format version 3 handlers to find one * which can handle the image. */ formatVersion3Ptr = (*TThreadSpecificData13)(unsafe.Pointer(tsdPtr)).FformatListVersion3 for { if !(formatVersion3Ptr != libc.UintptrFromInt32(0)) { break } if formatObj != libc.UintptrFromInt32(0) { if libc.Xstrncasecmp(tls, formatString, (*TTk_PhotoImageFormatVersion3)(unsafe.Pointer(formatVersion3Ptr)).Fname, libc.Xstrlen(tls, (*TTk_PhotoImageFormatVersion3)(unsafe.Pointer(formatVersion3Ptr)).Fname)) != 0 { goto _2 } matched = int32(1) if (*TTk_PhotoImageFormatVersion3)(unsafe.Pointer(formatVersion3Ptr)).FfileMatchProc == libc.UintptrFromInt32(0) { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+38728, libc.VaList(bp+16, formatString))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+16, __ccgo_ts+179, __ccgo_ts+29667, __ccgo_ts+37434, __ccgo_ts+38771, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) } } if (*TTk_PhotoImageFormatVersion3)(unsafe.Pointer(formatVersion3Ptr)).FfileMatchProc != libc.UintptrFromInt32(0) { libtcl9_0.XTcl_Seek(tls, chan1, int64(libc.Int64FromInt64(0)), 0) if (*(*func(*libc.TLS, uintptr, TTcl_Channel, uintptr, uintptr, uintptr, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*TTk_PhotoImageFormatVersion3)(unsafe.Pointer(formatVersion3Ptr)).FfileMatchProc})))(tls, interp, chan1, fileName, formatObj, metadataInObj, widthPtr, heightPtr, metadataOutObj) != 0 { if *(*int32)(unsafe.Pointer(widthPtr)) < int32(1) { *(*int32)(unsafe.Pointer(widthPtr)) = int32(1) } if *(*int32)(unsafe.Pointer(heightPtr)) < int32(1) { *(*int32)(unsafe.Pointer(heightPtr)) = int32(1) } *(*uintptr)(unsafe.Pointer(imageFormatVersion3Ptr)) = formatVersion3Ptr *(*uintptr)(unsafe.Pointer(imageFormatPtr)) = libc.UintptrFromInt32(0) *(*int32)(unsafe.Pointer(oldformat)) = 0 libtcl9_0.XTcl_Seek(tls, chan1, int64(libc.Int64FromInt64(0)), 0) return TCL_OK } /* * Check if driver has shared or changed the metadata Tcl object. * In this case, release and recreate it. */ if metadataOutObj != libc.UintptrFromInt32(0) { if (*TTcl_Obj)(unsafe.Pointer(metadataOutObj)).FrefCount > int64(1) || TCL_OK != libtcl9_0.XTcl_DictObjSize(tls, interp, metadataOutObj, bp) || *(*TTcl_Size)(unsafe.Pointer(bp)) > 0 { _objPtr = metadataOutObj v4 = _objPtr v3 = *(*TTcl_Size)(unsafe.Pointer(v4)) *(*TTcl_Size)(unsafe.Pointer(v4))-- if v3 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr) } metadataOutObj = libtcl9_0.XTcl_NewDictObj(tls) (*TTcl_Obj)(unsafe.Pointer(metadataOutObj)).FrefCount++ } } } goto _2 _2: ; formatVersion3Ptr = (*TTk_PhotoImageFormatVersion3)(unsafe.Pointer(formatVersion3Ptr)).FnextPtr } /* * No matching format found */ if formatObj != libc.UintptrFromInt32(0) && !(matched != 0) { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+38787, libc.VaList(bp+16, formatString))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+16, __ccgo_ts+179, __ccgo_ts+3058, __ccgo_ts+37641, formatString, libc.UintptrFromInt32(0))) } else { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+38827, libc.VaList(bp+16, fileName))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+16, __ccgo_ts+179, __ccgo_ts+37434, __ccgo_ts+29667, __ccgo_ts+38625, libc.UintptrFromInt32(0))) } return int32(TCL_ERROR) } /* *---------------------------------------------------------------------- * * MatchStringFormat -- * * This function is called to find a photo image file format handler * which can parse the image data in the given string. If a * user-specified format string is provided, only handlers whose names * match a prefix of the format string are tried. * * Results: * A standard TCL return value. If the return value is TCL_OK, a pointer * to the image format record is returned in *imageFormatPtr or * *imageFormatVersion3Ptr, and the width and height of the image are * returned in *widthPtr and *heightPtr. * * Side effects: * None. * *---------------------------------------------------------------------- */ func _MatchStringFormat(tls *libc.TLS, interp uintptr, data uintptr, formatObj uintptr, metadataInObj uintptr, metadataOutObj uintptr, imageFormatPtr uintptr, imageFormatVersion3Ptr uintptr, widthPtr uintptr, heightPtr uintptr, oldformat uintptr) (r int32) { bp := tls.Alloc(64) defer tls.Free(64) /* Returns 1 if the old image API is used. */ var _objPtr, defaultFormatPtr, formatPtr, formatString, formatVersion3Ptr, tsdPtr, v4 uintptr var matched, useoldformat int32 var v3 TTcl_Size var _ /* dictSize at bp+0 */ TTcl_Size _, _, _, _, _, _, _, _, _, _ = _objPtr, defaultFormatPtr, formatPtr, formatString, formatVersion3Ptr, matched, tsdPtr, useoldformat, v3, v4 matched = 0 useoldformat = 0 defaultFormatPtr = libc.UintptrFromInt32(0) formatVersion3Ptr = libc.UintptrFromInt32(0) tsdPtr = libtcl9_0.XTcl_GetThreadData(tls, uintptr(unsafe.Pointer(&_dataKey14)), int64(24)) formatString = libc.UintptrFromInt32(0) if formatObj != 0 { formatString = libtcl9_0.XTcl_GetStringFromObj(tls, formatObj, libc.UintptrFromInt32(0)) } /* * Scan through the table of file format handlers to find one which can * handle the image. */ formatPtr = (*TThreadSpecificData13)(unsafe.Pointer(tsdPtr)).FformatList for { if !(formatPtr != libc.UintptrFromInt32(0)) { break } /* * To keep the behaviour of older versions (Tk <= 8.6), the default * list-of-lists string format is checked last. Remember its position. */ if libc.Xstrncasecmp(tls, __ccgo_ts+17388, (*TTk_PhotoImageFormat)(unsafe.Pointer(formatPtr)).Fname, libc.Xstrlen(tls, (*TTk_PhotoImageFormat)(unsafe.Pointer(formatPtr)).Fname)) == 0 { defaultFormatPtr = formatPtr } if formatObj != libc.UintptrFromInt32(0) { if libc.Xstrncasecmp(tls, formatString, (*TTk_PhotoImageFormat)(unsafe.Pointer(formatPtr)).Fname, libc.Xstrlen(tls, (*TTk_PhotoImageFormat)(unsafe.Pointer(formatPtr)).Fname)) != 0 { goto _1 } matched = int32(1) if (*TTk_PhotoImageFormat)(unsafe.Pointer(formatPtr)).FstringMatchProc == libc.UintptrFromInt32(0) { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+38870, libc.VaList(bp+16, formatString))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+16, __ccgo_ts+179, __ccgo_ts+29667, __ccgo_ts+37434, __ccgo_ts+38913, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) } } /* * If this is the default format, and it was not passed as -format * option, skip the stringMatchProc test. It'll be done later */ if formatObj == libc.UintptrFromInt32(0) && formatPtr == defaultFormatPtr { goto _1 } if (*TTk_PhotoImageFormat)(unsafe.Pointer(formatPtr)).FstringMatchProc != libc.UintptrFromInt32(0) && (*TTk_PhotoImageFormat)(unsafe.Pointer(formatPtr)).FstringReadProc != libc.UintptrFromInt32(0) && (*(*func(*libc.TLS, uintptr, uintptr, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*TTk_PhotoImageFormat)(unsafe.Pointer(formatPtr)).FstringMatchProc})))(tls, data, formatObj, widthPtr, heightPtr, interp) != 0 { break } goto _1 _1: ; formatPtr = (*TTk_PhotoImageFormat)(unsafe.Pointer(formatPtr)).FnextPtr } if formatPtr == libc.UintptrFromInt32(0) { useoldformat = 0 formatVersion3Ptr = (*TThreadSpecificData13)(unsafe.Pointer(tsdPtr)).FformatListVersion3 for { if !(formatVersion3Ptr != libc.UintptrFromInt32(0)) { break } if formatObj != libc.UintptrFromInt32(0) { if libc.Xstrncasecmp(tls, formatString, (*TTk_PhotoImageFormatVersion3)(unsafe.Pointer(formatVersion3Ptr)).Fname, libc.Xstrlen(tls, (*TTk_PhotoImageFormatVersion3)(unsafe.Pointer(formatVersion3Ptr)).Fname)) != 0 { goto _2 } matched = int32(1) if (*TTk_PhotoImageFormatVersion3)(unsafe.Pointer(formatVersion3Ptr)).FstringMatchProc == libc.UintptrFromInt32(0) { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+38870, libc.VaList(bp+16, formatString))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+16, __ccgo_ts+179, __ccgo_ts+29667, __ccgo_ts+37434, __ccgo_ts+38913, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) } } if (*TTk_PhotoImageFormatVersion3)(unsafe.Pointer(formatVersion3Ptr)).FstringMatchProc != libc.UintptrFromInt32(0) && (*TTk_PhotoImageFormatVersion3)(unsafe.Pointer(formatVersion3Ptr)).FstringReadProc != libc.UintptrFromInt32(0) && (*(*func(*libc.TLS, uintptr, uintptr, uintptr, uintptr, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*TTk_PhotoImageFormatVersion3)(unsafe.Pointer(formatVersion3Ptr)).FstringMatchProc})))(tls, interp, data, formatObj, metadataInObj, widthPtr, heightPtr, metadataOutObj) != 0 { break } /* * Check if driver has shared or changed the metadata tcl object. * In this case, release and recreate it. */ if metadataOutObj != libc.UintptrFromInt32(0) { if (*TTcl_Obj)(unsafe.Pointer(metadataOutObj)).FrefCount > int64(1) || TCL_OK != libtcl9_0.XTcl_DictObjSize(tls, interp, metadataOutObj, bp) || *(*TTcl_Size)(unsafe.Pointer(bp)) > 0 { _objPtr = metadataOutObj v4 = _objPtr v3 = *(*TTcl_Size)(unsafe.Pointer(v4)) *(*TTcl_Size)(unsafe.Pointer(v4))-- if v3 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr) } metadataOutObj = libtcl9_0.XTcl_NewDictObj(tls) (*TTcl_Obj)(unsafe.Pointer(metadataOutObj)).FrefCount++ } } goto _2 _2: ; formatVersion3Ptr = (*TTk_PhotoImageFormatVersion3)(unsafe.Pointer(formatVersion3Ptr)).FnextPtr } } if formatPtr == libc.UintptrFromInt32(0) && formatVersion3Ptr == libc.UintptrFromInt32(0) { /* * Try the default format as last resort (only if no -format option * was passed). */ if formatObj == libc.UintptrFromInt32(0) && defaultFormatPtr == libc.UintptrFromInt32(0) { libtcl9_0.XTcl_Panic(tls, __ccgo_ts+38929, 0) } if formatObj == libc.UintptrFromInt32(0) && (*TTk_PhotoImageFormat)(unsafe.Pointer(defaultFormatPtr)).FstringMatchProc != libc.UintptrFromInt32(0) && (*TTk_PhotoImageFormat)(unsafe.Pointer(defaultFormatPtr)).FstringReadProc != libc.UintptrFromInt32(0) && (*(*func(*libc.TLS, uintptr, uintptr, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*TTk_PhotoImageFormat)(unsafe.Pointer(defaultFormatPtr)).FstringMatchProc})))(tls, data, formatObj, widthPtr, heightPtr, interp) != 0 { useoldformat = 0 formatPtr = defaultFormatPtr } else { if formatObj != libc.UintptrFromInt32(0) && !(matched != 0) { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+38973, libc.VaList(bp+16, formatString))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+16, __ccgo_ts+179, __ccgo_ts+3058, __ccgo_ts+37641, formatString, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) } else { /* * Some lower level routine (stringMatchProc) may have already set * a specific error message, so just return this. Otherwise return * a generic image data error. */ if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(libtcl9_0.XTcl_GetStringFromObj(tls, libtcl9_0.XTcl_GetObjResult(tls, interp), libc.UintptrFromInt32(0))))) == int32('\000') { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+39008, int64(-libc.Int32FromInt32(1)))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+16, __ccgo_ts+179, __ccgo_ts+29667, __ccgo_ts+37434, __ccgo_ts+38625, libc.UintptrFromInt32(0))) } return int32(TCL_ERROR) } } } *(*uintptr)(unsafe.Pointer(imageFormatPtr)) = formatPtr *(*uintptr)(unsafe.Pointer(imageFormatVersion3Ptr)) = formatVersion3Ptr *(*int32)(unsafe.Pointer(oldformat)) = useoldformat /* * Some stringMatchProc might have left error messages and error codes in * interp. Clear them before return. */ libtcl9_0.XTcl_ResetResult(tls, interp) return TCL_OK } /* *---------------------------------------------------------------------- * * Tk_FindPhoto -- * * This function is called to get an opaque handle (actually a * PhotoModel *) for a given image, which can be used in subsequent * calls to Tk_PhotoPutBlock, etc. The `name' parameter is the name of * the image. * * Results: * The handle for the photo image, or NULL if there is no photo image * with the name given. * * Side effects: * None. * *---------------------------------------------------------------------- */ func XTk_FindPhoto(tls *libc.TLS, interp uintptr, imageName uintptr) (r TTk_PhotoHandle) { bp := tls.Alloc(16) defer tls.Free(16) /* Name of the desired photo image. */ var clientData uintptr var _ /* typePtr at bp+0 */ uintptr _ = clientData clientData = XTk_GetImageModelData(tls, interp, imageName, bp) if *(*uintptr)(unsafe.Pointer(bp)) == libc.UintptrFromInt32(0) || (*TTk_ImageType)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp)))).Fname != XtkPhotoImageType.Fname { return libc.UintptrFromInt32(0) } return clientData } /* *---------------------------------------------------------------------- * * Tk_PhotoPutBlock -- * * This function is called to put image data into a photo image. * * Results: * A standard Tcl result code. * * Side effects: * The image data is stored. The image may be expanded. The Tk image code * is informed that the image has changed. If the result code is * TCL_ERROR, an error message will be placed in the interpreter (if * non-NULL). * *---------------------------------------------------------------------- */ func XTk_PhotoPutBlock(tls *libc.TLS, interp uintptr, handle TTk_PhotoHandle, blockPtr uintptr, x int32, y int32, width int32, height int32, compRule int32) (r int32) { bp := tls.Alloc(80) defer tls.Free(80) /* Compositing rule to use when processing * transparent pixels. */ var Alpha, alpha, alphaOffset, blueOffset, compRuleSet, greenOffset, hCopy, hLeft, pitch, pixelSize, sourceIsSimplePhoto, wCopy, wLeft, x1, xEnd, yEnd, v1, v2, v4, v7 int32 var cpyLen uint32 var destLinePtr, destPtr, memToFree, modelPtr, srcLinePtr, srcPtr, v10, v11, v12, v14, v15, v16, v17, v19, v20, v21, v22, v9 uintptr var newAlpha uint8 var workRgn TRegion var _ /* rect at bp+40 */ TXRectangle var _ /* sourceBlock at bp+0 */ TTk_PhotoImageBlock _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = Alpha, alpha, alphaOffset, blueOffset, compRuleSet, cpyLen, destLinePtr, destPtr, greenOffset, hCopy, hLeft, memToFree, modelPtr, newAlpha, pitch, pixelSize, sourceIsSimplePhoto, srcLinePtr, srcPtr, wCopy, wLeft, workRgn, x1, xEnd, yEnd, v1, v10, v11, v12, v14, v15, v16, v17, v19, v2, v20, v21, v22, v4, v7, v9 modelPtr = handle sourceIsSimplePhoto = compRule & int32(SOURCE_IS_SIMPLE_ALPHA_PHOTO) /* * Zero-sized blocks never cause any changes. [Bug 3078902] */ if (*TTk_PhotoImageBlock)(unsafe.Pointer(blockPtr)).Fheight == 0 || (*TTk_PhotoImageBlock)(unsafe.Pointer(blockPtr)).Fwidth == 0 { return TCL_OK } compRule &= ^libc.Int32FromInt32(SOURCE_IS_SIMPLE_ALPHA_PHOTO) if (*TPhotoModel)(unsafe.Pointer(modelPtr)).FuserWidth != 0 && x+width > (*TPhotoModel)(unsafe.Pointer(modelPtr)).FuserWidth { width = (*TPhotoModel)(unsafe.Pointer(modelPtr)).FuserWidth - x } if (*TPhotoModel)(unsafe.Pointer(modelPtr)).FuserHeight != 0 && y+height > (*TPhotoModel)(unsafe.Pointer(modelPtr)).FuserHeight { height = (*TPhotoModel)(unsafe.Pointer(modelPtr)).FuserHeight - y } if width <= 0 || height <= 0 { return TCL_OK } /* * Fix for bug e4336bef5d: * * Make a local copy of *blockPtr, as we might have to change some * of its fields and don't want to interfere with the caller's data. * * If source and destination are the same image, create a copy of the * source data in our local sourceBlock. * * To find out, just comparing the pointers is not enough - they might have * different values and still point to the same block of memory. (e.g. * if the -from option was passed to [imageName copy]) */ *(*TTk_PhotoImageBlock)(unsafe.Pointer(bp)) = *(*TTk_PhotoImageBlock)(unsafe.Pointer(blockPtr)) memToFree = libc.UintptrFromInt32(0) if (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fpix32 != 0 && (*(*TTk_PhotoImageBlock)(unsafe.Pointer(bp))).FpixelPtr >= (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fpix32 && (*(*TTk_PhotoImageBlock)(unsafe.Pointer(bp))).FpixelPtr < (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fpix32+uintptr((*TPhotoModel)(unsafe.Pointer(modelPtr)).Fwidth*(*TPhotoModel)(unsafe.Pointer(modelPtr)).Fheight*int32(4)) { /* * Fix 5c51be6411: avoid reading * * (sourceBlock.pitch - sourceBlock.width * sourceBlock.pixelSize) * * bytes past the end of modelPtr->pix32[] when * * blockPtr->pixelPtr > (modelPtr->pix32 + * 4 * modelPtr->width * modelPtr->height - * sourceBlock.height * sourceBlock.pitch) */ cpyLen = libc.Uint32FromInt32(((*(*TTk_PhotoImageBlock)(unsafe.Pointer(bp))).Fheight-int32(1))*(*(*TTk_PhotoImageBlock)(unsafe.Pointer(bp))).Fpitch + (*(*TTk_PhotoImageBlock)(unsafe.Pointer(bp))).Fwidth*(*(*TTk_PhotoImageBlock)(unsafe.Pointer(bp))).FpixelSize) (*(*TTk_PhotoImageBlock)(unsafe.Pointer(bp))).FpixelPtr = libtcl9_0.XTcl_AttemptAlloc(tls, uint64(cpyLen)) if (*(*TTk_PhotoImageBlock)(unsafe.Pointer(bp))).FpixelPtr == libc.UintptrFromInt32(0) { if interp != libc.UintptrFromInt32(0) { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+37506, int64(-libc.Int32FromInt32(1)))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+56, __ccgo_ts+179, __ccgo_ts+36356, libc.UintptrFromInt32(0))) } return int32(TCL_ERROR) } memToFree = (*(*TTk_PhotoImageBlock)(unsafe.Pointer(bp))).FpixelPtr libc.Xmemcpy(tls, (*(*TTk_PhotoImageBlock)(unsafe.Pointer(bp))).FpixelPtr, (*TTk_PhotoImageBlock)(unsafe.Pointer(blockPtr)).FpixelPtr, uint64(cpyLen)) } xEnd = x + width yEnd = y + height if xEnd > (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fwidth || yEnd > (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fheight { if xEnd > (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fwidth { v1 = xEnd } else { v1 = (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fwidth } if yEnd > (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fheight { v2 = yEnd } else { v2 = (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fheight } if _ImgPhotoSetSize(tls, modelPtr, v1, v2) == int32(TCL_ERROR) { if interp != libc.UintptrFromInt32(0) { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+37506, int64(-libc.Int32FromInt32(1)))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+56, __ccgo_ts+179, __ccgo_ts+36356, libc.UintptrFromInt32(0))) } goto errorExit } } if y < (*TPhotoModel)(unsafe.Pointer(modelPtr)).FditherY || y == (*TPhotoModel)(unsafe.Pointer(modelPtr)).FditherY && x < (*TPhotoModel)(unsafe.Pointer(modelPtr)).FditherX { /* * The dithering isn't correct past the start of this block. */ (*TPhotoModel)(unsafe.Pointer(modelPtr)).FditherX = x (*TPhotoModel)(unsafe.Pointer(modelPtr)).FditherY = y } /* * If this image block could have different red, green and blue * components, mark it as a color image. */ greenOffset = *(*int32)(unsafe.Pointer(bp + 24 + 1*4)) - *(*int32)(unsafe.Pointer(bp + 24)) blueOffset = *(*int32)(unsafe.Pointer(bp + 24 + 2*4)) - *(*int32)(unsafe.Pointer(bp + 24)) alphaOffset = *(*int32)(unsafe.Pointer(bp + 24 + 3*4)) if alphaOffset >= (*(*TTk_PhotoImageBlock)(unsafe.Pointer(bp))).FpixelSize || alphaOffset < 0 { alphaOffset = 0 sourceIsSimplePhoto = int32(1) } else { alphaOffset -= *(*int32)(unsafe.Pointer(bp + 24)) } if greenOffset != 0 || blueOffset != 0 { *(*int32)(unsafe.Pointer(modelPtr + 24)) |= int32(COLOR_IMAGE) } /* * Copy the data into our local 32-bit/pixel array. If we can do it with a * single memmove, we do. */ destLinePtr = (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fpix32 + uintptr((y*(*TPhotoModel)(unsafe.Pointer(modelPtr)).Fwidth+x)*int32(4)) pitch = (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fwidth * int32(4) /* * Test to see if we can do the whole write in a single copy. This test is * probably too restrictive. We should also be able to do a memmove if * pixelSize == 3 and alphaOffset == 0. Maybe other cases too. */ if (*(*TTk_PhotoImageBlock)(unsafe.Pointer(bp))).FpixelSize == int32(4) && greenOffset == int32(1) && blueOffset == int32(2) && alphaOffset == int32(3) && width <= (*(*TTk_PhotoImageBlock)(unsafe.Pointer(bp))).Fwidth && height <= (*(*TTk_PhotoImageBlock)(unsafe.Pointer(bp))).Fheight && (height == int32(1) || x == 0 && width == (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fwidth && (*(*TTk_PhotoImageBlock)(unsafe.Pointer(bp))).Fpitch == pitch) && compRule == int32(TK_PHOTO_COMPOSITE_SET) { libc.Xmemmove(tls, destLinePtr, (*(*TTk_PhotoImageBlock)(unsafe.Pointer(bp))).FpixelPtr+uintptr(*(*int32)(unsafe.Pointer(bp + 24))), libc.Uint64FromInt32(height)*libc.Uint64FromInt32(width)*libc.Uint64FromInt32(4)) /* * We know there's an alpha offset and we're setting the data, so skip * directly to the point when we recompute the photo validity region. */ goto recalculateValidRegion } /* * Copy and merge pixels according to the compositing rule. */ hLeft = height for { if !(hLeft > 0) { break } pixelSize = (*(*TTk_PhotoImageBlock)(unsafe.Pointer(bp))).FpixelSize compRuleSet = libc.BoolInt32(compRule == int32(TK_PHOTO_COMPOSITE_SET)) srcLinePtr = (*(*TTk_PhotoImageBlock)(unsafe.Pointer(bp))).FpixelPtr + uintptr(*(*int32)(unsafe.Pointer(bp + 24))) if hLeft < (*(*TTk_PhotoImageBlock)(unsafe.Pointer(bp))).Fheight { v4 = hLeft } else { v4 = (*(*TTk_PhotoImageBlock)(unsafe.Pointer(bp))).Fheight } hCopy = v4 hLeft -= hCopy for { if !(hCopy > 0) { break } /* * If the layout of the source line matches our memory layout and * we're setting, we can just copy the bytes directly, which is * much faster. */ if pixelSize == int32(4) && greenOffset == int32(1) && blueOffset == int32(2) && alphaOffset == int32(3) && width <= (*(*TTk_PhotoImageBlock)(unsafe.Pointer(bp))).Fwidth && compRuleSet != 0 { libc.Xmemcpy(tls, destLinePtr, srcLinePtr, libc.Uint64FromInt32(width)*libc.Uint64FromInt32(4)) srcLinePtr += uintptr((*(*TTk_PhotoImageBlock)(unsafe.Pointer(bp))).Fpitch) destLinePtr += uintptr(pitch) goto _5 } /* * Have to copy the slow way. */ destPtr = destLinePtr wLeft = width for { if !(wLeft > 0) { break } if wLeft < (*(*TTk_PhotoImageBlock)(unsafe.Pointer(bp))).Fwidth { v7 = wLeft } else { v7 = (*(*TTk_PhotoImageBlock)(unsafe.Pointer(bp))).Fwidth } wCopy = v7 wLeft -= wCopy srcPtr = srcLinePtr /* * But we might be lucky and be able to use fairly fast loops. * It's worth checking... */ if alphaOffset == 0 { /* * This is the non-alpha case, so can still be fairly * fast. Note that in the non-alpha-source case, the * compositing rule doesn't apply. */ for { if !(wCopy > 0) { break } v9 = destPtr destPtr++ *(*uint8)(unsafe.Pointer(v9)) = *(*uint8)(unsafe.Pointer(srcPtr)) v10 = destPtr destPtr++ *(*uint8)(unsafe.Pointer(v10)) = *(*uint8)(unsafe.Pointer(srcPtr + uintptr(greenOffset))) v11 = destPtr destPtr++ *(*uint8)(unsafe.Pointer(v11)) = *(*uint8)(unsafe.Pointer(srcPtr + uintptr(blueOffset))) v12 = destPtr destPtr++ *(*uint8)(unsafe.Pointer(v12)) = uint8(255) goto _8 _8: ; wCopy-- srcPtr += uintptr(pixelSize) } goto _6 } else { if compRuleSet != 0 { /* * This is the SET compositing rule, which just replaces * what was there before with the new data. This is * another fairly fast case. No point in doing a memcpy(); * the order of channels is probably wrong. */ for { if !(wCopy > 0) { break } v14 = destPtr destPtr++ *(*uint8)(unsafe.Pointer(v14)) = *(*uint8)(unsafe.Pointer(srcPtr)) v15 = destPtr destPtr++ *(*uint8)(unsafe.Pointer(v15)) = *(*uint8)(unsafe.Pointer(srcPtr + uintptr(greenOffset))) v16 = destPtr destPtr++ *(*uint8)(unsafe.Pointer(v16)) = *(*uint8)(unsafe.Pointer(srcPtr + uintptr(blueOffset))) v17 = destPtr destPtr++ *(*uint8)(unsafe.Pointer(v17)) = *(*uint8)(unsafe.Pointer(srcPtr + uintptr(alphaOffset))) goto _13 _13: ; wCopy-- srcPtr += uintptr(pixelSize) } goto _6 } } /* * Bother; need to consider the alpha value of each pixel to * know what to do. */ for { if !(wCopy > 0) { break } alpha = libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(srcPtr + uintptr(alphaOffset)))) if alpha == int32(255) || !(*(*uint8)(unsafe.Pointer(destPtr + 3)) != 0) { /* * Either the source is 100% opaque, or the * destination is entirely blank. In all cases, we * just set the destination to the source. */ v19 = destPtr destPtr++ *(*uint8)(unsafe.Pointer(v19)) = *(*uint8)(unsafe.Pointer(srcPtr)) v20 = destPtr destPtr++ *(*uint8)(unsafe.Pointer(v20)) = *(*uint8)(unsafe.Pointer(srcPtr + uintptr(greenOffset))) v21 = destPtr destPtr++ *(*uint8)(unsafe.Pointer(v21)) = *(*uint8)(unsafe.Pointer(srcPtr + uintptr(blueOffset))) v22 = destPtr destPtr++ *(*uint8)(unsafe.Pointer(v22)) = libc.Uint8FromInt32(alpha) goto _18 } /* * Can still skip doing work if the source is 100% * transparent at this point. */ if alpha != 0 { Alpha = libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(destPtr + 3))) /* * OK, there's real work to be done. Luckily, there's * a substantial literature on what to do in this * case. In particular, Porter and Duff have done a * taxonomy of compositing rules, and the right one is * the "Source Over" rule. This code implements that. */ *(*uint8)(unsafe.Pointer(destPtr)) = libc.Uint8FromInt32(libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(srcPtr)))*alpha/int32(255) + Alpha*(int32(255)-alpha)/int32(255)*libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(destPtr)))/int32(255)) *(*uint8)(unsafe.Pointer(destPtr + 1)) = libc.Uint8FromInt32(libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(srcPtr + uintptr(greenOffset))))*alpha/int32(255) + Alpha*(int32(255)-alpha)/int32(255)*libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(destPtr + 1)))/int32(255)) *(*uint8)(unsafe.Pointer(destPtr + 2)) = libc.Uint8FromInt32(libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(srcPtr + uintptr(blueOffset))))*alpha/int32(255) + Alpha*(int32(255)-alpha)/int32(255)*libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(destPtr + 2)))/int32(255)) *(*uint8)(unsafe.Pointer(destPtr + 3)) = libc.Uint8FromInt32(alpha + (libc.Int32FromInt32(255)-alpha)*Alpha/libc.Int32FromInt32(255)) } destPtr += uintptr(4) goto _18 _18: ; wCopy-- srcPtr += uintptr(pixelSize) } goto _6 _6: } srcLinePtr += uintptr((*(*TTk_PhotoImageBlock)(unsafe.Pointer(bp))).Fpitch) destLinePtr += uintptr(pitch) goto _5 _5: ; hCopy-- } goto _3 _3: } /* * Add this new block to the region which specifies which data is valid. */ if !(alphaOffset != 0) { goto _23 } /* * This block is grossly inefficient. For each row in the image, it * finds each contiguous string of nontransparent pixels, then marks * those areas as valid in the validRegion mask. This makes drawing * very efficient, because of the way we use X: we just say, here's * your mask, and here's your data. We need not worry about the * current background color, etc. But this costs us a lot on the image * setup. Still, image setup only happens once, whereas the drawing * happens many times, so this might be the best way to go. * * An alternative might be to not set up this mask, and instead, at * drawing time, for each transparent pixel, set its color to the * color of the background behind that pixel. This is what I suspect * most of programs do. However, they don't have to deal with the * canvas, which could have many different background colors. * Determining the correct bg color for a given pixel might be * expensive. */ if !(compRule != TK_PHOTO_COMPOSITE_OVERLAY) { goto _25 } /* * Don't need this when using the OVERLAY compositing rule, which * always strictly increases the valid region. */ goto recalculateValidRegion recalculateValidRegion: ; workRgn = libx11.XXCreateRegion(tls) (*(*TXRectangle)(unsafe.Pointer(bp + 40))).Fx = int16(x) (*(*TXRectangle)(unsafe.Pointer(bp + 40))).Fy = int16(y) (*(*TXRectangle)(unsafe.Pointer(bp + 40))).Fwidth = libc.Uint16FromInt32(width) (*(*TXRectangle)(unsafe.Pointer(bp + 40))).Fheight = libc.Uint16FromInt32(height) libx11.XXUnionRectWithRegion(tls, bp+40, workRgn, workRgn) libx11.XXSubtractRegion(tls, (*TPhotoModel)(unsafe.Pointer(modelPtr)).FvalidRegion, workRgn, (*TPhotoModel)(unsafe.Pointer(modelPtr)).FvalidRegion) libx11.XXDestroyRegion(tls, workRgn) _25: ; /* * Factorize out the main part of the building of the region data to * allow for more efficient per-platform implementations. [Bug 919066] */ XTkpBuildRegionFromAlphaData(tls, (*TPhotoModel)(unsafe.Pointer(modelPtr)).FvalidRegion, libc.Uint32FromInt32(x), libc.Uint32FromInt32(y), libc.Uint32FromInt32(width), libc.Uint32FromInt32(height), (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fpix32+uintptr((y*(*TPhotoModel)(unsafe.Pointer(modelPtr)).Fwidth+x)*int32(4))+uintptr(3), uint32(4), libc.Uint32FromInt32((*TPhotoModel)(unsafe.Pointer(modelPtr)).Fwidth)*uint32(4)) goto _24 _23: ; (*(*TXRectangle)(unsafe.Pointer(bp + 40))).Fx = int16(x) (*(*TXRectangle)(unsafe.Pointer(bp + 40))).Fy = int16(y) (*(*TXRectangle)(unsafe.Pointer(bp + 40))).Fwidth = libc.Uint16FromInt32(width) (*(*TXRectangle)(unsafe.Pointer(bp + 40))).Fheight = libc.Uint16FromInt32(height) libx11.XXUnionRectWithRegion(tls, bp+40, (*TPhotoModel)(unsafe.Pointer(modelPtr)).FvalidRegion, (*TPhotoModel)(unsafe.Pointer(modelPtr)).FvalidRegion) _24: ; /* * Check if display code needs alpha blending... */ if !(sourceIsSimplePhoto != 0) && height == int32(1) { /* * Optimize the single span case if we can. This speeds up code that * builds up large simple-alpha images by scan-lines or individual * pixels. We don't negate COMPLEX_ALPHA in this case. [Bug 1409140] * [Patch 1539990] */ if !((*TPhotoModel)(unsafe.Pointer(modelPtr)).Fflags&libc.Int32FromInt32(COMPLEX_ALPHA) != 0) { x1 = x for { if !(x1 < x+width) { break } destLinePtr = (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fpix32 + uintptr((y*(*TPhotoModel)(unsafe.Pointer(modelPtr)).Fwidth+x1)*int32(4)) newAlpha = *(*uint8)(unsafe.Pointer(destLinePtr + 3)) if newAlpha != 0 && libc.Int32FromUint8(newAlpha) != int32(255) { *(*int32)(unsafe.Pointer(modelPtr + 24)) |= int32(COMPLEX_ALPHA) break } goto _26 _26: ; x1++ } } } else { if alphaOffset != 0 || (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fflags&int32(COMPLEX_ALPHA) != 0 { /* * Check for partial transparency if alpha pixels are specified, or * rescan if we already knew such pixels existed. To restrict this * Toggle to only checking the changed pixels requires knowing where * the alpha pixels are. */ _ToggleComplexAlphaIfNeeded(tls, modelPtr) } } /* * Update each instance. */ XTk_DitherPhoto(tls, modelPtr, x, y, width, height) /* * Tell the core image code that this image has changed. */ XTk_ImageChanged(tls, (*TPhotoModel)(unsafe.Pointer(modelPtr)).FtkModel, x, y, width, height, (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fwidth, (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fheight) if memToFree != 0 { libtcl9_0.XTcl_Free(tls, memToFree) } return TCL_OK goto errorExit errorExit: ; if memToFree != 0 { libtcl9_0.XTcl_Free(tls, memToFree) } return int32(TCL_ERROR) } /* *---------------------------------------------------------------------- * * Tk_PhotoPutZoomedBlock -- * * This function is called to put image data into a photo image, with * possible subsampling and/or zooming of the pixels. * * Results: * None. * * Side effects: * The image data is stored. The image may be expanded. The Tk image code * is informed that the image has changed. * *---------------------------------------------------------------------- */ func XTk_PhotoPutZoomedBlock(tls *libc.TLS, interp uintptr, handle TTk_PhotoHandle, blockPtr uintptr, x int32, y int32, width int32, height int32, zoomX int32, zoomY int32, subsampleX int32, subsampleY int32, compRule int32) (r int32) { bp := tls.Alloc(80) defer tls.Free(80) /* Compositing rule to use when processing * transparent pixels. */ var Alpha, alpha, alphaOffset, blockHt, blockWid, blockXSkip, blockYSkip, blueOffset, greenOffset, hCopy, hLeft, pitch, sourceIsSimplePhoto, wCopy, wLeft, xEnd, xRepeat, yEnd, yRepeat, v1, v10, v2, v4, v7 int32 var cpyLen uint32 var destLinePtr, destPtr, memToFree, modelPtr, srcLinePtr, srcOrigPtr, srcPtr, v11, v12, v13, v14, v15, v16, v17, v18 uintptr var newAlpha uint8 var workRgn TRegion var _ /* rect at bp+40 */ TXRectangle var _ /* sourceBlock at bp+0 */ TTk_PhotoImageBlock _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = Alpha, alpha, alphaOffset, blockHt, blockWid, blockXSkip, blockYSkip, blueOffset, cpyLen, destLinePtr, destPtr, greenOffset, hCopy, hLeft, memToFree, modelPtr, newAlpha, pitch, sourceIsSimplePhoto, srcLinePtr, srcOrigPtr, srcPtr, wCopy, wLeft, workRgn, xEnd, xRepeat, yEnd, yRepeat, v1, v10, v11, v12, v13, v14, v15, v16, v17, v18, v2, v4, v7 modelPtr = handle /* * Zero-sized blocks never cause any changes. [Bug 3078902] */ if (*TTk_PhotoImageBlock)(unsafe.Pointer(blockPtr)).Fheight == 0 || (*TTk_PhotoImageBlock)(unsafe.Pointer(blockPtr)).Fwidth == 0 { return TCL_OK } if zoomX == int32(1) && zoomY == int32(1) && subsampleX == int32(1) && subsampleY == int32(1) { return XTk_PhotoPutBlock(tls, interp, handle, blockPtr, x, y, width, height, compRule) } sourceIsSimplePhoto = compRule & int32(SOURCE_IS_SIMPLE_ALPHA_PHOTO) compRule &= ^libc.Int32FromInt32(SOURCE_IS_SIMPLE_ALPHA_PHOTO) if zoomX <= 0 || zoomY <= 0 { return TCL_OK } if (*TPhotoModel)(unsafe.Pointer(modelPtr)).FuserWidth != 0 && x+width > (*TPhotoModel)(unsafe.Pointer(modelPtr)).FuserWidth { width = (*TPhotoModel)(unsafe.Pointer(modelPtr)).FuserWidth - x } if (*TPhotoModel)(unsafe.Pointer(modelPtr)).FuserHeight != 0 && y+height > (*TPhotoModel)(unsafe.Pointer(modelPtr)).FuserHeight { height = (*TPhotoModel)(unsafe.Pointer(modelPtr)).FuserHeight - y } if width <= 0 || height <= 0 { return TCL_OK } /* * Fix for Bug e4336bef5d: * Make a local copy of *blockPtr, as we might have to change some * of its fields and don't want to interfere with the caller's data. * * If source and destination are the same image, create a copy of the * source data in our local sourceBlock. * * To find out, just comparing the pointers is not enough - they might have * different values and still point to the same block of memory. (e.g. * if the -from option was passed to [imageName copy]) */ *(*TTk_PhotoImageBlock)(unsafe.Pointer(bp)) = *(*TTk_PhotoImageBlock)(unsafe.Pointer(blockPtr)) memToFree = libc.UintptrFromInt32(0) if (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fpix32 != 0 && (*(*TTk_PhotoImageBlock)(unsafe.Pointer(bp))).FpixelPtr >= (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fpix32 && (*(*TTk_PhotoImageBlock)(unsafe.Pointer(bp))).FpixelPtr < (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fpix32+uintptr((*TPhotoModel)(unsafe.Pointer(modelPtr)).Fwidth*(*TPhotoModel)(unsafe.Pointer(modelPtr)).Fheight*int32(4)) { /* * Fix 5c51be6411: avoid reading * * (sourceBlock.pitch - sourceBlock.width * sourceBlock.pixelSize) * * bytes past the end of modelPtr->pix32[] when * * blockPtr->pixelPtr > (modelPtr->pix32 + * 4 * modelPtr->width * modelPtr->height - * sourceBlock.height * sourceBlock.pitch) */ cpyLen = libc.Uint32FromInt32(((*(*TTk_PhotoImageBlock)(unsafe.Pointer(bp))).Fheight-int32(1))*(*(*TTk_PhotoImageBlock)(unsafe.Pointer(bp))).Fpitch + (*(*TTk_PhotoImageBlock)(unsafe.Pointer(bp))).Fwidth*(*(*TTk_PhotoImageBlock)(unsafe.Pointer(bp))).FpixelSize) (*(*TTk_PhotoImageBlock)(unsafe.Pointer(bp))).FpixelPtr = libtcl9_0.XTcl_AttemptAlloc(tls, uint64(cpyLen)) if (*(*TTk_PhotoImageBlock)(unsafe.Pointer(bp))).FpixelPtr == libc.UintptrFromInt32(0) { if interp != libc.UintptrFromInt32(0) { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+37506, int64(-libc.Int32FromInt32(1)))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+56, __ccgo_ts+179, __ccgo_ts+36356, libc.UintptrFromInt32(0))) } return int32(TCL_ERROR) } memToFree = (*(*TTk_PhotoImageBlock)(unsafe.Pointer(bp))).FpixelPtr libc.Xmemcpy(tls, (*(*TTk_PhotoImageBlock)(unsafe.Pointer(bp))).FpixelPtr, (*TTk_PhotoImageBlock)(unsafe.Pointer(blockPtr)).FpixelPtr, uint64(cpyLen)) } xEnd = x + width yEnd = y + height if xEnd > (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fwidth || yEnd > (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fheight { if xEnd > (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fwidth { v1 = xEnd } else { v1 = (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fwidth } if yEnd > (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fheight { v2 = yEnd } else { v2 = (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fheight } if _ImgPhotoSetSize(tls, modelPtr, v1, v2) == int32(TCL_ERROR) { if interp != libc.UintptrFromInt32(0) { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+37506, int64(-libc.Int32FromInt32(1)))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+56, __ccgo_ts+179, __ccgo_ts+36356, libc.UintptrFromInt32(0))) } goto errorExit } } if y < (*TPhotoModel)(unsafe.Pointer(modelPtr)).FditherY || y == (*TPhotoModel)(unsafe.Pointer(modelPtr)).FditherY && x < (*TPhotoModel)(unsafe.Pointer(modelPtr)).FditherX { /* * The dithering isn't correct past the start of this block. */ (*TPhotoModel)(unsafe.Pointer(modelPtr)).FditherX = x (*TPhotoModel)(unsafe.Pointer(modelPtr)).FditherY = y } /* * If this image block could have different red, green and blue * components, mark it as a color image. */ greenOffset = *(*int32)(unsafe.Pointer(bp + 24 + 1*4)) - *(*int32)(unsafe.Pointer(bp + 24)) blueOffset = *(*int32)(unsafe.Pointer(bp + 24 + 2*4)) - *(*int32)(unsafe.Pointer(bp + 24)) alphaOffset = *(*int32)(unsafe.Pointer(bp + 24 + 3*4)) if alphaOffset >= (*(*TTk_PhotoImageBlock)(unsafe.Pointer(bp))).FpixelSize || alphaOffset < 0 { alphaOffset = 0 sourceIsSimplePhoto = int32(1) } else { alphaOffset -= *(*int32)(unsafe.Pointer(bp + 24)) } if greenOffset != 0 || blueOffset != 0 { *(*int32)(unsafe.Pointer(modelPtr + 24)) |= int32(COLOR_IMAGE) } /* * Work out what area the pixel data in the block expands to after * subsampling and zooming. */ blockXSkip = subsampleX * (*(*TTk_PhotoImageBlock)(unsafe.Pointer(bp))).FpixelSize blockYSkip = subsampleY * (*(*TTk_PhotoImageBlock)(unsafe.Pointer(bp))).Fpitch if subsampleX > 0 { blockWid = ((*(*TTk_PhotoImageBlock)(unsafe.Pointer(bp))).Fwidth + subsampleX - int32(1)) / subsampleX * zoomX } else { if subsampleX == 0 { blockWid = width } else { blockWid = ((*(*TTk_PhotoImageBlock)(unsafe.Pointer(bp))).Fwidth - subsampleX - int32(1)) / -subsampleX * zoomX } } if subsampleY > 0 { blockHt = ((*(*TTk_PhotoImageBlock)(unsafe.Pointer(bp))).Fheight + subsampleY - int32(1)) / subsampleY * zoomY } else { if subsampleY == 0 { blockHt = height } else { blockHt = ((*(*TTk_PhotoImageBlock)(unsafe.Pointer(bp))).Fheight - subsampleY - int32(1)) / -subsampleY * zoomY } } /* * Copy the data into our local 32-bit/pixel array. */ destLinePtr = (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fpix32 + uintptr((y*(*TPhotoModel)(unsafe.Pointer(modelPtr)).Fwidth+x)*int32(4)) srcOrigPtr = (*(*TTk_PhotoImageBlock)(unsafe.Pointer(bp))).FpixelPtr + uintptr(*(*int32)(unsafe.Pointer(bp + 24))) if subsampleX < 0 { srcOrigPtr += uintptr(((*(*TTk_PhotoImageBlock)(unsafe.Pointer(bp))).Fwidth - int32(1)) * (*(*TTk_PhotoImageBlock)(unsafe.Pointer(bp))).FpixelSize) } if subsampleY < 0 { srcOrigPtr += uintptr(((*(*TTk_PhotoImageBlock)(unsafe.Pointer(bp))).Fheight - int32(1)) * (*(*TTk_PhotoImageBlock)(unsafe.Pointer(bp))).Fpitch) } pitch = (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fwidth * int32(4) hLeft = height for { if !(hLeft > 0) { break } if hLeft < blockHt { v4 = hLeft } else { v4 = blockHt } hCopy = v4 hLeft -= hCopy yRepeat = zoomY srcLinePtr = srcOrigPtr for { if !(hCopy > 0) { break } destPtr = destLinePtr wLeft = width for { if !(wLeft > 0) { break } if wLeft < blockWid { v7 = wLeft } else { v7 = blockWid } wCopy = v7 wLeft -= wCopy srcPtr = srcLinePtr for { if !(wCopy > 0) { break } if wCopy < zoomX { v10 = wCopy } else { v10 = zoomX } xRepeat = v10 for { if !(xRepeat > 0) { break } alpha = libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(srcPtr + uintptr(alphaOffset)))) /* Source alpha. */ /* * Common case (solid pixels) first */ if !(alphaOffset != 0) || alpha == int32(255) { v11 = destPtr destPtr++ *(*uint8)(unsafe.Pointer(v11)) = *(*uint8)(unsafe.Pointer(srcPtr)) v12 = destPtr destPtr++ *(*uint8)(unsafe.Pointer(v12)) = *(*uint8)(unsafe.Pointer(srcPtr + uintptr(greenOffset))) v13 = destPtr destPtr++ *(*uint8)(unsafe.Pointer(v13)) = *(*uint8)(unsafe.Pointer(srcPtr + uintptr(blueOffset))) v14 = destPtr destPtr++ *(*uint8)(unsafe.Pointer(v14)) = uint8(255) goto _9 } if compRule == int32(TK_PHOTO_COMPOSITE_SET) || !(*(*uint8)(unsafe.Pointer(destPtr + 3)) != 0) { /* * Either this is the SET rule (we overwrite * whatever is there) or the destination is * entirely blank. In both cases, we just set the * destination to the source. */ v15 = destPtr destPtr++ *(*uint8)(unsafe.Pointer(v15)) = *(*uint8)(unsafe.Pointer(srcPtr)) v16 = destPtr destPtr++ *(*uint8)(unsafe.Pointer(v16)) = *(*uint8)(unsafe.Pointer(srcPtr + uintptr(greenOffset))) v17 = destPtr destPtr++ *(*uint8)(unsafe.Pointer(v17)) = *(*uint8)(unsafe.Pointer(srcPtr + uintptr(blueOffset))) v18 = destPtr destPtr++ *(*uint8)(unsafe.Pointer(v18)) = libc.Uint8FromInt32(alpha) } else { if alpha != 0 { Alpha = libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(destPtr + 3))) /* Destination * alpha. */ *(*uint8)(unsafe.Pointer(destPtr)) = libc.Uint8FromInt32(libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(srcPtr)))*alpha/int32(255) + Alpha*(int32(255)-alpha)/int32(255)*libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(destPtr)))/int32(255)) *(*uint8)(unsafe.Pointer(destPtr + 1)) = libc.Uint8FromInt32(libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(srcPtr + uintptr(greenOffset))))*alpha/int32(255) + Alpha*(int32(255)-alpha)/int32(255)*libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(destPtr + 1)))/int32(255)) *(*uint8)(unsafe.Pointer(destPtr + 2)) = libc.Uint8FromInt32(libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(srcPtr + uintptr(blueOffset))))*alpha/int32(255) + Alpha*(int32(255)-alpha)/int32(255)*libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(destPtr + 2)))/int32(255)) *(*uint8)(unsafe.Pointer(destPtr + 3)) = libc.Uint8FromInt32(alpha + (libc.Int32FromInt32(255)-alpha)*Alpha/libc.Int32FromInt32(255)) destPtr += uintptr(4) } else { destPtr += uintptr(4) } } goto _9 _9: ; xRepeat-- } srcPtr += uintptr(blockXSkip) goto _8 _8: ; wCopy -= zoomX } goto _6 _6: } destLinePtr += uintptr(pitch) yRepeat-- if yRepeat <= 0 { srcLinePtr += uintptr(blockYSkip) yRepeat = zoomY } goto _5 _5: ; hCopy-- } goto _3 _3: } /* * Recompute the region of data for which we have valid pixels to plot. */ if alphaOffset != 0 { if compRule != TK_PHOTO_COMPOSITE_OVERLAY { /* * Don't need this when using the OVERLAY compositing rule, which * always strictly increases the valid region. */ workRgn = libx11.XXCreateRegion(tls) (*(*TXRectangle)(unsafe.Pointer(bp + 40))).Fx = int16(x) (*(*TXRectangle)(unsafe.Pointer(bp + 40))).Fy = int16(y) (*(*TXRectangle)(unsafe.Pointer(bp + 40))).Fwidth = libc.Uint16FromInt32(width) (*(*TXRectangle)(unsafe.Pointer(bp + 40))).Fheight = uint16(1) libx11.XXUnionRectWithRegion(tls, bp+40, workRgn, workRgn) libx11.XXSubtractRegion(tls, (*TPhotoModel)(unsafe.Pointer(modelPtr)).FvalidRegion, workRgn, (*TPhotoModel)(unsafe.Pointer(modelPtr)).FvalidRegion) libx11.XXDestroyRegion(tls, workRgn) } XTkpBuildRegionFromAlphaData(tls, (*TPhotoModel)(unsafe.Pointer(modelPtr)).FvalidRegion, libc.Uint32FromInt32(x), libc.Uint32FromInt32(y), libc.Uint32FromInt32(width), libc.Uint32FromInt32(height), (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fpix32+uintptr((y*(*TPhotoModel)(unsafe.Pointer(modelPtr)).Fwidth+x)*int32(4)+int32(3)), uint32(4), libc.Uint32FromInt32((*TPhotoModel)(unsafe.Pointer(modelPtr)).Fwidth)*uint32(4)) } else { (*(*TXRectangle)(unsafe.Pointer(bp + 40))).Fx = int16(x) (*(*TXRectangle)(unsafe.Pointer(bp + 40))).Fy = int16(y) (*(*TXRectangle)(unsafe.Pointer(bp + 40))).Fwidth = libc.Uint16FromInt32(width) (*(*TXRectangle)(unsafe.Pointer(bp + 40))).Fheight = libc.Uint16FromInt32(height) libx11.XXUnionRectWithRegion(tls, bp+40, (*TPhotoModel)(unsafe.Pointer(modelPtr)).FvalidRegion, (*TPhotoModel)(unsafe.Pointer(modelPtr)).FvalidRegion) } /* * Check if display code needs alpha blending... */ if !(sourceIsSimplePhoto != 0) && width == int32(1) && height == int32(1) { /* * Optimize the single pixel case if we can. This speeds up code that * builds up large simple-alpha images by single pixels. We don't * negate COMPLEX_ALPHA in this case. [Bug 1409140] */ if !((*TPhotoModel)(unsafe.Pointer(modelPtr)).Fflags&libc.Int32FromInt32(COMPLEX_ALPHA) != 0) { destLinePtr = (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fpix32 + uintptr((y*(*TPhotoModel)(unsafe.Pointer(modelPtr)).Fwidth+x)*int32(4)) newAlpha = *(*uint8)(unsafe.Pointer(destLinePtr + 3)) if newAlpha != 0 && libc.Int32FromUint8(newAlpha) != int32(255) { *(*int32)(unsafe.Pointer(modelPtr + 24)) |= int32(COMPLEX_ALPHA) } } } else { if alphaOffset != 0 || (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fflags&int32(COMPLEX_ALPHA) != 0 { /* * Check for partial transparency if alpha pixels are specified, or * rescan if we already knew such pixels existed. To restrict this * Toggle to only checking the changed pixels requires knowing where * the alpha pixels are. */ _ToggleComplexAlphaIfNeeded(tls, modelPtr) } } /* * Update each instance. */ XTk_DitherPhoto(tls, modelPtr, x, y, width, height) /* * Tell the core image code that this image has changed. */ XTk_ImageChanged(tls, (*TPhotoModel)(unsafe.Pointer(modelPtr)).FtkModel, x, y, width, height, (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fwidth, (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fheight) if memToFree != 0 { libtcl9_0.XTcl_Free(tls, memToFree) } return TCL_OK goto errorExit errorExit: ; if memToFree != 0 { libtcl9_0.XTcl_Free(tls, memToFree) } return int32(TCL_ERROR) } /* *---------------------------------------------------------------------- * * Tk_DitherPhoto -- * * This function is called to update an area of each instance's pixmap by * dithering the corresponding area of the image model. * * Results: * None. * * Side effects: * The pixmap of each instance of this image gets updated. The fields in * *modelPtr indicating which area of the image is correctly dithered * get updated. * *---------------------------------------------------------------------- */ func XTk_DitherPhoto(tls *libc.TLS, photo TTk_PhotoHandle, x int32, y int32, width int32, height int32) { /* Dimensions of the area to be dithered. */ var instancePtr, modelPtr uintptr _, _ = instancePtr, modelPtr modelPtr = photo if width <= 0 || height <= 0 { return } instancePtr = (*TPhotoModel)(unsafe.Pointer(modelPtr)).FinstancePtr for { if !(instancePtr != libc.UintptrFromInt32(0)) { break } XTkImgDitherInstance(tls, instancePtr, x, y, width, height) goto _1 _1: ; instancePtr = (*TPhotoInstance)(unsafe.Pointer(instancePtr)).FnextPtr } /* * Work out whether this block will be correctly dithered and whether it * will extend the correctly dithered region. */ if (y < (*TPhotoModel)(unsafe.Pointer(modelPtr)).FditherY || y == (*TPhotoModel)(unsafe.Pointer(modelPtr)).FditherY && x <= (*TPhotoModel)(unsafe.Pointer(modelPtr)).FditherX) && y+height > (*TPhotoModel)(unsafe.Pointer(modelPtr)).FditherY { /* * This block starts inside (or immediately after) the correctly * dithered region, so the first scan line at least will be right. * Furthermore this block extends into scanline modelPtr->ditherY. */ if x == 0 && width == (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fwidth { /* * We are doing the full width, therefore the dithering will be * correct to the end. */ (*TPhotoModel)(unsafe.Pointer(modelPtr)).FditherX = 0 (*TPhotoModel)(unsafe.Pointer(modelPtr)).FditherY = y + height } else { /* * We are doing partial scanlines, therefore the * correctly-dithered region will be extended by at most one scan * line. */ if x <= (*TPhotoModel)(unsafe.Pointer(modelPtr)).FditherX { (*TPhotoModel)(unsafe.Pointer(modelPtr)).FditherX = x + width if (*TPhotoModel)(unsafe.Pointer(modelPtr)).FditherX >= (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fwidth { (*TPhotoModel)(unsafe.Pointer(modelPtr)).FditherX = 0 (*TPhotoModel)(unsafe.Pointer(modelPtr)).FditherY++ } } } } } /* *---------------------------------------------------------------------- * * Tk_PhotoBlank -- * * This function is called to clear an entire photo image. * * Results: * None. * * Side effects: * The valid region for the image is set to the null region. The generic * image code is notified that the image has changed. * *---------------------------------------------------------------------- */ func XTk_PhotoBlank(tls *libc.TLS, handle TTk_PhotoHandle) { /* Handle for the image to be blanked. */ var instancePtr, modelPtr uintptr var v1 int32 _, _, _ = instancePtr, modelPtr, v1 modelPtr = handle v1 = libc.Int32FromInt32(0) (*TPhotoModel)(unsafe.Pointer(modelPtr)).FditherY = v1 (*TPhotoModel)(unsafe.Pointer(modelPtr)).FditherX = v1 (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fflags = 0 /* * The image has valid data nowhere. */ if (*TPhotoModel)(unsafe.Pointer(modelPtr)).FvalidRegion != libc.UintptrFromInt32(0) { libx11.XXDestroyRegion(tls, (*TPhotoModel)(unsafe.Pointer(modelPtr)).FvalidRegion) } (*TPhotoModel)(unsafe.Pointer(modelPtr)).FvalidRegion = libx11.XXCreateRegion(tls) /* * Clear out the 32-bit pixel storage array. Clear out the dithering error * arrays for each instance. */ if (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fpix32 != 0 { libc.Xmemset(tls, (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fpix32, 0, libc.Uint64FromInt32((*TPhotoModel)(unsafe.Pointer(modelPtr)).Fwidth)*libc.Uint64FromInt32((*TPhotoModel)(unsafe.Pointer(modelPtr)).Fheight)*libc.Uint64FromInt32(4)) } instancePtr = (*TPhotoModel)(unsafe.Pointer(modelPtr)).FinstancePtr for { if !(instancePtr != libc.UintptrFromInt32(0)) { break } XTkImgResetDither(tls, instancePtr) goto _2 _2: ; instancePtr = (*TPhotoInstance)(unsafe.Pointer(instancePtr)).FnextPtr } /* * Tell the core image code that this image has changed. */ XTk_ImageChanged(tls, (*TPhotoModel)(unsafe.Pointer(modelPtr)).FtkModel, 0, 0, (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fwidth, (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fheight, (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fwidth, (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fheight) } /* *---------------------------------------------------------------------- * * Tk_PhotoExpand -- * * This function is called to request that a photo image be expanded if * necessary to be at least `width' pixels wide and `height' pixels high. * If the user has declared a definite image size (using the -width and * -height configuration options) then this call has no effect. * * Results: * None. * * Side effects: * The size of the photo image may change; if so the generic image code * is informed. * *---------------------------------------------------------------------- */ func XTk_PhotoExpand(tls *libc.TLS, interp uintptr, handle TTk_PhotoHandle, width int32, height int32) (r int32) { bp := tls.Alloc(32) defer tls.Free(32) /* Desired minimum dimensions of the image. */ var modelPtr uintptr var v1, v2 int32 _, _, _ = modelPtr, v1, v2 modelPtr = handle if width <= (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fwidth { width = (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fwidth } if height <= (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fheight { height = (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fheight } if width != (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fwidth || height != (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fheight { if width > (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fwidth { v1 = width } else { v1 = (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fwidth } if height > (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fheight { v2 = height } else { v2 = (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fheight } if _ImgPhotoSetSize(tls, modelPtr, v1, v2) == int32(TCL_ERROR) { if interp != libc.UintptrFromInt32(0) { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+37506, int64(-libc.Int32FromInt32(1)))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+8, __ccgo_ts+179, __ccgo_ts+36356, libc.UintptrFromInt32(0))) } return int32(TCL_ERROR) } XTk_ImageChanged(tls, (*TPhotoModel)(unsafe.Pointer(modelPtr)).FtkModel, 0, 0, 0, 0, (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fwidth, (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fheight) } return TCL_OK } /* *---------------------------------------------------------------------- * * Tk_PhotoGetSize -- * * This function is called to obtain the current size of a photo image. * * Results: * The image's width and height are returned in *widthp and *heightp. * * Side effects: * None. * *---------------------------------------------------------------------- */ func XTk_PhotoGetSize(tls *libc.TLS, handle TTk_PhotoHandle, widthPtr uintptr, heightPtr uintptr) { /* The dimensions of the image are returned * here. */ var modelPtr uintptr _ = modelPtr modelPtr = handle *(*int32)(unsafe.Pointer(widthPtr)) = (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fwidth *(*int32)(unsafe.Pointer(heightPtr)) = (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fheight } /* *---------------------------------------------------------------------- * * Tk_PhotoSetSize -- * * This function is called to set size of a photo image. This call is * equivalent to using the -width and -height configuration options. * * Results: * None. * * Side effects: * The size of the image may change; if so the generic image code is * informed. * *---------------------------------------------------------------------- */ func XTk_PhotoSetSize(tls *libc.TLS, interp uintptr, handle TTk_PhotoHandle, width int32, height int32) (r int32) { bp := tls.Alloc(32) defer tls.Free(32) /* New dimensions for the image. */ var modelPtr uintptr var v1, v2 int32 _, _, _ = modelPtr, v1, v2 modelPtr = handle (*TPhotoModel)(unsafe.Pointer(modelPtr)).FuserWidth = width (*TPhotoModel)(unsafe.Pointer(modelPtr)).FuserHeight = height if width > 0 { v1 = width } else { v1 = (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fwidth } if height > 0 { v2 = height } else { v2 = (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fheight } if _ImgPhotoSetSize(tls, modelPtr, v1, v2) == int32(TCL_ERROR) { if interp != libc.UintptrFromInt32(0) { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+37506, int64(-libc.Int32FromInt32(1)))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+8, __ccgo_ts+179, __ccgo_ts+36356, libc.UintptrFromInt32(0))) } return int32(TCL_ERROR) } XTk_ImageChanged(tls, (*TPhotoModel)(unsafe.Pointer(modelPtr)).FtkModel, 0, 0, 0, 0, (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fwidth, (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fheight) return TCL_OK } /* *---------------------------------------------------------------------- * * TkGetPhotoValidRegion -- * * This function is called to get the part of the photo where there is * valid data. Or, conversely, the part of the photo which is * transparent. * * Results: * A TkRegion value that indicates the current area of the photo that is * valid. This value should not be used after any modification to the * photo image. * * Side Effects: * None. * *---------------------------------------------------------------------- */ func XTkPhotoGetValidRegion(tls *libc.TLS, handle TTk_PhotoHandle) (r TRegion) { /* Handle for the image whose valid region is * to obtained. */ var modelPtr uintptr _ = modelPtr modelPtr = handle return (*TPhotoModel)(unsafe.Pointer(modelPtr)).FvalidRegion } /* *---------------------------------------------------------------------- * * ImgGetPhoto -- * * This function is called to obtain image data from a photo image. This * function fills in the Tk_PhotoImageBlock structure pointed to by * `blockPtr' with details of the address and layout of the image data in * memory. * * Results: * A pointer to the allocated data which should be freed later. NULL if * there is no need to free data because blockPtr->pixelPtr points * directly to the image data. * * Side effects: * None. * *---------------------------------------------------------------------- */ func _ImgGetPhoto(tls *libc.TLS, modelPtr uintptr, blockPtr uintptr, optPtr uintptr) (r uintptr) { var alphaOffset, blue, blueOffset, gray, green, greenOffset, newPixelSize, red, x, y, v1, v4 int32 var data, destPtr, pixelPtr, srcPtr, p13, p14, p15, p18 uintptr _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = alphaOffset, blue, blueOffset, data, destPtr, gray, green, greenOffset, newPixelSize, pixelPtr, red, srcPtr, x, y, v1, v4, p13, p14, p15, p18 XTk_PhotoGetImage(tls, modelPtr, blockPtr) *(*uintptr)(unsafe.Pointer(blockPtr)) += uintptr((*TSubcommandOptions)(unsafe.Pointer(optPtr)).FfromY*(*TTk_PhotoImageBlock)(unsafe.Pointer(blockPtr)).Fpitch + (*TSubcommandOptions)(unsafe.Pointer(optPtr)).FfromX*(*TTk_PhotoImageBlock)(unsafe.Pointer(blockPtr)).FpixelSize) (*TTk_PhotoImageBlock)(unsafe.Pointer(blockPtr)).Fwidth = (*TSubcommandOptions)(unsafe.Pointer(optPtr)).FfromX2 - (*TSubcommandOptions)(unsafe.Pointer(optPtr)).FfromX (*TTk_PhotoImageBlock)(unsafe.Pointer(blockPtr)).Fheight = (*TSubcommandOptions)(unsafe.Pointer(optPtr)).FfromY2 - (*TSubcommandOptions)(unsafe.Pointer(optPtr)).FfromY if !((*TPhotoModel)(unsafe.Pointer(modelPtr)).Fflags&libc.Int32FromInt32(COLOR_IMAGE) != 0) && (!((*TSubcommandOptions)(unsafe.Pointer(optPtr)).Foptions&libc.Int32FromInt32(OPT_BACKGROUND) != 0) || libc.Int32FromUint16((*TXColor)(unsafe.Pointer((*TSubcommandOptions)(unsafe.Pointer(optPtr)).Fbackground)).Fred) == libc.Int32FromUint16((*TXColor)(unsafe.Pointer((*TSubcommandOptions)(unsafe.Pointer(optPtr)).Fbackground)).Fgreen) && libc.Int32FromUint16((*TXColor)(unsafe.Pointer((*TSubcommandOptions)(unsafe.Pointer(optPtr)).Fbackground)).Fred) == libc.Int32FromUint16((*TXColor)(unsafe.Pointer((*TSubcommandOptions)(unsafe.Pointer(optPtr)).Fbackground)).Fblue)) { v1 = *(*int32)(unsafe.Pointer(blockPtr + 24 + 2*4)) *(*int32)(unsafe.Pointer(blockPtr + 24 + 1*4)) = v1 *(*int32)(unsafe.Pointer(blockPtr + 24)) = v1 } alphaOffset = 0 y = 0 for { if !(y < (*TTk_PhotoImageBlock)(unsafe.Pointer(blockPtr)).Fheight) { break } pixelPtr = (*TTk_PhotoImageBlock)(unsafe.Pointer(blockPtr)).FpixelPtr + uintptr(y*(*TTk_PhotoImageBlock)(unsafe.Pointer(blockPtr)).Fpitch) + uintptr((*TTk_PhotoImageBlock)(unsafe.Pointer(blockPtr)).FpixelSize) - uintptr(1) x = 0 for { if !(x < (*TTk_PhotoImageBlock)(unsafe.Pointer(blockPtr)).Fwidth) { break } if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(pixelPtr))) != int32(255) { alphaOffset = int32(3) break } pixelPtr += uintptr((*TTk_PhotoImageBlock)(unsafe.Pointer(blockPtr)).FpixelSize) goto _3 _3: ; x++ } if alphaOffset != 0 { break } goto _2 _2: ; y++ } if !(alphaOffset != 0) { *(*int32)(unsafe.Pointer(blockPtr + 24 + 3*4)) = -int32(1) /* Tell caller alpha need not be read */ } greenOffset = *(*int32)(unsafe.Pointer(blockPtr + 24 + 1*4)) - *(*int32)(unsafe.Pointer(blockPtr + 24)) blueOffset = *(*int32)(unsafe.Pointer(blockPtr + 24 + 2*4)) - *(*int32)(unsafe.Pointer(blockPtr + 24)) if (*TSubcommandOptions)(unsafe.Pointer(optPtr)).Foptions&int32(OPT_BACKGROUND) != 0 && alphaOffset != 0 || (*TSubcommandOptions)(unsafe.Pointer(optPtr)).Foptions&int32(OPT_GRAYSCALE) != 0 && (greenOffset != 0 || blueOffset != 0) { if !((*TSubcommandOptions)(unsafe.Pointer(optPtr)).Foptions&libc.Int32FromInt32(OPT_BACKGROUND) != 0) && alphaOffset != 0 { v4 = int32(2) } else { v4 = int32(1) } newPixelSize = v4 if (greenOffset != 0 || blueOffset != 0) && !((*TSubcommandOptions)(unsafe.Pointer(optPtr)).Foptions&libc.Int32FromInt32(OPT_GRAYSCALE) != 0) { newPixelSize += int32(2) } if (*TTk_PhotoImageBlock)(unsafe.Pointer(blockPtr)).Fheight > libc.Int32FromUint32(libc.Uint32FromUint32(0xffffffff)/libc.Uint32FromInt32(newPixelSize)/libc.Uint32FromInt32((*TTk_PhotoImageBlock)(unsafe.Pointer(blockPtr)).Fwidth)) { return libc.UintptrFromInt32(0) } data = libtcl9_0.XTcl_AttemptAlloc(tls, libc.Uint64FromInt32(newPixelSize*(*TTk_PhotoImageBlock)(unsafe.Pointer(blockPtr)).Fwidth*(*TTk_PhotoImageBlock)(unsafe.Pointer(blockPtr)).Fheight)) if data == libc.UintptrFromInt32(0) { return libc.UintptrFromInt32(0) } srcPtr = (*TTk_PhotoImageBlock)(unsafe.Pointer(blockPtr)).FpixelPtr + uintptr(*(*int32)(unsafe.Pointer(blockPtr + 24))) destPtr = data if !(greenOffset != 0) && !(blueOffset != 0) { y = (*TTk_PhotoImageBlock)(unsafe.Pointer(blockPtr)).Fheight for { if !(y > 0) { break } x = (*TTk_PhotoImageBlock)(unsafe.Pointer(blockPtr)).Fwidth for { if !(x > 0) { break } *(*uint8)(unsafe.Pointer(destPtr)) = *(*uint8)(unsafe.Pointer(srcPtr)) srcPtr += uintptr((*TTk_PhotoImageBlock)(unsafe.Pointer(blockPtr)).FpixelSize) destPtr += uintptr(newPixelSize) goto _6 _6: ; x-- } srcPtr += uintptr((*TTk_PhotoImageBlock)(unsafe.Pointer(blockPtr)).Fpitch - (*TTk_PhotoImageBlock)(unsafe.Pointer(blockPtr)).Fwidth*(*TTk_PhotoImageBlock)(unsafe.Pointer(blockPtr)).FpixelSize) goto _5 _5: ; y-- } } else { if (*TSubcommandOptions)(unsafe.Pointer(optPtr)).Foptions&int32(OPT_GRAYSCALE) != 0 { y = (*TTk_PhotoImageBlock)(unsafe.Pointer(blockPtr)).Fheight for { if !(y > 0) { break } x = (*TTk_PhotoImageBlock)(unsafe.Pointer(blockPtr)).Fwidth for { if !(x > 0) { break } *(*uint8)(unsafe.Pointer(destPtr)) = libc.Uint8FromInt32((libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(srcPtr)))*libc.Int32FromInt32(11) + libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(srcPtr + 1)))*libc.Int32FromInt32(16) + libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(srcPtr + 2)))*libc.Int32FromInt32(5) + libc.Int32FromInt32(16)) >> libc.Int32FromInt32(5)) srcPtr += uintptr((*TTk_PhotoImageBlock)(unsafe.Pointer(blockPtr)).FpixelSize) destPtr += uintptr(newPixelSize) goto _8 _8: ; x-- } srcPtr += uintptr((*TTk_PhotoImageBlock)(unsafe.Pointer(blockPtr)).Fpitch - (*TTk_PhotoImageBlock)(unsafe.Pointer(blockPtr)).Fwidth*(*TTk_PhotoImageBlock)(unsafe.Pointer(blockPtr)).FpixelSize) goto _7 _7: ; y-- } } else { y = (*TTk_PhotoImageBlock)(unsafe.Pointer(blockPtr)).Fheight for { if !(y > 0) { break } x = (*TTk_PhotoImageBlock)(unsafe.Pointer(blockPtr)).Fwidth for { if !(x > 0) { break } *(*uint8)(unsafe.Pointer(destPtr)) = *(*uint8)(unsafe.Pointer(srcPtr)) *(*uint8)(unsafe.Pointer(destPtr + 1)) = *(*uint8)(unsafe.Pointer(srcPtr + 1)) *(*uint8)(unsafe.Pointer(destPtr + 2)) = *(*uint8)(unsafe.Pointer(srcPtr + 2)) srcPtr += uintptr((*TTk_PhotoImageBlock)(unsafe.Pointer(blockPtr)).FpixelSize) destPtr += uintptr(newPixelSize) goto _10 _10: ; x-- } srcPtr += uintptr((*TTk_PhotoImageBlock)(unsafe.Pointer(blockPtr)).Fpitch - (*TTk_PhotoImageBlock)(unsafe.Pointer(blockPtr)).Fwidth*(*TTk_PhotoImageBlock)(unsafe.Pointer(blockPtr)).FpixelSize) goto _9 _9: ; y-- } } } srcPtr = (*TTk_PhotoImageBlock)(unsafe.Pointer(blockPtr)).FpixelPtr + uintptr(alphaOffset) destPtr = data if !(alphaOffset != 0) { /* * Nothing to be done. */ } else { if (*TSubcommandOptions)(unsafe.Pointer(optPtr)).Foptions&int32(OPT_BACKGROUND) != 0 { if newPixelSize > int32(2) { red = libc.Int32FromUint16((*TXColor)(unsafe.Pointer((*TSubcommandOptions)(unsafe.Pointer(optPtr)).Fbackground)).Fred) >> int32(8) green = libc.Int32FromUint16((*TXColor)(unsafe.Pointer((*TSubcommandOptions)(unsafe.Pointer(optPtr)).Fbackground)).Fgreen) >> int32(8) blue = libc.Int32FromUint16((*TXColor)(unsafe.Pointer((*TSubcommandOptions)(unsafe.Pointer(optPtr)).Fbackground)).Fblue) >> int32(8) y = (*TTk_PhotoImageBlock)(unsafe.Pointer(blockPtr)).Fheight for { if !(y > 0) { break } x = (*TTk_PhotoImageBlock)(unsafe.Pointer(blockPtr)).Fwidth for { if !(x > 0) { break } p13 = destPtr *(*uint8)(unsafe.Pointer(p13)) = uint8(int32(*(*uint8)(unsafe.Pointer(p13))) + libc.Int32FromUint8(libc.Uint8FromInt32((libc.Int32FromInt32(255)-libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(srcPtr))))*(red-libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(destPtr))))/libc.Int32FromInt32(255)))) p14 = destPtr + 1 *(*uint8)(unsafe.Pointer(p14)) = uint8(int32(*(*uint8)(unsafe.Pointer(p14))) + libc.Int32FromUint8(libc.Uint8FromInt32((libc.Int32FromInt32(255)-libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(srcPtr))))*(green-libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(destPtr + 1))))/libc.Int32FromInt32(255)))) p15 = destPtr + 2 *(*uint8)(unsafe.Pointer(p15)) = uint8(int32(*(*uint8)(unsafe.Pointer(p15))) + libc.Int32FromUint8(libc.Uint8FromInt32((libc.Int32FromInt32(255)-libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(srcPtr))))*(blue-libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(destPtr + 2))))/libc.Int32FromInt32(255)))) srcPtr += uintptr((*TTk_PhotoImageBlock)(unsafe.Pointer(blockPtr)).FpixelSize) destPtr += uintptr(newPixelSize) goto _12 _12: ; x-- } srcPtr += uintptr((*TTk_PhotoImageBlock)(unsafe.Pointer(blockPtr)).Fpitch - (*TTk_PhotoImageBlock)(unsafe.Pointer(blockPtr)).Fwidth*(*TTk_PhotoImageBlock)(unsafe.Pointer(blockPtr)).FpixelSize) goto _11 _11: ; y-- } } else { gray = libc.Int32FromUint8(libc.Uint8FromInt32((libc.Int32FromUint16((*TXColor)(unsafe.Pointer((*TSubcommandOptions)(unsafe.Pointer(optPtr)).Fbackground)).Fred)>>libc.Int32FromInt32(8)*libc.Int32FromInt32(11) + libc.Int32FromUint16((*TXColor)(unsafe.Pointer((*TSubcommandOptions)(unsafe.Pointer(optPtr)).Fbackground)).Fgreen)>>libc.Int32FromInt32(8)*libc.Int32FromInt32(16) + libc.Int32FromUint16((*TXColor)(unsafe.Pointer((*TSubcommandOptions)(unsafe.Pointer(optPtr)).Fbackground)).Fblue)>>libc.Int32FromInt32(8)*libc.Int32FromInt32(5) + libc.Int32FromInt32(16)) >> libc.Int32FromInt32(5))) y = (*TTk_PhotoImageBlock)(unsafe.Pointer(blockPtr)).Fheight for { if !(y > 0) { break } x = (*TTk_PhotoImageBlock)(unsafe.Pointer(blockPtr)).Fwidth for { if !(x > 0) { break } p18 = destPtr *(*uint8)(unsafe.Pointer(p18)) = uint8(int32(*(*uint8)(unsafe.Pointer(p18))) + (libc.Int32FromInt32(255)-libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(srcPtr))))*(gray-libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(destPtr))))/libc.Int32FromInt32(255)) srcPtr += uintptr((*TTk_PhotoImageBlock)(unsafe.Pointer(blockPtr)).FpixelSize) destPtr += uintptr(newPixelSize) goto _17 _17: ; x-- } srcPtr += uintptr((*TTk_PhotoImageBlock)(unsafe.Pointer(blockPtr)).Fpitch - (*TTk_PhotoImageBlock)(unsafe.Pointer(blockPtr)).Fwidth*(*TTk_PhotoImageBlock)(unsafe.Pointer(blockPtr)).FpixelSize) goto _16 _16: ; y-- } } } else { destPtr += uintptr(newPixelSize - int32(1)) y = (*TTk_PhotoImageBlock)(unsafe.Pointer(blockPtr)).Fheight for { if !(y > 0) { break } x = (*TTk_PhotoImageBlock)(unsafe.Pointer(blockPtr)).Fwidth for { if !(x > 0) { break } *(*uint8)(unsafe.Pointer(destPtr)) = *(*uint8)(unsafe.Pointer(srcPtr)) srcPtr += uintptr((*TTk_PhotoImageBlock)(unsafe.Pointer(blockPtr)).FpixelSize) destPtr += uintptr(newPixelSize) goto _20 _20: ; x-- } srcPtr += uintptr((*TTk_PhotoImageBlock)(unsafe.Pointer(blockPtr)).Fpitch - (*TTk_PhotoImageBlock)(unsafe.Pointer(blockPtr)).Fwidth*(*TTk_PhotoImageBlock)(unsafe.Pointer(blockPtr)).FpixelSize) goto _19 _19: ; y-- } } } (*TTk_PhotoImageBlock)(unsafe.Pointer(blockPtr)).FpixelPtr = data (*TTk_PhotoImageBlock)(unsafe.Pointer(blockPtr)).FpixelSize = newPixelSize (*TTk_PhotoImageBlock)(unsafe.Pointer(blockPtr)).Fpitch = newPixelSize * (*TTk_PhotoImageBlock)(unsafe.Pointer(blockPtr)).Fwidth *(*int32)(unsafe.Pointer(blockPtr + 24)) = 0 if newPixelSize > int32(2) { *(*int32)(unsafe.Pointer(blockPtr + 24 + 1*4)) = int32(1) *(*int32)(unsafe.Pointer(blockPtr + 24 + 2*4)) = int32(2) *(*int32)(unsafe.Pointer(blockPtr + 24 + 3*4)) = int32(3) } else { *(*int32)(unsafe.Pointer(blockPtr + 24 + 1*4)) = 0 *(*int32)(unsafe.Pointer(blockPtr + 24 + 2*4)) = 0 *(*int32)(unsafe.Pointer(blockPtr + 24 + 3*4)) = int32(1) } return data } return libc.UintptrFromInt32(0) } /* *---------------------------------------------------------------------- * * Tk_PhotoGetImage -- * * This function is called to obtain image data from a photo image. This * function fills in the Tk_PhotoImageBlock structure pointed to by * `blockPtr' with details of the address and layout of the image data in * memory. * * Results: * TRUE (1) indicating that image data is available, for backwards * compatibility with the old photo widget. * * Side effects: * None. * *---------------------------------------------------------------------- */ func XTk_PhotoGetImage(tls *libc.TLS, handle TTk_PhotoHandle, blockPtr uintptr) (r int32) { /* Information about the address and layout of * the image data is returned here. */ var modelPtr uintptr _ = modelPtr modelPtr = handle (*TTk_PhotoImageBlock)(unsafe.Pointer(blockPtr)).FpixelPtr = (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fpix32 (*TTk_PhotoImageBlock)(unsafe.Pointer(blockPtr)).Fwidth = (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fwidth (*TTk_PhotoImageBlock)(unsafe.Pointer(blockPtr)).Fheight = (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fheight (*TTk_PhotoImageBlock)(unsafe.Pointer(blockPtr)).Fpitch = (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fwidth * int32(4) (*TTk_PhotoImageBlock)(unsafe.Pointer(blockPtr)).FpixelSize = int32(4) *(*int32)(unsafe.Pointer(blockPtr + 24)) = 0 *(*int32)(unsafe.Pointer(blockPtr + 24 + 1*4)) = int32(1) *(*int32)(unsafe.Pointer(blockPtr + 24 + 2*4)) = int32(2) *(*int32)(unsafe.Pointer(blockPtr + 24 + 3*4)) = int32(3) return int32(1) } /* *-------------------------------------------------------------- * * ImgPostscriptPhoto -- * * This function is called to output the contents of a photo image in * Postscript by calling the Tk_PostscriptPhoto function. * * Results: * Returns a standard Tcl return value. * * Side effects: * None. * *-------------------------------------------------------------- */ func _ImgPhotoPostscript(tls *libc.TLS, clientData uintptr, interp uintptr, dummy4368 TTk_Window, psInfo TTk_PostscriptInfo, x int32, y int32, width int32, height int32, dummy4372 int32) (r int32) { bp := tls.Alloc(48) defer tls.Free(48) /* (unused) */ var _ /* block at bp+0 */ TTk_PhotoImageBlock XTk_PhotoGetImage(tls, clientData, bp) (*(*TTk_PhotoImageBlock)(unsafe.Pointer(bp))).FpixelPtr += uintptr(y*(*(*TTk_PhotoImageBlock)(unsafe.Pointer(bp))).Fpitch + x*(*(*TTk_PhotoImageBlock)(unsafe.Pointer(bp))).FpixelSize) return XTk_PostscriptPhoto(tls, interp, bp, psInfo, width, height) } const N_COLOR_HASH = 0 /* * Hash table used to hash from (display, colormap, palette, gamma) to * ColorTable address. */ var _imgPhotoColorHash TTcl_HashTable var _imgPhotoColorHashInitialized int32 /* *---------------------------------------------------------------------- * * TkImgPhotoConfigureInstance -- * * This function is called to create displaying information for a photo * image instance based on the configuration information in the model. * It is invoked both when new instances are created and when the model * is reconfigured. * * Results: * None. * * Side effects: * Generates errors via Tcl_BackgroundException if there are problems in * setting up the instance. * *---------------------------------------------------------------------- */ func XTkImgPhotoConfigureInstance(tls *libc.TLS, instancePtr uintptr) { bp := tls.Alloc(16) defer tls.Free(16) /* Instance to reconfigure. */ var bitsPerPixel, v1 int32 var colorTablePtr, imagePtr, modelPtr uintptr var _ /* validBox at bp+0 */ TXRectangle _, _, _, _, _ = bitsPerPixel, colorTablePtr, imagePtr, modelPtr, v1 modelPtr = (*TPhotoInstance)(unsafe.Pointer(instancePtr)).FmodelPtr /* * If the -palette configuration option has been set for the model, use * the value specified for our palette, but only if it is a valid palette * for our windows. Use the gamma value specified the model. */ if (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fpalette != 0 && *(*uint8)(unsafe.Pointer((*TPhotoModel)(unsafe.Pointer(modelPtr)).Fpalette)) != 0 && _IsValidPalette(tls, instancePtr, (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fpalette) != 0 { (*TPhotoInstance)(unsafe.Pointer(instancePtr)).Fpalette = (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fpalette } else { (*TPhotoInstance)(unsafe.Pointer(instancePtr)).Fpalette = (*TPhotoInstance)(unsafe.Pointer(instancePtr)).FdefaultPalette } (*TPhotoInstance)(unsafe.Pointer(instancePtr)).Fgamma = (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fgamma /* * If we don't currently have a color table, or if the one we have no * longer applies (e.g. because our palette or gamma has changed), get a * new one. */ colorTablePtr = (*TPhotoInstance)(unsafe.Pointer(instancePtr)).FcolorTablePtr if colorTablePtr == libc.UintptrFromInt32(0) || (*TPhotoInstance)(unsafe.Pointer(instancePtr)).Fcolormap != (*TColorTable)(unsafe.Pointer(colorTablePtr)).Fid.Fcolormap || (*TPhotoInstance)(unsafe.Pointer(instancePtr)).Fpalette != (*TColorTable)(unsafe.Pointer(colorTablePtr)).Fid.Fpalette || (*TPhotoInstance)(unsafe.Pointer(instancePtr)).Fgamma != (*TColorTable)(unsafe.Pointer(colorTablePtr)).Fid.Fgamma { /* * Free up our old color table, and get a new one. */ if colorTablePtr != libc.UintptrFromInt32(0) { (*TColorTable)(unsafe.Pointer(colorTablePtr)).FliveRefCount-- _FreeColorTable(tls, colorTablePtr, 0) } _GetColorTable(tls, instancePtr) /* * Create a new XImage structure for sending data to the X server, if * necessary. */ if (*TColorTable)(unsafe.Pointer((*TPhotoInstance)(unsafe.Pointer(instancePtr)).FcolorTablePtr)).Fflags&int32(BLACK_AND_WHITE) != 0 { bitsPerPixel = int32(1) } else { bitsPerPixel = (*TPhotoInstance)(unsafe.Pointer(instancePtr)).FvisualInfo.Fdepth } if (*TPhotoInstance)(unsafe.Pointer(instancePtr)).FimagePtr == libc.UintptrFromInt32(0) || (*TXImage)(unsafe.Pointer((*TPhotoInstance)(unsafe.Pointer(instancePtr)).FimagePtr)).Fbits_per_pixel != bitsPerPixel { if (*TPhotoInstance)(unsafe.Pointer(instancePtr)).FimagePtr != libc.UintptrFromInt32(0) { (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*TXImage)(unsafe.Pointer((*TPhotoInstance)(unsafe.Pointer(instancePtr)).FimagePtr)).Ff.Fdestroy_image})))(tls, (*TPhotoInstance)(unsafe.Pointer(instancePtr)).FimagePtr) } if bitsPerPixel > int32(1) { v1 = int32(ZPixmap) } else { v1 = XYBitmap } imagePtr = libx11.XXCreateImage(tls, (*TPhotoInstance)(unsafe.Pointer(instancePtr)).Fdisplay, (*TPhotoInstance)(unsafe.Pointer(instancePtr)).FvisualInfo.Fvisual, libc.Uint32FromInt32(bitsPerPixel), v1, 0, libc.UintptrFromInt32(0), uint32(1), uint32(1), int32(32), 0) (*TPhotoInstance)(unsafe.Pointer(instancePtr)).FimagePtr = imagePtr /* * We create images using the local host's endianness, rather than * the endianness of the server; otherwise we would have to * byte-swap any 16 or 32 bit values that we store in the image * if the server's endianness is different from ours. */ if imagePtr != libc.UintptrFromInt32(0) { (*TXImage)(unsafe.Pointer(imagePtr)).Fbyte_order = LSBFirst libx11.X_XInitImageFuncPtrs(tls, imagePtr) } } } /* * If the user has specified a width and/or height for the model which is * different from our current width/height, set the size to the values * specified by the user. If we have no pixmap, we do this also, since it * has the side effect of allocating a pixmap for us. */ if (*TPhotoInstance)(unsafe.Pointer(instancePtr)).Fpixels == uint64(0) || (*TPhotoInstance)(unsafe.Pointer(instancePtr)).Ferror1 == libc.UintptrFromInt32(0) || (*TPhotoInstance)(unsafe.Pointer(instancePtr)).Fwidth != (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fwidth || (*TPhotoInstance)(unsafe.Pointer(instancePtr)).Fheight != (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fheight { XTkImgPhotoInstanceSetSize(tls, instancePtr) } /* * Redither this instance if necessary. */ if (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fflags&int32(IMAGE_CHANGED) != 0 || (*TPhotoInstance)(unsafe.Pointer(instancePtr)).FcolorTablePtr != colorTablePtr { libx11.XXClipBox(tls, (*TPhotoModel)(unsafe.Pointer(modelPtr)).FvalidRegion, bp) if libc.Int32FromUint16((*(*TXRectangle)(unsafe.Pointer(bp))).Fwidth) > 0 && libc.Int32FromUint16((*(*TXRectangle)(unsafe.Pointer(bp))).Fheight) > 0 { XTkImgDitherInstance(tls, instancePtr, int32((*(*TXRectangle)(unsafe.Pointer(bp))).Fx), int32((*(*TXRectangle)(unsafe.Pointer(bp))).Fy), libc.Int32FromUint16((*(*TXRectangle)(unsafe.Pointer(bp))).Fwidth), libc.Int32FromUint16((*(*TXRectangle)(unsafe.Pointer(bp))).Fheight)) } } } /* *---------------------------------------------------------------------- * * TkImgPhotoGet -- * * This function is called for each use of a photo image in a widget. * * Results: * The return value is a token for the instance, which is passed back to * us in calls to TkImgPhotoDisplay and ImgPhotoFree. * * Side effects: * A data structure is set up for the instance (or, an existing instance * is re-used for the new one). * *---------------------------------------------------------------------- */ func XTkImgPhotoGet(tls *libc.TLS, tkwin TTk_Window, modelData uintptr) (r uintptr) { bp := tls.Alloc(304) defer tls.Free(304) /* Pointer to our model structure for the * image. */ var black, instancePtr, ip, modelPtr, visInfoPtr, white uintptr var colormap TColormap var gcmask, mono, nBlue, nGreen, nRed, v2 int32 var v3, v4 uint64 var _ /* buf at bp+72 */ [72]uint8 var _ /* gcValues at bp+144 */ TXGCValues var _ /* numVisuals at bp+0 */ int32 var _ /* visualInfo at bp+8 */ TXVisualInfo _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = black, colormap, gcmask, instancePtr, ip, modelPtr, mono, nBlue, nGreen, nRed, visInfoPtr, white, v2, v3, v4 modelPtr = modelData /* * See if there is already an instance for windows using the same * colormap. If so then just re-use it. */ colormap = (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fatts.Fcolormap instancePtr = (*TPhotoModel)(unsafe.Pointer(modelPtr)).FinstancePtr for { if !(instancePtr != libc.UintptrFromInt32(0)) { break } if colormap == (*TPhotoInstance)(unsafe.Pointer(instancePtr)).Fcolormap && (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fdisplay == (*TPhotoInstance)(unsafe.Pointer(instancePtr)).Fdisplay && (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fvisual == (*TPhotoInstance)(unsafe.Pointer(instancePtr)).FvisualInfo.Fvisual { /* * Re-use this instance. */ if (*TPhotoInstance)(unsafe.Pointer(instancePtr)).FrefCount == uint64(0) { /* * We are resurrecting this instance. */ libtcl9_0.XTcl_CancelIdleCall(tls, __ccgo_fp(XTkImgDisposeInstance), instancePtr) if (*TPhotoInstance)(unsafe.Pointer(instancePtr)).FcolorTablePtr != libc.UintptrFromInt32(0) { _FreeColorTable(tls, (*TPhotoInstance)(unsafe.Pointer(instancePtr)).FcolorTablePtr, 0) } _GetColorTable(tls, instancePtr) } (*TPhotoInstance)(unsafe.Pointer(instancePtr)).FrefCount++ return instancePtr } goto _1 _1: ; instancePtr = (*TPhotoInstance)(unsafe.Pointer(instancePtr)).FnextPtr } /* * The image isn't already in use in a window with the same colormap. Make * a new instance of the image. */ instancePtr = libtcl9_0.XTcl_Alloc(tls, uint64(176)) (*TPhotoInstance)(unsafe.Pointer(instancePtr)).FmodelPtr = modelPtr (*TPhotoInstance)(unsafe.Pointer(instancePtr)).Fdisplay = (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fdisplay (*TPhotoInstance)(unsafe.Pointer(instancePtr)).Fcolormap = (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fatts.Fcolormap XTk_PreserveColormap(tls, (*TPhotoInstance)(unsafe.Pointer(instancePtr)).Fdisplay, (*TPhotoInstance)(unsafe.Pointer(instancePtr)).Fcolormap) (*TPhotoInstance)(unsafe.Pointer(instancePtr)).FrefCount = uint64(1) (*TPhotoInstance)(unsafe.Pointer(instancePtr)).FcolorTablePtr = libc.UintptrFromInt32(0) (*TPhotoInstance)(unsafe.Pointer(instancePtr)).Fpixels = uint64(0) (*TPhotoInstance)(unsafe.Pointer(instancePtr)).Ferror1 = libc.UintptrFromInt32(0) (*TPhotoInstance)(unsafe.Pointer(instancePtr)).Fwidth = 0 (*TPhotoInstance)(unsafe.Pointer(instancePtr)).Fheight = 0 (*TPhotoInstance)(unsafe.Pointer(instancePtr)).FimagePtr = uintptr(0) (*TPhotoInstance)(unsafe.Pointer(instancePtr)).FnextPtr = (*TPhotoModel)(unsafe.Pointer(modelPtr)).FinstancePtr (*TPhotoModel)(unsafe.Pointer(modelPtr)).FinstancePtr = instancePtr /* * Obtain information about the visual and decide on the default palette. */ (*(*TXVisualInfo)(unsafe.Pointer(bp + 8))).Fscreen = (*TTk_FakeWin)(unsafe.Pointer(tkwin)).FscreenNum (*(*TXVisualInfo)(unsafe.Pointer(bp + 8))).Fvisualid = libx11.XXVisualIDFromVisual(tls, (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fvisual) visInfoPtr = libx11.XXGetVisualInfo(tls, (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fdisplay, int64(libc.Int32FromInt32(VisualScreenMask)|libc.Int32FromInt32(VisualIDMask)), bp+8, bp) if visInfoPtr == libc.UintptrFromInt32(0) { libtcl9_0.XTcl_Panic(tls, __ccgo_ts+39038, 0) } nRed = int32(2) v2 = libc.Int32FromInt32(0) nBlue = v2 nGreen = v2 mono = int32(1) (*TPhotoInstance)(unsafe.Pointer(instancePtr)).FvisualInfo = *(*TXVisualInfo)(unsafe.Pointer(visInfoPtr)) gcmask = 0 (*TPhotoInstance)(unsafe.Pointer(instancePtr)).FvisualInfo.Fvisual = (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fvisual switch (*TXVisualInfo)(unsafe.Pointer(visInfoPtr)).Fclass { case int32(DirectColor): fallthrough case int32(TrueColor): nRed = int32(1) << _CountBits(tls, uint32((*TXVisualInfo)(unsafe.Pointer(visInfoPtr)).Fred_mask)) nGreen = int32(1) << _CountBits(tls, uint32((*TXVisualInfo)(unsafe.Pointer(visInfoPtr)).Fgreen_mask)) nBlue = int32(1) << _CountBits(tls, uint32((*TXVisualInfo)(unsafe.Pointer(visInfoPtr)).Fblue_mask)) mono = 0 if (*TXVisualInfo)(unsafe.Pointer(visInfoPtr)).Fdepth > int32(24) { (*(*TXGCValues)(unsafe.Pointer(bp + 144))).Fplane_mask = (*TXVisualInfo)(unsafe.Pointer(visInfoPtr)).Fred_mask | (*TXVisualInfo)(unsafe.Pointer(visInfoPtr)).Fgreen_mask | (*TXVisualInfo)(unsafe.Pointer(visInfoPtr)).Fblue_mask gcmask = int32(libc.Int64FromInt64(1) << libc.Int32FromInt32(1)) } case int32(PseudoColor): fallthrough case int32(StaticColor): if (*TXVisualInfo)(unsafe.Pointer(visInfoPtr)).Fdepth > int32(15) { nRed = int32(32) nGreen = int32(32) nBlue = int32(32) mono = 0 } else { if (*TXVisualInfo)(unsafe.Pointer(visInfoPtr)).Fdepth >= int32(3) { ip = uintptr(unsafe.Pointer(&_paletteChoice)) + uintptr((*TXVisualInfo)(unsafe.Pointer(visInfoPtr)).Fdepth-int32(3))*12 nRed = *(*int32)(unsafe.Pointer(ip)) nGreen = *(*int32)(unsafe.Pointer(ip + 1*4)) nBlue = *(*int32)(unsafe.Pointer(ip + 2*4)) mono = 0 } } case int32(GrayScale): fallthrough case StaticGray: nRed = int32(1) << (*TXVisualInfo)(unsafe.Pointer(visInfoPtr)).Fdepth break } libx11.XXFree(tls, visInfoPtr) if mono != 0 { libc.X__builtin_snprintf(tls, bp+72, uint64(72), __ccgo_ts+14540, libc.VaList(bp+280, nRed)) } else { libc.X__builtin_snprintf(tls, bp+72, uint64(72), __ccgo_ts+39084, libc.VaList(bp+280, nRed, nGreen, nBlue)) } (*TPhotoInstance)(unsafe.Pointer(instancePtr)).FdefaultPalette = XTk_GetUid(tls, bp+72) /* * Make a GC with background = black and foreground = white. */ white = XTk_GetColor(tls, (*TPhotoModel)(unsafe.Pointer(modelPtr)).Finterp, tkwin, __ccgo_ts+39093) black = XTk_GetColor(tls, (*TPhotoModel)(unsafe.Pointer(modelPtr)).Finterp, tkwin, __ccgo_ts+39099) if white != libc.UintptrFromInt32(0) { v3 = (*TXColor)(unsafe.Pointer(white)).Fpixel } else { v3 = (*TScreen)(unsafe.Pointer((*struct { Fext_data uintptr Fprivate1 uintptr Ffd int32 Fprivate2 int32 Fproto_major_version int32 Fproto_minor_version int32 Fvendor uintptr Fprivate3 TXID Fprivate4 TXID Fprivate5 TXID Fprivate6 int32 Fresource_alloc uintptr Fbyte_order int32 Fbitmap_unit int32 Fbitmap_pad int32 Fbitmap_bit_order int32 Fnformats int32 Fpixmap_format uintptr Fprivate8 int32 Frelease int32 Fprivate9 uintptr Fprivate10 uintptr Fqlen int32 Flast_request_read uint64 Frequest uint64 Fprivate11 TXPointer Fprivate12 TXPointer Fprivate13 TXPointer Fprivate14 TXPointer Fmax_request_size uint32 Fdb uintptr Fprivate15 uintptr Fdisplay_name uintptr Fdefault_screen int32 Fnscreens int32 Fscreens uintptr Fmotion_buffer uint64 Fprivate16 uint64 Fmin_keycode int32 Fmax_keycode int32 Fprivate17 TXPointer Fprivate18 TXPointer Fprivate19 int32 Fxdefaults uintptr })(unsafe.Pointer((*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fdisplay)).Fscreens + uintptr((*TTk_FakeWin)(unsafe.Pointer(tkwin)).FscreenNum)*128)).Fwhite_pixel } (*(*TXGCValues)(unsafe.Pointer(bp + 144))).Fforeground = v3 if black != libc.UintptrFromInt32(0) { v4 = (*TXColor)(unsafe.Pointer(black)).Fpixel } else { v4 = (*TScreen)(unsafe.Pointer((*struct { Fext_data uintptr Fprivate1 uintptr Ffd int32 Fprivate2 int32 Fproto_major_version int32 Fproto_minor_version int32 Fvendor uintptr Fprivate3 TXID Fprivate4 TXID Fprivate5 TXID Fprivate6 int32 Fresource_alloc uintptr Fbyte_order int32 Fbitmap_unit int32 Fbitmap_pad int32 Fbitmap_bit_order int32 Fnformats int32 Fpixmap_format uintptr Fprivate8 int32 Frelease int32 Fprivate9 uintptr Fprivate10 uintptr Fqlen int32 Flast_request_read uint64 Frequest uint64 Fprivate11 TXPointer Fprivate12 TXPointer Fprivate13 TXPointer Fprivate14 TXPointer Fmax_request_size uint32 Fdb uintptr Fprivate15 uintptr Fdisplay_name uintptr Fdefault_screen int32 Fnscreens int32 Fscreens uintptr Fmotion_buffer uint64 Fprivate16 uint64 Fmin_keycode int32 Fmax_keycode int32 Fprivate17 TXPointer Fprivate18 TXPointer Fprivate19 int32 Fxdefaults uintptr })(unsafe.Pointer((*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fdisplay)).Fscreens + uintptr((*TTk_FakeWin)(unsafe.Pointer(tkwin)).FscreenNum)*128)).Fblack_pixel } (*(*TXGCValues)(unsafe.Pointer(bp + 144))).Fbackground = v4 XTk_FreeColor(tls, white) XTk_FreeColor(tls, black) (*(*TXGCValues)(unsafe.Pointer(bp + 144))).Fgraphics_exposures = False (*TPhotoInstance)(unsafe.Pointer(instancePtr)).Fgc = XTk_GetGC(tls, tkwin, libc.Uint64FromInt64(int64(gcmask)|libc.Int64FromInt64(1)<>red_shift) == uint64(0) { red_shift++ } for uint64(0x0001)&(green_mask>>green_shift) == uint64(0) { green_shift++ } for uint64(0x0001)&(blue_mask>>blue_shift) == uint64(0) { blue_shift++ } /* * Only UNIX requires the special case for <24bpp. It varies with 3 extra * shifts and uses RGB15. The 24+bpp version could also then be further * optimized. */ if (*TXImage)(unsafe.Pointer(bgImg)).Fdepth < int32(24) { red_mlen = libc.Uint8FromInt32(int32(8) - _CountBits(tls, uint32(red_mask>>red_shift))) green_mlen = libc.Uint8FromInt32(int32(8) - _CountBits(tls, uint32(green_mask>>green_shift))) blue_mlen = libc.Uint8FromInt32(int32(8) - _CountBits(tls, uint32(blue_mask>>blue_shift))) y = 0 for { if !(y < height) { break } line = (y + yOffset) * (*TPhotoModel)(unsafe.Pointer((*TPhotoInstance)(unsafe.Pointer(iPtr)).FmodelPtr)).Fwidth x = 0 for { if !(x < width) { break } modelPtr = alphaAr + uintptr((line+x+xOffset)*libc.Int32FromInt32(4)) alpha = *(*uint8)(unsafe.Pointer(modelPtr + 3)) /* * Ignore pixels that are fully transparent */ if alpha != 0 { /* * We could perhaps be more efficient than XGetPixel for * 24 and 32 bit displays, but this seems "fast enough". */ r = *(*uint8)(unsafe.Pointer(modelPtr)) g = *(*uint8)(unsafe.Pointer(modelPtr + 1)) b = *(*uint8)(unsafe.Pointer(modelPtr + 2)) if libc.Int32FromUint8(alpha) != int32(255) { pixel = (*(*func(*libc.TLS, uintptr, int32, int32) uint64)(unsafe.Pointer(&struct{ uintptr }{(*TXImage)(unsafe.Pointer(bgImg)).Ff.Fget_pixel})))(tls, bgImg, x, y) ra = libc.Uint8FromInt32(libc.Int32FromUint8(uint8(pixel&red_mask>>red_shift)) << red_mlen) ga = libc.Uint8FromInt32(libc.Int32FromUint8(uint8(pixel&green_mask>>green_shift)) << green_mlen) ba = libc.Uint8FromInt32(libc.Int32FromUint8(uint8(pixel&blue_mask>>blue_shift)) << blue_mlen) unalpha = libc.Uint8FromInt32(int32(255) - libc.Int32FromUint8(alpha)) /* Calculate once. */ r = libc.Uint8FromInt32((libc.Int32FromUint8(ra)*libc.Int32FromUint8(unalpha) + libc.Int32FromUint8(r)*libc.Int32FromUint8(alpha)) / libc.Int32FromInt32(255)) g = libc.Uint8FromInt32((libc.Int32FromUint8(ga)*libc.Int32FromUint8(unalpha) + libc.Int32FromUint8(g)*libc.Int32FromUint8(alpha)) / libc.Int32FromInt32(255)) b = libc.Uint8FromInt32((libc.Int32FromUint8(ba)*libc.Int32FromUint8(unalpha) + libc.Int32FromUint8(b)*libc.Int32FromUint8(alpha)) / libc.Int32FromInt32(255)) } (*(*func(*libc.TLS, uintptr, int32, int32, uint64) int32)(unsafe.Pointer(&struct{ uintptr }{(*TXImage)(unsafe.Pointer(bgImg)).Ff.Fput_pixel})))(tls, bgImg, x, y, uint64(uint32(uint64(r)*red_mask/libc.Uint64FromInt32(255)&red_mask|uint64(g)*green_mask/libc.Uint64FromInt32(255)&green_mask|uint64(b)*blue_mask/libc.Uint64FromInt32(255)&blue_mask))) } goto _2 _2: ; x++ } goto _1 _1: ; y++ } return } y = 0 for { if !(y < height) { break } line = (y + yOffset) * (*TPhotoModel)(unsafe.Pointer((*TPhotoInstance)(unsafe.Pointer(iPtr)).FmodelPtr)).Fwidth x = 0 for { if !(x < width) { break } modelPtr = alphaAr + uintptr((line+x+xOffset)*libc.Int32FromInt32(4)) alpha = *(*uint8)(unsafe.Pointer(modelPtr + 3)) /* * Ignore pixels that are fully transparent */ if alpha != 0 { /* * We could perhaps be more efficient than XGetPixel for 24 * and 32 bit displays, but this seems "fast enough". */ r = *(*uint8)(unsafe.Pointer(modelPtr)) g = *(*uint8)(unsafe.Pointer(modelPtr + 1)) b = *(*uint8)(unsafe.Pointer(modelPtr + 2)) if libc.Int32FromUint8(alpha) != int32(255) { pixel = (*(*func(*libc.TLS, uintptr, int32, int32) uint64)(unsafe.Pointer(&struct{ uintptr }{(*TXImage)(unsafe.Pointer(bgImg)).Ff.Fget_pixel})))(tls, bgImg, x, y) ra1 = uint8(pixel & red_mask >> red_shift) ga1 = uint8(pixel & green_mask >> green_shift) ba1 = uint8(pixel & blue_mask >> blue_shift) unalpha = libc.Uint8FromInt32(int32(255) - libc.Int32FromUint8(alpha)) /* Calculate once. */ r = libc.Uint8FromInt32((libc.Int32FromUint8(ra1)*libc.Int32FromUint8(unalpha) + libc.Int32FromUint8(r)*libc.Int32FromUint8(alpha)) / libc.Int32FromInt32(255)) g = libc.Uint8FromInt32((libc.Int32FromUint8(ga1)*libc.Int32FromUint8(unalpha) + libc.Int32FromUint8(g)*libc.Int32FromUint8(alpha)) / libc.Int32FromInt32(255)) b = libc.Uint8FromInt32((libc.Int32FromUint8(ba1)*libc.Int32FromUint8(unalpha) + libc.Int32FromUint8(b)*libc.Int32FromUint8(alpha)) / libc.Int32FromInt32(255)) } (*(*func(*libc.TLS, uintptr, int32, int32, uint64) int32)(unsafe.Pointer(&struct{ uintptr }{(*TXImage)(unsafe.Pointer(bgImg)).Ff.Fput_pixel})))(tls, bgImg, x, y, uint64(libc.Uint32FromInt32(libc.Int32FromUint8(r)<= int32(15) && (visInfo.Fclass == int32(DirectColor) || visInfo.Fclass == int32(TrueColor))) { goto _1 } bgImg = libc.UintptrFromInt32(0) /* * Create an error handler to suppress the case where the input was * not properly constrained, which can cause an X error. [Bug 979239] */ handler = XTk_CreateErrorHandler(tls, display, -int32(1), -int32(1), -int32(1), libc.UintptrFromInt32(0), libc.UintptrFromInt32(0)) /* * Pull the current background from the display to blend with */ bgImg = libx11.XXGetImage(tls, display, drawable, drawableX, drawableY, libc.Uint32FromInt32(width), libc.Uint32FromInt32(height), libc.Uint64FromInt64(^libc.Int64FromInt64(0)), int32(ZPixmap)) if bgImg == libc.UintptrFromInt32(0) { XTk_DeleteErrorHandler(tls, handler) /* We failed to get the image, so draw without blending alpha. * It's the best we can do. */ goto fallBack } _BlendComplexAlpha(tls, bgImg, instancePtr, imageX, imageY, width, height) /* * Color info is unimportant as we only do this operation for depth >= * 15. */ libx11.XXPutImage(tls, display, drawable, (*TPhotoInstance)(unsafe.Pointer(instancePtr)).Fgc, bgImg, 0, 0, drawableX, drawableY, libc.Uint32FromInt32(width), libc.Uint32FromInt32(height)) (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*TXImage)(unsafe.Pointer(bgImg)).Ff.Fdestroy_image})))(tls, bgImg) XTk_DeleteErrorHandler(tls, handler) goto _2 _1: ; /* * modelPtr->validRegion describes which parts of the image contain valid * data. We set this region as the clip mask for the gc, setting its * origin appropriately, and use it when drawing the image. */ goto fallBack fallBack: ; libx11.XXSetRegion(tls, display, (*TPhotoInstance)(unsafe.Pointer(instancePtr)).Fgc, (*TPhotoModel)(unsafe.Pointer((*TPhotoInstance)(unsafe.Pointer(instancePtr)).FmodelPtr)).FvalidRegion) libx11.XXSetClipOrigin(tls, display, (*TPhotoInstance)(unsafe.Pointer(instancePtr)).Fgc, drawableX-imageX, drawableY-imageY) libx11.XXCopyArea(tls, display, (*TPhotoInstance)(unsafe.Pointer(instancePtr)).Fpixels, drawable, (*TPhotoInstance)(unsafe.Pointer(instancePtr)).Fgc, imageX, imageY, libc.Uint32FromInt32(width), libc.Uint32FromInt32(height), drawableX, drawableY) libx11.XXSetClipMask(tls, display, (*TPhotoInstance)(unsafe.Pointer(instancePtr)).Fgc, uint64(0)) libx11.XXSetClipOrigin(tls, display, (*TPhotoInstance)(unsafe.Pointer(instancePtr)).Fgc, 0, 0) _2: ; libx11.XXFlush(tls, display) } /* *---------------------------------------------------------------------- * * TkImgPhotoFree -- * * This function is called when a widget ceases to use a particular * instance of an image. We don't actually get rid of the instance until * later because we may be about to get this instance again. * * Results: * None. * * Side effects: * Internal data structures get cleaned up, later. * *---------------------------------------------------------------------- */ func XTkImgPhotoFree(tls *libc.TLS, clientData uintptr, dummy761 uintptr) { /* Display containing window that used * image. */ var colorPtr, instancePtr, v2 uintptr var v1 Tsize_t _, _, _, _ = colorPtr, instancePtr, v1, v2 instancePtr = clientData v2 = instancePtr + 32 v1 = *(*Tsize_t)(unsafe.Pointer(v2)) *(*Tsize_t)(unsafe.Pointer(v2))-- if v1 > uint64(1) { return } /* * There are no more uses of the image within this widget. Decrement the * count of live uses of its color table, so that its colors can be * reclaimed if necessary, and set up an idle call to free the instance * structure. */ colorPtr = (*TPhotoInstance)(unsafe.Pointer(instancePtr)).FcolorTablePtr if colorPtr != libc.UintptrFromInt32(0) { (*TColorTable)(unsafe.Pointer(colorPtr)).FliveRefCount-- } libtcl9_0.XTcl_DoWhenIdle(tls, __ccgo_fp(XTkImgDisposeInstance), instancePtr) } /* *---------------------------------------------------------------------- * * TkImgPhotoInstanceSetSize -- * * This function reallocates the instance pixmap and dithering error * array for a photo instance, as necessary, to change the image's size * to `width' x `height' pixels. * * Results: * None. * * Side effects: * Storage gets reallocated, here and in the X server. * *---------------------------------------------------------------------- */ func XTkImgPhotoInstanceSetSize(tls *libc.TLS, instancePtr uintptr) { bp := tls.Alloc(16) defer tls.Free(16) /* Instance whose size is to be changed. */ var errDestPtr, errSrcPtr, modelPtr, newError uintptr var h, offset, v1, v2 int32 var newPixmap TPixmap var _ /* validBox at bp+0 */ TXRectangle _, _, _, _, _, _, _, _, _ = errDestPtr, errSrcPtr, h, modelPtr, newError, newPixmap, offset, v1, v2 modelPtr = (*TPhotoInstance)(unsafe.Pointer(instancePtr)).FmodelPtr libx11.XXClipBox(tls, (*TPhotoModel)(unsafe.Pointer(modelPtr)).FvalidRegion, bp) if (*TPhotoInstance)(unsafe.Pointer(instancePtr)).Fwidth != (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fwidth || (*TPhotoInstance)(unsafe.Pointer(instancePtr)).Fheight != (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fheight || (*TPhotoInstance)(unsafe.Pointer(instancePtr)).Fpixels == uint64(0) { if (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fwidth > 0 { v1 = (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fwidth } else { v1 = int32(1) } if (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fheight > 0 { v2 = (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fheight } else { v2 = int32(1) } newPixmap = XTk_GetPixmap(tls, (*TPhotoInstance)(unsafe.Pointer(instancePtr)).Fdisplay, (*TScreen)(unsafe.Pointer((*struct { Fext_data uintptr Fprivate1 uintptr Ffd int32 Fprivate2 int32 Fproto_major_version int32 Fproto_minor_version int32 Fvendor uintptr Fprivate3 TXID Fprivate4 TXID Fprivate5 TXID Fprivate6 int32 Fresource_alloc uintptr Fbyte_order int32 Fbitmap_unit int32 Fbitmap_pad int32 Fbitmap_bit_order int32 Fnformats int32 Fpixmap_format uintptr Fprivate8 int32 Frelease int32 Fprivate9 uintptr Fprivate10 uintptr Fqlen int32 Flast_request_read uint64 Frequest uint64 Fprivate11 TXPointer Fprivate12 TXPointer Fprivate13 TXPointer Fprivate14 TXPointer Fmax_request_size uint32 Fdb uintptr Fprivate15 uintptr Fdisplay_name uintptr Fdefault_screen int32 Fnscreens int32 Fscreens uintptr Fmotion_buffer uint64 Fprivate16 uint64 Fmin_keycode int32 Fmax_keycode int32 Fprivate17 TXPointer Fprivate18 TXPointer Fprivate19 int32 Fxdefaults uintptr })(unsafe.Pointer((*TPhotoInstance)(unsafe.Pointer(instancePtr)).Fdisplay)).Fscreens+uintptr((*TPhotoInstance)(unsafe.Pointer(instancePtr)).FvisualInfo.Fscreen)*128)).Froot, v1, v2, (*TPhotoInstance)(unsafe.Pointer(instancePtr)).FvisualInfo.Fdepth) if !(newPixmap != 0) { libtcl9_0.XTcl_Panic(tls, __ccgo_ts+39105, 0) } /* * The following is a gross hack needed to properly support colormaps * under Windows. Before the pixels can be copied to the pixmap, the * relevent colormap must be associated with the drawable. Normally we * can infer this association from the window that was used to create * the pixmap. However, in this case we're using the root window, so * we have to be more explicit. */ if (*TPhotoInstance)(unsafe.Pointer(instancePtr)).Fpixels != uint64(0) { /* * Copy any common pixels from the old pixmap and free it. */ libx11.XXCopyArea(tls, (*TPhotoInstance)(unsafe.Pointer(instancePtr)).Fdisplay, (*TPhotoInstance)(unsafe.Pointer(instancePtr)).Fpixels, newPixmap, (*TPhotoInstance)(unsafe.Pointer(instancePtr)).Fgc, int32((*(*TXRectangle)(unsafe.Pointer(bp))).Fx), int32((*(*TXRectangle)(unsafe.Pointer(bp))).Fy), uint32((*(*TXRectangle)(unsafe.Pointer(bp))).Fwidth), uint32((*(*TXRectangle)(unsafe.Pointer(bp))).Fheight), int32((*(*TXRectangle)(unsafe.Pointer(bp))).Fx), int32((*(*TXRectangle)(unsafe.Pointer(bp))).Fy)) XTk_FreePixmap(tls, (*TPhotoInstance)(unsafe.Pointer(instancePtr)).Fdisplay, (*TPhotoInstance)(unsafe.Pointer(instancePtr)).Fpixels) } (*TPhotoInstance)(unsafe.Pointer(instancePtr)).Fpixels = newPixmap } if (*TPhotoInstance)(unsafe.Pointer(instancePtr)).Fwidth != (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fwidth || (*TPhotoInstance)(unsafe.Pointer(instancePtr)).Fheight != (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fheight || (*TPhotoInstance)(unsafe.Pointer(instancePtr)).Ferror1 == libc.UintptrFromInt32(0) { if (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fheight > 0 && (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fwidth > 0 { /* * TODO: use attemptckalloc() here once there is a strategy that * will allow us to recover from failure. Right now, there's no * such possibility. */ newError = libtcl9_0.XTcl_Alloc(tls, libc.Uint64FromInt32((*TPhotoModel)(unsafe.Pointer(modelPtr)).Fheight*(*TPhotoModel)(unsafe.Pointer(modelPtr)).Fwidth*int32(3))*uint64(1)) /* * Zero the new array so that we don't get bogus error values * propagating into areas we dither later. */ if (*TPhotoInstance)(unsafe.Pointer(instancePtr)).Ferror1 != libc.UintptrFromInt32(0) && ((*TPhotoInstance)(unsafe.Pointer(instancePtr)).Fwidth == (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fwidth || libc.Int32FromUint16((*(*TXRectangle)(unsafe.Pointer(bp))).Fwidth) == (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fwidth) { if int32((*(*TXRectangle)(unsafe.Pointer(bp))).Fy) > 0 { libc.Xmemset(tls, newError, 0, libc.Uint64FromInt16((*(*TXRectangle)(unsafe.Pointer(bp))).Fy)*libc.Uint64FromInt32((*TPhotoModel)(unsafe.Pointer(modelPtr)).Fwidth)*uint64(3)*uint64(1)) } h = int32((*(*TXRectangle)(unsafe.Pointer(bp))).Fy) + libc.Int32FromUint16((*(*TXRectangle)(unsafe.Pointer(bp))).Fheight) if h < (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fheight { libc.Xmemset(tls, newError+uintptr(h*(*TPhotoModel)(unsafe.Pointer(modelPtr)).Fwidth*int32(3)), 0, libc.Uint64FromInt32((*TPhotoModel)(unsafe.Pointer(modelPtr)).Fheight-h)*libc.Uint64FromInt32((*TPhotoModel)(unsafe.Pointer(modelPtr)).Fwidth)*uint64(3)*uint64(1)) } } else { libc.Xmemset(tls, newError, 0, libc.Uint64FromInt32((*TPhotoModel)(unsafe.Pointer(modelPtr)).Fheight)*libc.Uint64FromInt32((*TPhotoModel)(unsafe.Pointer(modelPtr)).Fwidth)*uint64(3)*uint64(1)) } } else { newError = libc.UintptrFromInt32(0) } if (*TPhotoInstance)(unsafe.Pointer(instancePtr)).Ferror1 != libc.UintptrFromInt32(0) { /* * Copy the common area over to the new array and free the old * array. */ if (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fwidth == (*TPhotoInstance)(unsafe.Pointer(instancePtr)).Fwidth { offset = int32((*(*TXRectangle)(unsafe.Pointer(bp))).Fy) * (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fwidth * int32(3) libc.Xmemcpy(tls, newError+uintptr(offset), (*TPhotoInstance)(unsafe.Pointer(instancePtr)).Ferror1+uintptr(offset), uint64((*(*TXRectangle)(unsafe.Pointer(bp))).Fheight)*libc.Uint64FromInt32((*TPhotoModel)(unsafe.Pointer(modelPtr)).Fwidth)*uint64(3)*uint64(1)) } else { if libc.Int32FromUint16((*(*TXRectangle)(unsafe.Pointer(bp))).Fwidth) > 0 && libc.Int32FromUint16((*(*TXRectangle)(unsafe.Pointer(bp))).Fheight) > 0 { errDestPtr = newError + uintptr((int32((*(*TXRectangle)(unsafe.Pointer(bp))).Fy)*(*TPhotoModel)(unsafe.Pointer(modelPtr)).Fwidth+int32((*(*TXRectangle)(unsafe.Pointer(bp))).Fx))*int32(3)) errSrcPtr = (*TPhotoInstance)(unsafe.Pointer(instancePtr)).Ferror1 + uintptr((int32((*(*TXRectangle)(unsafe.Pointer(bp))).Fy)*(*TPhotoInstance)(unsafe.Pointer(instancePtr)).Fwidth+int32((*(*TXRectangle)(unsafe.Pointer(bp))).Fx))*int32(3)) h = libc.Int32FromUint16((*(*TXRectangle)(unsafe.Pointer(bp))).Fheight) for { if !(h > 0) { break } libc.Xmemcpy(tls, errDestPtr, errSrcPtr, libc.Uint64FromInt32(libc.Int32FromUint16((*(*TXRectangle)(unsafe.Pointer(bp))).Fwidth)*int32(3))*uint64(1)) errDestPtr += uintptr((*TPhotoModel)(unsafe.Pointer(modelPtr)).Fwidth * int32(3)) errSrcPtr += uintptr((*TPhotoInstance)(unsafe.Pointer(instancePtr)).Fwidth * int32(3)) goto _3 _3: ; h-- } } } libtcl9_0.XTcl_Free(tls, (*TPhotoInstance)(unsafe.Pointer(instancePtr)).Ferror1) } (*TPhotoInstance)(unsafe.Pointer(instancePtr)).Ferror1 = newError } (*TPhotoInstance)(unsafe.Pointer(instancePtr)).Fwidth = (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fwidth (*TPhotoInstance)(unsafe.Pointer(instancePtr)).Fheight = (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fheight } /* *---------------------------------------------------------------------- * * IsValidPalette -- * * This function is called to check whether a value given for the * -palette option is valid for a particular instance of a photo image. * * Results: * A boolean value: 1 if the palette is acceptable, 0 otherwise. * * Side effects: * None. * *---------------------------------------------------------------------- */ func _IsValidPalette(tls *libc.TLS, instancePtr uintptr, palette uintptr) (r int32) { bp := tls.Alloc(16) defer tls.Free(16) /* Palette specification string. */ var mono, nBlue, nGreen, nRed, numColors, v1 int32 var _ /* endp at bp+0 */ uintptr _, _, _, _, _, _ = mono, nBlue, nGreen, nRed, numColors, v1 /* * First parse the specification: it must be of the form %d or %d/%d/%d. */ nRed = int32(libc.Xstrtol(tls, palette, bp, int32(10))) if *(*uintptr)(unsafe.Pointer(bp)) == palette || libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp))))) != 0 && libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp))))) != int32('/') || nRed < int32(2) || nRed > int32(256) { return 0 } if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp))))) == 0 { mono = int32(1) v1 = nRed nBlue = v1 nGreen = v1 } else { palette = *(*uintptr)(unsafe.Pointer(bp)) + uintptr(1) nGreen = int32(libc.Xstrtol(tls, palette, bp, int32(10))) if *(*uintptr)(unsafe.Pointer(bp)) == palette || libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp))))) != int32('/') || nGreen < int32(2) || nGreen > int32(256) { return 0 } palette = *(*uintptr)(unsafe.Pointer(bp)) + uintptr(1) nBlue = int32(libc.Xstrtol(tls, palette, bp, int32(10))) if *(*uintptr)(unsafe.Pointer(bp)) == palette || libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp))))) != 0 || nBlue < int32(2) || nBlue > int32(256) { return 0 } mono = 0 } switch (*TPhotoInstance)(unsafe.Pointer(instancePtr)).FvisualInfo.Fclass { case int32(DirectColor): fallthrough case int32(TrueColor): if nRed > int32(1)<<_CountBits(tls, uint32((*TPhotoInstance)(unsafe.Pointer(instancePtr)).FvisualInfo.Fred_mask)) || nGreen > int32(1)<<_CountBits(tls, uint32((*TPhotoInstance)(unsafe.Pointer(instancePtr)).FvisualInfo.Fgreen_mask)) || nBlue > int32(1)<<_CountBits(tls, uint32((*TPhotoInstance)(unsafe.Pointer(instancePtr)).FvisualInfo.Fblue_mask)) { return 0 } case int32(PseudoColor): fallthrough case int32(StaticColor): numColors = nRed if !(mono != 0) { numColors *= nGreen * nBlue } if numColors > int32(1)<<(*TPhotoInstance)(unsafe.Pointer(instancePtr)).FvisualInfo.Fdepth { return 0 } case int32(GrayScale): fallthrough case StaticGray: if !(mono != 0) || nRed > int32(1)<<(*TPhotoInstance)(unsafe.Pointer(instancePtr)).FvisualInfo.Fdepth { return 0 } break } return int32(1) } /* *---------------------------------------------------------------------- * * CountBits -- * * This function counts how many bits are set to 1 in `mask'. * * Results: * The integer number of bits. * * Side effects: * None. * *---------------------------------------------------------------------- */ func _CountBits(tls *libc.TLS, mask uint32) (r int32) { /* Value to count the 1 bits in. */ var n int32 _ = n n = 0 for { if !(mask != uint32(0)) { break } n++ goto _1 _1: ; mask &= mask - uint32(1) } return n } /* *---------------------------------------------------------------------- * * GetColorTable -- * * This function is called to allocate a table of colormap information * for an instance of a photo image. Only one such table is allocated for * all photo instances using the same display, colormap, palette and * gamma values, so that the application need only request a set of * colors from the X server once for all such photo widgets. This * function maintains a hash table to find previously-allocated * ColorTables. * * Results: * None. * * Side effects: * A new ColorTable may be allocated and placed in the hash table, and * have colors allocated for it. * *---------------------------------------------------------------------- */ func _GetColorTable(tls *libc.TLS, instancePtr uintptr) { bp := tls.Alloc(48) defer tls.Free(48) /* Instance needing a color table. */ var colorPtr, entry uintptr var _ /* id at bp+0 */ TColorTableId var _ /* isNew at bp+32 */ int32 _, _ = colorPtr, entry /* * Look for an existing ColorTable in the hash table. */ libc.Xmemset(tls, bp, 0, uint64(32)) (*(*TColorTableId)(unsafe.Pointer(bp))).Fdisplay = (*TPhotoInstance)(unsafe.Pointer(instancePtr)).Fdisplay (*(*TColorTableId)(unsafe.Pointer(bp))).Fcolormap = (*TPhotoInstance)(unsafe.Pointer(instancePtr)).Fcolormap (*(*TColorTableId)(unsafe.Pointer(bp))).Fpalette = (*TPhotoInstance)(unsafe.Pointer(instancePtr)).Fpalette (*(*TColorTableId)(unsafe.Pointer(bp))).Fgamma = (*TPhotoInstance)(unsafe.Pointer(instancePtr)).Fgamma if !(_imgPhotoColorHashInitialized != 0) { libtcl9_0.XTcl_InitHashTable(tls, uintptr(unsafe.Pointer(&_imgPhotoColorHash)), libc.Int32FromUint64(libc.Uint64FromInt64(32)/libc.Uint64FromInt64(4))) _imgPhotoColorHashInitialized = int32(1) } entry = (*(*func(*libc.TLS, uintptr, uintptr, uintptr) uintptr)(unsafe.Pointer(&struct{ uintptr }{(*TTcl_HashTable)(unsafe.Pointer(uintptr(unsafe.Pointer(&_imgPhotoColorHash)))).FcreateProc})))(tls, uintptr(unsafe.Pointer(&_imgPhotoColorHash)), bp, bp+32) if !(*(*int32)(unsafe.Pointer(bp + 32)) != 0) { /* * Re-use the existing entry. */ colorPtr = (*TTcl_HashEntry)(unsafe.Pointer(entry)).FclientData } else { /* * No color table currently available; need to make one. */ colorPtr = libtcl9_0.XTcl_Alloc(tls, uint64(3968)) /* * The following line of code should not normally be needed due to the * assignment in the following line. However, it compensates for bugs * in some compilers (HP, for example) where sizeof(ColorTable) is 24 * but the assignment only copies 20 bytes, leaving 4 bytes * uninitialized; these cause problems when using the id for lookups * in imgPhotoColorHash, and can result in core dumps. */ libc.Xmemset(tls, colorPtr, 0, uint64(32)) (*TColorTable)(unsafe.Pointer(colorPtr)).Fid = *(*TColorTableId)(unsafe.Pointer(bp)) XTk_PreserveColormap(tls, (*TColorTable)(unsafe.Pointer(colorPtr)).Fid.Fdisplay, (*TColorTable)(unsafe.Pointer(colorPtr)).Fid.Fcolormap) (*TColorTable)(unsafe.Pointer(colorPtr)).Fflags = 0 (*TColorTable)(unsafe.Pointer(colorPtr)).FrefCount = uint64(0) (*TColorTable)(unsafe.Pointer(colorPtr)).FliveRefCount = uint64(0) (*TColorTable)(unsafe.Pointer(colorPtr)).FnumColors = 0 (*TColorTable)(unsafe.Pointer(colorPtr)).FvisualInfo = (*TPhotoInstance)(unsafe.Pointer(instancePtr)).FvisualInfo (*TColorTable)(unsafe.Pointer(colorPtr)).FpixelMap = libc.UintptrFromInt32(0) (*TTcl_HashEntry)(unsafe.Pointer(entry)).FclientData = colorPtr } (*TColorTable)(unsafe.Pointer(colorPtr)).FrefCount++ (*TColorTable)(unsafe.Pointer(colorPtr)).FliveRefCount++ (*TPhotoInstance)(unsafe.Pointer(instancePtr)).FcolorTablePtr = colorPtr if (*TColorTable)(unsafe.Pointer(colorPtr)).Fflags&int32(DISPOSE_PENDING) != 0 { libtcl9_0.XTcl_CancelIdleCall(tls, __ccgo_fp(_DisposeColorTable), colorPtr) *(*int32)(unsafe.Pointer(colorPtr + 48)) &= ^libc.Int32FromInt32(DISPOSE_PENDING) } /* * Allocate colors for this color table if necessary. */ if (*TColorTable)(unsafe.Pointer(colorPtr)).FnumColors == 0 && !((*TColorTable)(unsafe.Pointer(colorPtr)).Fflags&libc.Int32FromInt32(BLACK_AND_WHITE) != 0) { _AllocateColors(tls, colorPtr) } } /* *---------------------------------------------------------------------- * * FreeColorTable -- * * This function is called when an instance ceases using a color table. * * Results: * None. * * Side effects: * If no other instances are using this color table, a when-idle handler * is registered to free up the color table and the colors allocated for * it. * *---------------------------------------------------------------------- */ func _FreeColorTable(tls *libc.TLS, colorPtr uintptr, force int32) { /* Force free to happen immediately. */ var v1 Tsize_t var v2 uintptr _, _ = v1, v2 v2 = colorPtr + 32 v1 = *(*Tsize_t)(unsafe.Pointer(v2)) *(*Tsize_t)(unsafe.Pointer(v2))-- if v1 > uint64(1) { return } if force != 0 { if (*TColorTable)(unsafe.Pointer(colorPtr)).Fflags&int32(DISPOSE_PENDING) != 0 { libtcl9_0.XTcl_CancelIdleCall(tls, __ccgo_fp(_DisposeColorTable), colorPtr) *(*int32)(unsafe.Pointer(colorPtr + 48)) &= ^libc.Int32FromInt32(DISPOSE_PENDING) } _DisposeColorTable(tls, colorPtr) } else { if !((*TColorTable)(unsafe.Pointer(colorPtr)).Fflags&libc.Int32FromInt32(DISPOSE_PENDING) != 0) { libtcl9_0.XTcl_DoWhenIdle(tls, __ccgo_fp(_DisposeColorTable), colorPtr) *(*int32)(unsafe.Pointer(colorPtr + 48)) |= int32(DISPOSE_PENDING) } } } /* *---------------------------------------------------------------------- * * AllocateColors -- * * This function allocates the colors required by a color table, and sets * up the fields in the color table data structure which are used in * dithering. * * Results: * None. * * Side effects: * Colors are allocated from the X server. Fields in the color table data * structure are updated. * *---------------------------------------------------------------------- */ func _AllocateColors(tls *libc.TLS, colorPtr uintptr) { bp := tls.Alloc(48) defer tls.Free(48) /* Pointer to the color table requiring colors * to be allocated. */ var b, g, i, mono, numColors, r, rMult, v2, v3, v4, v5, v6, v8 int32 var colors, pixels uintptr var fb, fg, fr, igam float64 var v13, v14 uint16 var _ /* nBlue at bp+8 */ int32 var _ /* nGreen at bp+4 */ int32 var _ /* nRed at bp+0 */ int32 _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = b, colors, fb, fg, fr, g, i, igam, mono, numColors, pixels, r, rMult, v13, v14, v2, v3, v4, v5, v6, v8 /* * 16-bit intensity value for i/n of full intensity. */ /* As for CFRAC, but apply exponent of g. */ /* * First parse the palette specification to get the required number of * shades of each primary. */ mono = libc.BoolInt32(libc.Xsscanf(tls, (*TColorTable)(unsafe.Pointer(colorPtr)).Fid.Fpalette, __ccgo_ts+39084, libc.VaList(bp+24, bp, bp+4, bp+8)) <= int32(1)) igam = float64(1) / (*TColorTable)(unsafe.Pointer(colorPtr)).Fid.Fgamma /* * Each time around this loop, we reduce the number of colors we're trying * to allocate until we succeed in allocating all of the colors we need. */ for { /* * If we are using 1 bit/pixel, we don't need to allocate any colors * (we just use the foreground and background colors in the GC). */ if mono != 0 && *(*int32)(unsafe.Pointer(bp)) <= int32(2) { *(*int32)(unsafe.Pointer(colorPtr + 48)) |= int32(BLACK_AND_WHITE) return } /* * Calculate the RGB coordinates of the colors we want to allocate and * store them in *colors. */ if (*TColorTable)(unsafe.Pointer(colorPtr)).FvisualInfo.Fclass == int32(DirectColor) || (*TColorTable)(unsafe.Pointer(colorPtr)).FvisualInfo.Fclass == int32(TrueColor) { /* * Direct/True Color: allocate shades of red, green, blue * independently. */ if mono != 0 { v3 = *(*int32)(unsafe.Pointer(bp)) *(*int32)(unsafe.Pointer(bp + 8)) = v3 v2 = v3 *(*int32)(unsafe.Pointer(bp + 4)) = v2 numColors = v2 } else { if *(*int32)(unsafe.Pointer(bp)) > *(*int32)(unsafe.Pointer(bp + 4)) { v5 = *(*int32)(unsafe.Pointer(bp)) } else { v5 = *(*int32)(unsafe.Pointer(bp + 4)) } if v5 > *(*int32)(unsafe.Pointer(bp + 8)) { if *(*int32)(unsafe.Pointer(bp)) > *(*int32)(unsafe.Pointer(bp + 4)) { v6 = *(*int32)(unsafe.Pointer(bp)) } else { v6 = *(*int32)(unsafe.Pointer(bp + 4)) } v4 = v6 } else { v4 = *(*int32)(unsafe.Pointer(bp + 8)) } numColors = v4 } colors = libtcl9_0.XTcl_Alloc(tls, libc.Uint64FromInt32(numColors)*uint64(16)) i = 0 for { if !(i < numColors) { break } if igam == float64(1) { (*(*TXColor)(unsafe.Pointer(colors + uintptr(i)*16))).Fred = libc.Uint16FromInt32(i * libc.Int32FromInt32(65535) / (*(*int32)(unsafe.Pointer(bp)) - libc.Int32FromInt32(1))) (*(*TXColor)(unsafe.Pointer(colors + uintptr(i)*16))).Fgreen = libc.Uint16FromInt32(i * libc.Int32FromInt32(65535) / (*(*int32)(unsafe.Pointer(bp + 4)) - libc.Int32FromInt32(1))) (*(*TXColor)(unsafe.Pointer(colors + uintptr(i)*16))).Fblue = libc.Uint16FromInt32(i * libc.Int32FromInt32(65535) / (*(*int32)(unsafe.Pointer(bp + 8)) - libc.Int32FromInt32(1))) } else { (*(*TXColor)(unsafe.Pointer(colors + uintptr(i)*16))).Fred = libc.Uint16FromInt32(int32(float64(libc.Float64FromInt32(65535) * libc.Xpow(tls, float64(i)/float64(*(*int32)(unsafe.Pointer(bp))-libc.Int32FromInt32(1)), igam)))) (*(*TXColor)(unsafe.Pointer(colors + uintptr(i)*16))).Fgreen = libc.Uint16FromInt32(int32(float64(libc.Float64FromInt32(65535) * libc.Xpow(tls, float64(i)/float64(*(*int32)(unsafe.Pointer(bp + 4))-libc.Int32FromInt32(1)), igam)))) (*(*TXColor)(unsafe.Pointer(colors + uintptr(i)*16))).Fblue = libc.Uint16FromInt32(int32(float64(libc.Float64FromInt32(65535) * libc.Xpow(tls, float64(i)/float64(*(*int32)(unsafe.Pointer(bp + 8))-libc.Int32FromInt32(1)), igam)))) } goto _7 _7: ; i++ } } else { /* * PseudoColor, StaticColor, GrayScale or StaticGray visual: we * have to allocate each color in the color cube separately. */ if mono != 0 { v8 = *(*int32)(unsafe.Pointer(bp)) } else { v8 = *(*int32)(unsafe.Pointer(bp)) * *(*int32)(unsafe.Pointer(bp + 4)) * *(*int32)(unsafe.Pointer(bp + 8)) } numColors = v8 colors = libtcl9_0.XTcl_Alloc(tls, libc.Uint64FromInt32(numColors)*uint64(16)) if !(mono != 0) { /* * Color display using a PseudoColor or StaticColor visual. */ i = 0 r = 0 for { if !(r < *(*int32)(unsafe.Pointer(bp))) { break } g = 0 for { if !(g < *(*int32)(unsafe.Pointer(bp + 4))) { break } b = 0 for { if !(b < *(*int32)(unsafe.Pointer(bp + 8))) { break } if igam == float64(1) { (*(*TXColor)(unsafe.Pointer(colors + uintptr(i)*16))).Fred = libc.Uint16FromInt32(r * libc.Int32FromInt32(65535) / (*(*int32)(unsafe.Pointer(bp)) - libc.Int32FromInt32(1))) (*(*TXColor)(unsafe.Pointer(colors + uintptr(i)*16))).Fgreen = libc.Uint16FromInt32(g * libc.Int32FromInt32(65535) / (*(*int32)(unsafe.Pointer(bp + 4)) - libc.Int32FromInt32(1))) (*(*TXColor)(unsafe.Pointer(colors + uintptr(i)*16))).Fblue = libc.Uint16FromInt32(b * libc.Int32FromInt32(65535) / (*(*int32)(unsafe.Pointer(bp + 8)) - libc.Int32FromInt32(1))) } else { (*(*TXColor)(unsafe.Pointer(colors + uintptr(i)*16))).Fred = libc.Uint16FromInt32(int32(float64(libc.Float64FromInt32(65535) * libc.Xpow(tls, float64(r)/float64(*(*int32)(unsafe.Pointer(bp))-libc.Int32FromInt32(1)), igam)))) (*(*TXColor)(unsafe.Pointer(colors + uintptr(i)*16))).Fgreen = libc.Uint16FromInt32(int32(float64(libc.Float64FromInt32(65535) * libc.Xpow(tls, float64(g)/float64(*(*int32)(unsafe.Pointer(bp + 4))-libc.Int32FromInt32(1)), igam)))) (*(*TXColor)(unsafe.Pointer(colors + uintptr(i)*16))).Fblue = libc.Uint16FromInt32(int32(float64(libc.Float64FromInt32(65535) * libc.Xpow(tls, float64(b)/float64(*(*int32)(unsafe.Pointer(bp + 8))-libc.Int32FromInt32(1)), igam)))) } i++ goto _11 _11: ; b++ } goto _10 _10: ; g++ } goto _9 _9: ; r++ } } else { /* * Monochrome display - allocate the shades of gray we want. */ i = 0 for { if !(i < numColors) { break } if igam == float64(1) { r = i * int32(65535) / (numColors - int32(1)) } else { r = int32(float64(libc.Float64FromInt32(65535) * libc.Xpow(tls, float64(i)/float64(numColors-libc.Int32FromInt32(1)), igam))) } v14 = libc.Uint16FromInt32(r) (*(*TXColor)(unsafe.Pointer(colors + uintptr(i)*16))).Fblue = v14 v13 = v14 (*(*TXColor)(unsafe.Pointer(colors + uintptr(i)*16))).Fgreen = v13 (*(*TXColor)(unsafe.Pointer(colors + uintptr(i)*16))).Fred = v13 goto _12 _12: ; i++ } } } /* * Now try to allocate the colors we've calculated. */ pixels = libtcl9_0.XTcl_Alloc(tls, libc.Uint64FromInt32(numColors)*uint64(8)) i = 0 for { if !(i < numColors) { break } if !(libx11.XXAllocColor(tls, (*TColorTable)(unsafe.Pointer(colorPtr)).Fid.Fdisplay, (*TColorTable)(unsafe.Pointer(colorPtr)).Fid.Fcolormap, colors+uintptr(i)*16) != 0) { /* * Can't get all the colors we want in the default colormap; * first try freeing colors from other unused color tables. */ if !(_ReclaimColors(tls, colorPtr, numColors-i) != 0) || !(libx11.XXAllocColor(tls, (*TColorTable)(unsafe.Pointer(colorPtr)).Fid.Fdisplay, (*TColorTable)(unsafe.Pointer(colorPtr)).Fid.Fcolormap, colors+uintptr(i)*16) != 0) { /* * Still can't allocate the color. */ break } } *(*uint64)(unsafe.Pointer(pixels + uintptr(i)*8)) = (*(*TXColor)(unsafe.Pointer(colors + uintptr(i)*16))).Fpixel goto _15 _15: ; i++ } /* * If we didn't get all of the colors, reduce the resolution of the * color cube, free the ones we got, and try again. */ if i >= numColors { break } libx11.XXFreeColors(tls, (*TColorTable)(unsafe.Pointer(colorPtr)).Fid.Fdisplay, (*TColorTable)(unsafe.Pointer(colorPtr)).Fid.Fcolormap, pixels, i, uint64(0)) libtcl9_0.XTcl_Free(tls, colors) libtcl9_0.XTcl_Free(tls, pixels) if !(mono != 0) { if *(*int32)(unsafe.Pointer(bp)) == int32(2) && *(*int32)(unsafe.Pointer(bp + 4)) == int32(2) && *(*int32)(unsafe.Pointer(bp + 8)) == int32(2) { /* * Fall back to 1-bit monochrome display. */ mono = int32(1) } else { /* * Reduce the number of shades of each primary to about 3/4 of * the previous value. This should reduce the total number of * colors required to about half the previous value for * PseudoColor displays. */ *(*int32)(unsafe.Pointer(bp)) = (*(*int32)(unsafe.Pointer(bp))*int32(3) + int32(2)) / int32(4) *(*int32)(unsafe.Pointer(bp + 4)) = (*(*int32)(unsafe.Pointer(bp + 4))*int32(3) + int32(2)) / int32(4) *(*int32)(unsafe.Pointer(bp + 8)) = (*(*int32)(unsafe.Pointer(bp + 8))*int32(3) + int32(2)) / int32(4) } } else { /* * Reduce the number of shades of gray to about 1/2. */ *(*int32)(unsafe.Pointer(bp)) = *(*int32)(unsafe.Pointer(bp)) / int32(2) } goto _1 _1: } /* * We have allocated all of the necessary colors: fill in various fields * of the ColorTable record. */ if !(mono != 0) { *(*int32)(unsafe.Pointer(colorPtr + 48)) |= int32(COLOR_WINDOW) /* * The following is a hairy hack. We only want to index into the * pixelMap on colormap displays. However, if the display is on * Windows, then we actually want to store the index not the value * since we will be passing the color table into the TkPutImage call. */ if (*TColorTable)(unsafe.Pointer(colorPtr)).FvisualInfo.Fclass != int32(DirectColor) && (*TColorTable)(unsafe.Pointer(colorPtr)).FvisualInfo.Fclass != int32(TrueColor) { *(*int32)(unsafe.Pointer(colorPtr + 48)) |= int32(MAP_COLORS) } } (*TColorTable)(unsafe.Pointer(colorPtr)).FnumColors = numColors (*TColorTable)(unsafe.Pointer(colorPtr)).FpixelMap = pixels /* * Set up quantization tables for dithering. */ rMult = *(*int32)(unsafe.Pointer(bp + 4)) * *(*int32)(unsafe.Pointer(bp + 8)) i = 0 for { if !(i < int32(256)) { break } r = (i*(*(*int32)(unsafe.Pointer(bp))-int32(1)) + int32(127)) / int32(255) if mono != 0 { fr = float64((*(*TXColor)(unsafe.Pointer(colors + uintptr(r)*16))).Fred) / float64(65535) if (*TColorTable)(unsafe.Pointer(colorPtr)).Fid.Fgamma != float64(1) { fr = libc.Xpow(tls, fr, (*TColorTable)(unsafe.Pointer(colorPtr)).Fid.Fgamma) } *(*uint8)(unsafe.Pointer(colorPtr + 3200 + uintptr(i))) = libc.Uint8FromInt32(int32(float64(fr * libc.Float64FromFloat64(255.99)))) *(*uint32)(unsafe.Pointer(colorPtr + 120 + uintptr(i)*4)) = uint32((*(*TXColor)(unsafe.Pointer(colors + uintptr(r)*16))).Fpixel) } else { g = (i*(*(*int32)(unsafe.Pointer(bp + 4))-int32(1)) + int32(127)) / int32(255) b = (i*(*(*int32)(unsafe.Pointer(bp + 8))-int32(1)) + int32(127)) / int32(255) if (*TColorTable)(unsafe.Pointer(colorPtr)).FvisualInfo.Fclass == int32(DirectColor) || (*TColorTable)(unsafe.Pointer(colorPtr)).FvisualInfo.Fclass == int32(TrueColor) { *(*uint32)(unsafe.Pointer(colorPtr + 120 + uintptr(i)*4)) = uint32((*(*TXColor)(unsafe.Pointer(colors + uintptr(r)*16))).Fpixel & (*TColorTable)(unsafe.Pointer(colorPtr)).FvisualInfo.Fred_mask) *(*uint32)(unsafe.Pointer(colorPtr + 1144 + uintptr(i)*4)) = uint32((*(*TXColor)(unsafe.Pointer(colors + uintptr(g)*16))).Fpixel & (*TColorTable)(unsafe.Pointer(colorPtr)).FvisualInfo.Fgreen_mask) *(*uint32)(unsafe.Pointer(colorPtr + 2168 + uintptr(i)*4)) = uint32((*(*TXColor)(unsafe.Pointer(colors + uintptr(b)*16))).Fpixel & (*TColorTable)(unsafe.Pointer(colorPtr)).FvisualInfo.Fblue_mask) } else { r *= rMult g *= *(*int32)(unsafe.Pointer(bp + 8)) *(*uint32)(unsafe.Pointer(colorPtr + 120 + uintptr(i)*4)) = libc.Uint32FromInt32(r) *(*uint32)(unsafe.Pointer(colorPtr + 1144 + uintptr(i)*4)) = libc.Uint32FromInt32(g) *(*uint32)(unsafe.Pointer(colorPtr + 2168 + uintptr(i)*4)) = libc.Uint32FromInt32(b) } fr = float64((*(*TXColor)(unsafe.Pointer(colors + uintptr(r)*16))).Fred) / float64(65535) fg = float64((*(*TXColor)(unsafe.Pointer(colors + uintptr(g)*16))).Fgreen) / float64(65535) fb = float64((*(*TXColor)(unsafe.Pointer(colors + uintptr(b)*16))).Fblue) / float64(65535) if (*TColorTable)(unsafe.Pointer(colorPtr)).Fid.Fgamma != float64(1) { fr = libc.Xpow(tls, fr, (*TColorTable)(unsafe.Pointer(colorPtr)).Fid.Fgamma) fg = libc.Xpow(tls, fg, (*TColorTable)(unsafe.Pointer(colorPtr)).Fid.Fgamma) fb = libc.Xpow(tls, fb, (*TColorTable)(unsafe.Pointer(colorPtr)).Fid.Fgamma) } *(*uint8)(unsafe.Pointer(colorPtr + 3200 + uintptr(i))) = libc.Uint8FromInt32(int32(float64(fr * libc.Float64FromFloat64(255.99)))) *(*uint8)(unsafe.Pointer(colorPtr + 3200 + 1*256 + uintptr(i))) = libc.Uint8FromInt32(int32(float64(fg * libc.Float64FromFloat64(255.99)))) *(*uint8)(unsafe.Pointer(colorPtr + 3200 + 2*256 + uintptr(i))) = libc.Uint8FromInt32(int32(float64(fb * libc.Float64FromFloat64(255.99)))) } goto _16 _16: ; i++ } libtcl9_0.XTcl_Free(tls, colors) } /* *---------------------------------------------------------------------- * * DisposeColorTable -- * * Release a color table and its associated resources. * * Results: * None. * * Side effects: * The colors in the argument color table are freed, as is the color * table structure itself. The color table is removed from the hash table * which is used to locate color tables. * *---------------------------------------------------------------------- */ func _DisposeColorTable(tls *libc.TLS, clientData uintptr) { /* Pointer to the ColorTable whose * colors are to be released. */ var colorPtr, entry uintptr _, _ = colorPtr, entry colorPtr = clientData if (*TColorTable)(unsafe.Pointer(colorPtr)).FpixelMap != libc.UintptrFromInt32(0) { if (*TColorTable)(unsafe.Pointer(colorPtr)).FnumColors > 0 { libx11.XXFreeColors(tls, (*TColorTable)(unsafe.Pointer(colorPtr)).Fid.Fdisplay, (*TColorTable)(unsafe.Pointer(colorPtr)).Fid.Fcolormap, (*TColorTable)(unsafe.Pointer(colorPtr)).FpixelMap, (*TColorTable)(unsafe.Pointer(colorPtr)).FnumColors, uint64(0)) XTk_FreeColormap(tls, (*TColorTable)(unsafe.Pointer(colorPtr)).Fid.Fdisplay, (*TColorTable)(unsafe.Pointer(colorPtr)).Fid.Fcolormap) } libtcl9_0.XTcl_Free(tls, (*TColorTable)(unsafe.Pointer(colorPtr)).FpixelMap) } entry = (*(*func(*libc.TLS, uintptr, uintptr) uintptr)(unsafe.Pointer(&struct{ uintptr }{(*TTcl_HashTable)(unsafe.Pointer(uintptr(unsafe.Pointer(&_imgPhotoColorHash)))).FfindProc})))(tls, uintptr(unsafe.Pointer(&_imgPhotoColorHash)), colorPtr) if entry == libc.UintptrFromInt32(0) { libtcl9_0.XTcl_Panic(tls, __ccgo_ts+39174, 0) } libtcl9_0.XTcl_DeleteHashEntry(tls, entry) libtcl9_0.XTcl_Free(tls, colorPtr) } /* *---------------------------------------------------------------------- * * ReclaimColors -- * * This function is called to try to free up colors in the colormap used * by a color table. It looks for other color tables with the same * colormap and with a zero live reference count, and frees their colors. * It only does so if there is the possibility of freeing up at least * `numColors' colors. * * Results: * The return value is TRUE if any colors were freed, FALSE otherwise. * * Side effects: * ColorTables which are not currently in use may lose their color * allocations. * *---------------------------------------------------------------------- */ func _ReclaimColors(tls *libc.TLS, id uintptr, numColors int32) (r int32) { bp := tls.Alloc(32) defer tls.Free(32) /* Number of colors required. */ var colorPtr, entry uintptr var nAvail int32 var _ /* srch at bp+0 */ TTcl_HashSearch _, _, _ = colorPtr, entry, nAvail nAvail = 0 /* * First scan through the color hash table to get an upper bound on how * many colors we might be able to free. */ entry = libtcl9_0.XTcl_FirstHashEntry(tls, uintptr(unsafe.Pointer(&_imgPhotoColorHash)), bp) for entry != libc.UintptrFromInt32(0) { colorPtr = (*TTcl_HashEntry)(unsafe.Pointer(entry)).FclientData if (*TColorTable)(unsafe.Pointer(colorPtr)).Fid.Fdisplay == (*TColorTableId)(unsafe.Pointer(id)).Fdisplay && (*TColorTable)(unsafe.Pointer(colorPtr)).Fid.Fcolormap == (*TColorTableId)(unsafe.Pointer(id)).Fcolormap && (*TColorTable)(unsafe.Pointer(colorPtr)).FliveRefCount == uint64(0) && (*TColorTable)(unsafe.Pointer(colorPtr)).FnumColors != 0 && ((*TColorTable)(unsafe.Pointer(colorPtr)).Fid.Fpalette != (*TColorTableId)(unsafe.Pointer(id)).Fpalette || (*TColorTable)(unsafe.Pointer(colorPtr)).Fid.Fgamma != (*TColorTableId)(unsafe.Pointer(id)).Fgamma) { /* * We could take this guy's colors off him. */ nAvail += (*TColorTable)(unsafe.Pointer(colorPtr)).FnumColors } entry = libtcl9_0.XTcl_NextHashEntry(tls, bp) } /* * nAvail is an (over)estimate of the number of colors we could free. */ if nAvail < numColors { return 0 } /* * Scan through a second time freeing colors. */ entry = libtcl9_0.XTcl_FirstHashEntry(tls, uintptr(unsafe.Pointer(&_imgPhotoColorHash)), bp) for entry != libc.UintptrFromInt32(0) && numColors > 0 { colorPtr = (*TTcl_HashEntry)(unsafe.Pointer(entry)).FclientData if (*TColorTable)(unsafe.Pointer(colorPtr)).Fid.Fdisplay == (*TColorTableId)(unsafe.Pointer(id)).Fdisplay && (*TColorTable)(unsafe.Pointer(colorPtr)).Fid.Fcolormap == (*TColorTableId)(unsafe.Pointer(id)).Fcolormap && (*TColorTable)(unsafe.Pointer(colorPtr)).FliveRefCount == uint64(0) && (*TColorTable)(unsafe.Pointer(colorPtr)).FnumColors != 0 && ((*TColorTable)(unsafe.Pointer(colorPtr)).Fid.Fpalette != (*TColorTableId)(unsafe.Pointer(id)).Fpalette || (*TColorTable)(unsafe.Pointer(colorPtr)).Fid.Fgamma != (*TColorTableId)(unsafe.Pointer(id)).Fgamma) { /* * Free the colors that this ColorTable has. */ libx11.XXFreeColors(tls, (*TColorTable)(unsafe.Pointer(colorPtr)).Fid.Fdisplay, (*TColorTable)(unsafe.Pointer(colorPtr)).Fid.Fcolormap, (*TColorTable)(unsafe.Pointer(colorPtr)).FpixelMap, (*TColorTable)(unsafe.Pointer(colorPtr)).FnumColors, uint64(0)) numColors -= (*TColorTable)(unsafe.Pointer(colorPtr)).FnumColors (*TColorTable)(unsafe.Pointer(colorPtr)).FnumColors = 0 libtcl9_0.XTcl_Free(tls, (*TColorTable)(unsafe.Pointer(colorPtr)).FpixelMap) (*TColorTable)(unsafe.Pointer(colorPtr)).FpixelMap = libc.UintptrFromInt32(0) } entry = libtcl9_0.XTcl_NextHashEntry(tls, bp) } return int32(1) /* We freed some colors. */ } /* *---------------------------------------------------------------------- * * TkImgDisposeInstance -- * * This function is called to finally free up an instance of a photo * image which is no longer required. * * Results: * None. * * Side effects: * The instance data structure and the resources it references are freed. * *---------------------------------------------------------------------- */ func XTkImgDisposeInstance(tls *libc.TLS, clientData uintptr) { /* Pointer to the instance whose resources are * to be released. */ var instancePtr, prevPtr uintptr _, _ = instancePtr, prevPtr instancePtr = clientData if (*TPhotoInstance)(unsafe.Pointer(instancePtr)).Fpixels != uint64(0) { XTk_FreePixmap(tls, (*TPhotoInstance)(unsafe.Pointer(instancePtr)).Fdisplay, (*TPhotoInstance)(unsafe.Pointer(instancePtr)).Fpixels) } if (*TPhotoInstance)(unsafe.Pointer(instancePtr)).Fgc != libc.UintptrFromInt32(0) { XTk_FreeGC(tls, (*TPhotoInstance)(unsafe.Pointer(instancePtr)).Fdisplay, (*TPhotoInstance)(unsafe.Pointer(instancePtr)).Fgc) } if (*TPhotoInstance)(unsafe.Pointer(instancePtr)).FimagePtr != libc.UintptrFromInt32(0) { (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*TXImage)(unsafe.Pointer((*TPhotoInstance)(unsafe.Pointer(instancePtr)).FimagePtr)).Ff.Fdestroy_image})))(tls, (*TPhotoInstance)(unsafe.Pointer(instancePtr)).FimagePtr) } if (*TPhotoInstance)(unsafe.Pointer(instancePtr)).Ferror1 != libc.UintptrFromInt32(0) { libtcl9_0.XTcl_Free(tls, (*TPhotoInstance)(unsafe.Pointer(instancePtr)).Ferror1) } if (*TPhotoInstance)(unsafe.Pointer(instancePtr)).FcolorTablePtr != libc.UintptrFromInt32(0) { _FreeColorTable(tls, (*TPhotoInstance)(unsafe.Pointer(instancePtr)).FcolorTablePtr, int32(1)) } if (*TPhotoModel)(unsafe.Pointer((*TPhotoInstance)(unsafe.Pointer(instancePtr)).FmodelPtr)).FinstancePtr == instancePtr { (*TPhotoModel)(unsafe.Pointer((*TPhotoInstance)(unsafe.Pointer(instancePtr)).FmodelPtr)).FinstancePtr = (*TPhotoInstance)(unsafe.Pointer(instancePtr)).FnextPtr } else { prevPtr = (*TPhotoModel)(unsafe.Pointer((*TPhotoInstance)(unsafe.Pointer(instancePtr)).FmodelPtr)).FinstancePtr for { if !((*TPhotoInstance)(unsafe.Pointer(prevPtr)).FnextPtr != instancePtr) { break } /* Empty loop body. */ goto _1 _1: ; prevPtr = (*TPhotoInstance)(unsafe.Pointer(prevPtr)).FnextPtr } (*TPhotoInstance)(unsafe.Pointer(prevPtr)).FnextPtr = (*TPhotoInstance)(unsafe.Pointer(instancePtr)).FnextPtr } XTk_FreeColormap(tls, (*TPhotoInstance)(unsafe.Pointer(instancePtr)).Fdisplay, (*TPhotoInstance)(unsafe.Pointer(instancePtr)).Fcolormap) libtcl9_0.XTcl_Free(tls, instancePtr) } /* *---------------------------------------------------------------------- * * TkImgDitherInstance -- * * This function is called to update an area of an instance's pixmap by * dithering the corresponding area of the model. * * Results: * None. * * Side effects: * The instance's pixmap gets updated. * *---------------------------------------------------------------------- */ func XTkImgDitherInstance(tls *libc.TLS, instancePtr uintptr, xStart int32, yStart int32, width int32, height int32) { bp := tls.Alloc(48) defer tls.Free(48) /* Dimensions of the block to be dithered. */ var bigEndian, bitsPerPixel, bytesPerLine, c, doDithering, i, lineLength, nLines, result, x, xEnd, y, yEnd, v1, v15, v21, v6 int32 var col [3]int32 var colorPtr, destBytePtr, destLongPtr, dstLinePtr, errLinePtr, errPtr, imagePtr, modelPtr, srcLinePtr, srcPtr, v10, v11, v12, v13, v16, v17, v18, v20, v22, v23, v7, v8, v9 uintptr var firstBit, mask, word, v24 uint32 var _ /* nBlue at bp+8 */ int32 var _ /* nGreen at bp+4 */ int32 var _ /* nRed at bp+0 */ int32 _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = bigEndian, bitsPerPixel, bytesPerLine, c, col, colorPtr, destBytePtr, destLongPtr, doDithering, dstLinePtr, errLinePtr, errPtr, firstBit, i, imagePtr, lineLength, mask, modelPtr, nLines, result, srcLinePtr, srcPtr, word, x, xEnd, y, yEnd, v1, v10, v11, v12, v13, v15, v16, v17, v18, v20, v21, v22, v23, v24, v6, v7, v8, v9 modelPtr = (*TPhotoInstance)(unsafe.Pointer(instancePtr)).FmodelPtr colorPtr = (*TPhotoInstance)(unsafe.Pointer(instancePtr)).FcolorTablePtr doDithering = int32(1) /* * Turn dithering off in certain cases where it is not needed (TrueColor, * DirectColor with many colors). */ if (*TColorTable)(unsafe.Pointer(colorPtr)).FvisualInfo.Fclass == int32(DirectColor) || (*TColorTable)(unsafe.Pointer(colorPtr)).FvisualInfo.Fclass == int32(TrueColor) { result = libc.Xsscanf(tls, (*TColorTable)(unsafe.Pointer(colorPtr)).Fid.Fpalette, __ccgo_ts+39084, libc.VaList(bp+24, bp, bp+4, bp+8)) if *(*int32)(unsafe.Pointer(bp)) >= int32(256) && (result == int32(1) || *(*int32)(unsafe.Pointer(bp + 4)) >= int32(256) && *(*int32)(unsafe.Pointer(bp + 8)) >= int32(256)) { doDithering = 0 } } /* * First work out how many lines to do at a time, then how many bytes * we'll need for pixel storage, and allocate it. */ nLines = (int32(MAX_PIXELS) + width - int32(1)) / width if nLines < int32(1) { nLines = int32(1) } if nLines > height { nLines = height } imagePtr = (*TPhotoInstance)(unsafe.Pointer(instancePtr)).FimagePtr if imagePtr == libc.UintptrFromInt32(0) { return /* We must be really tight on memory. */ } bitsPerPixel = (*TXImage)(unsafe.Pointer(imagePtr)).Fbits_per_pixel bytesPerLine = (bitsPerPixel*width + int32(31)) >> int32(3) & ^libc.Int32FromInt32(3) (*TXImage)(unsafe.Pointer(imagePtr)).Fwidth = width (*TXImage)(unsafe.Pointer(imagePtr)).Fheight = nLines (*TXImage)(unsafe.Pointer(imagePtr)).Fbytes_per_line = bytesPerLine /* * TODO: use attemptckalloc() here once we have some strategy for * recovering from the failure. */ (*TXImage)(unsafe.Pointer(imagePtr)).Fdata = libtcl9_0.XTcl_Alloc(tls, libc.Uint64FromInt32((*TXImage)(unsafe.Pointer(imagePtr)).Fbytes_per_line*nLines)) bigEndian = libc.BoolInt32((*TXImage)(unsafe.Pointer(imagePtr)).Fbitmap_bit_order == int32(MSBFirst)) if bigEndian != 0 { v1 = int32(1) << ((*TXImage)(unsafe.Pointer(imagePtr)).Fbitmap_unit - int32(1)) } else { v1 = int32(1) } firstBit = libc.Uint32FromInt32(v1) lineLength = (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fwidth * int32(3) srcLinePtr = (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fpix32 + uintptr((yStart*(*TPhotoModel)(unsafe.Pointer(modelPtr)).Fwidth+xStart)*int32(4)) errLinePtr = (*TPhotoInstance)(unsafe.Pointer(instancePtr)).Ferror1 + uintptr(yStart*lineLength) + uintptr(xStart*int32(3)) xEnd = xStart + width /* * Loop over the image, doing at most nLines lines before updating the * screen image. */ for { if !(height > 0) { break } dstLinePtr = (*TXImage)(unsafe.Pointer(imagePtr)).Fdata if nLines > height { nLines = height } yEnd = yStart + nLines y = yStart for { if !(y < yEnd) { break } srcPtr = srcLinePtr errPtr = errLinePtr destBytePtr = dstLinePtr destLongPtr = dstLinePtr if (*TColorTable)(unsafe.Pointer(colorPtr)).Fflags&int32(COLOR_WINDOW) != 0 { /* * Color window. We dither the three components independently, * using Floyd-Steinberg dithering, which propagates errors * from the quantization of pixels to the pixels below and to * the right. */ x = xStart for { if !(x < xEnd) { break } if doDithering != 0 { i = 0 for { if !(i < int32(3)) { break } /* * Compute the error propagated into this pixel * for this component. If e[x,y] is the array of * quantization error values, we compute * 7/16 * e[x-1,y] + 1/16 * e[x-1,y-1] * + 5/16 * e[x,y-1] + 3/16 * e[x+1,y-1] * and round it to an integer. * * The expression ((c + 2056) >> 4) - 128 computes * round(c / 16), and works correctly on machines * without a sign-extending right shift. */ if x > 0 { v6 = int32(*(*Tschar)(unsafe.Pointer(errPtr + uintptr(-libc.Int32FromInt32(3))))) * int32(7) } else { v6 = 0 } c = v6 if y > 0 { if x > 0 { c += int32(*(*Tschar)(unsafe.Pointer(errPtr + uintptr(-lineLength-int32(3))))) } c += int32(*(*Tschar)(unsafe.Pointer(errPtr + uintptr(-lineLength)))) * int32(5) if x+int32(1) < (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fwidth { c += int32(*(*Tschar)(unsafe.Pointer(errPtr + uintptr(-lineLength+int32(3))))) * int32(3) } } /* * Add the propagated error to the value of this * component, quantize it, and store the * quantization error. */ v7 = srcPtr srcPtr++ c = (c+int32(2056))>>int32(4) - int32(128) + libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(v7))) if c < 0 { c = 0 } else { if c > int32(255) { c = int32(255) } } col[i] = libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(colorPtr + 3200 + uintptr(i)*256 + uintptr(c)))) v8 = errPtr errPtr++ *(*Tschar)(unsafe.Pointer(v8)) = int8(c - col[i]) goto _5 _5: ; i++ } } else { /* * Output is virtually continuous in this case, so * don't bother dithering. */ v9 = srcPtr srcPtr++ col[0] = libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(v9))) v10 = srcPtr srcPtr++ col[int32(1)] = libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(v10))) v11 = srcPtr srcPtr++ col[int32(2)] = libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(v11))) } srcPtr++ /* * Translate the quantized component values into an X * pixel value, and store it in the image. */ i = libc.Int32FromUint32(*(*uint32)(unsafe.Pointer(colorPtr + 120 + uintptr(col[0])*4)) + *(*uint32)(unsafe.Pointer(colorPtr + 1144 + uintptr(col[int32(1)])*4)) + *(*uint32)(unsafe.Pointer(colorPtr + 2168 + uintptr(col[int32(2)])*4))) if (*TColorTable)(unsafe.Pointer(colorPtr)).Fflags&int32(MAP_COLORS) != 0 { i = libc.Int32FromUint64(*(*uint64)(unsafe.Pointer((*TColorTable)(unsafe.Pointer(colorPtr)).FpixelMap + uintptr(i)*8))) } switch bitsPerPixel { case int32(NBBY): v12 = destBytePtr destBytePtr++ *(*uint8)(unsafe.Pointer(v12)) = libc.Uint8FromInt32(i) break /* * This case is not valid for Windows because the * image format is different from the pixel format in * Win32. Eventually we need to fix the image code in * Tk to use the Windows native image ordering. This * would speed up the image code for all of the common * sizes. */ fallthrough case libc.Int32FromUint64(libc.Uint64FromInt32(NBBY) * libc.Uint64FromInt64(4)): v13 = destLongPtr destLongPtr += 4 *(*uint32)(unsafe.Pointer(v13)) = libc.Uint32FromInt32(i) default: (*(*func(*libc.TLS, uintptr, int32, int32, uint64) int32)(unsafe.Pointer(&struct{ uintptr }{(*TXImage)(unsafe.Pointer(imagePtr)).Ff.Fput_pixel})))(tls, imagePtr, x-xStart, y-yStart, uint64(libc.Uint32FromInt32(i))) } goto _4 _4: ; x++ } } else { if bitsPerPixel > int32(1) { /* * Multibit monochrome window. The operation here is similar * to the color window case above, except that there is only * one component. If the model image is in color, use the * luminance computed as * 0.344 * red + 0.5 * green + 0.156 * blue. */ x = xStart for { if !(x < xEnd) { break } if x > 0 { v15 = int32(*(*Tschar)(unsafe.Pointer(errPtr + uintptr(-libc.Int32FromInt32(1))))) * int32(7) } else { v15 = 0 } c = v15 if y > 0 { if x > 0 { c += int32(*(*Tschar)(unsafe.Pointer(errPtr + uintptr(-lineLength-int32(1))))) } c += int32(*(*Tschar)(unsafe.Pointer(errPtr + uintptr(-lineLength)))) * int32(5) if x+int32(1) < (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fwidth { c += int32(*(*Tschar)(unsafe.Pointer(errPtr + uintptr(-lineLength+int32(1))))) * int32(3) } } c = (c+int32(2056))>>int32(4) - int32(128) if (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fflags&int32(COLOR_IMAGE) != 0 { c = int32(uint32(c) + libc.Uint32FromInt32(libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(srcPtr)))*libc.Int32FromInt32(11)+libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(srcPtr + 1)))*libc.Int32FromInt32(16)+libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(srcPtr + 2)))*libc.Int32FromInt32(5)+libc.Int32FromInt32(16))>>libc.Int32FromInt32(5)) } else { c += libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(srcPtr))) } srcPtr += uintptr(4) if c < 0 { c = 0 } else { if c > int32(255) { c = int32(255) } } i = libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(colorPtr + 3200 + uintptr(c)))) v16 = errPtr errPtr++ *(*Tschar)(unsafe.Pointer(v16)) = int8(c - i) i = libc.Int32FromUint32(*(*uint32)(unsafe.Pointer(colorPtr + 120 + uintptr(i)*4))) switch bitsPerPixel { case int32(NBBY): v17 = destBytePtr destBytePtr++ *(*uint8)(unsafe.Pointer(v17)) = libc.Uint8FromInt32(i) break /* * This case is not valid for Windows because the * image format is different from the pixel format in * Win32. Eventually we need to fix the image code in * Tk to use the Windows native image ordering. This * would speed up the image code for all of the common * sizes. */ fallthrough case libc.Int32FromUint64(libc.Uint64FromInt32(NBBY) * libc.Uint64FromInt64(4)): v18 = destLongPtr destLongPtr += 4 *(*uint32)(unsafe.Pointer(v18)) = libc.Uint32FromInt32(i) default: (*(*func(*libc.TLS, uintptr, int32, int32, uint64) int32)(unsafe.Pointer(&struct{ uintptr }{(*TXImage)(unsafe.Pointer(imagePtr)).Ff.Fput_pixel})))(tls, imagePtr, x-xStart, y-yStart, uint64(libc.Uint32FromInt32(i))) } goto _14 _14: ; x++ } } else { /* * 1-bit monochrome window. This is similar to the multibit * monochrome case above, except that the quantization is * simpler (we only have black = 0 and white = 255), and we * produce an XY-Bitmap. */ word = uint32(0) mask = firstBit x = xStart for { if !(x < xEnd) { break } /* * If we have accumulated a whole word, store it in the * image and start a new word. */ if mask == uint32(0) { v20 = destLongPtr destLongPtr += 4 *(*uint32)(unsafe.Pointer(v20)) = word mask = firstBit word = uint32(0) } if x > 0 { v21 = int32(*(*Tschar)(unsafe.Pointer(errPtr + uintptr(-libc.Int32FromInt32(1))))) * int32(7) } else { v21 = 0 } c = v21 if y > 0 { if x > 0 { c += int32(*(*Tschar)(unsafe.Pointer(errPtr + uintptr(-lineLength-int32(1))))) } c += int32(*(*Tschar)(unsafe.Pointer(errPtr + uintptr(-lineLength)))) * int32(5) if x+int32(1) < (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fwidth { c += int32(*(*Tschar)(unsafe.Pointer(errPtr + uintptr(-lineLength+int32(1))))) * int32(3) } } c = (c+int32(2056))>>int32(4) - int32(128) if (*TPhotoModel)(unsafe.Pointer(modelPtr)).Fflags&int32(COLOR_IMAGE) != 0 { c = int32(uint32(c) + libc.Uint32FromInt32(libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(srcPtr)))*libc.Int32FromInt32(11)+libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(srcPtr + 1)))*libc.Int32FromInt32(16)+libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(srcPtr + 2)))*libc.Int32FromInt32(5)+libc.Int32FromInt32(16))>>libc.Int32FromInt32(5)) } else { c += libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(srcPtr))) } srcPtr += uintptr(4) if c < 0 { c = 0 } else { if c > int32(255) { c = int32(255) } } if c >= int32(128) { word |= mask v22 = errPtr errPtr++ *(*Tschar)(unsafe.Pointer(v22)) = int8(c - int32(255)) } else { v23 = errPtr errPtr++ *(*Tschar)(unsafe.Pointer(v23)) = int8(c) } if bigEndian != 0 { v24 = mask >> int32(1) } else { v24 = mask << int32(1) } mask = v24 goto _19 _19: ; x++ } *(*uint32)(unsafe.Pointer(destLongPtr)) = word } } srcLinePtr += uintptr((*TPhotoModel)(unsafe.Pointer(modelPtr)).Fwidth * int32(4)) errLinePtr += uintptr(lineLength) dstLinePtr += uintptr(bytesPerLine) goto _3 _3: ; y++ } /* * Update the pixmap for this instance with the block of pixels that * we have just computed. */ libx11.XXPutImage(tls, (*TPhotoInstance)(unsafe.Pointer(instancePtr)).Fdisplay, (*TPhotoInstance)(unsafe.Pointer(instancePtr)).Fpixels, (*TPhotoInstance)(unsafe.Pointer(instancePtr)).Fgc, imagePtr, 0, 0, xStart, yStart, libc.Uint32FromInt32(width), libc.Uint32FromInt32(nLines)) yStart = yEnd goto _2 _2: ; height -= nLines } libtcl9_0.XTcl_Free(tls, (*TXImage)(unsafe.Pointer(imagePtr)).Fdata) (*TXImage)(unsafe.Pointer(imagePtr)).Fdata = libc.UintptrFromInt32(0) } /* *---------------------------------------------------------------------- * * TkImgResetDither -- * * This function is called to eliminate the content of a photo instance's * dither error buffer. It's called when the overall image is blanked. * * Results: * None. * * Side effects: * The instance's dither buffer gets cleared. * *---------------------------------------------------------------------- */ func XTkImgResetDither(tls *libc.TLS, instancePtr uintptr) { if (*TPhotoInstance)(unsafe.Pointer(instancePtr)).Ferror1 != 0 { libc.Xmemset(tls, (*TPhotoInstance)(unsafe.Pointer(instancePtr)).Ferror1, 0, libc.Uint64FromInt32((*TPhotoModel)(unsafe.Pointer((*TPhotoInstance)(unsafe.Pointer(instancePtr)).FmodelPtr)).Fwidth)*libc.Uint64FromInt32((*TPhotoModel)(unsafe.Pointer((*TPhotoInstance)(unsafe.Pointer(instancePtr)).FmodelPtr)).Fheight)*uint64(3)*uint64(1)) } } const OPT_COLORFORMAT = 1 const TK_PHOTO_MAX_COLOR_LENGTH = 99 /* * Local Variables: * mode: c * c-basic-offset: 4 * fill-column: 78 * End: */ /* * Message to generate when an attempt to allocate memory for an image fails. */ /* * Color name length limit: do not attempt to parse as color strings that are * longer than this limit */ /* * Symbols for the different formats of a color string. */ type ColorFormatType = int32 const COLORFORMAT_TKCOLOR = 0 const COLORFORMAT_EMPTYSTRING = 1 const COLORFORMAT_LIST = 2 const COLORFORMAT_RGB1 = 3 const COLORFORMAT_RGB2 = 4 const COLORFORMAT_RGBA1 = 5 const COLORFORMAT_RGBA2 = 6 /* * Names for the color format types above. * Order must match the one in enum ColorFormatType */ var _colorFormatNames = [8]uintptr{ 0: __ccgo_ts + 39217, 1: __ccgo_ts + 39225, 2: __ccgo_ts + 39237, 3: __ccgo_ts + 39242, 4: __ccgo_ts + 6520, 5: __ccgo_ts + 39252, 6: __ccgo_ts + 39263, 7: libc.UintptrFromInt32(0), } /* * The following data structure is used to return information from * ParseFormatOptions: */ type TFormatOptions = struct { Foptions int32 FformatName uintptr FcolorFormat ColorFormatType } /* * Bit definitions for use with ParseFormatOptions: each bit is set in the * allowedOptions parameter on a call to ParseFormatOptions if that option * is allowed for the current photo image subcommand. On return, the bit is * set in the options field of the FormatOptions structure if that option * was specified. * * OPT_COLORFORMAT: Set if -alpha option allowed/specified. */ /* * List of format option names. The order here must match the order of * declarations of the FMT_OPT_* constants above. */ var _formatOptionNames = [2]uintptr{ 0: __ccgo_ts + 39268, 1: libc.UintptrFromInt32(0), } func init() { p := unsafe.Pointer(&XtkImgFmtDefault) *(*uintptr)(unsafe.Add(p, 16)) = __ccgo_fp(_StringMatchDef) *(*uintptr)(unsafe.Add(p, 32)) = __ccgo_fp(_StringReadDef) *(*uintptr)(unsafe.Add(p, 48)) = __ccgo_fp(_StringWriteDef) } // C documentation // // /* // *---------------------------------------------------------------------- // * // * ParseFormatOptions -- // * // * Parse the options passed to the image format handler. // * // * Results: // * On success, the structure pointed to by optPtr is filled with the // * values passed or with the defaults and TCL_OK returned. // * If an error occurs, leaves an error message in interp and returns // * TCL_ERROR. // * // * Side effects: // * The value in *indexPtr is updated to the index of the fist // * element in argv[] that does not look like an option/value, or to // * argc if parsing reached the end of argv[]. // * // *---------------------------------------------------------------------- // */ func _ParseFormatOptions(tls *libc.TLS, interp uintptr, allowedOptions int32, objc TTcl_Size, objv uintptr, indexPtr uintptr, optPtr uintptr) (r int32) { bp := tls.Alloc(64) defer tls.Free(64) /* Parsed option values are written to * this struct */ var first, optionExists int32 var index, v2, v3 TTcl_Size var option uintptr var _ /* optIndex at bp+0 */ TTcl_Size var _ /* typeIndex at bp+8 */ int32 _, _, _, _, _, _ = first, index, option, optionExists, v2, v3 first = int32(1) /* * Fill in default values */ (*TFormatOptions)(unsafe.Pointer(optPtr)).Foptions = 0 (*TFormatOptions)(unsafe.Pointer(optPtr)).FformatName = libc.UintptrFromInt32(0) (*TFormatOptions)(unsafe.Pointer(optPtr)).FcolorFormat = int32(COLORFORMAT_RGB2) index = *(*TTcl_Size)(unsafe.Pointer(indexPtr)) for { if !(index < objc) { break } /* * The first value can be the format handler's name. It goes to * optPtr->name. */ option = libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(index)*8)), libc.UintptrFromInt32(0)) if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(option))) != int32('-') { if first != 0 { (*TFormatOptions)(unsafe.Pointer(optPtr)).FformatName = *(*uintptr)(unsafe.Pointer(objv + uintptr(index)*8)) first = 0 goto _1 } else { break } } first = 0 /* * Check if option is known and allowed */ optionExists = int32(1) if libtcl9_0.XTcl_GetIndexFromObjStruct(tls, libc.UintptrFromInt32(0), *(*uintptr)(unsafe.Pointer(objv + uintptr(index)*8)), uintptr(unsafe.Pointer(&_formatOptionNames)), libc.Int64FromUint64(libc.Uint64FromInt64(8)), __ccgo_ts+39281, libc.Int32FromInt32(0)|libc.Int32FromUint64(libc.Uint64FromInt64(8)<= objc { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+38331, libc.VaList(bp+24, libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(index-int64(1))*8)), libc.UintptrFromInt32(0))))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+24, __ccgo_ts+179, __ccgo_ts+29667, __ccgo_ts+37434, __ccgo_ts+3203, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) } if libtcl9_0.XTcl_GetIndexFromObjStruct(tls, libc.UintptrFromInt32(0), *(*uintptr)(unsafe.Pointer(objv + uintptr(index)*8)), uintptr(unsafe.Pointer(&_colorFormatNames)), libc.Int64FromUint64(libc.Uint64FromInt64(8)), __ccgo_ts+195, libc.Int32FromInt32(TCL_EXACT)|libc.Int32FromUint64(libc.Uint64FromInt64(4)< put" command. // * // * Results: // * If thte data is in the default format, writes the size of the image // * to widthPtr and heightPtr and returns 1. Otherwise, leaves an error // * message in interp (if not NULL) and returns 0. // * Note that this function does not parse all data points. A return // * value of 1 does not guarantee that the data can be read without // * errors. // * // * Side effects: // * None // *---------------------------------------------------------------------- // */ func _StringMatchDef(tls *libc.TLS, data uintptr, dummy365 uintptr, widthPtr uintptr, heightPtr uintptr, interp uintptr) (r int32) { bp := tls.Alloc(96) defer tls.Free(96) /* Error messages are left in this interpreter */ var colCount, y TTcl_Size var _ /* curColCount at bp+8 */ TTcl_Size var _ /* dummy at bp+16 */ uint8 var _ /* pixelData at bp+32 */ uintptr var _ /* rowCount at bp+0 */ TTcl_Size var _ /* rowListPtr at bp+24 */ uintptr _, _ = colCount, y /* * See if data can be parsed as a list, if every element is itself a valid * list and all sublists have the same length. */ if libtcl9_0.XTcl_ListObjGetElements(tls, interp, data, bp, bp+24) != TCL_OK { return 0 } if *(*TTcl_Size)(unsafe.Pointer(bp)) == 0 { /* * empty list is valid data */ *(*int32)(unsafe.Pointer(widthPtr)) = 0 *(*int32)(unsafe.Pointer(heightPtr)) = 0 return int32(1) } colCount = int64(-int32(1)) y = 0 for { if !(y < *(*TTcl_Size)(unsafe.Pointer(bp))) { break } if libtcl9_0.XTcl_ListObjLength(tls, interp, *(*uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 24)) + uintptr(y)*8)), bp+8) != TCL_OK { return 0 } if colCount < 0 { colCount = *(*TTcl_Size)(unsafe.Pointer(bp + 8)) } else { if *(*TTcl_Size)(unsafe.Pointer(bp + 8)) != colCount { if interp != libc.UintptrFromInt32(0) { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+39465, libc.VaList(bp+48, y))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+48, __ccgo_ts+179, __ccgo_ts+29667, __ccgo_ts+37434, __ccgo_ts+39531, libc.UintptrFromInt32(0))) } return 0 } } goto _1 _1: ; y++ } /* * Data in base64 encoding (or even binary data), might actually pass * these tests. To avoid parsing it as list of lists format, check one * pixel for validity. */ if libtcl9_0.XTcl_ListObjIndex(tls, interp, *(*uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 24)))), 0, bp+32) != TCL_OK { return 0 } libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(bp + 32)), libc.UintptrFromInt32(0)) if (*TTcl_Obj)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 32)))).Flength > int64(TK_PHOTO_MAX_COLOR_LENGTH) { return 0 } if _ParseColor(tls, interp, *(*uintptr)(unsafe.Pointer(bp + 32)), (*TTk_FakeWin)(unsafe.Pointer(XTk_MainWindow(tls, interp))).Fdisplay, (*TTk_FakeWin)(unsafe.Pointer(XTk_MainWindow(tls, interp))).Fatts.Fcolormap, bp+16, bp+16, bp+16, bp+16) != TCL_OK { return 0 } /* * Looks like we have valid data for this format. * We do not check any pixel values - that's the job of ImgStringRead() */ *(*int32)(unsafe.Pointer(widthPtr)) = int32(colCount) *(*int32)(unsafe.Pointer(heightPtr)) = int32(*(*TTcl_Size)(unsafe.Pointer(bp))) return int32(1) } /* *---------------------------------------------------------------------- * * StringReadDef -- * * String read function for default format. (see manpage for details on * the format). * * Results: * A standard Tcl result. * * Side effects: * If the data has valid format, write it to the image identified by * imageHandle. * If the image data cannot be parsed, an error message is left in * interp. * *---------------------------------------------------------------------- */ func _StringReadDef(tls *libc.TLS, interp uintptr, data uintptr, formatString uintptr, imageHandle TTk_PhotoHandle, destX int32, destY int32, width int32, height int32, srcX int32, srcY int32) (r int32) { bp := tls.Alloc(176) defer tls.Free(176) /* start reading source data at these * coordinates */ var colormap TColormap var curPixelPtr, display uintptr var x, y int32 var _ /* colCount at bp+40 */ TTcl_Size var _ /* colListPtr at bp+8 */ uintptr var _ /* curColCount at bp+48 */ TTcl_Size var _ /* objc at bp+24 */ TTcl_Size var _ /* objv at bp+16 */ uintptr var _ /* optIndex at bp+120 */ TTcl_Size var _ /* opts at bp+96 */ TFormatOptions var _ /* rowCount at bp+32 */ TTcl_Size var _ /* rowListPtr at bp+0 */ uintptr var _ /* srcBlock at bp+56 */ TTk_PhotoImageBlock _, _, _, _, _ = colormap, curPixelPtr, display, x, y /* * Parse format suboptions * We don't use any format suboptions, but we still need to provide useful * error messages if suboptions were specified. */ libc.Xmemset(tls, bp+96, 0, uint64(24)) if formatString != libc.UintptrFromInt32(0) { if libtcl9_0.XTcl_ListObjGetElements(tls, interp, formatString, bp+24, bp+16) != TCL_OK { return int32(TCL_ERROR) } *(*TTcl_Size)(unsafe.Pointer(bp + 120)) = 0 if _ParseFormatOptions(tls, interp, 0, *(*TTcl_Size)(unsafe.Pointer(bp + 24)), *(*uintptr)(unsafe.Pointer(bp + 16)), bp+120, bp+96) != TCL_OK { return int32(TCL_ERROR) } if *(*TTcl_Size)(unsafe.Pointer(bp + 120)) < *(*TTcl_Size)(unsafe.Pointer(bp + 24)) { libtcl9_0.XTcl_SetObjResult(tls, interp, _GetBadOptMsg(tls, libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 16)) + uintptr(*(*TTcl_Size)(unsafe.Pointer(bp + 120)))*8)), libc.UintptrFromInt32(0)), 0)) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+136, __ccgo_ts+179, __ccgo_ts+29667, __ccgo_ts+37434, __ccgo_ts+3323, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) } } /* * Check input data */ if libtcl9_0.XTcl_ListObjGetElements(tls, interp, data, bp+32, bp) != TCL_OK { return int32(TCL_ERROR) } if *(*TTcl_Size)(unsafe.Pointer(bp + 32)) > 0 && libtcl9_0.XTcl_ListObjLength(tls, interp, *(*uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp)))), bp+40) != TCL_OK { return int32(TCL_ERROR) } if width <= 0 || height <= 0 || *(*TTcl_Size)(unsafe.Pointer(bp + 32)) == 0 || *(*TTcl_Size)(unsafe.Pointer(bp + 40)) == 0 { /* * No changes with zero sized input or zero sized output region */ return TCL_OK } if srcX < 0 || srcY < 0 || int64(srcX) >= *(*TTcl_Size)(unsafe.Pointer(bp + 32)) || int64(srcY) >= *(*TTcl_Size)(unsafe.Pointer(bp + 40)) { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+39544, 0)) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+136, __ccgo_ts+179, __ccgo_ts+29667, __ccgo_ts+37434, __ccgo_ts+37704, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) } /* * Memory allocation overflow protection. * May not be able to trigger/ demo / test this. */ if *(*TTcl_Size)(unsafe.Pointer(bp + 40)) > int64(int32(libc.Int64FromUint32(libc.Uint32FromUint32(0xffffffff)/libc.Uint32FromInt32(4)) / *(*TTcl_Size)(unsafe.Pointer(bp + 32)))) { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+39576, 0)) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+136, __ccgo_ts+179, __ccgo_ts+29667, __ccgo_ts+37434, __ccgo_ts+39624, libc.UintptrFromInt32(0))) return TCL_OK } /* * Read data and put it to imageHandle */ (*(*TTk_PhotoImageBlock)(unsafe.Pointer(bp + 56))).Fwidth = int32(*(*TTcl_Size)(unsafe.Pointer(bp + 40)) - int64(srcX)) (*(*TTk_PhotoImageBlock)(unsafe.Pointer(bp + 56))).Fheight = int32(*(*TTcl_Size)(unsafe.Pointer(bp + 32)) - int64(srcY)) (*(*TTk_PhotoImageBlock)(unsafe.Pointer(bp + 56))).FpixelSize = int32(4) (*(*TTk_PhotoImageBlock)(unsafe.Pointer(bp + 56))).Fpitch = (*(*TTk_PhotoImageBlock)(unsafe.Pointer(bp + 56))).Fwidth * int32(4) *(*int32)(unsafe.Pointer(bp + 56 + 24)) = 0 *(*int32)(unsafe.Pointer(bp + 56 + 24 + 1*4)) = int32(1) *(*int32)(unsafe.Pointer(bp + 56 + 24 + 2*4)) = int32(2) *(*int32)(unsafe.Pointer(bp + 56 + 24 + 3*4)) = int32(3) (*(*TTk_PhotoImageBlock)(unsafe.Pointer(bp + 56))).FpixelPtr = libtcl9_0.XTcl_AttemptAlloc(tls, libc.Uint64FromInt32((*(*TTk_PhotoImageBlock)(unsafe.Pointer(bp + 56))).Fpitch*(*(*TTk_PhotoImageBlock)(unsafe.Pointer(bp + 56))).Fheight)) if (*(*TTk_PhotoImageBlock)(unsafe.Pointer(bp + 56))).FpixelPtr == libc.UintptrFromInt32(0) { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+37506, 0)) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+136, __ccgo_ts+179, __ccgo_ts+36356, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) } curPixelPtr = (*(*TTk_PhotoImageBlock)(unsafe.Pointer(bp + 56))).FpixelPtr display = (*TTk_FakeWin)(unsafe.Pointer(XTk_MainWindow(tls, interp))).Fdisplay colormap = (*TTk_FakeWin)(unsafe.Pointer(XTk_MainWindow(tls, interp))).Fatts.Fcolormap y = srcY for { if !(int64(y) < *(*TTcl_Size)(unsafe.Pointer(bp + 32))) { break } /* * We don't test the length of row, as that's been done in * ImgStringMatch() */ if libtcl9_0.XTcl_ListObjGetElements(tls, interp, *(*uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp)) + uintptr(y)*8)), bp+48, bp+8) != TCL_OK { goto errorExit } x = srcX for { if !(int64(x) < *(*TTcl_Size)(unsafe.Pointer(bp + 40))) { break } if _ParseColor(tls, interp, *(*uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 8)) + uintptr(x)*8)), display, colormap, curPixelPtr, curPixelPtr+uintptr(1), curPixelPtr+uintptr(2), curPixelPtr+uintptr(3)) != TCL_OK { goto errorExit } curPixelPtr += uintptr(4) goto _2 _2: ; x++ } goto _1 _1: ; y++ } /* * Write image data to destHandle */ if XTk_PhotoPutBlock(tls, interp, imageHandle, bp+56, destX, destY, width, height, int32(TK_PHOTO_COMPOSITE_SET)) != TCL_OK { goto errorExit } libtcl9_0.XTcl_Free(tls, (*(*TTk_PhotoImageBlock)(unsafe.Pointer(bp + 56))).FpixelPtr) return TCL_OK goto errorExit errorExit: ; libtcl9_0.XTcl_Free(tls, (*(*TTk_PhotoImageBlock)(unsafe.Pointer(bp + 56))).FpixelPtr) return int32(TCL_ERROR) } /* *---------------------------------------------------------------------- * * StringWriteDef -- * * String write function for default image data format. See the user * documentation for details. * * Results: * The converted data is set as the result of interp. Returns a standard * Tcl result. * * Side effects: * None. * *---------------------------------------------------------------------- */ func _StringWriteDef(tls *libc.TLS, interp uintptr, formatString uintptr, blockPtr uintptr) (r int32) { bp := tls.Alloc(560) defer tls.Free(560) /* The image data to convert */ var allowedOpts TTcl_Size var alphaOffset, blueOffset, col, greenOffset, hasAlpha, row int32 var alphaVal uint8 var pixelPtr, result uintptr var _ /* colorBuf at bp+496 */ [11]uint8 var _ /* data at bp+48 */ TTcl_DString var _ /* line at bp+272 */ TTcl_DString var _ /* objc at bp+8 */ TTcl_Size var _ /* objv at bp+0 */ uintptr var _ /* optIndex at bp+16 */ TTcl_Size var _ /* opts at bp+24 */ TFormatOptions _, _, _, _, _, _, _, _, _, _ = allowedOpts, alphaOffset, alphaVal, blueOffset, col, greenOffset, hasAlpha, pixelPtr, result, row *(*uintptr)(unsafe.Pointer(bp)) = libc.UintptrFromInt32(0) /* * Parse format suboptions */ if libtcl9_0.XTcl_ListObjGetElements(tls, interp, formatString, bp+8, bp) != TCL_OK { return int32(TCL_ERROR) } allowedOpts = int64(OPT_COLORFORMAT) *(*TTcl_Size)(unsafe.Pointer(bp + 16)) = 0 if _ParseFormatOptions(tls, interp, int32(allowedOpts), *(*TTcl_Size)(unsafe.Pointer(bp + 8)), *(*uintptr)(unsafe.Pointer(bp)), bp+16, bp+24) != TCL_OK { return int32(TCL_ERROR) } if *(*TTcl_Size)(unsafe.Pointer(bp + 16)) < *(*TTcl_Size)(unsafe.Pointer(bp + 8)) { libtcl9_0.XTcl_SetObjResult(tls, interp, _GetBadOptMsg(tls, libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp)) + uintptr(*(*TTcl_Size)(unsafe.Pointer(bp + 16)))*8)), libc.UintptrFromInt32(0)), int32(allowedOpts))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+520, __ccgo_ts+179, __ccgo_ts+29667, __ccgo_ts+37434, __ccgo_ts+3323, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) } greenOffset = *(*int32)(unsafe.Pointer(blockPtr + 24 + 1*4)) - *(*int32)(unsafe.Pointer(blockPtr + 24)) blueOffset = *(*int32)(unsafe.Pointer(blockPtr + 24 + 2*4)) - *(*int32)(unsafe.Pointer(blockPtr + 24)) /* * A negative alpha offset signals that the image is fully opaque. * That's not really documented anywhere, but it's the way it is! */ if *(*int32)(unsafe.Pointer(blockPtr + 24 + 3*4)) < 0 { hasAlpha = 0 alphaOffset = 0 } else { hasAlpha = int32(1) alphaOffset = *(*int32)(unsafe.Pointer(blockPtr + 24 + 3*4)) - *(*int32)(unsafe.Pointer(blockPtr + 24)) } if (*TTk_PhotoImageBlock)(unsafe.Pointer(blockPtr)).Fwidth > 0 && (*TTk_PhotoImageBlock)(unsafe.Pointer(blockPtr)).Fheight > 0 { alphaVal = uint8(255) libtcl9_0.XTcl_DStringInit(tls, bp+48) row = 0 for { if !(row < (*TTk_PhotoImageBlock)(unsafe.Pointer(blockPtr)).Fheight) { break } pixelPtr = (*TTk_PhotoImageBlock)(unsafe.Pointer(blockPtr)).FpixelPtr + uintptr(*(*int32)(unsafe.Pointer(blockPtr + 24))) + uintptr(row*(*TTk_PhotoImageBlock)(unsafe.Pointer(blockPtr)).Fpitch) libtcl9_0.XTcl_DStringInit(tls, bp+272) col = 0 for { if !(col < (*TTk_PhotoImageBlock)(unsafe.Pointer(blockPtr)).Fwidth) { break } if hasAlpha != 0 { alphaVal = *(*uint8)(unsafe.Pointer(pixelPtr + uintptr(alphaOffset))) } /* * We don't build lines as a list for #RGBA and #RGB. Since * these color formats look like comments, the first element * of the list would get quoted with an additional {} . * While this is not a problem if the data is used as * a list, it would cause problems if someone decides to parse * it as a string (and it looks kinda strange) */ switch (*(*TFormatOptions)(unsafe.Pointer(bp + 24))).FcolorFormat { case int32(COLORFORMAT_RGB2): libc.X__builtin_snprintf(tls, bp+496, uint64(11), __ccgo_ts+39633, libc.VaList(bp+520, libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(pixelPtr))), libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(pixelPtr + uintptr(greenOffset)))), libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(pixelPtr + uintptr(blueOffset)))))) libtcl9_0.XTcl_DStringAppend(tls, bp+272, bp+496, int64(-libc.Int32FromInt32(1))) case int32(COLORFORMAT_RGBA2): libc.X__builtin_snprintf(tls, bp+496, uint64(11), __ccgo_ts+39648, libc.VaList(bp+520, libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(pixelPtr))), libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(pixelPtr + uintptr(greenOffset)))), libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(pixelPtr + uintptr(blueOffset)))), libc.Int32FromUint8(alphaVal))) libtcl9_0.XTcl_DStringAppend(tls, bp+272, bp+496, int64(-libc.Int32FromInt32(1))) case int32(COLORFORMAT_LIST): libtcl9_0.XTcl_DStringStartSublist(tls, bp+272) libc.X__builtin_snprintf(tls, bp+496, uint64(11), __ccgo_ts+14540, libc.VaList(bp+520, libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(pixelPtr))))) libtcl9_0.XTcl_DStringAppendElement(tls, bp+272, bp+496) libc.X__builtin_snprintf(tls, bp+496, uint64(11), __ccgo_ts+14540, libc.VaList(bp+520, libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(pixelPtr + uintptr(greenOffset)))))) libtcl9_0.XTcl_DStringAppendElement(tls, bp+272, bp+496) libc.X__builtin_snprintf(tls, bp+496, uint64(11), __ccgo_ts+14540, libc.VaList(bp+520, libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(pixelPtr + uintptr(blueOffset)))))) libtcl9_0.XTcl_DStringAppendElement(tls, bp+272, bp+496) libc.X__builtin_snprintf(tls, bp+496, uint64(11), __ccgo_ts+14540, libc.VaList(bp+520, libc.Int32FromUint8(alphaVal))) libtcl9_0.XTcl_DStringAppendElement(tls, bp+272, bp+496) libtcl9_0.XTcl_DStringEndSublist(tls, bp+272) default: libtcl9_0.XTcl_Panic(tls, __ccgo_ts+39667, 0) } pixelPtr += uintptr((*TTk_PhotoImageBlock)(unsafe.Pointer(blockPtr)).FpixelSize) goto _2 _2: ; col++ } if (*(*TFormatOptions)(unsafe.Pointer(bp + 24))).FcolorFormat != int32(COLORFORMAT_LIST) { /* * For the #XXX formats, we need to remove the last * whitespace. */ *(*uint8)(unsafe.Pointer((*TTcl_DString)(unsafe.Pointer(bp+272)).Fstring1 + uintptr((*TTcl_DString)(unsafe.Pointer(bp+272)).Flength) - libc.UintptrFromInt32(1))) = uint8('\000') } libtcl9_0.XTcl_DStringAppendElement(tls, bp+48, (*TTcl_DString)(unsafe.Pointer(bp+272)).Fstring1) libtcl9_0.XTcl_DStringFree(tls, bp+272) goto _1 _1: ; row++ } result = libtcl9_0.XTcl_NewStringObj(tls, (*TTcl_DString)(unsafe.Pointer(bp+48)).Fstring1, int64(-libc.Int32FromInt32(1))) libtcl9_0.XTcl_DStringFree(tls, bp+48) } else { result = libtcl9_0.XTcl_NewObj(tls) } libtcl9_0.XTcl_SetObjResult(tls, interp, result) return TCL_OK } // C documentation // // /* // *---------------------------------------------------------------------- // * // * ParseColor -- // * // * This function extracts color and alpha values from a string. It // * understands standard Tk color formats, alpha suffixes and the color // * formats specific to photo images, which include alpha data. // * // * Results: // * On success, writes red, green, blue and alpha values to the // * corresponding pointers. If the color spec contains no alpha // * information, 255 is taken as transparency value. // * If the input cannot be parsed, leaves an error message in // * interp. Returns a standard Tcl result. // * // * Side effects: // * None. // * // *---------------------------------------------------------------------- // */ func _ParseColor(tls *libc.TLS, interp uintptr, specObj uintptr, display uintptr, colormap TColormap, redPtr uintptr, greenPtr uintptr, bluePtr uintptr, alphaPtr uintptr) (r int32) { bp := tls.Alloc(64) defer tls.Free(64) var specString uintptr var v1, v2, v3 uint8 var _ /* length at bp+0 */ TTcl_Size _, _, _, _ = specString, v1, v2, v3 /* * Find out which color format we have */ specString = libtcl9_0.XTcl_GetStringFromObj(tls, specObj, bp) if *(*TTcl_Size)(unsafe.Pointer(bp)) == 0 { /* Empty string */ v3 = libc.Uint8FromInt32(0) *(*uint8)(unsafe.Pointer(alphaPtr)) = v3 v2 = v3 *(*uint8)(unsafe.Pointer(bluePtr)) = v2 v1 = v2 *(*uint8)(unsafe.Pointer(greenPtr)) = v1 *(*uint8)(unsafe.Pointer(redPtr)) = v1 return TCL_OK } if *(*TTcl_Size)(unsafe.Pointer(bp)) > int64(TK_PHOTO_MAX_COLOR_LENGTH) { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+39697, 0)) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+16, __ccgo_ts+179, __ccgo_ts+29667, __ccgo_ts+37434, __ccgo_ts+39711, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) } if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(specString))) == int32('#') { return _ParseColorAsHex(tls, interp, specString, int32(*(*TTcl_Size)(unsafe.Pointer(bp))), display, colormap, redPtr, greenPtr, bluePtr, alphaPtr) } if _ParseColorAsList(tls, specString, redPtr, greenPtr, bluePtr, alphaPtr) == TCL_OK { return TCL_OK } /* * Parsing the color as standard Tk color always is the last option tried * because TkParseColor() is very slow with values it cannot parse. */ libtcl9_0.XTcl_ResetResult(tls, interp) return _ParseColorAsStandard(tls, interp, specString, int32(*(*TTcl_Size)(unsafe.Pointer(bp))), display, colormap, redPtr, greenPtr, bluePtr, alphaPtr) } // C documentation // // /* // *---------------------------------------------------------------------- // * // * ParseColorAsList -- // * // * This function extracts color and alpha values from a list of 3 or 4 // * integers (the list color format). // * // * Results: // * On success, writes red, green, blue and alpha values to the // * corresponding pointers. If the color spec contains no alpha // * information, 255 is taken as transparency value. // * Returns a standard Tcl result. // * // * Side effects: // * None // * // *---------------------------------------------------------------------- // */ func _ParseColorAsList(tls *libc.TLS, colorString uintptr, redPtr uintptr, greenPtr uintptr, bluePtr uintptr, alphaPtr uintptr) (r int32) { bp := tls.Alloc(16) defer tls.Free(16) var i, v1, v2, v4, v5 int32 var values [4]int32 var _ /* curPos at bp+0 */ uintptr _, _, _, _, _, _ = i, values, v1, v2, v4, v5 *(*uintptr)(unsafe.Pointer(bp)) = colorString i = 0 /* * strtol can give false positives with a sequence of space chars. * To avoid that, advance the pointer to the next non-blank char. */ for { v1 = libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp))))) v2 = libc.BoolInt32(v1 == int32(' ') || libc.Uint32FromInt32(v1)-uint32('\t') < uint32(5)) goto _3 _3: if !(v2 != 0) { break } *(*uintptr)(unsafe.Pointer(bp))++ } for i < int32(4) && libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp))))) != int32('\000') { values[i] = int32(libc.Xstrtol(tls, *(*uintptr)(unsafe.Pointer(bp)), bp, 0)) if values[i] < 0 || values[i] > int32(255) { return int32(TCL_ERROR) } for { v4 = libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp))))) v5 = libc.BoolInt32(v4 == int32(' ') || libc.Uint32FromInt32(v4)-uint32('\t') < uint32(5)) goto _6 _6: if !(v5 != 0) { break } *(*uintptr)(unsafe.Pointer(bp))++ } i++ } if i < int32(3) || libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp))))) != int32('\000') { return int32(TCL_ERROR) } if i < int32(4) { values[int32(3)] = int32(255) } *(*uint8)(unsafe.Pointer(redPtr)) = libc.Uint8FromInt32(values[0]) *(*uint8)(unsafe.Pointer(greenPtr)) = libc.Uint8FromInt32(values[int32(1)]) *(*uint8)(unsafe.Pointer(bluePtr)) = libc.Uint8FromInt32(values[int32(2)]) *(*uint8)(unsafe.Pointer(alphaPtr)) = libc.Uint8FromInt32(values[int32(3)]) return TCL_OK } // C documentation // // /* // *---------------------------------------------------------------------- // * // * ParseColorAsHex -- // * // * This function extracts color and alpha values from a string // * starting with '#', followed by hex digits. It understands both // * the #RGBA form and the #RBG (with optional suffix) // * // * Results: // * On success, writes red, green, blue and alpha values to the // * corresponding pointers. If the color spec contains no alpha // * information, 255 is taken as transparency value. // * Returns a standard Tcl result. // * // * Side effects: // * None. // * // *---------------------------------------------------------------------- // */ func _ParseColorAsHex(tls *libc.TLS, interp uintptr, colorString uintptr, colorStrLen int32, display uintptr, colormap TColormap, redPtr uintptr, greenPtr uintptr, bluePtr uintptr, alphaPtr uintptr) (r int32) { var colorValue uint64 var i int32 _, _ = colorValue, i colorValue = uint64(0) if colorStrLen-int32(1) != int32(4) && colorStrLen-int32(1) != int32(8) { return _ParseColorAsStandard(tls, interp, colorString, colorStrLen, display, colormap, redPtr, greenPtr, bluePtr, alphaPtr) } i = int32(1) for { if !(i < colorStrLen) { break } if !(libc.Xisxdigit(tls, libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(colorString + uintptr(i))))) != 0) { /* * There still is a chance that this is a Tk color with * an alpha suffix */ return _ParseColorAsStandard(tls, interp, colorString, colorStrLen, display, colormap, redPtr, greenPtr, bluePtr, alphaPtr) } goto _1 _1: ; i++ } colorValue = libc.Xstrtoul(tls, colorString+uintptr(1), libc.UintptrFromInt32(0), int32(16)) switch colorStrLen - libc.Int32FromInt32(1) { case int32(4): /* #RGBA format */ *(*uint8)(unsafe.Pointer(redPtr)) = uint8(colorValue >> libc.Int32FromInt32(12) * libc.Uint64FromInt32(0x11)) *(*uint8)(unsafe.Pointer(greenPtr)) = uint8(colorValue >> libc.Int32FromInt32(8) & libc.Uint64FromInt32(0xf) * libc.Uint64FromInt32(0x11)) *(*uint8)(unsafe.Pointer(bluePtr)) = uint8(colorValue >> libc.Int32FromInt32(4) & libc.Uint64FromInt32(0xf) * libc.Uint64FromInt32(0x11)) *(*uint8)(unsafe.Pointer(alphaPtr)) = uint8(colorValue & libc.Uint64FromInt32(0xf) * libc.Uint64FromInt32(0x11)) return TCL_OK case int32(8): /* #RRGGBBAA format */ *(*uint8)(unsafe.Pointer(redPtr)) = uint8(colorValue >> libc.Int32FromInt32(24)) *(*uint8)(unsafe.Pointer(greenPtr)) = uint8(colorValue >> libc.Int32FromInt32(16) & libc.Uint64FromInt32(0xff)) *(*uint8)(unsafe.Pointer(bluePtr)) = uint8(colorValue >> libc.Int32FromInt32(8) & libc.Uint64FromInt32(0xff)) *(*uint8)(unsafe.Pointer(alphaPtr)) = uint8(colorValue & libc.Uint64FromInt32(0xff)) return TCL_OK default: libtcl9_0.XTcl_Panic(tls, __ccgo_ts+39667, 0) } /* Shouldn't get here */ return int32(TCL_ERROR) } // C documentation // // /* // *---------------------------------------------------------------------- // * // * ParseColorAsStandard -- // * // * This function tries to split a color string in a color and a // * suffix part and to extract color and alpha values from them. The // * color part is treated as regular Tk color. // * // * Results: // * On success, writes red, green, blue and alpha values to the // * corresponding pointers. If the color spec contains no alpha // * information, 255 is taken as transparency value. // * Returns a standard Tcl result. // * // * Side effects: // * None. // * // *---------------------------------------------------------------------- // */ func _ParseColorAsStandard(tls *libc.TLS, interp uintptr, specString uintptr, specStrLen int32, display uintptr, colormap TColormap, redPtr uintptr, greenPtr uintptr, bluePtr uintptr, alphaPtr uintptr) (r int32) { bp := tls.Alloc(192) defer tls.Free(192) var colorString, suffixString, v1, v2 uintptr var i int32 var v3 bool var _ /* colorBuffer at bp+16 */ [100]uint8 var _ /* fracAlpha at bp+120 */ float64 var _ /* parsedColor at bp+0 */ TXColor var _ /* suffixAlpha at bp+128 */ uint32 _, _, _, _, _, _ = colorString, i, suffixString, v1, v2, v3 *(*uint32)(unsafe.Pointer(bp + 128)) = uint32(0) /* * Split color data string in color and suffix parts */ v1 = libc.Xstrrchr(tls, specString, int32('@')) suffixString = v1 if v3 = v1 == libc.UintptrFromInt32(0); v3 { v2 = libc.Xstrrchr(tls, specString, int32('#')) suffixString = v2 } if v3 && (v2 == libc.UintptrFromInt32(0) || suffixString == specString) { suffixString = specString + uintptr(specStrLen) colorString = specString } else { libc.Xstrncpy(tls, bp+16, specString, libc.Uint64FromInt64(int64(suffixString)-int64(specString))) (*(*[100]uint8)(unsafe.Pointer(bp + 16)))[int64(suffixString)-int64(specString)] = uint8('\000') colorString = bp + 16 } /* * Try to parse as standard Tk color. * * We don't use Tk_GetColor() et al. here, as those functions * might return a color that does not exactly match the given name * if the colormap is full. Also, we don't really want the color to be * added to the colormap. */ if !(XTkParseColor(tls, display, colormap, colorString, bp) != 0) { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+7139, libc.VaList(bp+144, specString))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+144, __ccgo_ts+179, __ccgo_ts+29667, __ccgo_ts+37434, __ccgo_ts+39711, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) } /* * parse the Suffix */ switch libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(suffixString))) { case int32('\000'): *(*uint32)(unsafe.Pointer(bp + 128)) = uint32(255) case int32('@'): if libtcl9_0.XTcl_GetDouble(tls, libc.UintptrFromInt32(0), suffixString+uintptr(1), bp+120) != TCL_OK { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+39725, libc.VaList(bp+144, suffixString))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+144, __ccgo_ts+179, __ccgo_ts+29667, __ccgo_ts+37434, __ccgo_ts+39782, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) } if *(*float64)(unsafe.Pointer(bp + 120)) < libc.Float64FromInt32(0) || *(*float64)(unsafe.Pointer(bp + 120)) > libc.Float64FromInt32(1) { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+39796, libc.VaList(bp+144, suffixString))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+144, __ccgo_ts+179, __ccgo_ts+29667, __ccgo_ts+37434, __ccgo_ts+39711, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) } *(*uint32)(unsafe.Pointer(bp + 128)) = uint32(libc.Xfloor(tls, float64(*(*float64)(unsafe.Pointer(bp + 120))*libc.Float64FromInt32(255))+float64(0.5))) case int32('#'): if libc.Xstrlen(tls, suffixString+uintptr(1)) < uint64(1) || libc.Xstrlen(tls, suffixString+uintptr(1)) > uint64(2) { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+39862, libc.VaList(bp+144, suffixString))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+144, __ccgo_ts+179, __ccgo_ts+29667, __ccgo_ts+37434, __ccgo_ts+39711, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) } i = int32(1) for { if !(i <= libc.Int32FromUint64(libc.Xstrlen(tls, suffixString+uintptr(1)))) { break } if !(libc.Xisxdigit(tls, libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(suffixString + uintptr(i))))) != 0) { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+39888, libc.VaList(bp+144, suffixString))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+144, __ccgo_ts+179, __ccgo_ts+29667, __ccgo_ts+37434, __ccgo_ts+39711, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) } goto _4 _4: ; i++ } if libc.Xstrlen(tls, suffixString+uintptr(1)) == uint64(1) { libc.Xsscanf(tls, suffixString, __ccgo_ts+39934, libc.VaList(bp+144, bp+128)) *(*uint32)(unsafe.Pointer(bp + 128)) *= uint32(0x11) } else { libc.Xsscanf(tls, suffixString, __ccgo_ts+39939, libc.VaList(bp+144, bp+128)) } default: libtcl9_0.XTcl_Panic(tls, __ccgo_ts+39667, 0) } *(*uint8)(unsafe.Pointer(redPtr)) = libc.Uint8FromInt32(libc.Int32FromUint16((*(*TXColor)(unsafe.Pointer(bp))).Fred) >> libc.Int32FromInt32(8)) *(*uint8)(unsafe.Pointer(greenPtr)) = libc.Uint8FromInt32(libc.Int32FromUint16((*(*TXColor)(unsafe.Pointer(bp))).Fgreen) >> libc.Int32FromInt32(8)) *(*uint8)(unsafe.Pointer(bluePtr)) = libc.Uint8FromInt32(libc.Int32FromUint16((*(*TXColor)(unsafe.Pointer(bp))).Fblue) >> libc.Int32FromInt32(8)) *(*uint8)(unsafe.Pointer(alphaPtr)) = uint8(*(*uint32)(unsafe.Pointer(bp + 128))) return TCL_OK } // C documentation // // /* // *---------------------------------------------------------------------- // * // * TkDebugStringMatchDef -- // * // * Debugging function for StringMatchDef. Basically just an alias for // * that function, intended to expose it directly to tests, as // * StirngMatchDef cannot be sufficiently tested otherwise. // * // * Results: // * See StringMatchDef. // * // * Side effects: // * None // *---------------------------------------------------------------------- // */ func XTkDebugPhotoStringMatchDef(tls *libc.TLS, interp uintptr, data uintptr, formatString uintptr, widthPtr uintptr, heightPtr uintptr) (r int32) { /* Height of image is written to this location */ return _StringMatchDef(tls, data, formatString, widthPtr, heightPtr, interp) } const NANOSVG_SCOPE = "MODULE_SCOPE" const NANOSVG_free = 0 const NANOSVG_malloc = 0 const NANOSVG_realloc = 0 const NSVG_ALIGN_MAX = 2 const NSVG_ALIGN_MEET = 1 const NSVG_ALIGN_MID = 1 const NSVG_ALIGN_MIN = 0 const NSVG_ALIGN_NONE = 0 const NSVG_ALIGN_SLICE = 2 const NSVG_EPSILON = 1e-12 const NSVG_INLINE = 0 const NSVG_KAPPA90 = 0.5522847493 const NSVG_MAX_ATTR = 128 const NSVG_MAX_DASHES = 8 const NSVG_PI = 3.141592653589793 const NSVG_XML_CONTENT = 2 const NSVG_XML_MAX_ATTRIBS = 256 const NSVG_XML_TAG = 1 const NSVG__FIX = 1024 const NSVG__FIXMASK = 1023 const NSVG__FIXSHIFT = 10 const NSVG__MEMPAGE_SIZE = 1024 const NSVG__SUBSAMPLES = 5 type NSVGpaintType = int32 const NSVG_PAINT_UNDEF = -1 const NSVG_PAINT_NONE = 0 const NSVG_PAINT_COLOR = 1 const NSVG_PAINT_LINEAR_GRADIENT = 2 const NSVG_PAINT_RADIAL_GRADIENT = 3 type NSVGspreadType = int32 const NSVG_SPREAD_PAD = 0 const NSVG_SPREAD_REFLECT = 1 const NSVG_SPREAD_REPEAT = 2 type NSVGlineJoin = int32 const NSVG_JOIN_MITER = 0 const NSVG_JOIN_ROUND = 1 const NSVG_JOIN_BEVEL = 2 type NSVGlineCap = int32 const NSVG_CAP_BUTT = 0 const NSVG_CAP_ROUND = 1 const NSVG_CAP_SQUARE = 2 type NSVGfillRule = int32 const NSVG_FILLRULE_NONZERO = 0 const NSVG_FILLRULE_EVENODD = 1 type NSVGflags = int32 const NSVG_FLAGS_VISIBLE = 1 type TNSVGgradientStop = struct { Fcolor uint32 Foffset float32 } type TNSVGgradient = struct { Fxform [6]float32 Fspread uint8 Ffx float32 Ffy float32 Fnstops int32 Fstops [1]TNSVGgradientStop } type TNSVGpaint = struct { Ftype1 int8 F__ccgo1_8 struct { Fgradient [0]uintptr Fcolor uint32 F__ccgo_pad2 [4]byte } } type TNSVGpath = struct { Fpts uintptr Fnpts int32 Fclosed uint8 Fbounds [4]float32 Fnext uintptr } type TNSVGshape = struct { Fid [64]uint8 Ffill TNSVGpaint Fstroke TNSVGpaint Fopacity float32 FstrokeWidth float32 FstrokeDashOffset float32 FstrokeDashArray [8]float32 FstrokeDashCount uint8 FstrokeLineJoin uint8 FstrokeLineCap uint8 FmiterLimit float32 FfillRule uint8 Fflags uint8 Fbounds [4]float32 FfillGradient [64]uint8 FstrokeGradient [64]uint8 Fxform [6]float32 Fpaths uintptr Fnext uintptr } type TNSVGimage = struct { Fwidth float32 Fheight float32 Fshapes uintptr } func _nsvg__isspace(tls *libc.TLS, c uint8) (r int32) { return libc.BoolInt32(libc.Xstrchr(tls, __ccgo_ts+41383, libc.Int32FromUint8(c)) != uintptr(0)) } func _nsvg__isdigit(tls *libc.TLS, c uint8) (r int32) { return libc.BoolInt32(libc.Int32FromUint8(c) >= int32('0') && libc.Int32FromUint8(c) <= int32('9')) } func _nsvg__parseContent(tls *libc.TLS, s uintptr, contentCb uintptr, ud uintptr) { for *(*uint8)(unsafe.Pointer(s)) != 0 && _nsvg__isspace(tls, *(*uint8)(unsafe.Pointer(s))) != 0 { s++ } if !(*(*uint8)(unsafe.Pointer(s)) != 0) { return } if contentCb != 0 { (*(*func(*libc.TLS, uintptr, uintptr))(unsafe.Pointer(&struct{ uintptr }{contentCb})))(tls, ud, s) } } func _nsvg__parseElement(tls *libc.TLS, s uintptr, startelCb uintptr, endelCb uintptr, ud uintptr) { bp := tls.Alloc(2048) defer tls.Free(2048) var cbname, name, value, v1, v2, v3 uintptr var end, nattr, start, v4, v5, v6, v7 int32 var quote uint8 var _ /* attr at bp+0 */ [256]uintptr _, _, _, _, _, _, _, _, _, _, _, _, _, _ = cbname, end, name, nattr, quote, start, value, v1, v2, v3, v4, v5, v6, v7 nattr = 0 start = 0 end = 0 for *(*uint8)(unsafe.Pointer(s)) != 0 && _nsvg__isspace(tls, *(*uint8)(unsafe.Pointer(s))) != 0 { s++ } if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(s))) == int32('/') { s++ end = int32(1) } else { start = int32(1) } if !(*(*uint8)(unsafe.Pointer(s)) != 0) || libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(s))) == int32('?') || libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(s))) == int32('!') { return } cbname = s for *(*uint8)(unsafe.Pointer(s)) != 0 && !(_nsvg__isspace(tls, *(*uint8)(unsafe.Pointer(s))) != 0) { s++ } if *(*uint8)(unsafe.Pointer(s)) != 0 { v1 = s s++ *(*uint8)(unsafe.Pointer(v1)) = uint8('\000') } for !(end != 0) && *(*uint8)(unsafe.Pointer(s)) != 0 && nattr < libc.Int32FromInt32(NSVG_XML_MAX_ATTRIBS)-libc.Int32FromInt32(3) { name = libc.UintptrFromInt32(0) value = libc.UintptrFromInt32(0) for *(*uint8)(unsafe.Pointer(s)) != 0 && _nsvg__isspace(tls, *(*uint8)(unsafe.Pointer(s))) != 0 { s++ } if !(*(*uint8)(unsafe.Pointer(s)) != 0) { break } if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(s))) == int32('/') { end = int32(1) break } name = s for *(*uint8)(unsafe.Pointer(s)) != 0 && !(_nsvg__isspace(tls, *(*uint8)(unsafe.Pointer(s))) != 0) && libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(s))) != int32('=') { s++ } if *(*uint8)(unsafe.Pointer(s)) != 0 { v2 = s s++ *(*uint8)(unsafe.Pointer(v2)) = uint8('\000') } for *(*uint8)(unsafe.Pointer(s)) != 0 && libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(s))) != int32('"') && libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(s))) != int32('\'') { s++ } if !(*(*uint8)(unsafe.Pointer(s)) != 0) { break } quote = *(*uint8)(unsafe.Pointer(s)) s++ value = s for *(*uint8)(unsafe.Pointer(s)) != 0 && libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(s))) != libc.Int32FromUint8(quote) { s++ } if *(*uint8)(unsafe.Pointer(s)) != 0 { v3 = s s++ *(*uint8)(unsafe.Pointer(v3)) = uint8('\000') } if name != 0 && value != 0 { v4 = nattr nattr++ (*(*[256]uintptr)(unsafe.Pointer(bp)))[v4] = name v5 = nattr nattr++ (*(*[256]uintptr)(unsafe.Pointer(bp)))[v5] = value } } v6 = nattr nattr++ (*(*[256]uintptr)(unsafe.Pointer(bp)))[v6] = uintptr(0) v7 = nattr nattr++ (*(*[256]uintptr)(unsafe.Pointer(bp)))[v7] = uintptr(0) if start != 0 && startelCb != 0 { (*(*func(*libc.TLS, uintptr, uintptr, uintptr))(unsafe.Pointer(&struct{ uintptr }{startelCb})))(tls, ud, cbname, bp) } if end != 0 && endelCb != 0 { (*(*func(*libc.TLS, uintptr, uintptr))(unsafe.Pointer(&struct{ uintptr }{endelCb})))(tls, ud, cbname) } } func Xnsvg__parseXML(tls *libc.TLS, input uintptr, startelCb uintptr, endelCb uintptr, contentCb uintptr, ud uintptr) (r int32) { var mark, s, v1, v2 uintptr var state int32 _, _, _, _, _ = mark, s, state, v1, v2 s = input mark = s state = int32(NSVG_XML_CONTENT) for *(*uint8)(unsafe.Pointer(s)) != 0 { if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(s))) == int32('<') && state == int32(NSVG_XML_CONTENT) { v1 = s s++ *(*uint8)(unsafe.Pointer(v1)) = uint8('\000') _nsvg__parseContent(tls, mark, contentCb, ud) mark = s state = int32(NSVG_XML_TAG) } else { if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(s))) == int32('>') && state == int32(NSVG_XML_TAG) { v2 = s s++ *(*uint8)(unsafe.Pointer(v2)) = uint8('\000') _nsvg__parseContent(tls, mark, contentCb, ud) _nsvg__parseElement(tls, mark, startelCb, endelCb, ud) mark = s state = int32(NSVG_XML_CONTENT) } else { s++ } } } return int32(1) } type NSVGgradientUnits = int32 const NSVG_USER_SPACE = 0 const NSVG_OBJECT_SPACE = 1 type NSVGunits = int32 const NSVG_UNITS_USER = 0 const NSVG_UNITS_PX = 1 const NSVG_UNITS_PT = 2 const NSVG_UNITS_PC = 3 const NSVG_UNITS_MM = 4 const NSVG_UNITS_CM = 5 const NSVG_UNITS_IN = 6 const NSVG_UNITS_PERCENT = 7 const NSVG_UNITS_EM = 8 const NSVG_UNITS_EX = 9 type NSVGvisible = int32 const NSVG_VIS_DISPLAY = 1 const NSVG_VIS_VISIBLE = 2 type TNSVGcoordinate = struct { Fvalue float32 Funits int32 } type TNSVGlinearData = struct { Fx1 TNSVGcoordinate Fy1 TNSVGcoordinate Fx2 TNSVGcoordinate Fy2 TNSVGcoordinate } type TNSVGradialData = struct { Fcx TNSVGcoordinate Fcy TNSVGcoordinate Fr TNSVGcoordinate Ffx TNSVGcoordinate Ffy TNSVGcoordinate } type TNSVGgradientData = struct { Fid [64]uint8 Fref [64]uint8 Ftype1 int8 F__ccgo3_132 struct { Fradial [0]TNSVGradialData Flinear TNSVGlinearData F__ccgo_pad2 [8]byte } Fspread uint8 Funits uint8 Fxform [6]float32 Fnstops int32 Fstops uintptr Fnext uintptr } type TNSVGattrib = struct { Fid [64]uint8 Fxform [6]float32 FfillColor uint32 FstrokeColor uint32 Fopacity float32 FfillOpacity float32 FstrokeOpacity float32 FfillGradient [64]uint8 FstrokeGradient [64]uint8 FstrokeWidth float32 FstrokeDashOffset float32 FstrokeDashArray [8]float32 FstrokeDashCount int32 FstrokeLineJoin uint8 FstrokeLineCap uint8 FmiterLimit float32 FfillRule uint8 FfontSize float32 FstopColor uint32 FstopOpacity float32 FstopOffset float32 FhasFill uint8 FhasStroke uint8 Fvisible uint8 } type TNSVGstyles = struct { Fname uintptr Fdescription uintptr Fnext uintptr } type TNSVGparser = struct { Fattr [128]TNSVGattrib FattrHead int32 Fpts uintptr Fnpts int32 Fcpts int32 Fplist uintptr Fimage uintptr Fstyles uintptr Fgradients uintptr FshapesTail uintptr FviewMinx float32 FviewMiny float32 FviewWidth float32 FviewHeight float32 FalignX int32 FalignY int32 FalignType int32 Fdpi float32 FpathFlag uint8 FdefsFlag uint8 FstyleFlag uint8 } func _nsvg__xformIdentity(tls *libc.TLS, t uintptr) { *(*float32)(unsafe.Pointer(t)) = libc.Float32FromFloat32(1) *(*float32)(unsafe.Pointer(t + 1*4)) = libc.Float32FromFloat32(0) *(*float32)(unsafe.Pointer(t + 2*4)) = libc.Float32FromFloat32(0) *(*float32)(unsafe.Pointer(t + 3*4)) = libc.Float32FromFloat32(1) *(*float32)(unsafe.Pointer(t + 4*4)) = libc.Float32FromFloat32(0) *(*float32)(unsafe.Pointer(t + 5*4)) = libc.Float32FromFloat32(0) } func _nsvg__xformSetTranslation(tls *libc.TLS, t uintptr, tx float32, ty float32) { *(*float32)(unsafe.Pointer(t)) = libc.Float32FromFloat32(1) *(*float32)(unsafe.Pointer(t + 1*4)) = libc.Float32FromFloat32(0) *(*float32)(unsafe.Pointer(t + 2*4)) = libc.Float32FromFloat32(0) *(*float32)(unsafe.Pointer(t + 3*4)) = libc.Float32FromFloat32(1) *(*float32)(unsafe.Pointer(t + 4*4)) = tx *(*float32)(unsafe.Pointer(t + 5*4)) = ty } func _nsvg__xformSetScale(tls *libc.TLS, t uintptr, sx float32, sy float32) { *(*float32)(unsafe.Pointer(t)) = sx *(*float32)(unsafe.Pointer(t + 1*4)) = libc.Float32FromFloat32(0) *(*float32)(unsafe.Pointer(t + 2*4)) = libc.Float32FromFloat32(0) *(*float32)(unsafe.Pointer(t + 3*4)) = sy *(*float32)(unsafe.Pointer(t + 4*4)) = libc.Float32FromFloat32(0) *(*float32)(unsafe.Pointer(t + 5*4)) = libc.Float32FromFloat32(0) } func _nsvg__xformSetSkewX(tls *libc.TLS, t uintptr, a float32) { *(*float32)(unsafe.Pointer(t)) = libc.Float32FromFloat32(1) *(*float32)(unsafe.Pointer(t + 1*4)) = libc.Float32FromFloat32(0) *(*float32)(unsafe.Pointer(t + 2*4)) = libc.Xtanf(tls, a) *(*float32)(unsafe.Pointer(t + 3*4)) = libc.Float32FromFloat32(1) *(*float32)(unsafe.Pointer(t + 4*4)) = libc.Float32FromFloat32(0) *(*float32)(unsafe.Pointer(t + 5*4)) = libc.Float32FromFloat32(0) } func _nsvg__xformSetSkewY(tls *libc.TLS, t uintptr, a float32) { *(*float32)(unsafe.Pointer(t)) = libc.Float32FromFloat32(1) *(*float32)(unsafe.Pointer(t + 1*4)) = libc.Xtanf(tls, a) *(*float32)(unsafe.Pointer(t + 2*4)) = libc.Float32FromFloat32(0) *(*float32)(unsafe.Pointer(t + 3*4)) = libc.Float32FromFloat32(1) *(*float32)(unsafe.Pointer(t + 4*4)) = libc.Float32FromFloat32(0) *(*float32)(unsafe.Pointer(t + 5*4)) = libc.Float32FromFloat32(0) } func _nsvg__xformSetRotation(tls *libc.TLS, t uintptr, a float32) { var cs, sn float32 _, _ = cs, sn cs = libc.Xcosf(tls, a) sn = libc.Xsinf(tls, a) *(*float32)(unsafe.Pointer(t)) = cs *(*float32)(unsafe.Pointer(t + 1*4)) = sn *(*float32)(unsafe.Pointer(t + 2*4)) = -sn *(*float32)(unsafe.Pointer(t + 3*4)) = cs *(*float32)(unsafe.Pointer(t + 4*4)) = libc.Float32FromFloat32(0) *(*float32)(unsafe.Pointer(t + 5*4)) = libc.Float32FromFloat32(0) } func _nsvg__xformMultiply(tls *libc.TLS, t uintptr, s uintptr) { var t0, t2, t4 float32 _, _, _ = t0, t2, t4 t0 = float32(*(*float32)(unsafe.Pointer(t))**(*float32)(unsafe.Pointer(s))) + float32(*(*float32)(unsafe.Pointer(t + 1*4))**(*float32)(unsafe.Pointer(s + 2*4))) t2 = float32(*(*float32)(unsafe.Pointer(t + 2*4))**(*float32)(unsafe.Pointer(s))) + float32(*(*float32)(unsafe.Pointer(t + 3*4))**(*float32)(unsafe.Pointer(s + 2*4))) t4 = float32(*(*float32)(unsafe.Pointer(t + 4*4))**(*float32)(unsafe.Pointer(s))) + float32(*(*float32)(unsafe.Pointer(t + 5*4))**(*float32)(unsafe.Pointer(s + 2*4))) + *(*float32)(unsafe.Pointer(s + 4*4)) *(*float32)(unsafe.Pointer(t + 1*4)) = float32(*(*float32)(unsafe.Pointer(t))**(*float32)(unsafe.Pointer(s + 1*4))) + float32(*(*float32)(unsafe.Pointer(t + 1*4))**(*float32)(unsafe.Pointer(s + 3*4))) *(*float32)(unsafe.Pointer(t + 3*4)) = float32(*(*float32)(unsafe.Pointer(t + 2*4))**(*float32)(unsafe.Pointer(s + 1*4))) + float32(*(*float32)(unsafe.Pointer(t + 3*4))**(*float32)(unsafe.Pointer(s + 3*4))) *(*float32)(unsafe.Pointer(t + 5*4)) = float32(*(*float32)(unsafe.Pointer(t + 4*4))**(*float32)(unsafe.Pointer(s + 1*4))) + float32(*(*float32)(unsafe.Pointer(t + 5*4))**(*float32)(unsafe.Pointer(s + 3*4))) + *(*float32)(unsafe.Pointer(s + 5*4)) *(*float32)(unsafe.Pointer(t)) = t0 *(*float32)(unsafe.Pointer(t + 2*4)) = t2 *(*float32)(unsafe.Pointer(t + 4*4)) = t4 } func _nsvg__xformInverse(tls *libc.TLS, inv uintptr, t uintptr) { var det, invdet float64 _, _ = det, invdet det = float64(float64(*(*float32)(unsafe.Pointer(t)))*float64(*(*float32)(unsafe.Pointer(t + 3*4)))) - float64(float64(*(*float32)(unsafe.Pointer(t + 2*4)))*float64(*(*float32)(unsafe.Pointer(t + 1*4)))) if det > -libc.Float64FromFloat64(1e-06) && det < float64(1e-06) { _nsvg__xformIdentity(tls, t) return } invdet = float64(1) / det *(*float32)(unsafe.Pointer(inv)) = float32(float64(float64(*(*float32)(unsafe.Pointer(t + 3*4))) * invdet)) *(*float32)(unsafe.Pointer(inv + 2*4)) = float32(float64(float64(-*(*float32)(unsafe.Pointer(t + 2*4))) * invdet)) *(*float32)(unsafe.Pointer(inv + 4*4)) = float32(float64((float64(float64(*(*float32)(unsafe.Pointer(t + 2*4)))*float64(*(*float32)(unsafe.Pointer(t + 5*4)))) - float64(float64(*(*float32)(unsafe.Pointer(t + 3*4)))*float64(*(*float32)(unsafe.Pointer(t + 4*4))))) * invdet)) *(*float32)(unsafe.Pointer(inv + 1*4)) = float32(float64(float64(-*(*float32)(unsafe.Pointer(t + 1*4))) * invdet)) *(*float32)(unsafe.Pointer(inv + 3*4)) = float32(float64(float64(*(*float32)(unsafe.Pointer(t))) * invdet)) *(*float32)(unsafe.Pointer(inv + 5*4)) = float32(float64((float64(float64(*(*float32)(unsafe.Pointer(t + 1*4)))*float64(*(*float32)(unsafe.Pointer(t + 4*4)))) - float64(float64(*(*float32)(unsafe.Pointer(t)))*float64(*(*float32)(unsafe.Pointer(t + 5*4))))) * invdet)) } func _nsvg__xformPremultiply(tls *libc.TLS, t uintptr, s uintptr) { bp := tls.Alloc(32) defer tls.Free(32) var _ /* s2 at bp+0 */ [6]float32 libc.Xmemcpy(tls, bp, s, libc.Uint64FromInt64(4)*libc.Uint64FromInt32(6)) _nsvg__xformMultiply(tls, bp, t) libc.Xmemcpy(tls, t, bp, libc.Uint64FromInt64(4)*libc.Uint64FromInt32(6)) } func _nsvg__xformPoint(tls *libc.TLS, dx uintptr, dy uintptr, x float32, y float32, t uintptr) { *(*float32)(unsafe.Pointer(dx)) = float32(x**(*float32)(unsafe.Pointer(t))) + float32(y**(*float32)(unsafe.Pointer(t + 2*4))) + *(*float32)(unsafe.Pointer(t + 4*4)) *(*float32)(unsafe.Pointer(dy)) = float32(x**(*float32)(unsafe.Pointer(t + 1*4))) + float32(y**(*float32)(unsafe.Pointer(t + 3*4))) + *(*float32)(unsafe.Pointer(t + 5*4)) } func _nsvg__xformVec(tls *libc.TLS, dx uintptr, dy uintptr, x float32, y float32, t uintptr) { *(*float32)(unsafe.Pointer(dx)) = float32(x**(*float32)(unsafe.Pointer(t))) + float32(y**(*float32)(unsafe.Pointer(t + 2*4))) *(*float32)(unsafe.Pointer(dy)) = float32(x**(*float32)(unsafe.Pointer(t + 1*4))) + float32(y**(*float32)(unsafe.Pointer(t + 3*4))) } func _nsvg__ptInBounds(tls *libc.TLS, pt uintptr, bounds uintptr) (r int32) { return libc.BoolInt32(*(*float32)(unsafe.Pointer(pt)) >= *(*float32)(unsafe.Pointer(bounds)) && *(*float32)(unsafe.Pointer(pt)) <= *(*float32)(unsafe.Pointer(bounds + 2*4)) && *(*float32)(unsafe.Pointer(pt + 1*4)) >= *(*float32)(unsafe.Pointer(bounds + 1*4)) && *(*float32)(unsafe.Pointer(pt + 1*4)) <= *(*float32)(unsafe.Pointer(bounds + 3*4))) } func _nsvg__evalBezier(tls *libc.TLS, t float64, p0 float64, p1 float64, p2 float64, p3 float64) (r float64) { var it float64 _ = it it = float64(1) - t return float64(float64(float64(it*it)*it)*p0) + float64(float64(float64(float64(float64(3)*it)*it)*t)*p1) + float64(float64(float64(float64(float64(3)*it)*t)*t)*p2) + float64(float64(float64(t*t)*t)*p3) } func _nsvg__curveBounds(tls *libc.TLS, bounds uintptr, curve uintptr) { var a2, b2, b2ac, c, t, v float64 var count, i, j, v22, v23, v24 int32 var roots [2]float64 var v0, v1, v2, v3 uintptr var v11, v10, v111, v12, v13, v15, v16, v17, v18, v21, v20, v26, v27, v28, v31, v30, v311, v32, v33, v35, v5, v6, v7, v8 float32 _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = a2, b2, b2ac, c, count, i, j, roots, t, v, v0, v1, v2, v3, v11, v10, v111, v12, v13, v15, v16, v17, v18, v21, v20, v22, v23, v24, v26, v27, v28, v31, v30, v311, v32, v33, v35, v5, v6, v7, v8 v0 = curve v1 = curve + 2*4 v2 = curve + 4*4 v3 = curve + 6*4 v11 = *(*float32)(unsafe.Pointer(v0)) v21 = *(*float32)(unsafe.Pointer(v3)) if v11 < v21 { v5 = v11 } else { v5 = v21 } v31 = v5 goto _4 _4: *(*float32)(unsafe.Pointer(bounds)) = v31 v6 = *(*float32)(unsafe.Pointer(v0 + 1*4)) v7 = *(*float32)(unsafe.Pointer(v3 + 1*4)) if v6 < v7 { v10 = v6 } else { v10 = v7 } v8 = v10 goto _9 _9: *(*float32)(unsafe.Pointer(bounds + 1*4)) = v8 v111 = *(*float32)(unsafe.Pointer(v0)) v12 = *(*float32)(unsafe.Pointer(v3)) if v111 > v12 { v15 = v111 } else { v15 = v12 } v13 = v15 goto _14 _14: *(*float32)(unsafe.Pointer(bounds + 2*4)) = v13 v16 = *(*float32)(unsafe.Pointer(v0 + 1*4)) v17 = *(*float32)(unsafe.Pointer(v3 + 1*4)) if v16 > v17 { v20 = v16 } else { v20 = v17 } v18 = v20 goto _19 _19: *(*float32)(unsafe.Pointer(bounds + 3*4)) = v18 if _nsvg__ptInBounds(tls, v1, bounds) != 0 && _nsvg__ptInBounds(tls, v2, bounds) != 0 { return } i = 0 for { if !(i < int32(2)) { break } a2 = float64(-libc.Float64FromFloat64(3)*float64(*(*float32)(unsafe.Pointer(v0 + uintptr(i)*4)))) + float64(float64(9)*float64(*(*float32)(unsafe.Pointer(v1 + uintptr(i)*4)))) - float64(float64(9)*float64(*(*float32)(unsafe.Pointer(v2 + uintptr(i)*4)))) + float64(float64(3)*float64(*(*float32)(unsafe.Pointer(v3 + uintptr(i)*4)))) b2 = float64(float64(6)*float64(*(*float32)(unsafe.Pointer(v0 + uintptr(i)*4)))) - float64(float64(12)*float64(*(*float32)(unsafe.Pointer(v1 + uintptr(i)*4)))) + float64(float64(6)*float64(*(*float32)(unsafe.Pointer(v2 + uintptr(i)*4)))) c = float64(float64(3)*float64(*(*float32)(unsafe.Pointer(v1 + uintptr(i)*4)))) - float64(float64(3)*float64(*(*float32)(unsafe.Pointer(v0 + uintptr(i)*4)))) count = 0 if libc.Xfabs(tls, a2) < float64(NSVG_EPSILON) { if libc.Xfabs(tls, b2) > float64(NSVG_EPSILON) { t = -c / b2 if t > float64(NSVG_EPSILON) && t < libc.Float64FromFloat64(1)-libc.Float64FromFloat64(NSVG_EPSILON) { v22 = count count++ roots[v22] = t } } } else { b2ac = float64(b2*b2) - float64(float64(float64(4)*c)*a2) if b2ac > float64(NSVG_EPSILON) { t = (-b2 + libc.Xsqrt(tls, b2ac)) / float64(float64(2)*a2) if t > float64(NSVG_EPSILON) && t < libc.Float64FromFloat64(1)-libc.Float64FromFloat64(NSVG_EPSILON) { v23 = count count++ roots[v23] = t } t = (-b2 - libc.Xsqrt(tls, b2ac)) / float64(float64(2)*a2) if t > float64(NSVG_EPSILON) && t < libc.Float64FromFloat64(1)-libc.Float64FromFloat64(NSVG_EPSILON) { v24 = count count++ roots[v24] = t } } } j = 0 for { if !(j < count) { break } v = _nsvg__evalBezier(tls, roots[j], float64(*(*float32)(unsafe.Pointer(v0 + uintptr(i)*4))), float64(*(*float32)(unsafe.Pointer(v1 + uintptr(i)*4))), float64(*(*float32)(unsafe.Pointer(v2 + uintptr(i)*4))), float64(*(*float32)(unsafe.Pointer(v3 + uintptr(i)*4)))) v26 = *(*float32)(unsafe.Pointer(bounds + uintptr(0+i)*4)) v27 = float32(v) if v26 < v27 { v30 = v26 } else { v30 = v27 } v28 = v30 goto _29 _29: *(*float32)(unsafe.Pointer(bounds + uintptr(0+i)*4)) = v28 v311 = *(*float32)(unsafe.Pointer(bounds + uintptr(int32(2)+i)*4)) v32 = float32(v) if v311 > v32 { v35 = v311 } else { v35 = v32 } v33 = v35 goto _34 _34: *(*float32)(unsafe.Pointer(bounds + uintptr(int32(2)+i)*4)) = v33 goto _25 _25: ; j++ } goto _21 _21: ; i++ } } func _nsvg__createParser(tls *libc.TLS) (r uintptr) { var p uintptr _ = p p = libtcl9_0.XTcl_Alloc(tls, uint64(40040)) if p == libc.UintptrFromInt32(0) { goto error } libc.Xmemset(tls, p, 0, uint64(40040)) (*TNSVGparser)(unsafe.Pointer(p)).Fimage = libtcl9_0.XTcl_Alloc(tls, uint64(16)) if (*TNSVGparser)(unsafe.Pointer(p)).Fimage == libc.UintptrFromInt32(0) { goto error } libc.Xmemset(tls, (*TNSVGparser)(unsafe.Pointer(p)).Fimage, 0, uint64(16)) _nsvg__xformIdentity(tls, p+64) libc.Xmemset(tls, p, 0, uint64(64)) (*(*TNSVGattrib)(unsafe.Pointer(p))).FfillColor = libc.Uint32FromInt32(0) | libc.Uint32FromInt32(0)< (*TNSVGparser)(unsafe.Pointer(p)).Fcpts { if (*TNSVGparser)(unsafe.Pointer(p)).Fcpts != 0 { v1 = (*TNSVGparser)(unsafe.Pointer(p)).Fcpts * int32(2) } else { v1 = int32(8) } (*TNSVGparser)(unsafe.Pointer(p)).Fcpts = v1 (*TNSVGparser)(unsafe.Pointer(p)).Fpts = libtcl9_0.XTcl_Realloc(tls, (*TNSVGparser)(unsafe.Pointer(p)).Fpts, libc.Uint64FromInt32((*TNSVGparser)(unsafe.Pointer(p)).Fcpts*int32(2))*uint64(4)) if !((*TNSVGparser)(unsafe.Pointer(p)).Fpts != 0) { return } } *(*float32)(unsafe.Pointer((*TNSVGparser)(unsafe.Pointer(p)).Fpts + uintptr((*TNSVGparser)(unsafe.Pointer(p)).Fnpts*int32(2)+0)*4)) = x *(*float32)(unsafe.Pointer((*TNSVGparser)(unsafe.Pointer(p)).Fpts + uintptr((*TNSVGparser)(unsafe.Pointer(p)).Fnpts*int32(2)+int32(1))*4)) = y (*TNSVGparser)(unsafe.Pointer(p)).Fnpts++ } func _nsvg__moveTo(tls *libc.TLS, p uintptr, x float32, y float32) { if (*TNSVGparser)(unsafe.Pointer(p)).Fnpts > 0 { *(*float32)(unsafe.Pointer((*TNSVGparser)(unsafe.Pointer(p)).Fpts + uintptr(((*TNSVGparser)(unsafe.Pointer(p)).Fnpts-int32(1))*int32(2)+0)*4)) = x *(*float32)(unsafe.Pointer((*TNSVGparser)(unsafe.Pointer(p)).Fpts + uintptr(((*TNSVGparser)(unsafe.Pointer(p)).Fnpts-int32(1))*int32(2)+int32(1))*4)) = y } else { _nsvg__addPoint(tls, p, x, y) } } func _nsvg__lineTo(tls *libc.TLS, p uintptr, x float32, y float32) { var dx, dy, px, py float32 _, _, _, _ = dx, dy, px, py if (*TNSVGparser)(unsafe.Pointer(p)).Fnpts > 0 { px = *(*float32)(unsafe.Pointer((*TNSVGparser)(unsafe.Pointer(p)).Fpts + uintptr(((*TNSVGparser)(unsafe.Pointer(p)).Fnpts-int32(1))*int32(2)+0)*4)) py = *(*float32)(unsafe.Pointer((*TNSVGparser)(unsafe.Pointer(p)).Fpts + uintptr(((*TNSVGparser)(unsafe.Pointer(p)).Fnpts-int32(1))*int32(2)+int32(1))*4)) dx = x - px dy = y - py _nsvg__addPoint(tls, p, px+dx/libc.Float32FromFloat32(3), py+dy/libc.Float32FromFloat32(3)) _nsvg__addPoint(tls, p, x-dx/libc.Float32FromFloat32(3), y-dy/libc.Float32FromFloat32(3)) _nsvg__addPoint(tls, p, x, y) } } func _nsvg__cubicBezTo(tls *libc.TLS, p uintptr, cpx1 float32, cpy1 float32, cpx2 float32, cpy2 float32, x float32, y float32) { if (*TNSVGparser)(unsafe.Pointer(p)).Fnpts > 0 { _nsvg__addPoint(tls, p, cpx1, cpy1) _nsvg__addPoint(tls, p, cpx2, cpy2) _nsvg__addPoint(tls, p, x, y) } } func _nsvg__getAttr(tls *libc.TLS, p uintptr) (r uintptr) { return p + uintptr((*TNSVGparser)(unsafe.Pointer(p)).FattrHead)*312 } func _nsvg__pushAttr(tls *libc.TLS, p uintptr) { if (*TNSVGparser)(unsafe.Pointer(p)).FattrHead < libc.Int32FromInt32(NSVG_MAX_ATTR)-libc.Int32FromInt32(1) { (*TNSVGparser)(unsafe.Pointer(p)).FattrHead++ libc.Xmemcpy(tls, p+uintptr((*TNSVGparser)(unsafe.Pointer(p)).FattrHead)*312, p+uintptr((*TNSVGparser)(unsafe.Pointer(p)).FattrHead-int32(1))*312, uint64(312)) } } func _nsvg__popAttr(tls *libc.TLS, p uintptr) { if (*TNSVGparser)(unsafe.Pointer(p)).FattrHead > 0 { (*TNSVGparser)(unsafe.Pointer(p)).FattrHead-- } } func _nsvg__actualOrigX(tls *libc.TLS, p uintptr) (r float32) { return (*TNSVGparser)(unsafe.Pointer(p)).FviewMinx } func _nsvg__actualOrigY(tls *libc.TLS, p uintptr) (r float32) { return (*TNSVGparser)(unsafe.Pointer(p)).FviewMiny } func _nsvg__actualWidth(tls *libc.TLS, p uintptr) (r float32) { return (*TNSVGparser)(unsafe.Pointer(p)).FviewWidth } func _nsvg__actualHeight(tls *libc.TLS, p uintptr) (r float32) { return (*TNSVGparser)(unsafe.Pointer(p)).FviewHeight } func _nsvg__actualLength(tls *libc.TLS, p uintptr) (r float32) { var h, w float32 _, _ = h, w w = _nsvg__actualWidth(tls, p) h = _nsvg__actualHeight(tls, p) return libc.Xsqrtf(tls, float32(w*w)+float32(h*h)) / libc.Xsqrtf(tls, libc.Float32FromFloat32(2)) } func _nsvg__convertToPixels(tls *libc.TLS, p uintptr, c TNSVGcoordinate, orig float32, length float32) (r float32) { var attr uintptr _ = attr attr = _nsvg__getAttr(tls, p) switch c.Funits { case int32(NSVG_UNITS_USER): return c.Fvalue case int32(NSVG_UNITS_PX): return c.Fvalue case int32(NSVG_UNITS_PT): return float32(c.Fvalue / libc.Float32FromFloat32(72) * (*TNSVGparser)(unsafe.Pointer(p)).Fdpi) case int32(NSVG_UNITS_PC): return float32(c.Fvalue / libc.Float32FromFloat32(6) * (*TNSVGparser)(unsafe.Pointer(p)).Fdpi) case int32(NSVG_UNITS_MM): return float32(c.Fvalue / libc.Float32FromFloat32(25.4) * (*TNSVGparser)(unsafe.Pointer(p)).Fdpi) case int32(NSVG_UNITS_CM): return float32(c.Fvalue / libc.Float32FromFloat32(2.54) * (*TNSVGparser)(unsafe.Pointer(p)).Fdpi) case int32(NSVG_UNITS_IN): return float32(c.Fvalue * (*TNSVGparser)(unsafe.Pointer(p)).Fdpi) case int32(NSVG_UNITS_EM): return float32(c.Fvalue * (*TNSVGattrib)(unsafe.Pointer(attr)).FfontSize) case int32(NSVG_UNITS_EX): return float32(float32(c.Fvalue*(*TNSVGattrib)(unsafe.Pointer(attr)).FfontSize) * libc.Float32FromFloat32(0.52)) case int32(NSVG_UNITS_PERCENT): return orig + float32(c.Fvalue/libc.Float32FromFloat32(100)*length) default: return c.Fvalue } return c.Fvalue } func _nsvg__findGradientData(tls *libc.TLS, p uintptr, id uintptr) (r uintptr) { var grad uintptr _ = grad grad = (*TNSVGparser)(unsafe.Pointer(p)).Fgradients if id == libc.UintptrFromInt32(0) || libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(id))) == int32('\000') { return libc.UintptrFromInt32(0) } for grad != libc.UintptrFromInt32(0) { if libc.Xstrcmp(tls, grad, id) == 0 { return grad } grad = (*TNSVGgradientData)(unsafe.Pointer(grad)).Fnext } return libc.UintptrFromInt32(0) } func _nsvg__createGradient(tls *libc.TLS, p uintptr, id uintptr, localBounds uintptr, xform uintptr, paintType uintptr) (r1 uintptr) { var cx, cy, dx, dy, fx, fy, ox, oy, r, sh, sl, sw, x1, x2, y1, y2 float32 var data, grad, nextRef, ref, stops uintptr var nstops, refIter int32 _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = cx, cy, data, dx, dy, fx, fy, grad, nextRef, nstops, ox, oy, r, ref, refIter, sh, sl, stops, sw, x1, x2, y1, y2 data = libc.UintptrFromInt32(0) ref = libc.UintptrFromInt32(0) stops = libc.UintptrFromInt32(0) nstops = 0 data = _nsvg__findGradientData(tls, p, id) if data == libc.UintptrFromInt32(0) { return libc.UintptrFromInt32(0) } ref = data refIter = 0 for ref != libc.UintptrFromInt32(0) { nextRef = libc.UintptrFromInt32(0) if stops == libc.UintptrFromInt32(0) && (*TNSVGgradientData)(unsafe.Pointer(ref)).Fstops != libc.UintptrFromInt32(0) { stops = (*TNSVGgradientData)(unsafe.Pointer(ref)).Fstops nstops = (*TNSVGgradientData)(unsafe.Pointer(ref)).Fnstops break } nextRef = _nsvg__findGradientData(tls, p, ref+64) if nextRef == ref { break } ref = nextRef refIter++ if refIter > int32(32) { break } } if stops == libc.UintptrFromInt32(0) { return libc.UintptrFromInt32(0) } grad = libtcl9_0.XTcl_Alloc(tls, uint64(48)+uint64(8)*libc.Uint64FromInt32(nstops-libc.Int32FromInt32(1))) if grad == libc.UintptrFromInt32(0) { return libc.UintptrFromInt32(0) } if libc.Int32FromUint8((*TNSVGgradientData)(unsafe.Pointer(data)).Funits) == int32(NSVG_OBJECT_SPACE) { ox = *(*float32)(unsafe.Pointer(localBounds)) oy = *(*float32)(unsafe.Pointer(localBounds + 1*4)) sw = *(*float32)(unsafe.Pointer(localBounds + 2*4)) - *(*float32)(unsafe.Pointer(localBounds)) sh = *(*float32)(unsafe.Pointer(localBounds + 3*4)) - *(*float32)(unsafe.Pointer(localBounds + 1*4)) } else { ox = _nsvg__actualOrigX(tls, p) oy = _nsvg__actualOrigY(tls, p) sw = _nsvg__actualWidth(tls, p) sh = _nsvg__actualHeight(tls, p) } sl = libc.Xsqrtf(tls, float32(sw*sw)+float32(sh*sh)) / libc.Xsqrtf(tls, libc.Float32FromFloat32(2)) if int32((*TNSVGgradientData)(unsafe.Pointer(data)).Ftype1) == int32(NSVG_PAINT_LINEAR_GRADIENT) { x1 = _nsvg__convertToPixels(tls, p, (*TNSVGgradientData)(unsafe.Pointer(data)).F__ccgo3_132.Flinear.Fx1, ox, sw) y1 = _nsvg__convertToPixels(tls, p, (*TNSVGgradientData)(unsafe.Pointer(data)).F__ccgo3_132.Flinear.Fy1, oy, sh) x2 = _nsvg__convertToPixels(tls, p, (*TNSVGgradientData)(unsafe.Pointer(data)).F__ccgo3_132.Flinear.Fx2, ox, sw) y2 = _nsvg__convertToPixels(tls, p, (*TNSVGgradientData)(unsafe.Pointer(data)).F__ccgo3_132.Flinear.Fy2, oy, sh) dx = x2 - x1 dy = y2 - y1 *(*float32)(unsafe.Pointer(grad)) = dy *(*float32)(unsafe.Pointer(grad + 1*4)) = -dx *(*float32)(unsafe.Pointer(grad + 2*4)) = dx *(*float32)(unsafe.Pointer(grad + 3*4)) = dy *(*float32)(unsafe.Pointer(grad + 4*4)) = x1 *(*float32)(unsafe.Pointer(grad + 5*4)) = y1 } else { cx = _nsvg__convertToPixels(tls, p, (*(*TNSVGradialData)(unsafe.Add(unsafe.Pointer(data), 132))).Fcx, ox, sw) cy = _nsvg__convertToPixels(tls, p, (*(*TNSVGradialData)(unsafe.Add(unsafe.Pointer(data), 132))).Fcy, oy, sh) fx = _nsvg__convertToPixels(tls, p, (*(*TNSVGradialData)(unsafe.Add(unsafe.Pointer(data), 132))).Ffx, ox, sw) fy = _nsvg__convertToPixels(tls, p, (*(*TNSVGradialData)(unsafe.Add(unsafe.Pointer(data), 132))).Ffy, oy, sh) r = _nsvg__convertToPixels(tls, p, (*(*TNSVGradialData)(unsafe.Add(unsafe.Pointer(data), 132))).Fr, libc.Float32FromInt32(0), sl) *(*float32)(unsafe.Pointer(grad)) = r *(*float32)(unsafe.Pointer(grad + 1*4)) = libc.Float32FromInt32(0) *(*float32)(unsafe.Pointer(grad + 2*4)) = libc.Float32FromInt32(0) *(*float32)(unsafe.Pointer(grad + 3*4)) = r *(*float32)(unsafe.Pointer(grad + 4*4)) = cx *(*float32)(unsafe.Pointer(grad + 5*4)) = cy (*TNSVGgradient)(unsafe.Pointer(grad)).Ffx = fx / r (*TNSVGgradient)(unsafe.Pointer(grad)).Ffy = fy / r } _nsvg__xformMultiply(tls, grad, data+176) _nsvg__xformMultiply(tls, grad, xform) (*TNSVGgradient)(unsafe.Pointer(grad)).Fspread = (*TNSVGgradientData)(unsafe.Pointer(data)).Fspread libc.Xmemcpy(tls, grad+40, stops, libc.Uint64FromInt32(nstops)*uint64(8)) (*TNSVGgradient)(unsafe.Pointer(grad)).Fnstops = nstops *(*int8)(unsafe.Pointer(paintType)) = (*TNSVGgradientData)(unsafe.Pointer(data)).Ftype1 return grad } func _nsvg__getAverageScale(tls *libc.TLS, t uintptr) (r float32) { var sx, sy float32 _, _ = sx, sy sx = libc.Xsqrtf(tls, float32(*(*float32)(unsafe.Pointer(t))**(*float32)(unsafe.Pointer(t)))+float32(*(*float32)(unsafe.Pointer(t + 2*4))**(*float32)(unsafe.Pointer(t + 2*4)))) sy = libc.Xsqrtf(tls, float32(*(*float32)(unsafe.Pointer(t + 1*4))**(*float32)(unsafe.Pointer(t + 1*4)))+float32(*(*float32)(unsafe.Pointer(t + 3*4))**(*float32)(unsafe.Pointer(t + 3*4)))) return float32((sx + sy) * libc.Float32FromFloat32(0.5)) } func _nsvg__getLocalBounds(tls *libc.TLS, bounds uintptr, shape uintptr, xform uintptr) { bp := tls.Alloc(48) defer tls.Free(48) var first, i int32 var path uintptr var v10, v12, v13, v14, v15, v17, v18, v19, v20, v22, v3, v4, v5, v7, v8, v9 float32 var _ /* curve at bp+0 */ [8]float32 var _ /* curveBounds at bp+32 */ [4]float32 _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = first, i, path, v10, v12, v13, v14, v15, v17, v18, v19, v20, v22, v3, v4, v5, v7, v8, v9 first = int32(1) path = (*TNSVGshape)(unsafe.Pointer(shape)).Fpaths for { if !(path != libc.UintptrFromInt32(0)) { break } _nsvg__xformPoint(tls, bp, bp+1*4, *(*float32)(unsafe.Pointer((*TNSVGpath)(unsafe.Pointer(path)).Fpts)), *(*float32)(unsafe.Pointer((*TNSVGpath)(unsafe.Pointer(path)).Fpts + 1*4)), xform) i = 0 for { if !(i < (*TNSVGpath)(unsafe.Pointer(path)).Fnpts-int32(1)) { break } _nsvg__xformPoint(tls, bp+2*4, bp+3*4, *(*float32)(unsafe.Pointer((*TNSVGpath)(unsafe.Pointer(path)).Fpts + uintptr((i+int32(1))*int32(2))*4)), *(*float32)(unsafe.Pointer((*TNSVGpath)(unsafe.Pointer(path)).Fpts + uintptr((i+int32(1))*int32(2)+int32(1))*4)), xform) _nsvg__xformPoint(tls, bp+4*4, bp+5*4, *(*float32)(unsafe.Pointer((*TNSVGpath)(unsafe.Pointer(path)).Fpts + uintptr((i+int32(2))*int32(2))*4)), *(*float32)(unsafe.Pointer((*TNSVGpath)(unsafe.Pointer(path)).Fpts + uintptr((i+int32(2))*int32(2)+int32(1))*4)), xform) _nsvg__xformPoint(tls, bp+6*4, bp+7*4, *(*float32)(unsafe.Pointer((*TNSVGpath)(unsafe.Pointer(path)).Fpts + uintptr((i+int32(3))*int32(2))*4)), *(*float32)(unsafe.Pointer((*TNSVGpath)(unsafe.Pointer(path)).Fpts + uintptr((i+int32(3))*int32(2)+int32(1))*4)), xform) _nsvg__curveBounds(tls, bp+32, bp) if first != 0 { *(*float32)(unsafe.Pointer(bounds)) = (*(*[4]float32)(unsafe.Pointer(bp + 32)))[0] *(*float32)(unsafe.Pointer(bounds + 1*4)) = (*(*[4]float32)(unsafe.Pointer(bp + 32)))[int32(1)] *(*float32)(unsafe.Pointer(bounds + 2*4)) = (*(*[4]float32)(unsafe.Pointer(bp + 32)))[int32(2)] *(*float32)(unsafe.Pointer(bounds + 3*4)) = (*(*[4]float32)(unsafe.Pointer(bp + 32)))[int32(3)] first = 0 } else { v3 = *(*float32)(unsafe.Pointer(bounds)) v4 = (*(*[4]float32)(unsafe.Pointer(bp + 32)))[0] if v3 < v4 { v7 = v3 } else { v7 = v4 } v5 = v7 goto _6 _6: *(*float32)(unsafe.Pointer(bounds)) = v5 v8 = *(*float32)(unsafe.Pointer(bounds + 1*4)) v9 = (*(*[4]float32)(unsafe.Pointer(bp + 32)))[int32(1)] if v8 < v9 { v12 = v8 } else { v12 = v9 } v10 = v12 goto _11 _11: *(*float32)(unsafe.Pointer(bounds + 1*4)) = v10 v13 = *(*float32)(unsafe.Pointer(bounds + 2*4)) v14 = (*(*[4]float32)(unsafe.Pointer(bp + 32)))[int32(2)] if v13 > v14 { v17 = v13 } else { v17 = v14 } v15 = v17 goto _16 _16: *(*float32)(unsafe.Pointer(bounds + 2*4)) = v15 v18 = *(*float32)(unsafe.Pointer(bounds + 3*4)) v19 = (*(*[4]float32)(unsafe.Pointer(bp + 32)))[int32(3)] if v18 > v19 { v22 = v18 } else { v22 = v19 } v20 = v22 goto _21 _21: *(*float32)(unsafe.Pointer(bounds + 3*4)) = v20 } (*(*[8]float32)(unsafe.Pointer(bp)))[0] = (*(*[8]float32)(unsafe.Pointer(bp)))[int32(6)] (*(*[8]float32)(unsafe.Pointer(bp)))[int32(1)] = (*(*[8]float32)(unsafe.Pointer(bp)))[int32(7)] goto _2 _2: ; i += int32(3) } goto _1 _1: ; path = (*TNSVGpath)(unsafe.Pointer(path)).Fnext } } func _nsvg__addShape(tls *libc.TLS, p uintptr) { var attr, path, shape uintptr var i, v23 int32 var scale, v10, v12, v13, v14, v15, v17, v18, v19, v20, v22, v3, v4, v5, v7, v8, v9 float32 _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = attr, i, path, scale, shape, v10, v12, v13, v14, v15, v17, v18, v19, v20, v22, v23, v3, v4, v5, v7, v8, v9 attr = _nsvg__getAttr(tls, p) scale = libc.Float32FromFloat32(1) if (*TNSVGparser)(unsafe.Pointer(p)).Fplist == libc.UintptrFromInt32(0) { return } shape = libtcl9_0.XTcl_Alloc(tls, uint64(336)) if shape == libc.UintptrFromInt32(0) { goto error } libc.Xmemset(tls, shape, 0, uint64(336)) libc.Xmemcpy(tls, shape, attr, uint64(64)) libc.Xmemcpy(tls, shape+168, attr+108, uint64(64)) libc.Xmemcpy(tls, shape+232, attr+172, uint64(64)) libc.Xmemcpy(tls, shape+296, attr+64, uint64(24)) scale = _nsvg__getAverageScale(tls, attr+64) (*TNSVGshape)(unsafe.Pointer(shape)).FstrokeWidth = float32((*TNSVGattrib)(unsafe.Pointer(attr)).FstrokeWidth * scale) (*TNSVGshape)(unsafe.Pointer(shape)).FstrokeDashOffset = float32((*TNSVGattrib)(unsafe.Pointer(attr)).FstrokeDashOffset * scale) (*TNSVGshape)(unsafe.Pointer(shape)).FstrokeDashCount = libc.Uint8FromInt32((*TNSVGattrib)(unsafe.Pointer(attr)).FstrokeDashCount) i = 0 for { if !(i < (*TNSVGattrib)(unsafe.Pointer(attr)).FstrokeDashCount) { break } *(*float32)(unsafe.Pointer(shape + 108 + uintptr(i)*4)) = float32(*(*float32)(unsafe.Pointer(attr + 244 + uintptr(i)*4)) * scale) goto _1 _1: ; i++ } (*TNSVGshape)(unsafe.Pointer(shape)).FstrokeLineJoin = (*TNSVGattrib)(unsafe.Pointer(attr)).FstrokeLineJoin (*TNSVGshape)(unsafe.Pointer(shape)).FstrokeLineCap = (*TNSVGattrib)(unsafe.Pointer(attr)).FstrokeLineCap (*TNSVGshape)(unsafe.Pointer(shape)).FmiterLimit = (*TNSVGattrib)(unsafe.Pointer(attr)).FmiterLimit (*TNSVGshape)(unsafe.Pointer(shape)).FfillRule = (*TNSVGattrib)(unsafe.Pointer(attr)).FfillRule (*TNSVGshape)(unsafe.Pointer(shape)).Fopacity = (*TNSVGattrib)(unsafe.Pointer(attr)).Fopacity (*TNSVGshape)(unsafe.Pointer(shape)).Fpaths = (*TNSVGparser)(unsafe.Pointer(p)).Fplist (*TNSVGparser)(unsafe.Pointer(p)).Fplist = libc.UintptrFromInt32(0) *(*float32)(unsafe.Pointer(shape + 152)) = *(*float32)(unsafe.Pointer((*TNSVGshape)(unsafe.Pointer(shape)).Fpaths + 16)) *(*float32)(unsafe.Pointer(shape + 152 + 1*4)) = *(*float32)(unsafe.Pointer((*TNSVGshape)(unsafe.Pointer(shape)).Fpaths + 16 + 1*4)) *(*float32)(unsafe.Pointer(shape + 152 + 2*4)) = *(*float32)(unsafe.Pointer((*TNSVGshape)(unsafe.Pointer(shape)).Fpaths + 16 + 2*4)) *(*float32)(unsafe.Pointer(shape + 152 + 3*4)) = *(*float32)(unsafe.Pointer((*TNSVGshape)(unsafe.Pointer(shape)).Fpaths + 16 + 3*4)) path = (*TNSVGpath)(unsafe.Pointer((*TNSVGshape)(unsafe.Pointer(shape)).Fpaths)).Fnext for { if !(path != libc.UintptrFromInt32(0)) { break } v3 = *(*float32)(unsafe.Pointer(shape + 152)) v4 = *(*float32)(unsafe.Pointer(path + 16)) if v3 < v4 { v7 = v3 } else { v7 = v4 } v5 = v7 goto _6 _6: *(*float32)(unsafe.Pointer(shape + 152)) = v5 v8 = *(*float32)(unsafe.Pointer(shape + 152 + 1*4)) v9 = *(*float32)(unsafe.Pointer(path + 16 + 1*4)) if v8 < v9 { v12 = v8 } else { v12 = v9 } v10 = v12 goto _11 _11: *(*float32)(unsafe.Pointer(shape + 152 + 1*4)) = v10 v13 = *(*float32)(unsafe.Pointer(shape + 152 + 2*4)) v14 = *(*float32)(unsafe.Pointer(path + 16 + 2*4)) if v13 > v14 { v17 = v13 } else { v17 = v14 } v15 = v17 goto _16 _16: *(*float32)(unsafe.Pointer(shape + 152 + 2*4)) = v15 v18 = *(*float32)(unsafe.Pointer(shape + 152 + 3*4)) v19 = *(*float32)(unsafe.Pointer(path + 16 + 3*4)) if v18 > v19 { v22 = v18 } else { v22 = v19 } v20 = v22 goto _21 _21: *(*float32)(unsafe.Pointer(shape + 152 + 3*4)) = v20 goto _2 _2: ; path = (*TNSVGpath)(unsafe.Pointer(path)).Fnext } if libc.Int32FromUint8((*TNSVGattrib)(unsafe.Pointer(attr)).FhasFill) == 0 { (*TNSVGshape)(unsafe.Pointer(shape)).Ffill.Ftype1 = int8(NSVG_PAINT_NONE) } else { if libc.Int32FromUint8((*TNSVGattrib)(unsafe.Pointer(attr)).FhasFill) == int32(1) { (*TNSVGshape)(unsafe.Pointer(shape)).Ffill.Ftype1 = int8(NSVG_PAINT_COLOR) (*TNSVGshape)(unsafe.Pointer(shape)).Ffill.F__ccgo1_8.Fcolor = (*TNSVGattrib)(unsafe.Pointer(attr)).FfillColor (*TNSVGshape)(unsafe.Pointer(shape)).Ffill.F__ccgo1_8.Fcolor |= uint32(float32((*TNSVGattrib)(unsafe.Pointer(attr)).FfillOpacity*libc.Float32FromInt32(255))) << int32(24) } else { if libc.Int32FromUint8((*TNSVGattrib)(unsafe.Pointer(attr)).FhasFill) == int32(2) { (*TNSVGshape)(unsafe.Pointer(shape)).Ffill.Ftype1 = int8(NSVG_PAINT_UNDEF) } } } if libc.Int32FromUint8((*TNSVGattrib)(unsafe.Pointer(attr)).FhasStroke) == 0 { (*TNSVGshape)(unsafe.Pointer(shape)).Fstroke.Ftype1 = int8(NSVG_PAINT_NONE) } else { if libc.Int32FromUint8((*TNSVGattrib)(unsafe.Pointer(attr)).FhasStroke) == int32(1) { (*TNSVGshape)(unsafe.Pointer(shape)).Fstroke.Ftype1 = int8(NSVG_PAINT_COLOR) (*TNSVGshape)(unsafe.Pointer(shape)).Fstroke.F__ccgo1_8.Fcolor = (*TNSVGattrib)(unsafe.Pointer(attr)).FstrokeColor (*TNSVGshape)(unsafe.Pointer(shape)).Fstroke.F__ccgo1_8.Fcolor |= uint32(float32((*TNSVGattrib)(unsafe.Pointer(attr)).FstrokeOpacity*libc.Float32FromInt32(255))) << int32(24) } else { if libc.Int32FromUint8((*TNSVGattrib)(unsafe.Pointer(attr)).FhasStroke) == int32(2) { (*TNSVGshape)(unsafe.Pointer(shape)).Fstroke.Ftype1 = int8(NSVG_PAINT_UNDEF) } } } if libc.Int32FromUint8((*TNSVGattrib)(unsafe.Pointer(attr)).Fvisible)&int32(NSVG_VIS_DISPLAY) != 0 && libc.Int32FromUint8((*TNSVGattrib)(unsafe.Pointer(attr)).Fvisible)&int32(NSVG_VIS_VISIBLE) != 0 { v23 = int32(NSVG_FLAGS_VISIBLE) } else { v23 = 0x00 } (*TNSVGshape)(unsafe.Pointer(shape)).Fflags = libc.Uint8FromInt32(v23) if (*TNSVGimage)(unsafe.Pointer((*TNSVGparser)(unsafe.Pointer(p)).Fimage)).Fshapes == libc.UintptrFromInt32(0) { (*TNSVGimage)(unsafe.Pointer((*TNSVGparser)(unsafe.Pointer(p)).Fimage)).Fshapes = shape } else { (*TNSVGshape)(unsafe.Pointer((*TNSVGparser)(unsafe.Pointer(p)).FshapesTail)).Fnext = shape } (*TNSVGparser)(unsafe.Pointer(p)).FshapesTail = shape return goto error error: ; if shape != 0 { libtcl9_0.XTcl_Free(tls, shape) } } func _nsvg__addPath(tls *libc.TLS, p uintptr, closed uint8) { bp := tls.Alloc(16) defer tls.Free(16) var attr, curve, path uintptr var i int32 var v10, v12, v13, v14, v15, v17, v18, v19, v20, v22, v3, v4, v5, v7, v8, v9 float32 var _ /* bounds at bp+0 */ [4]float32 _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = attr, curve, i, path, v10, v12, v13, v14, v15, v17, v18, v19, v20, v22, v3, v4, v5, v7, v8, v9 attr = _nsvg__getAttr(tls, p) path = libc.UintptrFromInt32(0) if (*TNSVGparser)(unsafe.Pointer(p)).Fnpts < int32(4) { return } if closed != 0 { _nsvg__lineTo(tls, p, *(*float32)(unsafe.Pointer((*TNSVGparser)(unsafe.Pointer(p)).Fpts)), *(*float32)(unsafe.Pointer((*TNSVGparser)(unsafe.Pointer(p)).Fpts + 1*4))) } if (*TNSVGparser)(unsafe.Pointer(p)).Fnpts%int32(3) != int32(1) { return } path = libtcl9_0.XTcl_Alloc(tls, uint64(40)) if path == libc.UintptrFromInt32(0) { goto error } libc.Xmemset(tls, path, 0, uint64(40)) (*TNSVGpath)(unsafe.Pointer(path)).Fpts = libtcl9_0.XTcl_Alloc(tls, libc.Uint64FromInt32((*TNSVGparser)(unsafe.Pointer(p)).Fnpts*int32(2))*uint64(4)) if (*TNSVGpath)(unsafe.Pointer(path)).Fpts == libc.UintptrFromInt32(0) { goto error } (*TNSVGpath)(unsafe.Pointer(path)).Fclosed = closed (*TNSVGpath)(unsafe.Pointer(path)).Fnpts = (*TNSVGparser)(unsafe.Pointer(p)).Fnpts i = 0 for { if !(i < (*TNSVGparser)(unsafe.Pointer(p)).Fnpts) { break } _nsvg__xformPoint(tls, (*TNSVGpath)(unsafe.Pointer(path)).Fpts+uintptr(i*int32(2))*4, (*TNSVGpath)(unsafe.Pointer(path)).Fpts+uintptr(i*int32(2)+int32(1))*4, *(*float32)(unsafe.Pointer((*TNSVGparser)(unsafe.Pointer(p)).Fpts + uintptr(i*int32(2))*4)), *(*float32)(unsafe.Pointer((*TNSVGparser)(unsafe.Pointer(p)).Fpts + uintptr(i*int32(2)+int32(1))*4)), attr+64) goto _1 _1: ; i++ } i = 0 for { if !(i < (*TNSVGpath)(unsafe.Pointer(path)).Fnpts-int32(1)) { break } curve = (*TNSVGpath)(unsafe.Pointer(path)).Fpts + uintptr(i*int32(2))*4 _nsvg__curveBounds(tls, bp, curve) if i == 0 { *(*float32)(unsafe.Pointer(path + 16)) = (*(*[4]float32)(unsafe.Pointer(bp)))[0] *(*float32)(unsafe.Pointer(path + 16 + 1*4)) = (*(*[4]float32)(unsafe.Pointer(bp)))[int32(1)] *(*float32)(unsafe.Pointer(path + 16 + 2*4)) = (*(*[4]float32)(unsafe.Pointer(bp)))[int32(2)] *(*float32)(unsafe.Pointer(path + 16 + 3*4)) = (*(*[4]float32)(unsafe.Pointer(bp)))[int32(3)] } else { v3 = *(*float32)(unsafe.Pointer(path + 16)) v4 = (*(*[4]float32)(unsafe.Pointer(bp)))[0] if v3 < v4 { v7 = v3 } else { v7 = v4 } v5 = v7 goto _6 _6: *(*float32)(unsafe.Pointer(path + 16)) = v5 v8 = *(*float32)(unsafe.Pointer(path + 16 + 1*4)) v9 = (*(*[4]float32)(unsafe.Pointer(bp)))[int32(1)] if v8 < v9 { v12 = v8 } else { v12 = v9 } v10 = v12 goto _11 _11: *(*float32)(unsafe.Pointer(path + 16 + 1*4)) = v10 v13 = *(*float32)(unsafe.Pointer(path + 16 + 2*4)) v14 = (*(*[4]float32)(unsafe.Pointer(bp)))[int32(2)] if v13 > v14 { v17 = v13 } else { v17 = v14 } v15 = v17 goto _16 _16: *(*float32)(unsafe.Pointer(path + 16 + 2*4)) = v15 v18 = *(*float32)(unsafe.Pointer(path + 16 + 3*4)) v19 = (*(*[4]float32)(unsafe.Pointer(bp)))[int32(3)] if v18 > v19 { v22 = v18 } else { v22 = v19 } v20 = v22 goto _21 _21: *(*float32)(unsafe.Pointer(path + 16 + 3*4)) = v20 } goto _2 _2: ; i += int32(3) } (*TNSVGpath)(unsafe.Pointer(path)).Fnext = (*TNSVGparser)(unsafe.Pointer(p)).Fplist (*TNSVGparser)(unsafe.Pointer(p)).Fplist = path return goto error error: ; if path != libc.UintptrFromInt32(0) { if (*TNSVGpath)(unsafe.Pointer(path)).Fpts != libc.UintptrFromInt32(0) { libtcl9_0.XTcl_Free(tls, (*TNSVGpath)(unsafe.Pointer(path)).Fpts) } libtcl9_0.XTcl_Free(tls, path) } } func _nsvg__atof(tls *libc.TLS, s uintptr) (r float64) { bp := tls.Alloc(16) defer tls.Free(16) var cur uintptr var expPart int32 var fracPart, intPart int64 var hasFracPart, hasIntPart uint8 var res, sign float64 var _ /* end at bp+0 */ uintptr _, _, _, _, _, _, _, _ = cur, expPart, fracPart, hasFracPart, hasIntPart, intPart, res, sign cur = s *(*uintptr)(unsafe.Pointer(bp)) = libc.UintptrFromInt32(0) res = float64(0) sign = float64(1) intPart = 0 fracPart = 0 hasIntPart = uint8(0) hasFracPart = uint8(0) if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(cur))) == int32('+') { cur++ } else { if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(cur))) == int32('-') { sign = float64(-libc.Int32FromInt32(1)) cur++ } } if _nsvg__isdigit(tls, *(*uint8)(unsafe.Pointer(cur))) != 0 { intPart = libc.Xstrtoll(tls, cur, bp, int32(10)) if cur != *(*uintptr)(unsafe.Pointer(bp)) { res = float64(intPart) hasIntPart = uint8(1) cur = *(*uintptr)(unsafe.Pointer(bp)) } } if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(cur))) == int32('.') { cur++ if _nsvg__isdigit(tls, *(*uint8)(unsafe.Pointer(cur))) != 0 { fracPart = libc.Xstrtoll(tls, cur, bp, int32(10)) if cur != *(*uintptr)(unsafe.Pointer(bp)) { res += float64(fracPart) / libc.Xpow(tls, float64(10), float64(int64(*(*uintptr)(unsafe.Pointer(bp)))-int64(cur))) hasFracPart = uint8(1) cur = *(*uintptr)(unsafe.Pointer(bp)) } } } if !(hasIntPart != 0) && !(hasFracPart != 0) { return float64(0) } if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(cur))) == int32('e') || libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(cur))) == int32('E') { expPart = 0 cur++ expPart = int32(libc.Xstrtol(tls, cur, bp, int32(10))) if cur != *(*uintptr)(unsafe.Pointer(bp)) { res *= libc.Xpow(tls, float64(10), float64(expPart)) } } return float64(res * sign) } func _nsvg__parseNumber(tls *libc.TLS, s uintptr, it uintptr, size int32) (r uintptr) { var i, last, v1, v2, v3, v4, v5, v6, v7 int32 _, _, _, _, _, _, _, _, _ = i, last, v1, v2, v3, v4, v5, v6, v7 last = size - int32(1) i = 0 if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(s))) == int32('-') || libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(s))) == int32('+') { if i < last { v1 = i i++ *(*uint8)(unsafe.Pointer(it + uintptr(v1))) = *(*uint8)(unsafe.Pointer(s)) } s++ } for *(*uint8)(unsafe.Pointer(s)) != 0 && _nsvg__isdigit(tls, *(*uint8)(unsafe.Pointer(s))) != 0 { if i < last { v2 = i i++ *(*uint8)(unsafe.Pointer(it + uintptr(v2))) = *(*uint8)(unsafe.Pointer(s)) } s++ } if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(s))) == int32('.') { if i < last { v3 = i i++ *(*uint8)(unsafe.Pointer(it + uintptr(v3))) = *(*uint8)(unsafe.Pointer(s)) } s++ for *(*uint8)(unsafe.Pointer(s)) != 0 && _nsvg__isdigit(tls, *(*uint8)(unsafe.Pointer(s))) != 0 { if i < last { v4 = i i++ *(*uint8)(unsafe.Pointer(it + uintptr(v4))) = *(*uint8)(unsafe.Pointer(s)) } s++ } } if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(s))) == int32('e') || libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(s))) == int32('E') { if i < last { v5 = i i++ *(*uint8)(unsafe.Pointer(it + uintptr(v5))) = *(*uint8)(unsafe.Pointer(s)) } s++ if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(s))) == int32('-') || libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(s))) == int32('+') { if i < last { v6 = i i++ *(*uint8)(unsafe.Pointer(it + uintptr(v6))) = *(*uint8)(unsafe.Pointer(s)) } s++ } for *(*uint8)(unsafe.Pointer(s)) != 0 && _nsvg__isdigit(tls, *(*uint8)(unsafe.Pointer(s))) != 0 { if i < last { v7 = i i++ *(*uint8)(unsafe.Pointer(it + uintptr(v7))) = *(*uint8)(unsafe.Pointer(s)) } s++ } } *(*uint8)(unsafe.Pointer(it + uintptr(i))) = uint8('\000') return s } func _nsvg__getNextPathItemWhenArcFlag(tls *libc.TLS, s uintptr, it uintptr) (r uintptr) { var v1 uintptr _ = v1 *(*uint8)(unsafe.Pointer(it)) = uint8('\000') for *(*uint8)(unsafe.Pointer(s)) != 0 && (_nsvg__isspace(tls, *(*uint8)(unsafe.Pointer(s))) != 0 || libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(s))) == int32(',')) { s++ } if !(*(*uint8)(unsafe.Pointer(s)) != 0) { return s } if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(s))) == int32('0') || libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(s))) == int32('1') { v1 = s s++ *(*uint8)(unsafe.Pointer(it)) = *(*uint8)(unsafe.Pointer(v1)) *(*uint8)(unsafe.Pointer(it + 1)) = uint8('\000') return s } return s } func _nsvg__getNextPathItem(tls *libc.TLS, s uintptr, it uintptr) (r uintptr) { var v1 uintptr _ = v1 *(*uint8)(unsafe.Pointer(it)) = uint8('\000') for *(*uint8)(unsafe.Pointer(s)) != 0 && (_nsvg__isspace(tls, *(*uint8)(unsafe.Pointer(s))) != 0 || libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(s))) == int32(',')) { s++ } if !(*(*uint8)(unsafe.Pointer(s)) != 0) { return s } if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(s))) == int32('-') || libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(s))) == int32('+') || libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(s))) == int32('.') || _nsvg__isdigit(tls, *(*uint8)(unsafe.Pointer(s))) != 0 { s = _nsvg__parseNumber(tls, s, it, int32(64)) } else { v1 = s s++ *(*uint8)(unsafe.Pointer(it)) = *(*uint8)(unsafe.Pointer(v1)) *(*uint8)(unsafe.Pointer(it + 1)) = uint8('\000') return s } return s } func _nsvg__parseColorHex(tls *libc.TLS, str uintptr) (r uint32) { bp := tls.Alloc(48) defer tls.Free(48) var _ /* b at bp+8 */ uint32 var _ /* g at bp+4 */ uint32 var _ /* r at bp+0 */ uint32 *(*uint32)(unsafe.Pointer(bp)) = uint32(0) *(*uint32)(unsafe.Pointer(bp + 4)) = uint32(0) *(*uint32)(unsafe.Pointer(bp + 8)) = uint32(0) if libc.Xsscanf(tls, str, __ccgo_ts+41390, libc.VaList(bp+24, bp, bp+4, bp+8)) == int32(3) { return *(*uint32)(unsafe.Pointer(bp)) | *(*uint32)(unsafe.Pointer(bp + 4))< uint32(255) { (*(*[3]uint32)(unsafe.Pointer(bp)))[i] = uint32(255) } goto _4 _4: ; i++ } return (*(*[3]uint32)(unsafe.Pointer(bp)))[0] | (*(*[3]uint32)(unsafe.Pointer(bp)))[int32(1)]<= uint64(1) && libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(str))) == int32('#') { return _nsvg__parseColorHex(tls, str) } else { if len1 >= uint64(4) && libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(str))) == int32('r') && libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(str + 1))) == int32('g') && libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(str + 2))) == int32('b') && libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(str + 3))) == int32('(') { return _nsvg__parseColorRGB(tls, str) } } return _nsvg__parseColorName(tls, str) } func _nsvg__parseOpacity(tls *libc.TLS, str uintptr) (r float32) { bp := tls.Alloc(32) defer tls.Free(32) var _ /* val at bp+0 */ float32 *(*float32)(unsafe.Pointer(bp)) = libc.Float32FromInt32(0) libc.Xsscanf(tls, str, __ccgo_ts+41428, libc.VaList(bp+16, bp)) if *(*float32)(unsafe.Pointer(bp)) < libc.Float32FromFloat32(0) { *(*float32)(unsafe.Pointer(bp)) = libc.Float32FromFloat32(0) } if *(*float32)(unsafe.Pointer(bp)) > libc.Float32FromFloat32(1) { *(*float32)(unsafe.Pointer(bp)) = libc.Float32FromFloat32(1) } return *(*float32)(unsafe.Pointer(bp)) } func _nsvg__parseMiterLimit(tls *libc.TLS, str uintptr) (r float32) { bp := tls.Alloc(32) defer tls.Free(32) var _ /* val at bp+0 */ float32 *(*float32)(unsafe.Pointer(bp)) = libc.Float32FromInt32(0) libc.Xsscanf(tls, str, __ccgo_ts+41428, libc.VaList(bp+16, bp)) if *(*float32)(unsafe.Pointer(bp)) < libc.Float32FromFloat32(0) { *(*float32)(unsafe.Pointer(bp)) = libc.Float32FromFloat32(0) } return *(*float32)(unsafe.Pointer(bp)) } func _nsvg__parseUnits(tls *libc.TLS, units uintptr) (r int32) { if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(units))) == int32('p') && libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(units + 1))) == int32('x') { return int32(NSVG_UNITS_PX) } else { if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(units))) == int32('p') && libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(units + 1))) == int32('t') { return int32(NSVG_UNITS_PT) } else { if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(units))) == int32('p') && libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(units + 1))) == int32('c') { return int32(NSVG_UNITS_PC) } else { if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(units))) == int32('m') && libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(units + 1))) == int32('m') { return int32(NSVG_UNITS_MM) } else { if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(units))) == int32('c') && libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(units + 1))) == int32('m') { return int32(NSVG_UNITS_CM) } else { if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(units))) == int32('i') && libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(units + 1))) == int32('n') { return int32(NSVG_UNITS_IN) } else { if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(units))) == int32('%') { return int32(NSVG_UNITS_PERCENT) } else { if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(units))) == int32('e') && libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(units + 1))) == int32('m') { return int32(NSVG_UNITS_EM) } else { if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(units))) == int32('e') && libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(units + 1))) == int32('x') { return int32(NSVG_UNITS_EX) } } } } } } } } } return int32(NSVG_UNITS_USER) } func _nsvg__isCoordinate(tls *libc.TLS, s uintptr) (r int32) { if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(s))) == int32('-') || libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(s))) == int32('+') { s++ } return libc.BoolInt32(_nsvg__isdigit(tls, *(*uint8)(unsafe.Pointer(s))) != 0 || libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(s))) == int32('.')) } func _nsvg__parseCoordinateRaw(tls *libc.TLS, str uintptr) (r TNSVGcoordinate) { bp := tls.Alloc(64) defer tls.Free(64) var _ /* coord at bp+0 */ TNSVGcoordinate var _ /* units at bp+8 */ [32]uint8 *(*TNSVGcoordinate)(unsafe.Pointer(bp)) = TNSVGcoordinate{} *(*[32]uint8)(unsafe.Pointer(bp + 8)) = [32]uint8{} libc.Xsscanf(tls, str, __ccgo_ts+41431, libc.VaList(bp+48, bp, bp+8)) (*(*TNSVGcoordinate)(unsafe.Pointer(bp))).Funits = _nsvg__parseUnits(tls, bp+8) return *(*TNSVGcoordinate)(unsafe.Pointer(bp)) } func _nsvg__coord(tls *libc.TLS, v float32, units int32) (r TNSVGcoordinate) { var coord TNSVGcoordinate _ = coord coord = TNSVGcoordinate{ Fvalue: v, Funits: units, } return coord } func _nsvg__parseCoordinate(tls *libc.TLS, p uintptr, str uintptr, orig float32, length float32) (r float32) { var coord TNSVGcoordinate _ = coord coord = _nsvg__parseCoordinateRaw(tls, str) return _nsvg__convertToPixels(tls, p, coord, orig, length) } func _nsvg__parseTransformArgs(tls *libc.TLS, str uintptr, args uintptr, maxNa int32, na uintptr) (r int32) { bp := tls.Alloc(64) defer tls.Free(64) var end, ptr, v2 uintptr var v1 int32 var _ /* it at bp+0 */ [64]uint8 _, _, _, _ = end, ptr, v1, v2 *(*int32)(unsafe.Pointer(na)) = 0 ptr = str for *(*uint8)(unsafe.Pointer(ptr)) != 0 && libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(ptr))) != int32('(') { ptr++ } if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(ptr))) == 0 { return int32(1) } end = ptr for *(*uint8)(unsafe.Pointer(end)) != 0 && libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(end))) != int32(')') { end++ } if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(end))) == 0 { return int32(1) } for ptr < end { if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(ptr))) == int32('-') || libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(ptr))) == int32('+') || libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(ptr))) == int32('.') || _nsvg__isdigit(tls, *(*uint8)(unsafe.Pointer(ptr))) != 0 { if *(*int32)(unsafe.Pointer(na)) >= maxNa { return 0 } ptr = _nsvg__parseNumber(tls, ptr, bp, int32(64)) v2 = na v1 = *(*int32)(unsafe.Pointer(v2)) *(*int32)(unsafe.Pointer(v2))++ *(*float32)(unsafe.Pointer(args + uintptr(v1)*4)) = float32(_nsvg__atof(tls, bp)) } else { ptr++ } } return int32(int64(end) - int64(str)) } func _nsvg__parseMatrix(tls *libc.TLS, xform uintptr, str uintptr) (r int32) { bp := tls.Alloc(32) defer tls.Free(32) var len1 int32 var _ /* na at bp+24 */ int32 var _ /* t at bp+0 */ [6]float32 _ = len1 *(*int32)(unsafe.Pointer(bp + 24)) = 0 len1 = _nsvg__parseTransformArgs(tls, str, bp, int32(6), bp+24) if *(*int32)(unsafe.Pointer(bp + 24)) != int32(6) { return len1 } libc.Xmemcpy(tls, xform, bp, libc.Uint64FromInt64(4)*libc.Uint64FromInt32(6)) return len1 } func _nsvg__parseTranslate(tls *libc.TLS, xform uintptr, str uintptr) (r int32) { bp := tls.Alloc(48) defer tls.Free(48) var len1 int32 var _ /* args at bp+0 */ [2]float32 var _ /* na at bp+32 */ int32 var _ /* t at bp+8 */ [6]float32 _ = len1 *(*int32)(unsafe.Pointer(bp + 32)) = 0 len1 = _nsvg__parseTransformArgs(tls, str, bp, int32(2), bp+32) if *(*int32)(unsafe.Pointer(bp + 32)) == int32(1) { (*(*[2]float32)(unsafe.Pointer(bp)))[int32(1)] = float32(0) } _nsvg__xformSetTranslation(tls, bp+8, (*(*[2]float32)(unsafe.Pointer(bp)))[0], (*(*[2]float32)(unsafe.Pointer(bp)))[int32(1)]) libc.Xmemcpy(tls, xform, bp+8, libc.Uint64FromInt64(4)*libc.Uint64FromInt32(6)) return len1 } func _nsvg__parseScale(tls *libc.TLS, xform uintptr, str uintptr) (r int32) { bp := tls.Alloc(48) defer tls.Free(48) var len1 int32 var _ /* args at bp+0 */ [2]float32 var _ /* na at bp+8 */ int32 var _ /* t at bp+12 */ [6]float32 _ = len1 *(*int32)(unsafe.Pointer(bp + 8)) = 0 len1 = _nsvg__parseTransformArgs(tls, str, bp, int32(2), bp+8) if *(*int32)(unsafe.Pointer(bp + 8)) == int32(1) { (*(*[2]float32)(unsafe.Pointer(bp)))[int32(1)] = (*(*[2]float32)(unsafe.Pointer(bp)))[0] } _nsvg__xformSetScale(tls, bp+12, (*(*[2]float32)(unsafe.Pointer(bp)))[0], (*(*[2]float32)(unsafe.Pointer(bp)))[int32(1)]) libc.Xmemcpy(tls, xform, bp+12, libc.Uint64FromInt64(4)*libc.Uint64FromInt32(6)) return len1 } func _nsvg__parseSkewX(tls *libc.TLS, xform uintptr, str uintptr) (r int32) { bp := tls.Alloc(32) defer tls.Free(32) var len1 int32 var _ /* args at bp+0 */ [1]float32 var _ /* na at bp+4 */ int32 var _ /* t at bp+8 */ [6]float32 _ = len1 *(*int32)(unsafe.Pointer(bp + 4)) = 0 len1 = _nsvg__parseTransformArgs(tls, str, bp, int32(1), bp+4) _nsvg__xformSetSkewX(tls, bp+8, float32((*(*[1]float32)(unsafe.Pointer(bp)))[0]/libc.Float32FromFloat32(180)*libc.Float32FromFloat32(3.141592653589793))) libc.Xmemcpy(tls, xform, bp+8, libc.Uint64FromInt64(4)*libc.Uint64FromInt32(6)) return len1 } func _nsvg__parseSkewY(tls *libc.TLS, xform uintptr, str uintptr) (r int32) { bp := tls.Alloc(32) defer tls.Free(32) var len1 int32 var _ /* args at bp+0 */ [1]float32 var _ /* na at bp+4 */ int32 var _ /* t at bp+8 */ [6]float32 _ = len1 *(*int32)(unsafe.Pointer(bp + 4)) = 0 len1 = _nsvg__parseTransformArgs(tls, str, bp, int32(1), bp+4) _nsvg__xformSetSkewY(tls, bp+8, float32((*(*[1]float32)(unsafe.Pointer(bp)))[0]/libc.Float32FromFloat32(180)*libc.Float32FromFloat32(3.141592653589793))) libc.Xmemcpy(tls, xform, bp+8, libc.Uint64FromInt64(4)*libc.Uint64FromInt32(6)) return len1 } func _nsvg__parseRotate(tls *libc.TLS, xform uintptr, str uintptr) (r int32) { bp := tls.Alloc(64) defer tls.Free(64) var len1 int32 var v1 float32 var _ /* args at bp+0 */ [3]float32 var _ /* m at bp+16 */ [6]float32 var _ /* na at bp+12 */ int32 var _ /* t at bp+40 */ [6]float32 _, _ = len1, v1 *(*int32)(unsafe.Pointer(bp + 12)) = 0 len1 = _nsvg__parseTransformArgs(tls, str, bp, int32(3), bp+12) if *(*int32)(unsafe.Pointer(bp + 12)) == int32(1) { v1 = libc.Float32FromFloat32(0) (*(*[3]float32)(unsafe.Pointer(bp)))[int32(2)] = v1 (*(*[3]float32)(unsafe.Pointer(bp)))[int32(1)] = v1 } _nsvg__xformIdentity(tls, bp+16) if *(*int32)(unsafe.Pointer(bp + 12)) > int32(1) { _nsvg__xformSetTranslation(tls, bp+40, -(*(*[3]float32)(unsafe.Pointer(bp)))[int32(1)], -(*(*[3]float32)(unsafe.Pointer(bp)))[int32(2)]) _nsvg__xformMultiply(tls, bp+16, bp+40) } _nsvg__xformSetRotation(tls, bp+40, float32((*(*[3]float32)(unsafe.Pointer(bp)))[0]/libc.Float32FromFloat32(180)*libc.Float32FromFloat32(3.141592653589793))) _nsvg__xformMultiply(tls, bp+16, bp+40) if *(*int32)(unsafe.Pointer(bp + 12)) > int32(1) { _nsvg__xformSetTranslation(tls, bp+40, (*(*[3]float32)(unsafe.Pointer(bp)))[int32(1)], (*(*[3]float32)(unsafe.Pointer(bp)))[int32(2)]) _nsvg__xformMultiply(tls, bp+16, bp+40) } libc.Xmemcpy(tls, xform, bp+16, libc.Uint64FromInt64(4)*libc.Uint64FromInt32(6)) return len1 } func _nsvg__parseTransform(tls *libc.TLS, xform uintptr, str uintptr) { bp := tls.Alloc(32) defer tls.Free(32) var len1 int32 var _ /* t at bp+0 */ [6]float32 _ = len1 _nsvg__xformIdentity(tls, xform) for *(*uint8)(unsafe.Pointer(str)) != 0 { if libc.Xstrncmp(tls, str, __ccgo_ts+41436, uint64(6)) == 0 { len1 = _nsvg__parseMatrix(tls, bp, str) } else { if libc.Xstrncmp(tls, str, __ccgo_ts+41443, uint64(9)) == 0 { len1 = _nsvg__parseTranslate(tls, bp, str) } else { if libc.Xstrncmp(tls, str, __ccgo_ts+17972, uint64(5)) == 0 { len1 = _nsvg__parseScale(tls, bp, str) } else { if libc.Xstrncmp(tls, str, __ccgo_ts+26784, uint64(6)) == 0 { len1 = _nsvg__parseRotate(tls, bp, str) } else { if libc.Xstrncmp(tls, str, __ccgo_ts+41453, uint64(5)) == 0 { len1 = _nsvg__parseSkewX(tls, bp, str) } else { if libc.Xstrncmp(tls, str, __ccgo_ts+41459, uint64(5)) == 0 { len1 = _nsvg__parseSkewY(tls, bp, str) } else { str++ continue } } } } } } if len1 != 0 { str += uintptr(len1) } else { str++ continue } _nsvg__xformPremultiply(tls, xform, bp) } } func _nsvg__parseUrl(tls *libc.TLS, id uintptr, str uintptr) { var i int32 var v1 uintptr _, _ = i, v1 i = 0 str += uintptr(4) if *(*uint8)(unsafe.Pointer(str)) != 0 && libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(str))) == int32('#') { str++ } for i < int32(63) && *(*uint8)(unsafe.Pointer(str)) != 0 && libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(str))) != int32(')') { v1 = str str++ *(*uint8)(unsafe.Pointer(id + uintptr(i))) = *(*uint8)(unsafe.Pointer(v1)) i++ } *(*uint8)(unsafe.Pointer(id + uintptr(i))) = uint8('\000') } func _nsvg__parseLineCap(tls *libc.TLS, str uintptr) (r uint8) { if libc.Xstrcmp(tls, str, __ccgo_ts+11165) == 0 { return uint8(NSVG_CAP_BUTT) } else { if libc.Xstrcmp(tls, str, __ccgo_ts+11083) == 0 { return uint8(NSVG_CAP_ROUND) } else { if libc.Xstrcmp(tls, str, __ccgo_ts+41465) == 0 { return uint8(NSVG_CAP_SQUARE) } } } return uint8(NSVG_CAP_BUTT) } func _nsvg__parseLineJoin(tls *libc.TLS, str uintptr) (r uint8) { if libc.Xstrcmp(tls, str, __ccgo_ts+11077) == 0 { return uint8(NSVG_JOIN_MITER) } else { if libc.Xstrcmp(tls, str, __ccgo_ts+11083) == 0 { return uint8(NSVG_JOIN_ROUND) } else { if libc.Xstrcmp(tls, str, __ccgo_ts+11071) == 0 { return uint8(NSVG_JOIN_BEVEL) } } } return uint8(NSVG_JOIN_MITER) } func _nsvg__parseFillRule(tls *libc.TLS, str uintptr) (r uint8) { if libc.Xstrcmp(tls, str, __ccgo_ts+41472) == 0 { return uint8(NSVG_FILLRULE_NONZERO) } else { if libc.Xstrcmp(tls, str, __ccgo_ts+41480) == 0 { return uint8(NSVG_FILLRULE_EVENODD) } } return uint8(NSVG_FILLRULE_NONZERO) } func _nsvg__getNextDashItem(tls *libc.TLS, s uintptr, it uintptr) (r uintptr) { var n, v1, v2 int32 _, _, _ = n, v1, v2 n = 0 *(*uint8)(unsafe.Pointer(it)) = uint8('\000') for *(*uint8)(unsafe.Pointer(s)) != 0 && (_nsvg__isspace(tls, *(*uint8)(unsafe.Pointer(s))) != 0 || libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(s))) == int32(',')) { s++ } for *(*uint8)(unsafe.Pointer(s)) != 0 && (!(_nsvg__isspace(tls, *(*uint8)(unsafe.Pointer(s))) != 0) && libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(s))) != int32(',')) { if n < int32(63) { v1 = n n++ *(*uint8)(unsafe.Pointer(it + uintptr(v1))) = *(*uint8)(unsafe.Pointer(s)) } s++ } v2 = n n++ *(*uint8)(unsafe.Pointer(it + uintptr(v2))) = uint8('\000') return s } func _nsvg__parseStrokeDashArray(tls *libc.TLS, p uintptr, str uintptr, strokeDashArray uintptr) (r int32) { bp := tls.Alloc(64) defer tls.Free(64) var count, i, v1 int32 var sum float32 var _ /* item at bp+0 */ [64]uint8 _, _, _, _ = count, i, sum, v1 count = 0 sum = libc.Float32FromFloat32(0) if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(str))) == int32('n') { return 0 } for *(*uint8)(unsafe.Pointer(str)) != 0 { str = _nsvg__getNextDashItem(tls, str, bp) if !(*(*uint8)(unsafe.Pointer(bp)) != 0) { break } if count < int32(NSVG_MAX_DASHES) { v1 = count count++ *(*float32)(unsafe.Pointer(strokeDashArray + uintptr(v1)*4)) = libc.Xfabsf(tls, _nsvg__parseCoordinate(tls, p, bp, libc.Float32FromFloat32(0), _nsvg__actualLength(tls, p))) } } i = 0 for { if !(i < count) { break } sum += *(*float32)(unsafe.Pointer(strokeDashArray + uintptr(i)*4)) goto _2 _2: ; i++ } if sum <= libc.Float32FromFloat32(1e-06) { count = 0 } return count } func _nsvg__parseAttr(tls *libc.TLS, p uintptr, name uintptr, value uintptr) (r int32) { bp := tls.Alloc(32) defer tls.Free(32) var attr, style, p1, p2, p3 uintptr var _ /* xform at bp+0 */ [6]float32 _, _, _, _, _ = attr, style, p1, p2, p3 attr = _nsvg__getAttr(tls, p) if !(attr != 0) { return 0 } if libc.Xstrcmp(tls, name, __ccgo_ts+16580) == 0 { _nsvg__parseStyle(tls, p, value) } else { if libc.Xstrcmp(tls, name, __ccgo_ts+41488) == 0 { if libc.Xstrcmp(tls, value, __ccgo_ts+8223) == 0 { p1 = attr + 310 *(*uint8)(unsafe.Pointer(p1)) = uint8(int32(*(*uint8)(unsafe.Pointer(p1))) & ^int32(NSVG_VIS_DISPLAY)) } } else { if libc.Xstrcmp(tls, name, __ccgo_ts+5922) == 0 { if libc.Xstrcmp(tls, value, __ccgo_ts+16731) == 0 { p2 = attr + 310 *(*uint8)(unsafe.Pointer(p2)) = uint8(int32(*(*uint8)(unsafe.Pointer(p2))) & ^int32(NSVG_VIS_VISIBLE)) } else { if libc.Xstrcmp(tls, value, __ccgo_ts+41496) == 0 { p3 = attr + 310 *(*uint8)(unsafe.Pointer(p3)) = uint8(int32(*(*uint8)(unsafe.Pointer(p3))) | int32(NSVG_VIS_VISIBLE)) } } } else { if libc.Xstrcmp(tls, name, __ccgo_ts+41504) == 0 { if libc.Xstrcmp(tls, value, __ccgo_ts+8223) == 0 { (*TNSVGattrib)(unsafe.Pointer(attr)).FhasFill = uint8(0) } else { if libc.Xstrncmp(tls, value, __ccgo_ts+41509, uint64(4)) == 0 { (*TNSVGattrib)(unsafe.Pointer(attr)).FhasFill = uint8(2) _nsvg__parseUrl(tls, attr+108, value) } else { (*TNSVGattrib)(unsafe.Pointer(attr)).FhasFill = uint8(1) (*TNSVGattrib)(unsafe.Pointer(attr)).FfillColor = _nsvg__parseColor(tls, value) } } } else { if libc.Xstrcmp(tls, name, __ccgo_ts+41514) == 0 { (*TNSVGattrib)(unsafe.Pointer(attr)).Fopacity = _nsvg__parseOpacity(tls, value) } else { if libc.Xstrcmp(tls, name, __ccgo_ts+41522) == 0 { (*TNSVGattrib)(unsafe.Pointer(attr)).FfillOpacity = _nsvg__parseOpacity(tls, value) } else { if libc.Xstrcmp(tls, name, __ccgo_ts+41535) == 0 { if libc.Xstrcmp(tls, value, __ccgo_ts+8223) == 0 { (*TNSVGattrib)(unsafe.Pointer(attr)).FhasStroke = uint8(0) } else { if libc.Xstrncmp(tls, value, __ccgo_ts+41509, uint64(4)) == 0 { (*TNSVGattrib)(unsafe.Pointer(attr)).FhasStroke = uint8(2) _nsvg__parseUrl(tls, attr+172, value) } else { (*TNSVGattrib)(unsafe.Pointer(attr)).FhasStroke = uint8(1) (*TNSVGattrib)(unsafe.Pointer(attr)).FstrokeColor = _nsvg__parseColor(tls, value) } } } else { if libc.Xstrcmp(tls, name, __ccgo_ts+41542) == 0 { (*TNSVGattrib)(unsafe.Pointer(attr)).FstrokeWidth = _nsvg__parseCoordinate(tls, p, value, libc.Float32FromFloat32(0), _nsvg__actualLength(tls, p)) } else { if libc.Xstrcmp(tls, name, __ccgo_ts+41555) == 0 { (*TNSVGattrib)(unsafe.Pointer(attr)).FstrokeDashCount = _nsvg__parseStrokeDashArray(tls, p, value, attr+244) } else { if libc.Xstrcmp(tls, name, __ccgo_ts+41572) == 0 { (*TNSVGattrib)(unsafe.Pointer(attr)).FstrokeDashOffset = _nsvg__parseCoordinate(tls, p, value, libc.Float32FromFloat32(0), _nsvg__actualLength(tls, p)) } else { if libc.Xstrcmp(tls, name, __ccgo_ts+41590) == 0 { (*TNSVGattrib)(unsafe.Pointer(attr)).FstrokeOpacity = _nsvg__parseOpacity(tls, value) } else { if libc.Xstrcmp(tls, name, __ccgo_ts+41605) == 0 { (*TNSVGattrib)(unsafe.Pointer(attr)).FstrokeLineCap = _nsvg__parseLineCap(tls, value) } else { if libc.Xstrcmp(tls, name, __ccgo_ts+41620) == 0 { (*TNSVGattrib)(unsafe.Pointer(attr)).FstrokeLineJoin = _nsvg__parseLineJoin(tls, value) } else { if libc.Xstrcmp(tls, name, __ccgo_ts+41636) == 0 { (*TNSVGattrib)(unsafe.Pointer(attr)).FmiterLimit = _nsvg__parseMiterLimit(tls, value) } else { if libc.Xstrcmp(tls, name, __ccgo_ts+41654) == 0 { (*TNSVGattrib)(unsafe.Pointer(attr)).FfillRule = _nsvg__parseFillRule(tls, value) } else { if libc.Xstrcmp(tls, name, __ccgo_ts+41664) == 0 { (*TNSVGattrib)(unsafe.Pointer(attr)).FfontSize = _nsvg__parseCoordinate(tls, p, value, libc.Float32FromFloat32(0), _nsvg__actualLength(tls, p)) } else { if libc.Xstrcmp(tls, name, __ccgo_ts+41674) == 0 { _nsvg__parseTransform(tls, bp, value) _nsvg__xformPremultiply(tls, attr+64, bp) } else { if libc.Xstrcmp(tls, name, __ccgo_ts+41684) == 0 { (*TNSVGattrib)(unsafe.Pointer(attr)).FstopColor = _nsvg__parseColor(tls, value) } else { if libc.Xstrcmp(tls, name, __ccgo_ts+41695) == 0 { (*TNSVGattrib)(unsafe.Pointer(attr)).FstopOpacity = _nsvg__parseOpacity(tls, value) } else { if libc.Xstrcmp(tls, name, __ccgo_ts+26552) == 0 { (*TNSVGattrib)(unsafe.Pointer(attr)).FstopOffset = _nsvg__parseCoordinate(tls, p, value, libc.Float32FromFloat32(0), libc.Float32FromFloat32(1)) } else { if libc.Xstrcmp(tls, name, __ccgo_ts+6179) == 0 { libc.Xstrncpy(tls, attr, value, uint64(63)) *(*uint8)(unsafe.Pointer(attr + 63)) = uint8('\000') } else { if libc.Xstrcmp(tls, name, __ccgo_ts+6138) == 0 { style = (*TNSVGparser)(unsafe.Pointer(p)).Fstyles for style != 0 { if libc.Xstrcmp(tls, (*TNSVGstyles)(unsafe.Pointer(style)).Fname+uintptr(1), value) == 0 { break } style = (*TNSVGstyles)(unsafe.Pointer(style)).Fnext } if style != 0 { _nsvg__parseStyle(tls, p, (*TNSVGstyles)(unsafe.Pointer(style)).Fdescription) } } else { return 0 } } } } } } } } } } } } } } } } } } } } } } return int32(1) } func _nsvg__parseNameValue(tls *libc.TLS, p uintptr, start uintptr, end uintptr) (r int32) { bp := tls.Alloc(1024) defer tls.Free(1024) var n int32 var str, val uintptr var _ /* name at bp+0 */ [512]uint8 var _ /* value at bp+512 */ [512]uint8 _, _, _ = n, str, val str = start for str < end && libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(str))) != int32(':') { str++ } val = str for str > start && (libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(str))) == int32(':') || _nsvg__isspace(tls, *(*uint8)(unsafe.Pointer(str))) != 0) { str-- } str++ n = int32(int64(str) - int64(start)) if n > int32(511) { n = int32(511) } if n != 0 { libc.Xmemcpy(tls, bp, start, libc.Uint64FromInt32(n)) } (*(*[512]uint8)(unsafe.Pointer(bp)))[n] = uint8(0) for val < end && (libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(val))) == int32(':') || _nsvg__isspace(tls, *(*uint8)(unsafe.Pointer(val))) != 0) { val++ } n = int32(int64(end) - int64(val)) if n > int32(511) { n = int32(511) } if n != 0 { libc.Xmemcpy(tls, bp+512, val, libc.Uint64FromInt32(n)) } (*(*[512]uint8)(unsafe.Pointer(bp + 512)))[n] = uint8(0) return _nsvg__parseAttr(tls, p, bp, bp+512) } func _nsvg__parseStyle(tls *libc.TLS, p uintptr, str uintptr) { var end, start uintptr _, _ = end, start for *(*uint8)(unsafe.Pointer(str)) != 0 { for *(*uint8)(unsafe.Pointer(str)) != 0 && _nsvg__isspace(tls, *(*uint8)(unsafe.Pointer(str))) != 0 { str++ } start = str for *(*uint8)(unsafe.Pointer(str)) != 0 && libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(str))) != int32(';') { str++ } end = str for end > start && (libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(end))) == int32(';') || _nsvg__isspace(tls, *(*uint8)(unsafe.Pointer(end))) != 0) { end-- } end++ _nsvg__parseNameValue(tls, p, start, end) if *(*uint8)(unsafe.Pointer(str)) != 0 { str++ } } } func _nsvg__parseAttribs(tls *libc.TLS, p uintptr, attr uintptr) { var i int32 _ = i i = 0 for { if !(*(*uintptr)(unsafe.Pointer(attr + uintptr(i)*8)) != 0) { break } if libc.Xstrcmp(tls, *(*uintptr)(unsafe.Pointer(attr + uintptr(i)*8)), __ccgo_ts+16580) == 0 { _nsvg__parseStyle(tls, p, *(*uintptr)(unsafe.Pointer(attr + uintptr(i+int32(1))*8))) } else { _nsvg__parseAttr(tls, p, *(*uintptr)(unsafe.Pointer(attr + uintptr(i)*8)), *(*uintptr)(unsafe.Pointer(attr + uintptr(i+int32(1))*8))) } goto _1 _1: ; i += int32(2) } } func _nsvg__getArgsPerElement(tls *libc.TLS, cmd uint8) (r int32) { switch libc.Int32FromUint8(cmd) { case int32('v'): fallthrough case int32('V'): fallthrough case int32('h'): fallthrough case int32('H'): return int32(1) case int32('m'): fallthrough case int32('M'): fallthrough case int32('l'): fallthrough case int32('L'): fallthrough case int32('t'): fallthrough case int32('T'): return int32(2) case int32('q'): fallthrough case int32('Q'): fallthrough case int32('s'): fallthrough case int32('S'): return int32(4) case int32('c'): fallthrough case int32('C'): return int32(6) case int32('a'): fallthrough case int32('A'): return int32(7) case int32('z'): fallthrough case int32('Z'): return 0 } return -int32(1) } func _nsvg__pathMoveTo(tls *libc.TLS, p uintptr, cpx uintptr, cpy uintptr, args uintptr, rel int32) { if rel != 0 { *(*float32)(unsafe.Pointer(cpx)) += *(*float32)(unsafe.Pointer(args)) *(*float32)(unsafe.Pointer(cpy)) += *(*float32)(unsafe.Pointer(args + 1*4)) } else { *(*float32)(unsafe.Pointer(cpx)) = *(*float32)(unsafe.Pointer(args)) *(*float32)(unsafe.Pointer(cpy)) = *(*float32)(unsafe.Pointer(args + 1*4)) } _nsvg__moveTo(tls, p, *(*float32)(unsafe.Pointer(cpx)), *(*float32)(unsafe.Pointer(cpy))) } func _nsvg__pathLineTo(tls *libc.TLS, p uintptr, cpx uintptr, cpy uintptr, args uintptr, rel int32) { if rel != 0 { *(*float32)(unsafe.Pointer(cpx)) += *(*float32)(unsafe.Pointer(args)) *(*float32)(unsafe.Pointer(cpy)) += *(*float32)(unsafe.Pointer(args + 1*4)) } else { *(*float32)(unsafe.Pointer(cpx)) = *(*float32)(unsafe.Pointer(args)) *(*float32)(unsafe.Pointer(cpy)) = *(*float32)(unsafe.Pointer(args + 1*4)) } _nsvg__lineTo(tls, p, *(*float32)(unsafe.Pointer(cpx)), *(*float32)(unsafe.Pointer(cpy))) } func _nsvg__pathHLineTo(tls *libc.TLS, p uintptr, cpx uintptr, cpy uintptr, args uintptr, rel int32) { if rel != 0 { *(*float32)(unsafe.Pointer(cpx)) += *(*float32)(unsafe.Pointer(args)) } else { *(*float32)(unsafe.Pointer(cpx)) = *(*float32)(unsafe.Pointer(args)) } _nsvg__lineTo(tls, p, *(*float32)(unsafe.Pointer(cpx)), *(*float32)(unsafe.Pointer(cpy))) } func _nsvg__pathVLineTo(tls *libc.TLS, p uintptr, cpx uintptr, cpy uintptr, args uintptr, rel int32) { if rel != 0 { *(*float32)(unsafe.Pointer(cpy)) += *(*float32)(unsafe.Pointer(args)) } else { *(*float32)(unsafe.Pointer(cpy)) = *(*float32)(unsafe.Pointer(args)) } _nsvg__lineTo(tls, p, *(*float32)(unsafe.Pointer(cpx)), *(*float32)(unsafe.Pointer(cpy))) } func _nsvg__pathCubicBezTo(tls *libc.TLS, p uintptr, cpx uintptr, cpy uintptr, cpx2 uintptr, cpy2 uintptr, args uintptr, rel int32) { var cx1, cx2, cy1, cy2, x2, y2 float32 _, _, _, _, _, _ = cx1, cx2, cy1, cy2, x2, y2 if rel != 0 { cx1 = *(*float32)(unsafe.Pointer(cpx)) + *(*float32)(unsafe.Pointer(args)) cy1 = *(*float32)(unsafe.Pointer(cpy)) + *(*float32)(unsafe.Pointer(args + 1*4)) cx2 = *(*float32)(unsafe.Pointer(cpx)) + *(*float32)(unsafe.Pointer(args + 2*4)) cy2 = *(*float32)(unsafe.Pointer(cpy)) + *(*float32)(unsafe.Pointer(args + 3*4)) x2 = *(*float32)(unsafe.Pointer(cpx)) + *(*float32)(unsafe.Pointer(args + 4*4)) y2 = *(*float32)(unsafe.Pointer(cpy)) + *(*float32)(unsafe.Pointer(args + 5*4)) } else { cx1 = *(*float32)(unsafe.Pointer(args)) cy1 = *(*float32)(unsafe.Pointer(args + 1*4)) cx2 = *(*float32)(unsafe.Pointer(args + 2*4)) cy2 = *(*float32)(unsafe.Pointer(args + 3*4)) x2 = *(*float32)(unsafe.Pointer(args + 4*4)) y2 = *(*float32)(unsafe.Pointer(args + 5*4)) } _nsvg__cubicBezTo(tls, p, cx1, cy1, cx2, cy2, x2, y2) *(*float32)(unsafe.Pointer(cpx2)) = cx2 *(*float32)(unsafe.Pointer(cpy2)) = cy2 *(*float32)(unsafe.Pointer(cpx)) = x2 *(*float32)(unsafe.Pointer(cpy)) = y2 } func _nsvg__pathCubicBezShortTo(tls *libc.TLS, p uintptr, cpx uintptr, cpy uintptr, cpx2 uintptr, cpy2 uintptr, args uintptr, rel int32) { var cx1, cx2, cy1, cy2, x1, x2, y1, y2 float32 _, _, _, _, _, _, _, _ = cx1, cx2, cy1, cy2, x1, x2, y1, y2 x1 = *(*float32)(unsafe.Pointer(cpx)) y1 = *(*float32)(unsafe.Pointer(cpy)) if rel != 0 { cx2 = *(*float32)(unsafe.Pointer(cpx)) + *(*float32)(unsafe.Pointer(args)) cy2 = *(*float32)(unsafe.Pointer(cpy)) + *(*float32)(unsafe.Pointer(args + 1*4)) x2 = *(*float32)(unsafe.Pointer(cpx)) + *(*float32)(unsafe.Pointer(args + 2*4)) y2 = *(*float32)(unsafe.Pointer(cpy)) + *(*float32)(unsafe.Pointer(args + 3*4)) } else { cx2 = *(*float32)(unsafe.Pointer(args)) cy2 = *(*float32)(unsafe.Pointer(args + 1*4)) x2 = *(*float32)(unsafe.Pointer(args + 2*4)) y2 = *(*float32)(unsafe.Pointer(args + 3*4)) } cx1 = float32(libc.Float32FromInt32(2)*x1) - *(*float32)(unsafe.Pointer(cpx2)) cy1 = float32(libc.Float32FromInt32(2)*y1) - *(*float32)(unsafe.Pointer(cpy2)) _nsvg__cubicBezTo(tls, p, cx1, cy1, cx2, cy2, x2, y2) *(*float32)(unsafe.Pointer(cpx2)) = cx2 *(*float32)(unsafe.Pointer(cpy2)) = cy2 *(*float32)(unsafe.Pointer(cpx)) = x2 *(*float32)(unsafe.Pointer(cpy)) = y2 } func _nsvg__pathQuadBezTo(tls *libc.TLS, p uintptr, cpx uintptr, cpy uintptr, cpx2 uintptr, cpy2 uintptr, args uintptr, rel int32) { var cx, cx1, cx2, cy, cy1, cy2, x1, x2, y1, y2 float32 _, _, _, _, _, _, _, _, _, _ = cx, cx1, cx2, cy, cy1, cy2, x1, x2, y1, y2 x1 = *(*float32)(unsafe.Pointer(cpx)) y1 = *(*float32)(unsafe.Pointer(cpy)) if rel != 0 { cx = *(*float32)(unsafe.Pointer(cpx)) + *(*float32)(unsafe.Pointer(args)) cy = *(*float32)(unsafe.Pointer(cpy)) + *(*float32)(unsafe.Pointer(args + 1*4)) x2 = *(*float32)(unsafe.Pointer(cpx)) + *(*float32)(unsafe.Pointer(args + 2*4)) y2 = *(*float32)(unsafe.Pointer(cpy)) + *(*float32)(unsafe.Pointer(args + 3*4)) } else { cx = *(*float32)(unsafe.Pointer(args)) cy = *(*float32)(unsafe.Pointer(args + 1*4)) x2 = *(*float32)(unsafe.Pointer(args + 2*4)) y2 = *(*float32)(unsafe.Pointer(args + 3*4)) } cx1 = x1 + float32(libc.Float32FromFloat32(2)/libc.Float32FromFloat32(3)*(cx-x1)) cy1 = y1 + float32(libc.Float32FromFloat32(2)/libc.Float32FromFloat32(3)*(cy-y1)) cx2 = x2 + float32(libc.Float32FromFloat32(2)/libc.Float32FromFloat32(3)*(cx-x2)) cy2 = y2 + float32(libc.Float32FromFloat32(2)/libc.Float32FromFloat32(3)*(cy-y2)) _nsvg__cubicBezTo(tls, p, cx1, cy1, cx2, cy2, x2, y2) *(*float32)(unsafe.Pointer(cpx2)) = cx *(*float32)(unsafe.Pointer(cpy2)) = cy *(*float32)(unsafe.Pointer(cpx)) = x2 *(*float32)(unsafe.Pointer(cpy)) = y2 } func _nsvg__pathQuadBezShortTo(tls *libc.TLS, p uintptr, cpx uintptr, cpy uintptr, cpx2 uintptr, cpy2 uintptr, args uintptr, rel int32) { var cx, cx1, cx2, cy, cy1, cy2, x1, x2, y1, y2 float32 _, _, _, _, _, _, _, _, _, _ = cx, cx1, cx2, cy, cy1, cy2, x1, x2, y1, y2 x1 = *(*float32)(unsafe.Pointer(cpx)) y1 = *(*float32)(unsafe.Pointer(cpy)) if rel != 0 { x2 = *(*float32)(unsafe.Pointer(cpx)) + *(*float32)(unsafe.Pointer(args)) y2 = *(*float32)(unsafe.Pointer(cpy)) + *(*float32)(unsafe.Pointer(args + 1*4)) } else { x2 = *(*float32)(unsafe.Pointer(args)) y2 = *(*float32)(unsafe.Pointer(args + 1*4)) } cx = float32(libc.Float32FromInt32(2)*x1) - *(*float32)(unsafe.Pointer(cpx2)) cy = float32(libc.Float32FromInt32(2)*y1) - *(*float32)(unsafe.Pointer(cpy2)) cx1 = x1 + float32(libc.Float32FromFloat32(2)/libc.Float32FromFloat32(3)*(cx-x1)) cy1 = y1 + float32(libc.Float32FromFloat32(2)/libc.Float32FromFloat32(3)*(cy-y1)) cx2 = x2 + float32(libc.Float32FromFloat32(2)/libc.Float32FromFloat32(3)*(cx-x2)) cy2 = y2 + float32(libc.Float32FromFloat32(2)/libc.Float32FromFloat32(3)*(cy-y2)) _nsvg__cubicBezTo(tls, p, cx1, cy1, cx2, cy2, x2, y2) *(*float32)(unsafe.Pointer(cpx2)) = cx *(*float32)(unsafe.Pointer(cpy2)) = cy *(*float32)(unsafe.Pointer(cpx)) = x2 *(*float32)(unsafe.Pointer(cpy)) = y2 } func _nsvg__sqr(tls *libc.TLS, x float32) (r float32) { return float32(x * x) } func _nsvg__vmag(tls *libc.TLS, x float32, y float32) (r float32) { return libc.Xsqrtf(tls, float32(x*x)+float32(y*y)) } func _nsvg__vecrat(tls *libc.TLS, ux float32, uy float32, vx float32, vy float32) (r float32) { return (float32(ux*vx) + float32(uy*vy)) / float32(_nsvg__vmag(tls, ux, uy)*_nsvg__vmag(tls, vx, vy)) } func _nsvg__vecang(tls *libc.TLS, ux float32, uy float32, vx float32, vy float32) (r1 float32) { var r, v1 float32 _, _ = r, v1 r = _nsvg__vecrat(tls, ux, uy, vx, vy) if r < -libc.Float32FromFloat32(1) { r = -libc.Float32FromFloat32(1) } if r > libc.Float32FromFloat32(1) { r = libc.Float32FromFloat32(1) } if float32(ux*vy) < float32(uy*vx) { v1 = -libc.Float32FromFloat32(1) } else { v1 = libc.Float32FromFloat32(1) } return float32(v1 * libc.Xacosf(tls, r)) } func _nsvg__pathArcTo(tls *libc.TLS, p uintptr, cpx uintptr, cpy uintptr, args uintptr, rel int32) { bp := tls.Alloc(48) defer tls.Free(48) var a, a1, cosrx, cx, cxp, cy, cyp, d, da, dx, dy, hda, kappa, ptanx, ptany, px, py, rotx, rx, ry, s, sa, sb, sinrx, ux, uy, vx, vy, x1, x1p, x2, y1, y1p, y2 float32 var fa, fs, i, ndivs, v1, v2 int32 var _ /* t at bp+16 */ [6]float32 var _ /* tanx at bp+8 */ float32 var _ /* tany at bp+12 */ float32 var _ /* x at bp+0 */ float32 var _ /* y at bp+4 */ float32 _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = a, a1, cosrx, cx, cxp, cy, cyp, d, da, dx, dy, fa, fs, hda, i, kappa, ndivs, ptanx, ptany, px, py, rotx, rx, ry, s, sa, sb, sinrx, ux, uy, vx, vy, x1, x1p, x2, y1, y1p, y2, v1, v2 px = libc.Float32FromInt32(0) py = libc.Float32FromInt32(0) ptanx = libc.Float32FromInt32(0) ptany = libc.Float32FromInt32(0) rx = libc.Xfabsf(tls, *(*float32)(unsafe.Pointer(args))) ry = libc.Xfabsf(tls, *(*float32)(unsafe.Pointer(args + 1*4))) rotx = float32(*(*float32)(unsafe.Pointer(args + 2*4)) / libc.Float32FromFloat32(180) * libc.Float32FromFloat32(3.141592653589793)) if float64(libc.Xfabsf(tls, *(*float32)(unsafe.Pointer(args + 3*4)))) > float64(1e-06) { v1 = int32(1) } else { v1 = 0 } fa = v1 if float64(libc.Xfabsf(tls, *(*float32)(unsafe.Pointer(args + 4*4)))) > float64(1e-06) { v2 = int32(1) } else { v2 = 0 } fs = v2 x1 = *(*float32)(unsafe.Pointer(cpx)) y1 = *(*float32)(unsafe.Pointer(cpy)) if rel != 0 { x2 = *(*float32)(unsafe.Pointer(cpx)) + *(*float32)(unsafe.Pointer(args + 5*4)) y2 = *(*float32)(unsafe.Pointer(cpy)) + *(*float32)(unsafe.Pointer(args + 6*4)) } else { x2 = *(*float32)(unsafe.Pointer(args + 5*4)) y2 = *(*float32)(unsafe.Pointer(args + 6*4)) } dx = x1 - x2 dy = y1 - y2 d = libc.Xsqrtf(tls, float32(dx*dx)+float32(dy*dy)) if d < libc.Float32FromFloat32(1e-06) || rx < libc.Float32FromFloat32(1e-06) || ry < libc.Float32FromFloat32(1e-06) { _nsvg__lineTo(tls, p, x2, y2) *(*float32)(unsafe.Pointer(cpx)) = x2 *(*float32)(unsafe.Pointer(cpy)) = y2 return } sinrx = libc.Xsinf(tls, rotx) cosrx = libc.Xcosf(tls, rotx) x1p = float32(cosrx*dx)/libc.Float32FromFloat32(2) + float32(sinrx*dy)/libc.Float32FromFloat32(2) y1p = float32(-sinrx*dx)/libc.Float32FromFloat32(2) + float32(cosrx*dy)/libc.Float32FromFloat32(2) d = _nsvg__sqr(tls, x1p)/_nsvg__sqr(tls, rx) + _nsvg__sqr(tls, y1p)/_nsvg__sqr(tls, ry) if d > libc.Float32FromInt32(1) { d = libc.Xsqrtf(tls, d) rx *= d ry *= d } s = libc.Float32FromFloat32(0) sa = float32(_nsvg__sqr(tls, rx)*_nsvg__sqr(tls, ry)) - float32(_nsvg__sqr(tls, rx)*_nsvg__sqr(tls, y1p)) - float32(_nsvg__sqr(tls, ry)*_nsvg__sqr(tls, x1p)) sb = float32(_nsvg__sqr(tls, rx)*_nsvg__sqr(tls, y1p)) + float32(_nsvg__sqr(tls, ry)*_nsvg__sqr(tls, x1p)) if sa < libc.Float32FromFloat32(0) { sa = libc.Float32FromFloat32(0) } if sb > libc.Float32FromFloat32(0) { s = libc.Xsqrtf(tls, sa/sb) } if fa == fs { s = -s } cxp = float32(float32(s*rx)*y1p) / ry cyp = float32(float32(s*-ry)*x1p) / rx cx = (x1+x2)/libc.Float32FromFloat32(2) + float32(cosrx*cxp) - float32(sinrx*cyp) cy = (y1+y2)/libc.Float32FromFloat32(2) + float32(sinrx*cxp) + float32(cosrx*cyp) ux = (x1p - cxp) / rx uy = (y1p - cyp) / ry vx = (-x1p - cxp) / rx vy = (-y1p - cyp) / ry a1 = _nsvg__vecang(tls, libc.Float32FromFloat32(1), libc.Float32FromFloat32(0), ux, uy) da = _nsvg__vecang(tls, ux, uy, vx, vy) if fs == 0 && da > libc.Float32FromInt32(0) { da -= float32(libc.Float32FromInt32(2) * libc.Float32FromFloat32(3.141592653589793)) } else { if fs == int32(1) && da < libc.Float32FromInt32(0) { da += float32(libc.Float32FromInt32(2) * libc.Float32FromFloat32(3.141592653589793)) } } (*(*[6]float32)(unsafe.Pointer(bp + 16)))[0] = cosrx (*(*[6]float32)(unsafe.Pointer(bp + 16)))[int32(1)] = sinrx (*(*[6]float32)(unsafe.Pointer(bp + 16)))[int32(2)] = -sinrx (*(*[6]float32)(unsafe.Pointer(bp + 16)))[int32(3)] = cosrx (*(*[6]float32)(unsafe.Pointer(bp + 16)))[int32(4)] = cx (*(*[6]float32)(unsafe.Pointer(bp + 16)))[int32(5)] = cy ndivs = int32(libc.Xfabsf(tls, da)/float32(libc.Float32FromFloat32(3.141592653589793)*libc.Float32FromFloat32(0.5)) + libc.Float32FromFloat32(1)) hda = da / float32(ndivs) / libc.Float32FromFloat32(2) if hda < libc.Float32FromFloat32(0.001) && hda > -libc.Float32FromFloat32(0.001) { hda *= libc.Float32FromFloat32(0.5) } else { hda = (libc.Float32FromFloat32(1) - libc.Xcosf(tls, hda)) / libc.Xsinf(tls, hda) } kappa = libc.Xfabsf(tls, float32(libc.Float32FromFloat32(4)/libc.Float32FromFloat32(3)*hda)) if da < libc.Float32FromFloat32(0) { kappa = -kappa } i = 0 for { if !(i <= ndivs) { break } a = a1 + float32(da*(float32(i)/float32(ndivs))) dx = libc.Xcosf(tls, a) dy = libc.Xsinf(tls, a) _nsvg__xformPoint(tls, bp, bp+4, float32(dx*rx), float32(dy*ry), bp+16) _nsvg__xformVec(tls, bp+8, bp+12, float32(float32(-dy*rx)*kappa), float32(float32(dx*ry)*kappa), bp+16) if i > 0 { _nsvg__cubicBezTo(tls, p, px+ptanx, py+ptany, *(*float32)(unsafe.Pointer(bp))-*(*float32)(unsafe.Pointer(bp + 8)), *(*float32)(unsafe.Pointer(bp + 4))-*(*float32)(unsafe.Pointer(bp + 12)), *(*float32)(unsafe.Pointer(bp)), *(*float32)(unsafe.Pointer(bp + 4))) } px = *(*float32)(unsafe.Pointer(bp)) py = *(*float32)(unsafe.Pointer(bp + 4)) ptanx = *(*float32)(unsafe.Pointer(bp + 8)) ptany = *(*float32)(unsafe.Pointer(bp + 12)) goto _3 _3: ; i++ } *(*float32)(unsafe.Pointer(cpx)) = x2 *(*float32)(unsafe.Pointer(cpy)) = y2 } func _nsvg__parsePath(tls *libc.TLS, p uintptr, attr uintptr) { bp := tls.Alloc(160) defer tls.Free(160) var closedFlag, cmd, initPoint uint8 var i, nargs, rargs, v10, v11, v12, v2, v3, v4, v5, v6, v7, v8, v9 int32 var s uintptr var _ /* args at bp+0 */ [10]float32 var _ /* cpx at bp+40 */ float32 var _ /* cpx2 at bp+48 */ float32 var _ /* cpy at bp+44 */ float32 var _ /* cpy2 at bp+52 */ float32 var _ /* item at bp+88 */ [64]uint8 var _ /* tmp at bp+56 */ [4]uintptr _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = closedFlag, cmd, i, initPoint, nargs, rargs, s, v10, v11, v12, v2, v3, v4, v5, v6, v7, v8, v9 s = libc.UintptrFromInt32(0) cmd = uint8('\000') rargs = 0 i = 0 for { if !(*(*uintptr)(unsafe.Pointer(attr + uintptr(i)*8)) != 0) { break } if libc.Xstrcmp(tls, *(*uintptr)(unsafe.Pointer(attr + uintptr(i)*8)), __ccgo_ts+41708) == 0 { s = *(*uintptr)(unsafe.Pointer(attr + uintptr(i+int32(1))*8)) } else { (*(*[4]uintptr)(unsafe.Pointer(bp + 56)))[0] = *(*uintptr)(unsafe.Pointer(attr + uintptr(i)*8)) (*(*[4]uintptr)(unsafe.Pointer(bp + 56)))[int32(1)] = *(*uintptr)(unsafe.Pointer(attr + uintptr(i+int32(1))*8)) (*(*[4]uintptr)(unsafe.Pointer(bp + 56)))[int32(2)] = uintptr(0) (*(*[4]uintptr)(unsafe.Pointer(bp + 56)))[int32(3)] = uintptr(0) _nsvg__parseAttribs(tls, p, bp+56) } goto _1 _1: ; i += int32(2) } if s != 0 { _nsvg__resetPath(tls, p) *(*float32)(unsafe.Pointer(bp + 40)) = libc.Float32FromInt32(0) *(*float32)(unsafe.Pointer(bp + 44)) = libc.Float32FromInt32(0) *(*float32)(unsafe.Pointer(bp + 48)) = libc.Float32FromInt32(0) *(*float32)(unsafe.Pointer(bp + 52)) = libc.Float32FromInt32(0) initPoint = uint8(0) closedFlag = uint8(0) nargs = 0 for *(*uint8)(unsafe.Pointer(s)) != 0 { (*(*[64]uint8)(unsafe.Pointer(bp + 88)))[0] = uint8('\000') if (libc.Int32FromUint8(cmd) == int32('A') || libc.Int32FromUint8(cmd) == int32('a')) && (nargs == int32(3) || nargs == int32(4)) { s = _nsvg__getNextPathItemWhenArcFlag(tls, s, bp+88) } if !(*(*uint8)(unsafe.Pointer(bp + 88)) != 0) { s = _nsvg__getNextPathItem(tls, s, bp+88) } if !(*(*uint8)(unsafe.Pointer(bp + 88)) != 0) { break } if libc.Int32FromUint8(cmd) != int32('\000') && _nsvg__isCoordinate(tls, bp+88) != 0 { if nargs < int32(10) { v2 = nargs nargs++ (*(*[10]float32)(unsafe.Pointer(bp)))[v2] = float32(_nsvg__atof(tls, bp+88)) } if nargs >= rargs { switch libc.Int32FromUint8(cmd) { case int32('m'): fallthrough case int32('M'): if libc.Int32FromUint8(cmd) == int32('m') { v3 = int32(1) } else { v3 = 0 } _nsvg__pathMoveTo(tls, p, bp+40, bp+44, bp, v3) if libc.Int32FromUint8(cmd) == int32('m') { v4 = int32('l') } else { v4 = int32('L') } cmd = libc.Uint8FromInt32(v4) rargs = _nsvg__getArgsPerElement(tls, cmd) *(*float32)(unsafe.Pointer(bp + 48)) = *(*float32)(unsafe.Pointer(bp + 40)) *(*float32)(unsafe.Pointer(bp + 52)) = *(*float32)(unsafe.Pointer(bp + 44)) initPoint = uint8(1) case int32('l'): fallthrough case int32('L'): if libc.Int32FromUint8(cmd) == int32('l') { v5 = int32(1) } else { v5 = 0 } _nsvg__pathLineTo(tls, p, bp+40, bp+44, bp, v5) *(*float32)(unsafe.Pointer(bp + 48)) = *(*float32)(unsafe.Pointer(bp + 40)) *(*float32)(unsafe.Pointer(bp + 52)) = *(*float32)(unsafe.Pointer(bp + 44)) case int32('H'): fallthrough case int32('h'): if libc.Int32FromUint8(cmd) == int32('h') { v6 = int32(1) } else { v6 = 0 } _nsvg__pathHLineTo(tls, p, bp+40, bp+44, bp, v6) *(*float32)(unsafe.Pointer(bp + 48)) = *(*float32)(unsafe.Pointer(bp + 40)) *(*float32)(unsafe.Pointer(bp + 52)) = *(*float32)(unsafe.Pointer(bp + 44)) case int32('V'): fallthrough case int32('v'): if libc.Int32FromUint8(cmd) == int32('v') { v7 = int32(1) } else { v7 = 0 } _nsvg__pathVLineTo(tls, p, bp+40, bp+44, bp, v7) *(*float32)(unsafe.Pointer(bp + 48)) = *(*float32)(unsafe.Pointer(bp + 40)) *(*float32)(unsafe.Pointer(bp + 52)) = *(*float32)(unsafe.Pointer(bp + 44)) case int32('C'): fallthrough case int32('c'): if libc.Int32FromUint8(cmd) == int32('c') { v8 = int32(1) } else { v8 = 0 } _nsvg__pathCubicBezTo(tls, p, bp+40, bp+44, bp+48, bp+52, bp, v8) case int32('S'): fallthrough case int32('s'): if libc.Int32FromUint8(cmd) == int32('s') { v9 = int32(1) } else { v9 = 0 } _nsvg__pathCubicBezShortTo(tls, p, bp+40, bp+44, bp+48, bp+52, bp, v9) case int32('Q'): fallthrough case int32('q'): if libc.Int32FromUint8(cmd) == int32('q') { v10 = int32(1) } else { v10 = 0 } _nsvg__pathQuadBezTo(tls, p, bp+40, bp+44, bp+48, bp+52, bp, v10) case int32('T'): fallthrough case int32('t'): if libc.Int32FromUint8(cmd) == int32('t') { v11 = int32(1) } else { v11 = 0 } _nsvg__pathQuadBezShortTo(tls, p, bp+40, bp+44, bp+48, bp+52, bp, v11) case int32('A'): fallthrough case int32('a'): if libc.Int32FromUint8(cmd) == int32('a') { v12 = int32(1) } else { v12 = 0 } _nsvg__pathArcTo(tls, p, bp+40, bp+44, bp, v12) *(*float32)(unsafe.Pointer(bp + 48)) = *(*float32)(unsafe.Pointer(bp + 40)) *(*float32)(unsafe.Pointer(bp + 52)) = *(*float32)(unsafe.Pointer(bp + 44)) default: if nargs >= int32(2) { *(*float32)(unsafe.Pointer(bp + 40)) = (*(*[10]float32)(unsafe.Pointer(bp)))[nargs-int32(2)] *(*float32)(unsafe.Pointer(bp + 44)) = (*(*[10]float32)(unsafe.Pointer(bp)))[nargs-int32(1)] *(*float32)(unsafe.Pointer(bp + 48)) = *(*float32)(unsafe.Pointer(bp + 40)) *(*float32)(unsafe.Pointer(bp + 52)) = *(*float32)(unsafe.Pointer(bp + 44)) } break } nargs = 0 } } else { cmd = (*(*[64]uint8)(unsafe.Pointer(bp + 88)))[0] if libc.Int32FromUint8(cmd) == int32('M') || libc.Int32FromUint8(cmd) == int32('m') { if (*TNSVGparser)(unsafe.Pointer(p)).Fnpts > 0 { _nsvg__addPath(tls, p, closedFlag) } _nsvg__resetPath(tls, p) closedFlag = uint8(0) nargs = 0 } else { if libc.Int32FromUint8(initPoint) == 0 { cmd = uint8('\000') } } if libc.Int32FromUint8(cmd) == int32('Z') || libc.Int32FromUint8(cmd) == int32('z') { closedFlag = uint8(1) if (*TNSVGparser)(unsafe.Pointer(p)).Fnpts > 0 { *(*float32)(unsafe.Pointer(bp + 40)) = *(*float32)(unsafe.Pointer((*TNSVGparser)(unsafe.Pointer(p)).Fpts)) *(*float32)(unsafe.Pointer(bp + 44)) = *(*float32)(unsafe.Pointer((*TNSVGparser)(unsafe.Pointer(p)).Fpts + 1*4)) *(*float32)(unsafe.Pointer(bp + 48)) = *(*float32)(unsafe.Pointer(bp + 40)) *(*float32)(unsafe.Pointer(bp + 52)) = *(*float32)(unsafe.Pointer(bp + 44)) _nsvg__addPath(tls, p, closedFlag) } _nsvg__resetPath(tls, p) _nsvg__moveTo(tls, p, *(*float32)(unsafe.Pointer(bp + 40)), *(*float32)(unsafe.Pointer(bp + 44))) closedFlag = uint8(0) nargs = 0 } rargs = _nsvg__getArgsPerElement(tls, cmd) if rargs == -int32(1) { cmd = uint8('\000') rargs = 0 } } } if (*TNSVGparser)(unsafe.Pointer(p)).Fnpts != 0 { _nsvg__addPath(tls, p, closedFlag) } } _nsvg__addShape(tls, p) } func _nsvg__parseRect(tls *libc.TLS, p uintptr, attr uintptr) { var h, rx, ry, w, x, y float32 var i int32 _, _, _, _, _, _, _ = h, i, rx, ry, w, x, y x = libc.Float32FromFloat32(0) y = libc.Float32FromFloat32(0) w = libc.Float32FromFloat32(0) h = libc.Float32FromFloat32(0) rx = -libc.Float32FromFloat32(1) ry = -libc.Float32FromFloat32(1) i = 0 for { if !(*(*uintptr)(unsafe.Pointer(attr + uintptr(i)*8)) != 0) { break } if !(_nsvg__parseAttr(tls, p, *(*uintptr)(unsafe.Pointer(attr + uintptr(i)*8)), *(*uintptr)(unsafe.Pointer(attr + uintptr(i+int32(1))*8))) != 0) { if libc.Xstrcmp(tls, *(*uintptr)(unsafe.Pointer(attr + uintptr(i)*8)), __ccgo_ts+6452) == 0 { x = _nsvg__parseCoordinate(tls, p, *(*uintptr)(unsafe.Pointer(attr + uintptr(i+int32(1))*8)), _nsvg__actualOrigX(tls, p), _nsvg__actualWidth(tls, p)) } if libc.Xstrcmp(tls, *(*uintptr)(unsafe.Pointer(attr + uintptr(i)*8)), __ccgo_ts+6454) == 0 { y = _nsvg__parseCoordinate(tls, p, *(*uintptr)(unsafe.Pointer(attr + uintptr(i+int32(1))*8)), _nsvg__actualOrigY(tls, p), _nsvg__actualHeight(tls, p)) } if libc.Xstrcmp(tls, *(*uintptr)(unsafe.Pointer(attr + uintptr(i)*8)), __ccgo_ts+6446) == 0 { w = _nsvg__parseCoordinate(tls, p, *(*uintptr)(unsafe.Pointer(attr + uintptr(i+int32(1))*8)), libc.Float32FromFloat32(0), _nsvg__actualWidth(tls, p)) } if libc.Xstrcmp(tls, *(*uintptr)(unsafe.Pointer(attr + uintptr(i)*8)), __ccgo_ts+6172) == 0 { h = _nsvg__parseCoordinate(tls, p, *(*uintptr)(unsafe.Pointer(attr + uintptr(i+int32(1))*8)), libc.Float32FromFloat32(0), _nsvg__actualHeight(tls, p)) } if libc.Xstrcmp(tls, *(*uintptr)(unsafe.Pointer(attr + uintptr(i)*8)), __ccgo_ts+41710) == 0 { rx = libc.Xfabsf(tls, _nsvg__parseCoordinate(tls, p, *(*uintptr)(unsafe.Pointer(attr + uintptr(i+int32(1))*8)), libc.Float32FromFloat32(0), _nsvg__actualWidth(tls, p))) } if libc.Xstrcmp(tls, *(*uintptr)(unsafe.Pointer(attr + uintptr(i)*8)), __ccgo_ts+41713) == 0 { ry = libc.Xfabsf(tls, _nsvg__parseCoordinate(tls, p, *(*uintptr)(unsafe.Pointer(attr + uintptr(i+int32(1))*8)), libc.Float32FromFloat32(0), _nsvg__actualHeight(tls, p))) } } goto _1 _1: ; i += int32(2) } if rx < libc.Float32FromFloat32(0) && ry > libc.Float32FromFloat32(0) { rx = ry } if ry < libc.Float32FromFloat32(0) && rx > libc.Float32FromFloat32(0) { ry = rx } if rx < libc.Float32FromFloat32(0) { rx = libc.Float32FromFloat32(0) } if ry < libc.Float32FromFloat32(0) { ry = libc.Float32FromFloat32(0) } if rx > w/libc.Float32FromFloat32(2) { rx = w / libc.Float32FromFloat32(2) } if ry > h/libc.Float32FromFloat32(2) { ry = h / libc.Float32FromFloat32(2) } if w != libc.Float32FromFloat32(0) && h != libc.Float32FromFloat32(0) { _nsvg__resetPath(tls, p) if rx < libc.Float32FromFloat32(1e-05) || ry < libc.Float32FromFloat32(0.0001) { _nsvg__moveTo(tls, p, x, y) _nsvg__lineTo(tls, p, x+w, y) _nsvg__lineTo(tls, p, x+w, y+h) _nsvg__lineTo(tls, p, x, y+h) } else { _nsvg__moveTo(tls, p, x+rx, y) _nsvg__lineTo(tls, p, x+w-rx, y) _nsvg__cubicBezTo(tls, p, x+w-float32(rx*(libc.Float32FromInt32(1)-libc.Float32FromFloat32(0.5522847493))), y, x+w, y+float32(ry*(libc.Float32FromInt32(1)-libc.Float32FromFloat32(0.5522847493))), x+w, y+ry) _nsvg__lineTo(tls, p, x+w, y+h-ry) _nsvg__cubicBezTo(tls, p, x+w, y+h-float32(ry*(libc.Float32FromInt32(1)-libc.Float32FromFloat32(0.5522847493))), x+w-float32(rx*(libc.Float32FromInt32(1)-libc.Float32FromFloat32(0.5522847493))), y+h, x+w-rx, y+h) _nsvg__lineTo(tls, p, x+rx, y+h) _nsvg__cubicBezTo(tls, p, x+float32(rx*(libc.Float32FromInt32(1)-libc.Float32FromFloat32(0.5522847493))), y+h, x, y+h-float32(ry*(libc.Float32FromInt32(1)-libc.Float32FromFloat32(0.5522847493))), x, y+h-ry) _nsvg__lineTo(tls, p, x, y+ry) _nsvg__cubicBezTo(tls, p, x, y+float32(ry*(libc.Float32FromInt32(1)-libc.Float32FromFloat32(0.5522847493))), x+float32(rx*(libc.Float32FromInt32(1)-libc.Float32FromFloat32(0.5522847493))), y, x+rx, y) } _nsvg__addPath(tls, p, uint8(1)) _nsvg__addShape(tls, p) } } func _nsvg__parseCircle(tls *libc.TLS, p uintptr, attr uintptr) { var cx, cy, r float32 var i int32 _, _, _, _ = cx, cy, i, r cx = libc.Float32FromFloat32(0) cy = libc.Float32FromFloat32(0) r = libc.Float32FromFloat32(0) i = 0 for { if !(*(*uintptr)(unsafe.Pointer(attr + uintptr(i)*8)) != 0) { break } if !(_nsvg__parseAttr(tls, p, *(*uintptr)(unsafe.Pointer(attr + uintptr(i)*8)), *(*uintptr)(unsafe.Pointer(attr + uintptr(i+int32(1))*8))) != 0) { if libc.Xstrcmp(tls, *(*uintptr)(unsafe.Pointer(attr + uintptr(i)*8)), __ccgo_ts+41716) == 0 { cx = _nsvg__parseCoordinate(tls, p, *(*uintptr)(unsafe.Pointer(attr + uintptr(i+int32(1))*8)), _nsvg__actualOrigX(tls, p), _nsvg__actualWidth(tls, p)) } if libc.Xstrcmp(tls, *(*uintptr)(unsafe.Pointer(attr + uintptr(i)*8)), __ccgo_ts+41719) == 0 { cy = _nsvg__parseCoordinate(tls, p, *(*uintptr)(unsafe.Pointer(attr + uintptr(i+int32(1))*8)), _nsvg__actualOrigY(tls, p), _nsvg__actualHeight(tls, p)) } if libc.Xstrcmp(tls, *(*uintptr)(unsafe.Pointer(attr + uintptr(i)*8)), __ccgo_ts+9441) == 0 { r = libc.Xfabsf(tls, _nsvg__parseCoordinate(tls, p, *(*uintptr)(unsafe.Pointer(attr + uintptr(i+int32(1))*8)), libc.Float32FromFloat32(0), _nsvg__actualLength(tls, p))) } } goto _1 _1: ; i += int32(2) } if r > libc.Float32FromFloat32(0) { _nsvg__resetPath(tls, p) _nsvg__moveTo(tls, p, cx+r, cy) _nsvg__cubicBezTo(tls, p, cx+r, cy+float32(r*libc.Float32FromFloat32(0.5522847493)), cx+float32(r*libc.Float32FromFloat32(0.5522847493)), cy+r, cx, cy+r) _nsvg__cubicBezTo(tls, p, cx-float32(r*libc.Float32FromFloat32(0.5522847493)), cy+r, cx-r, cy+float32(r*libc.Float32FromFloat32(0.5522847493)), cx-r, cy) _nsvg__cubicBezTo(tls, p, cx-r, cy-float32(r*libc.Float32FromFloat32(0.5522847493)), cx-float32(r*libc.Float32FromFloat32(0.5522847493)), cy-r, cx, cy-r) _nsvg__cubicBezTo(tls, p, cx+float32(r*libc.Float32FromFloat32(0.5522847493)), cy-r, cx+r, cy-float32(r*libc.Float32FromFloat32(0.5522847493)), cx+r, cy) _nsvg__addPath(tls, p, uint8(1)) _nsvg__addShape(tls, p) } } func _nsvg__parseEllipse(tls *libc.TLS, p uintptr, attr uintptr) { var cx, cy, rx, ry float32 var i int32 _, _, _, _, _ = cx, cy, i, rx, ry cx = libc.Float32FromFloat32(0) cy = libc.Float32FromFloat32(0) rx = libc.Float32FromFloat32(0) ry = libc.Float32FromFloat32(0) i = 0 for { if !(*(*uintptr)(unsafe.Pointer(attr + uintptr(i)*8)) != 0) { break } if !(_nsvg__parseAttr(tls, p, *(*uintptr)(unsafe.Pointer(attr + uintptr(i)*8)), *(*uintptr)(unsafe.Pointer(attr + uintptr(i+int32(1))*8))) != 0) { if libc.Xstrcmp(tls, *(*uintptr)(unsafe.Pointer(attr + uintptr(i)*8)), __ccgo_ts+41716) == 0 { cx = _nsvg__parseCoordinate(tls, p, *(*uintptr)(unsafe.Pointer(attr + uintptr(i+int32(1))*8)), _nsvg__actualOrigX(tls, p), _nsvg__actualWidth(tls, p)) } if libc.Xstrcmp(tls, *(*uintptr)(unsafe.Pointer(attr + uintptr(i)*8)), __ccgo_ts+41719) == 0 { cy = _nsvg__parseCoordinate(tls, p, *(*uintptr)(unsafe.Pointer(attr + uintptr(i+int32(1))*8)), _nsvg__actualOrigY(tls, p), _nsvg__actualHeight(tls, p)) } if libc.Xstrcmp(tls, *(*uintptr)(unsafe.Pointer(attr + uintptr(i)*8)), __ccgo_ts+41710) == 0 { rx = libc.Xfabsf(tls, _nsvg__parseCoordinate(tls, p, *(*uintptr)(unsafe.Pointer(attr + uintptr(i+int32(1))*8)), libc.Float32FromFloat32(0), _nsvg__actualWidth(tls, p))) } if libc.Xstrcmp(tls, *(*uintptr)(unsafe.Pointer(attr + uintptr(i)*8)), __ccgo_ts+41713) == 0 { ry = libc.Xfabsf(tls, _nsvg__parseCoordinate(tls, p, *(*uintptr)(unsafe.Pointer(attr + uintptr(i+int32(1))*8)), libc.Float32FromFloat32(0), _nsvg__actualHeight(tls, p))) } } goto _1 _1: ; i += int32(2) } if rx > libc.Float32FromFloat32(0) && ry > libc.Float32FromFloat32(0) { _nsvg__resetPath(tls, p) _nsvg__moveTo(tls, p, cx+rx, cy) _nsvg__cubicBezTo(tls, p, cx+rx, cy+float32(ry*libc.Float32FromFloat32(0.5522847493)), cx+float32(rx*libc.Float32FromFloat32(0.5522847493)), cy+ry, cx, cy+ry) _nsvg__cubicBezTo(tls, p, cx-float32(rx*libc.Float32FromFloat32(0.5522847493)), cy+ry, cx-rx, cy+float32(ry*libc.Float32FromFloat32(0.5522847493)), cx-rx, cy) _nsvg__cubicBezTo(tls, p, cx-rx, cy-float32(ry*libc.Float32FromFloat32(0.5522847493)), cx-float32(rx*libc.Float32FromFloat32(0.5522847493)), cy-ry, cx, cy-ry) _nsvg__cubicBezTo(tls, p, cx+float32(rx*libc.Float32FromFloat32(0.5522847493)), cy-ry, cx+rx, cy-float32(ry*libc.Float32FromFloat32(0.5522847493)), cx+rx, cy) _nsvg__addPath(tls, p, uint8(1)) _nsvg__addShape(tls, p) } } func _nsvg__parseLine(tls *libc.TLS, p uintptr, attr uintptr) { var i int32 var x1, x2, y1, y2 float32 _, _, _, _, _ = i, x1, x2, y1, y2 x1 = float32(0) y1 = float32(0) x2 = float32(0) y2 = float32(0) i = 0 for { if !(*(*uintptr)(unsafe.Pointer(attr + uintptr(i)*8)) != 0) { break } if !(_nsvg__parseAttr(tls, p, *(*uintptr)(unsafe.Pointer(attr + uintptr(i)*8)), *(*uintptr)(unsafe.Pointer(attr + uintptr(i+int32(1))*8))) != 0) { if libc.Xstrcmp(tls, *(*uintptr)(unsafe.Pointer(attr + uintptr(i)*8)), __ccgo_ts+41722) == 0 { x1 = _nsvg__parseCoordinate(tls, p, *(*uintptr)(unsafe.Pointer(attr + uintptr(i+int32(1))*8)), _nsvg__actualOrigX(tls, p), _nsvg__actualWidth(tls, p)) } if libc.Xstrcmp(tls, *(*uintptr)(unsafe.Pointer(attr + uintptr(i)*8)), __ccgo_ts+41725) == 0 { y1 = _nsvg__parseCoordinate(tls, p, *(*uintptr)(unsafe.Pointer(attr + uintptr(i+int32(1))*8)), _nsvg__actualOrigY(tls, p), _nsvg__actualHeight(tls, p)) } if libc.Xstrcmp(tls, *(*uintptr)(unsafe.Pointer(attr + uintptr(i)*8)), __ccgo_ts+41728) == 0 { x2 = _nsvg__parseCoordinate(tls, p, *(*uintptr)(unsafe.Pointer(attr + uintptr(i+int32(1))*8)), _nsvg__actualOrigX(tls, p), _nsvg__actualWidth(tls, p)) } if libc.Xstrcmp(tls, *(*uintptr)(unsafe.Pointer(attr + uintptr(i)*8)), __ccgo_ts+41731) == 0 { y2 = _nsvg__parseCoordinate(tls, p, *(*uintptr)(unsafe.Pointer(attr + uintptr(i+int32(1))*8)), _nsvg__actualOrigY(tls, p), _nsvg__actualHeight(tls, p)) } } goto _1 _1: ; i += int32(2) } _nsvg__resetPath(tls, p) _nsvg__moveTo(tls, p, x1, y1) _nsvg__lineTo(tls, p, x2, y2) _nsvg__addPath(tls, p, uint8(0)) _nsvg__addShape(tls, p) } func _nsvg__parsePoly(tls *libc.TLS, p uintptr, attr uintptr, closeFlag int32) { bp := tls.Alloc(64) defer tls.Free(64) var args [2]float32 var i, nargs, npts, v2 int32 var s uintptr var _ /* item at bp+0 */ [64]uint8 _, _, _, _, _, _ = args, i, nargs, npts, s, v2 npts = 0 _nsvg__resetPath(tls, p) i = 0 for { if !(*(*uintptr)(unsafe.Pointer(attr + uintptr(i)*8)) != 0) { break } if !(_nsvg__parseAttr(tls, p, *(*uintptr)(unsafe.Pointer(attr + uintptr(i)*8)), *(*uintptr)(unsafe.Pointer(attr + uintptr(i+int32(1))*8))) != 0) { if libc.Xstrcmp(tls, *(*uintptr)(unsafe.Pointer(attr + uintptr(i)*8)), __ccgo_ts+41734) == 0 { s = *(*uintptr)(unsafe.Pointer(attr + uintptr(i+int32(1))*8)) nargs = 0 for *(*uint8)(unsafe.Pointer(s)) != 0 { s = _nsvg__getNextPathItem(tls, s, bp) v2 = nargs nargs++ args[v2] = float32(_nsvg__atof(tls, bp)) if nargs >= int32(2) { if npts == 0 { _nsvg__moveTo(tls, p, args[0], args[int32(1)]) } else { _nsvg__lineTo(tls, p, args[0], args[int32(1)]) } nargs = 0 npts++ } } } } goto _1 _1: ; i += int32(2) } _nsvg__addPath(tls, p, libc.Uint8FromInt32(closeFlag)) _nsvg__addShape(tls, p) } func _nsvg__parseSVG(tls *libc.TLS, p uintptr, attr uintptr) { bp := tls.Alloc(48) defer tls.Free(48) var i int32 _ = i i = 0 for { if !(*(*uintptr)(unsafe.Pointer(attr + uintptr(i)*8)) != 0) { break } if !(_nsvg__parseAttr(tls, p, *(*uintptr)(unsafe.Pointer(attr + uintptr(i)*8)), *(*uintptr)(unsafe.Pointer(attr + uintptr(i+int32(1))*8))) != 0) { if libc.Xstrcmp(tls, *(*uintptr)(unsafe.Pointer(attr + uintptr(i)*8)), __ccgo_ts+6446) == 0 { (*TNSVGimage)(unsafe.Pointer((*TNSVGparser)(unsafe.Pointer(p)).Fimage)).Fwidth = _nsvg__parseCoordinate(tls, p, *(*uintptr)(unsafe.Pointer(attr + uintptr(i+int32(1))*8)), libc.Float32FromFloat32(0), libc.Float32FromFloat32(0)) } else { if libc.Xstrcmp(tls, *(*uintptr)(unsafe.Pointer(attr + uintptr(i)*8)), __ccgo_ts+6172) == 0 { (*TNSVGimage)(unsafe.Pointer((*TNSVGparser)(unsafe.Pointer(p)).Fimage)).Fheight = _nsvg__parseCoordinate(tls, p, *(*uintptr)(unsafe.Pointer(attr + uintptr(i+int32(1))*8)), libc.Float32FromFloat32(0), libc.Float32FromFloat32(0)) } else { if libc.Xstrcmp(tls, *(*uintptr)(unsafe.Pointer(attr + uintptr(i)*8)), __ccgo_ts+41741) == 0 { libc.Xsscanf(tls, *(*uintptr)(unsafe.Pointer(attr + uintptr(i+int32(1))*8)), __ccgo_ts+41749, libc.VaList(bp+8, p+40000, p+40004, p+40008, p+40012)) } else { if libc.Xstrcmp(tls, *(*uintptr)(unsafe.Pointer(attr + uintptr(i)*8)), __ccgo_ts+41785) == 0 { if libc.Xstrstr(tls, *(*uintptr)(unsafe.Pointer(attr + uintptr(i+int32(1))*8)), __ccgo_ts+8223) != uintptr(0) { (*TNSVGparser)(unsafe.Pointer(p)).FalignType = NSVG_ALIGN_NONE } else { if libc.Xstrstr(tls, *(*uintptr)(unsafe.Pointer(attr + uintptr(i+int32(1))*8)), __ccgo_ts+41805) != uintptr(0) { (*TNSVGparser)(unsafe.Pointer(p)).FalignX = NSVG_ALIGN_MIN } else { if libc.Xstrstr(tls, *(*uintptr)(unsafe.Pointer(attr + uintptr(i+int32(1))*8)), __ccgo_ts+41810) != uintptr(0) { (*TNSVGparser)(unsafe.Pointer(p)).FalignX = int32(NSVG_ALIGN_MID) } else { if libc.Xstrstr(tls, *(*uintptr)(unsafe.Pointer(attr + uintptr(i+int32(1))*8)), __ccgo_ts+41815) != uintptr(0) { (*TNSVGparser)(unsafe.Pointer(p)).FalignX = int32(NSVG_ALIGN_MAX) } } } if libc.Xstrstr(tls, *(*uintptr)(unsafe.Pointer(attr + uintptr(i+int32(1))*8)), __ccgo_ts+41820) != uintptr(0) { (*TNSVGparser)(unsafe.Pointer(p)).FalignY = NSVG_ALIGN_MIN } else { if libc.Xstrstr(tls, *(*uintptr)(unsafe.Pointer(attr + uintptr(i+int32(1))*8)), __ccgo_ts+41825) != uintptr(0) { (*TNSVGparser)(unsafe.Pointer(p)).FalignY = int32(NSVG_ALIGN_MID) } else { if libc.Xstrstr(tls, *(*uintptr)(unsafe.Pointer(attr + uintptr(i+int32(1))*8)), __ccgo_ts+41830) != uintptr(0) { (*TNSVGparser)(unsafe.Pointer(p)).FalignY = int32(NSVG_ALIGN_MAX) } } } (*TNSVGparser)(unsafe.Pointer(p)).FalignType = int32(NSVG_ALIGN_MEET) if libc.Xstrstr(tls, *(*uintptr)(unsafe.Pointer(attr + uintptr(i+int32(1))*8)), __ccgo_ts+41835) != uintptr(0) { (*TNSVGparser)(unsafe.Pointer(p)).FalignType = int32(NSVG_ALIGN_SLICE) } } } } } } } goto _1 _1: ; i += int32(2) } } func _nsvg__parseGradient(tls *libc.TLS, p uintptr, attr uintptr, type1 int8) { var grad, href uintptr var i int32 _, _, _ = grad, href, i grad = libtcl9_0.XTcl_Alloc(tls, uint64(224)) if grad == libc.UintptrFromInt32(0) { return } libc.Xmemset(tls, grad, 0, uint64(224)) (*TNSVGgradientData)(unsafe.Pointer(grad)).Funits = uint8(NSVG_OBJECT_SPACE) (*TNSVGgradientData)(unsafe.Pointer(grad)).Ftype1 = type1 if int32((*TNSVGgradientData)(unsafe.Pointer(grad)).Ftype1) == int32(NSVG_PAINT_LINEAR_GRADIENT) { (*TNSVGgradientData)(unsafe.Pointer(grad)).F__ccgo3_132.Flinear.Fx1 = _nsvg__coord(tls, libc.Float32FromFloat32(0), int32(NSVG_UNITS_PERCENT)) (*TNSVGgradientData)(unsafe.Pointer(grad)).F__ccgo3_132.Flinear.Fy1 = _nsvg__coord(tls, libc.Float32FromFloat32(0), int32(NSVG_UNITS_PERCENT)) (*TNSVGgradientData)(unsafe.Pointer(grad)).F__ccgo3_132.Flinear.Fx2 = _nsvg__coord(tls, libc.Float32FromFloat32(100), int32(NSVG_UNITS_PERCENT)) (*TNSVGgradientData)(unsafe.Pointer(grad)).F__ccgo3_132.Flinear.Fy2 = _nsvg__coord(tls, libc.Float32FromFloat32(0), int32(NSVG_UNITS_PERCENT)) } else { if int32((*TNSVGgradientData)(unsafe.Pointer(grad)).Ftype1) == int32(NSVG_PAINT_RADIAL_GRADIENT) { (*(*TNSVGradialData)(unsafe.Add(unsafe.Pointer(grad), 132))).Fcx = _nsvg__coord(tls, libc.Float32FromFloat32(50), int32(NSVG_UNITS_PERCENT)) (*(*TNSVGradialData)(unsafe.Add(unsafe.Pointer(grad), 132))).Fcy = _nsvg__coord(tls, libc.Float32FromFloat32(50), int32(NSVG_UNITS_PERCENT)) (*(*TNSVGradialData)(unsafe.Add(unsafe.Pointer(grad), 132))).Fr = _nsvg__coord(tls, libc.Float32FromFloat32(50), int32(NSVG_UNITS_PERCENT)) } } _nsvg__xformIdentity(tls, grad+176) i = 0 for { if !(*(*uintptr)(unsafe.Pointer(attr + uintptr(i)*8)) != 0) { break } if libc.Xstrcmp(tls, *(*uintptr)(unsafe.Pointer(attr + uintptr(i)*8)), __ccgo_ts+6179) == 0 { libc.Xstrncpy(tls, grad, *(*uintptr)(unsafe.Pointer(attr + uintptr(i+int32(1))*8)), uint64(63)) *(*uint8)(unsafe.Pointer(grad + 63)) = uint8('\000') } else { if !(_nsvg__parseAttr(tls, p, *(*uintptr)(unsafe.Pointer(attr + uintptr(i)*8)), *(*uintptr)(unsafe.Pointer(attr + uintptr(i+int32(1))*8))) != 0) { if libc.Xstrcmp(tls, *(*uintptr)(unsafe.Pointer(attr + uintptr(i)*8)), __ccgo_ts+41841) == 0 { if libc.Xstrcmp(tls, *(*uintptr)(unsafe.Pointer(attr + uintptr(i+int32(1))*8)), __ccgo_ts+41855) == 0 { (*TNSVGgradientData)(unsafe.Pointer(grad)).Funits = uint8(NSVG_OBJECT_SPACE) } else { (*TNSVGgradientData)(unsafe.Pointer(grad)).Funits = uint8(NSVG_USER_SPACE) } } else { if libc.Xstrcmp(tls, *(*uintptr)(unsafe.Pointer(attr + uintptr(i)*8)), __ccgo_ts+41873) == 0 { _nsvg__parseTransform(tls, grad+176, *(*uintptr)(unsafe.Pointer(attr + uintptr(i+int32(1))*8))) } else { if libc.Xstrcmp(tls, *(*uintptr)(unsafe.Pointer(attr + uintptr(i)*8)), __ccgo_ts+41716) == 0 { (*(*TNSVGradialData)(unsafe.Add(unsafe.Pointer(grad), 132))).Fcx = _nsvg__parseCoordinateRaw(tls, *(*uintptr)(unsafe.Pointer(attr + uintptr(i+int32(1))*8))) } else { if libc.Xstrcmp(tls, *(*uintptr)(unsafe.Pointer(attr + uintptr(i)*8)), __ccgo_ts+41719) == 0 { (*(*TNSVGradialData)(unsafe.Add(unsafe.Pointer(grad), 132))).Fcy = _nsvg__parseCoordinateRaw(tls, *(*uintptr)(unsafe.Pointer(attr + uintptr(i+int32(1))*8))) } else { if libc.Xstrcmp(tls, *(*uintptr)(unsafe.Pointer(attr + uintptr(i)*8)), __ccgo_ts+9441) == 0 { (*(*TNSVGradialData)(unsafe.Add(unsafe.Pointer(grad), 132))).Fr = _nsvg__parseCoordinateRaw(tls, *(*uintptr)(unsafe.Pointer(attr + uintptr(i+int32(1))*8))) } else { if libc.Xstrcmp(tls, *(*uintptr)(unsafe.Pointer(attr + uintptr(i)*8)), __ccgo_ts+41891) == 0 { (*(*TNSVGradialData)(unsafe.Add(unsafe.Pointer(grad), 132))).Ffx = _nsvg__parseCoordinateRaw(tls, *(*uintptr)(unsafe.Pointer(attr + uintptr(i+int32(1))*8))) } else { if libc.Xstrcmp(tls, *(*uintptr)(unsafe.Pointer(attr + uintptr(i)*8)), __ccgo_ts+41894) == 0 { (*(*TNSVGradialData)(unsafe.Add(unsafe.Pointer(grad), 132))).Ffy = _nsvg__parseCoordinateRaw(tls, *(*uintptr)(unsafe.Pointer(attr + uintptr(i+int32(1))*8))) } else { if libc.Xstrcmp(tls, *(*uintptr)(unsafe.Pointer(attr + uintptr(i)*8)), __ccgo_ts+41722) == 0 { (*TNSVGgradientData)(unsafe.Pointer(grad)).F__ccgo3_132.Flinear.Fx1 = _nsvg__parseCoordinateRaw(tls, *(*uintptr)(unsafe.Pointer(attr + uintptr(i+int32(1))*8))) } else { if libc.Xstrcmp(tls, *(*uintptr)(unsafe.Pointer(attr + uintptr(i)*8)), __ccgo_ts+41725) == 0 { (*TNSVGgradientData)(unsafe.Pointer(grad)).F__ccgo3_132.Flinear.Fy1 = _nsvg__parseCoordinateRaw(tls, *(*uintptr)(unsafe.Pointer(attr + uintptr(i+int32(1))*8))) } else { if libc.Xstrcmp(tls, *(*uintptr)(unsafe.Pointer(attr + uintptr(i)*8)), __ccgo_ts+41728) == 0 { (*TNSVGgradientData)(unsafe.Pointer(grad)).F__ccgo3_132.Flinear.Fx2 = _nsvg__parseCoordinateRaw(tls, *(*uintptr)(unsafe.Pointer(attr + uintptr(i+int32(1))*8))) } else { if libc.Xstrcmp(tls, *(*uintptr)(unsafe.Pointer(attr + uintptr(i)*8)), __ccgo_ts+41731) == 0 { (*TNSVGgradientData)(unsafe.Pointer(grad)).F__ccgo3_132.Flinear.Fy2 = _nsvg__parseCoordinateRaw(tls, *(*uintptr)(unsafe.Pointer(attr + uintptr(i+int32(1))*8))) } else { if libc.Xstrcmp(tls, *(*uintptr)(unsafe.Pointer(attr + uintptr(i)*8)), __ccgo_ts+41897) == 0 { if libc.Xstrcmp(tls, *(*uintptr)(unsafe.Pointer(attr + uintptr(i+int32(1))*8)), __ccgo_ts+41910) == 0 { (*TNSVGgradientData)(unsafe.Pointer(grad)).Fspread = uint8(NSVG_SPREAD_PAD) } else { if libc.Xstrcmp(tls, *(*uintptr)(unsafe.Pointer(attr + uintptr(i+int32(1))*8)), __ccgo_ts+41914) == 0 { (*TNSVGgradientData)(unsafe.Pointer(grad)).Fspread = uint8(NSVG_SPREAD_REFLECT) } else { if libc.Xstrcmp(tls, *(*uintptr)(unsafe.Pointer(attr + uintptr(i+int32(1))*8)), __ccgo_ts+41922) == 0 { (*TNSVGgradientData)(unsafe.Pointer(grad)).Fspread = uint8(NSVG_SPREAD_REPEAT) } } } } else { if libc.Xstrcmp(tls, *(*uintptr)(unsafe.Pointer(attr + uintptr(i)*8)), __ccgo_ts+41929) == 0 { href = *(*uintptr)(unsafe.Pointer(attr + uintptr(i+int32(1))*8)) libc.Xstrncpy(tls, grad+64, href+uintptr(1), uint64(62)) *(*uint8)(unsafe.Pointer(grad + 64 + 62)) = uint8('\000') } } } } } } } } } } } } } } } goto _1 _1: ; i += int32(2) } (*TNSVGgradientData)(unsafe.Pointer(grad)).Fnext = (*TNSVGparser)(unsafe.Pointer(p)).Fgradients (*TNSVGparser)(unsafe.Pointer(p)).Fgradients = grad } func _nsvg__parseGradientStop(tls *libc.TLS, p uintptr, attr uintptr) { var curAttr, grad, stop uintptr var i, idx int32 _, _, _, _, _ = curAttr, grad, i, idx, stop curAttr = _nsvg__getAttr(tls, p) (*TNSVGattrib)(unsafe.Pointer(curAttr)).FstopOffset = libc.Float32FromInt32(0) (*TNSVGattrib)(unsafe.Pointer(curAttr)).FstopColor = uint32(0) (*TNSVGattrib)(unsafe.Pointer(curAttr)).FstopOpacity = libc.Float32FromFloat32(1) i = 0 for { if !(*(*uintptr)(unsafe.Pointer(attr + uintptr(i)*8)) != 0) { break } _nsvg__parseAttr(tls, p, *(*uintptr)(unsafe.Pointer(attr + uintptr(i)*8)), *(*uintptr)(unsafe.Pointer(attr + uintptr(i+int32(1))*8))) goto _1 _1: ; i += int32(2) } grad = (*TNSVGparser)(unsafe.Pointer(p)).Fgradients if grad == libc.UintptrFromInt32(0) { return } (*TNSVGgradientData)(unsafe.Pointer(grad)).Fnstops++ (*TNSVGgradientData)(unsafe.Pointer(grad)).Fstops = libtcl9_0.XTcl_Realloc(tls, (*TNSVGgradientData)(unsafe.Pointer(grad)).Fstops, uint64(8)*libc.Uint64FromInt32((*TNSVGgradientData)(unsafe.Pointer(grad)).Fnstops)) if (*TNSVGgradientData)(unsafe.Pointer(grad)).Fstops == libc.UintptrFromInt32(0) { return } idx = (*TNSVGgradientData)(unsafe.Pointer(grad)).Fnstops - int32(1) i = 0 for { if !(i < (*TNSVGgradientData)(unsafe.Pointer(grad)).Fnstops-int32(1)) { break } if (*TNSVGattrib)(unsafe.Pointer(curAttr)).FstopOffset < (*(*TNSVGgradientStop)(unsafe.Pointer((*TNSVGgradientData)(unsafe.Pointer(grad)).Fstops + uintptr(i)*8))).Foffset { idx = i break } goto _2 _2: ; i++ } if idx != (*TNSVGgradientData)(unsafe.Pointer(grad)).Fnstops-int32(1) { i = (*TNSVGgradientData)(unsafe.Pointer(grad)).Fnstops - int32(1) for { if !(i > idx) { break } *(*TNSVGgradientStop)(unsafe.Pointer((*TNSVGgradientData)(unsafe.Pointer(grad)).Fstops + uintptr(i)*8)) = *(*TNSVGgradientStop)(unsafe.Pointer((*TNSVGgradientData)(unsafe.Pointer(grad)).Fstops + uintptr(i-int32(1))*8)) goto _3 _3: ; i-- } } stop = (*TNSVGgradientData)(unsafe.Pointer(grad)).Fstops + uintptr(idx)*8 (*TNSVGgradientStop)(unsafe.Pointer(stop)).Fcolor = (*TNSVGattrib)(unsafe.Pointer(curAttr)).FstopColor *(*uint32)(unsafe.Pointer(stop)) |= uint32(float32((*TNSVGattrib)(unsafe.Pointer(curAttr)).FstopOpacity*libc.Float32FromInt32(255))) << int32(24) (*TNSVGgradientStop)(unsafe.Pointer(stop)).Foffset = (*TNSVGattrib)(unsafe.Pointer(curAttr)).FstopOffset } func _nsvg__startElement(tls *libc.TLS, ud uintptr, el uintptr, attr uintptr) { var p uintptr _ = p p = ud if (*TNSVGparser)(unsafe.Pointer(p)).FdefsFlag != 0 { if libc.Xstrcmp(tls, el, __ccgo_ts+41940) == 0 { _nsvg__parseGradient(tls, p, attr, int8(NSVG_PAINT_LINEAR_GRADIENT)) } else { if libc.Xstrcmp(tls, el, __ccgo_ts+41955) == 0 { _nsvg__parseGradient(tls, p, attr, int8(NSVG_PAINT_RADIAL_GRADIENT)) } else { if libc.Xstrcmp(tls, el, __ccgo_ts+41970) == 0 { _nsvg__parseGradientStop(tls, p, attr) } } } return } if libc.Xstrcmp(tls, el, __ccgo_ts+41975) == 0 { _nsvg__pushAttr(tls, p) _nsvg__parseAttribs(tls, p, attr) } else { if libc.Xstrcmp(tls, el, __ccgo_ts+41977) == 0 { if (*TNSVGparser)(unsafe.Pointer(p)).FpathFlag != 0 { return } _nsvg__pushAttr(tls, p) _nsvg__parsePath(tls, p, attr) _nsvg__popAttr(tls, p) } else { if libc.Xstrcmp(tls, el, __ccgo_ts+41982) == 0 { _nsvg__pushAttr(tls, p) _nsvg__parseRect(tls, p, attr) _nsvg__popAttr(tls, p) } else { if libc.Xstrcmp(tls, el, __ccgo_ts+41987) == 0 { _nsvg__pushAttr(tls, p) _nsvg__parseCircle(tls, p, attr) _nsvg__popAttr(tls, p) } else { if libc.Xstrcmp(tls, el, __ccgo_ts+41994) == 0 { _nsvg__pushAttr(tls, p) _nsvg__parseEllipse(tls, p, attr) _nsvg__popAttr(tls, p) } else { if libc.Xstrcmp(tls, el, __ccgo_ts+29673) == 0 { _nsvg__pushAttr(tls, p) _nsvg__parseLine(tls, p, attr) _nsvg__popAttr(tls, p) } else { if libc.Xstrcmp(tls, el, __ccgo_ts+42002) == 0 { _nsvg__pushAttr(tls, p) _nsvg__parsePoly(tls, p, attr, 0) _nsvg__popAttr(tls, p) } else { if libc.Xstrcmp(tls, el, __ccgo_ts+30195) == 0 { _nsvg__pushAttr(tls, p) _nsvg__parsePoly(tls, p, attr, int32(1)) _nsvg__popAttr(tls, p) } else { if libc.Xstrcmp(tls, el, __ccgo_ts+41940) == 0 { _nsvg__parseGradient(tls, p, attr, int8(NSVG_PAINT_LINEAR_GRADIENT)) } else { if libc.Xstrcmp(tls, el, __ccgo_ts+41955) == 0 { _nsvg__parseGradient(tls, p, attr, int8(NSVG_PAINT_RADIAL_GRADIENT)) } else { if libc.Xstrcmp(tls, el, __ccgo_ts+41970) == 0 { _nsvg__parseGradientStop(tls, p, attr) } else { if libc.Xstrcmp(tls, el, __ccgo_ts+42011) == 0 { (*TNSVGparser)(unsafe.Pointer(p)).FdefsFlag = uint8(1) } else { if libc.Xstrcmp(tls, el, __ccgo_ts+5607) == 0 { _nsvg__parseSVG(tls, p, attr) } else { if libc.Xstrcmp(tls, el, __ccgo_ts+16580) == 0 { (*TNSVGparser)(unsafe.Pointer(p)).FstyleFlag = uint8(1) } } } } } } } } } } } } } } } func _nsvg__endElement(tls *libc.TLS, ud uintptr, el uintptr) { var p uintptr _ = p p = ud if libc.Xstrcmp(tls, el, __ccgo_ts+41975) == 0 { _nsvg__popAttr(tls, p) } else { if libc.Xstrcmp(tls, el, __ccgo_ts+41977) == 0 { (*TNSVGparser)(unsafe.Pointer(p)).FpathFlag = uint8(0) } else { if libc.Xstrcmp(tls, el, __ccgo_ts+42011) == 0 { (*TNSVGparser)(unsafe.Pointer(p)).FdefsFlag = uint8(0) } else { if libc.Xstrcmp(tls, el, __ccgo_ts+16580) == 0 { (*TNSVGparser)(unsafe.Pointer(p)).FstyleFlag = uint8(0) } } } } } func _nsvg__strndup(tls *libc.TLS, s uintptr, n Tsize_t) (r uintptr) { var len1 Tsize_t var result uintptr _, _ = len1, result len1 = libc.Xstrlen(tls, s) if n < len1 { len1 = n } result = libtcl9_0.XTcl_Alloc(tls, len1+uint64(1)) if !(result != 0) { return uintptr(0) } *(*uint8)(unsafe.Pointer(result + uintptr(len1))) = uint8('\000') return libc.Xmemcpy(tls, result, s, len1) } func _nsvg__content(tls *libc.TLS, ud uintptr, s uintptr) { var c uint8 var next, p, start uintptr var state int32 _, _, _, _, _ = c, next, p, start, state p = ud if (*TNSVGparser)(unsafe.Pointer(p)).FstyleFlag != 0 { state = 0 start = libc.UintptrFromInt32(0) for *(*uint8)(unsafe.Pointer(s)) != 0 { c = *(*uint8)(unsafe.Pointer(s)) if _nsvg__isspace(tls, c) != 0 || libc.Int32FromUint8(c) == int32('{') { if state == int32(1) { next = (*TNSVGparser)(unsafe.Pointer(p)).Fstyles (*TNSVGparser)(unsafe.Pointer(p)).Fstyles = libtcl9_0.XTcl_Alloc(tls, uint64(24)) (*TNSVGstyles)(unsafe.Pointer((*TNSVGparser)(unsafe.Pointer(p)).Fstyles)).Fnext = next (*TNSVGstyles)(unsafe.Pointer((*TNSVGparser)(unsafe.Pointer(p)).Fstyles)).Fname = _nsvg__strndup(tls, start, libc.Uint64FromInt64(int64(s)-int64(start))) start = s + uintptr(1) state = int32(2) } } else { if state == int32(2) && libc.Int32FromUint8(c) == int32('}') { (*TNSVGstyles)(unsafe.Pointer((*TNSVGparser)(unsafe.Pointer(p)).Fstyles)).Fdescription = _nsvg__strndup(tls, start, libc.Uint64FromInt64(int64(s)-int64(start))) state = 0 } else { if state == 0 { start = s state = int32(1) } } } s++ } } } func _nsvg__imageBounds(tls *libc.TLS, p uintptr, bounds uintptr) { var shape uintptr var v1, v10, v11, v12, v14, v15, v16, v17, v19, v2, v20, v21, v22, v24, v3, v5, v6, v7, v9 float32 _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = shape, v1, v10, v11, v12, v14, v15, v16, v17, v19, v2, v20, v21, v22, v24, v3, v5, v6, v7, v9 shape = (*TNSVGimage)(unsafe.Pointer((*TNSVGparser)(unsafe.Pointer(p)).Fimage)).Fshapes if shape == libc.UintptrFromInt32(0) { v3 = libc.Float32FromFloat64(0) *(*float32)(unsafe.Pointer(bounds + 3*4)) = v3 v2 = v3 *(*float32)(unsafe.Pointer(bounds + 2*4)) = v2 v1 = v2 *(*float32)(unsafe.Pointer(bounds + 1*4)) = v1 *(*float32)(unsafe.Pointer(bounds)) = v1 return } *(*float32)(unsafe.Pointer(bounds)) = *(*float32)(unsafe.Pointer(shape + 152)) *(*float32)(unsafe.Pointer(bounds + 1*4)) = *(*float32)(unsafe.Pointer(shape + 152 + 1*4)) *(*float32)(unsafe.Pointer(bounds + 2*4)) = *(*float32)(unsafe.Pointer(shape + 152 + 2*4)) *(*float32)(unsafe.Pointer(bounds + 3*4)) = *(*float32)(unsafe.Pointer(shape + 152 + 3*4)) shape = (*TNSVGshape)(unsafe.Pointer(shape)).Fnext for { if !(shape != libc.UintptrFromInt32(0)) { break } v5 = *(*float32)(unsafe.Pointer(bounds)) v6 = *(*float32)(unsafe.Pointer(shape + 152)) if v5 < v6 { v9 = v5 } else { v9 = v6 } v7 = v9 goto _8 _8: *(*float32)(unsafe.Pointer(bounds)) = v7 v10 = *(*float32)(unsafe.Pointer(bounds + 1*4)) v11 = *(*float32)(unsafe.Pointer(shape + 152 + 1*4)) if v10 < v11 { v14 = v10 } else { v14 = v11 } v12 = v14 goto _13 _13: *(*float32)(unsafe.Pointer(bounds + 1*4)) = v12 v15 = *(*float32)(unsafe.Pointer(bounds + 2*4)) v16 = *(*float32)(unsafe.Pointer(shape + 152 + 2*4)) if v15 > v16 { v19 = v15 } else { v19 = v16 } v17 = v19 goto _18 _18: *(*float32)(unsafe.Pointer(bounds + 2*4)) = v17 v20 = *(*float32)(unsafe.Pointer(bounds + 3*4)) v21 = *(*float32)(unsafe.Pointer(shape + 152 + 3*4)) if v20 > v21 { v24 = v20 } else { v24 = v21 } v22 = v24 goto _23 _23: *(*float32)(unsafe.Pointer(bounds + 3*4)) = v22 goto _4 _4: ; shape = (*TNSVGshape)(unsafe.Pointer(shape)).Fnext } } func _nsvg__viewAlign(tls *libc.TLS, content float32, container float32, type1 int32) (r float32) { if type1 == NSVG_ALIGN_MIN { return libc.Float32FromInt32(0) } else { if type1 == int32(NSVG_ALIGN_MAX) { return container - content } } return float32((container - content) * libc.Float32FromFloat32(0.5)) } func _nsvg__scaleGradient(tls *libc.TLS, grad uintptr, tx float32, ty float32, sx float32, sy float32) { bp := tls.Alloc(32) defer tls.Free(32) var _ /* t at bp+0 */ [6]float32 _nsvg__xformSetTranslation(tls, bp, tx, ty) _nsvg__xformMultiply(tls, grad, bp) _nsvg__xformSetScale(tls, bp, sx, sy) _nsvg__xformMultiply(tls, grad, bp) } func _nsvg__scaleToViewbox(tls *libc.TLS, p uintptr, units uintptr) { bp := tls.Alloc(48) defer tls.Free(48) var avgs, sx, sy, tx, ty, us, v1, v10, v11, v12, v14, v2, v3, v4, v5, v6, v8, v9 float32 var i int32 var path, pt, shape uintptr var _ /* bounds at bp+0 */ [4]float32 var _ /* t at bp+16 */ [6]float32 _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = avgs, i, path, pt, shape, sx, sy, tx, ty, us, v1, v10, v11, v12, v14, v2, v3, v4, v5, v6, v8, v9 _nsvg__imageBounds(tls, p, bp) if (*TNSVGparser)(unsafe.Pointer(p)).FviewWidth == libc.Float32FromInt32(0) { if (*TNSVGimage)(unsafe.Pointer((*TNSVGparser)(unsafe.Pointer(p)).Fimage)).Fwidth > libc.Float32FromInt32(0) { (*TNSVGparser)(unsafe.Pointer(p)).FviewWidth = (*TNSVGimage)(unsafe.Pointer((*TNSVGparser)(unsafe.Pointer(p)).Fimage)).Fwidth } else { (*TNSVGparser)(unsafe.Pointer(p)).FviewMinx = (*(*[4]float32)(unsafe.Pointer(bp)))[0] (*TNSVGparser)(unsafe.Pointer(p)).FviewWidth = (*(*[4]float32)(unsafe.Pointer(bp)))[int32(2)] - (*(*[4]float32)(unsafe.Pointer(bp)))[0] } } if (*TNSVGparser)(unsafe.Pointer(p)).FviewHeight == libc.Float32FromInt32(0) { if (*TNSVGimage)(unsafe.Pointer((*TNSVGparser)(unsafe.Pointer(p)).Fimage)).Fheight > libc.Float32FromInt32(0) { (*TNSVGparser)(unsafe.Pointer(p)).FviewHeight = (*TNSVGimage)(unsafe.Pointer((*TNSVGparser)(unsafe.Pointer(p)).Fimage)).Fheight } else { (*TNSVGparser)(unsafe.Pointer(p)).FviewMiny = (*(*[4]float32)(unsafe.Pointer(bp)))[int32(1)] (*TNSVGparser)(unsafe.Pointer(p)).FviewHeight = (*(*[4]float32)(unsafe.Pointer(bp)))[int32(3)] - (*(*[4]float32)(unsafe.Pointer(bp)))[int32(1)] } } if (*TNSVGimage)(unsafe.Pointer((*TNSVGparser)(unsafe.Pointer(p)).Fimage)).Fwidth == libc.Float32FromInt32(0) { (*TNSVGimage)(unsafe.Pointer((*TNSVGparser)(unsafe.Pointer(p)).Fimage)).Fwidth = (*TNSVGparser)(unsafe.Pointer(p)).FviewWidth } if (*TNSVGimage)(unsafe.Pointer((*TNSVGparser)(unsafe.Pointer(p)).Fimage)).Fheight == libc.Float32FromInt32(0) { (*TNSVGimage)(unsafe.Pointer((*TNSVGparser)(unsafe.Pointer(p)).Fimage)).Fheight = (*TNSVGparser)(unsafe.Pointer(p)).FviewHeight } tx = -(*TNSVGparser)(unsafe.Pointer(p)).FviewMinx ty = -(*TNSVGparser)(unsafe.Pointer(p)).FviewMiny if (*TNSVGparser)(unsafe.Pointer(p)).FviewWidth > libc.Float32FromInt32(0) { v1 = (*TNSVGimage)(unsafe.Pointer((*TNSVGparser)(unsafe.Pointer(p)).Fimage)).Fwidth / (*TNSVGparser)(unsafe.Pointer(p)).FviewWidth } else { v1 = libc.Float32FromInt32(0) } sx = v1 if (*TNSVGparser)(unsafe.Pointer(p)).FviewHeight > libc.Float32FromInt32(0) { v2 = (*TNSVGimage)(unsafe.Pointer((*TNSVGparser)(unsafe.Pointer(p)).Fimage)).Fheight / (*TNSVGparser)(unsafe.Pointer(p)).FviewHeight } else { v2 = libc.Float32FromInt32(0) } sy = v2 us = libc.Float32FromFloat32(1) / _nsvg__convertToPixels(tls, p, _nsvg__coord(tls, libc.Float32FromFloat32(1), _nsvg__parseUnits(tls, units)), libc.Float32FromFloat32(0), libc.Float32FromFloat32(1)) if (*TNSVGparser)(unsafe.Pointer(p)).FalignType == int32(NSVG_ALIGN_MEET) { v4 = sx v5 = sy if v4 < v5 { v8 = v4 } else { v8 = v5 } v6 = v8 goto _7 _7: v3 = v6 sy = v3 sx = v3 tx += _nsvg__viewAlign(tls, float32((*TNSVGparser)(unsafe.Pointer(p)).FviewWidth*sx), (*TNSVGimage)(unsafe.Pointer((*TNSVGparser)(unsafe.Pointer(p)).Fimage)).Fwidth, (*TNSVGparser)(unsafe.Pointer(p)).FalignX) / sx ty += _nsvg__viewAlign(tls, float32((*TNSVGparser)(unsafe.Pointer(p)).FviewHeight*sy), (*TNSVGimage)(unsafe.Pointer((*TNSVGparser)(unsafe.Pointer(p)).Fimage)).Fheight, (*TNSVGparser)(unsafe.Pointer(p)).FalignY) / sy } else { if (*TNSVGparser)(unsafe.Pointer(p)).FalignType == int32(NSVG_ALIGN_SLICE) { v10 = sx v11 = sy if v10 > v11 { v14 = v10 } else { v14 = v11 } v12 = v14 goto _13 _13: v9 = v12 sy = v9 sx = v9 tx += _nsvg__viewAlign(tls, float32((*TNSVGparser)(unsafe.Pointer(p)).FviewWidth*sx), (*TNSVGimage)(unsafe.Pointer((*TNSVGparser)(unsafe.Pointer(p)).Fimage)).Fwidth, (*TNSVGparser)(unsafe.Pointer(p)).FalignX) / sx ty += _nsvg__viewAlign(tls, float32((*TNSVGparser)(unsafe.Pointer(p)).FviewHeight*sy), (*TNSVGimage)(unsafe.Pointer((*TNSVGparser)(unsafe.Pointer(p)).Fimage)).Fheight, (*TNSVGparser)(unsafe.Pointer(p)).FalignY) / sy } } sx *= us sy *= us avgs = (sx + sy) / libc.Float32FromFloat32(2) shape = (*TNSVGimage)(unsafe.Pointer((*TNSVGparser)(unsafe.Pointer(p)).Fimage)).Fshapes for { if !(shape != libc.UintptrFromInt32(0)) { break } *(*float32)(unsafe.Pointer(shape + 152)) = float32((*(*float32)(unsafe.Pointer(shape + 152)) + tx) * sx) *(*float32)(unsafe.Pointer(shape + 152 + 1*4)) = float32((*(*float32)(unsafe.Pointer(shape + 152 + 1*4)) + ty) * sy) *(*float32)(unsafe.Pointer(shape + 152 + 2*4)) = float32((*(*float32)(unsafe.Pointer(shape + 152 + 2*4)) + tx) * sx) *(*float32)(unsafe.Pointer(shape + 152 + 3*4)) = float32((*(*float32)(unsafe.Pointer(shape + 152 + 3*4)) + ty) * sy) path = (*TNSVGshape)(unsafe.Pointer(shape)).Fpaths for { if !(path != libc.UintptrFromInt32(0)) { break } *(*float32)(unsafe.Pointer(path + 16)) = float32((*(*float32)(unsafe.Pointer(path + 16)) + tx) * sx) *(*float32)(unsafe.Pointer(path + 16 + 1*4)) = float32((*(*float32)(unsafe.Pointer(path + 16 + 1*4)) + ty) * sy) *(*float32)(unsafe.Pointer(path + 16 + 2*4)) = float32((*(*float32)(unsafe.Pointer(path + 16 + 2*4)) + tx) * sx) *(*float32)(unsafe.Pointer(path + 16 + 3*4)) = float32((*(*float32)(unsafe.Pointer(path + 16 + 3*4)) + ty) * sy) i = 0 for { if !(i < (*TNSVGpath)(unsafe.Pointer(path)).Fnpts) { break } pt = (*TNSVGpath)(unsafe.Pointer(path)).Fpts + uintptr(i*int32(2))*4 *(*float32)(unsafe.Pointer(pt)) = float32((*(*float32)(unsafe.Pointer(pt)) + tx) * sx) *(*float32)(unsafe.Pointer(pt + 1*4)) = float32((*(*float32)(unsafe.Pointer(pt + 1*4)) + ty) * sy) goto _17 _17: ; i++ } goto _16 _16: ; path = (*TNSVGpath)(unsafe.Pointer(path)).Fnext } if int32((*TNSVGshape)(unsafe.Pointer(shape)).Ffill.Ftype1) == int32(NSVG_PAINT_LINEAR_GRADIENT) || int32((*TNSVGshape)(unsafe.Pointer(shape)).Ffill.Ftype1) == int32(NSVG_PAINT_RADIAL_GRADIENT) { _nsvg__scaleGradient(tls, *(*uintptr)(unsafe.Add(unsafe.Pointer(&(*TNSVGshape)(unsafe.Pointer(shape)).Ffill), 8)), tx, ty, sx, sy) libc.Xmemcpy(tls, bp+16, *(*uintptr)(unsafe.Add(unsafe.Pointer(&(*TNSVGshape)(unsafe.Pointer(shape)).Ffill), 8)), libc.Uint64FromInt64(4)*libc.Uint64FromInt32(6)) _nsvg__xformInverse(tls, *(*uintptr)(unsafe.Add(unsafe.Pointer(&(*TNSVGshape)(unsafe.Pointer(shape)).Ffill), 8)), bp+16) } if int32((*TNSVGshape)(unsafe.Pointer(shape)).Fstroke.Ftype1) == int32(NSVG_PAINT_LINEAR_GRADIENT) || int32((*TNSVGshape)(unsafe.Pointer(shape)).Fstroke.Ftype1) == int32(NSVG_PAINT_RADIAL_GRADIENT) { _nsvg__scaleGradient(tls, *(*uintptr)(unsafe.Add(unsafe.Pointer(&(*TNSVGshape)(unsafe.Pointer(shape)).Fstroke), 8)), tx, ty, sx, sy) libc.Xmemcpy(tls, bp+16, *(*uintptr)(unsafe.Add(unsafe.Pointer(&(*TNSVGshape)(unsafe.Pointer(shape)).Fstroke), 8)), libc.Uint64FromInt64(4)*libc.Uint64FromInt32(6)) _nsvg__xformInverse(tls, *(*uintptr)(unsafe.Add(unsafe.Pointer(&(*TNSVGshape)(unsafe.Pointer(shape)).Fstroke), 8)), bp+16) } *(*float32)(unsafe.Pointer(shape + 100)) *= avgs *(*float32)(unsafe.Pointer(shape + 104)) *= avgs i = 0 for { if !(i < libc.Int32FromUint8((*TNSVGshape)(unsafe.Pointer(shape)).FstrokeDashCount)) { break } *(*float32)(unsafe.Pointer(shape + 108 + uintptr(i)*4)) *= avgs goto _18 _18: ; i++ } goto _15 _15: ; shape = (*TNSVGshape)(unsafe.Pointer(shape)).Fnext } } func _nsvg__createGradients(tls *libc.TLS, p uintptr) { bp := tls.Alloc(80) defer tls.Free(80) var shape uintptr var _ /* inv at bp+0 */ [6]float32 var _ /* inv at bp+40 */ [6]float32 var _ /* localBounds at bp+24 */ [4]float32 var _ /* localBounds at bp+64 */ [4]float32 _ = shape shape = (*TNSVGimage)(unsafe.Pointer((*TNSVGparser)(unsafe.Pointer(p)).Fimage)).Fshapes for { if !(shape != libc.UintptrFromInt32(0)) { break } if int32((*TNSVGshape)(unsafe.Pointer(shape)).Ffill.Ftype1) == int32(NSVG_PAINT_UNDEF) { if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(shape + 168))) != int32('\000') { _nsvg__xformInverse(tls, bp, shape+296) _nsvg__getLocalBounds(tls, bp+24, shape, bp) *(*uintptr)(unsafe.Add(unsafe.Pointer(&(*TNSVGshape)(unsafe.Pointer(shape)).Ffill), 8)) = _nsvg__createGradient(tls, p, shape+168, bp+24, shape+296, shape+64) } if int32((*TNSVGshape)(unsafe.Pointer(shape)).Ffill.Ftype1) == int32(NSVG_PAINT_UNDEF) { (*TNSVGshape)(unsafe.Pointer(shape)).Ffill.Ftype1 = int8(NSVG_PAINT_NONE) } } if int32((*TNSVGshape)(unsafe.Pointer(shape)).Fstroke.Ftype1) == int32(NSVG_PAINT_UNDEF) { if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(shape + 232))) != int32('\000') { _nsvg__xformInverse(tls, bp+40, shape+296) _nsvg__getLocalBounds(tls, bp+64, shape, bp+40) *(*uintptr)(unsafe.Add(unsafe.Pointer(&(*TNSVGshape)(unsafe.Pointer(shape)).Fstroke), 8)) = _nsvg__createGradient(tls, p, shape+232, bp+64, shape+296, shape+80) } if int32((*TNSVGshape)(unsafe.Pointer(shape)).Fstroke.Ftype1) == int32(NSVG_PAINT_UNDEF) { (*TNSVGshape)(unsafe.Pointer(shape)).Fstroke.Ftype1 = int8(NSVG_PAINT_NONE) } } goto _1 _1: ; shape = (*TNSVGshape)(unsafe.Pointer(shape)).Fnext } } func XnsvgParse(tls *libc.TLS, input uintptr, units uintptr, dpi float32) (r uintptr) { var p, ret uintptr _, _ = p, ret ret = uintptr(0) p = _nsvg__createParser(tls) if p == libc.UintptrFromInt32(0) { return libc.UintptrFromInt32(0) } (*TNSVGparser)(unsafe.Pointer(p)).Fdpi = dpi Xnsvg__parseXML(tls, input, __ccgo_fp(_nsvg__startElement), __ccgo_fp(_nsvg__endElement), __ccgo_fp(_nsvg__content), p) _nsvg__createGradients(tls, p) _nsvg__scaleToViewbox(tls, p, units) ret = (*TNSVGparser)(unsafe.Pointer(p)).Fimage (*TNSVGparser)(unsafe.Pointer(p)).Fimage = libc.UintptrFromInt32(0) _nsvg__deleteParser(tls, p) return ret } func XnsvgParseFromFile(tls *libc.TLS, filename uintptr, units uintptr, dpi float32) (r uintptr) { var data, fp, image uintptr var size Tsize_t _, _, _, _ = data, fp, image, size fp = libc.UintptrFromInt32(0) data = libc.UintptrFromInt32(0) image = libc.UintptrFromInt32(0) fp = libc.Xfopen(tls, filename, __ccgo_ts+38643) if !(fp != 0) { goto error } libc.Xfseek(tls, fp, 0, int32(2)) size = libc.Uint64FromInt64(libc.Xftell(tls, fp)) libc.Xfseek(tls, fp, 0, 0) data = libtcl9_0.XTcl_Alloc(tls, size+uint64(1)) if data == libc.UintptrFromInt32(0) { goto error } if libc.Xfread(tls, data, uint64(1), size, fp) != size { goto error } *(*uint8)(unsafe.Pointer(data + uintptr(size))) = uint8('\000') libc.Xfclose(tls, fp) image = XnsvgParse(tls, data, units, dpi) libtcl9_0.XTcl_Free(tls, data) return image goto error error: ; if fp != 0 { libc.Xfclose(tls, fp) } if data != 0 { libtcl9_0.XTcl_Free(tls, data) } if image != 0 { XnsvgDelete(tls, image) } return libc.UintptrFromInt32(0) } func XnsvgDelete(tls *libc.TLS, image uintptr) { var shape, snext uintptr _, _ = shape, snext if image == libc.UintptrFromInt32(0) { return } shape = (*TNSVGimage)(unsafe.Pointer(image)).Fshapes for shape != libc.UintptrFromInt32(0) { snext = (*TNSVGshape)(unsafe.Pointer(shape)).Fnext _nsvg__deletePaths(tls, (*TNSVGshape)(unsafe.Pointer(shape)).Fpaths) _nsvg__deletePaint(tls, shape+64) _nsvg__deletePaint(tls, shape+80) libtcl9_0.XTcl_Free(tls, shape) shape = snext } libtcl9_0.XTcl_Free(tls, image) } type TNSVGrasterizer = struct { Fpx float32 Fpy float32 FtessTol float32 FdistTol float32 Fedges uintptr Fnedges int32 Fcedges int32 Fpoints uintptr Fnpoints int32 Fcpoints int32 Fpoints2 uintptr Fnpoints2 int32 Fcpoints2 int32 Ffreelist uintptr Fpages uintptr Fcurpage uintptr Fscanline uintptr Fcscanline int32 Fbitmap uintptr Fwidth int32 Fheight int32 Fstride int32 } type TNSVGedge = struct { Fx0 float32 Fy0 float32 Fx1 float32 Fy1 float32 Fdir int32 Fnext uintptr } type TNSVGpoint = struct { Fx float32 Fy float32 Fdx float32 Fdy float32 Flen1 float32 Fdmx float32 Fdmy float32 Fflags uint8 } type TNSVGactiveEdge = struct { Fx int32 Fdx int32 Fey float32 Fdir int32 Fnext uintptr } type TNSVGmemPage = struct { Fmem [1024]uint8 Fsize int32 Fnext uintptr } type TNSVGcachedPaint = struct { Ftype1 int8 Fspread uint8 Fxform [6]float32 Fcolors [256]uint32 } type TNSVGrasterizer1 = struct { Fpx float32 Fpy float32 FtessTol float32 FdistTol float32 Fedges uintptr Fnedges int32 Fcedges int32 Fpoints uintptr Fnpoints int32 Fcpoints int32 Fpoints2 uintptr Fnpoints2 int32 Fcpoints2 int32 Ffreelist uintptr Fpages uintptr Fcurpage uintptr Fscanline uintptr Fcscanline int32 Fbitmap uintptr Fwidth int32 Fheight int32 Fstride int32 } func XnsvgCreateRasterizer(tls *libc.TLS) (r1 uintptr) { var r uintptr _ = r r = libtcl9_0.XTcl_Alloc(tls, uint64(128)) if r == libc.UintptrFromInt32(0) { goto error } libc.Xmemset(tls, r, 0, uint64(128)) (*TNSVGrasterizer)(unsafe.Pointer(r)).FtessTol = libc.Float32FromFloat32(0.25) (*TNSVGrasterizer)(unsafe.Pointer(r)).FdistTol = libc.Float32FromFloat32(0.01) return r goto error error: ; XnsvgDeleteRasterizer(tls, r) return libc.UintptrFromInt32(0) } func XnsvgDeleteRasterizer(tls *libc.TLS, r uintptr) { var next, p uintptr _, _ = next, p if r == libc.UintptrFromInt32(0) { return } p = (*TNSVGrasterizer)(unsafe.Pointer(r)).Fpages for p != libc.UintptrFromInt32(0) { next = (*TNSVGmemPage)(unsafe.Pointer(p)).Fnext libtcl9_0.XTcl_Free(tls, p) p = next } if (*TNSVGrasterizer)(unsafe.Pointer(r)).Fedges != 0 { libtcl9_0.XTcl_Free(tls, (*TNSVGrasterizer)(unsafe.Pointer(r)).Fedges) } if (*TNSVGrasterizer)(unsafe.Pointer(r)).Fpoints != 0 { libtcl9_0.XTcl_Free(tls, (*TNSVGrasterizer)(unsafe.Pointer(r)).Fpoints) } if (*TNSVGrasterizer)(unsafe.Pointer(r)).Fpoints2 != 0 { libtcl9_0.XTcl_Free(tls, (*TNSVGrasterizer)(unsafe.Pointer(r)).Fpoints2) } if (*TNSVGrasterizer)(unsafe.Pointer(r)).Fscanline != 0 { libtcl9_0.XTcl_Free(tls, (*TNSVGrasterizer)(unsafe.Pointer(r)).Fscanline) } libtcl9_0.XTcl_Free(tls, r) } func _nsvg__nextPage(tls *libc.TLS, r uintptr, cur uintptr) (r1 uintptr) { var newp uintptr _ = newp if cur != libc.UintptrFromInt32(0) && (*TNSVGmemPage)(unsafe.Pointer(cur)).Fnext != libc.UintptrFromInt32(0) { return (*TNSVGmemPage)(unsafe.Pointer(cur)).Fnext } newp = libtcl9_0.XTcl_Alloc(tls, uint64(1040)) if newp == libc.UintptrFromInt32(0) { return libc.UintptrFromInt32(0) } libc.Xmemset(tls, newp, 0, uint64(1040)) if cur != libc.UintptrFromInt32(0) { (*TNSVGmemPage)(unsafe.Pointer(cur)).Fnext = newp } else { (*TNSVGrasterizer)(unsafe.Pointer(r)).Fpages = newp } return newp } func _nsvg__resetPool(tls *libc.TLS, r uintptr) { var p uintptr _ = p p = (*TNSVGrasterizer)(unsafe.Pointer(r)).Fpages for p != libc.UintptrFromInt32(0) { (*TNSVGmemPage)(unsafe.Pointer(p)).Fsize = 0 p = (*TNSVGmemPage)(unsafe.Pointer(p)).Fnext } (*TNSVGrasterizer)(unsafe.Pointer(r)).Fcurpage = (*TNSVGrasterizer)(unsafe.Pointer(r)).Fpages } func _nsvg__alloc(tls *libc.TLS, r uintptr, size int32) (r1 uintptr) { var buf uintptr _ = buf if size > int32(NSVG__MEMPAGE_SIZE) { return libc.UintptrFromInt32(0) } if (*TNSVGrasterizer)(unsafe.Pointer(r)).Fcurpage == libc.UintptrFromInt32(0) || (*TNSVGmemPage)(unsafe.Pointer((*TNSVGrasterizer)(unsafe.Pointer(r)).Fcurpage)).Fsize+size > int32(NSVG__MEMPAGE_SIZE) { (*TNSVGrasterizer)(unsafe.Pointer(r)).Fcurpage = _nsvg__nextPage(tls, r, (*TNSVGrasterizer)(unsafe.Pointer(r)).Fcurpage) } buf = (*TNSVGrasterizer)(unsafe.Pointer(r)).Fcurpage + uintptr((*TNSVGmemPage)(unsafe.Pointer((*TNSVGrasterizer)(unsafe.Pointer(r)).Fcurpage)).Fsize) *(*int32)(unsafe.Pointer((*TNSVGrasterizer)(unsafe.Pointer(r)).Fcurpage + 1024)) += size return buf } func _nsvg__ptEquals(tls *libc.TLS, x1 float32, y1 float32, x2 float32, y2 float32, tol float32) (r int32) { var dx, dy float32 _, _ = dx, dy dx = x2 - x1 dy = y2 - y1 return libc.BoolInt32(float32(dx*dx)+float32(dy*dy) < float32(tol*tol)) } func _nsvg__addPathPoint(tls *libc.TLS, r uintptr, x float32, y float32, flags int32) { var pt uintptr var v1 int32 _, _ = pt, v1 if (*TNSVGrasterizer)(unsafe.Pointer(r)).Fnpoints > 0 { pt = (*TNSVGrasterizer)(unsafe.Pointer(r)).Fpoints + uintptr((*TNSVGrasterizer)(unsafe.Pointer(r)).Fnpoints-int32(1))*32 if _nsvg__ptEquals(tls, (*TNSVGpoint)(unsafe.Pointer(pt)).Fx, (*TNSVGpoint)(unsafe.Pointer(pt)).Fy, x, y, (*TNSVGrasterizer)(unsafe.Pointer(r)).FdistTol) != 0 { (*TNSVGpoint)(unsafe.Pointer(pt)).Fflags = libc.Uint8FromInt32(libc.Int32FromUint8((*TNSVGpoint)(unsafe.Pointer(pt)).Fflags) | flags) return } } if (*TNSVGrasterizer)(unsafe.Pointer(r)).Fnpoints+int32(1) > (*TNSVGrasterizer)(unsafe.Pointer(r)).Fcpoints { if (*TNSVGrasterizer)(unsafe.Pointer(r)).Fcpoints > 0 { v1 = (*TNSVGrasterizer)(unsafe.Pointer(r)).Fcpoints * int32(2) } else { v1 = int32(64) } (*TNSVGrasterizer)(unsafe.Pointer(r)).Fcpoints = v1 (*TNSVGrasterizer)(unsafe.Pointer(r)).Fpoints = libtcl9_0.XTcl_Realloc(tls, (*TNSVGrasterizer)(unsafe.Pointer(r)).Fpoints, uint64(32)*libc.Uint64FromInt32((*TNSVGrasterizer)(unsafe.Pointer(r)).Fcpoints)) if (*TNSVGrasterizer)(unsafe.Pointer(r)).Fpoints == libc.UintptrFromInt32(0) { return } } pt = (*TNSVGrasterizer)(unsafe.Pointer(r)).Fpoints + uintptr((*TNSVGrasterizer)(unsafe.Pointer(r)).Fnpoints)*32 (*TNSVGpoint)(unsafe.Pointer(pt)).Fx = x (*TNSVGpoint)(unsafe.Pointer(pt)).Fy = y (*TNSVGpoint)(unsafe.Pointer(pt)).Fflags = libc.Uint8FromInt32(flags) (*TNSVGrasterizer)(unsafe.Pointer(r)).Fnpoints++ } func _nsvg__appendPathPoint(tls *libc.TLS, r uintptr, pt TNSVGpoint) { var v1 int32 _ = v1 if (*TNSVGrasterizer)(unsafe.Pointer(r)).Fnpoints+int32(1) > (*TNSVGrasterizer)(unsafe.Pointer(r)).Fcpoints { if (*TNSVGrasterizer)(unsafe.Pointer(r)).Fcpoints > 0 { v1 = (*TNSVGrasterizer)(unsafe.Pointer(r)).Fcpoints * int32(2) } else { v1 = int32(64) } (*TNSVGrasterizer)(unsafe.Pointer(r)).Fcpoints = v1 (*TNSVGrasterizer)(unsafe.Pointer(r)).Fpoints = libtcl9_0.XTcl_Realloc(tls, (*TNSVGrasterizer)(unsafe.Pointer(r)).Fpoints, uint64(32)*libc.Uint64FromInt32((*TNSVGrasterizer)(unsafe.Pointer(r)).Fcpoints)) if (*TNSVGrasterizer)(unsafe.Pointer(r)).Fpoints == libc.UintptrFromInt32(0) { return } } *(*TNSVGpoint)(unsafe.Pointer((*TNSVGrasterizer)(unsafe.Pointer(r)).Fpoints + uintptr((*TNSVGrasterizer)(unsafe.Pointer(r)).Fnpoints)*32)) = pt (*TNSVGrasterizer)(unsafe.Pointer(r)).Fnpoints++ } func _nsvg__duplicatePoints(tls *libc.TLS, r uintptr) { if (*TNSVGrasterizer)(unsafe.Pointer(r)).Fnpoints > (*TNSVGrasterizer)(unsafe.Pointer(r)).Fcpoints2 { (*TNSVGrasterizer)(unsafe.Pointer(r)).Fcpoints2 = (*TNSVGrasterizer)(unsafe.Pointer(r)).Fnpoints (*TNSVGrasterizer)(unsafe.Pointer(r)).Fpoints2 = libtcl9_0.XTcl_Realloc(tls, (*TNSVGrasterizer)(unsafe.Pointer(r)).Fpoints2, uint64(32)*libc.Uint64FromInt32((*TNSVGrasterizer)(unsafe.Pointer(r)).Fcpoints2)) if (*TNSVGrasterizer)(unsafe.Pointer(r)).Fpoints2 == libc.UintptrFromInt32(0) { return } } libc.Xmemcpy(tls, (*TNSVGrasterizer)(unsafe.Pointer(r)).Fpoints2, (*TNSVGrasterizer)(unsafe.Pointer(r)).Fpoints, uint64(32)*libc.Uint64FromInt32((*TNSVGrasterizer)(unsafe.Pointer(r)).Fnpoints)) (*TNSVGrasterizer)(unsafe.Pointer(r)).Fnpoints2 = (*TNSVGrasterizer)(unsafe.Pointer(r)).Fnpoints } func _nsvg__addEdge(tls *libc.TLS, r uintptr, x0 float32, y0 float32, x1 float32, y1 float32) { var e uintptr var v1 int32 _, _ = e, v1 if y0 == y1 { return } if (*TNSVGrasterizer)(unsafe.Pointer(r)).Fnedges+int32(1) > (*TNSVGrasterizer)(unsafe.Pointer(r)).Fcedges { if (*TNSVGrasterizer)(unsafe.Pointer(r)).Fcedges > 0 { v1 = (*TNSVGrasterizer)(unsafe.Pointer(r)).Fcedges * int32(2) } else { v1 = int32(64) } (*TNSVGrasterizer)(unsafe.Pointer(r)).Fcedges = v1 (*TNSVGrasterizer)(unsafe.Pointer(r)).Fedges = libtcl9_0.XTcl_Realloc(tls, (*TNSVGrasterizer)(unsafe.Pointer(r)).Fedges, uint64(32)*libc.Uint64FromInt32((*TNSVGrasterizer)(unsafe.Pointer(r)).Fcedges)) if (*TNSVGrasterizer)(unsafe.Pointer(r)).Fedges == libc.UintptrFromInt32(0) { return } } e = (*TNSVGrasterizer)(unsafe.Pointer(r)).Fedges + uintptr((*TNSVGrasterizer)(unsafe.Pointer(r)).Fnedges)*32 (*TNSVGrasterizer)(unsafe.Pointer(r)).Fnedges++ if y0 < y1 { (*TNSVGedge)(unsafe.Pointer(e)).Fx0 = x0 (*TNSVGedge)(unsafe.Pointer(e)).Fy0 = y0 (*TNSVGedge)(unsafe.Pointer(e)).Fx1 = x1 (*TNSVGedge)(unsafe.Pointer(e)).Fy1 = y1 (*TNSVGedge)(unsafe.Pointer(e)).Fdir = int32(1) } else { (*TNSVGedge)(unsafe.Pointer(e)).Fx0 = x1 (*TNSVGedge)(unsafe.Pointer(e)).Fy0 = y1 (*TNSVGedge)(unsafe.Pointer(e)).Fx1 = x0 (*TNSVGedge)(unsafe.Pointer(e)).Fy1 = y0 (*TNSVGedge)(unsafe.Pointer(e)).Fdir = -int32(1) } } func _nsvg__normalize(tls *libc.TLS, x uintptr, y uintptr) (r float32) { var d, id float32 _, _ = d, id d = libc.Xsqrtf(tls, float32(*(*float32)(unsafe.Pointer(x))**(*float32)(unsafe.Pointer(x)))+float32(*(*float32)(unsafe.Pointer(y))**(*float32)(unsafe.Pointer(y)))) if d > libc.Float32FromFloat32(1e-06) { id = libc.Float32FromFloat32(1) / d *(*float32)(unsafe.Pointer(x)) *= id *(*float32)(unsafe.Pointer(y)) *= id } return d } func _nsvg__absf(tls *libc.TLS, x float32) (r float32) { var v1 float32 _ = v1 if x < libc.Float32FromInt32(0) { v1 = -x } else { v1 = x } return v1 } func _nsvg__roundf(tls *libc.TLS, x float32) (r float32) { var v1 float32 _ = v1 if x >= libc.Float32FromInt32(0) { v1 = libc.Xfloorf(tls, float32(float64(x)+float64(0.5))) } else { v1 = libc.Xceilf(tls, float32(float64(x)-float64(0.5))) } return v1 } func _nsvg__flattenCubicBez(tls *libc.TLS, r uintptr, x1 float32, y1 float32, x2 float32, y2 float32, x3 float32, y3 float32, x4 float32, y4 float32, level int32, type1 int32) { var d2, d3, dx, dy, x12, x123, x1234, x23, x234, x34, y12, y123, y1234, y23, y234, y34 float32 _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = d2, d3, dx, dy, x12, x123, x1234, x23, x234, x34, y12, y123, y1234, y23, y234, y34 if level > int32(10) { return } x12 = float32((x1 + x2) * libc.Float32FromFloat32(0.5)) y12 = float32((y1 + y2) * libc.Float32FromFloat32(0.5)) x23 = float32((x2 + x3) * libc.Float32FromFloat32(0.5)) y23 = float32((y2 + y3) * libc.Float32FromFloat32(0.5)) x34 = float32((x3 + x4) * libc.Float32FromFloat32(0.5)) y34 = float32((y3 + y4) * libc.Float32FromFloat32(0.5)) x123 = float32((x12 + x23) * libc.Float32FromFloat32(0.5)) y123 = float32((y12 + y23) * libc.Float32FromFloat32(0.5)) dx = x4 - x1 dy = y4 - y1 d2 = _nsvg__absf(tls, float32((x2-x4)*dy)-float32((y2-y4)*dx)) d3 = _nsvg__absf(tls, float32((x3-x4)*dy)-float32((y3-y4)*dx)) if float32((d2+d3)*(d2+d3)) < float32((*TNSVGrasterizer)(unsafe.Pointer(r)).FtessTol*(float32(dx*dx)+float32(dy*dy))) { _nsvg__addPathPoint(tls, r, x4, y4, type1) return } x234 = float32((x23 + x34) * libc.Float32FromFloat32(0.5)) y234 = float32((y23 + y34) * libc.Float32FromFloat32(0.5)) x1234 = float32((x123 + x234) * libc.Float32FromFloat32(0.5)) y1234 = float32((y123 + y234) * libc.Float32FromFloat32(0.5)) _nsvg__flattenCubicBez(tls, r, x1, y1, x12, y12, x123, y123, x1234, y1234, level+int32(1), 0) _nsvg__flattenCubicBez(tls, r, x1234, y1234, x234, y234, x34, y34, x4, y4, level+int32(1), type1) } func _nsvg__flattenShape(tls *libc.TLS, r uintptr, shape uintptr, scale float32) { var i, j, v4 int32 var p, path uintptr _, _, _, _, _ = i, j, p, path, v4 path = (*TNSVGshape)(unsafe.Pointer(shape)).Fpaths for { if !(path != libc.UintptrFromInt32(0)) { break } (*TNSVGrasterizer)(unsafe.Pointer(r)).Fnpoints = 0 _nsvg__addPathPoint(tls, r, float32(*(*float32)(unsafe.Pointer((*TNSVGpath)(unsafe.Pointer(path)).Fpts))*scale), float32(*(*float32)(unsafe.Pointer((*TNSVGpath)(unsafe.Pointer(path)).Fpts + 1*4))*scale), 0) i = 0 for { if !(i < (*TNSVGpath)(unsafe.Pointer(path)).Fnpts-int32(1)) { break } p = (*TNSVGpath)(unsafe.Pointer(path)).Fpts + uintptr(i*int32(2))*4 _nsvg__flattenCubicBez(tls, r, float32(*(*float32)(unsafe.Pointer(p))*scale), float32(*(*float32)(unsafe.Pointer(p + 1*4))*scale), float32(*(*float32)(unsafe.Pointer(p + 2*4))*scale), float32(*(*float32)(unsafe.Pointer(p + 3*4))*scale), float32(*(*float32)(unsafe.Pointer(p + 4*4))*scale), float32(*(*float32)(unsafe.Pointer(p + 5*4))*scale), float32(*(*float32)(unsafe.Pointer(p + 6*4))*scale), float32(*(*float32)(unsafe.Pointer(p + 7*4))*scale), 0, 0) goto _2 _2: ; i += int32(3) } _nsvg__addPathPoint(tls, r, float32(*(*float32)(unsafe.Pointer((*TNSVGpath)(unsafe.Pointer(path)).Fpts))*scale), float32(*(*float32)(unsafe.Pointer((*TNSVGpath)(unsafe.Pointer(path)).Fpts + 1*4))*scale), 0) i = 0 j = (*TNSVGrasterizer)(unsafe.Pointer(r)).Fnpoints - libc.Int32FromInt32(1) for { if !(i < (*TNSVGrasterizer)(unsafe.Pointer(r)).Fnpoints) { break } _nsvg__addEdge(tls, r, (*(*TNSVGpoint)(unsafe.Pointer((*TNSVGrasterizer)(unsafe.Pointer(r)).Fpoints + uintptr(j)*32))).Fx, (*(*TNSVGpoint)(unsafe.Pointer((*TNSVGrasterizer)(unsafe.Pointer(r)).Fpoints + uintptr(j)*32))).Fy, (*(*TNSVGpoint)(unsafe.Pointer((*TNSVGrasterizer)(unsafe.Pointer(r)).Fpoints + uintptr(i)*32))).Fx, (*(*TNSVGpoint)(unsafe.Pointer((*TNSVGrasterizer)(unsafe.Pointer(r)).Fpoints + uintptr(i)*32))).Fy) goto _3 _3: ; v4 = i i++ j = v4 } goto _1 _1: ; path = (*TNSVGpath)(unsafe.Pointer(path)).Fnext } } type NSVGpointFlags = int32 const NSVG_PT_CORNER = 1 const NSVG_PT_BEVEL = 2 const NSVG_PT_LEFT = 4 func _nsvg__initClosed(tls *libc.TLS, left uintptr, right uintptr, p0 uintptr, p1 uintptr, lineWidth float32) { bp := tls.Alloc(16) defer tls.Free(16) var dlx, dly, len1, lx, ly, px, py, rx, ry, w float32 var _ /* dx at bp+0 */ float32 var _ /* dy at bp+4 */ float32 _, _, _, _, _, _, _, _, _, _ = dlx, dly, len1, lx, ly, px, py, rx, ry, w w = float32(lineWidth * libc.Float32FromFloat32(0.5)) *(*float32)(unsafe.Pointer(bp)) = (*TNSVGpoint)(unsafe.Pointer(p1)).Fx - (*TNSVGpoint)(unsafe.Pointer(p0)).Fx *(*float32)(unsafe.Pointer(bp + 4)) = (*TNSVGpoint)(unsafe.Pointer(p1)).Fy - (*TNSVGpoint)(unsafe.Pointer(p0)).Fy len1 = _nsvg__normalize(tls, bp, bp+4) px = (*TNSVGpoint)(unsafe.Pointer(p0)).Fx + float32(float32(*(*float32)(unsafe.Pointer(bp))*len1)*libc.Float32FromFloat32(0.5)) py = (*TNSVGpoint)(unsafe.Pointer(p0)).Fy + float32(float32(*(*float32)(unsafe.Pointer(bp + 4))*len1)*libc.Float32FromFloat32(0.5)) dlx = *(*float32)(unsafe.Pointer(bp + 4)) dly = -*(*float32)(unsafe.Pointer(bp)) lx = px - float32(dlx*w) ly = py - float32(dly*w) rx = px + float32(dlx*w) ry = py + float32(dly*w) (*TNSVGpoint)(unsafe.Pointer(left)).Fx = lx (*TNSVGpoint)(unsafe.Pointer(left)).Fy = ly (*TNSVGpoint)(unsafe.Pointer(right)).Fx = rx (*TNSVGpoint)(unsafe.Pointer(right)).Fy = ry } func _nsvg__buttCap(tls *libc.TLS, r uintptr, left uintptr, right uintptr, p uintptr, dx float32, dy float32, lineWidth float32, connect int32) { var dlx, dly, lx, ly, px, py, rx, ry, w float32 _, _, _, _, _, _, _, _, _ = dlx, dly, lx, ly, px, py, rx, ry, w w = float32(lineWidth * libc.Float32FromFloat32(0.5)) px = (*TNSVGpoint)(unsafe.Pointer(p)).Fx py = (*TNSVGpoint)(unsafe.Pointer(p)).Fy dlx = dy dly = -dx lx = px - float32(dlx*w) ly = py - float32(dly*w) rx = px + float32(dlx*w) ry = py + float32(dly*w) _nsvg__addEdge(tls, r, lx, ly, rx, ry) if connect != 0 { _nsvg__addEdge(tls, r, (*TNSVGpoint)(unsafe.Pointer(left)).Fx, (*TNSVGpoint)(unsafe.Pointer(left)).Fy, lx, ly) _nsvg__addEdge(tls, r, rx, ry, (*TNSVGpoint)(unsafe.Pointer(right)).Fx, (*TNSVGpoint)(unsafe.Pointer(right)).Fy) } (*TNSVGpoint)(unsafe.Pointer(left)).Fx = lx (*TNSVGpoint)(unsafe.Pointer(left)).Fy = ly (*TNSVGpoint)(unsafe.Pointer(right)).Fx = rx (*TNSVGpoint)(unsafe.Pointer(right)).Fy = ry } func _nsvg__squareCap(tls *libc.TLS, r uintptr, left uintptr, right uintptr, p uintptr, dx float32, dy float32, lineWidth float32, connect int32) { var dlx, dly, lx, ly, px, py, rx, ry, w float32 _, _, _, _, _, _, _, _, _ = dlx, dly, lx, ly, px, py, rx, ry, w w = float32(lineWidth * libc.Float32FromFloat32(0.5)) px = (*TNSVGpoint)(unsafe.Pointer(p)).Fx - float32(dx*w) py = (*TNSVGpoint)(unsafe.Pointer(p)).Fy - float32(dy*w) dlx = dy dly = -dx lx = px - float32(dlx*w) ly = py - float32(dly*w) rx = px + float32(dlx*w) ry = py + float32(dly*w) _nsvg__addEdge(tls, r, lx, ly, rx, ry) if connect != 0 { _nsvg__addEdge(tls, r, (*TNSVGpoint)(unsafe.Pointer(left)).Fx, (*TNSVGpoint)(unsafe.Pointer(left)).Fy, lx, ly) _nsvg__addEdge(tls, r, rx, ry, (*TNSVGpoint)(unsafe.Pointer(right)).Fx, (*TNSVGpoint)(unsafe.Pointer(right)).Fy) } (*TNSVGpoint)(unsafe.Pointer(left)).Fx = lx (*TNSVGpoint)(unsafe.Pointer(left)).Fy = ly (*TNSVGpoint)(unsafe.Pointer(right)).Fx = rx (*TNSVGpoint)(unsafe.Pointer(right)).Fy = ry } func _nsvg__roundCap(tls *libc.TLS, r uintptr, left uintptr, right uintptr, p uintptr, dx float32, dy float32, lineWidth float32, ncap int32, connect int32) { var a, ax, ay, dlx, dly, lx, ly, prevx, prevy, px, py, rx, ry, w, x, y float32 var i int32 _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = a, ax, ay, dlx, dly, i, lx, ly, prevx, prevy, px, py, rx, ry, w, x, y w = float32(lineWidth * libc.Float32FromFloat32(0.5)) px = (*TNSVGpoint)(unsafe.Pointer(p)).Fx py = (*TNSVGpoint)(unsafe.Pointer(p)).Fy dlx = dy dly = -dx lx = libc.Float32FromInt32(0) ly = libc.Float32FromInt32(0) rx = libc.Float32FromInt32(0) ry = libc.Float32FromInt32(0) prevx = libc.Float32FromInt32(0) prevy = libc.Float32FromInt32(0) i = 0 for { if !(i < ncap) { break } a = float32(float32(i) / float32(ncap-libc.Int32FromInt32(1)) * libc.Float32FromFloat32(3.141592653589793)) ax = float32(libc.Xcosf(tls, a) * w) ay = float32(libc.Xsinf(tls, a) * w) x = px - float32(dlx*ax) - float32(dx*ay) y = py - float32(dly*ax) - float32(dy*ay) if i > 0 { _nsvg__addEdge(tls, r, prevx, prevy, x, y) } prevx = x prevy = y if i == 0 { lx = x ly = y } else { if i == ncap-int32(1) { rx = x ry = y } } goto _1 _1: ; i++ } if connect != 0 { _nsvg__addEdge(tls, r, (*TNSVGpoint)(unsafe.Pointer(left)).Fx, (*TNSVGpoint)(unsafe.Pointer(left)).Fy, lx, ly) _nsvg__addEdge(tls, r, rx, ry, (*TNSVGpoint)(unsafe.Pointer(right)).Fx, (*TNSVGpoint)(unsafe.Pointer(right)).Fy) } (*TNSVGpoint)(unsafe.Pointer(left)).Fx = lx (*TNSVGpoint)(unsafe.Pointer(left)).Fy = ly (*TNSVGpoint)(unsafe.Pointer(right)).Fx = rx (*TNSVGpoint)(unsafe.Pointer(right)).Fy = ry } func _nsvg__bevelJoin(tls *libc.TLS, r uintptr, left uintptr, right uintptr, p0 uintptr, p1 uintptr, lineWidth float32) { var dlx0, dlx1, dly0, dly1, lx0, lx1, ly0, ly1, rx0, rx1, ry0, ry1, w float32 _, _, _, _, _, _, _, _, _, _, _, _, _ = dlx0, dlx1, dly0, dly1, lx0, lx1, ly0, ly1, rx0, rx1, ry0, ry1, w w = float32(lineWidth * libc.Float32FromFloat32(0.5)) dlx0 = (*TNSVGpoint)(unsafe.Pointer(p0)).Fdy dly0 = -(*TNSVGpoint)(unsafe.Pointer(p0)).Fdx dlx1 = (*TNSVGpoint)(unsafe.Pointer(p1)).Fdy dly1 = -(*TNSVGpoint)(unsafe.Pointer(p1)).Fdx lx0 = (*TNSVGpoint)(unsafe.Pointer(p1)).Fx - float32(dlx0*w) ly0 = (*TNSVGpoint)(unsafe.Pointer(p1)).Fy - float32(dly0*w) rx0 = (*TNSVGpoint)(unsafe.Pointer(p1)).Fx + float32(dlx0*w) ry0 = (*TNSVGpoint)(unsafe.Pointer(p1)).Fy + float32(dly0*w) lx1 = (*TNSVGpoint)(unsafe.Pointer(p1)).Fx - float32(dlx1*w) ly1 = (*TNSVGpoint)(unsafe.Pointer(p1)).Fy - float32(dly1*w) rx1 = (*TNSVGpoint)(unsafe.Pointer(p1)).Fx + float32(dlx1*w) ry1 = (*TNSVGpoint)(unsafe.Pointer(p1)).Fy + float32(dly1*w) _nsvg__addEdge(tls, r, lx0, ly0, (*TNSVGpoint)(unsafe.Pointer(left)).Fx, (*TNSVGpoint)(unsafe.Pointer(left)).Fy) _nsvg__addEdge(tls, r, lx1, ly1, lx0, ly0) _nsvg__addEdge(tls, r, (*TNSVGpoint)(unsafe.Pointer(right)).Fx, (*TNSVGpoint)(unsafe.Pointer(right)).Fy, rx0, ry0) _nsvg__addEdge(tls, r, rx0, ry0, rx1, ry1) (*TNSVGpoint)(unsafe.Pointer(left)).Fx = lx1 (*TNSVGpoint)(unsafe.Pointer(left)).Fy = ly1 (*TNSVGpoint)(unsafe.Pointer(right)).Fx = rx1 (*TNSVGpoint)(unsafe.Pointer(right)).Fy = ry1 } func _nsvg__miterJoin(tls *libc.TLS, r uintptr, left uintptr, right uintptr, p0 uintptr, p1 uintptr, lineWidth float32) { var dlx0, dlx1, dly0, dly1, lx0, lx1, ly0, ly1, rx0, rx1, ry0, ry1, w, v1, v2, v3, v4 float32 _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = dlx0, dlx1, dly0, dly1, lx0, lx1, ly0, ly1, rx0, rx1, ry0, ry1, w, v1, v2, v3, v4 w = float32(lineWidth * libc.Float32FromFloat32(0.5)) dlx0 = (*TNSVGpoint)(unsafe.Pointer(p0)).Fdy dly0 = -(*TNSVGpoint)(unsafe.Pointer(p0)).Fdx dlx1 = (*TNSVGpoint)(unsafe.Pointer(p1)).Fdy dly1 = -(*TNSVGpoint)(unsafe.Pointer(p1)).Fdx if libc.Int32FromUint8((*TNSVGpoint)(unsafe.Pointer(p1)).Fflags)&int32(NSVG_PT_LEFT) != 0 { v1 = (*TNSVGpoint)(unsafe.Pointer(p1)).Fx - float32((*TNSVGpoint)(unsafe.Pointer(p1)).Fdmx*w) lx1 = v1 lx0 = v1 v2 = (*TNSVGpoint)(unsafe.Pointer(p1)).Fy - float32((*TNSVGpoint)(unsafe.Pointer(p1)).Fdmy*w) ly1 = v2 ly0 = v2 _nsvg__addEdge(tls, r, lx1, ly1, (*TNSVGpoint)(unsafe.Pointer(left)).Fx, (*TNSVGpoint)(unsafe.Pointer(left)).Fy) rx0 = (*TNSVGpoint)(unsafe.Pointer(p1)).Fx + float32(dlx0*w) ry0 = (*TNSVGpoint)(unsafe.Pointer(p1)).Fy + float32(dly0*w) rx1 = (*TNSVGpoint)(unsafe.Pointer(p1)).Fx + float32(dlx1*w) ry1 = (*TNSVGpoint)(unsafe.Pointer(p1)).Fy + float32(dly1*w) _nsvg__addEdge(tls, r, (*TNSVGpoint)(unsafe.Pointer(right)).Fx, (*TNSVGpoint)(unsafe.Pointer(right)).Fy, rx0, ry0) _nsvg__addEdge(tls, r, rx0, ry0, rx1, ry1) } else { lx0 = (*TNSVGpoint)(unsafe.Pointer(p1)).Fx - float32(dlx0*w) ly0 = (*TNSVGpoint)(unsafe.Pointer(p1)).Fy - float32(dly0*w) lx1 = (*TNSVGpoint)(unsafe.Pointer(p1)).Fx - float32(dlx1*w) ly1 = (*TNSVGpoint)(unsafe.Pointer(p1)).Fy - float32(dly1*w) _nsvg__addEdge(tls, r, lx0, ly0, (*TNSVGpoint)(unsafe.Pointer(left)).Fx, (*TNSVGpoint)(unsafe.Pointer(left)).Fy) _nsvg__addEdge(tls, r, lx1, ly1, lx0, ly0) v3 = (*TNSVGpoint)(unsafe.Pointer(p1)).Fx + float32((*TNSVGpoint)(unsafe.Pointer(p1)).Fdmx*w) rx1 = v3 rx0 = v3 v4 = (*TNSVGpoint)(unsafe.Pointer(p1)).Fy + float32((*TNSVGpoint)(unsafe.Pointer(p1)).Fdmy*w) ry1 = v4 ry0 = v4 _nsvg__addEdge(tls, r, (*TNSVGpoint)(unsafe.Pointer(right)).Fx, (*TNSVGpoint)(unsafe.Pointer(right)).Fy, rx1, ry1) } (*TNSVGpoint)(unsafe.Pointer(left)).Fx = lx1 (*TNSVGpoint)(unsafe.Pointer(left)).Fy = ly1 (*TNSVGpoint)(unsafe.Pointer(right)).Fx = rx1 (*TNSVGpoint)(unsafe.Pointer(right)).Fy = ry1 } func _nsvg__roundJoin(tls *libc.TLS, r uintptr, left uintptr, right uintptr, p0 uintptr, p1 uintptr, lineWidth float32, ncap int32) { var a, a0, a1, ax, ay, da, dlx0, dlx1, dly0, dly1, lx, lx1, ly, ly1, rx, rx1, ry, ry1, u, w float32 var i, n int32 _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = a, a0, a1, ax, ay, da, dlx0, dlx1, dly0, dly1, i, lx, lx1, ly, ly1, n, rx, rx1, ry, ry1, u, w w = float32(lineWidth * libc.Float32FromFloat32(0.5)) dlx0 = (*TNSVGpoint)(unsafe.Pointer(p0)).Fdy dly0 = -(*TNSVGpoint)(unsafe.Pointer(p0)).Fdx dlx1 = (*TNSVGpoint)(unsafe.Pointer(p1)).Fdy dly1 = -(*TNSVGpoint)(unsafe.Pointer(p1)).Fdx a0 = libc.Xatan2f(tls, dly0, dlx0) a1 = libc.Xatan2f(tls, dly1, dlx1) da = a1 - a0 if da < libc.Float32FromFloat32(3.141592653589793) { da += float32(libc.Float32FromFloat32(3.141592653589793) * libc.Float32FromInt32(2)) } if da > libc.Float32FromFloat32(3.141592653589793) { da -= float32(libc.Float32FromFloat32(3.141592653589793) * libc.Float32FromInt32(2)) } n = int32(libc.Xceilf(tls, float32(_nsvg__absf(tls, da)/libc.Float32FromFloat32(3.141592653589793)*float32(ncap)))) if n < int32(2) { n = int32(2) } if n > ncap { n = ncap } lx = (*TNSVGpoint)(unsafe.Pointer(left)).Fx ly = (*TNSVGpoint)(unsafe.Pointer(left)).Fy rx = (*TNSVGpoint)(unsafe.Pointer(right)).Fx ry = (*TNSVGpoint)(unsafe.Pointer(right)).Fy i = 0 for { if !(i < n) { break } u = float32(i) / float32(n-libc.Int32FromInt32(1)) a = a0 + float32(u*da) ax = float32(libc.Xcosf(tls, a) * w) ay = float32(libc.Xsinf(tls, a) * w) lx1 = (*TNSVGpoint)(unsafe.Pointer(p1)).Fx - ax ly1 = (*TNSVGpoint)(unsafe.Pointer(p1)).Fy - ay rx1 = (*TNSVGpoint)(unsafe.Pointer(p1)).Fx + ax ry1 = (*TNSVGpoint)(unsafe.Pointer(p1)).Fy + ay _nsvg__addEdge(tls, r, lx1, ly1, lx, ly) _nsvg__addEdge(tls, r, rx, ry, rx1, ry1) lx = lx1 ly = ly1 rx = rx1 ry = ry1 goto _1 _1: ; i++ } (*TNSVGpoint)(unsafe.Pointer(left)).Fx = lx (*TNSVGpoint)(unsafe.Pointer(left)).Fy = ly (*TNSVGpoint)(unsafe.Pointer(right)).Fx = rx (*TNSVGpoint)(unsafe.Pointer(right)).Fy = ry } func _nsvg__straightJoin(tls *libc.TLS, r uintptr, left uintptr, right uintptr, p1 uintptr, lineWidth float32) { var lx, ly, rx, ry, w float32 _, _, _, _, _ = lx, ly, rx, ry, w w = float32(lineWidth * libc.Float32FromFloat32(0.5)) lx = (*TNSVGpoint)(unsafe.Pointer(p1)).Fx - float32((*TNSVGpoint)(unsafe.Pointer(p1)).Fdmx*w) ly = (*TNSVGpoint)(unsafe.Pointer(p1)).Fy - float32((*TNSVGpoint)(unsafe.Pointer(p1)).Fdmy*w) rx = (*TNSVGpoint)(unsafe.Pointer(p1)).Fx + float32((*TNSVGpoint)(unsafe.Pointer(p1)).Fdmx*w) ry = (*TNSVGpoint)(unsafe.Pointer(p1)).Fy + float32((*TNSVGpoint)(unsafe.Pointer(p1)).Fdmy*w) _nsvg__addEdge(tls, r, lx, ly, (*TNSVGpoint)(unsafe.Pointer(left)).Fx, (*TNSVGpoint)(unsafe.Pointer(left)).Fy) _nsvg__addEdge(tls, r, (*TNSVGpoint)(unsafe.Pointer(right)).Fx, (*TNSVGpoint)(unsafe.Pointer(right)).Fy, rx, ry) (*TNSVGpoint)(unsafe.Pointer(left)).Fx = lx (*TNSVGpoint)(unsafe.Pointer(left)).Fy = ly (*TNSVGpoint)(unsafe.Pointer(right)).Fx = rx (*TNSVGpoint)(unsafe.Pointer(right)).Fy = ry } func _nsvg__curveDivs(tls *libc.TLS, r float32, arc float32, tol float32) (r1 int32) { var da float32 var divs int32 _, _ = da, divs da = float32(libc.Xacosf(tls, r/(r+tol)) * libc.Float32FromFloat32(2)) divs = int32(libc.Xceilf(tls, arc/da)) if divs < int32(2) { divs = int32(2) } return divs } func _nsvg__expandStroke(tls *libc.TLS, r uintptr, points uintptr, npoints int32, closed int32, lineJoin int32, lineCap int32, lineWidth float32) { bp := tls.Alloc(80) defer tls.Free(80) var e, j, ncap, s int32 var firstLeft, firstRight TNSVGpoint var p0, p1, v2 uintptr var _ /* dx at bp+64 */ float32 var _ /* dx at bp+72 */ float32 var _ /* dy at bp+68 */ float32 var _ /* dy at bp+76 */ float32 var _ /* left at bp+0 */ TNSVGpoint var _ /* right at bp+32 */ TNSVGpoint _, _, _, _, _, _, _, _, _ = e, firstLeft, firstRight, j, ncap, p0, p1, s, v2 ncap = _nsvg__curveDivs(tls, float32(lineWidth*libc.Float32FromFloat32(0.5)), libc.Float32FromFloat32(3.141592653589793), (*TNSVGrasterizer)(unsafe.Pointer(r)).FtessTol) *(*TNSVGpoint)(unsafe.Pointer(bp)) = TNSVGpoint{} *(*TNSVGpoint)(unsafe.Pointer(bp + 32)) = TNSVGpoint{} firstLeft = TNSVGpoint{} firstRight = TNSVGpoint{} if closed != 0 { p0 = points + uintptr(npoints-int32(1))*32 p1 = points s = 0 e = npoints } else { p0 = points p1 = points + 1*32 s = int32(1) e = npoints - int32(1) } if closed != 0 { _nsvg__initClosed(tls, bp, bp+32, p0, p1, lineWidth) firstLeft = *(*TNSVGpoint)(unsafe.Pointer(bp)) firstRight = *(*TNSVGpoint)(unsafe.Pointer(bp + 32)) } else { *(*float32)(unsafe.Pointer(bp + 64)) = (*TNSVGpoint)(unsafe.Pointer(p1)).Fx - (*TNSVGpoint)(unsafe.Pointer(p0)).Fx *(*float32)(unsafe.Pointer(bp + 68)) = (*TNSVGpoint)(unsafe.Pointer(p1)).Fy - (*TNSVGpoint)(unsafe.Pointer(p0)).Fy _nsvg__normalize(tls, bp+64, bp+68) if lineCap == int32(NSVG_CAP_BUTT) { _nsvg__buttCap(tls, r, bp, bp+32, p0, *(*float32)(unsafe.Pointer(bp + 64)), *(*float32)(unsafe.Pointer(bp + 68)), lineWidth, 0) } else { if lineCap == int32(NSVG_CAP_SQUARE) { _nsvg__squareCap(tls, r, bp, bp+32, p0, *(*float32)(unsafe.Pointer(bp + 64)), *(*float32)(unsafe.Pointer(bp + 68)), lineWidth, 0) } else { if lineCap == int32(NSVG_CAP_ROUND) { _nsvg__roundCap(tls, r, bp, bp+32, p0, *(*float32)(unsafe.Pointer(bp + 64)), *(*float32)(unsafe.Pointer(bp + 68)), lineWidth, ncap, 0) } } } } j = s for { if !(j < e) { break } if libc.Int32FromUint8((*TNSVGpoint)(unsafe.Pointer(p1)).Fflags)&int32(NSVG_PT_CORNER) != 0 { if lineJoin == int32(NSVG_JOIN_ROUND) { _nsvg__roundJoin(tls, r, bp, bp+32, p0, p1, lineWidth, ncap) } else { if lineJoin == int32(NSVG_JOIN_BEVEL) || libc.Int32FromUint8((*TNSVGpoint)(unsafe.Pointer(p1)).Fflags)&int32(NSVG_PT_BEVEL) != 0 { _nsvg__bevelJoin(tls, r, bp, bp+32, p0, p1, lineWidth) } else { _nsvg__miterJoin(tls, r, bp, bp+32, p0, p1, lineWidth) } } } else { _nsvg__straightJoin(tls, r, bp, bp+32, p1, lineWidth) } v2 = p1 p1 += 32 p0 = v2 goto _1 _1: ; j++ } if closed != 0 { _nsvg__addEdge(tls, r, firstLeft.Fx, firstLeft.Fy, (*(*TNSVGpoint)(unsafe.Pointer(bp))).Fx, (*(*TNSVGpoint)(unsafe.Pointer(bp))).Fy) _nsvg__addEdge(tls, r, (*(*TNSVGpoint)(unsafe.Pointer(bp + 32))).Fx, (*(*TNSVGpoint)(unsafe.Pointer(bp + 32))).Fy, firstRight.Fx, firstRight.Fy) } else { *(*float32)(unsafe.Pointer(bp + 72)) = (*TNSVGpoint)(unsafe.Pointer(p1)).Fx - (*TNSVGpoint)(unsafe.Pointer(p0)).Fx *(*float32)(unsafe.Pointer(bp + 76)) = (*TNSVGpoint)(unsafe.Pointer(p1)).Fy - (*TNSVGpoint)(unsafe.Pointer(p0)).Fy _nsvg__normalize(tls, bp+72, bp+76) if lineCap == int32(NSVG_CAP_BUTT) { _nsvg__buttCap(tls, r, bp+32, bp, p1, -*(*float32)(unsafe.Pointer(bp + 72)), -*(*float32)(unsafe.Pointer(bp + 76)), lineWidth, int32(1)) } else { if lineCap == int32(NSVG_CAP_SQUARE) { _nsvg__squareCap(tls, r, bp+32, bp, p1, -*(*float32)(unsafe.Pointer(bp + 72)), -*(*float32)(unsafe.Pointer(bp + 76)), lineWidth, int32(1)) } else { if lineCap == int32(NSVG_CAP_ROUND) { _nsvg__roundCap(tls, r, bp+32, bp, p1, -*(*float32)(unsafe.Pointer(bp + 72)), -*(*float32)(unsafe.Pointer(bp + 76)), lineWidth, ncap, int32(1)) } } } } } func _nsvg__prepareStroke(tls *libc.TLS, r uintptr, miterLimit float32, lineJoin int32) { var cross, dlx0, dlx1, dly0, dly1, dmr2, s2 float32 var i, j, v4 int32 var p0, p1, v2, v7, p5, p6 uintptr _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = cross, dlx0, dlx1, dly0, dly1, dmr2, i, j, p0, p1, s2, v2, v4, v7, p5, p6 p0 = (*TNSVGrasterizer)(unsafe.Pointer(r)).Fpoints + uintptr((*TNSVGrasterizer)(unsafe.Pointer(r)).Fnpoints-int32(1))*32 p1 = (*TNSVGrasterizer)(unsafe.Pointer(r)).Fpoints i = 0 for { if !(i < (*TNSVGrasterizer)(unsafe.Pointer(r)).Fnpoints) { break } (*TNSVGpoint)(unsafe.Pointer(p0)).Fdx = (*TNSVGpoint)(unsafe.Pointer(p1)).Fx - (*TNSVGpoint)(unsafe.Pointer(p0)).Fx (*TNSVGpoint)(unsafe.Pointer(p0)).Fdy = (*TNSVGpoint)(unsafe.Pointer(p1)).Fy - (*TNSVGpoint)(unsafe.Pointer(p0)).Fy (*TNSVGpoint)(unsafe.Pointer(p0)).Flen1 = _nsvg__normalize(tls, p0+8, p0+12) v2 = p1 p1 += 32 p0 = v2 goto _1 _1: ; i++ } p0 = (*TNSVGrasterizer)(unsafe.Pointer(r)).Fpoints + uintptr((*TNSVGrasterizer)(unsafe.Pointer(r)).Fnpoints-int32(1))*32 p1 = (*TNSVGrasterizer)(unsafe.Pointer(r)).Fpoints j = 0 for { if !(j < (*TNSVGrasterizer)(unsafe.Pointer(r)).Fnpoints) { break } dlx0 = (*TNSVGpoint)(unsafe.Pointer(p0)).Fdy dly0 = -(*TNSVGpoint)(unsafe.Pointer(p0)).Fdx dlx1 = (*TNSVGpoint)(unsafe.Pointer(p1)).Fdy dly1 = -(*TNSVGpoint)(unsafe.Pointer(p1)).Fdx (*TNSVGpoint)(unsafe.Pointer(p1)).Fdmx = float32((dlx0 + dlx1) * libc.Float32FromFloat32(0.5)) (*TNSVGpoint)(unsafe.Pointer(p1)).Fdmy = float32((dly0 + dly1) * libc.Float32FromFloat32(0.5)) dmr2 = float32((*TNSVGpoint)(unsafe.Pointer(p1)).Fdmx*(*TNSVGpoint)(unsafe.Pointer(p1)).Fdmx) + float32((*TNSVGpoint)(unsafe.Pointer(p1)).Fdmy*(*TNSVGpoint)(unsafe.Pointer(p1)).Fdmy) if dmr2 > libc.Float32FromFloat32(1e-06) { s2 = libc.Float32FromFloat32(1) / dmr2 if s2 > libc.Float32FromFloat32(600) { s2 = libc.Float32FromFloat32(600) } *(*float32)(unsafe.Pointer(p1 + 20)) *= s2 *(*float32)(unsafe.Pointer(p1 + 24)) *= s2 } if libc.Int32FromUint8((*TNSVGpoint)(unsafe.Pointer(p1)).Fflags)&int32(NSVG_PT_CORNER) != 0 { v4 = int32(NSVG_PT_CORNER) } else { v4 = 0 } (*TNSVGpoint)(unsafe.Pointer(p1)).Fflags = libc.Uint8FromInt32(v4) cross = float32((*TNSVGpoint)(unsafe.Pointer(p1)).Fdx*(*TNSVGpoint)(unsafe.Pointer(p0)).Fdy) - float32((*TNSVGpoint)(unsafe.Pointer(p0)).Fdx*(*TNSVGpoint)(unsafe.Pointer(p1)).Fdy) if cross > libc.Float32FromFloat32(0) { p5 = p1 + 28 *(*uint8)(unsafe.Pointer(p5)) = uint8(int32(*(*uint8)(unsafe.Pointer(p5))) | int32(NSVG_PT_LEFT)) } if libc.Int32FromUint8((*TNSVGpoint)(unsafe.Pointer(p1)).Fflags)&int32(NSVG_PT_CORNER) != 0 { if float32(float32(dmr2*miterLimit)*miterLimit) < libc.Float32FromFloat32(1) || lineJoin == int32(NSVG_JOIN_BEVEL) || lineJoin == int32(NSVG_JOIN_ROUND) { p6 = p1 + 28 *(*uint8)(unsafe.Pointer(p6)) = uint8(int32(*(*uint8)(unsafe.Pointer(p6))) | int32(NSVG_PT_BEVEL)) } } v7 = p1 p1 += 32 p0 = v7 goto _3 _3: ; j++ } } func _nsvg__flattenShapeStroke(tls *libc.TLS, r uintptr, shape uintptr, scale float32) { var allDashLen, d, dashLen, dashOffset, dist, dx, dy, lineWidth, miterLimit, totalDist, x, y float32 var closed, dashState, i, idash, j, lineCap, lineJoin int32 var cur TNSVGpoint var p, p0, p1, path uintptr _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = allDashLen, closed, cur, d, dashLen, dashOffset, dashState, dist, dx, dy, i, idash, j, lineCap, lineJoin, lineWidth, miterLimit, p, p0, p1, path, totalDist, x, y miterLimit = (*TNSVGshape)(unsafe.Pointer(shape)).FmiterLimit lineJoin = libc.Int32FromUint8((*TNSVGshape)(unsafe.Pointer(shape)).FstrokeLineJoin) lineCap = libc.Int32FromUint8((*TNSVGshape)(unsafe.Pointer(shape)).FstrokeLineCap) lineWidth = float32((*TNSVGshape)(unsafe.Pointer(shape)).FstrokeWidth * scale) path = (*TNSVGshape)(unsafe.Pointer(shape)).Fpaths for { if !(path != libc.UintptrFromInt32(0)) { break } (*TNSVGrasterizer)(unsafe.Pointer(r)).Fnpoints = 0 _nsvg__addPathPoint(tls, r, float32(*(*float32)(unsafe.Pointer((*TNSVGpath)(unsafe.Pointer(path)).Fpts))*scale), float32(*(*float32)(unsafe.Pointer((*TNSVGpath)(unsafe.Pointer(path)).Fpts + 1*4))*scale), int32(NSVG_PT_CORNER)) i = 0 for { if !(i < (*TNSVGpath)(unsafe.Pointer(path)).Fnpts-int32(1)) { break } p = (*TNSVGpath)(unsafe.Pointer(path)).Fpts + uintptr(i*int32(2))*4 _nsvg__flattenCubicBez(tls, r, float32(*(*float32)(unsafe.Pointer(p))*scale), float32(*(*float32)(unsafe.Pointer(p + 1*4))*scale), float32(*(*float32)(unsafe.Pointer(p + 2*4))*scale), float32(*(*float32)(unsafe.Pointer(p + 3*4))*scale), float32(*(*float32)(unsafe.Pointer(p + 4*4))*scale), float32(*(*float32)(unsafe.Pointer(p + 5*4))*scale), float32(*(*float32)(unsafe.Pointer(p + 6*4))*scale), float32(*(*float32)(unsafe.Pointer(p + 7*4))*scale), 0, int32(NSVG_PT_CORNER)) goto _2 _2: ; i += int32(3) } if (*TNSVGrasterizer)(unsafe.Pointer(r)).Fnpoints < int32(2) { goto _1 } closed = libc.Int32FromUint8((*TNSVGpath)(unsafe.Pointer(path)).Fclosed) p0 = (*TNSVGrasterizer)(unsafe.Pointer(r)).Fpoints + uintptr((*TNSVGrasterizer)(unsafe.Pointer(r)).Fnpoints-int32(1))*32 p1 = (*TNSVGrasterizer)(unsafe.Pointer(r)).Fpoints if _nsvg__ptEquals(tls, (*TNSVGpoint)(unsafe.Pointer(p0)).Fx, (*TNSVGpoint)(unsafe.Pointer(p0)).Fy, (*TNSVGpoint)(unsafe.Pointer(p1)).Fx, (*TNSVGpoint)(unsafe.Pointer(p1)).Fy, (*TNSVGrasterizer)(unsafe.Pointer(r)).FdistTol) != 0 { (*TNSVGrasterizer)(unsafe.Pointer(r)).Fnpoints-- p0 = (*TNSVGrasterizer)(unsafe.Pointer(r)).Fpoints + uintptr((*TNSVGrasterizer)(unsafe.Pointer(r)).Fnpoints-int32(1))*32 closed = int32(1) } if libc.Int32FromUint8((*TNSVGshape)(unsafe.Pointer(shape)).FstrokeDashCount) > 0 { idash = 0 dashState = int32(1) totalDist = libc.Float32FromInt32(0) if closed != 0 { _nsvg__appendPathPoint(tls, r, *(*TNSVGpoint)(unsafe.Pointer((*TNSVGrasterizer)(unsafe.Pointer(r)).Fpoints))) } _nsvg__duplicatePoints(tls, r) (*TNSVGrasterizer)(unsafe.Pointer(r)).Fnpoints = 0 cur = *(*TNSVGpoint)(unsafe.Pointer((*TNSVGrasterizer)(unsafe.Pointer(r)).Fpoints2)) _nsvg__appendPathPoint(tls, r, cur) allDashLen = libc.Float32FromInt32(0) j = 0 for { if !(j < libc.Int32FromUint8((*TNSVGshape)(unsafe.Pointer(shape)).FstrokeDashCount)) { break } allDashLen += *(*float32)(unsafe.Pointer(shape + 108 + uintptr(j)*4)) goto _3 _3: ; j++ } if libc.Int32FromUint8((*TNSVGshape)(unsafe.Pointer(shape)).FstrokeDashCount)&int32(1) != 0 { allDashLen *= libc.Float32FromFloat32(2) } dashOffset = libc.Xfmodf(tls, (*TNSVGshape)(unsafe.Pointer(shape)).FstrokeDashOffset, allDashLen) if dashOffset < libc.Float32FromFloat32(0) { dashOffset += allDashLen } for dashOffset > *(*float32)(unsafe.Pointer(shape + 108 + uintptr(idash)*4)) { dashOffset -= *(*float32)(unsafe.Pointer(shape + 108 + uintptr(idash)*4)) idash = (idash + int32(1)) % libc.Int32FromUint8((*TNSVGshape)(unsafe.Pointer(shape)).FstrokeDashCount) } dashLen = float32((*(*float32)(unsafe.Pointer(shape + 108 + uintptr(idash)*4)) - dashOffset) * scale) j = int32(1) for { if !(j < (*TNSVGrasterizer)(unsafe.Pointer(r)).Fnpoints2) { break } dx = (*(*TNSVGpoint)(unsafe.Pointer((*TNSVGrasterizer)(unsafe.Pointer(r)).Fpoints2 + uintptr(j)*32))).Fx - cur.Fx dy = (*(*TNSVGpoint)(unsafe.Pointer((*TNSVGrasterizer)(unsafe.Pointer(r)).Fpoints2 + uintptr(j)*32))).Fy - cur.Fy dist = libc.Xsqrtf(tls, float32(dx*dx)+float32(dy*dy)) if totalDist+dist > dashLen { d = (dashLen - totalDist) / dist x = cur.Fx + float32(dx*d) y = cur.Fy + float32(dy*d) _nsvg__addPathPoint(tls, r, x, y, int32(NSVG_PT_CORNER)) if (*TNSVGrasterizer)(unsafe.Pointer(r)).Fnpoints > int32(1) && dashState != 0 { _nsvg__prepareStroke(tls, r, miterLimit, lineJoin) _nsvg__expandStroke(tls, r, (*TNSVGrasterizer)(unsafe.Pointer(r)).Fpoints, (*TNSVGrasterizer)(unsafe.Pointer(r)).Fnpoints, 0, lineJoin, lineCap, lineWidth) } dashState = libc.BoolInt32(!(dashState != 0)) idash = (idash + int32(1)) % libc.Int32FromUint8((*TNSVGshape)(unsafe.Pointer(shape)).FstrokeDashCount) dashLen = float32(*(*float32)(unsafe.Pointer(shape + 108 + uintptr(idash)*4)) * scale) cur.Fx = x cur.Fy = y cur.Fflags = uint8(NSVG_PT_CORNER) totalDist = libc.Float32FromFloat32(0) (*TNSVGrasterizer)(unsafe.Pointer(r)).Fnpoints = 0 _nsvg__appendPathPoint(tls, r, cur) } else { totalDist += dist cur = *(*TNSVGpoint)(unsafe.Pointer((*TNSVGrasterizer)(unsafe.Pointer(r)).Fpoints2 + uintptr(j)*32)) _nsvg__appendPathPoint(tls, r, cur) j++ } goto _4 _4: } if (*TNSVGrasterizer)(unsafe.Pointer(r)).Fnpoints > int32(1) && dashState != 0 { _nsvg__expandStroke(tls, r, (*TNSVGrasterizer)(unsafe.Pointer(r)).Fpoints, (*TNSVGrasterizer)(unsafe.Pointer(r)).Fnpoints, 0, lineJoin, lineCap, lineWidth) } } else { _nsvg__prepareStroke(tls, r, miterLimit, lineJoin) _nsvg__expandStroke(tls, r, (*TNSVGrasterizer)(unsafe.Pointer(r)).Fpoints, (*TNSVGrasterizer)(unsafe.Pointer(r)).Fnpoints, closed, lineJoin, lineCap, lineWidth) } goto _1 _1: ; path = (*TNSVGpath)(unsafe.Pointer(path)).Fnext } } func _nsvg__cmpEdge(tls *libc.TLS, p uintptr, q uintptr) (r int32) { var a, b uintptr _, _ = a, b a = p b = q if (*TNSVGedge)(unsafe.Pointer(a)).Fy0 < (*TNSVGedge)(unsafe.Pointer(b)).Fy0 { return -int32(1) } if (*TNSVGedge)(unsafe.Pointer(a)).Fy0 > (*TNSVGedge)(unsafe.Pointer(b)).Fy0 { return int32(1) } return 0 } func _nsvg__addActive(tls *libc.TLS, r uintptr, e uintptr, startPoint float32) (r1 uintptr) { var dxdy float32 var z uintptr _, _ = dxdy, z if (*TNSVGrasterizer)(unsafe.Pointer(r)).Ffreelist != libc.UintptrFromInt32(0) { z = (*TNSVGrasterizer)(unsafe.Pointer(r)).Ffreelist (*TNSVGrasterizer)(unsafe.Pointer(r)).Ffreelist = (*TNSVGactiveEdge)(unsafe.Pointer(z)).Fnext } else { z = _nsvg__alloc(tls, r, int32(24)) if z == libc.UintptrFromInt32(0) { return libc.UintptrFromInt32(0) } } dxdy = ((*TNSVGedge)(unsafe.Pointer(e)).Fx1 - (*TNSVGedge)(unsafe.Pointer(e)).Fx0) / ((*TNSVGedge)(unsafe.Pointer(e)).Fy1 - (*TNSVGedge)(unsafe.Pointer(e)).Fy0) if dxdy < libc.Float32FromInt32(0) { (*TNSVGactiveEdge)(unsafe.Pointer(z)).Fdx = int32(-_nsvg__roundf(tls, float32(float32(libc.Int32FromInt32(1)<> int32(NSVG__FIXSHIFT) j = x1 >> int32(NSVG__FIXSHIFT) if i < *(*int32)(unsafe.Pointer(xmin)) { *(*int32)(unsafe.Pointer(xmin)) = i } if j > *(*int32)(unsafe.Pointer(xmax)) { *(*int32)(unsafe.Pointer(xmax)) = j } if i < len1 && j >= 0 { if i == j { *(*uint8)(unsafe.Pointer(scanline + uintptr(i))) = libc.Uint8FromInt32(libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(scanline + uintptr(i)))) + (x1-x0)*maxWeight>>libc.Int32FromInt32(NSVG__FIXSHIFT)) } else { if i >= 0 { *(*uint8)(unsafe.Pointer(scanline + uintptr(i))) = libc.Uint8FromInt32(libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(scanline + uintptr(i)))) + (libc.Int32FromInt32(1)<>libc.Int32FromInt32(NSVG__FIXSHIFT)) } else { i = -int32(1) } if j < len1 { *(*uint8)(unsafe.Pointer(scanline + uintptr(j))) = libc.Uint8FromInt32(libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(scanline + uintptr(j)))) + x1&(libc.Int32FromInt32(1)<>libc.Int32FromInt32(NSVG__FIXSHIFT)) } else { j = len1 } i++ for { if !(i < j) { break } *(*uint8)(unsafe.Pointer(scanline + uintptr(i))) = libc.Uint8FromInt32(libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(scanline + uintptr(i)))) + maxWeight) goto _1 _1: ; i++ } } } } func _nsvg__fillActiveEdges(tls *libc.TLS, scanline uintptr, len1 int32, e uintptr, maxWeight int32, xmin uintptr, xmax uintptr, fillRule uint8) { var w, x0, x1, x11 int32 _, _, _, _ = w, x0, x1, x11 x0 = 0 w = 0 if libc.Int32FromUint8(fillRule) == int32(NSVG_FILLRULE_NONZERO) { for e != libc.UintptrFromInt32(0) { if w == 0 { x0 = (*TNSVGactiveEdge)(unsafe.Pointer(e)).Fx w += (*TNSVGactiveEdge)(unsafe.Pointer(e)).Fdir } else { x1 = (*TNSVGactiveEdge)(unsafe.Pointer(e)).Fx w += (*TNSVGactiveEdge)(unsafe.Pointer(e)).Fdir if w == 0 { _nsvg__fillScanline(tls, scanline, len1, x0, x1, maxWeight, xmin, xmax) } } e = (*TNSVGactiveEdge)(unsafe.Pointer(e)).Fnext } } else { if libc.Int32FromUint8(fillRule) == int32(NSVG_FILLRULE_EVENODD) { for e != libc.UintptrFromInt32(0) { if w == 0 { x0 = (*TNSVGactiveEdge)(unsafe.Pointer(e)).Fx w = int32(1) } else { x11 = (*TNSVGactiveEdge)(unsafe.Pointer(e)).Fx w = 0 _nsvg__fillScanline(tls, scanline, len1, x0, x11, maxWeight, xmin, xmax) } e = (*TNSVGactiveEdge)(unsafe.Pointer(e)).Fnext } } } } func _nsvg__clampf(tls *libc.TLS, a float32, mn float32, mx float32) (r float32) { var v1, v2 float32 _, _ = v1, v2 if a < mn { v1 = mn } else { if a > mx { v2 = mx } else { v2 = a } v1 = v2 } return v1 } func _nsvg__RGBA(tls *libc.TLS, r uint8, g uint8, b uint8, a uint8) (r1 uint32) { return uint32(r) | uint32(g)<> int32(8)) g = libc.Int32FromUint32((c0>>int32(8)&uint32(0xff)*libc.Uint32FromInt32(libc.Int32FromInt32(256)-iu) + c1>>int32(8)&uint32(0xff)*libc.Uint32FromInt32(iu)) >> int32(8)) b = libc.Int32FromUint32((c0>>int32(16)&uint32(0xff)*libc.Uint32FromInt32(libc.Int32FromInt32(256)-iu) + c1>>int32(16)&uint32(0xff)*libc.Uint32FromInt32(iu)) >> int32(8)) a = libc.Int32FromUint32((c0>>int32(24)&uint32(0xff)*libc.Uint32FromInt32(libc.Int32FromInt32(256)-iu) + c1>>int32(24)&uint32(0xff)*libc.Uint32FromInt32(iu)) >> int32(8)) return _nsvg__RGBA(tls, libc.Uint8FromInt32(r), libc.Uint8FromInt32(g), libc.Uint8FromInt32(b), libc.Uint8FromInt32(a)) } func _nsvg__applyOpacity(tls *libc.TLS, c uint32, u float32) (r1 uint32) { var a, b, g, iu, r int32 _, _, _, _, _ = a, b, g, iu, r iu = int32(float32(_nsvg__clampf(tls, u, libc.Float32FromFloat32(0), libc.Float32FromFloat32(1)) * libc.Float32FromFloat32(256))) r = libc.Int32FromUint32(c & uint32(0xff)) g = libc.Int32FromUint32(c >> int32(8) & uint32(0xff)) b = libc.Int32FromUint32(c >> int32(16) & uint32(0xff)) a = libc.Int32FromUint32(c >> int32(24) & uint32(0xff) * libc.Uint32FromInt32(iu) >> int32(8)) return _nsvg__RGBA(tls, libc.Uint8FromInt32(r), libc.Uint8FromInt32(g), libc.Uint8FromInt32(b), libc.Uint8FromInt32(a)) } func _nsvg__scanlineSolid(tls *libc.TLS, dst uintptr, count int32, cover uintptr, x1 int32, y int32, tx float32, ty float32, scale float32, cache uintptr) { var a, a1, a2, b, b1, b2, ca, ca1, ca2, cb, cb1, cb2, cg, cg1, cg2, cr, cr1, cr2, g, g1, g2, i, i1, i2, ia, ia1, ia2, r, r1, r2, v10, v12, v14, v16, v19, v2, v21, v23, v25, v27, v29, v31, v33, v36, v38, v4, v40, v42, v44, v46, v48, v50, v6, v8 int32 var c, c1 uint32 var dx, dx1, fx, fx1, fy, fy1, gd, gx, gy, gy1 float32 var t, t1 uintptr _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = a, a1, a2, b, b1, b2, c, c1, ca, ca1, ca2, cb, cb1, cb2, cg, cg1, cg2, cr, cr1, cr2, dx, dx1, fx, fx1, fy, fy1, g, g1, g2, gd, gx, gy, gy1, i, i1, i2, ia, ia1, ia2, r, r1, r2, t, t1, v10, v12, v14, v16, v19, v2, v21, v23, v25, v27, v29, v31, v33, v36, v38, v4, v40, v42, v44, v46, v48, v50, v6, v8 if int32((*TNSVGcachedPaint)(unsafe.Pointer(cache)).Ftype1) == int32(NSVG_PAINT_COLOR) { cr = libc.Int32FromUint32(*(*uint32)(unsafe.Pointer(cache + 28)) & uint32(0xff)) cg = libc.Int32FromUint32(*(*uint32)(unsafe.Pointer(cache + 28)) >> int32(8) & uint32(0xff)) cb = libc.Int32FromUint32(*(*uint32)(unsafe.Pointer(cache + 28)) >> int32(16) & uint32(0xff)) ca = libc.Int32FromUint32(*(*uint32)(unsafe.Pointer(cache + 28)) >> int32(24) & uint32(0xff)) i = 0 for { if !(i < count) { break } v2 = (libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(cover)))*ca + int32(1)) * int32(257) >> int32(16) goto _3 _3: a = v2 ia = int32(255) - a v4 = (cr*a + int32(1)) * int32(257) >> int32(16) goto _5 _5: r = v4 v6 = (cg*a + int32(1)) * int32(257) >> int32(16) goto _7 _7: g = v6 v8 = (cb*a + int32(1)) * int32(257) >> int32(16) goto _9 _9: b = v8 v10 = (ia*libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(dst))) + int32(1)) * int32(257) >> int32(16) goto _11 _11: r += v10 v12 = (ia*libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(dst + 1))) + int32(1)) * int32(257) >> int32(16) goto _13 _13: g += v12 v14 = (ia*libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(dst + 2))) + int32(1)) * int32(257) >> int32(16) goto _15 _15: b += v14 v16 = (ia*libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(dst + 3))) + int32(1)) * int32(257) >> int32(16) goto _17 _17: a += v16 *(*uint8)(unsafe.Pointer(dst)) = libc.Uint8FromInt32(r) *(*uint8)(unsafe.Pointer(dst + 1)) = libc.Uint8FromInt32(g) *(*uint8)(unsafe.Pointer(dst + 2)) = libc.Uint8FromInt32(b) *(*uint8)(unsafe.Pointer(dst + 3)) = libc.Uint8FromInt32(a) cover++ dst += uintptr(4) goto _1 _1: ; i++ } } else { if int32((*TNSVGcachedPaint)(unsafe.Pointer(cache)).Ftype1) == int32(NSVG_PAINT_LINEAR_GRADIENT) { t = cache + 4 fx = (float32(x1) - tx) / scale fy = (float32(y) - ty) / scale dx = libc.Float32FromFloat32(1) / scale i1 = 0 for { if !(i1 < count) { break } gy = float32(fx**(*float32)(unsafe.Pointer(t + 1*4))) + float32(fy**(*float32)(unsafe.Pointer(t + 3*4))) + *(*float32)(unsafe.Pointer(t + 5*4)) c = *(*uint32)(unsafe.Pointer(cache + 28 + uintptr(int32(_nsvg__clampf(tls, float32(gy*libc.Float32FromFloat32(255)), libc.Float32FromInt32(0), libc.Float32FromFloat32(255))))*4)) cr1 = libc.Int32FromUint32(c & uint32(0xff)) cg1 = libc.Int32FromUint32(c >> int32(8) & uint32(0xff)) cb1 = libc.Int32FromUint32(c >> int32(16) & uint32(0xff)) ca1 = libc.Int32FromUint32(c >> int32(24) & uint32(0xff)) v19 = (libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(cover)))*ca1 + int32(1)) * int32(257) >> int32(16) goto _20 _20: a1 = v19 ia1 = int32(255) - a1 v21 = (cr1*a1 + int32(1)) * int32(257) >> int32(16) goto _22 _22: r1 = v21 v23 = (cg1*a1 + int32(1)) * int32(257) >> int32(16) goto _24 _24: g1 = v23 v25 = (cb1*a1 + int32(1)) * int32(257) >> int32(16) goto _26 _26: b1 = v25 v27 = (ia1*libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(dst))) + int32(1)) * int32(257) >> int32(16) goto _28 _28: r1 += v27 v29 = (ia1*libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(dst + 1))) + int32(1)) * int32(257) >> int32(16) goto _30 _30: g1 += v29 v31 = (ia1*libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(dst + 2))) + int32(1)) * int32(257) >> int32(16) goto _32 _32: b1 += v31 v33 = (ia1*libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(dst + 3))) + int32(1)) * int32(257) >> int32(16) goto _34 _34: a1 += v33 *(*uint8)(unsafe.Pointer(dst)) = libc.Uint8FromInt32(r1) *(*uint8)(unsafe.Pointer(dst + 1)) = libc.Uint8FromInt32(g1) *(*uint8)(unsafe.Pointer(dst + 2)) = libc.Uint8FromInt32(b1) *(*uint8)(unsafe.Pointer(dst + 3)) = libc.Uint8FromInt32(a1) cover++ dst += uintptr(4) fx += dx goto _18 _18: ; i1++ } } else { if int32((*TNSVGcachedPaint)(unsafe.Pointer(cache)).Ftype1) == int32(NSVG_PAINT_RADIAL_GRADIENT) { t1 = cache + 4 fx1 = (float32(x1) - tx) / scale fy1 = (float32(y) - ty) / scale dx1 = libc.Float32FromFloat32(1) / scale i2 = 0 for { if !(i2 < count) { break } gx = float32(fx1**(*float32)(unsafe.Pointer(t1))) + float32(fy1**(*float32)(unsafe.Pointer(t1 + 2*4))) + *(*float32)(unsafe.Pointer(t1 + 4*4)) gy1 = float32(fx1**(*float32)(unsafe.Pointer(t1 + 1*4))) + float32(fy1**(*float32)(unsafe.Pointer(t1 + 3*4))) + *(*float32)(unsafe.Pointer(t1 + 5*4)) gd = libc.Xsqrtf(tls, float32(gx*gx)+float32(gy1*gy1)) c1 = *(*uint32)(unsafe.Pointer(cache + 28 + uintptr(int32(_nsvg__clampf(tls, float32(gd*libc.Float32FromFloat32(255)), libc.Float32FromInt32(0), libc.Float32FromFloat32(255))))*4)) cr2 = libc.Int32FromUint32(c1 & uint32(0xff)) cg2 = libc.Int32FromUint32(c1 >> int32(8) & uint32(0xff)) cb2 = libc.Int32FromUint32(c1 >> int32(16) & uint32(0xff)) ca2 = libc.Int32FromUint32(c1 >> int32(24) & uint32(0xff)) v36 = (libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(cover)))*ca2 + int32(1)) * int32(257) >> int32(16) goto _37 _37: a2 = v36 ia2 = int32(255) - a2 v38 = (cr2*a2 + int32(1)) * int32(257) >> int32(16) goto _39 _39: r2 = v38 v40 = (cg2*a2 + int32(1)) * int32(257) >> int32(16) goto _41 _41: g2 = v40 v42 = (cb2*a2 + int32(1)) * int32(257) >> int32(16) goto _43 _43: b2 = v42 v44 = (ia2*libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(dst))) + int32(1)) * int32(257) >> int32(16) goto _45 _45: r2 += v44 v46 = (ia2*libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(dst + 1))) + int32(1)) * int32(257) >> int32(16) goto _47 _47: g2 += v46 v48 = (ia2*libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(dst + 2))) + int32(1)) * int32(257) >> int32(16) goto _49 _49: b2 += v48 v50 = (ia2*libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(dst + 3))) + int32(1)) * int32(257) >> int32(16) goto _51 _51: a2 += v50 *(*uint8)(unsafe.Pointer(dst)) = libc.Uint8FromInt32(r2) *(*uint8)(unsafe.Pointer(dst + 1)) = libc.Uint8FromInt32(g2) *(*uint8)(unsafe.Pointer(dst + 2)) = libc.Uint8FromInt32(b2) *(*uint8)(unsafe.Pointer(dst + 3)) = libc.Uint8FromInt32(a2) cover++ dst += uintptr(4) fx1 += dx1 goto _35 _35: ; i2++ } } } } } func _nsvg__rasterizeSortedEdges(tls *libc.TLS, r uintptr, tx float32, ty float32, scale float32, cache uintptr, fillRule uint8) { bp := tls.Alloc(16) defer tls.Free(16) var changed, e, maxWeight, s, y int32 var p, q, step, t, z, z1 uintptr var scany float32 var _ /* active at bp+0 */ uintptr var _ /* xmax at bp+12 */ int32 var _ /* xmin at bp+8 */ int32 _, _, _, _, _, _, _, _, _, _, _, _ = changed, e, maxWeight, p, q, s, scany, step, t, y, z, z1 *(*uintptr)(unsafe.Pointer(bp)) = libc.UintptrFromInt32(0) e = 0 maxWeight = libc.Int32FromInt32(255) / libc.Int32FromInt32(NSVG__SUBSAMPLES) y = 0 for { if !(y < (*TNSVGrasterizer)(unsafe.Pointer(r)).Fheight) { break } libc.Xmemset(tls, (*TNSVGrasterizer)(unsafe.Pointer(r)).Fscanline, 0, libc.Uint64FromInt32((*TNSVGrasterizer)(unsafe.Pointer(r)).Fwidth)) *(*int32)(unsafe.Pointer(bp + 8)) = (*TNSVGrasterizer)(unsafe.Pointer(r)).Fwidth *(*int32)(unsafe.Pointer(bp + 12)) = 0 s = 0 for { if !(s < int32(NSVG__SUBSAMPLES)) { break } scany = float32(y*libc.Int32FromInt32(NSVG__SUBSAMPLES)+s) + libc.Float32FromFloat32(0.5) step = bp for *(*uintptr)(unsafe.Pointer(step)) != 0 { z = *(*uintptr)(unsafe.Pointer(step)) if (*TNSVGactiveEdge)(unsafe.Pointer(z)).Fey <= scany { *(*uintptr)(unsafe.Pointer(step)) = (*TNSVGactiveEdge)(unsafe.Pointer(z)).Fnext _nsvg__freeActive(tls, r, z) } else { *(*int32)(unsafe.Pointer(z)) += (*TNSVGactiveEdge)(unsafe.Pointer(z)).Fdx step = *(*uintptr)(unsafe.Pointer(step)) + 16 } } for { changed = 0 step = bp for *(*uintptr)(unsafe.Pointer(step)) != 0 && (*TNSVGactiveEdge)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(step)))).Fnext != 0 { if (*TNSVGactiveEdge)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(step)))).Fx > (*TNSVGactiveEdge1)(unsafe.Pointer((*TNSVGactiveEdge)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(step)))).Fnext)).Fx { t = *(*uintptr)(unsafe.Pointer(step)) q = (*TNSVGactiveEdge)(unsafe.Pointer(t)).Fnext (*TNSVGactiveEdge)(unsafe.Pointer(t)).Fnext = (*TNSVGactiveEdge)(unsafe.Pointer(q)).Fnext (*TNSVGactiveEdge)(unsafe.Pointer(q)).Fnext = t *(*uintptr)(unsafe.Pointer(step)) = q changed = int32(1) } step = *(*uintptr)(unsafe.Pointer(step)) + 16 } if !(changed != 0) { break } goto _3 _3: } for e < (*TNSVGrasterizer)(unsafe.Pointer(r)).Fnedges && (*(*TNSVGedge)(unsafe.Pointer((*TNSVGrasterizer)(unsafe.Pointer(r)).Fedges + uintptr(e)*32))).Fy0 <= scany { if (*(*TNSVGedge)(unsafe.Pointer((*TNSVGrasterizer)(unsafe.Pointer(r)).Fedges + uintptr(e)*32))).Fy1 > scany { z1 = _nsvg__addActive(tls, r, (*TNSVGrasterizer)(unsafe.Pointer(r)).Fedges+uintptr(e)*32, scany) if z1 == libc.UintptrFromInt32(0) { break } if *(*uintptr)(unsafe.Pointer(bp)) == libc.UintptrFromInt32(0) { *(*uintptr)(unsafe.Pointer(bp)) = z1 } else { if (*TNSVGactiveEdge)(unsafe.Pointer(z1)).Fx < (*TNSVGactiveEdge)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp)))).Fx { (*TNSVGactiveEdge)(unsafe.Pointer(z1)).Fnext = *(*uintptr)(unsafe.Pointer(bp)) *(*uintptr)(unsafe.Pointer(bp)) = z1 } else { p = *(*uintptr)(unsafe.Pointer(bp)) for (*TNSVGactiveEdge)(unsafe.Pointer(p)).Fnext != 0 && (*TNSVGactiveEdge1)(unsafe.Pointer((*TNSVGactiveEdge)(unsafe.Pointer(p)).Fnext)).Fx < (*TNSVGactiveEdge)(unsafe.Pointer(z1)).Fx { p = (*TNSVGactiveEdge)(unsafe.Pointer(p)).Fnext } (*TNSVGactiveEdge)(unsafe.Pointer(z1)).Fnext = (*TNSVGactiveEdge)(unsafe.Pointer(p)).Fnext (*TNSVGactiveEdge)(unsafe.Pointer(p)).Fnext = z1 } } } e++ } if *(*uintptr)(unsafe.Pointer(bp)) != libc.UintptrFromInt32(0) { _nsvg__fillActiveEdges(tls, (*TNSVGrasterizer)(unsafe.Pointer(r)).Fscanline, (*TNSVGrasterizer)(unsafe.Pointer(r)).Fwidth, *(*uintptr)(unsafe.Pointer(bp)), maxWeight, bp+8, bp+12, fillRule) } goto _2 _2: ; s++ } if *(*int32)(unsafe.Pointer(bp + 8)) < 0 { *(*int32)(unsafe.Pointer(bp + 8)) = 0 } if *(*int32)(unsafe.Pointer(bp + 12)) > (*TNSVGrasterizer)(unsafe.Pointer(r)).Fwidth-int32(1) { *(*int32)(unsafe.Pointer(bp + 12)) = (*TNSVGrasterizer)(unsafe.Pointer(r)).Fwidth - int32(1) } if *(*int32)(unsafe.Pointer(bp + 8)) <= *(*int32)(unsafe.Pointer(bp + 12)) { _nsvg__scanlineSolid(tls, (*TNSVGrasterizer)(unsafe.Pointer(r)).Fbitmap+uintptr(y*(*TNSVGrasterizer)(unsafe.Pointer(r)).Fstride)+uintptr(*(*int32)(unsafe.Pointer(bp + 8))*int32(4)), *(*int32)(unsafe.Pointer(bp + 12))-*(*int32)(unsafe.Pointer(bp + 8))+int32(1), (*TNSVGrasterizer)(unsafe.Pointer(r)).Fscanline+uintptr(*(*int32)(unsafe.Pointer(bp + 8))), *(*int32)(unsafe.Pointer(bp + 8)), y, tx, ty, scale, cache) } goto _1 _1: ; y++ } } func _nsvg__unpremultiplyAlpha(tls *libc.TLS, image uintptr, w int32, h int32, stride int32) { var a, a1, b, b1, g, g1, n, r, r1, x, y int32 var row, row1 uintptr _, _, _, _, _, _, _, _, _, _, _, _, _ = a, a1, b, b1, g, g1, n, r, r1, row, row1, x, y y = 0 for { if !(y < h) { break } row = image + uintptr(y*stride) x = 0 for { if !(x < w) { break } r = libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(row))) g = libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(row + 1))) b = libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(row + 2))) a = libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(row + 3))) if a != 0 { *(*uint8)(unsafe.Pointer(row)) = libc.Uint8FromInt32(r * libc.Int32FromInt32(255) / a) *(*uint8)(unsafe.Pointer(row + 1)) = libc.Uint8FromInt32(g * libc.Int32FromInt32(255) / a) *(*uint8)(unsafe.Pointer(row + 2)) = libc.Uint8FromInt32(b * libc.Int32FromInt32(255) / a) } row += uintptr(4) goto _2 _2: ; x++ } goto _1 _1: ; y++ } y = 0 for { if !(y < h) { break } row1 = image + uintptr(y*stride) x = 0 for { if !(x < w) { break } r1 = 0 g1 = 0 b1 = 0 a1 = libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(row1 + 3))) n = 0 if a1 == 0 { if x-int32(1) > 0 && libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(row1 + uintptr(-libc.Int32FromInt32(1))))) != 0 { r1 += libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(row1 + uintptr(-libc.Int32FromInt32(4))))) g1 += libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(row1 + uintptr(-libc.Int32FromInt32(3))))) b1 += libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(row1 + uintptr(-libc.Int32FromInt32(2))))) n++ } if x+int32(1) < w && libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(row1 + 7))) != 0 { r1 += libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(row1 + 4))) g1 += libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(row1 + 5))) b1 += libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(row1 + 6))) n++ } if y-int32(1) > 0 && libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(row1 + uintptr(-stride+int32(3))))) != 0 { r1 += libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(row1 + uintptr(-stride)))) g1 += libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(row1 + uintptr(-stride+int32(1))))) b1 += libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(row1 + uintptr(-stride+int32(2))))) n++ } if y+int32(1) < h && libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(row1 + uintptr(stride+int32(3))))) != 0 { r1 += libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(row1 + uintptr(stride)))) g1 += libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(row1 + uintptr(stride+int32(1))))) b1 += libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(row1 + uintptr(stride+int32(2))))) n++ } if n > 0 { *(*uint8)(unsafe.Pointer(row1)) = libc.Uint8FromInt32(r1 / n) *(*uint8)(unsafe.Pointer(row1 + 1)) = libc.Uint8FromInt32(g1 / n) *(*uint8)(unsafe.Pointer(row1 + 2)) = libc.Uint8FromInt32(b1 / n) } } row1 += uintptr(4) goto _4 _4: ; x++ } goto _3 _3: ; y++ } } func _nsvg__initPaint(tls *libc.TLS, cache uintptr, paint uintptr, opacity float32) { var ca, cb, color uint32 var count, i, ia, ib, j int32 var du, u, ua, ub float32 var grad uintptr _, _, _, _, _, _, _, _, _, _, _, _, _ = ca, cb, color, count, du, grad, i, ia, ib, j, u, ua, ub (*TNSVGcachedPaint)(unsafe.Pointer(cache)).Ftype1 = (*TNSVGpaint)(unsafe.Pointer(paint)).Ftype1 if int32((*TNSVGpaint)(unsafe.Pointer(paint)).Ftype1) == int32(NSVG_PAINT_COLOR) { *(*uint32)(unsafe.Pointer(cache + 28)) = _nsvg__applyOpacity(tls, (*TNSVGpaint)(unsafe.Pointer(paint)).F__ccgo1_8.Fcolor, opacity) return } grad = *(*uintptr)(unsafe.Add(unsafe.Pointer(paint), 8)) (*TNSVGcachedPaint)(unsafe.Pointer(cache)).Fspread = (*TNSVGgradient)(unsafe.Pointer(grad)).Fspread libc.Xmemcpy(tls, cache+4, grad, libc.Uint64FromInt64(4)*libc.Uint64FromInt32(6)) if (*TNSVGgradient)(unsafe.Pointer(grad)).Fnstops == 0 { i = 0 for { if !(i < int32(256)) { break } *(*uint32)(unsafe.Pointer(cache + 28 + uintptr(i)*4)) = uint32(0) goto _1 _1: ; i++ } } else { if (*TNSVGgradient)(unsafe.Pointer(grad)).Fnstops == int32(1) { color = _nsvg__applyOpacity(tls, (*(*TNSVGgradientStop)(unsafe.Pointer(grad + 40))).Fcolor, opacity) i = 0 for { if !(i < int32(256)) { break } *(*uint32)(unsafe.Pointer(cache + 28 + uintptr(i)*4)) = color goto _2 _2: ; i++ } } else { cb = uint32(0) ca = _nsvg__applyOpacity(tls, (*(*TNSVGgradientStop)(unsafe.Pointer(grad + 40))).Fcolor, opacity) ua = _nsvg__clampf(tls, (*(*TNSVGgradientStop)(unsafe.Pointer(grad + 40))).Foffset, libc.Float32FromInt32(0), libc.Float32FromInt32(1)) ub = _nsvg__clampf(tls, (*(*TNSVGgradientStop)(unsafe.Pointer(grad + 40 + uintptr((*TNSVGgradient)(unsafe.Pointer(grad)).Fnstops-int32(1))*8))).Foffset, ua, libc.Float32FromInt32(1)) ia = int32(float32(ua * libc.Float32FromFloat32(255))) ib = int32(float32(ub * libc.Float32FromFloat32(255))) i = 0 for { if !(i < ia) { break } *(*uint32)(unsafe.Pointer(cache + 28 + uintptr(i)*4)) = ca goto _3 _3: ; i++ } i = 0 for { if !(i < (*TNSVGgradient)(unsafe.Pointer(grad)).Fnstops-int32(1)) { break } ca = _nsvg__applyOpacity(tls, (*(*TNSVGgradientStop)(unsafe.Pointer(grad + 40 + uintptr(i)*8))).Fcolor, opacity) cb = _nsvg__applyOpacity(tls, (*(*TNSVGgradientStop)(unsafe.Pointer(grad + 40 + uintptr(i+int32(1))*8))).Fcolor, opacity) ua = _nsvg__clampf(tls, (*(*TNSVGgradientStop)(unsafe.Pointer(grad + 40 + uintptr(i)*8))).Foffset, libc.Float32FromInt32(0), libc.Float32FromInt32(1)) ub = _nsvg__clampf(tls, (*(*TNSVGgradientStop)(unsafe.Pointer(grad + 40 + uintptr(i+int32(1))*8))).Foffset, libc.Float32FromInt32(0), libc.Float32FromInt32(1)) ia = int32(float32(ua * libc.Float32FromFloat32(255))) ib = int32(float32(ub * libc.Float32FromFloat32(255))) count = ib - ia if count <= 0 { goto _4 } u = libc.Float32FromInt32(0) du = libc.Float32FromFloat32(1) / float32(count) j = 0 for { if !(j < count) { break } *(*uint32)(unsafe.Pointer(cache + 28 + uintptr(ia+j)*4)) = _nsvg__lerpRGBA(tls, ca, cb, u) u += du goto _5 _5: ; j++ } goto _4 _4: ; i++ } i = ib for { if !(i < int32(256)) { break } *(*uint32)(unsafe.Pointer(cache + 28 + uintptr(i)*4)) = cb goto _6 _6: ; i++ } } } } func XnsvgRasterize(tls *libc.TLS, r uintptr, image uintptr, tx float32, ty float32, scale float32, dst uintptr, w int32, h int32, stride int32) { bp := tls.Alloc(1056) defer tls.Free(1056) var e, shape uintptr var i int32 var _ /* cache at bp+0 */ TNSVGcachedPaint _, _, _ = e, i, shape shape = libc.UintptrFromInt32(0) e = libc.UintptrFromInt32(0) (*TNSVGrasterizer)(unsafe.Pointer(r)).Fbitmap = dst (*TNSVGrasterizer)(unsafe.Pointer(r)).Fwidth = w (*TNSVGrasterizer)(unsafe.Pointer(r)).Fheight = h (*TNSVGrasterizer)(unsafe.Pointer(r)).Fstride = stride if w > (*TNSVGrasterizer)(unsafe.Pointer(r)).Fcscanline { (*TNSVGrasterizer)(unsafe.Pointer(r)).Fcscanline = w (*TNSVGrasterizer)(unsafe.Pointer(r)).Fscanline = libtcl9_0.XTcl_Realloc(tls, (*TNSVGrasterizer)(unsafe.Pointer(r)).Fscanline, libc.Uint64FromInt32(w)) if (*TNSVGrasterizer)(unsafe.Pointer(r)).Fscanline == libc.UintptrFromInt32(0) { return } } i = 0 for { if !(i < h) { break } libc.Xmemset(tls, dst+uintptr(i*stride), 0, libc.Uint64FromInt32(w*int32(4))) goto _1 _1: ; i++ } shape = (*TNSVGimage)(unsafe.Pointer(image)).Fshapes for { if !(shape != libc.UintptrFromInt32(0)) { break } if !(libc.Int32FromUint8((*TNSVGshape)(unsafe.Pointer(shape)).Fflags)&int32(NSVG_FLAGS_VISIBLE) != 0) { goto _2 } if int32((*TNSVGshape)(unsafe.Pointer(shape)).Ffill.Ftype1) != int32(NSVG_PAINT_NONE) { _nsvg__resetPool(tls, r) (*TNSVGrasterizer)(unsafe.Pointer(r)).Ffreelist = libc.UintptrFromInt32(0) (*TNSVGrasterizer)(unsafe.Pointer(r)).Fnedges = 0 _nsvg__flattenShape(tls, r, shape, scale) i = 0 for { if !(i < (*TNSVGrasterizer)(unsafe.Pointer(r)).Fnedges) { break } e = (*TNSVGrasterizer)(unsafe.Pointer(r)).Fedges + uintptr(i)*32 (*TNSVGedge)(unsafe.Pointer(e)).Fx0 = tx + (*TNSVGedge)(unsafe.Pointer(e)).Fx0 (*TNSVGedge)(unsafe.Pointer(e)).Fy0 = float32((ty + (*TNSVGedge)(unsafe.Pointer(e)).Fy0) * libc.Float32FromInt32(NSVG__SUBSAMPLES)) (*TNSVGedge)(unsafe.Pointer(e)).Fx1 = tx + (*TNSVGedge)(unsafe.Pointer(e)).Fx1 (*TNSVGedge)(unsafe.Pointer(e)).Fy1 = float32((ty + (*TNSVGedge)(unsafe.Pointer(e)).Fy1) * libc.Float32FromInt32(NSVG__SUBSAMPLES)) goto _3 _3: ; i++ } if (*TNSVGrasterizer)(unsafe.Pointer(r)).Fnedges != 0 { libc.Xqsort(tls, (*TNSVGrasterizer)(unsafe.Pointer(r)).Fedges, libc.Uint64FromInt32((*TNSVGrasterizer)(unsafe.Pointer(r)).Fnedges), uint64(32), __ccgo_fp(_nsvg__cmpEdge)) } _nsvg__initPaint(tls, bp, shape+64, (*TNSVGshape)(unsafe.Pointer(shape)).Fopacity) _nsvg__rasterizeSortedEdges(tls, r, tx, ty, scale, bp, (*TNSVGshape)(unsafe.Pointer(shape)).FfillRule) } if int32((*TNSVGshape)(unsafe.Pointer(shape)).Fstroke.Ftype1) != int32(NSVG_PAINT_NONE) && float32((*TNSVGshape)(unsafe.Pointer(shape)).FstrokeWidth*scale) > libc.Float32FromFloat32(0.01) { _nsvg__resetPool(tls, r) (*TNSVGrasterizer)(unsafe.Pointer(r)).Ffreelist = libc.UintptrFromInt32(0) (*TNSVGrasterizer)(unsafe.Pointer(r)).Fnedges = 0 _nsvg__flattenShapeStroke(tls, r, shape, scale) i = 0 for { if !(i < (*TNSVGrasterizer)(unsafe.Pointer(r)).Fnedges) { break } e = (*TNSVGrasterizer)(unsafe.Pointer(r)).Fedges + uintptr(i)*32 (*TNSVGedge)(unsafe.Pointer(e)).Fx0 = tx + (*TNSVGedge)(unsafe.Pointer(e)).Fx0 (*TNSVGedge)(unsafe.Pointer(e)).Fy0 = float32((ty + (*TNSVGedge)(unsafe.Pointer(e)).Fy0) * libc.Float32FromInt32(NSVG__SUBSAMPLES)) (*TNSVGedge)(unsafe.Pointer(e)).Fx1 = tx + (*TNSVGedge)(unsafe.Pointer(e)).Fx1 (*TNSVGedge)(unsafe.Pointer(e)).Fy1 = float32((ty + (*TNSVGedge)(unsafe.Pointer(e)).Fy1) * libc.Float32FromInt32(NSVG__SUBSAMPLES)) goto _4 _4: ; i++ } if (*TNSVGrasterizer)(unsafe.Pointer(r)).Fnedges != 0 { libc.Xqsort(tls, (*TNSVGrasterizer)(unsafe.Pointer(r)).Fedges, libc.Uint64FromInt32((*TNSVGrasterizer)(unsafe.Pointer(r)).Fnedges), uint64(32), __ccgo_fp(_nsvg__cmpEdge)) } _nsvg__initPaint(tls, bp, shape+80, (*TNSVGshape)(unsafe.Pointer(shape)).Fopacity) _nsvg__rasterizeSortedEdges(tls, r, tx, ty, scale, bp, uint8(NSVG_FILLRULE_NONZERO)) } goto _2 _2: ; shape = (*TNSVGshape)(unsafe.Pointer(shape)).Fnext } _nsvg__unpremultiplyAlpha(tls, dst, w, h, stride) (*TNSVGrasterizer)(unsafe.Pointer(r)).Fbitmap = libc.UintptrFromInt32(0) (*TNSVGrasterizer)(unsafe.Pointer(r)).Fwidth = 0 (*TNSVGrasterizer)(unsafe.Pointer(r)).Fheight = 0 (*TNSVGrasterizer)(unsafe.Pointer(r)).Fstride = 0 } /* Additional parameters to nsvgRasterize() */ type TRastOpts = struct { Fscale float64 FscaleToHeight int32 FscaleToWidth int32 } /* * Per interp cache of last NSVGimage which was matched to * be immediately rasterized after the match. This helps to * eliminate double parsing of the SVG file/string. */ type TNSVGcache = struct { FdataOrChan uintptr FformatString TTcl_DString FnsvgImage uintptr Fropts TRastOpts } func init() { p := unsafe.Pointer(&XtkImgFmtSVGnano) *(*uintptr)(unsafe.Add(p, 8)) = __ccgo_fp(_FileMatchSVG) *(*uintptr)(unsafe.Add(p, 16)) = __ccgo_fp(_StringMatchSVG) *(*uintptr)(unsafe.Add(p, 24)) = __ccgo_fp(_FileReadSVG) *(*uintptr)(unsafe.Add(p, 32)) = __ccgo_fp(_StringReadSVG) } /* *---------------------------------------------------------------------- * * MemMem -- * * Like strstr() but operating on memory buffers with sizes. * *---------------------------------------------------------------------- */ func _MemMem(tls *libc.TLS, haystack uintptr, haylen Tsize_t, needle uintptr, needlen Tsize_t) (r uintptr) { var first uint8 var hayend, p, second uintptr _, _, _, _ = first, hayend, p, second if needlen <= uint64(0) || haylen < needlen { return libc.UintptrFromInt32(0) } hayend = haystack + uintptr(haylen) - uintptr(needlen) first = *(*uint8)(unsafe.Pointer(needle)) second = needle + libc.UintptrFromInt32(1) needlen -= uint64(1) for haystack < hayend { p = libc.Xmemchr(tls, haystack, libc.Int32FromUint8(first), libc.Uint64FromInt64(int64(hayend)-int64(haystack))) if p == libc.UintptrFromInt32(0) { break } if needlen == uint64(0) { return p } haystack = p + libc.UintptrFromInt32(1) if libc.Xmemcmp(tls, second, haystack, needlen) == 0 { return p } } return libc.UintptrFromInt32(0) } /* *---------------------------------------------------------------------- * * FileMatchSVG -- * * This function is invoked by the photo image type to see if a file * contains image data in SVG format. * * Results: * The return value is >0 if the file can be successfully parsed, * and 0 otherwise. * * Side effects: * The file is saved in the internal cache for further use. * *---------------------------------------------------------------------- */ func _FileMatchSVG(tls *libc.TLS, chan1 TTcl_Channel, dummy164 uintptr, formatObj uintptr, widthPtr uintptr, heightPtr uintptr, interp uintptr) (r int32) { bp := tls.Alloc(32) defer tls.Free(32) var _objPtr, _objPtr1, _objPtr2, _objPtr3, data, dataObj, nsvgImage, v2, v4, v6, v8 uintptr var v1, v3, v5, v7 TTcl_Size var _ /* length at bp+0 */ TTcl_Size var _ /* ropts at bp+8 */ TRastOpts _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = _objPtr, _objPtr1, _objPtr2, _objPtr3, data, dataObj, nsvgImage, v1, v2, v3, v4, v5, v6, v7, v8 dataObj = libtcl9_0.XTcl_NewObj(tls) _CleanCache(tls, interp) if libtcl9_0.XTcl_ReadChars(tls, chan1, dataObj, int64(4096), 0) == int64(-libc.Int32FromInt32(1)) { /* in case of an error reading the file */ _objPtr = dataObj v2 = _objPtr v1 = *(*TTcl_Size)(unsafe.Pointer(v2)) *(*TTcl_Size)(unsafe.Pointer(v2))-- if v1 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr) } return 0 } data = libtcl9_0.XTcl_GetStringFromObj(tls, dataObj, bp) /* should have a '' in the first 4k */ if libc.Xmemchr(tls, data, int32('>'), libc.Uint64FromInt64(*(*TTcl_Size)(unsafe.Pointer(bp)))) == libc.UintptrFromInt32(0) || _MemMem(tls, data, libc.Uint64FromInt64(*(*TTcl_Size)(unsafe.Pointer(bp))), __ccgo_ts+42016, uint64(4)) == libc.UintptrFromInt32(0) { _objPtr1 = dataObj v4 = _objPtr1 v3 = *(*TTcl_Size)(unsafe.Pointer(v4)) *(*TTcl_Size)(unsafe.Pointer(v4))-- if v3 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr1) } return 0 } if !(libtcl9_0.XTcl_Eof(tls, chan1) != 0) && libtcl9_0.XTcl_ReadChars(tls, chan1, dataObj, int64(-libc.Int32FromInt32(1)), int32(1)) == int64(-libc.Int32FromInt32(1)) { /* in case of an error reading the file */ _objPtr2 = dataObj v6 = _objPtr2 v5 = *(*TTcl_Size)(unsafe.Pointer(v6)) *(*TTcl_Size)(unsafe.Pointer(v6))-- if v5 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr2) } return 0 } data = libtcl9_0.XTcl_GetStringFromObj(tls, dataObj, bp) nsvgImage = _ParseSVGWithOptions(tls, interp, data, *(*TTcl_Size)(unsafe.Pointer(bp)), formatObj, bp+8) _objPtr3 = dataObj v8 = _objPtr3 v7 = *(*TTcl_Size)(unsafe.Pointer(v8)) *(*TTcl_Size)(unsafe.Pointer(v8))-- if v7 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr3) } if nsvgImage != libc.UintptrFromInt32(0) { _GetScaleFromParameters(tls, nsvgImage, bp+8, widthPtr, heightPtr) if float64(*(*int32)(unsafe.Pointer(widthPtr))) <= float64(0) || float64(*(*int32)(unsafe.Pointer(heightPtr))) <= float64(0) { XnsvgDelete(tls, nsvgImage) return 0 } if !(_CacheSVG(tls, interp, chan1, formatObj, nsvgImage, bp+8) != 0) { XnsvgDelete(tls, nsvgImage) } return int32(1) } return 0 } /* *---------------------------------------------------------------------- * * FileReadSVG -- * * This function is called by the photo image type to read SVG format * data from a file and write it into a given photo image. * * Results: * A standard TCL completion code. If TCL_ERROR is returned then an error * message is left in the interp's result. * * Side effects: * The access position in file f is changed, and new data is added to the * image given by imageHandle. * *---------------------------------------------------------------------- */ func _FileReadSVG(tls *libc.TLS, interp uintptr, chan1 TTcl_Channel, dummy233 uintptr, formatObj uintptr, imageHandle TTk_PhotoHandle, destX int32, destY int32, width int32, height int32, srcX int32, srcY int32) (r int32) { bp := tls.Alloc(80) defer tls.Free(80) var _objPtr, _objPtr1, data, dataObj, nsvgImage, v2, v4 uintptr var v1, v3 TTcl_Size var _ /* length at bp+0 */ TTcl_Size var _ /* ropts at bp+8 */ TRastOpts _, _, _, _, _, _, _, _, _ = _objPtr, _objPtr1, data, dataObj, nsvgImage, v1, v2, v3, v4 nsvgImage = _GetCachedSVG(tls, interp, chan1, formatObj, bp+8) if nsvgImage == libc.UintptrFromInt32(0) { dataObj = libtcl9_0.XTcl_NewObj(tls) if libtcl9_0.XTcl_ReadChars(tls, chan1, dataObj, int64(-libc.Int32FromInt32(1)), 0) == int64(-libc.Int32FromInt32(1)) { /* in case of an error reading the file */ _objPtr = dataObj v2 = _objPtr v1 = *(*TTcl_Size)(unsafe.Pointer(v2)) *(*TTcl_Size)(unsafe.Pointer(v2))-- if v1 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr) } libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+42021, int64(-libc.Int32FromInt32(1)))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+32, __ccgo_ts+179, __ccgo_ts+29667, __ccgo_ts+42032, __ccgo_ts+42036, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) } data = libtcl9_0.XTcl_GetStringFromObj(tls, dataObj, bp) nsvgImage = _ParseSVGWithOptions(tls, interp, data, *(*TTcl_Size)(unsafe.Pointer(bp)), formatObj, bp+8) _objPtr1 = dataObj v4 = _objPtr1 v3 = *(*TTcl_Size)(unsafe.Pointer(v4)) *(*TTcl_Size)(unsafe.Pointer(v4))-- if v3 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr1) } if nsvgImage == libc.UintptrFromInt32(0) { return int32(TCL_ERROR) } } return _RasterizeSVG(tls, interp, imageHandle, nsvgImage, destX, destY, width, height, srcX, srcY, bp+8) } /* *---------------------------------------------------------------------- * * StringMatchSVG -- * * This function is invoked by the photo image type to see if a string * contains image data in SVG format. * * Results: * The return value is >0 if the file can be successfully parsed, * and 0 otherwise. * * Side effects: * The file is saved in the internal cache for further use. * *---------------------------------------------------------------------- */ func _StringMatchSVG(tls *libc.TLS, dataObj uintptr, formatObj uintptr, widthPtr uintptr, heightPtr uintptr, interp uintptr) (r int32) { bp := tls.Alloc(32) defer tls.Free(32) var data, nsvgImage uintptr var testLength TTcl_Size var v1 int64 var _ /* length at bp+0 */ TTcl_Size var _ /* ropts at bp+8 */ TRastOpts _, _, _, _ = data, nsvgImage, testLength, v1 _CleanCache(tls, interp) data = libtcl9_0.XTcl_GetStringFromObj(tls, dataObj, bp) /* should have a '' in the first 4k */ if *(*TTcl_Size)(unsafe.Pointer(bp)) > int64(4096) { v1 = int64(4096) } else { v1 = *(*TTcl_Size)(unsafe.Pointer(bp)) } testLength = v1 if libc.Xmemchr(tls, data, int32('>'), libc.Uint64FromInt64(testLength)) == libc.UintptrFromInt32(0) || _MemMem(tls, data, libc.Uint64FromInt64(testLength), __ccgo_ts+42016, uint64(4)) == libc.UintptrFromInt32(0) { return 0 } nsvgImage = _ParseSVGWithOptions(tls, interp, data, *(*TTcl_Size)(unsafe.Pointer(bp)), formatObj, bp+8) if nsvgImage != libc.UintptrFromInt32(0) { _GetScaleFromParameters(tls, nsvgImage, bp+8, widthPtr, heightPtr) if float64(*(*int32)(unsafe.Pointer(widthPtr))) <= float64(0) || float64(*(*int32)(unsafe.Pointer(heightPtr))) <= float64(0) { XnsvgDelete(tls, nsvgImage) return 0 } if !(_CacheSVG(tls, interp, dataObj, formatObj, nsvgImage, bp+8) != 0) { XnsvgDelete(tls, nsvgImage) } return int32(1) } return 0 } /* *---------------------------------------------------------------------- * * StringReadSVG -- * * This function is called by the photo image type to read SVG format * data from a string and write it into a given photo image. * * Results: * A standard TCL completion code. If TCL_ERROR is returned then an error * message is left in the interp's result. * * Side effects: * New data is added to the image given by imageHandle. * *---------------------------------------------------------------------- */ func _StringReadSVG(tls *libc.TLS, interp uintptr, dataObj uintptr, formatObj uintptr, imageHandle TTk_PhotoHandle, destX int32, destY int32, width int32, height int32, srcX int32, srcY int32) (r int32) { bp := tls.Alloc(32) defer tls.Free(32) var data, nsvgImage uintptr var _ /* length at bp+0 */ TTcl_Size var _ /* ropts at bp+8 */ TRastOpts _, _ = data, nsvgImage nsvgImage = _GetCachedSVG(tls, interp, dataObj, formatObj, bp+8) if nsvgImage == libc.UintptrFromInt32(0) { data = libtcl9_0.XTcl_GetStringFromObj(tls, dataObj, bp) nsvgImage = _ParseSVGWithOptions(tls, interp, data, *(*TTcl_Size)(unsafe.Pointer(bp)), formatObj, bp+8) } if nsvgImage == libc.UintptrFromInt32(0) { return int32(TCL_ERROR) } return _RasterizeSVG(tls, interp, imageHandle, nsvgImage, destX, destY, width, height, srcX, srcY, bp+8) } /* *---------------------------------------------------------------------- * * ParseSVGWithOptions -- * * This function is called to parse the given input string as SVG. * * Results: * Return a newly create NSVGimage on success, and NULL otherwise. * * Side effects: * *---------------------------------------------------------------------- */ func _ParseSVGWithOptions(tls *libc.TLS, interp uintptr, input uintptr, length TTcl_Size, formatObj uintptr, ropts uintptr) (r uintptr) { bp := tls.Alloc(80) defer tls.Free(80) var inputCopy, nsvgImage uintptr var parameterScaleSeen int32 var _ /* dpi at bp+16 */ float64 var _ /* objc at bp+8 */ TTcl_Size var _ /* objv at bp+0 */ uintptr var _ /* optIndex at bp+24 */ int32 _, _, _ = inputCopy, nsvgImage, parameterScaleSeen *(*uintptr)(unsafe.Pointer(bp)) = libc.UintptrFromInt32(0) *(*TTcl_Size)(unsafe.Pointer(bp + 8)) = 0 *(*float64)(unsafe.Pointer(bp + 16)) = float64(96) inputCopy = libc.UintptrFromInt32(0) parameterScaleSeen = 0 /* * The parser destroys the original input string, * therefore first duplicate. */ inputCopy = libtcl9_0.XTcl_AttemptAlloc(tls, libc.Uint64FromInt64(length+int64(1))) if inputCopy == libc.UintptrFromInt32(0) { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+42081, int64(-libc.Int32FromInt32(1)))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+40, __ccgo_ts+179, __ccgo_ts+29667, __ccgo_ts+42032, __ccgo_ts+42106, libc.UintptrFromInt32(0))) goto error } libc.Xmemcpy(tls, inputCopy, input, libc.Uint64FromInt64(length)) *(*uint8)(unsafe.Pointer(inputCopy + uintptr(length))) = uint8('\000') /* * Process elements of format specification as a list. */ (*TRastOpts)(unsafe.Pointer(ropts)).Fscale = float64(1) (*TRastOpts)(unsafe.Pointer(ropts)).FscaleToHeight = 0 (*TRastOpts)(unsafe.Pointer(ropts)).FscaleToWidth = 0 if formatObj != libc.UintptrFromInt32(0) && libtcl9_0.XTcl_ListObjGetElements(tls, interp, formatObj, bp+8, bp) != TCL_OK { goto error } for { if !(*(*TTcl_Size)(unsafe.Pointer(bp + 8)) > 0) { break } /* * Ignore the "svg" part of the format specification. */ if !(libc.Xstrcasecmp(tls, libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp)))), libc.UintptrFromInt32(0)), __ccgo_ts+5607) != 0) { goto _1 } if libtcl9_0.XTcl_GetIndexFromObjStruct(tls, interp, *(*uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp)))), uintptr(unsafe.Pointer(&_fmtOptions1)), libc.Int64FromUint64(libc.Uint64FromInt64(8)), __ccgo_ts+2689, libc.Int32FromInt32(0)|libc.Int32FromUint64(libc.Uint64FromInt64(4)< libc.Uint64FromInt32(libc.Int32FromInt32(INT_MAX)/libc.Int32FromInt32(4)) { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+42408, int64(-libc.Int32FromInt32(1)))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+56, __ccgo_ts+179, __ccgo_ts+29667, __ccgo_ts+42032, __ccgo_ts+42428, libc.UintptrFromInt32(0))) goto cleanRAST } imgData = libtcl9_0.XTcl_AttemptAlloc(tls, wh*uint64(4)) if imgData == libc.UintptrFromInt32(0) { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+42448, int64(-libc.Int32FromInt32(1)))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+56, __ccgo_ts+179, __ccgo_ts+29667, __ccgo_ts+42032, __ccgo_ts+42106, libc.UintptrFromInt32(0))) goto cleanRAST } XnsvgRasterize(tls, rast, nsvgImage, libc.Float32FromInt32(0), libc.Float32FromInt32(0), float32(scale), imgData, *(*int32)(unsafe.Pointer(bp)), *(*int32)(unsafe.Pointer(bp + 4)), *(*int32)(unsafe.Pointer(bp))*int32(4)) /* transfer the data to a photo block */ (*(*TTk_PhotoImageBlock)(unsafe.Pointer(bp + 8))).FpixelPtr = imgData (*(*TTk_PhotoImageBlock)(unsafe.Pointer(bp + 8))).Fwidth = *(*int32)(unsafe.Pointer(bp)) (*(*TTk_PhotoImageBlock)(unsafe.Pointer(bp + 8))).Fheight = *(*int32)(unsafe.Pointer(bp + 4)) (*(*TTk_PhotoImageBlock)(unsafe.Pointer(bp + 8))).Fpitch = *(*int32)(unsafe.Pointer(bp)) * int32(4) (*(*TTk_PhotoImageBlock)(unsafe.Pointer(bp + 8))).FpixelSize = int32(4) c = 0 for { if !(c <= int32(3)) { break } *(*int32)(unsafe.Pointer(bp + 8 + 24 + uintptr(c)*4)) = c goto _1 _1: ; c++ } if XTk_PhotoExpand(tls, interp, imageHandle, destX+width, destY+height) != TCL_OK { goto cleanRAST } if XTk_PhotoPutBlock(tls, interp, imageHandle, bp+8, destX, destY, width, height, int32(TK_PHOTO_COMPOSITE_SET)) != TCL_OK { goto cleanimg } libtcl9_0.XTcl_Free(tls, imgData) XnsvgDeleteRasterizer(tls, rast) XnsvgDelete(tls, nsvgImage) return TCL_OK goto cleanimg cleanimg: ; libtcl9_0.XTcl_Free(tls, imgData) goto cleanRAST cleanRAST: ; XnsvgDeleteRasterizer(tls, rast) goto cleanAST cleanAST: ; XnsvgDelete(tls, nsvgImage) return int32(TCL_ERROR) } /* *---------------------------------------------------------------------- * * GetScaleFromParameters -- * * Get the scale value from the already parsed parameters -scale, * -scaletoheight and -scaletowidth. * * The image width and height is also returned. * * Results: * The evaluated or configured scale value, or 0.0 on failure * * Side effects: * heightPtr and widthPtr are set to height and width of the image. * *---------------------------------------------------------------------- */ func _GetScaleFromParameters(tls *libc.TLS, nsvgImage uintptr, ropts uintptr, widthPtr uintptr, heightPtr uintptr) (r float64) { var height, width, v1 int32 var scale float64 _, _, _, _ = height, scale, width, v1 if float64((*TNSVGimage)(unsafe.Pointer(nsvgImage)).Fwidth) == float64(0) || float64((*TNSVGimage)(unsafe.Pointer(nsvgImage)).Fheight) == float64(0) { v1 = libc.Int32FromInt32(0) height = v1 width = v1 scale = float64(1) } else { if (*TRastOpts)(unsafe.Pointer(ropts)).FscaleToHeight > 0 { /* * Fixed height */ height = (*TRastOpts)(unsafe.Pointer(ropts)).FscaleToHeight scale = float64(float32(height) / (*TNSVGimage)(unsafe.Pointer(nsvgImage)).Fheight) width = int32(libc.Xceil(tls, float64(float64((*TNSVGimage)(unsafe.Pointer(nsvgImage)).Fwidth)*scale))) } else { if (*TRastOpts)(unsafe.Pointer(ropts)).FscaleToWidth > 0 { /* * Fixed width */ width = (*TRastOpts)(unsafe.Pointer(ropts)).FscaleToWidth scale = float64(float32(width) / (*TNSVGimage)(unsafe.Pointer(nsvgImage)).Fwidth) height = int32(libc.Xceil(tls, float64(float64((*TNSVGimage)(unsafe.Pointer(nsvgImage)).Fheight)*scale))) } else { /* * Scale factor */ scale = (*TRastOpts)(unsafe.Pointer(ropts)).Fscale width = int32(libc.Xceil(tls, float64(float64((*TNSVGimage)(unsafe.Pointer(nsvgImage)).Fwidth)*scale))) height = int32(libc.Xceil(tls, float64(float64((*TNSVGimage)(unsafe.Pointer(nsvgImage)).Fheight)*scale))) } } } *(*int32)(unsafe.Pointer(heightPtr)) = height *(*int32)(unsafe.Pointer(widthPtr)) = width return scale } /* *---------------------------------------------------------------------- * * GetCachePtr -- * * This function is called to get the per interpreter used * svg image cache. * * Results: * Return a pointer to the used cache. * * Side effects: * Initialize the cache on the first call. * *---------------------------------------------------------------------- */ func _GetCachePtr(tls *libc.TLS, interp uintptr) (r uintptr) { var cachePtr uintptr _ = cachePtr cachePtr = libtcl9_0.XTcl_GetAssocData(tls, interp, __ccgo_ts+42474, libc.UintptrFromInt32(0)) if cachePtr == libc.UintptrFromInt32(0) { cachePtr = libtcl9_0.XTcl_Alloc(tls, uint64(256)) (*TNSVGcache)(unsafe.Pointer(cachePtr)).FdataOrChan = libc.UintptrFromInt32(0) libtcl9_0.XTcl_DStringInit(tls, cachePtr+8) (*TNSVGcache)(unsafe.Pointer(cachePtr)).FnsvgImage = libc.UintptrFromInt32(0) libtcl9_0.XTcl_SetAssocData(tls, interp, __ccgo_ts+42474, __ccgo_fp(_FreeCache), cachePtr) } return cachePtr } /* *---------------------------------------------------------------------- * * CacheSVG -- * * Add the given svg image informations to the cache for further usage. * * Results: * Return 1 on success, and 0 otherwise. * * Side effects: * *---------------------------------------------------------------------- */ func _CacheSVG(tls *libc.TLS, interp uintptr, dataOrChan uintptr, formatObj uintptr, nsvgImage uintptr, ropts uintptr) (r int32) { bp := tls.Alloc(16) defer tls.Free(16) var cachePtr, data uintptr var _ /* length at bp+0 */ TTcl_Size _, _ = cachePtr, data cachePtr = _GetCachePtr(tls, interp) if cachePtr != libc.UintptrFromInt32(0) { (*TNSVGcache)(unsafe.Pointer(cachePtr)).FdataOrChan = dataOrChan if formatObj != libc.UintptrFromInt32(0) { data = libtcl9_0.XTcl_GetStringFromObj(tls, formatObj, bp) libtcl9_0.XTcl_DStringAppend(tls, cachePtr+8, data, *(*TTcl_Size)(unsafe.Pointer(bp))) } (*TNSVGcache)(unsafe.Pointer(cachePtr)).FnsvgImage = nsvgImage (*TNSVGcache)(unsafe.Pointer(cachePtr)).Fropts = *(*TRastOpts)(unsafe.Pointer(ropts)) return int32(1) } return 0 } /* *---------------------------------------------------------------------- * * GetCachedSVG -- * * Try to get the NSVGimage from the internal cache. * * Results: * Return the found NSVGimage on success, and NULL otherwise. * * Side effects: * Calls the CleanCache() function. * *---------------------------------------------------------------------- */ func _GetCachedSVG(tls *libc.TLS, interp uintptr, dataOrChan uintptr, formatObj uintptr, ropts uintptr) (r uintptr) { bp := tls.Alloc(16) defer tls.Free(16) var cachePtr, data, nsvgImage uintptr var _ /* length at bp+0 */ TTcl_Size _, _, _ = cachePtr, data, nsvgImage cachePtr = _GetCachePtr(tls, interp) nsvgImage = libc.UintptrFromInt32(0) if cachePtr != libc.UintptrFromInt32(0) && (*TNSVGcache)(unsafe.Pointer(cachePtr)).FnsvgImage != libc.UintptrFromInt32(0) && (*TNSVGcache)(unsafe.Pointer(cachePtr)).FdataOrChan == dataOrChan { if formatObj != libc.UintptrFromInt32(0) { data = libtcl9_0.XTcl_GetStringFromObj(tls, formatObj, bp) if libc.Xstrcmp(tls, data, (*TTcl_DString)(unsafe.Pointer(cachePtr+8)).Fstring1) == 0 { nsvgImage = (*TNSVGcache)(unsafe.Pointer(cachePtr)).FnsvgImage *(*TRastOpts)(unsafe.Pointer(ropts)) = (*TNSVGcache)(unsafe.Pointer(cachePtr)).Fropts (*TNSVGcache)(unsafe.Pointer(cachePtr)).FnsvgImage = libc.UintptrFromInt32(0) } } else { if (*TTcl_DString)(unsafe.Pointer(cachePtr+8)).Flength == 0 { nsvgImage = (*TNSVGcache)(unsafe.Pointer(cachePtr)).FnsvgImage *(*TRastOpts)(unsafe.Pointer(ropts)) = (*TNSVGcache)(unsafe.Pointer(cachePtr)).Fropts (*TNSVGcache)(unsafe.Pointer(cachePtr)).FnsvgImage = libc.UintptrFromInt32(0) } } } _CleanCache(tls, interp) return nsvgImage } /* *---------------------------------------------------------------------- * * CleanCache -- * * Reset the cache and delete the saved image in it. * * Results: * * Side effects: * *---------------------------------------------------------------------- */ func _CleanCache(tls *libc.TLS, interp uintptr) { var cachePtr uintptr _ = cachePtr cachePtr = _GetCachePtr(tls, interp) if cachePtr != libc.UintptrFromInt32(0) { (*TNSVGcache)(unsafe.Pointer(cachePtr)).FdataOrChan = libc.UintptrFromInt32(0) libtcl9_0.XTcl_DStringSetLength(tls, cachePtr+8, 0) if (*TNSVGcache)(unsafe.Pointer(cachePtr)).FnsvgImage != libc.UintptrFromInt32(0) { XnsvgDelete(tls, (*TNSVGcache)(unsafe.Pointer(cachePtr)).FnsvgImage) (*TNSVGcache)(unsafe.Pointer(cachePtr)).FnsvgImage = libc.UintptrFromInt32(0) } } } /* *---------------------------------------------------------------------- * * FreeCache -- * * This function is called to clean up the internal cache data. * * Results: * * Side effects: * Existing image data in the cache and the cache will be deleted. * *---------------------------------------------------------------------- */ func _FreeCache(tls *libc.TLS, clientData uintptr, dummy866 uintptr) { var cachePtr uintptr _ = cachePtr cachePtr = clientData libtcl9_0.XTcl_DStringFree(tls, cachePtr+8) if (*TNSVGcache)(unsafe.Pointer(cachePtr)).FnsvgImage != libc.UintptrFromInt32(0) { XnsvgDelete(tls, (*TNSVGcache)(unsafe.Pointer(cachePtr)).FnsvgImage) } libtcl9_0.XTcl_Free(tls, cachePtr) } type TNSVGactiveEdge1 = struct { Fx int32 Fdx int32 Fey float32 Fdir int32 Fnext uintptr } const BUTTON_DOWN = 8 const COUNT_CHARS = 0 const COUNT_DISPLAY = 2 const COUNT_DISPLAY_CHARS = 2 const COUNT_DISPLAY_INDICES = 3 const COUNT_INDICES = 1 const DESTROYED = 128 const GOT_FOCUS8 = 4 const GOT_SELECTION1 = 1 const INSERT_ON = 2 const LOTSA_TAGS = 1000 const LOTS_OF_MATCHES = 20 const NEED_REPICK = 32 const OPTIONS_FREED = 64 const PIXEL_CLIENTS = 5 const TK_DUMP_ALL = 31 const TK_DUMP_IMG = 16 const TK_DUMP_MARK = 2 const TK_DUMP_TAG = 4 const TK_DUMP_TEXT = 1 const TK_DUMP_WIN = 8 const TK_END_OF_TEXT = 1000000 const TK_POS_CHARS = 30 const TK_TAG_AFFECTS_DISPLAY = 1 const TK_TAG_JUSTIFY = 4 const TK_TAG_OFFSET = 16 const TK_TAG_UNDERLINE = 2 const TK_TEXT_LINE_GEOMETRY = 1 const TK_TEXT_LINE_RANGE = 2 const TK_TEXT_NOPIXELADJUST = -2 const TK_TEXT_PICKPLACE = -1 const UPDATE_SCROLLBARS1 = 16 type TTkText1 = struct { FsharedTextPtr uintptr Fnext uintptr Fstart uintptr Fend uintptr FpixelReference int32 FabortSelections int32 Ftkwin TTk_Window Fdisplay uintptr Finterp uintptr FwidgetCmd TTcl_Command Fstate TTkTextState Fborder TTk_3DBorder FborderWidthObj uintptr FpadXObj uintptr FpadYObj uintptr Frelief int32 FhighlightWidthObj uintptr FhighlightBgColorPtr uintptr FhighlightColorPtr uintptr Fcursor TTk_Cursor FfgColor uintptr Ftkfont TTk_Font FcharWidth int32 FcharHeight int32 Fspacing1Obj uintptr Fspacing2Obj uintptr Fspacing3Obj uintptr FtabOptionObj uintptr FtabArrayPtr uintptr FtabStyle TTkTextTabStyle FwrapMode TTkWrapMode Fwidth int32 FheightObj uintptr FsetGrid int32 FprevWidth int32 FprevHeight int32 FtopIndex TTkTextIndex FdInfoPtr uintptr FselTagPtr uintptr FselBorder TTk_3DBorder FinactiveSelBorder TTk_3DBorder FselBorderWidthObj uintptr FselFgColorPtr uintptr FexportSelection int32 FselIndex TTkTextIndex FinsertMarkPtr uintptr FinsertBorder TTk_3DBorder FinsertWidthObj uintptr FinsertBorderWidthObj uintptr FinsertUnfocussed TTkTextInsertUnfocussed FinsertOnTime int32 FinsertOffTime int32 FinsertBlinkHandler TTcl_TimerToken FcurrentMarkPtr uintptr FpickEvent TXEvent FnumCurTags int32 FcurTagArrayPtr uintptr FtakeFocusObj uintptr FxScrollCmdObj uintptr FyScrollCmdObj uintptr Fflags int32 FoptionTable TTk_OptionTable FrefCount TTcl_Size FinsertCursorType int32 Fundo int32 FmaxUndo int32 FautoSeparators int32 FafterSyncCmd uintptr } const TK_TEXT_STATE_DISABLED = 0 const TK_TEXT_STATE_NORMAL = 1 const TK_TEXT_TABSTYLE_NULL = -1 const TK_TEXT_TABSTYLE_TABULAR = 0 const TK_TEXT_TABSTYLE_WORDPROCESSOR = 1 const TEXT_WRAPMODE_NULL = -1 const TEXT_WRAPMODE_CHAR = 0 const TEXT_WRAPMODE_NONE = 1 const TEXT_WRAPMODE_WORD = 2 const TK_TEXT_INSERT_NOFOCUS_HOLLOW = 0 const TK_TEXT_INSERT_NOFOCUS_NONE = 1 const TK_TEXT_INSERT_NOFOCUS_SOLID = 2 type TTkTextDispChunk1 = struct { Fx int32 FnextPtr uintptr FstylePtr uintptr FdisplayProc uintptr FundisplayProc uintptr FmeasureProc uintptr FbboxProc uintptr FnumBytes TTcl_Size FminAscent int32 FminDescent int32 FminHeight int32 Fwidth int32 FbreakIndex TTcl_Size FclientData uintptr } type TTkTextIndex1 = struct { Ftree TTkTextBTree FlinePtr uintptr FbyteIndex TTcl_Size FtextPtr uintptr } type TTkTextSegment1 = struct { FtypePtr uintptr FnextPtr uintptr Fsize TTcl_Size Fbody struct { Fmark [0]TTkTextMark Few [0]TTkTextEmbWindow Fei [0]TTkTextEmbImage Ftoggle TTkTextToggle F__ccgo_pad5 [64]byte } } type TTkSharedText1 = struct { FrefCount TTcl_Size Ftree TTkTextBTree FtagTable TTcl_HashTable FnumTags TTcl_Size FmarkTable TTcl_HashTable FwindowTable TTcl_HashTable FimageTable TTcl_HashTable FbindingTable TTk_BindingTable FstateEpoch TTcl_Size FimageCount int32 FundoStack uintptr Fundo int32 FmaxUndo int32 FautoSeparators int32 FisDirty int32 FdirtyMode TTkTextDirtyMode FlastEditMode TTkTextEditMode Fpeers uintptr FundoMarkId TTcl_Size } const TK_TEXT_DIRTY_NORMAL = 0 const TK_TEXT_DIRTY_UNDO = 1 const TK_TEXT_DIRTY_REDO = 2 const TK_TEXT_DIRTY_FIXED = 3 const TK_TEXT_EDIT_INSERT = 0 const TK_TEXT_EDIT_DELETE = 1 const TK_TEXT_EDIT_REPLACE = 2 const TK_TEXT_EDIT_OTHER = 3 type TTkTextLine = struct { FparentPtr uintptr FnextPtr uintptr FsegPtr uintptr Fpixels uintptr } type TTkTextToggle = struct { FtagPtr uintptr FinNodeCounts int32 } type TTkTextMark = struct { FtextPtr uintptr FlinePtr uintptr FhPtr uintptr } type TTkTextEmbWindowClient = struct { FtextPtr uintptr Ftkwin TTk_Window FchunkCount int32 Fdisplayed int32 Fparent uintptr Fnext uintptr } type TTkAlignMode = int32 const TK_ALIGN_BASELINE = 0 const TK_ALIGN_BOTTOM = 1 const TK_ALIGN_CENTER = 2 const TK_ALIGN_TOP = 3 type TTkTextEmbWindow = struct { FsharedTextPtr uintptr Ftkwin TTk_Window FlinePtr uintptr FcreateObj uintptr FpadXObj uintptr FpadYObj uintptr Falign TTkAlignMode Fstretch int32 FoptionTable TTk_OptionTable Fclients uintptr } type TTkTextEmbImage = struct { FsharedTextPtr uintptr FlinePtr uintptr FimageObj uintptr FimageNameObj uintptr Fname uintptr Fimage TTk_Image FpadXObj uintptr FpadYObj uintptr Falign TTkAlignMode FchunkCount int32 FoptionTable TTk_OptionTable } type TTkTextSegment = struct { FtypePtr uintptr FnextPtr uintptr Fsize TTcl_Size Fbody struct { Fmark [0]TTkTextMark Few [0]TTkTextEmbWindow Fei [0]TTkTextEmbImage Ftoggle TTkTextToggle F__ccgo_pad5 [64]byte } } type TTkTextIndex = struct { Ftree TTkTextBTree FlinePtr uintptr FbyteIndex TTcl_Size FtextPtr uintptr } type TTkTextDispChunk = struct { Fx int32 FnextPtr uintptr FstylePtr uintptr FdisplayProc uintptr FundisplayProc uintptr FmeasureProc uintptr FbboxProc uintptr FnumBytes TTcl_Size FminAscent int32 FminDescent int32 FminHeight int32 Fwidth int32 FbreakIndex TTcl_Size FclientData uintptr } type TTkWrapMode = int32 type TTkTextTabStyle = int32 type TTkTextTag = struct { Fname uintptr FtextPtr uintptr Fpriority TTcl_Size FtagRootPtr uintptr FtoggleCount TTcl_Size Fborder TTk_3DBorder FborderWidthObj uintptr Frelief int32 FbgStipple TPixmap FfgColor uintptr Ftkfont TTk_Font FfgStipple TPixmap Fjustify TTk_Justify FlMargin1Obj uintptr FlMargin1 int32 FlMargin2Obj uintptr FlMargin2 int32 FlMarginColor TTk_3DBorder FoffsetObj uintptr Foffset int32 Foverstrike int32 FoverstrikeColor uintptr FrMarginObj uintptr FrMargin int32 FrMarginColor TTk_3DBorder FselBorder TTk_3DBorder FselFgColor uintptr Fspacing1Obj uintptr Fspacing2Obj uintptr Fspacing3Obj uintptr FtabStringPtr uintptr FtabArrayPtr uintptr FtabStyle TTkTextTabStyle Funderline int32 FunderlineColor uintptr FwrapMode TTkWrapMode Felide int32 FaffectsDisplay int32 FoptionTable TTk_OptionTable FaffectsDisplayGeometry int32 } type TTkTextSearch = struct { FcurIndex TTkTextIndex FsegPtr uintptr FnextPtr uintptr FlastPtr uintptr FtagPtr uintptr FlinesLeft int32 FallTags int32 } type TTkTextTabAlign = int32 const LEFT1 = 0 const RIGHT1 = 1 const CENTER = 2 const NUMERIC = 3 type TTkTextTab = struct { Flocation int32 Falignment TTkTextTabAlign } type TTkTextTabArray = struct { FnumTabs int32 FlastTab float64 FtabIncrement float64 } type TTkTextEditMode = int32 type TTkTextDirtyMode = int32 type TTkTextState = int32 type TTkSharedText = struct { FrefCount TTcl_Size Ftree TTkTextBTree FtagTable TTcl_HashTable FnumTags TTcl_Size FmarkTable TTcl_HashTable FwindowTable TTcl_HashTable FimageTable TTcl_HashTable FbindingTable TTk_BindingTable FstateEpoch TTcl_Size FimageCount int32 FundoStack uintptr Fundo int32 FmaxUndo int32 FautoSeparators int32 FisDirty int32 FdirtyMode TTkTextDirtyMode FlastEditMode TTkTextEditMode Fpeers uintptr FundoMarkId TTcl_Size } type TTkTextInsertUnfocussed = int32 type TTkText = struct { FsharedTextPtr uintptr Fnext uintptr Fstart uintptr Fend uintptr FpixelReference int32 FabortSelections int32 Ftkwin TTk_Window Fdisplay uintptr Finterp uintptr FwidgetCmd TTcl_Command Fstate TTkTextState Fborder TTk_3DBorder FborderWidthObj uintptr FpadXObj uintptr FpadYObj uintptr Frelief int32 FhighlightWidthObj uintptr FhighlightBgColorPtr uintptr FhighlightColorPtr uintptr Fcursor TTk_Cursor FfgColor uintptr Ftkfont TTk_Font FcharWidth int32 FcharHeight int32 Fspacing1Obj uintptr Fspacing2Obj uintptr Fspacing3Obj uintptr FtabOptionObj uintptr FtabArrayPtr uintptr FtabStyle TTkTextTabStyle FwrapMode TTkWrapMode Fwidth int32 FheightObj uintptr FsetGrid int32 FprevWidth int32 FprevHeight int32 FtopIndex TTkTextIndex FdInfoPtr uintptr FselTagPtr uintptr FselBorder TTk_3DBorder FinactiveSelBorder TTk_3DBorder FselBorderWidthObj uintptr FselFgColorPtr uintptr FexportSelection int32 FselIndex TTkTextIndex FinsertMarkPtr uintptr FinsertBorder TTk_3DBorder FinsertWidthObj uintptr FinsertBorderWidthObj uintptr FinsertUnfocussed TTkTextInsertUnfocussed FinsertOnTime int32 FinsertOffTime int32 FinsertBlinkHandler TTcl_TimerToken FcurrentMarkPtr uintptr FpickEvent TXEvent FnumCurTags int32 FcurTagArrayPtr uintptr FtakeFocusObj uintptr FxScrollCmdObj uintptr FyScrollCmdObj uintptr Fflags int32 FoptionTable TTk_OptionTable FrefCount TTcl_Size FinsertCursorType int32 Fundo int32 FmaxUndo int32 FautoSeparators int32 FafterSyncCmd uintptr } type TTk_SegType = struct { Fname uintptr FleftGravity int32 FsplitProc uintptr FdeleteProc uintptr FcleanupProc uintptr FlineChangeProc uintptr FlayoutProc uintptr FcheckProc uintptr } type TTkTextCountType = int32 type TTkTextElideInfo = struct { FnumTags TTcl_Size Felide int32 FelidePriority TTcl_Size FsegPtr uintptr FsegOffset int32 FdeftagCnts [1000]int32 FdeftagPtrs [1000]uintptr FtagCnts uintptr FtagPtrs uintptr } type TTkTextInvalidateAction = int32 const TK_TEXT_INVALIDATE_ONLY = 0 const TK_TEXT_INVALIDATE_INSERT = 1 const TK_TEXT_INVALIDATE_DELETE = 2 /* * The 'TkTextInsertUnfocussed' enum in tkText.h is used to define a type for * the -insertunfocussed option of the Text widget. These values are used as * indice into the string table below. */ var _insertUnfocussedStrings = [4]uintptr{ 0: __ccgo_ts + 42511, 1: __ccgo_ts + 8223, 2: __ccgo_ts + 25, 3: libc.UintptrFromInt32(0), } var _lineOption = TTk_ObjCustomOption{ Fname: __ccgo_ts + 29673, } func init() { p := unsafe.Pointer(&_lineOption) *(*uintptr)(unsafe.Add(p, 8)) = __ccgo_fp(_SetLineStartEnd) *(*uintptr)(unsafe.Add(p, 16)) = __ccgo_fp(_GetLineStartEnd) *(*uintptr)(unsafe.Add(p, 24)) = __ccgo_fp(_RestoreLineStartEnd) } /* * Information used to parse text configuration options: */ var _optionSpecs8 = [45]TTk_OptionSpec{ 0: { FoptionName: __ccgo_ts + 42518, FdbName: __ccgo_ts + 42534, FdbClass: __ccgo_ts + 42549, FdefValue: __ccgo_ts + 14538, FobjOffset: int64(-libc.Int32FromInt32(1)), FinternalOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 708)), Fflags: libc.Int32FromInt32(1) << libc.Int32FromInt32(3), }, 1: { Ftype1: int32(TK_OPTION_BORDER), FoptionName: __ccgo_ts + 19898, FdbName: __ccgo_ts + 19910, FdbClass: __ccgo_ts + 19872, FdefValue: __ccgo_ts + 19883, FobjOffset: int64(-libc.Int32FromInt32(1)), FinternalOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 80)), FclientData: __ccgo_ts + 19883, }, 2: { Ftype1: int32(TK_OPTION_SYNONYM), FoptionName: __ccgo_ts + 19929, FinternalOffset: int64(-libc.Int32FromInt32(1)), FclientData: __ccgo_ts + 2814, FtypeMask: libc.Int32FromInt32(1) << libc.Int32FromInt32(0), }, 3: { Ftype1: int32(TK_OPTION_SYNONYM), FoptionName: __ccgo_ts + 19933, FinternalOffset: int64(-libc.Int32FromInt32(1)), FclientData: __ccgo_ts + 19898, }, 4: { FoptionName: __ccgo_ts + 42564, FdbName: __ccgo_ts + 42577, FdbClass: __ccgo_ts + 42589, FdefValue: __ccgo_ts + 10533, FobjOffset: int64(-libc.Int32FromInt32(1)), FinternalOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 696)), }, 5: { Ftype1: int32(TK_OPTION_PIXELS), FoptionName: __ccgo_ts + 2814, FdbName: __ccgo_ts + 19952, FdbClass: __ccgo_ts + 19964, FdefValue: __ccgo_ts + 14538, FobjOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 88)), FinternalOffset: int64(-libc.Int32FromInt32(1)), FtypeMask: libc.Int32FromInt32(1) << libc.Int32FromInt32(0), }, 6: { Ftype1: int32(TK_OPTION_CURSOR), FoptionName: __ccgo_ts + 4638, FdbName: __ccgo_ts + 4646, FdbClass: __ccgo_ts + 4653, FdefValue: __ccgo_ts + 21100, FobjOffset: int64(-libc.Int32FromInt32(1)), FinternalOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 144)), Fflags: int32(TCL_NULL_OK), }, 7: { Ftype1: int32(TK_OPTION_CUSTOM), FoptionName: __ccgo_ts + 42601, FobjOffset: int64(-libc.Int32FromInt32(1)), FinternalOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 24)), Fflags: int32(TCL_NULL_OK), FclientData: uintptr(unsafe.Pointer(&_lineOption)), FtypeMask: libc.Int32FromInt32(1) << libc.Int32FromInt32(1), }, 8: { FoptionName: __ccgo_ts + 21164, FdbName: __ccgo_ts + 21181, FdbClass: __ccgo_ts + 21197, FdefValue: __ccgo_ts + 14538, FobjOffset: int64(-libc.Int32FromInt32(1)), FinternalOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 336)), }, 9: { Ftype1: int32(TK_OPTION_SYNONYM), FoptionName: __ccgo_ts + 20070, FdbName: __ccgo_ts + 20074, FinternalOffset: int64(-libc.Int32FromInt32(1)), FclientData: __ccgo_ts + 20085, }, 10: { Ftype1: int32(TK_OPTION_FONT), FoptionName: __ccgo_ts + 20097, FdbName: __ccgo_ts + 9358, FdbClass: __ccgo_ts + 20103, FdefValue: __ccgo_ts + 42610, FobjOffset: int64(-libc.Int32FromInt32(1)), FinternalOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 160)), FtypeMask: libc.Int32FromInt32(1) << libc.Int32FromInt32(0), }, 11: { Ftype1: int32(TK_OPTION_COLOR), FoptionName: __ccgo_ts + 20085, FdbName: __ccgo_ts + 20074, FdbClass: __ccgo_ts + 19810, FdefValue: __ccgo_ts + 19829, FobjOffset: int64(-libc.Int32FromInt32(1)), FinternalOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 152)), }, 12: { Ftype1: int32(TK_OPTION_PIXELS), FoptionName: __ccgo_ts + 2870, FdbName: __ccgo_ts + 6172, FdbClass: __ccgo_ts + 20122, FdefValue: __ccgo_ts + 42622, FobjOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 232)), FinternalOffset: int64(-libc.Int32FromInt32(1)), }, 13: { Ftype1: int32(TK_OPTION_COLOR), FoptionName: __ccgo_ts + 20129, FdbName: __ccgo_ts + 20150, FdbClass: __ccgo_ts + 20170, FdefValue: __ccgo_ts + 19921, FobjOffset: int64(-libc.Int32FromInt32(1)), FinternalOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 128)), }, 14: { Ftype1: int32(TK_OPTION_COLOR), FoptionName: __ccgo_ts + 20190, FdbName: __ccgo_ts + 20206, FdbClass: __ccgo_ts + 20221, FdefValue: __ccgo_ts + 19829, FobjOffset: int64(-libc.Int32FromInt32(1)), FinternalOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 136)), }, 15: { Ftype1: int32(TK_OPTION_PIXELS), FoptionName: __ccgo_ts + 20236, FdbName: __ccgo_ts + 20256, FdbClass: __ccgo_ts + 20275, FdefValue: __ccgo_ts + 14538, FobjOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 120)), FinternalOffset: int64(-libc.Int32FromInt32(1)), FtypeMask: libc.Int32FromInt32(1) << libc.Int32FromInt32(0), }, 16: { Ftype1: int32(TK_OPTION_BORDER), FoptionName: __ccgo_ts + 42625, FdbName: __ccgo_ts + 42651, FdbClass: __ccgo_ts + 19810, FdefValue: __ccgo_ts + 21673, FobjOffset: int64(-libc.Int32FromInt32(1)), FinternalOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 312)), Fflags: int32(TCL_NULL_OK), FclientData: __ccgo_ts + 19829, }, 17: { Ftype1: int32(TK_OPTION_BORDER), FoptionName: __ccgo_ts + 21224, FdbName: __ccgo_ts + 21242, FdbClass: __ccgo_ts + 19810, FdefValue: __ccgo_ts + 19829, FobjOffset: int64(-libc.Int32FromInt32(1)), FinternalOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 384)), }, 18: { Ftype1: int32(TK_OPTION_PIXELS), FoptionName: __ccgo_ts + 21259, FdbName: __ccgo_ts + 21278, FdbClass: __ccgo_ts + 19964, FdefValue: __ccgo_ts + 10533, FobjOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 400)), FinternalOffset: int64(-libc.Int32FromInt32(1)), FclientData: __ccgo_ts + 10533, }, 19: { Ftype1: int32(TK_OPTION_INT), FoptionName: __ccgo_ts + 21296, FdbName: __ccgo_ts + 21311, FdbClass: __ccgo_ts + 21325, FdefValue: __ccgo_ts + 21333, FobjOffset: int64(-libc.Int32FromInt32(1)), FinternalOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 416)), }, 20: { Ftype1: int32(TK_OPTION_INT), FoptionName: __ccgo_ts + 21337, FdbName: __ccgo_ts + 21351, FdbClass: __ccgo_ts + 21364, FdefValue: __ccgo_ts + 21371, FobjOffset: int64(-libc.Int32FromInt32(1)), FinternalOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 412)), }, 21: { Ftype1: int32(TK_OPTION_STRING_TABLE), FoptionName: __ccgo_ts + 42676, FdbName: __ccgo_ts + 42694, FdbClass: __ccgo_ts + 42711, FdefValue: __ccgo_ts + 8223, FobjOffset: int64(-libc.Int32FromInt32(1)), FinternalOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 408)), FclientData: uintptr(unsafe.Pointer(&_insertUnfocussedStrings)), }, 22: { Ftype1: int32(TK_OPTION_PIXELS), FoptionName: __ccgo_ts + 21375, FdbName: __ccgo_ts + 21388, FdbClass: __ccgo_ts + 21400, FdefValue: __ccgo_ts + 21412, FobjOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 392)), FinternalOffset: int64(-libc.Int32FromInt32(1)), }, 23: { Ftype1: int32(TK_OPTION_INT), FoptionName: __ccgo_ts + 42728, FdbName: __ccgo_ts + 42737, FdbClass: __ccgo_ts + 42745, FdefValue: __ccgo_ts + 10533, FobjOffset: int64(-libc.Int32FromInt32(1)), FinternalOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 704)), Fflags: libc.Int32FromInt32(1) << libc.Int32FromInt32(3), }, 24: { Ftype1: int32(TK_OPTION_PIXELS), FoptionName: __ccgo_ts + 12320, FdbName: __ccgo_ts + 20332, FdbClass: __ccgo_ts + 20337, FdefValue: __ccgo_ts + 14538, FobjOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 96)), FinternalOffset: int64(-libc.Int32FromInt32(1)), FtypeMask: libc.Int32FromInt32(1) << libc.Int32FromInt32(0), }, 25: { Ftype1: int32(TK_OPTION_PIXELS), FoptionName: __ccgo_ts + 12326, FdbName: __ccgo_ts + 20341, FdbClass: __ccgo_ts + 20337, FdefValue: __ccgo_ts + 14538, FobjOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 104)), FinternalOffset: int64(-libc.Int32FromInt32(1)), }, 26: { Ftype1: int32(TK_OPTION_RELIEF), FoptionName: __ccgo_ts + 20346, FdbName: __ccgo_ts + 82, FdbClass: __ccgo_ts + 20354, FdefValue: __ccgo_ts + 31, FobjOffset: int64(-libc.Int32FromInt32(1)), FinternalOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 112)), }, 27: { Ftype1: int32(TK_OPTION_BORDER), FoptionName: __ccgo_ts + 21638, FdbName: __ccgo_ts + 21656, FdbClass: __ccgo_ts + 19810, FdefValue: __ccgo_ts + 21673, FobjOffset: int64(-libc.Int32FromInt32(1)), FinternalOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 304)), FclientData: __ccgo_ts + 19829, }, 28: { Ftype1: int32(TK_OPTION_PIXELS), FoptionName: __ccgo_ts + 21681, FdbName: __ccgo_ts + 21700, FdbClass: __ccgo_ts + 19964, FdefValue: __ccgo_ts + 10533, FobjOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 320)), FinternalOffset: int64(-libc.Int32FromInt32(1)), FclientData: __ccgo_ts + 10533, }, 29: { Ftype1: int32(TK_OPTION_COLOR), FoptionName: __ccgo_ts + 21718, FdbName: __ccgo_ts + 21736, FdbClass: __ccgo_ts + 19872, FdefValue: __ccgo_ts + 19829, FobjOffset: int64(-libc.Int32FromInt32(1)), FinternalOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 328)), Fflags: int32(TCL_NULL_OK), FclientData: __ccgo_ts + 19883, }, 30: { FoptionName: __ccgo_ts + 23546, FdbName: __ccgo_ts + 23555, FdbClass: __ccgo_ts + 23563, FdefValue: __ccgo_ts + 10533, FobjOffset: int64(-libc.Int32FromInt32(1)), FinternalOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 240)), }, 31: { Ftype1: int32(TK_OPTION_PIXELS), FoptionName: __ccgo_ts + 42753, FdbName: __ccgo_ts + 42763, FdbClass: __ccgo_ts + 42772, FdefValue: __ccgo_ts + 10533, FobjOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 176)), FinternalOffset: int64(-libc.Int32FromInt32(1)), FtypeMask: libc.Int32FromInt32(1) << libc.Int32FromInt32(0), }, 32: { Ftype1: int32(TK_OPTION_PIXELS), FoptionName: __ccgo_ts + 42780, FdbName: __ccgo_ts + 42790, FdbClass: __ccgo_ts + 42772, FdefValue: __ccgo_ts + 10533, FobjOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 184)), FinternalOffset: int64(-libc.Int32FromInt32(1)), FtypeMask: libc.Int32FromInt32(1) << libc.Int32FromInt32(0), }, 33: { Ftype1: int32(TK_OPTION_PIXELS), FoptionName: __ccgo_ts + 42799, FdbName: __ccgo_ts + 42809, FdbClass: __ccgo_ts + 42772, FdefValue: __ccgo_ts + 10533, FobjOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 192)), FinternalOffset: int64(-libc.Int32FromInt32(1)), FtypeMask: libc.Int32FromInt32(1) << libc.Int32FromInt32(0), }, 34: { Ftype1: int32(TK_OPTION_CUSTOM), FoptionName: __ccgo_ts + 42818, FobjOffset: int64(-libc.Int32FromInt32(1)), FinternalOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 16)), Fflags: int32(TCL_NULL_OK), FclientData: uintptr(unsafe.Pointer(&_lineOption)), FtypeMask: libc.Int32FromInt32(1) << libc.Int32FromInt32(1), }, 35: { Ftype1: int32(TK_OPTION_STRING_TABLE), FoptionName: __ccgo_ts + 2957, FdbName: __ccgo_ts + 16747, FdbClass: __ccgo_ts + 20361, FdefValue: __ccgo_ts + 9363, FobjOffset: int64(-libc.Int32FromInt32(1)), FinternalOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 72)), FclientData: uintptr(unsafe.Pointer(&XtkStateStrings)) + 1*8, }, 36: { Ftype1: int32(TK_OPTION_STRING), FoptionName: __ccgo_ts + 42829, FdbName: __ccgo_ts + 42835, FdbClass: __ccgo_ts + 42840, FdefValue: __ccgo_ts + 195, FobjOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 200)), FinternalOffset: int64(-libc.Int32FromInt32(1)), Fflags: int32(TCL_NULL_OK), FtypeMask: libc.Int32FromInt32(1) << libc.Int32FromInt32(0), }, 37: { Ftype1: int32(TK_OPTION_STRING_TABLE), FoptionName: __ccgo_ts + 42845, FdbName: __ccgo_ts + 42855, FdbClass: __ccgo_ts + 42864, FdefValue: __ccgo_ts + 42489, FobjOffset: int64(-libc.Int32FromInt32(1)), FinternalOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 216)), FclientData: uintptr(unsafe.Pointer(&XtkTextTabStyleStrings)), FtypeMask: libc.Int32FromInt32(1) << libc.Int32FromInt32(0), }, 38: { Ftype1: int32(TK_OPTION_STRING), FoptionName: __ccgo_ts + 20367, FdbName: __ccgo_ts + 20378, FdbClass: __ccgo_ts + 20388, FobjOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 648)), FinternalOffset: int64(-libc.Int32FromInt32(1)), Fflags: int32(TCL_NULL_OK), }, 39: { FoptionName: __ccgo_ts + 42873, FdbName: __ccgo_ts + 42879, FdbClass: __ccgo_ts + 42884, FdefValue: __ccgo_ts + 10533, FobjOffset: int64(-libc.Int32FromInt32(1)), FinternalOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 700)), Fflags: libc.Int32FromInt32(1) << libc.Int32FromInt32(3), }, 40: { Ftype1: int32(TK_OPTION_INT), FoptionName: __ccgo_ts + 2987, FdbName: __ccgo_ts + 6446, FdbClass: __ccgo_ts + 20455, FdefValue: __ccgo_ts + 42889, FobjOffset: int64(-libc.Int32FromInt32(1)), FinternalOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 224)), FtypeMask: libc.Int32FromInt32(1) << libc.Int32FromInt32(0), }, 41: { Ftype1: int32(TK_OPTION_STRING_TABLE), FoptionName: __ccgo_ts + 22128, FdbName: __ccgo_ts + 22134, FdbClass: __ccgo_ts + 22139, FdefValue: __ccgo_ts + 33478, FobjOffset: int64(-libc.Int32FromInt32(1)), FinternalOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 220)), FclientData: uintptr(unsafe.Pointer(&XtkTextWrapStrings)), FtypeMask: libc.Int32FromInt32(1) << libc.Int32FromInt32(0), }, 42: { Ftype1: int32(TK_OPTION_STRING), FoptionName: __ccgo_ts + 21850, FdbName: __ccgo_ts + 21866, FdbClass: __ccgo_ts + 21881, FdefValue: __ccgo_ts + 195, FobjOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 656)), FinternalOffset: int64(-libc.Int32FromInt32(1)), Fflags: int32(TCL_NULL_OK), }, 43: { Ftype1: int32(TK_OPTION_STRING), FoptionName: __ccgo_ts + 23571, FdbName: __ccgo_ts + 23587, FdbClass: __ccgo_ts + 21881, FdefValue: __ccgo_ts + 195, FobjOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 664)), FinternalOffset: int64(-libc.Int32FromInt32(1)), Fflags: int32(TCL_NULL_OK), }, 44: { Ftype1: int32(TK_OPTION_END), }, } /* * These three typedefs, the structure and the SearchPerform, SearchCore * functions below are used for line-based searches of the text widget, and, * in particular, to handle multi-line matching even though the text widget is * a single-line based data structure. They are completely abstracted away * from the Text widget internals, however, so could easily be re-used with * any line-based entity to provide multi-line matching. * * We have abstracted this code away from the text widget to try to keep Tk as * modular as possible. */ type TSearchSpec1 = struct { Fexact int32 FnoCase int32 FnoLineStop int32 Foverlap int32 FstrictLimits int32 Fall int32 FstartLine int32 FstartOffset TTcl_Size FstopLine int32 FstopOffset TTcl_Size FnumLines int32 Fbackwards int32 FvarPtr uintptr FcountPtr uintptr FresPtr uintptr FsearchElide int32 FaddLineProc uintptr FfoundMatchProc uintptr FlineIndexProc uintptr FclientData uintptr } type TSearchSpec = struct { Fexact int32 FnoCase int32 FnoLineStop int32 Foverlap int32 FstrictLimits int32 Fall int32 FstartLine int32 FstartOffset TTcl_Size FstopLine int32 FstopOffset TTcl_Size FnumLines int32 Fbackwards int32 FvarPtr uintptr FcountPtr uintptr FresPtr uintptr FsearchElide int32 FaddLineProc uintptr FfoundMatchProc uintptr FlineIndexProc uintptr FclientData uintptr } /* * The structure below defines text class behavior by means of functions that * can be invoked from generic window code. */ var _textClass = TTk_ClassProcs{ Fsize: int64(32), } func init() { p := unsafe.Pointer(&_textClass) *(*uintptr)(unsafe.Add(p, 8)) = __ccgo_fp(_TextWorldChangedCallback) } /* *-------------------------------------------------------------- * * Tk_TextObjCmd -- * * This function is invoked to process the "text" Tcl command. See the * user documentation for details on what it does. * * Results: * A standard Tcl result. * * Side effects: * See the user documentation. * *-------------------------------------------------------------- */ func XTk_TextObjCmd(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) (r int32) { /* Argument objects. */ var tkwin TTk_Window _ = tkwin tkwin = clientData if objc < int32(2) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(1), objv, __ccgo_ts+20960) return int32(TCL_ERROR) } return _CreateWidget(tls, libc.UintptrFromInt32(0), tkwin, interp, libc.UintptrFromInt32(0), int64(objc), objv) } /* *-------------------------------------------------------------- * * CreateWidget -- * * This function is invoked to process the "text" Tcl command, (when * called by Tk_TextObjCmd) and the "$text peer create" text widget * sub-command (called from TextPeerCmd). * * See the user documentation for details on what it does. * * Results: * A standard Tcl result, places the name of the widget created into the * interp's result. * * Side effects: * See the user documentation. * *-------------------------------------------------------------- */ func _CreateWidget(tls *libc.TLS, sharedPtr uintptr, tkwin TTk_Window, interp uintptr, parent uintptr, objc TTcl_Size, objv uintptr) (r int32) { bp := tls.Alloc(32) defer tls.Free(32) /* Argument objects. */ var newWin TTk_Window var optionTable TTk_OptionTable var textPtr uintptr var _ /* startIndex at bp+0 */ TTkTextIndex _, _, _ = newWin, optionTable, textPtr /* * Create the window. */ newWin = XTk_CreateWindowFromPath(tls, interp, tkwin, libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8)), libc.UintptrFromInt32(0)), libc.UintptrFromInt32(0)) if newWin == libc.UintptrFromInt32(0) { return int32(TCL_ERROR) } /* * Create the text widget and initialize everything to zero, then set the * necessary initial (non-NULL) values. It is important that the 'set' tag * and 'insert', 'current' mark pointers are all NULL to start. */ textPtr = libtcl9_0.XTcl_Alloc(tls, uint64(720)) libc.Xmemset(tls, textPtr, 0, uint64(720)) (*TTkText)(unsafe.Pointer(textPtr)).Ftkwin = newWin (*TTkText)(unsafe.Pointer(textPtr)).Fdisplay = (*TTk_FakeWin)(unsafe.Pointer(newWin)).Fdisplay (*TTkText)(unsafe.Pointer(textPtr)).Finterp = interp (*TTkText)(unsafe.Pointer(textPtr)).FwidgetCmd = libtcl9_0.XTcl_CreateObjCommand(tls, interp, (*TTk_FakeWin)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).Ftkwin)).FpathName, __ccgo_fp(_TextWidgetObjCmd), textPtr, __ccgo_fp(_TextCmdDeletedProc)) if sharedPtr == libc.UintptrFromInt32(0) { sharedPtr = libtcl9_0.XTcl_Alloc(tls, uint64(512)) libc.Xmemset(tls, sharedPtr, 0, uint64(512)) (*TTkSharedText)(unsafe.Pointer(sharedPtr)).FrefCount = 0 (*TTkSharedText)(unsafe.Pointer(sharedPtr)).Fpeers = libc.UintptrFromInt32(0) (*TTkSharedText)(unsafe.Pointer(sharedPtr)).Ftree = XTkBTreeCreate(tls, sharedPtr) libtcl9_0.XTcl_InitHashTable(tls, sharedPtr+16, TCL_STRING_KEYS) libtcl9_0.XTcl_InitHashTable(tls, sharedPtr+128, TCL_STRING_KEYS) libtcl9_0.XTcl_InitHashTable(tls, sharedPtr+232, TCL_STRING_KEYS) libtcl9_0.XTcl_InitHashTable(tls, sharedPtr+336, TCL_STRING_KEYS) (*TTkSharedText)(unsafe.Pointer(sharedPtr)).FundoStack = XTkUndoInitStack(tls, interp, 0) (*TTkSharedText)(unsafe.Pointer(sharedPtr)).Fundo = 0 (*TTkSharedText)(unsafe.Pointer(sharedPtr)).FisDirty = 0 (*TTkSharedText)(unsafe.Pointer(sharedPtr)).FdirtyMode = int32(TK_TEXT_DIRTY_NORMAL) (*TTkSharedText)(unsafe.Pointer(sharedPtr)).FautoSeparators = int32(1) (*TTkSharedText)(unsafe.Pointer(sharedPtr)).FlastEditMode = int32(TK_TEXT_EDIT_OTHER) (*TTkSharedText)(unsafe.Pointer(sharedPtr)).FstateEpoch = 0 (*TTkSharedText)(unsafe.Pointer(sharedPtr)).FimageCount = 0 } /* * Add the new widget to the shared list. */ (*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr = sharedPtr (*TTkSharedText)(unsafe.Pointer(sharedPtr)).FrefCount++ (*TTkText)(unsafe.Pointer(textPtr)).Fnext = (*TTkSharedText)(unsafe.Pointer(sharedPtr)).Fpeers (*TTkSharedText)(unsafe.Pointer(sharedPtr)).Fpeers = textPtr /* * This refCount will be held until DestroyText is called. Note also that * the later call to 'TkTextCreateDInfo' will add more refCounts. */ (*TTkText)(unsafe.Pointer(textPtr)).FrefCount = int64(1) /* * Specify start and end lines in the B-tree. The default is the same as * the parent, but this can be adjusted to display more or less if the * start, end where given as configuration options. */ if parent != libc.UintptrFromInt32(0) { (*TTkText)(unsafe.Pointer(textPtr)).Fstart = (*TTkText)(unsafe.Pointer(parent)).Fstart (*TTkText)(unsafe.Pointer(textPtr)).Fend = (*TTkText)(unsafe.Pointer(parent)).Fend } else { (*TTkText)(unsafe.Pointer(textPtr)).Fstart = libc.UintptrFromInt32(0) (*TTkText)(unsafe.Pointer(textPtr)).Fend = libc.UintptrFromInt32(0) } (*TTkText)(unsafe.Pointer(textPtr)).Fstate = int32(TK_TEXT_STATE_NORMAL) (*TTkText)(unsafe.Pointer(textPtr)).Frelief = TK_RELIEF_FLAT (*TTkText)(unsafe.Pointer(textPtr)).Fcursor = libc.UintptrFromInt32(0) (*TTkText)(unsafe.Pointer(textPtr)).FcharWidth = int32(1) (*TTkText)(unsafe.Pointer(textPtr)).FcharHeight = int32(10) (*TTkText)(unsafe.Pointer(textPtr)).FwrapMode = int32(TEXT_WRAPMODE_CHAR) (*TTkText)(unsafe.Pointer(textPtr)).FprevWidth = (*TTk_FakeWin)(unsafe.Pointer(newWin)).Fchanges.Fwidth (*TTkText)(unsafe.Pointer(textPtr)).FprevHeight = (*TTk_FakeWin)(unsafe.Pointer(newWin)).Fchanges.Fheight /* * Register with the B-tree. In some sense it would be best if we could do * this later (after configuration options), so that any changes to * start,end do not require a total recalculation. */ XTkBTreeAddClient(tls, (*TTkSharedText)(unsafe.Pointer(sharedPtr)).Ftree, textPtr, (*TTkText)(unsafe.Pointer(textPtr)).FcharHeight) /* * This will add refCounts to textPtr. */ XTkTextCreateDInfo(tls, textPtr) XTkTextMakeByteIndex(tls, (*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).Ftree, textPtr, 0, 0, bp) XTkTextSetYView(tls, textPtr, bp, 0) (*TTkText)(unsafe.Pointer(textPtr)).FexportSelection = int32(1) (*TTkText)(unsafe.Pointer(textPtr)).FpickEvent.Ftype1 = int32(LeaveNotify) (*TTkText)(unsafe.Pointer(textPtr)).Fundo = (*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).Fundo (*TTkText)(unsafe.Pointer(textPtr)).FmaxUndo = (*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).FmaxUndo (*TTkText)(unsafe.Pointer(textPtr)).FautoSeparators = (*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).FautoSeparators (*TTkText)(unsafe.Pointer(textPtr)).FtabOptionObj = libc.UintptrFromInt32(0) /* * Create the "sel" tag and the "current" and "insert" marks. */ (*TTkText)(unsafe.Pointer(textPtr)).FselBorder = libc.UintptrFromInt32(0) (*TTkText)(unsafe.Pointer(textPtr)).FinactiveSelBorder = libc.UintptrFromInt32(0) (*TTkText)(unsafe.Pointer(textPtr)).FselBorderWidthObj = libc.UintptrFromInt32(0) (*TTkText)(unsafe.Pointer(textPtr)).FselFgColorPtr = libc.UintptrFromInt32(0) /* * Note: it is important that textPtr->selTagPtr is NULL before this * initial call. */ (*TTkText)(unsafe.Pointer(textPtr)).FselTagPtr = XTkTextCreateTag(tls, textPtr, __ccgo_ts+42892, libc.UintptrFromInt32(0)) XTk_GetRelief(tls, interp, __ccgo_ts+12, (*TTkText)(unsafe.Pointer(textPtr)).FselTagPtr+56) (*TTkText)(unsafe.Pointer(textPtr)).FcurrentMarkPtr = XTkTextSetMark(tls, textPtr, __ccgo_ts+3279, bp) (*TTkText)(unsafe.Pointer(textPtr)).FinsertMarkPtr = XTkTextSetMark(tls, textPtr, __ccgo_ts+22158, bp) /* * Create the option table for this widget class. If it has already been * created, the cached pointer will be returned. */ optionTable = XTk_CreateOptionTable(tls, interp, uintptr(unsafe.Pointer(&_optionSpecs8))) XTk_SetClass(tls, (*TTkText)(unsafe.Pointer(textPtr)).Ftkwin, __ccgo_ts+20404) XTk_SetClassProcs(tls, (*TTkText)(unsafe.Pointer(textPtr)).Ftkwin, uintptr(unsafe.Pointer(&_textClass)), textPtr) (*TTkText)(unsafe.Pointer(textPtr)).FoptionTable = optionTable XTk_CreateEventHandler(tls, (*TTkText)(unsafe.Pointer(textPtr)).Ftkwin, libc.Uint64FromInt64(libc.Int64FromInt64(1)<') { value = libc.BoolInt32(relation > 0) if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(p + 1))) == int32('=') && libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(p + 2))) == 0 { value = libc.BoolInt32(relation >= 0) } else { if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(p + 1))) != 0 { goto compareError } } } else { if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(p))) == int32('=') && libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(p + 1))) == int32('=') && libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(p + 2))) == 0 { value = libc.BoolInt32(relation == 0) } else { if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(p))) == int32('!') && libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(p + 1))) == int32('=') && libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(p + 2))) == 0 { value = libc.BoolInt32(relation != 0) } else { goto compareError } } } } libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewWideIntObj(tls, libc.BoolInt64(value != 0))) goto _27 goto compareError compareError: ; libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+42990, libc.VaList(bp+272, libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 3*8)), libc.UintptrFromInt32(0))))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+272, __ccgo_ts+179, __ccgo_ts+182, __ccgo_ts+43052, libc.UintptrFromInt32(0))) result = int32(TCL_ERROR) goto done _4: ; if objc <= int32(3) { if objc == int32(3) { v28 = *(*uintptr)(unsafe.Pointer(objv + 2*8)) } else { v28 = libc.UintptrFromInt32(0) } objPtr1 = XTk_GetOptionInfo(tls, interp, textPtr, (*TTkText)(unsafe.Pointer(textPtr)).FoptionTable, v28, (*TTkText)(unsafe.Pointer(textPtr)).Ftkwin) if objPtr1 == libc.UintptrFromInt32(0) { result = int32(TCL_ERROR) goto done } libtcl9_0.XTcl_SetObjResult(tls, interp, objPtr1) } else { result = _ConfigureText1(tls, interp, textPtr, int64(objc-int32(2)), objv+uintptr(2)*8) } goto _27 _5: ; found = 0 update = 0 objPtr2 = libc.UintptrFromInt32(0) if objc < int32(4) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(2), objv, __ccgo_ts+43063) result = int32(TCL_ERROR) goto done } indexFromPtr = XTkTextGetIndexFromObj(tls, interp, textPtr, *(*uintptr)(unsafe.Pointer(objv + uintptr(objc-int32(2))*8))) if indexFromPtr == libc.UintptrFromInt32(0) { result = int32(TCL_ERROR) goto done } indexToPtr = XTkTextGetIndexFromObj(tls, interp, textPtr, *(*uintptr)(unsafe.Pointer(objv + uintptr(objc-int32(1))*8))) if indexToPtr == libc.UintptrFromInt32(0) { result = int32(TCL_ERROR) goto done } i = int64(2) for { if !(i < int64(objc-int32(2))) { break } option = libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(i)*8)), bp+24) if *(*TTcl_Size)(unsafe.Pointer(bp + 24)) < int64(2) || libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(option))) != int32('-') { goto badOption } c = *(*uint8)(unsafe.Pointer(option + 1)) if libc.Int32FromUint8(c) == int32('c') && !(libc.Xstrncmp(tls, __ccgo_ts+43097, option, libc.Uint64FromInt64(*(*TTcl_Size)(unsafe.Pointer(bp + 24)))) != 0) { value1 = _CountIndices(tls, textPtr, indexFromPtr, indexToPtr, COUNT_CHARS) } else { if libc.Int32FromUint8(c) == int32('d') && *(*TTcl_Size)(unsafe.Pointer(bp + 24)) > int64(8) && !(libc.Xstrncmp(tls, __ccgo_ts+43104, option, libc.Uint64FromInt64(*(*TTcl_Size)(unsafe.Pointer(bp + 24)))) != 0) { value1 = _CountIndices(tls, textPtr, indexFromPtr, indexToPtr, libc.Int32FromInt32(COUNT_CHARS)|libc.Int32FromInt32(COUNT_DISPLAY)) } else { if libc.Int32FromUint8(c) == int32('d') && *(*TTcl_Size)(unsafe.Pointer(bp + 24)) > int64(8) && !(libc.Xstrncmp(tls, __ccgo_ts+43118, option, libc.Uint64FromInt64(*(*TTcl_Size)(unsafe.Pointer(bp + 24)))) != 0) { value1 = _CountIndices(tls, textPtr, indexFromPtr, indexToPtr, libc.Int32FromInt32(COUNT_INDICES)|libc.Int32FromInt32(COUNT_DISPLAY)) } else { if libc.Int32FromUint8(c) == int32('d') && *(*TTcl_Size)(unsafe.Pointer(bp + 24)) > int64(8) && !(libc.Xstrncmp(tls, __ccgo_ts+43134, option, libc.Uint64FromInt64(*(*TTcl_Size)(unsafe.Pointer(bp + 24)))) != 0) { compare = XTkTextIndexCmp(tls, indexFromPtr, indexToPtr) value1 = 0 if compare == 0 { goto countDone } if compare > 0 { tmpPtr = indexFromPtr indexFromPtr = indexToPtr indexToPtr = tmpPtr } lastPtr = XTkBTreeFindLine(tls, (*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).Ftree, textPtr, XTkBTreeNumLines(tls, (*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).Ftree, textPtr)) fromPtr = (*TTkTextIndex)(unsafe.Pointer(indexFromPtr)).FlinePtr if fromPtr == lastPtr { goto countDone } /* * Caution: we must NEVER call TkTextUpdateOneLine with the * last artificial line in the widget. */ *(*TTkTextIndex)(unsafe.Pointer(bp + 32)) = *(*TTkTextIndex)(unsafe.Pointer(indexFromPtr)) (*(*TTkTextIndex)(unsafe.Pointer(bp + 32))).FbyteIndex = 0 /* * We're going to count up all display lines in the logical * line of 'indexFromPtr' up to, but not including the logical * line of 'indexToPtr' (except if this line is elided), and * then subtract off what came in too much from elided lines, * also subtract off what we didn't want from 'from' and add * on what we didn't count from 'to'. */ for XTkTextIndexCmp(tls, bp+32, indexToPtr) < 0 { value1 += XTkTextUpdateOneLine(tls, textPtr, (*(*TTkTextIndex)(unsafe.Pointer(bp + 32))).FlinePtr, 0, bp+32, 0) } *(*TTkTextIndex)(unsafe.Pointer(bp + 64)) = *(*TTkTextIndex)(unsafe.Pointer(bp + 32)) /* * Now we need to adjust the count to: * - subtract off the number of display lines between * indexToPtr and index2, since we might have skipped past * indexToPtr, if we have several logical lines in a * single display line * - subtract off the number of display lines overcounted * in the first logical line * - add on the number of display lines in the last logical * line * This logic is still ok if both indexFromPtr and indexToPtr * are in the same logical line. */ *(*TTkTextIndex)(unsafe.Pointer(bp + 32)) = *(*TTkTextIndex)(unsafe.Pointer(indexToPtr)) (*(*TTkTextIndex)(unsafe.Pointer(bp + 32))).FbyteIndex = 0 for XTkTextIndexCmp(tls, bp+32, bp+64) < 0 { value1 -= XTkTextUpdateOneLine(tls, textPtr, (*(*TTkTextIndex)(unsafe.Pointer(bp + 32))).FlinePtr, 0, bp+32, 0) } (*(*TTkTextIndex)(unsafe.Pointer(bp + 32))).FlinePtr = (*TTkTextIndex)(unsafe.Pointer(indexFromPtr)).FlinePtr (*(*TTkTextIndex)(unsafe.Pointer(bp + 32))).FbyteIndex = 0 for int32(1) != 0 { XTkTextFindDisplayLineEnd(tls, textPtr, bp+32, int32(1), libc.UintptrFromInt32(0)) if XTkTextIndexCmp(tls, bp+32, indexFromPtr) >= 0 { break } XTkTextIndexForwBytes(tls, textPtr, bp+32, int64(1), bp+32) value1-- } if (*TTkTextIndex)(unsafe.Pointer(indexToPtr)).FlinePtr != lastPtr { (*(*TTkTextIndex)(unsafe.Pointer(bp + 32))).FlinePtr = (*TTkTextIndex)(unsafe.Pointer(indexToPtr)).FlinePtr (*(*TTkTextIndex)(unsafe.Pointer(bp + 32))).FbyteIndex = 0 for int32(1) != 0 { XTkTextFindDisplayLineEnd(tls, textPtr, bp+32, int32(1), libc.UintptrFromInt32(0)) if XTkTextIndexCmp(tls, bp+32, indexToPtr) >= 0 { break } XTkTextIndexForwBytes(tls, textPtr, bp+32, int64(1), bp+32) value1++ } } if compare > 0 { value1 = -value1 } } else { if libc.Int32FromUint8(c) == int32('i') && !(libc.Xstrncmp(tls, __ccgo_ts+43148, option, libc.Uint64FromInt64(*(*TTcl_Size)(unsafe.Pointer(bp + 24)))) != 0) { value1 = _CountIndices(tls, textPtr, indexFromPtr, indexToPtr, int32(COUNT_INDICES)) } else { if libc.Int32FromUint8(c) == int32('l') && !(libc.Xstrncmp(tls, __ccgo_ts+43157, option, libc.Uint64FromInt64(*(*TTcl_Size)(unsafe.Pointer(bp + 24)))) != 0) { value1 = XTkBTreeLinesTo(tls, textPtr, (*TTkTextIndex)(unsafe.Pointer(indexToPtr)).FlinePtr) - XTkBTreeLinesTo(tls, textPtr, (*TTkTextIndex)(unsafe.Pointer(indexFromPtr)).FlinePtr) } else { if libc.Int32FromUint8(c) == int32('u') && !(libc.Xstrncmp(tls, __ccgo_ts+43164, option, libc.Uint64FromInt64(*(*TTcl_Size)(unsafe.Pointer(bp + 24)))) != 0) { update = int32(1) goto _29 } else { if libc.Int32FromUint8(c) == int32('x') && !(libc.Xstrncmp(tls, __ccgo_ts+43172, option, libc.Uint64FromInt64(*(*TTcl_Size)(unsafe.Pointer(bp + 24)))) != 0) { *(*TTkTextIndex)(unsafe.Pointer(bp + 104)) = *(*TTkTextIndex)(unsafe.Pointer(indexFromPtr)) XTkTextFindDisplayLineEnd(tls, textPtr, bp+104, 0, bp+96) *(*TTkTextIndex)(unsafe.Pointer(bp + 104)) = *(*TTkTextIndex)(unsafe.Pointer(indexToPtr)) XTkTextFindDisplayLineEnd(tls, textPtr, bp+104, 0, bp+100) value1 = *(*int32)(unsafe.Pointer(bp + 100)) - *(*int32)(unsafe.Pointer(bp + 96)) } else { if libc.Int32FromUint8(c) == int32('y') && !(libc.Xstrncmp(tls, __ccgo_ts+43181, option, libc.Uint64FromInt64(*(*TTcl_Size)(unsafe.Pointer(bp + 24)))) != 0) { if update != 0 { XTkTextUpdateLineMetrics(tls, textPtr, XTkBTreeLinesTo(tls, textPtr, (*TTkTextIndex)(unsafe.Pointer(indexFromPtr)).FlinePtr), XTkBTreeLinesTo(tls, textPtr, (*TTkTextIndex)(unsafe.Pointer(indexToPtr)).FlinePtr), -int32(1)) } value1 = XTkTextIndexYPixels(tls, textPtr, indexToPtr) - XTkTextIndexYPixels(tls, textPtr, indexFromPtr) } else { goto badOption } } } } } } } } } goto countDone countDone: ; found++ if found == int32(1) { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewWideIntObj(tls, int64(value1))) } else { if found == int32(2) { /* * Move the first item we put into the result into the * first element of the list object. */ objPtr2 = libtcl9_0.XTcl_NewObj(tls) libtcl9_0.XTcl_ListObjAppendElement(tls, libc.UintptrFromInt32(0), objPtr2, libtcl9_0.XTcl_GetObjResult(tls, interp)) } libtcl9_0.XTcl_ListObjAppendElement(tls, libc.UintptrFromInt32(0), objPtr2, libtcl9_0.XTcl_NewWideIntObj(tls, int64(value1))) } goto _29 _29: ; i++ } if found == 0 { /* * Use the default '-indices'. */ value2 = _CountIndices(tls, textPtr, indexFromPtr, indexToPtr, int32(COUNT_INDICES)) libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewWideIntObj(tls, int64(value2))) } else { if found > int32(1) { libtcl9_0.XTcl_SetObjResult(tls, interp, objPtr2) } } goto _27 goto badOption badOption: ; libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+43190, libc.VaList(bp+272, libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(i)*8)), libc.UintptrFromInt32(0))))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+272, __ccgo_ts+179, __ccgo_ts+16417, __ccgo_ts+43319, libc.UintptrFromInt32(0))) result = int32(TCL_ERROR) goto done _6: ; if objc > int32(3) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(2), objv, __ccgo_ts+43332) result = int32(TCL_ERROR) goto done } if objc == int32(2) { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewWideIntObj(tls, libc.BoolInt64(XtkBTreeDebug != 0))) } else { if libtcl9_0.XTcl_GetBoolFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), (libc.Int32FromInt32(TCL_NULL_OK)-libc.Int32FromInt32(2))&libc.Int32FromInt64(4), uintptr(unsafe.Pointer(&XtkBTreeDebug))) != TCL_OK { result = int32(TCL_ERROR) goto done } XtkTextDebug = XtkBTreeDebug } goto _27 _7: ; if objc < int32(3) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(2), objv, __ccgo_ts+43340) result = int32(TCL_ERROR) goto done } if (*TTkText)(unsafe.Pointer(textPtr)).Fstate != int32(TK_TEXT_STATE_DISABLED) { if objc < int32(5) { /* * Parse the starting and stopping indices. */ indexPtr11 = XTkTextGetIndexFromObj(tls, (*TTkText)(unsafe.Pointer(textPtr)).Finterp, textPtr, *(*uintptr)(unsafe.Pointer(objv + 2*8))) if indexPtr11 == libc.UintptrFromInt32(0) { result = int32(TCL_ERROR) goto done } if objc == int32(4) { indexPtr21 = XTkTextGetIndexFromObj(tls, (*TTkText)(unsafe.Pointer(textPtr)).Finterp, textPtr, *(*uintptr)(unsafe.Pointer(objv + 3*8))) if indexPtr21 == libc.UintptrFromInt32(0) { result = int32(TCL_ERROR) goto done } } else { indexPtr21 = libc.UintptrFromInt32(0) } _DeleteIndexRange(tls, libc.UintptrFromInt32(0), textPtr, indexPtr11, indexPtr21, int32(1)) } else { objc -= int32(2) objv += uintptr(2) * 8 indices = libtcl9_0.XTcl_Alloc(tls, libc.Uint64FromInt32(objc+libc.Int32FromInt32(1))*uint64(32)) /* * First pass verifies that all indices are valid. */ i1 = 0 for { if !(i1 < int64(objc)) { break } indexPtr1 = XTkTextGetIndexFromObj(tls, interp, textPtr, *(*uintptr)(unsafe.Pointer(objv + uintptr(i1)*8))) if indexPtr1 == libc.UintptrFromInt32(0) { result = int32(TCL_ERROR) libtcl9_0.XTcl_Free(tls, indices) goto done } *(*TTkTextIndex)(unsafe.Pointer(indices + uintptr(i1)*32)) = *(*TTkTextIndex)(unsafe.Pointer(indexPtr1)) goto _30 _30: ; i1++ } /* * Pad out the pairs evenly to make later code easier. */ if objc&int32(1) != 0 { *(*TTkTextIndex)(unsafe.Pointer(indices + uintptr(i1)*32)) = *(*TTkTextIndex)(unsafe.Pointer(indices + uintptr(i1-int64(1))*32)) XTkTextIndexForwChars(tls, libc.UintptrFromInt32(0), indices+uintptr(i1)*32, int32(1), indices+uintptr(i1)*32, int32(COUNT_INDICES)) objc++ } useIdx = libtcl9_0.XTcl_Alloc(tls, libc.Uint64FromInt32(objc)) libc.Xmemset(tls, useIdx, 0, libc.Uint64FromInt32(objc)) /* * Do a decreasing order sort so that we delete the end ranges * first to maintain index consistency. */ libc.Xqsort(tls, indices, libc.Uint64FromInt32(objc)/uint64(2), libc.Uint64FromInt32(2)*libc.Uint64FromInt64(32), __ccgo_fp(_TextIndexSortProc)) lastStart = libc.UintptrFromInt32(0) /* * Second pass will handle bogus ranges (end < start) and * overlapping ranges. */ i1 = 0 for { if !(i1 < int64(objc)) { break } ixStart = indices + uintptr(i1)*32 ixEnd = indices + uintptr(i1+int64(1))*32 if XTkTextIndexCmp(tls, ixEnd, ixStart) <= 0 { goto _31 } if lastStart != 0 { if XTkTextIndexCmp(tls, ixStart, lastStart) == 0 { /* * Start indices were equal, and the sort placed * the longest range first, so skip this one. */ goto _31 } else { if XTkTextIndexCmp(tls, lastStart, ixEnd) < 0 { /* * The next pair has a start range before the end * point of the last range. Constrain the delete * range, but use the pointer values. */ *(*TTkTextIndex)(unsafe.Pointer(ixEnd)) = *(*TTkTextIndex)(unsafe.Pointer(lastStart)) if XTkTextIndexCmp(tls, ixEnd, ixStart) <= 0 { goto _31 } } } } lastStart = ixStart *(*uint8)(unsafe.Pointer(useIdx + uintptr(i1))) = uint8(1) goto _31 _31: ; i1 += int64(2) } /* * Final pass take the input from the previous and deletes the * ranges which are flagged to be deleted. */ i1 = 0 for { if !(i1 < int64(objc)) { break } if *(*uint8)(unsafe.Pointer(useIdx + uintptr(i1))) != 0 { /* * We don't need to check the return value because all * indices are preparsed above. */ _DeleteIndexRange(tls, libc.UintptrFromInt32(0), textPtr, indices+uintptr(i1)*32, indices+uintptr(i1+int64(1))*32, int32(1)) } goto _32 _32: ; i1 += int64(2) } libtcl9_0.XTcl_Free(tls, indices) } } goto _27 _8: ; if objc != int32(3) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(2), objv, __ccgo_ts+22152) result = int32(TCL_ERROR) goto done } indexPtr2 = XTkTextGetIndexFromObj(tls, interp, textPtr, *(*uintptr)(unsafe.Pointer(objv + 2*8))) if indexPtr2 == libc.UintptrFromInt32(0) { result = int32(TCL_ERROR) goto done } if XTkTextDLineInfo(tls, textPtr, indexPtr2, bp+136, bp+140, bp+144, bp+148, bp+152) == 0 { listObj1 = libtcl9_0.XTcl_NewListObj(tls, 0, libc.UintptrFromInt32(0)) libtcl9_0.XTcl_ListObjAppendElement(tls, interp, listObj1, libtcl9_0.XTcl_NewWideIntObj(tls, int64(*(*int32)(unsafe.Pointer(bp + 136))))) libtcl9_0.XTcl_ListObjAppendElement(tls, interp, listObj1, libtcl9_0.XTcl_NewWideIntObj(tls, int64(*(*int32)(unsafe.Pointer(bp + 140))))) libtcl9_0.XTcl_ListObjAppendElement(tls, interp, listObj1, libtcl9_0.XTcl_NewWideIntObj(tls, int64(*(*int32)(unsafe.Pointer(bp + 144))))) libtcl9_0.XTcl_ListObjAppendElement(tls, interp, listObj1, libtcl9_0.XTcl_NewWideIntObj(tls, int64(*(*int32)(unsafe.Pointer(bp + 148))))) libtcl9_0.XTcl_ListObjAppendElement(tls, interp, listObj1, libtcl9_0.XTcl_NewWideIntObj(tls, int64(*(*int32)(unsafe.Pointer(bp + 152))))) libtcl9_0.XTcl_SetObjResult(tls, interp, listObj1) } goto _27 _9: ; result = _TextDumpCmd(tls, textPtr, interp, int64(objc), objv) goto _27 _10: ; result = _TextEditCmd(tls, textPtr, interp, int64(objc), objv) goto _27 _11: ; objPtr3 = libc.UintptrFromInt32(0) found1 = 0 visible = 0 if objc < int32(3) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(2), objv, __ccgo_ts+43360) result = int32(TCL_ERROR) goto done } /* * Simple, restrictive argument parsing. The only options are -- and * -displaychars (or any unique prefix). */ i2 = int64(2) if objc > int32(3) { name = libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(i2)*8)), bp+160) if *(*TTcl_Size)(unsafe.Pointer(bp + 160)) > int64(1) && libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(name))) == int32('-') { if libc.Xstrncmp(tls, __ccgo_ts+43104, name, libc.Uint64FromInt64(*(*TTcl_Size)(unsafe.Pointer(bp + 160)))) == 0 { i2++ visible = int32(1) name = libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(i2)*8)), bp+160) } if i2 < int64(objc-int32(1)) && *(*TTcl_Size)(unsafe.Pointer(bp + 160)) == int64(2) && !(libc.Xstrcmp(tls, __ccgo_ts+10042, name) != 0) { i2++ } } } for { if !(i2 < int64(objc)) { break } index1Ptr1 = XTkTextGetIndexFromObj(tls, interp, textPtr, *(*uintptr)(unsafe.Pointer(objv + uintptr(i2)*8))) if index1Ptr1 == libc.UintptrFromInt32(0) { if objPtr3 != 0 { _objPtr = objPtr3 v35 = _objPtr v34 = *(*TTcl_Size)(unsafe.Pointer(v35)) *(*TTcl_Size)(unsafe.Pointer(v35))-- if v34 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr) } } result = int32(TCL_ERROR) goto done } if i2+int64(1) == int64(objc) { XTkTextIndexForwChars(tls, libc.UintptrFromInt32(0), index1Ptr1, int32(1), bp+168, int32(COUNT_INDICES)) index2Ptr1 = bp + 168 } else { index2Ptr1 = XTkTextGetIndexFromObj(tls, interp, textPtr, *(*uintptr)(unsafe.Pointer(objv + uintptr(i2+int64(1))*8))) if index2Ptr1 == libc.UintptrFromInt32(0) { if objPtr3 != 0 { _objPtr1 = objPtr3 v37 = _objPtr1 v36 = *(*TTcl_Size)(unsafe.Pointer(v37)) *(*TTcl_Size)(unsafe.Pointer(v37))-- if v36 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr1) } } result = int32(TCL_ERROR) goto done } } if XTkTextIndexCmp(tls, index1Ptr1, index2Ptr1) < 0 { /* * We want to move the text we get from the window into the * result, but since this could in principle be a megabyte or * more, we want to do it efficiently! */ get = _TextGetText(tls, textPtr, index1Ptr1, index2Ptr1, visible) found1++ if found1 == int32(1) { libtcl9_0.XTcl_SetObjResult(tls, interp, get) } else { if found1 == int32(2) { /* * Move the first item we put into the result into the * first element of the list object. */ objPtr3 = libtcl9_0.XTcl_NewObj(tls) libtcl9_0.XTcl_ListObjAppendElement(tls, libc.UintptrFromInt32(0), objPtr3, libtcl9_0.XTcl_GetObjResult(tls, interp)) } libtcl9_0.XTcl_ListObjAppendElement(tls, libc.UintptrFromInt32(0), objPtr3, get) } } goto _33 _33: ; i2 += int64(2) } if found1 > int32(1) { libtcl9_0.XTcl_SetObjResult(tls, interp, objPtr3) } goto _27 _12: ; result = XTkTextImageCmd(tls, textPtr, interp, int64(objc), objv) goto _27 _13: ; if objc != int32(3) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(2), objv, __ccgo_ts+22152) result = int32(TCL_ERROR) goto done } indexPtr3 = XTkTextGetIndexFromObj(tls, interp, textPtr, *(*uintptr)(unsafe.Pointer(objv + 2*8))) if indexPtr3 == libc.UintptrFromInt32(0) { result = int32(TCL_ERROR) goto done } libtcl9_0.XTcl_SetObjResult(tls, interp, XTkTextNewIndexObj(tls, textPtr, indexPtr3)) goto _27 _14: ; if objc < int32(4) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(2), objv, __ccgo_ts+43401) result = int32(TCL_ERROR) goto done } indexPtr4 = XTkTextGetIndexFromObj(tls, interp, textPtr, *(*uintptr)(unsafe.Pointer(objv + 2*8))) if indexPtr4 == libc.UintptrFromInt32(0) { result = int32(TCL_ERROR) goto done } if (*TTkText)(unsafe.Pointer(textPtr)).Fstate != int32(TK_TEXT_STATE_DISABLED) { result = _TextInsertCmd(tls, libc.UintptrFromInt32(0), textPtr, interp, int64(objc-int32(3)), objv+uintptr(3)*8, indexPtr4, int32(1)) } goto _27 _15: ; result = XTkTextMarkCmd(tls, textPtr, interp, int64(objc), objv) goto _27 _16: ; result = _TextPeerCmd(tls, textPtr, interp, int64(objc), objv) goto _27 _17: ; if objc != int32(2) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(2), objv, libc.UintptrFromInt32(0)) result = int32(TCL_ERROR) goto done } libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewWideIntObj(tls, libc.BoolInt64(XTkTextPendingsync(tls, textPtr) != 0))) goto _27 _18: ; if objc < int32(5) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(2), objv, __ccgo_ts+43441) result = int32(TCL_ERROR) goto done } indexFromPtr1 = XTkTextGetIndexFromObj(tls, interp, textPtr, *(*uintptr)(unsafe.Pointer(objv + 2*8))) if indexFromPtr1 == libc.UintptrFromInt32(0) { result = int32(TCL_ERROR) goto done } indexToPtr1 = XTkTextGetIndexFromObj(tls, interp, textPtr, *(*uintptr)(unsafe.Pointer(objv + 3*8))) if indexToPtr1 == libc.UintptrFromInt32(0) { result = int32(TCL_ERROR) goto done } if XTkTextIndexCmp(tls, indexFromPtr1, indexToPtr1) > 0 { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+43489, libc.VaList(bp+272, libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 3*8)), libc.UintptrFromInt32(0)), libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8)), libc.UintptrFromInt32(0))))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+272, __ccgo_ts+179, __ccgo_ts+16417, __ccgo_ts+43524, libc.UintptrFromInt32(0))) result = int32(TCL_ERROR) goto done } if (*TTkText)(unsafe.Pointer(textPtr)).Fstate != int32(TK_TEXT_STATE_DISABLED) { /* * The 'replace' operation is quite complex to do correctly, * because we want a number of criteria to hold: * * 1. The insertion point shouldn't move, unless it is within the * deleted range. In this case it should end up after the new * text. * * 2. The window should not change the text it shows - should not * scroll vertically - unless the result of the replace is * that the insertion position which used to be on-screen is * now off-screen. */ byteIndex = (*TTkText)(unsafe.Pointer(textPtr)).FtopIndex.FbyteIndex lineNum = XTkBTreeLinesTo(tls, textPtr, (*TTkText)(unsafe.Pointer(textPtr)).FtopIndex.FlinePtr) XTkTextMarkSegToIndex(tls, textPtr, (*TTkText)(unsafe.Pointer(textPtr)).FinsertMarkPtr, bp+200) if XTkTextIndexCmp(tls, indexFromPtr1, bp+200) < 0 && XTkTextIndexCmp(tls, indexToPtr1, bp+200) > 0 { insertLength = 0 j = int64(4) for { if !(j < int64(objc)) { break } insertLength = int32(int64(insertLength) + libtcl9_0.XTcl_GetCharLength(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(j)*8)))) goto _38 _38: ; j += int64(2) } /* * Calculate 'deleteInsertOffset' as an offset we will apply * to the insertion point after this operation. */ deleteInsertOffset = _CountIndices(tls, textPtr, indexFromPtr1, bp+200, COUNT_CHARS) if deleteInsertOffset > insertLength { deleteInsertOffset = insertLength } indexFromLine = XTkBTreeLinesTo(tls, textPtr, (*TTkTextIndex)(unsafe.Pointer(indexFromPtr1)).FlinePtr) indexFromByteOffset = int32((*TTkTextIndex)(unsafe.Pointer(indexFromPtr1)).FbyteIndex) result = _TextReplaceCmd(tls, textPtr, interp, indexFromPtr1, indexToPtr1, int64(objc), objv, 0) if result == TCL_OK { XTkTextMakeByteIndex(tls, (*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).Ftree, textPtr, indexFromLine, int64(indexFromByteOffset), bp+232) XTkTextIndexForwChars(tls, libc.UintptrFromInt32(0), bp+232, deleteInsertOffset, bp+200, int32(COUNT_INDICES)) XTkBTreeUnlinkSegment(tls, (*TTkText)(unsafe.Pointer(textPtr)).FinsertMarkPtr, (*(*TTkTextMark)(unsafe.Pointer(&(*TTkTextSegment)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FinsertMarkPtr)).Fbody))).FlinePtr) XTkBTreeLinkSegment(tls, (*TTkText)(unsafe.Pointer(textPtr)).FinsertMarkPtr, bp+200) } } else { result = _TextReplaceCmd(tls, textPtr, interp, indexFromPtr1, indexToPtr1, int64(objc), objv, int32(1)) } if result == TCL_OK { /* * Now ensure the top-line is in the right place. */ XTkTextMakeByteIndex(tls, (*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).Ftree, textPtr, lineNum, byteIndex, bp+200) XTkTextSetYView(tls, textPtr, bp+200, -int32(2)) } } goto _27 _19: ; result = XTkTextScanCmd(tls, textPtr, interp, int64(objc), objv) goto _27 _20: ; result = _TextSearchCmd(tls, textPtr, interp, int64(objc), objv) goto _27 _21: ; result = XTkTextSeeCmd(tls, textPtr, interp, int64(objc), objv) goto _27 _22: ; if objc == int32(4) { cmd = *(*uintptr)(unsafe.Pointer(objv + 3*8)) option1 = libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8)), libc.UintptrFromInt32(0)) if libc.Xstrncmp(tls, option1, __ccgo_ts+16356, libc.Uint64FromInt64((*TTcl_Obj)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(objv + 2*8)))).Flength)) != 0 { libtcl9_0.XTcl_AppendResult(tls, interp, libc.VaList(bp+272, __ccgo_ts+43536, option1, __ccgo_ts+43551, libc.UintptrFromInt32(0))) result = int32(TCL_ERROR) goto done } (*TTcl_Obj)(unsafe.Pointer(cmd)).FrefCount++ if XTkTextPendingsync(tls, textPtr) != 0 { if (*TTkText)(unsafe.Pointer(textPtr)).FafterSyncCmd != 0 { _objPtr2 = (*TTkText)(unsafe.Pointer(textPtr)).FafterSyncCmd v40 = _objPtr2 v39 = *(*TTcl_Size)(unsafe.Pointer(v40)) *(*TTcl_Size)(unsafe.Pointer(v40))-- if v39 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr2) } } (*TTkText)(unsafe.Pointer(textPtr)).FafterSyncCmd = cmd } else { (*TTkText)(unsafe.Pointer(textPtr)).FafterSyncCmd = cmd libtcl9_0.XTcl_DoWhenIdle(tls, __ccgo_fp(XTkTextRunAfterSyncCmd), textPtr) } goto _27 } else { if objc != int32(2) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(2), objv, __ccgo_ts+43575) result = int32(TCL_ERROR) goto done } } if (*TTkText)(unsafe.Pointer(textPtr)).FafterSyncCmd != 0 { _objPtr3 = (*TTkText)(unsafe.Pointer(textPtr)).FafterSyncCmd v42 = _objPtr3 v41 = *(*TTcl_Size)(unsafe.Pointer(v42)) *(*TTcl_Size)(unsafe.Pointer(v42))-- if v41 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr3) } } (*TTkText)(unsafe.Pointer(textPtr)).FafterSyncCmd = libc.UintptrFromInt32(0) XTkTextUpdateLineMetrics(tls, textPtr, 0, XTkBTreeNumLines(tls, (*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).Ftree, textPtr), -int32(1)) goto _27 _23: ; result = XTkTextTagCmd(tls, textPtr, interp, int64(objc), objv) goto _27 _24: ; result = XTkTextWindowCmd(tls, textPtr, interp, int64(objc), objv) goto _27 _25: ; result = XTkTextXviewCmd(tls, textPtr, interp, int64(objc), objv) goto _27 _26: ; result = XTkTextYviewCmd(tls, textPtr, interp, int64(objc), objv) goto _27 _27: ; goto done done: ; v44 = textPtr + 688 v43 = *(*TTcl_Size)(unsafe.Pointer(v44)) *(*TTcl_Size)(unsafe.Pointer(v44))-- if v43 <= int64(1) { libtcl9_0.XTcl_Free(tls, textPtr) } return result } var _optionStrings22 = [27]uintptr{ 0: __ccgo_ts + 12095, 1: __ccgo_ts + 4735, 2: __ccgo_ts + 42896, 3: __ccgo_ts + 4740, 4: __ccgo_ts + 42904, 5: __ccgo_ts + 42910, 6: __ccgo_ts + 2655, 7: __ccgo_ts + 42916, 8: __ccgo_ts + 42926, 9: __ccgo_ts + 42931, 10: __ccgo_ts + 4949, 11: __ccgo_ts + 17810, 12: __ccgo_ts + 22152, 13: __ccgo_ts + 22158, 14: __ccgo_ts + 2046, 15: __ccgo_ts + 42936, 16: __ccgo_ts + 42941, 17: __ccgo_ts + 42953, 18: __ccgo_ts + 22165, 19: __ccgo_ts + 42961, 20: __ccgo_ts + 23682, 21: __ccgo_ts + 42968, 22: __ccgo_ts + 27770, 23: __ccgo_ts + 4814, 24: __ccgo_ts + 22170, 25: __ccgo_ts + 23686, 26: libc.UintptrFromInt32(0), } /* *-------------------------------------------------------------- * * SharedTextObjCmd -- * * This function is invoked to process commands on the shared portion of * a text widget. Currently it is not actually exported as a Tcl command, * and is only used internally to process parts of undo/redo scripts. * See the user documentation for 'text' for details on what it does - * the only subcommands it currently supports are 'insert' and 'delete'. * * Results: * A standard Tcl result. * * Side effects: * See the user documentation for "text". * *-------------------------------------------------------------- */ func _SharedTextObjCmd(tls *libc.TLS, clientData uintptr, interp uintptr, objc TTcl_Size, objv uintptr) (r int32) { bp := tls.Alloc(112) defer tls.Free(112) /* Argument objects. */ var result int32 var sharedPtr uintptr var _ /* index at bp+0 */ int32 var _ /* index1 at bp+72 */ TTkTextIndex var _ /* index1 at bp+8 */ TTkTextIndex var _ /* index2 at bp+40 */ TTkTextIndex _, _ = result, sharedPtr sharedPtr = clientData result = TCL_OK if objc < int64(2) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(1), objv, __ccgo_ts+4953) return int32(TCL_ERROR) } if libtcl9_0.XTcl_GetIndexFromObjStruct(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 1*8)), uintptr(unsafe.Pointer(&_optionStrings23)), libc.Int64FromUint64(libc.Uint64FromInt64(8)), __ccgo_ts+2689, libc.Int32FromInt32(0)|libc.Int32FromUint64(libc.Uint64FromInt64(4)< int64(3) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(3), objv, libc.UintptrFromInt32(0)) return int32(TCL_ERROR) } peersObj = libtcl9_0.XTcl_NewObj(tls) for tPtr != libc.UintptrFromInt32(0) { if tPtr != textPtr { libtcl9_0.XTcl_ListObjAppendElement(tls, libc.UintptrFromInt32(0), peersObj, XTk_NewWindowObj(tls, (*TTkText)(unsafe.Pointer(tPtr)).Ftkwin)) } tPtr = (*TTkText)(unsafe.Pointer(tPtr)).Fnext } libtcl9_0.XTcl_SetObjResult(tls, interp, peersObj) } return TCL_OK } var _peerOptionStrings = [3]uintptr{ 0: __ccgo_ts + 10004, 1: __ccgo_ts + 10036, 2: libc.UintptrFromInt32(0), } /* *---------------------------------------------------------------------- * * TextReplaceCmd -- * * This function is invoked to process part of the "replace" widget * command for text widgets. * * Results: * A standard Tcl result. * * Side effects: * See the user documentation. * * If 'viewUpdate' is false, then textPtr->topIndex may no longer be a * valid index after this function returns. The caller is responsible for * ensuring a correct index is in place. * *---------------------------------------------------------------------- */ func _TextReplaceCmd(tls *libc.TLS, textPtr uintptr, interp uintptr, indexFromPtr uintptr, indexToPtr uintptr, objc TTcl_Size, objv uintptr, viewUpdate int32) (r int32) { bp := tls.Alloc(32) defer tls.Free(32) /* Update vertical view if set. */ var lineNumber, origAutoSep, result int32 var _ /* indexTmp at bp+0 */ TTkTextIndex _, _, _ = lineNumber, origAutoSep, result /* * Perform the deletion and insertion, but ensure no undo-separator is * placed between the two operations. Since we are using the helper * functions 'DeleteIndexRange' and 'TextInsertCmd' we have to pretend * that the autoSeparators setting is off, so that we don't get an * undo-separator between the delete and insert. */ origAutoSep = (*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).FautoSeparators if (*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).Fundo != 0 { (*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).FautoSeparators = 0 if origAutoSep != 0 && (*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).FlastEditMode != int32(TK_TEXT_EDIT_REPLACE) { XTkUndoInsertUndoSeparator(tls, (*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).FundoStack) } } /* * Must save and restore line in indexFromPtr based on line number; can't * keep the line itself as that might be eliminated/invalidated when * deleting the range. [Bug 1602537] */ *(*TTkTextIndex)(unsafe.Pointer(bp)) = *(*TTkTextIndex)(unsafe.Pointer(indexFromPtr)) lineNumber = XTkBTreeLinesTo(tls, textPtr, (*TTkTextIndex)(unsafe.Pointer(indexFromPtr)).FlinePtr) _DeleteIndexRange(tls, libc.UintptrFromInt32(0), textPtr, indexFromPtr, indexToPtr, viewUpdate) (*(*TTkTextIndex)(unsafe.Pointer(bp))).FlinePtr = XTkBTreeFindLine(tls, (*(*TTkTextIndex)(unsafe.Pointer(bp))).Ftree, textPtr, lineNumber) result = _TextInsertCmd(tls, libc.UintptrFromInt32(0), textPtr, interp, objc-int64(4), objv+uintptr(4)*8, bp, viewUpdate) if (*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).Fundo != 0 { (*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).FlastEditMode = int32(TK_TEXT_EDIT_REPLACE) (*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).FautoSeparators = origAutoSep } return result } /* *---------------------------------------------------------------------- * * TextIndexSortProc -- * * This function is called by qsort when sorting an array of indices in * *decreasing* order (last to first). * * Results: * The return value is -1 if the first argument should be before the * second element, 0 if it's equivalent, and 1 if it should be after the * second element. * * Side effects: * None. * *---------------------------------------------------------------------- */ func _TextIndexSortProc(tls *libc.TLS, first uintptr, second uintptr) (r int32) { var cmp int32 var pair1, pair2 uintptr _, _, _ = cmp, pair1, pair2 pair1 = first pair2 = second cmp = XTkTextIndexCmp(tls, pair1+1*32, pair2+1*32) if cmp == 0 { /* * If the first indices were equal, we want the second index of the * pair also to be the greater. Use pointer magic to access the second * index pair. */ cmp = XTkTextIndexCmp(tls, pair1, pair2) } if cmp > 0 { return -int32(1) } else { if cmp < 0 { return int32(1) } } return 0 } /* *---------------------------------------------------------------------- * * DestroyText -- * * This function is invoked when we receive a destroy event to clean up * the internal structure of a text widget. We will free up most of the * internal structure and delete the associated Tcl command. If there are * no outstanding references to the widget, we also free up the textPtr * itself. * * The widget has already been flagged as deleted. * * Results: * None. * * Side effects: * Either everything or almost everything associated with the text is * freed up. * *---------------------------------------------------------------------- */ func _DestroyText(tls *libc.TLS, textPtr uintptr) { bp := tls.Alloc(32) defer tls.Free(32) /* Info about text widget. */ var _objPtr, client, ewPtr, hPtr, loop, nextPtr, sharedTextPtr, tagPtr, v2, v7, v9 uintptr var v1, v6, v8 TTcl_Size var _ /* search at bp+0 */ TTcl_HashSearch _, _, _, _, _, _, _, _, _, _, _, _, _, _ = _objPtr, client, ewPtr, hPtr, loop, nextPtr, sharedTextPtr, tagPtr, v1, v2, v6, v7, v8, v9 sharedTextPtr = (*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr /* * Free up all the stuff that requires special handling. We have already * called let Tk_FreeConfigOptions to handle all the standard * option-related stuff (and so none of that exists when we are called). * Special note: free up display-related information before deleting the * B-tree, since display-related stuff may refer to stuff in the B-tree. */ XTkTextFreeDInfo(tls, textPtr) (*TTkText)(unsafe.Pointer(textPtr)).FdInfoPtr = libc.UintptrFromInt32(0) /* * Remove ourselves from the peer list. */ if (*TTkSharedText)(unsafe.Pointer(sharedTextPtr)).Fpeers == textPtr { (*TTkSharedText)(unsafe.Pointer(sharedTextPtr)).Fpeers = (*TTkText)(unsafe.Pointer(textPtr)).Fnext } else { nextPtr = (*TTkSharedText)(unsafe.Pointer(sharedTextPtr)).Fpeers for nextPtr != libc.UintptrFromInt32(0) { if (*TTkText)(unsafe.Pointer(nextPtr)).Fnext == textPtr { (*TTkText)(unsafe.Pointer(nextPtr)).Fnext = (*TTkText)(unsafe.Pointer(textPtr)).Fnext break } nextPtr = (*TTkText)(unsafe.Pointer(nextPtr)).Fnext } } /* * Always clean up the widget-specific tags first. Common tags (i.e. most) * will only be cleaned up when the shared structure is cleaned up. * * We also need to clean up widget-specific marks ('insert', 'current'), * since otherwise marks will never disappear from the B-tree. */ XTkTextDeleteTag(tls, textPtr, (*TTkText)(unsafe.Pointer(textPtr)).FselTagPtr) XTkBTreeUnlinkSegment(tls, (*TTkText)(unsafe.Pointer(textPtr)).FinsertMarkPtr, (*(*TTkTextMark)(unsafe.Pointer(&(*TTkTextSegment)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FinsertMarkPtr)).Fbody))).FlinePtr) libtcl9_0.XTcl_Free(tls, (*TTkText)(unsafe.Pointer(textPtr)).FinsertMarkPtr) XTkBTreeUnlinkSegment(tls, (*TTkText)(unsafe.Pointer(textPtr)).FcurrentMarkPtr, (*(*TTkTextMark)(unsafe.Pointer(&(*TTkTextSegment)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FcurrentMarkPtr)).Fbody))).FlinePtr) libtcl9_0.XTcl_Free(tls, (*TTkText)(unsafe.Pointer(textPtr)).FcurrentMarkPtr) /* * Now we've cleaned up everything of relevance to us in the B-tree, so we * disassociate outselves from it. * * When the refCount reaches zero, it's time to clean up the shared * portion of the text widget. */ v2 = sharedTextPtr v1 = *(*TTcl_Size)(unsafe.Pointer(v2)) *(*TTcl_Size)(unsafe.Pointer(v2))-- if v1 > int64(1) { XTkBTreeRemoveClient(tls, (*TTkSharedText)(unsafe.Pointer(sharedTextPtr)).Ftree, textPtr) /* * Free up any embedded windows which belong to this widget. */ hPtr = libtcl9_0.XTcl_FirstHashEntry(tls, sharedTextPtr+232, bp) for { if !(hPtr != libc.UintptrFromInt32(0)) { break } ewPtr = (*TTcl_HashEntry)(unsafe.Pointer(hPtr)).FclientData loop = (*(*TTkTextEmbWindow)(unsafe.Pointer(&(*TTkTextSegment)(unsafe.Pointer(ewPtr)).Fbody))).Fclients if (*TTkTextEmbWindowClient)(unsafe.Pointer(loop)).FtextPtr == textPtr { (*(*TTkTextEmbWindow)(unsafe.Pointer(&(*TTkTextSegment)(unsafe.Pointer(ewPtr)).Fbody))).Fclients = (*TTkTextEmbWindowClient)(unsafe.Pointer(loop)).Fnext XTkTextWinFreeClient(tls, hPtr, loop) } else { client = (*(*TTkTextEmbWindow)(unsafe.Pointer(&(*TTkTextSegment)(unsafe.Pointer(ewPtr)).Fbody))).Fclients client = (*TTkTextEmbWindowClient)(unsafe.Pointer(loop)).Fnext for client != libc.UintptrFromInt32(0) { if (*TTkTextEmbWindowClient)(unsafe.Pointer(client)).FtextPtr == textPtr { (*TTkTextEmbWindowClient)(unsafe.Pointer(loop)).Fnext = (*TTkTextEmbWindowClient)(unsafe.Pointer(client)).Fnext XTkTextWinFreeClient(tls, hPtr, client) break } else { loop = (*TTkTextEmbWindowClient)(unsafe.Pointer(loop)).Fnext } client = (*TTkTextEmbWindowClient)(unsafe.Pointer(loop)).Fnext } } goto _3 _3: ; hPtr = libtcl9_0.XTcl_NextHashEntry(tls, bp) } } else { /* * No need to call 'TkBTreeRemoveClient' first, since this will do * everything in one go, more quickly. */ XTkBTreeDestroy(tls, (*TTkSharedText)(unsafe.Pointer(sharedTextPtr)).Ftree) hPtr = libtcl9_0.XTcl_FirstHashEntry(tls, sharedTextPtr+16, bp) for { if !(hPtr != libc.UintptrFromInt32(0)) { break } tagPtr = (*TTcl_HashEntry)(unsafe.Pointer(hPtr)).FclientData /* * No need to use 'TkTextDeleteTag' since we've already removed * the B-tree completely. */ XTkTextFreeTag(tls, textPtr, tagPtr) goto _4 _4: ; hPtr = libtcl9_0.XTcl_NextHashEntry(tls, bp) } libtcl9_0.XTcl_DeleteHashTable(tls, sharedTextPtr+16) hPtr = libtcl9_0.XTcl_FirstHashEntry(tls, sharedTextPtr+128, bp) for { if !(hPtr != libc.UintptrFromInt32(0)) { break } libtcl9_0.XTcl_Free(tls, (*TTcl_HashEntry)(unsafe.Pointer(hPtr)).FclientData) goto _5 _5: ; hPtr = libtcl9_0.XTcl_NextHashEntry(tls, bp) } libtcl9_0.XTcl_DeleteHashTable(tls, sharedTextPtr+128) XTkUndoFreeStack(tls, (*TTkSharedText)(unsafe.Pointer(sharedTextPtr)).FundoStack) libtcl9_0.XTcl_DeleteHashTable(tls, sharedTextPtr+232) libtcl9_0.XTcl_DeleteHashTable(tls, sharedTextPtr+336) if (*TTkSharedText)(unsafe.Pointer(sharedTextPtr)).FbindingTable != libc.UintptrFromInt32(0) { XTk_DeleteBindingTable(tls, (*TTkSharedText)(unsafe.Pointer(sharedTextPtr)).FbindingTable) } libtcl9_0.XTcl_Free(tls, sharedTextPtr) } if (*TTkText)(unsafe.Pointer(textPtr)).FtabArrayPtr != libc.UintptrFromInt32(0) { libtcl9_0.XTcl_Free(tls, (*TTkText)(unsafe.Pointer(textPtr)).FtabArrayPtr) } if (*TTkText)(unsafe.Pointer(textPtr)).FinsertBlinkHandler != libc.UintptrFromInt32(0) { libtcl9_0.XTcl_DeleteTimerHandler(tls, (*TTkText)(unsafe.Pointer(textPtr)).FinsertBlinkHandler) } (*TTkText)(unsafe.Pointer(textPtr)).Ftkwin = libc.UintptrFromInt32(0) libtcl9_0.XTcl_DeleteCommandFromToken(tls, (*TTkText)(unsafe.Pointer(textPtr)).Finterp, (*TTkText)(unsafe.Pointer(textPtr)).FwidgetCmd) if (*TTkText)(unsafe.Pointer(textPtr)).FafterSyncCmd != 0 { _objPtr = (*TTkText)(unsafe.Pointer(textPtr)).FafterSyncCmd v7 = _objPtr v6 = *(*TTcl_Size)(unsafe.Pointer(v7)) *(*TTcl_Size)(unsafe.Pointer(v7))-- if v6 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr) } (*TTkText)(unsafe.Pointer(textPtr)).FafterSyncCmd = libc.UintptrFromInt32(0) } v9 = textPtr + 688 v8 = *(*TTcl_Size)(unsafe.Pointer(v9)) *(*TTcl_Size)(unsafe.Pointer(v9))-- if v8 <= int64(1) { libtcl9_0.XTcl_Free(tls, textPtr) } } /* *---------------------------------------------------------------------- * * ConfigureText -- * * This function is called to process an objv/objc list, plus the Tk * option database, in order to configure (or reconfigure) a text widget. * * Results: * The return value is a standard Tcl result. If TCL_ERROR is returned, * then the interp's result contains an error message. * * Side effects: * Configuration information, such as text string, colors, font, etc. get * set for textPtr; old resources get freed, if there were any. * *---------------------------------------------------------------------- */ func _ConfigureText1(tls *libc.TLS, interp uintptr, textPtr uintptr, objc TTcl_Size, objv uintptr) (r int32) { bp := tls.Alloc(960) defer tls.Free(960) /* Argument objects. */ var _objPtr, _objPtr1, _objPtr2, _objPtr3, _objPtr4, _objPtr5, linePtr, v10, v12, v2, v4, v6, v8 uintptr var current, end, line, oldExport, selChanged, start int32 var v1, v11, v3, v5, v7, v9 TTcl_Size var _ /* first at bp+712 */ TTkTextIndex var _ /* first at bp+848 */ TTkTextIndex var _ /* index1 at bp+544 */ TTkTextIndex var _ /* index2 at bp+576 */ TTkTextIndex var _ /* index3 at bp+608 */ TTkTextIndex var _ /* insertBorderWidth at bp+532 */ int32 var _ /* insertWidth at bp+536 */ int32 var _ /* last at bp+744 */ TTkTextIndex var _ /* last at bp+880 */ TTkTextIndex var _ /* mask at bp+512 */ int32 var _ /* savedOptions at bp+0 */ TTk_SavedOptions var _ /* search at bp+640 */ TTkTextSearch var _ /* search at bp+776 */ TTkTextSearch var _ /* selBorderWidth at bp+516 */ int32 var _ /* spacing1 at bp+520 */ int32 var _ /* spacing2 at bp+524 */ int32 var _ /* spacing3 at bp+528 */ int32 _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = _objPtr, _objPtr1, _objPtr2, _objPtr3, _objPtr4, _objPtr5, current, end, line, linePtr, oldExport, selChanged, start, v1, v10, v11, v12, v2, v3, v4, v5, v6, v7, v8, v9 oldExport = libc.BoolInt32((*TTkText)(unsafe.Pointer(textPtr)).FexportSelection != 0 && !(libtcl9_0.XTcl_IsSafe(tls, (*TTkText)(unsafe.Pointer(textPtr)).Finterp) != 0)) *(*int32)(unsafe.Pointer(bp + 512)) = 0 *(*int32)(unsafe.Pointer(bp + 516)) = -libc.Int32FromInt32(1) - libc.Int32FromInt32(0x7fffffff) if XTk_SetOptions(tls, interp, textPtr, (*TTkText)(unsafe.Pointer(textPtr)).FoptionTable, objc, objv, (*TTkText)(unsafe.Pointer(textPtr)).Ftkwin, bp, bp+512) != TCL_OK { return int32(TCL_ERROR) } /* * Copy down shared flags. */ (*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).Fundo = (*TTkText)(unsafe.Pointer(textPtr)).Fundo (*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).FmaxUndo = (*TTkText)(unsafe.Pointer(textPtr)).FmaxUndo (*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).FautoSeparators = (*TTkText)(unsafe.Pointer(textPtr)).FautoSeparators XTkUndoSetMaxDepth(tls, (*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).FundoStack, (*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).FmaxUndo) /* * A few other options also need special processing, such as parsing the * geometry and setting the background from a 3-D border. */ XTk_SetBackgroundFromBorder(tls, (*TTkText)(unsafe.Pointer(textPtr)).Ftkwin, (*TTkText)(unsafe.Pointer(textPtr)).Fborder) if *(*int32)(unsafe.Pointer(bp + 512))&(libc.Int32FromInt32(1)< end { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+43606, int64(-libc.Int32FromInt32(1)))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+920, __ccgo_ts+179, __ccgo_ts+16417, __ccgo_ts+43524, libc.UintptrFromInt32(0))) XTk_RestoreSavedOptions(tls, bp) return int32(TCL_ERROR) } current = XTkBTreeLinesTo(tls, libc.UintptrFromInt32(0), (*TTkText)(unsafe.Pointer(textPtr)).FtopIndex.FlinePtr) XTkTextMakeByteIndex(tls, (*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).Ftree, libc.UintptrFromInt32(0), start, 0, bp+544) XTkTextMakeByteIndex(tls, (*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).Ftree, libc.UintptrFromInt32(0), end, 0, bp+576) if current < start || current > end { selChanged = 0 XTkTextSetYView(tls, textPtr, bp+544, 0) /* * We may need to adjust the selection. So we have to check * whether the "sel" tag was applied to anything outside the * current start,end. */ XTkTextMakeByteIndex(tls, (*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).Ftree, libc.UintptrFromInt32(0), 0, 0, bp+712) XTkTextMakeByteIndex(tls, (*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).Ftree, libc.UintptrFromInt32(0), XTkBTreeNumLines(tls, (*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).Ftree, libc.UintptrFromInt32(0)), 0, bp+744) XTkBTreeStartSearch(tls, bp+712, bp+744, (*TTkText)(unsafe.Pointer(textPtr)).FselTagPtr, bp+640) if !(XTkBTreeCharTagged(tls, bp+712, (*TTkText)(unsafe.Pointer(textPtr)).FselTagPtr) != 0) && !(XTkBTreeNextTag(tls, bp+640) != 0) { /* Nothing tagged with "sel" */ } else { line = XTkBTreeLinesTo(tls, libc.UintptrFromInt32(0), (*(*TTkTextSearch)(unsafe.Pointer(bp + 640))).FcurIndex.FlinePtr) if line < start { selChanged = int32(1) } else { linePtr = (*(*TTkTextSearch)(unsafe.Pointer(bp + 640))).FcurIndex.FlinePtr for XTkBTreeNextTag(tls, bp+640) != 0 { linePtr = (*(*TTkTextSearch)(unsafe.Pointer(bp + 640))).FcurIndex.FlinePtr } line = XTkBTreeLinesTo(tls, libc.UintptrFromInt32(0), linePtr) if line >= end { selChanged = int32(1) } } } if selChanged != 0 { /* * Send an event that the selection has changed, and abort any * partial-selections in progress. */ XTkTextSelectionEvent(tls, textPtr) (*TTkText)(unsafe.Pointer(textPtr)).FabortSelections = int32(1) } } /* Indices are potentially obsolete after changing -startline and/or * -endline, therefore increase the epoch. * Also, clamp the insert and current (unshared) marks to the new * -startline/-endline range limits of the widget. All other (shared) * marks are unchanged. * The return value of TkTextMarkNameToIndex does not need to be * checked: "insert" and "current" marks always exist, and the * purpose of the code below precisely is to move them inside the * -startline/-endline range. */ (*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).FstateEpoch++ XTkTextMarkNameToIndex(tls, textPtr, __ccgo_ts+22158, bp+608) if XTkTextIndexCmp(tls, bp+608, bp+544) < 0 { (*TTkText)(unsafe.Pointer(textPtr)).FinsertMarkPtr = XTkTextSetMark(tls, textPtr, __ccgo_ts+22158, bp+544) } if XTkTextIndexCmp(tls, bp+608, bp+576) > 0 { (*TTkText)(unsafe.Pointer(textPtr)).FinsertMarkPtr = XTkTextSetMark(tls, textPtr, __ccgo_ts+22158, bp+576) } XTkTextMarkNameToIndex(tls, textPtr, __ccgo_ts+3279, bp+608) if XTkTextIndexCmp(tls, bp+608, bp+544) < 0 { (*TTkText)(unsafe.Pointer(textPtr)).FcurrentMarkPtr = XTkTextSetMark(tls, textPtr, __ccgo_ts+3279, bp+544) } if XTkTextIndexCmp(tls, bp+608, bp+576) > 0 { (*TTkText)(unsafe.Pointer(textPtr)).FcurrentMarkPtr = XTkTextSetMark(tls, textPtr, __ccgo_ts+3279, bp+576) } } /* * Don't allow negative spacings. */ XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), (*TTkText)(unsafe.Pointer(textPtr)).Ftkwin, (*TTkText)(unsafe.Pointer(textPtr)).Fspacing1Obj, bp+520) if *(*int32)(unsafe.Pointer(bp + 520)) < 0 { *(*int32)(unsafe.Pointer(bp + 520)) = 0 _objPtr = (*TTkText)(unsafe.Pointer(textPtr)).Fspacing1Obj v2 = _objPtr v1 = *(*TTcl_Size)(unsafe.Pointer(v2)) *(*TTcl_Size)(unsafe.Pointer(v2))-- if v1 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr) } (*TTkText)(unsafe.Pointer(textPtr)).Fspacing1Obj = libtcl9_0.XTcl_NewWideIntObj(tls, int64(libc.Int32FromInt32(0))) (*TTcl_Obj)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).Fspacing1Obj)).FrefCount++ } XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), (*TTkText)(unsafe.Pointer(textPtr)).Ftkwin, (*TTkText)(unsafe.Pointer(textPtr)).Fspacing2Obj, bp+524) if *(*int32)(unsafe.Pointer(bp + 524)) < 0 { *(*int32)(unsafe.Pointer(bp + 524)) = 0 _objPtr1 = (*TTkText)(unsafe.Pointer(textPtr)).Fspacing2Obj v4 = _objPtr1 v3 = *(*TTcl_Size)(unsafe.Pointer(v4)) *(*TTcl_Size)(unsafe.Pointer(v4))-- if v3 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr1) } (*TTkText)(unsafe.Pointer(textPtr)).Fspacing2Obj = libtcl9_0.XTcl_NewWideIntObj(tls, int64(libc.Int32FromInt32(0))) (*TTcl_Obj)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).Fspacing2Obj)).FrefCount++ } XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), (*TTkText)(unsafe.Pointer(textPtr)).Ftkwin, (*TTkText)(unsafe.Pointer(textPtr)).Fspacing3Obj, bp+528) if *(*int32)(unsafe.Pointer(bp + 528)) < 0 { *(*int32)(unsafe.Pointer(bp + 528)) = 0 _objPtr2 = (*TTkText)(unsafe.Pointer(textPtr)).Fspacing3Obj v6 = _objPtr2 v5 = *(*TTcl_Size)(unsafe.Pointer(v6)) *(*TTcl_Size)(unsafe.Pointer(v6))-- if v5 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr2) } (*TTkText)(unsafe.Pointer(textPtr)).Fspacing3Obj = libtcl9_0.XTcl_NewWideIntObj(tls, int64(libc.Int32FromInt32(0))) (*TTcl_Obj)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).Fspacing3Obj)).FrefCount++ } XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), (*TTkText)(unsafe.Pointer(textPtr)).Ftkwin, (*TTkText)(unsafe.Pointer(textPtr)).FinsertBorderWidthObj, bp+532) if *(*int32)(unsafe.Pointer(bp + 532)) < 0 { *(*int32)(unsafe.Pointer(bp + 532)) = 0 _objPtr3 = (*TTkText)(unsafe.Pointer(textPtr)).FinsertBorderWidthObj v8 = _objPtr3 v7 = *(*TTcl_Size)(unsafe.Pointer(v8)) *(*TTcl_Size)(unsafe.Pointer(v8))-- if v7 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr3) } (*TTkText)(unsafe.Pointer(textPtr)).FinsertBorderWidthObj = libtcl9_0.XTcl_NewWideIntObj(tls, int64(libc.Int32FromInt32(0))) (*TTcl_Obj)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FinsertBorderWidthObj)).FrefCount++ } XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), (*TTkText)(unsafe.Pointer(textPtr)).Ftkwin, (*TTkText)(unsafe.Pointer(textPtr)).FinsertWidthObj, bp+536) if *(*int32)(unsafe.Pointer(bp + 536)) < 0 { *(*int32)(unsafe.Pointer(bp + 536)) = 0 _objPtr4 = (*TTkText)(unsafe.Pointer(textPtr)).FinsertWidthObj v10 = _objPtr4 v9 = *(*TTcl_Size)(unsafe.Pointer(v10)) *(*TTcl_Size)(unsafe.Pointer(v10))-- if v9 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr4) } (*TTkText)(unsafe.Pointer(textPtr)).FinsertWidthObj = libtcl9_0.XTcl_NewWideIntObj(tls, int64(libc.Int32FromInt32(0))) (*TTcl_Obj)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FinsertWidthObj)).FrefCount++ } if (*TTkText)(unsafe.Pointer(textPtr)).FselBorderWidthObj != 0 { XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), (*TTkText)(unsafe.Pointer(textPtr)).Ftkwin, (*TTkText)(unsafe.Pointer(textPtr)).FselBorderWidthObj, bp+516) } if *(*int32)(unsafe.Pointer(bp + 516)) < 0 { *(*int32)(unsafe.Pointer(bp + 516)) = 0 if (*TTkText)(unsafe.Pointer(textPtr)).FselBorderWidthObj != 0 { _objPtr5 = (*TTkText)(unsafe.Pointer(textPtr)).FselBorderWidthObj v12 = _objPtr5 v11 = *(*TTcl_Size)(unsafe.Pointer(v12)) *(*TTcl_Size)(unsafe.Pointer(v12))-- if v11 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr5) } } (*TTkText)(unsafe.Pointer(textPtr)).FselBorderWidthObj = libtcl9_0.XTcl_NewWideIntObj(tls, int64(libc.Int32FromInt32(0))) (*TTcl_Obj)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FselBorderWidthObj)).FrefCount++ } /* * Parse tab stops. */ if (*TTkText)(unsafe.Pointer(textPtr)).FtabArrayPtr != libc.UintptrFromInt32(0) { libtcl9_0.XTcl_Free(tls, (*TTkText)(unsafe.Pointer(textPtr)).FtabArrayPtr) (*TTkText)(unsafe.Pointer(textPtr)).FtabArrayPtr = libc.UintptrFromInt32(0) } if (*TTkText)(unsafe.Pointer(textPtr)).FtabOptionObj != libc.UintptrFromInt32(0) { (*TTkText)(unsafe.Pointer(textPtr)).FtabArrayPtr = XTkTextGetTabs(tls, interp, (*TTkText)(unsafe.Pointer(textPtr)).Ftkwin, (*TTkText)(unsafe.Pointer(textPtr)).FtabOptionObj) if (*TTkText)(unsafe.Pointer(textPtr)).FtabArrayPtr == libc.UintptrFromInt32(0) { libtcl9_0.XTcl_AppendObjToErrorInfo(tls, interp, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+43656, int64(-int32(1)))) XTk_RestoreSavedOptions(tls, bp) return int32(TCL_ERROR) } } /* * Make sure that configuration options are properly mirrored between the * widget record and the "sel" tags. NOTE: we don't have to free up * information during the mirroring; old information was freed when it was * replaced in the widget record. */ if (*TTkTextTag)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FselTagPtr)).FselBorder == libc.UintptrFromInt32(0) { (*TTkTextTag)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FselTagPtr)).Fborder = (*TTkText)(unsafe.Pointer(textPtr)).FselBorder } else { (*TTkTextTag)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FselTagPtr)).FselBorder = (*TTkText)(unsafe.Pointer(textPtr)).FselBorder } if (*TTkTextTag)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FselTagPtr)).FborderWidthObj != (*TTkText)(unsafe.Pointer(textPtr)).FselBorderWidthObj { (*TTkTextTag)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FselTagPtr)).FborderWidthObj = (*TTkText)(unsafe.Pointer(textPtr)).FselBorderWidthObj } if (*TTkTextTag)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FselTagPtr)).FselFgColor == libc.UintptrFromInt32(0) { (*TTkTextTag)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FselTagPtr)).FfgColor = (*TTkText)(unsafe.Pointer(textPtr)).FselFgColorPtr } else { (*TTkTextTag)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FselTagPtr)).FselFgColor = (*TTkText)(unsafe.Pointer(textPtr)).FselFgColorPtr } (*TTkTextTag)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FselTagPtr)).FaffectsDisplay = 0 (*TTkTextTag)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FselTagPtr)).FaffectsDisplayGeometry = 0 if (*TTkTextTag)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FselTagPtr)).Felide >= 0 || (*TTkTextTag)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FselTagPtr)).Ftkfont != libc.UintptrFromInt32(0) || (*TTkTextTag)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FselTagPtr)).Fjustify != int32(TK_JUSTIFY_NULL) || (*TTkTextTag)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FselTagPtr)).FlMargin1Obj != libc.UintptrFromInt32(0) || (*TTkTextTag)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FselTagPtr)).FlMargin2Obj != libc.UintptrFromInt32(0) || (*TTkTextTag)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FselTagPtr)).FoffsetObj != libc.UintptrFromInt32(0) || (*TTkTextTag)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FselTagPtr)).FrMarginObj != libc.UintptrFromInt32(0) || (*TTkTextTag)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FselTagPtr)).Fspacing1Obj != libc.UintptrFromInt32(0) || (*TTkTextTag)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FselTagPtr)).Fspacing2Obj != libc.UintptrFromInt32(0) || (*TTkTextTag)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FselTagPtr)).Fspacing3Obj != libc.UintptrFromInt32(0) || (*TTkTextTag)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FselTagPtr)).FtabStringPtr != libc.UintptrFromInt32(0) || (*TTkTextTag)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FselTagPtr)).FtabStyle == int32(TK_TEXT_TABSTYLE_TABULAR) || (*TTkTextTag)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FselTagPtr)).FtabStyle == int32(TK_TEXT_TABSTYLE_WORDPROCESSOR) || (*TTkTextTag)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FselTagPtr)).FwrapMode == int32(TEXT_WRAPMODE_CHAR) || (*TTkTextTag)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FselTagPtr)).FwrapMode == int32(TEXT_WRAPMODE_NONE) || (*TTkTextTag)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FselTagPtr)).FwrapMode == int32(TEXT_WRAPMODE_WORD) { (*TTkTextTag)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FselTagPtr)).FaffectsDisplay = int32(1) (*TTkTextTag)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FselTagPtr)).FaffectsDisplayGeometry = int32(1) } if (*TTkTextTag)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FselTagPtr)).Fborder != libc.UintptrFromInt32(0) || (*TTkTextTag)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FselTagPtr)).FselBorder != libc.UintptrFromInt32(0) || (*TTkTextTag)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FselTagPtr)).Frelief != -int32(1) || (*TTkTextTag)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FselTagPtr)).FbgStipple != uint64(0) || (*TTkTextTag)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FselTagPtr)).FfgColor != libc.UintptrFromInt32(0) || (*TTkTextTag)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FselTagPtr)).FselFgColor != libc.UintptrFromInt32(0) || (*TTkTextTag)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FselTagPtr)).FfgStipple != uint64(0) || (*TTkTextTag)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FselTagPtr)).Foverstrike >= 0 || (*TTkTextTag)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FselTagPtr)).FoverstrikeColor != libc.UintptrFromInt32(0) || (*TTkTextTag)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FselTagPtr)).Funderline >= 0 || (*TTkTextTag)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FselTagPtr)).FunderlineColor != libc.UintptrFromInt32(0) || (*TTkTextTag)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FselTagPtr)).FlMarginColor != libc.UintptrFromInt32(0) || (*TTkTextTag)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FselTagPtr)).FrMarginColor != libc.UintptrFromInt32(0) { (*TTkTextTag)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FselTagPtr)).FaffectsDisplay = int32(1) } XTkTextRedrawTag(tls, libc.UintptrFromInt32(0), textPtr, libc.UintptrFromInt32(0), libc.UintptrFromInt32(0), (*TTkText)(unsafe.Pointer(textPtr)).FselTagPtr, int32(1)) /* * Claim the selection if we've suddenly started exporting it and there * are tagged characters. */ if (*TTkText)(unsafe.Pointer(textPtr)).FexportSelection != 0 && !(oldExport != 0) && !(libtcl9_0.XTcl_IsSafe(tls, (*TTkText)(unsafe.Pointer(textPtr)).Finterp) != 0) { XTkTextMakeByteIndex(tls, (*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).Ftree, textPtr, 0, 0, bp+848) XTkTextMakeByteIndex(tls, (*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).Ftree, textPtr, XTkBTreeNumLines(tls, (*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).Ftree, textPtr), 0, bp+880) XTkBTreeStartSearch(tls, bp+848, bp+880, (*TTkText)(unsafe.Pointer(textPtr)).FselTagPtr, bp+776) if XTkBTreeCharTagged(tls, bp+848, (*TTkText)(unsafe.Pointer(textPtr)).FselTagPtr) != 0 || XTkBTreeNextTag(tls, bp+776) != 0 { XTk_OwnSelection(tls, (*TTkText)(unsafe.Pointer(textPtr)).Ftkwin, libc.Uint64FromInt32(1), __ccgo_fp(XTkTextLostSelection), textPtr) *(*int32)(unsafe.Pointer(textPtr + 672)) |= int32(GOT_SELECTION1) } } /* * Account for state changes that would reenable blinking cursor state. */ if (*TTkText)(unsafe.Pointer(textPtr)).Fflags&int32(GOT_FOCUS8) != 0 { libtcl9_0.XTcl_DeleteTimerHandler(tls, (*TTkText)(unsafe.Pointer(textPtr)).FinsertBlinkHandler) (*TTkText)(unsafe.Pointer(textPtr)).FinsertBlinkHandler = libc.UintptrFromInt32(0) _TextBlinkProc(tls, textPtr) } /* * Register the desired geometry for the window, and arrange for the * window to be redisplayed. */ if (*TTkText)(unsafe.Pointer(textPtr)).Fwidth <= 0 { (*TTkText)(unsafe.Pointer(textPtr)).Fwidth = int32(1) } XTk_FreeSavedOptions(tls, bp) _TextWorldChanged(tls, textPtr, *(*int32)(unsafe.Pointer(bp + 512))) return TCL_OK } /* *--------------------------------------------------------------------------- * * TextWorldChangedCallback -- * * This function is called when the world has changed in some way and the * widget needs to recompute all its graphics contexts and determine its * new geometry. * * Results: * None. * * Side effects: * Configures all tags in the Text with a empty objc/objv, for the side * effect of causing all the items to recompute their geometry and to be * redisplayed. * *--------------------------------------------------------------------------- */ func _TextWorldChangedCallback(tls *libc.TLS, instanceData uintptr) { /* Information about widget. */ var textPtr uintptr _ = textPtr textPtr = instanceData _TextWorldChanged(tls, textPtr, libc.Int32FromInt32(1)< 0 { XTkTextRedrawRegion(tls, textPtr, 0, 0, *(*int32)(unsafe.Pointer(bp + 64)), *(*int32)(unsafe.Pointer(bp + 64))) } } } } } } } /* *---------------------------------------------------------------------- * * TextCmdDeletedProc -- * * This function is invoked when a widget command is deleted. If the * widget isn't already in the process of being destroyed, this command * destroys it. * * Results: * None. * * Side effects: * The widget is destroyed. * *---------------------------------------------------------------------- */ func _TextCmdDeletedProc(tls *libc.TLS, clientData uintptr) { /* Pointer to widget record for widget. */ var textPtr uintptr var tkwin TTk_Window _, _ = textPtr, tkwin textPtr = clientData tkwin = (*TTkText)(unsafe.Pointer(textPtr)).Ftkwin /* * This function could be invoked either because the window was destroyed * and the command was then deleted (in which this flag is already set) or * because the command was deleted, and then this function destroys the * widget. */ if !((*TTkText)(unsafe.Pointer(textPtr)).Fflags&libc.Int32FromInt32(DESTROYED) != 0) { if (*TTkText)(unsafe.Pointer(textPtr)).FsetGrid != 0 { XTk_UnsetGrid(tls, (*TTkText)(unsafe.Pointer(textPtr)).Ftkwin) (*TTkText)(unsafe.Pointer(textPtr)).FsetGrid = 0 } *(*int32)(unsafe.Pointer(textPtr + 672)) |= int32(DESTROYED) XTk_DestroyWindow(tls, tkwin) } } /* *---------------------------------------------------------------------- * * InsertChars -- * * This function implements most of the functionality of the "insert" * widget command. * * Results: * The length of the inserted string. * * Side effects: * The characters in "stringPtr" get added to the text just before the * character indicated by "indexPtr". * * If 'viewUpdate' is true, we may adjust the window contents' * y-position, and scrollbar setting. * *---------------------------------------------------------------------- */ func _InsertChars1(tls *libc.TLS, sharedTextPtr uintptr, textPtr uintptr, indexPtr uintptr, stringPtr uintptr, viewUpdate int32) (r int32) { bp := tls.Alloc(112) defer tls.Free(112) /* Update the view if set. */ var lineAndByteIndex, string1, tPtr, p2 uintptr var lineIndex, resetViewCount int32 var _ /* length at bp+0 */ TTcl_Size var _ /* newTop at bp+80 */ TTkTextIndex var _ /* pixels at bp+8 */ [10]int32 var _ /* toIndex at bp+48 */ TTkTextIndex _, _, _, _, _, _ = lineAndByteIndex, lineIndex, resetViewCount, string1, tPtr, p2 string1 = libtcl9_0.XTcl_GetStringFromObj(tls, stringPtr, bp) if sharedTextPtr == libc.UintptrFromInt32(0) { sharedTextPtr = (*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr } /* * Don't allow insertions on the last (dummy) line of the text. This is * the only place in this function where the indexPtr is modified. */ lineIndex = XTkBTreeLinesTo(tls, textPtr, (*TTkTextIndex)(unsafe.Pointer(indexPtr)).FlinePtr) if lineIndex == XTkBTreeNumLines(tls, (*TTkSharedText)(unsafe.Pointer(sharedTextPtr)).Ftree, textPtr) { lineIndex-- XTkTextMakeByteIndex(tls, (*TTkSharedText)(unsafe.Pointer(sharedTextPtr)).Ftree, textPtr, lineIndex, int64(1000000), indexPtr) } /* * Notify the display module that lines are about to change, then do the * insertion. If the insertion occurs on the top line of the widget * (textPtr->topIndex), then we have to recompute topIndex after the * insertion, since the insertion could invalidate it. */ resetViewCount = 0 if (*TTkSharedText)(unsafe.Pointer(sharedTextPtr)).FrefCount > int64(PIXEL_CLIENTS) { lineAndByteIndex = libtcl9_0.XTcl_Alloc(tls, libc.Uint64FromInt64(4)*libc.Uint64FromInt32(2)*libc.Uint64FromInt64((*TTkSharedText)(unsafe.Pointer(sharedTextPtr)).FrefCount)) } else { lineAndByteIndex = bp + 8 } tPtr = (*TTkSharedText)(unsafe.Pointer(sharedTextPtr)).Fpeers for { if !(tPtr != libc.UintptrFromInt32(0)) { break } *(*int32)(unsafe.Pointer(lineAndByteIndex + uintptr(resetViewCount)*4)) = -int32(1) if (*TTkTextIndex)(unsafe.Pointer(indexPtr)).FlinePtr == (*TTkText)(unsafe.Pointer(tPtr)).FtopIndex.FlinePtr { *(*int32)(unsafe.Pointer(lineAndByteIndex + uintptr(resetViewCount)*4)) = XTkBTreeLinesTo(tls, tPtr, (*TTkTextIndex)(unsafe.Pointer(indexPtr)).FlinePtr) *(*int32)(unsafe.Pointer(lineAndByteIndex + uintptr(resetViewCount+int32(1))*4)) = int32((*TTkText)(unsafe.Pointer(tPtr)).FtopIndex.FbyteIndex) if int64(*(*int32)(unsafe.Pointer(lineAndByteIndex + uintptr(resetViewCount+int32(1))*4))) > (*TTkTextIndex)(unsafe.Pointer(indexPtr)).FbyteIndex { p2 = lineAndByteIndex + uintptr(resetViewCount+int32(1))*4 *(*int32)(unsafe.Pointer(p2)) = int32(int64(*(*int32)(unsafe.Pointer(p2))) + *(*TTcl_Size)(unsafe.Pointer(bp))) } } resetViewCount += int32(2) goto _1 _1: ; tPtr = (*TTkText)(unsafe.Pointer(tPtr)).Fnext } XTkTextChanged(tls, sharedTextPtr, libc.UintptrFromInt32(0), indexPtr, indexPtr) (*TTkSharedText)(unsafe.Pointer(sharedTextPtr)).FstateEpoch++ XTkBTreeInsertChars(tls, (*TTkSharedText)(unsafe.Pointer(sharedTextPtr)).Ftree, indexPtr, string1) /* * Push the insertion on the undo stack, and update the modified status of * the widget. */ if *(*TTcl_Size)(unsafe.Pointer(bp)) > 0 { if (*TTkSharedText)(unsafe.Pointer(sharedTextPtr)).Fundo != 0 { if (*TTkSharedText)(unsafe.Pointer(sharedTextPtr)).FautoSeparators != 0 && (*TTkSharedText)(unsafe.Pointer(sharedTextPtr)).FlastEditMode != int32(TK_TEXT_EDIT_INSERT) { XTkUndoInsertUndoSeparator(tls, (*TTkSharedText)(unsafe.Pointer(sharedTextPtr)).FundoStack) } (*TTkSharedText)(unsafe.Pointer(sharedTextPtr)).FlastEditMode = int32(TK_TEXT_EDIT_INSERT) XTkTextIndexForwBytes(tls, textPtr, indexPtr, *(*TTcl_Size)(unsafe.Pointer(bp)), bp+48) _TextPushUndoAction(tls, textPtr, stringPtr, int32(1), indexPtr, bp+48) } _UpdateDirtyFlag(tls, sharedTextPtr) } resetViewCount = 0 tPtr = (*TTkSharedText)(unsafe.Pointer(sharedTextPtr)).Fpeers for { if !(tPtr != libc.UintptrFromInt32(0)) { break } if *(*int32)(unsafe.Pointer(lineAndByteIndex + uintptr(resetViewCount)*4)) != -int32(1) { if tPtr != textPtr || viewUpdate != 0 { XTkTextMakeByteIndex(tls, (*TTkSharedText)(unsafe.Pointer(sharedTextPtr)).Ftree, tPtr, *(*int32)(unsafe.Pointer(lineAndByteIndex + uintptr(resetViewCount)*4)), 0, bp+80) XTkTextIndexForwBytes(tls, tPtr, bp+80, int64(*(*int32)(unsafe.Pointer(lineAndByteIndex + uintptr(resetViewCount+int32(1))*4))), bp+80) XTkTextSetYView(tls, tPtr, bp+80, 0) } } resetViewCount += int32(2) goto _3 _3: ; tPtr = (*TTkText)(unsafe.Pointer(tPtr)).Fnext } if (*TTkSharedText)(unsafe.Pointer(sharedTextPtr)).FrefCount > int64(PIXEL_CLIENTS) { libtcl9_0.XTcl_Free(tls, lineAndByteIndex) } /* * Invalidate any selection retrievals in progress, and send an event * that the selection changed if that is the case. */ tPtr = (*TTkSharedText)(unsafe.Pointer(sharedTextPtr)).Fpeers for { if !(tPtr != libc.UintptrFromInt32(0)) { break } if XTkBTreeCharTagged(tls, indexPtr, (*TTkText)(unsafe.Pointer(tPtr)).FselTagPtr) != 0 { XTkTextSelectionEvent(tls, tPtr) } (*TTkText)(unsafe.Pointer(tPtr)).FabortSelections = int32(1) goto _4 _4: ; tPtr = (*TTkText)(unsafe.Pointer(tPtr)).Fnext } /* * For convenience, return the length of the string. */ return int32(*(*TTcl_Size)(unsafe.Pointer(bp))) } /* *---------------------------------------------------------------------- * * TextPushUndoAction -- * * Shared by insert and delete actions. Stores the appropriate scripts * into our undo stack. We will add a single refCount to the 'undoString' * object, so, if it previously had a refCount of zero, the caller should * not free it. * * Results: * None. * * Side effects: * Items pushed onto stack. * *---------------------------------------------------------------------- */ func _TextPushUndoAction(tls *libc.TLS, textPtr uintptr, undoString uintptr, insert int32, index1Ptr uintptr, index2Ptr uintptr) { bp := tls.Alloc(128) defer tls.Free(128) /* Index describing second location. */ var _objPtr, _objPtr1, _objPtr2, dAtom, deleteCmdObj, iAtom, index1Obj, index2Obj, insertCmdObj, markGravityLUndoMarkCmdObj, markGravityRUndoMarkCmdObj, markSet1InsertObj, markSet2InsertObj, markSetLUndoMarkCmdObj, markSetRUndoMarkCmdObj, seeInsertObj, v2, v4, v6 uintptr var canRedo, canUndo int32 var v1, v3, v5 TTcl_Size var _ /* lMarkName at bp+0 */ [40]uint8 var _ /* rMarkName at bp+40 */ [40]uint8 var _ /* stringUndoMarkId at bp+80 */ [24]uint8 _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = _objPtr, _objPtr1, _objPtr2, canRedo, canUndo, dAtom, deleteCmdObj, iAtom, index1Obj, index2Obj, insertCmdObj, markGravityLUndoMarkCmdObj, markGravityRUndoMarkCmdObj, markSet1InsertObj, markSet2InsertObj, markSetLUndoMarkCmdObj, markSetRUndoMarkCmdObj, seeInsertObj, v1, v2, v3, v4, v5, v6 *(*[40]uint8)(unsafe.Pointer(bp)) = [40]uint8{'t', 'k', ':', ':', 'u', 'n', 'd', 'o', 'M', 'a', 'r', 'k', 'L'} *(*[40]uint8)(unsafe.Pointer(bp + 40)) = [40]uint8{'t', 'k', ':', ':', 'u', 'n', 'd', 'o', 'M', 'a', 'r', 'k', 'R'} *(*[24]uint8)(unsafe.Pointer(bp + 80)) = [24]uint8{} /* * Create the helpers. */ seeInsertObj = libtcl9_0.XTcl_NewObj(tls) markSet1InsertObj = libtcl9_0.XTcl_NewObj(tls) markSet2InsertObj = libc.UintptrFromInt32(0) insertCmdObj = libtcl9_0.XTcl_NewObj(tls) deleteCmdObj = libtcl9_0.XTcl_NewObj(tls) markSetLUndoMarkCmdObj = libtcl9_0.XTcl_NewObj(tls) markSetRUndoMarkCmdObj = libc.UintptrFromInt32(0) markGravityLUndoMarkCmdObj = libtcl9_0.XTcl_NewObj(tls) markGravityRUndoMarkCmdObj = libc.UintptrFromInt32(0) /* * Get the index positions. */ index1Obj = XTkTextNewIndexObj(tls, libc.UintptrFromInt32(0), index1Ptr) index2Obj = XTkTextNewIndexObj(tls, libc.UintptrFromInt32(0), index2Ptr) /* * These need refCounts, because they are used more than once below. */ (*TTcl_Obj)(unsafe.Pointer(seeInsertObj)).FrefCount++ (*TTcl_Obj)(unsafe.Pointer(index1Obj)).FrefCount++ (*TTcl_Obj)(unsafe.Pointer(index2Obj)).FrefCount++ libtcl9_0.XTcl_ListObjAppendElement(tls, libc.UintptrFromInt32(0), seeInsertObj, libtcl9_0.XTcl_NewStringObj(tls, (*TTk_FakeWin)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).Ftkwin)).FpathName, int64(-libc.Int32FromInt32(1)))) libtcl9_0.XTcl_ListObjAppendElement(tls, libc.UintptrFromInt32(0), seeInsertObj, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+23682, int64(3))) libtcl9_0.XTcl_ListObjAppendElement(tls, libc.UintptrFromInt32(0), seeInsertObj, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+22158, int64(6))) libtcl9_0.XTcl_ListObjAppendElement(tls, libc.UintptrFromInt32(0), markSet1InsertObj, libtcl9_0.XTcl_NewStringObj(tls, (*TTk_FakeWin)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).Ftkwin)).FpathName, int64(-libc.Int32FromInt32(1)))) libtcl9_0.XTcl_ListObjAppendElement(tls, libc.UintptrFromInt32(0), markSet1InsertObj, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+2046, int64(4))) libtcl9_0.XTcl_ListObjAppendElement(tls, libc.UintptrFromInt32(0), markSet1InsertObj, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+11726, int64(3))) libtcl9_0.XTcl_ListObjAppendElement(tls, libc.UintptrFromInt32(0), markSet1InsertObj, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+22158, int64(6))) markSet2InsertObj = libtcl9_0.XTcl_DuplicateObj(tls, markSet1InsertObj) libtcl9_0.XTcl_ListObjAppendElement(tls, libc.UintptrFromInt32(0), markSet1InsertObj, index1Obj) libtcl9_0.XTcl_ListObjAppendElement(tls, libc.UintptrFromInt32(0), markSet2InsertObj, index2Obj) libtcl9_0.XTcl_ListObjAppendElement(tls, libc.UintptrFromInt32(0), insertCmdObj, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+22158, int64(6))) libtcl9_0.XTcl_ListObjAppendElement(tls, libc.UintptrFromInt32(0), insertCmdObj, index1Obj) /* * Only use of 'undoString' is here. */ libtcl9_0.XTcl_ListObjAppendElement(tls, libc.UintptrFromInt32(0), insertCmdObj, undoString) libtcl9_0.XTcl_ListObjAppendElement(tls, libc.UintptrFromInt32(0), deleteCmdObj, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+2655, int64(6))) libtcl9_0.XTcl_ListObjAppendElement(tls, libc.UintptrFromInt32(0), deleteCmdObj, index1Obj) libtcl9_0.XTcl_ListObjAppendElement(tls, libc.UintptrFromInt32(0), deleteCmdObj, index2Obj) libtcl9_0.XTcl_ListObjAppendElement(tls, libc.UintptrFromInt32(0), markSetLUndoMarkCmdObj, libtcl9_0.XTcl_NewStringObj(tls, (*TTk_FakeWin)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).Ftkwin)).FpathName, int64(-libc.Int32FromInt32(1)))) libtcl9_0.XTcl_ListObjAppendElement(tls, libc.UintptrFromInt32(0), markSetLUndoMarkCmdObj, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+2046, int64(4))) libtcl9_0.XTcl_ListObjAppendElement(tls, libc.UintptrFromInt32(0), markSetLUndoMarkCmdObj, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+11726, int64(3))) markSetRUndoMarkCmdObj = libtcl9_0.XTcl_DuplicateObj(tls, markSetLUndoMarkCmdObj) (*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).FundoMarkId++ libc.X__builtin_snprintf(tls, bp+80, libc.Uint64FromInt32(libc.Int32FromInt32(3)*libc.Int32FromInt64(8)), __ccgo_ts+43693, libc.VaList(bp+112, (*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).FundoMarkId)) libc.Xstrcat(tls, bp, bp+80) libc.Xstrcat(tls, bp+40, bp+80) libtcl9_0.XTcl_ListObjAppendElement(tls, libc.UintptrFromInt32(0), markSetLUndoMarkCmdObj, libtcl9_0.XTcl_NewStringObj(tls, bp, int64(-libc.Int32FromInt32(1)))) libtcl9_0.XTcl_ListObjAppendElement(tls, libc.UintptrFromInt32(0), markSetRUndoMarkCmdObj, libtcl9_0.XTcl_NewStringObj(tls, bp+40, int64(-libc.Int32FromInt32(1)))) libtcl9_0.XTcl_ListObjAppendElement(tls, libc.UintptrFromInt32(0), markSetLUndoMarkCmdObj, index1Obj) libtcl9_0.XTcl_ListObjAppendElement(tls, libc.UintptrFromInt32(0), markSetRUndoMarkCmdObj, index2Obj) libtcl9_0.XTcl_ListObjAppendElement(tls, libc.UintptrFromInt32(0), markGravityLUndoMarkCmdObj, libtcl9_0.XTcl_NewStringObj(tls, (*TTk_FakeWin)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).Ftkwin)).FpathName, int64(-libc.Int32FromInt32(1)))) libtcl9_0.XTcl_ListObjAppendElement(tls, libc.UintptrFromInt32(0), markGravityLUndoMarkCmdObj, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+2046, int64(4))) libtcl9_0.XTcl_ListObjAppendElement(tls, libc.UintptrFromInt32(0), markGravityLUndoMarkCmdObj, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+43697, int64(7))) markGravityRUndoMarkCmdObj = libtcl9_0.XTcl_DuplicateObj(tls, markGravityLUndoMarkCmdObj) libtcl9_0.XTcl_ListObjAppendElement(tls, libc.UintptrFromInt32(0), markGravityLUndoMarkCmdObj, libtcl9_0.XTcl_NewStringObj(tls, bp, int64(-libc.Int32FromInt32(1)))) libtcl9_0.XTcl_ListObjAppendElement(tls, libc.UintptrFromInt32(0), markGravityRUndoMarkCmdObj, libtcl9_0.XTcl_NewStringObj(tls, bp+40, int64(-libc.Int32FromInt32(1)))) libtcl9_0.XTcl_ListObjAppendElement(tls, libc.UintptrFromInt32(0), markGravityLUndoMarkCmdObj, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+10966, int64(4))) libtcl9_0.XTcl_ListObjAppendElement(tls, libc.UintptrFromInt32(0), markGravityRUndoMarkCmdObj, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+10971, int64(5))) /* * Note: we don't wish to use textPtr->widgetCmd in these callbacks * because if we delete the textPtr, but peers still exist, we will then * have references to a non-existent Tcl_Command in the undo stack, which * will lead to crashes later. Also, the behaviour of the widget w.r.t. * bindings (%W substitutions) always uses the widget path name, so there * is no good reason the undo stack should do otherwise. * * For the 'insert' and 'delete' actions, we have to register a functional * callback, because these actions are defined to operate on the * underlying data shared by all peers. */ iAtom = XTkUndoMakeSubAtom(tls, __ccgo_fp(_TextUndoRedoCallback), (*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr, insertCmdObj, libc.UintptrFromInt32(0)) XTkUndoMakeCmdSubAtom(tls, libc.UintptrFromInt32(0), markSet2InsertObj, iAtom) XTkUndoMakeCmdSubAtom(tls, libc.UintptrFromInt32(0), seeInsertObj, iAtom) XTkUndoMakeCmdSubAtom(tls, libc.UintptrFromInt32(0), markSetLUndoMarkCmdObj, iAtom) XTkUndoMakeCmdSubAtom(tls, libc.UintptrFromInt32(0), markSetRUndoMarkCmdObj, iAtom) XTkUndoMakeCmdSubAtom(tls, libc.UintptrFromInt32(0), markGravityLUndoMarkCmdObj, iAtom) XTkUndoMakeCmdSubAtom(tls, libc.UintptrFromInt32(0), markGravityRUndoMarkCmdObj, iAtom) dAtom = XTkUndoMakeSubAtom(tls, __ccgo_fp(_TextUndoRedoCallback), (*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr, deleteCmdObj, libc.UintptrFromInt32(0)) XTkUndoMakeCmdSubAtom(tls, libc.UintptrFromInt32(0), markSet1InsertObj, dAtom) XTkUndoMakeCmdSubAtom(tls, libc.UintptrFromInt32(0), seeInsertObj, dAtom) XTkUndoMakeCmdSubAtom(tls, libc.UintptrFromInt32(0), markSetLUndoMarkCmdObj, dAtom) XTkUndoMakeCmdSubAtom(tls, libc.UintptrFromInt32(0), markSetRUndoMarkCmdObj, dAtom) XTkUndoMakeCmdSubAtom(tls, libc.UintptrFromInt32(0), markGravityLUndoMarkCmdObj, dAtom) XTkUndoMakeCmdSubAtom(tls, libc.UintptrFromInt32(0), markGravityRUndoMarkCmdObj, dAtom) _objPtr = seeInsertObj v2 = _objPtr v1 = *(*TTcl_Size)(unsafe.Pointer(v2)) *(*TTcl_Size)(unsafe.Pointer(v2))-- if v1 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr) } _objPtr1 = index1Obj v4 = _objPtr1 v3 = *(*TTcl_Size)(unsafe.Pointer(v4)) *(*TTcl_Size)(unsafe.Pointer(v4))-- if v3 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr1) } _objPtr2 = index2Obj v6 = _objPtr2 v5 = *(*TTcl_Size)(unsafe.Pointer(v6)) *(*TTcl_Size)(unsafe.Pointer(v6))-- if v5 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr2) } canUndo = XTkUndoCanUndo(tls, (*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).FundoStack) canRedo = XTkUndoCanRedo(tls, (*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).FundoStack) /* * Depending whether the action is to insert or delete, we provide the * appropriate second and third arguments to TkUndoPushAction. (The first * is the 'actionCommand', and the second the 'revertCommand'). */ if insert != 0 { XTkUndoPushAction(tls, (*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).FundoStack, iAtom, dAtom) } else { XTkUndoPushAction(tls, (*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).FundoStack, dAtom, iAtom) } if !(canUndo != 0) || canRedo != 0 { _GenerateUndoStackEvent(tls, textPtr) } } /* *---------------------------------------------------------------------- * * TextUndoRedoCallback -- * * This function is registered with the generic undo/redo code to handle * 'insert' and 'delete' actions on all text widgets. We cannot perform * those actions on any particular text widget, because that text widget * might have been deleted by the time we get here. * * Results: * A standard Tcl result. * * Side effects: * Will insert or delete text, depending on the first word contained in * objPtr. * *---------------------------------------------------------------------- */ func _TextUndoRedoCallback(tls *libc.TLS, interp uintptr, clientData uintptr, objPtr uintptr) (r int32) { bp := tls.Alloc(16) defer tls.Free(16) /* Arguments of a command to be handled by the * shared text data structure. */ var _objPtr, cmdNameObj, evalObj, sharedPtr, textPtr, v2 uintptr var res int32 var v1 TTcl_Size var _ /* objc at bp+0 */ TTcl_Size var _ /* objv at bp+8 */ uintptr _, _, _, _, _, _, _, _ = _objPtr, cmdNameObj, evalObj, res, sharedPtr, textPtr, v1, v2 sharedPtr = clientData res = libtcl9_0.XTcl_ListObjGetElements(tls, interp, objPtr, bp, bp+8) if res != TCL_OK { return res } /* * If possible, use a real text widget to perform the undo/redo action * (i.e. insertion or deletion of text). This provides maximum * compatibility with older versions of Tk, in which the user may rename * the text widget to allow capture of undo or redo actions. * * In particular, this sorting of capture is useful in text editors based * on the Tk text widget, which need to know which new text needs * re-coloring. * * It would be better if the text widget provided some other mechanism to * allow capture of this information ("What has just changed in the text * widget?"). What we have here is not entirely satisfactory under all * circumstances. */ textPtr = (*TTkSharedText)(unsafe.Pointer(sharedPtr)).Fpeers for textPtr != libc.UintptrFromInt32(0) { if (*TTkText)(unsafe.Pointer(textPtr)).Fstart == libc.UintptrFromInt32(0) && (*TTkText)(unsafe.Pointer(textPtr)).Fend == libc.UintptrFromInt32(0) { evalObj = libtcl9_0.XTcl_NewObj(tls) (*TTcl_Obj)(unsafe.Pointer(evalObj)).FrefCount++ /* * We might wish to use the real, current command-name for the * widget, but this will break any code that has over-ridden the * widget, and is expecting to observe the insert/delete actions * which are caused by undo/redo operations. * * cmdNameObj = Tcl_NewObj(); * Tcl_GetCommandFullName(interp, textPtr->widgetCmd, cmdNameObj); * * While such interception is not explicitly documented as * supported, it does occur, and so until we can provide some * alternative mechanism for such code to do what it needs, we * allow it to take place here. */ cmdNameObj = libtcl9_0.XTcl_NewStringObj(tls, (*TTk_FakeWin)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).Ftkwin)).FpathName, int64(-libc.Int32FromInt32(1))) libtcl9_0.XTcl_ListObjAppendElement(tls, libc.UintptrFromInt32(0), evalObj, cmdNameObj) libtcl9_0.XTcl_ListObjAppendList(tls, libc.UintptrFromInt32(0), evalObj, objPtr) res = libtcl9_0.XTcl_EvalObjEx(tls, interp, evalObj, int32(TCL_EVAL_GLOBAL)) _objPtr = evalObj v2 = _objPtr v1 = *(*TTcl_Size)(unsafe.Pointer(v2)) *(*TTcl_Size)(unsafe.Pointer(v2))-- if v1 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr) } return res } textPtr = (*TTkText)(unsafe.Pointer(textPtr)).Fnext } /* * If there's no current text widget which shows everything, then we fall * back on acting directly. This means there is no way to intercept from * the Tcl level. */ return _SharedTextObjCmd(tls, sharedPtr, interp, *(*TTcl_Size)(unsafe.Pointer(bp))+int64(1), *(*uintptr)(unsafe.Pointer(bp + 8))-uintptr(1)*8) } /* *---------------------------------------------------------------------- * * CountIndices -- * * This function implements most of the functionality of the "count" * widget command. * * Note that 'textPtr' is only used if we need to check for elided * attributes, i.e. if type is COUNT_DISPLAY_INDICES or * COUNT_DISPLAY_CHARS * * Results: * Returns the number of characters in the range. * * Side effects: * None. * *---------------------------------------------------------------------- */ func _CountIndices(tls *libc.TLS, textPtr uintptr, indexPtr1 uintptr, indexPtr2 uintptr, type1 TTkTextCountType) (r int32) { /* The kind of indices to count. */ var compare int32 _ = compare /* * Order the starting and stopping indices. */ compare = XTkTextIndexCmp(tls, indexPtr1, indexPtr2) if compare == 0 { return 0 } else { if compare > 0 { return -XTkTextIndexCount(tls, textPtr, indexPtr2, indexPtr1, type1) } else { return XTkTextIndexCount(tls, textPtr, indexPtr1, indexPtr2, type1) } } return r } /* *---------------------------------------------------------------------- * * DeleteIndexRange -- * * This function implements most of the functionality of the "delete" * widget command. * * Results: * Returns a standard Tcl result, currently always TCL_OK. * * Side effects: * Characters and other entities (windows, images) get deleted from the * text. * * If 'viewUpdate' is true, we may adjust the window contents' * y-position, and scrollbar setting. * * If 'viewUpdate' is true we can guarantee that textPtr->topIndex * points to a valid TkTextLine after this function returns. However, if * 'viewUpdate' is false, then there is no such guarantee (since * topIndex.linePtr can be garbage). The caller is expected to take * actions to ensure the topIndex is validated before laying out the * window again. * *---------------------------------------------------------------------- */ func _DeleteIndexRange(tls *libc.TLS, sharedTextPtr uintptr, textPtr uintptr, indexPtr1 uintptr, indexPtr2 uintptr, viewUpdate int32) (r int32) { bp := tls.Alloc(208) defer tls.Free(208) /* Update vertical view if set. */ var arrayPtr, get, hPtr, lineAndByteIndex, tPtr uintptr var byteIndex, byteIndex1, i, line1 TTcl_Size var line, line11, line2, resetView, resetViewCount int32 var _ /* arraySize at bp+128 */ TTcl_Size var _ /* index1 at bp+0 */ TTkTextIndex var _ /* index2 at bp+32 */ TTkTextIndex var _ /* indexTmp at bp+168 */ TTkTextIndex var _ /* oldIndex2 at bp+136 */ TTkTextIndex var _ /* pixels at bp+64 */ [10]int32 var _ /* search at bp+104 */ TTcl_HashSearch _, _, _, _, _, _, _, _, _, _, _, _, _, _ = arrayPtr, byteIndex, byteIndex1, get, hPtr, i, line, line1, line11, line2, lineAndByteIndex, resetView, resetViewCount, tPtr if sharedTextPtr == libc.UintptrFromInt32(0) { sharedTextPtr = (*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr } /* * Prepare the starting and stopping indices. */ *(*TTkTextIndex)(unsafe.Pointer(bp)) = *(*TTkTextIndex)(unsafe.Pointer(indexPtr1)) if indexPtr2 != libc.UintptrFromInt32(0) { *(*TTkTextIndex)(unsafe.Pointer(bp + 32)) = *(*TTkTextIndex)(unsafe.Pointer(indexPtr2)) } else { *(*TTkTextIndex)(unsafe.Pointer(bp + 32)) = *(*TTkTextIndex)(unsafe.Pointer(bp)) XTkTextIndexForwChars(tls, libc.UintptrFromInt32(0), bp+32, int32(1), bp+32, int32(COUNT_INDICES)) } /* * Make sure there's really something to delete. */ if XTkTextIndexCmp(tls, bp, bp+32) >= 0 { return TCL_OK } /* * The code below is ugly, but it's needed to make sure there is always a * dummy empty line at the end of the text. If the final newline of the * file (just before the dummy line) is being deleted, then back up index * to just before the newline. If there is a newline just before the first * character being deleted, then back up the first index too. The idea is * that a deletion involving a range starting at a line start and * including the final \n (i.e. index2 is "end") is an attempt to delete * complete lines, so the \n before the deleted block shall become the new * final \n. Furthermore, remove any tags that are present on the newline * that isn't going to be deleted after all (this simulates deleting the * newline and then adding a "clean" one back again). Note that index1 and * index2 might now be equal again which means that no text will be * deleted but tags might be removed. */ line11 = XTkBTreeLinesTo(tls, textPtr, (*(*TTkTextIndex)(unsafe.Pointer(bp))).FlinePtr) line2 = XTkBTreeLinesTo(tls, textPtr, (*(*TTkTextIndex)(unsafe.Pointer(bp + 32))).FlinePtr) if line2 == XTkBTreeNumLines(tls, (*TTkSharedText)(unsafe.Pointer(sharedTextPtr)).Ftree, textPtr) { *(*TTkTextIndex)(unsafe.Pointer(bp + 136)) = *(*TTkTextIndex)(unsafe.Pointer(bp + 32)) XTkTextIndexBackChars(tls, libc.UintptrFromInt32(0), bp+136, int32(1), bp+32, int32(COUNT_INDICES)) line2-- if (*(*TTkTextIndex)(unsafe.Pointer(bp))).FbyteIndex == 0 && line11 != 0 { XTkTextIndexBackChars(tls, libc.UintptrFromInt32(0), bp, int32(1), bp, int32(COUNT_INDICES)) line11-- } arrayPtr = XTkBTreeGetTags(tls, bp+32, libc.UintptrFromInt32(0), bp+128) if arrayPtr != libc.UintptrFromInt32(0) { i = 0 for { if !(i < *(*TTcl_Size)(unsafe.Pointer(bp + 128))) { break } XTkBTreeTag(tls, bp+32, bp+136, *(*uintptr)(unsafe.Pointer(arrayPtr + uintptr(i)*8)), 0) goto _1 _1: ; i++ } libtcl9_0.XTcl_Free(tls, arrayPtr) } } /* * For speed, we remove all tags from the range first. If we don't * do this, the code below can (when there are many tags) grow * non-linearly in execution time. */ i = 0 hPtr = libtcl9_0.XTcl_FirstHashEntry(tls, sharedTextPtr+16, bp+104) for { if !(hPtr != libc.UintptrFromInt32(0)) { break } XTkBTreeTag(tls, bp, bp+32, (*TTcl_HashEntry)(unsafe.Pointer(hPtr)).FclientData, 0) goto _2 _2: ; i++ hPtr = libtcl9_0.XTcl_NextHashEntry(tls, bp+104) } /* * Special case for the sel tag which is not in the hash table. We * need to do this once for each peer text widget. */ tPtr = (*TTkSharedText)(unsafe.Pointer(sharedTextPtr)).Fpeers for { if !(tPtr != libc.UintptrFromInt32(0)) { break } if XTkBTreeTag(tls, bp, bp+32, (*TTkText)(unsafe.Pointer(tPtr)).FselTagPtr, 0) != 0 { /* * Send an event that the selection changed. This is * equivalent to: * event generate $textWidget <> */ XTkTextSelectionEvent(tls, textPtr) (*TTkText)(unsafe.Pointer(tPtr)).FabortSelections = int32(1) } goto _3 _3: ; tPtr = (*TTkText)(unsafe.Pointer(tPtr)).Fnext } /* * Tell the display what's about to happen so it can discard obsolete * display information, then do the deletion. Also, if the deletion * involves the top line on the screen, then we have to reset the view * (the deletion will invalidate textPtr->topIndex). Compute what the new * first character will be, then do the deletion, then reset the view. */ XTkTextChanged(tls, sharedTextPtr, libc.UintptrFromInt32(0), bp, bp+32) resetViewCount = 0 if (*TTkSharedText)(unsafe.Pointer(sharedTextPtr)).FrefCount > int64(PIXEL_CLIENTS) { lineAndByteIndex = libtcl9_0.XTcl_Alloc(tls, libc.Uint64FromInt64(4)*libc.Uint64FromInt32(2)*libc.Uint64FromInt64((*TTkSharedText)(unsafe.Pointer(sharedTextPtr)).FrefCount)) } else { lineAndByteIndex = bp + 64 } tPtr = (*TTkSharedText)(unsafe.Pointer(sharedTextPtr)).Fpeers for { if !(tPtr != libc.UintptrFromInt32(0)) { break } line = 0 byteIndex = 0 resetView = 0 if XTkTextIndexCmp(tls, bp+32, tPtr+256) >= 0 { if XTkTextIndexCmp(tls, bp, tPtr+256) <= 0 { /* * Deletion range straddles topIndex: use the beginning of the * range as the new topIndex. */ resetView = int32(1) line = line11 byteIndex = (*(*TTkTextIndex)(unsafe.Pointer(bp))).FbyteIndex } else { if (*(*TTkTextIndex)(unsafe.Pointer(bp))).FlinePtr == (*TTkText)(unsafe.Pointer(tPtr)).FtopIndex.FlinePtr { /* * Deletion range starts on top line but after topIndex. Use * the current topIndex as the new one. */ resetView = int32(1) line = line11 byteIndex = (*TTkText)(unsafe.Pointer(tPtr)).FtopIndex.FbyteIndex } else { /* * Deletion range starts after the top line. This peers's view * will not need to be reset. Nothing to do. */ } } } else { if (*(*TTkTextIndex)(unsafe.Pointer(bp + 32))).FlinePtr == (*TTkText)(unsafe.Pointer(tPtr)).FtopIndex.FlinePtr { /* * Deletion range ends on top line but before topIndex. Figure out * what will be the new character index for the character * currently pointed to by topIndex. */ resetView = int32(1) line = line2 byteIndex = (*TTkText)(unsafe.Pointer(tPtr)).FtopIndex.FbyteIndex if (*(*TTkTextIndex)(unsafe.Pointer(bp))).FlinePtr != (*(*TTkTextIndex)(unsafe.Pointer(bp + 32))).FlinePtr { byteIndex -= (*(*TTkTextIndex)(unsafe.Pointer(bp + 32))).FbyteIndex } else { byteIndex -= (*(*TTkTextIndex)(unsafe.Pointer(bp + 32))).FbyteIndex - (*(*TTkTextIndex)(unsafe.Pointer(bp))).FbyteIndex } } else { /* * Deletion range ends before the top line. This peers's view * will not need to be reset. Nothing to do. */ } } if resetView != 0 { *(*int32)(unsafe.Pointer(lineAndByteIndex + uintptr(resetViewCount)*4)) = line *(*int32)(unsafe.Pointer(lineAndByteIndex + uintptr(resetViewCount+int32(1))*4)) = int32(byteIndex) } else { *(*int32)(unsafe.Pointer(lineAndByteIndex + uintptr(resetViewCount)*4)) = -int32(1) } resetViewCount += int32(2) goto _4 _4: ; tPtr = (*TTkText)(unsafe.Pointer(tPtr)).Fnext } /* * Push the deletion on the undo stack if something was actually deleted. */ if XTkTextIndexCmp(tls, bp, bp+32) < 0 { if (*TTkSharedText)(unsafe.Pointer(sharedTextPtr)).Fundo != 0 { if (*TTkSharedText)(unsafe.Pointer(sharedTextPtr)).FautoSeparators != 0 && (*TTkSharedText)(unsafe.Pointer(sharedTextPtr)).FlastEditMode != int32(TK_TEXT_EDIT_DELETE) { XTkUndoInsertUndoSeparator(tls, (*TTkSharedText)(unsafe.Pointer(sharedTextPtr)).FundoStack) } (*TTkSharedText)(unsafe.Pointer(sharedTextPtr)).FlastEditMode = int32(TK_TEXT_EDIT_DELETE) get = _TextGetText(tls, textPtr, bp, bp+32, 0) _TextPushUndoAction(tls, textPtr, get, 0, bp, bp+32) } (*TTkSharedText)(unsafe.Pointer(sharedTextPtr)).FstateEpoch++ XTkBTreeDeleteIndexRange(tls, (*TTkSharedText)(unsafe.Pointer(sharedTextPtr)).Ftree, bp, bp+32) _UpdateDirtyFlag(tls, sharedTextPtr) } resetViewCount = 0 tPtr = (*TTkSharedText)(unsafe.Pointer(sharedTextPtr)).Fpeers for { if !(tPtr != libc.UintptrFromInt32(0)) { break } line1 = int64(*(*int32)(unsafe.Pointer(lineAndByteIndex + uintptr(resetViewCount)*4))) if line1 != int64(-int32(1)) { byteIndex1 = int64(*(*int32)(unsafe.Pointer(lineAndByteIndex + uintptr(resetViewCount+int32(1))*4))) if tPtr == textPtr { if viewUpdate != 0 { /* * line cannot be before -startline of textPtr because * this line corresponds to an index which is necessarily * between "1.0" and "end" relative to textPtr. * Therefore no need to clamp line to the -start/-end * range. */ XTkTextMakeByteIndex(tls, (*TTkSharedText)(unsafe.Pointer(sharedTextPtr)).Ftree, textPtr, int32(line1), byteIndex1, bp+168) XTkTextSetYView(tls, tPtr, bp+168, 0) } } else { XTkTextMakeByteIndex(tls, (*TTkSharedText)(unsafe.Pointer(sharedTextPtr)).Ftree, libc.UintptrFromInt32(0), int32(line1), byteIndex1, bp+168) /* * line may be before -startline of tPtr and must be * clamped to -startline before providing it to * TkTextSetYView otherwise lines before -startline * would be displayed. * There is no need to worry about -endline however, * because the view will only be reset if the deletion * involves the TOP line of the screen. That said, * the following call adjusts to both. */ XTkTextIndexAdjustToStartEnd(tls, tPtr, bp+168, 0) XTkTextSetYView(tls, tPtr, bp+168, 0) } } resetViewCount += int32(2) goto _5 _5: ; tPtr = (*TTkText)(unsafe.Pointer(tPtr)).Fnext } if (*TTkSharedText)(unsafe.Pointer(sharedTextPtr)).FrefCount > int64(PIXEL_CLIENTS) { libtcl9_0.XTcl_Free(tls, lineAndByteIndex) } if line11 >= line2 { /* * Invalidate any selection retrievals in progress, assuming we didn't * check for this case above. */ tPtr = (*TTkSharedText)(unsafe.Pointer(sharedTextPtr)).Fpeers for { if !(tPtr != libc.UintptrFromInt32(0)) { break } (*TTkText)(unsafe.Pointer(tPtr)).FabortSelections = int32(1) goto _6 _6: ; tPtr = (*TTkText)(unsafe.Pointer(tPtr)).Fnext } } return TCL_OK } /* *---------------------------------------------------------------------- * * TextFetchSelection -- * * This function is called back by Tk when the selection is requested by * someone. It returns part or all of the selection in a buffer provided * by the caller. * * Results: * The return value is the number of non-NULL bytes stored at buffer. * Buffer is filled (or partially filled) with a NULL-terminated string * containing part or all of the selection, as given by offset and * maxBytes. * * Side effects: * None. * *---------------------------------------------------------------------- */ func _TextFetchSelection(tls *libc.TLS, clientData uintptr, offset TTcl_Size, buffer uintptr, maxBytes TTcl_Size) (r TTcl_Size) { bp := tls.Alloc(112) defer tls.Free(112) /* Maximum number of bytes to place at buffer, * not including terminating NULL * character. */ var chunkSize, count, leftInRange TTcl_Size var segPtr, textPtr uintptr var _ /* eof at bp+0 */ TTkTextIndex var _ /* offsetInSeg at bp+32 */ TTcl_Size var _ /* search at bp+40 */ TTkTextSearch _, _, _, _, _ = chunkSize, count, leftInRange, segPtr, textPtr textPtr = clientData if !((*TTkText)(unsafe.Pointer(textPtr)).FexportSelection != 0) || libtcl9_0.XTcl_IsSafe(tls, (*TTkText)(unsafe.Pointer(textPtr)).Finterp) != 0 { return int64(-int32(1)) } /* * Find the beginning of the next range of selected text. Note: if the * selection is being retrieved in multiple pieces (offset != 0) and some * modification has been made to the text that affects the selection then * reject the selection request (make 'em start over again). */ if offset == 0 { XTkTextMakeByteIndex(tls, (*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).Ftree, textPtr, 0, 0, textPtr+344) (*TTkText)(unsafe.Pointer(textPtr)).FabortSelections = 0 } else { if (*TTkText)(unsafe.Pointer(textPtr)).FabortSelections != 0 { return 0 } } XTkTextMakeByteIndex(tls, (*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).Ftree, textPtr, XTkBTreeNumLines(tls, (*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).Ftree, textPtr), 0, bp) XTkBTreeStartSearch(tls, textPtr+344, bp, (*TTkText)(unsafe.Pointer(textPtr)).FselTagPtr, bp+40) if !(XTkBTreeCharTagged(tls, textPtr+344, (*TTkText)(unsafe.Pointer(textPtr)).FselTagPtr) != 0) { if !(XTkBTreeNextTag(tls, bp+40) != 0) { if offset == 0 { return int64(-int32(1)) } else { return 0 } } (*TTkText)(unsafe.Pointer(textPtr)).FselIndex = (*(*TTkTextSearch)(unsafe.Pointer(bp + 40))).FcurIndex } /* * Each iteration through the outer loop below scans one selected range. * Each iteration through the inner loop scans one segment in the selected * range. */ count = 0 for int32(1) != 0 { /* * Find the end of the current range of selected text. */ if !(XTkBTreeNextTag(tls, bp+40) != 0) { libtcl9_0.XTcl_Panic(tls, __ccgo_ts+43705, 0) } /* * Copy information from character segments into the buffer until * either we run out of space in the buffer or we get to the end of * this range of text. */ for int32(1) != 0 { if maxBytes == 0 { goto fetchDone } segPtr = XTkTextIndexToSeg(tls, textPtr+344, bp+32) chunkSize = (*TTkTextSegment)(unsafe.Pointer(segPtr)).Fsize - *(*TTcl_Size)(unsafe.Pointer(bp + 32)) if chunkSize > int64(int32(maxBytes)) { chunkSize = int64(int32(maxBytes)) } if (*TTkText)(unsafe.Pointer(textPtr)).FselIndex.FlinePtr == (*(*TTkTextSearch)(unsafe.Pointer(bp + 40))).FcurIndex.FlinePtr { leftInRange = (*(*TTkTextSearch)(unsafe.Pointer(bp + 40))).FcurIndex.FbyteIndex - (*TTkText)(unsafe.Pointer(textPtr)).FselIndex.FbyteIndex if leftInRange < chunkSize { chunkSize = leftInRange if chunkSize <= 0 { break } } } if (*TTkTextSegment)(unsafe.Pointer(segPtr)).FtypePtr == uintptr(unsafe.Pointer(&XtkTextCharType)) && !(XTkTextIsElided(tls, textPtr, textPtr+344, libc.UintptrFromInt32(0)) != 0) { libc.Xmemcpy(tls, buffer, segPtr+24+uintptr(*(*TTcl_Size)(unsafe.Pointer(bp + 32))), libc.Uint64FromInt64(chunkSize)) buffer += uintptr(chunkSize) maxBytes -= chunkSize count += chunkSize } XTkTextIndexForwBytes(tls, textPtr, textPtr+344, chunkSize, textPtr+344) } /* * Find the beginning of the next range of selected text. */ if !(XTkBTreeNextTag(tls, bp+40) != 0) { break } (*TTkText)(unsafe.Pointer(textPtr)).FselIndex = (*(*TTkTextSearch)(unsafe.Pointer(bp + 40))).FcurIndex } goto fetchDone fetchDone: ; *(*uint8)(unsafe.Pointer(buffer)) = uint8(0) return count } /* *---------------------------------------------------------------------- * * TkTextLostSelection -- * * This function is called back by Tk when the selection is grabbed away * from a text widget. On Windows and Mac systems, we want to remember * the selection for the next time the focus enters the window. On Unix, * just remove the "sel" tag from everything in the widget. * * Results: * None. * * Side effects: * The "sel" tag is cleared from the window. * *---------------------------------------------------------------------- */ func XTkTextLostSelection(tls *libc.TLS, clientData uintptr) { bp := tls.Alloc(64) defer tls.Free(64) /* Information about text widget. */ var textPtr uintptr var _ /* end at bp+32 */ TTkTextIndex var _ /* start at bp+0 */ TTkTextIndex _ = textPtr textPtr = clientData if XTk_AlwaysShowSelection(tls, (*TTkText)(unsafe.Pointer(textPtr)).Ftkwin) != 0 { if !((*TTkText)(unsafe.Pointer(textPtr)).FexportSelection != 0) || libtcl9_0.XTcl_IsSafe(tls, (*TTkText)(unsafe.Pointer(textPtr)).Finterp) != 0 { return } /* * On Windows and Mac systems, we want to remember the selection for * the next time the focus enters the window. On Unix, just remove the * "sel" tag from everything in the widget. */ XTkTextMakeByteIndex(tls, (*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).Ftree, textPtr, 0, 0, bp) XTkTextMakeByteIndex(tls, (*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).Ftree, textPtr, XTkBTreeNumLines(tls, (*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).Ftree, textPtr), 0, bp+32) XTkTextRedrawTag(tls, libc.UintptrFromInt32(0), textPtr, bp, bp+32, (*TTkText)(unsafe.Pointer(textPtr)).FselTagPtr, int32(1)) XTkBTreeTag(tls, bp, bp+32, (*TTkText)(unsafe.Pointer(textPtr)).FselTagPtr, 0) } /* * Send an event that the selection changed. This is equivalent to: * event generate $textWidget <> */ XTkTextSelectionEvent(tls, textPtr) *(*int32)(unsafe.Pointer(textPtr + 672)) &= ^libc.Int32FromInt32(GOT_SELECTION1) } /* *---------------------------------------------------------------------- * * TkTextSelectionEvent -- * * When anything relevant to the "sel" tag has been changed, call this * function to generate a <> event. * * Results: * None. * * Side effects: * If <> bindings are present, they will trigger. * *---------------------------------------------------------------------- */ func XTkTextSelectionEvent(tls *libc.TLS, textPtr uintptr) { /* * Send an event that the selection changed. This is equivalent to: * event generate $textWidget <> */ XTk_SendVirtualEvent(tls, (*TTkText)(unsafe.Pointer(textPtr)).Ftkwin, __ccgo_ts+43751, libc.UintptrFromInt32(0)) } /* *---------------------------------------------------------------------- * * TextBlinkProc -- * * This function is called as a timer handler to blink the insertion * cursor off and on. * * Results: * None. * * Side effects: * The cursor gets turned on or off, redisplay gets invoked, and this * function reschedules itself. * *---------------------------------------------------------------------- */ func _TextBlinkProc(tls *libc.TLS, clientData uintptr) { bp := tls.Alloc(64) defer tls.Free(64) /* Pointer to record describing text. */ var textPtr uintptr var _ /* charWidth at bp+48 */ int32 var _ /* h at bp+44 */ int32 var _ /* index at bp+0 */ TTkTextIndex var _ /* insertWidth at bp+52 */ int32 var _ /* w at bp+40 */ int32 var _ /* x at bp+32 */ int32 var _ /* y at bp+36 */ int32 _ = textPtr textPtr = clientData if (*TTkText)(unsafe.Pointer(textPtr)).Fstate == int32(TK_TEXT_STATE_DISABLED) || !((*TTkText)(unsafe.Pointer(textPtr)).Fflags&libc.Int32FromInt32(GOT_FOCUS8) != 0) || (*TTkText)(unsafe.Pointer(textPtr)).FinsertOffTime == 0 { if !((*TTkText)(unsafe.Pointer(textPtr)).Fflags&libc.Int32FromInt32(GOT_FOCUS8) != 0) && (*TTkText)(unsafe.Pointer(textPtr)).FinsertUnfocussed != int32(TK_TEXT_INSERT_NOFOCUS_NONE) { /* * The widget doesn't have the focus yet it is configured to * display the cursor when it doesn't have the focus. Act now! */ *(*int32)(unsafe.Pointer(textPtr + 672)) |= int32(INSERT_ON) goto redrawInsert } if (*TTkText)(unsafe.Pointer(textPtr)).FinsertOffTime == 0 && !((*TTkText)(unsafe.Pointer(textPtr)).Fflags&libc.Int32FromInt32(INSERT_ON) != 0) { /* * The widget was configured to have zero offtime while the * insertion point was not displayed. We have to display it once. */ *(*int32)(unsafe.Pointer(textPtr + 672)) |= int32(INSERT_ON) goto redrawInsert } return } if (*TTkText)(unsafe.Pointer(textPtr)).Fflags&int32(INSERT_ON) != 0 { *(*int32)(unsafe.Pointer(textPtr + 672)) &= ^libc.Int32FromInt32(INSERT_ON) (*TTkText)(unsafe.Pointer(textPtr)).FinsertBlinkHandler = libtcl9_0.XTcl_CreateTimerHandler(tls, (*TTkText)(unsafe.Pointer(textPtr)).FinsertOffTime, __ccgo_fp(_TextBlinkProc), textPtr) } else { *(*int32)(unsafe.Pointer(textPtr + 672)) |= int32(INSERT_ON) (*TTkText)(unsafe.Pointer(textPtr)).FinsertBlinkHandler = libtcl9_0.XTcl_CreateTimerHandler(tls, (*TTkText)(unsafe.Pointer(textPtr)).FinsertOnTime, __ccgo_fp(_TextBlinkProc), textPtr) } goto redrawInsert redrawInsert: ; XTkTextMarkSegToIndex(tls, textPtr, (*TTkText)(unsafe.Pointer(textPtr)).FinsertMarkPtr, bp) if XTkTextIndexBbox(tls, textPtr, bp, bp+32, bp+36, bp+40, bp+44, bp+48) == 0 { XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), (*TTkText)(unsafe.Pointer(textPtr)).Ftkwin, (*TTkText)(unsafe.Pointer(textPtr)).FinsertWidthObj, bp+52) if (*TTkText)(unsafe.Pointer(textPtr)).FinsertCursorType != 0 { /* Block cursor */ XTkTextRedrawRegion(tls, textPtr, *(*int32)(unsafe.Pointer(bp + 32))-(*TTkText)(unsafe.Pointer(textPtr)).Fwidth/int32(2), *(*int32)(unsafe.Pointer(bp + 36)), *(*int32)(unsafe.Pointer(bp + 48))+*(*int32)(unsafe.Pointer(bp + 52))/int32(2), *(*int32)(unsafe.Pointer(bp + 44))) } else { /* I-beam cursor */ XTkTextRedrawRegion(tls, textPtr, *(*int32)(unsafe.Pointer(bp + 32))-*(*int32)(unsafe.Pointer(bp + 52))/int32(2), *(*int32)(unsafe.Pointer(bp + 36)), *(*int32)(unsafe.Pointer(bp + 52)), *(*int32)(unsafe.Pointer(bp + 44))) } } } /* *---------------------------------------------------------------------- * * TextInsertCmd -- * * This function is invoked to process the "insert" and "replace" widget * commands for text widgets. * * Results: * A standard Tcl result. * * Side effects: * See the user documentation. * * If 'viewUpdate' is true, we may adjust the window contents' * y-position, and scrollbar setting. * *---------------------------------------------------------------------- */ func _TextInsertCmd(tls *libc.TLS, sharedTextPtr uintptr, textPtr uintptr, interp uintptr, objc TTcl_Size, objv uintptr, indexPtr uintptr, viewUpdate int32) (r int32) { bp := tls.Alloc(80) defer tls.Free(80) /* Update the view if set. */ var i, i1, j, length TTcl_Size var oldTagArrayPtr, strTag uintptr var _ /* index1 at bp+0 */ TTkTextIndex var _ /* index2 at bp+32 */ TTkTextIndex var _ /* numTags at bp+72 */ TTcl_Size var _ /* tagNamePtrs at bp+64 */ uintptr _, _, _, _, _, _ = i, i1, j, length, oldTagArrayPtr, strTag if sharedTextPtr == libc.UintptrFromInt32(0) { sharedTextPtr = (*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr } *(*TTkTextIndex)(unsafe.Pointer(bp)) = *(*TTkTextIndex)(unsafe.Pointer(indexPtr)) j = 0 for { if !(j < objc) { break } /* * Here we rely on this call to modify index1 if it is outside the * acceptable range. In particular, if index1 is "end", it must be set * to the last allowable index for insertion, otherwise subsequent tag * insertions will fail. */ length = int64(_InsertChars1(tls, sharedTextPtr, textPtr, bp, *(*uintptr)(unsafe.Pointer(objv + uintptr(j)*8)), viewUpdate)) if objc > j+int64(1) { XTkTextIndexForwBytes(tls, textPtr, bp, length, bp+32) oldTagArrayPtr = XTkBTreeGetTags(tls, bp, libc.UintptrFromInt32(0), bp+72) if oldTagArrayPtr != libc.UintptrFromInt32(0) { i = 0 for { if !(i < *(*TTcl_Size)(unsafe.Pointer(bp + 72))) { break } XTkBTreeTag(tls, bp, bp+32, *(*uintptr)(unsafe.Pointer(oldTagArrayPtr + uintptr(i)*8)), 0) goto _2 _2: ; i++ } libtcl9_0.XTcl_Free(tls, oldTagArrayPtr) } if libtcl9_0.XTcl_ListObjGetElements(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(j+int64(1))*8)), bp+72, bp+64) != TCL_OK { return int32(TCL_ERROR) } else { i1 = 0 for { if !(i1 < *(*TTcl_Size)(unsafe.Pointer(bp + 72))) { break } strTag = libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 64)) + uintptr(i1)*8)), libc.UintptrFromInt32(0)) XTkBTreeTag(tls, bp, bp+32, XTkTextCreateTag(tls, textPtr, strTag, libc.UintptrFromInt32(0)), int32(1)) goto _3 _3: ; i1++ } *(*TTkTextIndex)(unsafe.Pointer(bp)) = *(*TTkTextIndex)(unsafe.Pointer(bp + 32)) } } goto _1 _1: ; j += int64(2) } return TCL_OK } /* *---------------------------------------------------------------------- * * TextSearchCmd -- * * This function is invoked to process the "search" widget command for * text widgets. See the user documentation for details on what it does. * * Results: * A standard Tcl result. * * Side effects: * See the user documentation. * *---------------------------------------------------------------------- */ func _TextSearchCmd(tls *libc.TLS, textPtr uintptr, interp uintptr, objc TTcl_Size, objv uintptr) (r int32) { bp := tls.Alloc(176) defer tls.Free(176) /* Argument objects. */ var _objPtr, _objPtr1, v2, v4, v6 uintptr var argsLeft, i, v3, v5 TTcl_Size var code int32 var _ /* index at bp+128 */ int32 var _ /* searchSpec at bp+0 */ TSearchSpec _, _, _, _, _, _, _, _, _, _ = _objPtr, _objPtr1, argsLeft, code, i, v2, v3, v4, v5, v6 /* * Set up the search specification, including the last 4 fields which are * text widget specific. */ (*(*TSearchSpec)(unsafe.Pointer(bp))).Fexact = int32(1) (*(*TSearchSpec)(unsafe.Pointer(bp))).FnoCase = 0 (*(*TSearchSpec)(unsafe.Pointer(bp))).Fall = 0 (*(*TSearchSpec)(unsafe.Pointer(bp))).Fbackwards = 0 (*(*TSearchSpec)(unsafe.Pointer(bp))).FvarPtr = libc.UintptrFromInt32(0) (*(*TSearchSpec)(unsafe.Pointer(bp))).FcountPtr = libc.UintptrFromInt32(0) (*(*TSearchSpec)(unsafe.Pointer(bp))).FresPtr = libc.UintptrFromInt32(0) (*(*TSearchSpec)(unsafe.Pointer(bp))).FsearchElide = 0 (*(*TSearchSpec)(unsafe.Pointer(bp))).FnoLineStop = 0 (*(*TSearchSpec)(unsafe.Pointer(bp))).Foverlap = 0 (*(*TSearchSpec)(unsafe.Pointer(bp))).FstrictLimits = 0 (*(*TSearchSpec)(unsafe.Pointer(bp))).FnumLines = XTkBTreeNumLines(tls, (*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).Ftree, textPtr) (*(*TSearchSpec)(unsafe.Pointer(bp))).FclientData = textPtr (*(*TSearchSpec)(unsafe.Pointer(bp))).FaddLineProc = __ccgo_fp(_TextSearchAddNextLine) (*(*TSearchSpec)(unsafe.Pointer(bp))).FfoundMatchProc = __ccgo_fp(_TextSearchFoundMatch) (*(*TSearchSpec)(unsafe.Pointer(bp))).FlineIndexProc = __ccgo_fp(_TextSearchGetLineIndex) /* * Parse switches and other arguments. */ i = int64(2) for { if !(i < objc) { break } if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(i)*8)), libc.UintptrFromInt32(0))))) != int32('-') { break } if libtcl9_0.XTcl_GetIndexFromObjStruct(tls, libc.UintptrFromInt32(0), *(*uintptr)(unsafe.Pointer(objv + uintptr(i)*8)), uintptr(unsafe.Pointer(&_switchStrings)), libc.Int64FromUint64(libc.Uint64FromInt64(8)), __ccgo_ts+43860, libc.Int32FromInt32(0)|libc.Int32FromUint64(libc.Uint64FromInt64(4)<= objc { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+43867, int64(-libc.Int32FromInt32(1)))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+144, __ccgo_ts+179, __ccgo_ts+16417, __ccgo_ts+182, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) } i++ /* * Assumption objv[i] isn't going to disappear on us during this * function, which is fair. */ (*(*TSearchSpec)(unsafe.Pointer(bp))).FvarPtr = *(*uintptr)(unsafe.Pointer(objv + uintptr(i)*8)) case 5: fallthrough case 0: (*(*TSearchSpec)(unsafe.Pointer(bp))).FsearchElide = int32(1) case 6: (*(*TSearchSpec)(unsafe.Pointer(bp))).Fexact = int32(1) case 7: (*(*TSearchSpec)(unsafe.Pointer(bp))).Fbackwards = 0 case 8: (*(*TSearchSpec)(unsafe.Pointer(bp))).FnoCase = int32(1) case 9: (*(*TSearchSpec)(unsafe.Pointer(bp))).FnoLineStop = int32(1) case 10: (*(*TSearchSpec)(unsafe.Pointer(bp))).Foverlap = int32(1) case 12: (*(*TSearchSpec)(unsafe.Pointer(bp))).FstrictLimits = int32(1) case 11: (*(*TSearchSpec)(unsafe.Pointer(bp))).Fexact = 0 default: libtcl9_0.XTcl_Panic(tls, __ccgo_ts+39667, 0) } goto _1 _1: ; i++ } goto endOfSwitchProcessing endOfSwitchProcessing: ; argsLeft = objc - (i + int64(2)) if argsLeft != 0 && argsLeft != int64(1) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(2), objv, __ccgo_ts+43902) return int32(TCL_ERROR) } if (*(*TSearchSpec)(unsafe.Pointer(bp))).FnoLineStop != 0 && (*(*TSearchSpec)(unsafe.Pointer(bp))).Fexact != 0 { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+43939, int64(-libc.Int32FromInt32(1)))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+144, __ccgo_ts+179, __ccgo_ts+16417, __ccgo_ts+44008, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) } if (*(*TSearchSpec)(unsafe.Pointer(bp))).Foverlap != 0 && !((*(*TSearchSpec)(unsafe.Pointer(bp))).Fall != 0) { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+44021, int64(-libc.Int32FromInt32(1)))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+144, __ccgo_ts+179, __ccgo_ts+16417, __ccgo_ts+44008, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) } /* * Scan through all of the lines of the text circularly, starting at the * given index. 'objv[i]' is the pattern which may be an exact string or a * regexp pattern depending on the flags set above. */ if argsLeft == int64(1) { v2 = *(*uintptr)(unsafe.Pointer(objv + uintptr(i+int64(2))*8)) } else { v2 = libc.UintptrFromInt32(0) } code = _SearchPerform(tls, interp, bp, *(*uintptr)(unsafe.Pointer(objv + uintptr(i)*8)), *(*uintptr)(unsafe.Pointer(objv + uintptr(i+int64(1))*8)), v2) if code != TCL_OK { goto cleanup } /* * Set the '-count' variable, if given. */ if (*(*TSearchSpec)(unsafe.Pointer(bp))).FvarPtr != libc.UintptrFromInt32(0) && (*(*TSearchSpec)(unsafe.Pointer(bp))).FcountPtr != libc.UintptrFromInt32(0) { (*TTcl_Obj)(unsafe.Pointer((*(*TSearchSpec)(unsafe.Pointer(bp))).FcountPtr)).FrefCount++ if libtcl9_0.XTcl_ObjSetVar2(tls, interp, (*(*TSearchSpec)(unsafe.Pointer(bp))).FvarPtr, libc.UintptrFromInt32(0), (*(*TSearchSpec)(unsafe.Pointer(bp))).FcountPtr, int32(TCL_LEAVE_ERR_MSG)) == libc.UintptrFromInt32(0) { code = int32(TCL_ERROR) goto cleanup } } /* * Set the result. */ if (*(*TSearchSpec)(unsafe.Pointer(bp))).FresPtr != libc.UintptrFromInt32(0) { libtcl9_0.XTcl_SetObjResult(tls, interp, (*(*TSearchSpec)(unsafe.Pointer(bp))).FresPtr) (*(*TSearchSpec)(unsafe.Pointer(bp))).FresPtr = libc.UintptrFromInt32(0) } goto cleanup cleanup: ; if (*(*TSearchSpec)(unsafe.Pointer(bp))).FcountPtr != libc.UintptrFromInt32(0) { _objPtr = (*(*TSearchSpec)(unsafe.Pointer(bp))).FcountPtr v4 = _objPtr v3 = *(*TTcl_Size)(unsafe.Pointer(v4)) *(*TTcl_Size)(unsafe.Pointer(v4))-- if v3 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr) } } if (*(*TSearchSpec)(unsafe.Pointer(bp))).FresPtr != libc.UintptrFromInt32(0) { _objPtr1 = (*(*TSearchSpec)(unsafe.Pointer(bp))).FresPtr v6 = _objPtr1 v5 = *(*TTcl_Size)(unsafe.Pointer(v6)) *(*TTcl_Size)(unsafe.Pointer(v6))-- if v5 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr1) } } return code } var _switchStrings = [14]uintptr{ 0: __ccgo_ts + 43761, 1: __ccgo_ts + 10042, 2: __ccgo_ts + 43769, 3: __ccgo_ts + 43774, 4: __ccgo_ts + 2835, 5: __ccgo_ts + 43785, 6: __ccgo_ts + 43792, 7: __ccgo_ts + 43799, 8: __ccgo_ts + 43809, 9: __ccgo_ts + 43817, 10: __ccgo_ts + 43829, 11: __ccgo_ts + 43838, 12: __ccgo_ts + 43846, 13: libc.UintptrFromInt32(0), } /* *---------------------------------------------------------------------- * * TextSearchGetLineIndex -- * * Extract a row, text offset index position from an objPtr * * This means we ignore any embedded windows/images and elided text * (unless we are searching that). * * Results: * Standard Tcl error code (with a message in the interpreter on error * conditions). * * The offset placed in offsetPosPtr is a utf-8 char* byte index for * exact searches, and a Unicode character index for regexp searches. * * The line number should start at zero (searches which wrap around * assume the first line is numbered 0). * * Side effects: * None. * *---------------------------------------------------------------------- */ func _TextSearchGetLineIndex(tls *libc.TLS, interp uintptr, objPtr uintptr, searchSpecPtr uintptr, linePosPtr uintptr, offsetPosPtr uintptr) (r int32) { /* For returning the text offset in the * line. */ var count, line int32 var indexPtr, linePtr, segPtr, textPtr uintptr _, _, _, _, _, _ = count, indexPtr, line, linePtr, segPtr, textPtr textPtr = (*TSearchSpec)(unsafe.Pointer(searchSpecPtr)).FclientData indexPtr = XTkTextGetIndexFromObj(tls, interp, textPtr, objPtr) if indexPtr == libc.UintptrFromInt32(0) { return int32(TCL_ERROR) } line = XTkBTreeLinesTo(tls, textPtr, (*TTkTextIndex)(unsafe.Pointer(indexPtr)).FlinePtr) if line >= (*TSearchSpec)(unsafe.Pointer(searchSpecPtr)).FnumLines { count = 0 line = (*TSearchSpec)(unsafe.Pointer(searchSpecPtr)).FnumLines - int32(1) linePtr = XTkBTreeFindLine(tls, (*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).Ftree, textPtr, line) /* * Count the number of bytes in this line. */ segPtr = (*TTkTextLine)(unsafe.Pointer(linePtr)).FsegPtr for { if !(segPtr != libc.UintptrFromInt32(0)) { break } count = int32(int64(count) + (*TTkTextSegment)(unsafe.Pointer(segPtr)).Fsize) goto _1 _1: ; segPtr = (*TTkTextSegment)(unsafe.Pointer(segPtr)).FnextPtr } *(*TTcl_Size)(unsafe.Pointer(offsetPosPtr)) = _TextSearchIndexInLine(tls, searchSpecPtr, linePtr, int64(count)) } else { *(*TTcl_Size)(unsafe.Pointer(offsetPosPtr)) = _TextSearchIndexInLine(tls, searchSpecPtr, (*TTkTextIndex)(unsafe.Pointer(indexPtr)).FlinePtr, (*TTkTextIndex)(unsafe.Pointer(indexPtr)).FbyteIndex) } *(*int32)(unsafe.Pointer(linePosPtr)) = line return TCL_OK } /* *---------------------------------------------------------------------- * * TextSearchIndexInLine -- * * Find textual index of 'byteIndex' in the searchable characters of * 'linePtr'. * * This means we ignore any embedded windows/images and elided text * (unless we are searching that). * * Results: * The returned index is a utf-8 char* byte index for exact searches, and * a Unicode character index for regexp searches. * * Side effects: * None. * *---------------------------------------------------------------------- */ func _TextSearchIndexInLine(tls *libc.TLS, searchSpecPtr uintptr, linePtr uintptr, byteIndex TTcl_Size) (r TTcl_Size) { bp := tls.Alloc(32) defer tls.Free(32) /* Index into the line. */ var index TTcl_Size var leftToScan int32 var segPtr, textPtr uintptr var _ /* curIndex at bp+0 */ TTkTextIndex _, _, _, _ = index, leftToScan, segPtr, textPtr textPtr = (*TSearchSpec)(unsafe.Pointer(searchSpecPtr)).FclientData index = 0 (*(*TTkTextIndex)(unsafe.Pointer(bp))).Ftree = (*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).Ftree (*(*TTkTextIndex)(unsafe.Pointer(bp))).FlinePtr = linePtr (*(*TTkTextIndex)(unsafe.Pointer(bp))).FbyteIndex = 0 segPtr = (*TTkTextLine)(unsafe.Pointer(linePtr)).FsegPtr leftToScan = int32(byteIndex) for { if !(leftToScan > 0) { break } if (*TTkTextSegment)(unsafe.Pointer(segPtr)).FtypePtr == uintptr(unsafe.Pointer(&XtkTextCharType)) && ((*TSearchSpec)(unsafe.Pointer(searchSpecPtr)).FsearchElide != 0 || !(XTkTextIsElided(tls, textPtr, bp, libc.UintptrFromInt32(0)) != 0)) { if int64(leftToScan) < (*TTkTextSegment)(unsafe.Pointer(segPtr)).Fsize { if (*TSearchSpec)(unsafe.Pointer(searchSpecPtr)).Fexact != 0 { index += int64(leftToScan) } else { index += libtcl9_0.XTcl_NumUtfChars(tls, segPtr+24, int64(leftToScan)) } } else { if (*TSearchSpec)(unsafe.Pointer(searchSpecPtr)).Fexact != 0 { index += (*TTkTextSegment)(unsafe.Pointer(segPtr)).Fsize } else { index += libtcl9_0.XTcl_NumUtfChars(tls, segPtr+24, int64(-int32(1))) } } } leftToScan = int32(int64(leftToScan) - (*TTkTextSegment)(unsafe.Pointer(segPtr)).Fsize) goto _1 _1: ; (*(*TTkTextIndex)(unsafe.Pointer(bp))).FbyteIndex += (*TTkTextSegment)(unsafe.Pointer(segPtr)).Fsize segPtr = (*TTkTextSegment)(unsafe.Pointer(segPtr)).FnextPtr } return index } /* *---------------------------------------------------------------------- * * TextSearchAddNextLine -- * * Adds a line from the text widget to the object 'theLine'. * * Results: * A pointer to the TkTextLine corresponding to the given line, or NULL * if there was no available line. * * Also 'lenPtr' (if non-NULL) is filled in with the total length of * 'theLine' (not just what we added to it, but the length including what * was already in there). This is in bytes for an exact search and in * chars for a regexp search. * * Also 'extraLinesPtr' (if non-NULL) will have its value incremented by * 1 for each additional logical line we have added because a newline is * elided (this will only ever happen if we have chosen not to search * elided text, of course). * * Side effects: * Memory may be allocated or re-allocated for theLine's string * representation. * *---------------------------------------------------------------------- */ func _TextSearchAddNextLine(tls *libc.TLS, lineNum int32, searchSpecPtr uintptr, theLine uintptr, lenPtr uintptr, extraLinesPtr uintptr) (r uintptr) { bp := tls.Alloc(32) defer tls.Free(32) /* If non-NULL, will have its value * incremented by the number of additional * logical lines which are merged into this * one by newlines being elided. */ var elideWraps, nothingYet int32 var linePtr, segPtr, textPtr, thisLinePtr uintptr var _ /* curIndex at bp+0 */ TTkTextIndex _, _, _, _, _, _ = elideWraps, linePtr, nothingYet, segPtr, textPtr, thisLinePtr textPtr = (*TSearchSpec)(unsafe.Pointer(searchSpecPtr)).FclientData nothingYet = int32(1) /* * Extract the text from the line. */ linePtr = XTkBTreeFindLine(tls, (*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).Ftree, textPtr, lineNum) if linePtr == libc.UintptrFromInt32(0) { return libc.UintptrFromInt32(0) } (*(*TTkTextIndex)(unsafe.Pointer(bp))).Ftree = (*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).Ftree thisLinePtr = linePtr for thisLinePtr != libc.UintptrFromInt32(0) { elideWraps = 0 (*(*TTkTextIndex)(unsafe.Pointer(bp))).FlinePtr = thisLinePtr (*(*TTkTextIndex)(unsafe.Pointer(bp))).FbyteIndex = 0 segPtr = (*TTkTextLine)(unsafe.Pointer(thisLinePtr)).FsegPtr for { if !(segPtr != libc.UintptrFromInt32(0)) { break } if !((*TSearchSpec)(unsafe.Pointer(searchSpecPtr)).FsearchElide != 0) && XTkTextIsElided(tls, textPtr, bp, libc.UintptrFromInt32(0)) != 0 { /* * If we reach the end of the logical line, and if we have at * least one character in the string, then we continue * wrapping to the next logical line. If there are no * characters yet, then the entire line of characters is * elided and there's no need to complicate matters by * wrapping - we'll look at the next line in due course. */ if (*TTkTextSegment)(unsafe.Pointer(segPtr)).FnextPtr == libc.UintptrFromInt32(0) && !(nothingYet != 0) { elideWraps = int32(1) } goto _1 } if (*TTkTextSegment)(unsafe.Pointer(segPtr)).FtypePtr != uintptr(unsafe.Pointer(&XtkTextCharType)) { goto _1 } libtcl9_0.XTcl_AppendToObj(tls, theLine, segPtr+24, (*TTkTextSegment)(unsafe.Pointer(segPtr)).Fsize) nothingYet = 0 goto _1 _1: ; (*(*TTkTextIndex)(unsafe.Pointer(bp))).FbyteIndex += (*TTkTextSegment)(unsafe.Pointer(segPtr)).Fsize segPtr = (*TTkTextSegment)(unsafe.Pointer(segPtr)).FnextPtr } if !(elideWraps != 0) { break } lineNum++ if lineNum >= (*TSearchSpec)(unsafe.Pointer(searchSpecPtr)).FnumLines { break } thisLinePtr = XTkBTreeNextLine(tls, textPtr, thisLinePtr) if thisLinePtr != libc.UintptrFromInt32(0) && extraLinesPtr != libc.UintptrFromInt32(0) { /* * Tell our caller we have an extra line merged in. */ *(*int32)(unsafe.Pointer(extraLinesPtr)) = *(*int32)(unsafe.Pointer(extraLinesPtr)) + int32(1) } } /* * If we're ignoring case, convert the line to lower case. There is no * need to do this for regexp searches, since they handle a flag for this * purpose. */ if (*TSearchSpec)(unsafe.Pointer(searchSpecPtr)).Fexact != 0 && (*TSearchSpec)(unsafe.Pointer(searchSpecPtr)).FnoCase != 0 { libtcl9_0.XTcl_SetObjLength(tls, theLine, libtcl9_0.XTcl_UtfToLower(tls, libtcl9_0.XTcl_GetStringFromObj(tls, theLine, libc.UintptrFromInt32(0)))) } if lenPtr != libc.UintptrFromInt32(0) { if (*TSearchSpec)(unsafe.Pointer(searchSpecPtr)).Fexact != 0 { libtcl9_0.XTcl_GetStringFromObj(tls, theLine, libc.UintptrFromInt32(0)) *(*int32)(unsafe.Pointer(lenPtr)) = int32((*TTcl_Obj)(unsafe.Pointer(theLine)).Flength) } else { *(*int32)(unsafe.Pointer(lenPtr)) = int32(libtcl9_0.XTcl_GetCharLength(tls, theLine)) } } return linePtr } /* *---------------------------------------------------------------------- * * TextSearchFoundMatch -- * * Stores information from a successful search. * * Results: * 1 if the information was stored, 0 if the position at which the match * was found actually falls outside the allowable search region (and * therefore the search is actually complete). * * Side effects: * Memory may be allocated in the 'countPtr' and 'resPtr' fields of * 'searchSpecPtr'. Each of those objects will have refCount zero and * must eventually be freed or stored elsewhere as appropriate. * *---------------------------------------------------------------------- */ func _TextSearchFoundMatch(tls *libc.TLS, lineNum int32, searchSpecPtr uintptr, clientData uintptr, theLine uintptr, matchOffset TTcl_Size, matchLength TTcl_Size) (r int32) { bp := tls.Alloc(64) defer tls.Free(64) /* Length also in bytes/chars as per search * type. */ var leftToScan int32 var linePtr, segPtr, startOfLine, textPtr, tmpPtr uintptr var numChars TTcl_Size var _ /* curIndex at bp+0 */ TTkTextIndex var _ /* foundIndex at bp+32 */ TTkTextIndex _, _, _, _, _, _, _ = leftToScan, linePtr, numChars, segPtr, startOfLine, textPtr, tmpPtr textPtr = (*TSearchSpec)(unsafe.Pointer(searchSpecPtr)).FclientData if lineNum == (*TSearchSpec)(unsafe.Pointer(searchSpecPtr)).FstopLine { /* * If the current index is on the wrong side of the stopIndex, then * the item we just found is actually outside the acceptable range, * and the search is over. */ if (*TSearchSpec)(unsafe.Pointer(searchSpecPtr)).Fbackwards^libc.BoolInt32(matchOffset >= (*TSearchSpec)(unsafe.Pointer(searchSpecPtr)).FstopOffset) != 0 { return 0 } } /* * Calculate the character count, which may need augmenting if there are * embedded windows or elided text. */ if (*TSearchSpec)(unsafe.Pointer(searchSpecPtr)).Fexact != 0 { startOfLine = libtcl9_0.XTcl_GetStringFromObj(tls, theLine, libc.UintptrFromInt32(0)) numChars = libtcl9_0.XTcl_NumUtfChars(tls, startOfLine+uintptr(matchOffset), matchLength) } else { numChars = matchLength } /* * If we're using strict limits checking, ensure that the match with its * full length fits inside the given range. */ if (*TSearchSpec)(unsafe.Pointer(searchSpecPtr)).FstrictLimits != 0 && lineNum == (*TSearchSpec)(unsafe.Pointer(searchSpecPtr)).FstopLine { if (*TSearchSpec)(unsafe.Pointer(searchSpecPtr)).Fbackwards^libc.BoolInt32(matchOffset+numChars > (*TSearchSpec)(unsafe.Pointer(searchSpecPtr)).FstopOffset) != 0 { return 0 } } /* * The index information returned by the regular expression parser only * considers textual information: it doesn't account for embedded windows, * elided text (when we are not searching elided text) or any other * non-textual info. Scan through the line's segments again to adjust both * matchChar and matchCount. * * We will walk through the segments of this line until we have either * reached the end of the match or we have reached the end of the line. */ linePtr = clientData if linePtr == libc.UintptrFromInt32(0) { linePtr = XTkBTreeFindLine(tls, (*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).Ftree, textPtr, lineNum) } (*(*TTkTextIndex)(unsafe.Pointer(bp))).Ftree = (*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).Ftree /* * Find the starting point. */ leftToScan = int32(matchOffset) for int32(1) != 0 { (*(*TTkTextIndex)(unsafe.Pointer(bp))).FlinePtr = linePtr (*(*TTkTextIndex)(unsafe.Pointer(bp))).FbyteIndex = 0 /* * Note that we allow leftToScan to be zero because we want to skip * over any preceding non-textual items. */ segPtr = (*TTkTextLine)(unsafe.Pointer(linePtr)).FsegPtr for { if !(leftToScan >= 0 && segPtr != 0) { break } if (*TTkTextSegment)(unsafe.Pointer(segPtr)).FtypePtr != uintptr(unsafe.Pointer(&XtkTextCharType)) { matchOffset += (*TTkTextSegment)(unsafe.Pointer(segPtr)).Fsize } else { if !((*TSearchSpec)(unsafe.Pointer(searchSpecPtr)).FsearchElide != 0) && XTkTextIsElided(tls, textPtr, bp, libc.UintptrFromInt32(0)) != 0 { if (*TSearchSpec)(unsafe.Pointer(searchSpecPtr)).Fexact != 0 { matchOffset += (*TTkTextSegment)(unsafe.Pointer(segPtr)).Fsize } else { matchOffset += libtcl9_0.XTcl_NumUtfChars(tls, segPtr+24, int64(-int32(1))) } } else { if (*TSearchSpec)(unsafe.Pointer(searchSpecPtr)).Fexact != 0 { leftToScan -= int32((*TTkTextSegment)(unsafe.Pointer(segPtr)).Fsize) } else { leftToScan = int32(int64(leftToScan) - libtcl9_0.XTcl_NumUtfChars(tls, segPtr+24, int64(-int32(1)))) } } } (*(*TTkTextIndex)(unsafe.Pointer(bp))).FbyteIndex += (*TTkTextSegment)(unsafe.Pointer(segPtr)).Fsize goto _1 _1: ; segPtr = (*TTkTextSegment)(unsafe.Pointer(segPtr)).FnextPtr } if segPtr == libc.UintptrFromInt32(0) && leftToScan >= 0 { /* * This will only happen if we are eliding newlines. */ linePtr = XTkBTreeNextLine(tls, textPtr, linePtr) if linePtr == libc.UintptrFromInt32(0) { /* * If we reach the end of the text, we have a serious problem, * unless there's actually nothing left to look for. */ if leftToScan == 0 { break } else { libtcl9_0.XTcl_Panic(tls, __ccgo_ts+44084, 0) } } /* * We've wrapped to the beginning of the next logical line, which * has been merged with the previous one whose newline was elided. */ lineNum++ matchOffset = 0 } else { break } } /* * Calculate and store the found index in the result. */ if (*TSearchSpec)(unsafe.Pointer(searchSpecPtr)).Fexact != 0 { XTkTextMakeByteIndex(tls, (*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).Ftree, textPtr, lineNum, matchOffset, bp+32) } else { XTkTextMakeCharIndex(tls, (*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).Ftree, textPtr, lineNum, int32(matchOffset), bp+32) } if (*TSearchSpec)(unsafe.Pointer(searchSpecPtr)).Fall != 0 { if (*TSearchSpec)(unsafe.Pointer(searchSpecPtr)).FresPtr == libc.UintptrFromInt32(0) { (*TSearchSpec)(unsafe.Pointer(searchSpecPtr)).FresPtr = libtcl9_0.XTcl_NewObj(tls) } libtcl9_0.XTcl_ListObjAppendElement(tls, libc.UintptrFromInt32(0), (*TSearchSpec)(unsafe.Pointer(searchSpecPtr)).FresPtr, XTkTextNewIndexObj(tls, textPtr, bp+32)) } else { (*TSearchSpec)(unsafe.Pointer(searchSpecPtr)).FresPtr = XTkTextNewIndexObj(tls, textPtr, bp+32) } /* * Find the end point. Here 'leftToScan' could be negative already as a * result of the above loop if the segment we reached spanned the start of * the string. When we add matchLength it will become non-negative. */ leftToScan = int32(int64(leftToScan) + matchLength) for { if !(leftToScan > 0) { break } if segPtr == libc.UintptrFromInt32(0) { /* * We are on the next line - this of course should only ever * happen with searches which have matched across multiple lines. */ linePtr = XTkBTreeNextLine(tls, textPtr, linePtr) segPtr = (*TTkTextLine)(unsafe.Pointer(linePtr)).FsegPtr (*(*TTkTextIndex)(unsafe.Pointer(bp))).FlinePtr = linePtr (*(*TTkTextIndex)(unsafe.Pointer(bp))).FbyteIndex = 0 } if (*TTkTextSegment)(unsafe.Pointer(segPtr)).FtypePtr != uintptr(unsafe.Pointer(&XtkTextCharType)) { /* * Anything we didn't count in the search needs adding. */ numChars += (*TTkTextSegment)(unsafe.Pointer(segPtr)).Fsize goto _2 } else { if !((*TSearchSpec)(unsafe.Pointer(searchSpecPtr)).FsearchElide != 0) && XTkTextIsElided(tls, textPtr, bp, libc.UintptrFromInt32(0)) != 0 { numChars += libtcl9_0.XTcl_NumUtfChars(tls, segPtr+24, int64(-int32(1))) goto _2 } } if (*TSearchSpec)(unsafe.Pointer(searchSpecPtr)).Fexact != 0 { leftToScan = int32(int64(leftToScan) - (*TTkTextSegment)(unsafe.Pointer(segPtr)).Fsize) } else { leftToScan = int32(int64(leftToScan) - libtcl9_0.XTcl_NumUtfChars(tls, segPtr+24, int64(-int32(1)))) } goto _2 _2: ; (*(*TTkTextIndex)(unsafe.Pointer(bp))).FbyteIndex += (*TTkTextSegment)(unsafe.Pointer(segPtr)).Fsize segPtr = (*TTkTextSegment)(unsafe.Pointer(segPtr)).FnextPtr } /* * Now store the count result, if it is wanted. */ if (*TSearchSpec)(unsafe.Pointer(searchSpecPtr)).FvarPtr != libc.UintptrFromInt32(0) { tmpPtr = libtcl9_0.XTcl_NewWideIntObj(tls, numChars) if (*TSearchSpec)(unsafe.Pointer(searchSpecPtr)).Fall != 0 { if (*TSearchSpec)(unsafe.Pointer(searchSpecPtr)).FcountPtr == libc.UintptrFromInt32(0) { (*TSearchSpec)(unsafe.Pointer(searchSpecPtr)).FcountPtr = libtcl9_0.XTcl_NewObj(tls) } libtcl9_0.XTcl_ListObjAppendElement(tls, libc.UintptrFromInt32(0), (*TSearchSpec)(unsafe.Pointer(searchSpecPtr)).FcountPtr, tmpPtr) } else { (*TSearchSpec)(unsafe.Pointer(searchSpecPtr)).FcountPtr = tmpPtr } } return int32(1) } /* *---------------------------------------------------------------------- * * TkTextGetTabs -- * * Parses a string description of a set of tab stops. * * Results: * The return value is a pointer to a malloc'ed structure holding parsed * information about the tab stops. If an error occurred then the return * value is NULL and an error message is left in the interp's result. * * Side effects: * Memory is allocated for the structure that is returned. It is up to * the caller to free this structure when it is no longer needed. * *---------------------------------------------------------------------- */ func XTkTextGetTabs(tls *libc.TLS, interp uintptr, tkwin TTk_Window, stringPtr uintptr) (r uintptr) { bp := tls.Alloc(80) defer tls.Free(80) /* Description of the tab stops. See the text * manual entry for details. */ var c uint8 var count, i TTcl_Size var prevStop float64 var tabArrayPtr, tabPtr uintptr var _ /* ch at bp+16 */ int32 var _ /* index at bp+32 */ int32 var _ /* lastStop at bp+24 */ float64 var _ /* objc at bp+0 */ TTcl_Size var _ /* objv at bp+8 */ uintptr _, _, _, _, _, _ = c, count, i, prevStop, tabArrayPtr, tabPtr if libtcl9_0.XTcl_ListObjGetElements(tls, interp, stringPtr, bp, bp+8) != TCL_OK { return libc.UintptrFromInt32(0) } /* * First find out how many entries we need to allocate in the tab array. */ count = 0 i = 0 for { if !(i < *(*TTcl_Size)(unsafe.Pointer(bp))) { break } c = *(*uint8)(unsafe.Pointer(libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 8)) + uintptr(i)*8)), libc.UintptrFromInt32(0)))) if libc.Int32FromUint8(c) != int32('l') && libc.Int32FromUint8(c) != int32('r') && libc.Int32FromUint8(c) != int32('c') && libc.Int32FromUint8(c) != int32('n') { count++ } goto _1 _1: ; i++ } /* * Parse the elements of the list one at a time to fill in the array. */ tabArrayPtr = libtcl9_0.XTcl_Alloc(tls, uint64(libc.UintptrFromInt32(0)+24)+libc.Uint64FromInt64(count)*uint64(8)) (*TTkTextTabArray)(unsafe.Pointer(tabArrayPtr)).FnumTabs = 0 prevStop = float64(0) *(*float64)(unsafe.Pointer(bp + 24)) = float64(0) i = 0 tabPtr = tabArrayPtr + 24 for { if !(i < *(*TTcl_Size)(unsafe.Pointer(bp))) { break } /* * This will round fractional pixels above 0.5 upwards, and otherwise * downwards, to find the right integer pixel position. */ if XTk_GetPixelsFromObj(tls, interp, tkwin, *(*uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 8)) + uintptr(i)*8)), tabPtr) != TCL_OK { goto error } if (*TTkTextTab)(unsafe.Pointer(tabPtr)).Flocation <= 0 { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+44123, libc.VaList(bp+48, libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 8)) + uintptr(i)*8)), libc.UintptrFromInt32(0))))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+48, __ccgo_ts+179, __ccgo_ts+182, __ccgo_ts+44167, libc.UintptrFromInt32(0))) goto error } prevStop = *(*float64)(unsafe.Pointer(bp + 24)) if XTk_GetDoublePixelsFromObj(tls, interp, tkwin, *(*uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 8)) + uintptr(i)*8)), bp+24) != TCL_OK { goto error } if i > 0 && (*TTkTextTab)(unsafe.Pointer(tabPtr)).Flocation <= (*TTkTextTab)(unsafe.Pointer(tabPtr-libc.UintptrFromInt32(1)*8)).Flocation { /* * This tab is actually to the left of the previous one, which is * illegal. */ libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+44176, libc.VaList(bp+48, libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 8)) + uintptr(i)*8)), libc.UintptrFromInt32(0))))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+48, __ccgo_ts+179, __ccgo_ts+182, __ccgo_ts+44167, libc.UintptrFromInt32(0))) goto error } (*TTkTextTabArray)(unsafe.Pointer(tabArrayPtr)).FnumTabs++ /* * See if there is an explicit alignment in the next list element. * Otherwise just use "left". */ (*TTkTextTab)(unsafe.Pointer(tabPtr)).Falignment = int32(LEFT1) if i+int64(1) == *(*TTcl_Size)(unsafe.Pointer(bp)) { goto _2 } /* * There may be a more efficient way of getting this. */ libtcl9_0.XTcl_UtfToUniChar(tls, libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 8)) + uintptr(i+int64(1))*8)), libc.UintptrFromInt32(0)), bp+16) if !(libtcl9_0.XTcl_UniCharIsAlpha(tls, *(*int32)(unsafe.Pointer(bp + 16))) != 0) { goto _2 } i += int64(1) if libtcl9_0.XTcl_GetIndexFromObjStruct(tls, interp, *(*uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 8)) + uintptr(i)*8)), uintptr(unsafe.Pointer(&_tabOptionStrings)), libc.Int64FromUint64(libc.Uint64FromInt64(8)), __ccgo_ts+44269, libc.Int32FromInt32(0)|libc.Int32FromUint64(libc.Uint64FromInt64(4)<= objc { goto wrongArgs } command = *(*uintptr)(unsafe.Pointer(objv + uintptr(arg)*8)) default: libtcl9_0.XTcl_Panic(tls, __ccgo_ts+39667, 0) } goto _1 _1: ; arg++ } if !(arg >= objc || arg+int64(2) < objc) { goto _2 } goto wrongArgs wrongArgs: ; libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+44294, libc.VaList(bp+88, libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv)), libc.UintptrFromInt32(0))))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+88, __ccgo_ts+5785, __ccgo_ts+17073, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) _2: ; if what == 0 { what = libc.Int32FromInt32(TK_DUMP_TEXT) | libc.Int32FromInt32(TK_DUMP_MARK) | libc.Int32FromInt32(TK_DUMP_TAG) | libc.Int32FromInt32(TK_DUMP_WIN) | libc.Int32FromInt32(TK_DUMP_IMG) } if XTkTextGetObjIndex(tls, interp, textPtr, *(*uintptr)(unsafe.Pointer(objv + uintptr(arg)*8)), bp) != TCL_OK { return int32(TCL_ERROR) } arg++ atEnd = 0 if objc == arg { XTkTextIndexForwChars(tls, libc.UintptrFromInt32(0), bp, int32(1), bp+32, int32(COUNT_INDICES)) } else { if XTkTextGetObjIndex(tls, interp, textPtr, *(*uintptr)(unsafe.Pointer(objv + uintptr(arg)*8)), bp+32) != TCL_OK { return int32(TCL_ERROR) } str = libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(arg)*8)), bp+72) if libc.Xstrncmp(tls, str, __ccgo_ts+8126, libc.Uint64FromInt64(*(*TTcl_Size)(unsafe.Pointer(bp + 72)))) == 0 { atEnd = int32(1) } } if XTkTextIndexCmp(tls, bp, bp+32) >= 0 { return TCL_OK } lineno = XTkBTreeLinesTo(tls, textPtr, (*(*TTkTextIndex)(unsafe.Pointer(bp))).FlinePtr) if (*(*TTkTextIndex)(unsafe.Pointer(bp))).FlinePtr == (*(*TTkTextIndex)(unsafe.Pointer(bp + 32))).FlinePtr { _DumpLine(tls, interp, textPtr, what, (*(*TTkTextIndex)(unsafe.Pointer(bp))).FlinePtr, int32((*(*TTkTextIndex)(unsafe.Pointer(bp))).FbyteIndex), int32((*(*TTkTextIndex)(unsafe.Pointer(bp + 32))).FbyteIndex), lineno, command) } else { lineend = XTkBTreeLinesTo(tls, textPtr, (*(*TTkTextIndex)(unsafe.Pointer(bp + 32))).FlinePtr) endByteIndex = int32((*(*TTkTextIndex)(unsafe.Pointer(bp + 32))).FbyteIndex) textChanged = _DumpLine(tls, interp, textPtr, what, (*(*TTkTextIndex)(unsafe.Pointer(bp))).FlinePtr, int32((*(*TTkTextIndex)(unsafe.Pointer(bp))).FbyteIndex), int32(32000000), lineno, command) if textChanged != 0 { if (*TTkText)(unsafe.Pointer(textPtr)).Fflags&int32(DESTROYED) != 0 { return TCL_OK } linePtr = XTkBTreeFindLine(tls, (*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).Ftree, textPtr, lineno) textChanged = 0 } else { linePtr = (*(*TTkTextIndex)(unsafe.Pointer(bp))).FlinePtr } for { v3 = XTkBTreeNextLine(tls, textPtr, linePtr) linePtr = v3 if !(v3 != libc.UintptrFromInt32(0)) { break } lineno++ if lineno == lineend { break } textChanged = _DumpLine(tls, interp, textPtr, what, linePtr, 0, int32(32000000), lineno, command) if textChanged != 0 { if (*TTkText)(unsafe.Pointer(textPtr)).Fflags&int32(DESTROYED) != 0 { return TCL_OK } linePtr = XTkBTreeFindLine(tls, (*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).Ftree, textPtr, lineno) textChanged = 0 } } if linePtr != libc.UintptrFromInt32(0) { _DumpLine(tls, interp, textPtr, what, linePtr, 0, endByteIndex, lineno, command) if (*TTkText)(unsafe.Pointer(textPtr)).Fflags&int32(DESTROYED) != 0 { return TCL_OK } } } /* * Special case to get the leftovers hiding at the end mark. */ if atEnd != 0 { if (*TTkText)(unsafe.Pointer(textPtr)).Fflags&int32(DESTROYED) != 0 { return TCL_OK } /* * Re-get the end index, in case it has changed. */ if XTkTextGetObjIndex(tls, interp, textPtr, *(*uintptr)(unsafe.Pointer(objv + uintptr(arg)*8)), bp+32) != TCL_OK { return int32(TCL_ERROR) } _DumpLine(tls, interp, textPtr, what & ^libc.Int32FromInt32(TK_DUMP_TEXT), (*(*TTkTextIndex)(unsafe.Pointer(bp + 32))).FlinePtr, 0, int32(1), lineno, command) } return TCL_OK } var _optStrings = [8]uintptr{ 0: __ccgo_ts + 43769, 1: __ccgo_ts + 16356, 2: __ccgo_ts + 20294, 3: __ccgo_ts + 44283, 4: __ccgo_ts + 44289, 5: __ccgo_ts + 20398, 6: __ccgo_ts + 2994, 7: libc.UintptrFromInt32(0), } /* *---------------------------------------------------------------------- * * DumpLine * * Return information about a given text line from character position * "start" up to, but not including, "end". * * Results: * Returns 1 if the command callback made any changes to the text widget * which will have invalidated internal structures such as TkTextSegment, * TkTextIndex, pointers. Our caller can then take action to recompute * such entities. Returns 0 otherwise. * * Side effects: * None, but see DumpSegment which can have arbitrary side-effects * *---------------------------------------------------------------------- */ func _DumpLine(tls *libc.TLS, interp uintptr, textPtr uintptr, what int32, linePtr uintptr, startByte int32, endByte int32, lineno int32, command uintptr) (r int32) { bp := tls.Alloc(32) defer tls.Free(32) /* Script to apply to the segment. */ var currentSize, first, last, length, lineChanged, newOffset, offset, textChanged int32 var eiPtr, ewPtr, markPtr, name, name1, newSegPtr, pathname, range1, searchPtr, segPtr, v1 uintptr var _ /* index at bp+0 */ TTkTextIndex _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = currentSize, eiPtr, ewPtr, first, last, length, lineChanged, markPtr, name, name1, newOffset, newSegPtr, offset, pathname, range1, searchPtr, segPtr, textChanged, v1 offset = 0 textChanged = 0 /* * Must loop through line looking at its segments. * character * toggleOn, toggleOff * mark * image * window */ segPtr = (*TTkTextLine)(unsafe.Pointer(linePtr)).FsegPtr for offset < endByte && segPtr != libc.UintptrFromInt32(0) { lineChanged = 0 currentSize = int32((*TTkTextSegment)(unsafe.Pointer(segPtr)).Fsize) if what&int32(TK_DUMP_TEXT) != 0 && (*TTkTextSegment)(unsafe.Pointer(segPtr)).FtypePtr == uintptr(unsafe.Pointer(&XtkTextCharType)) && offset+currentSize > startByte { last = currentSize /* Index of last char in seg. */ first = 0 /* Index of first char in seg. */ if offset+currentSize > endByte { last = endByte - offset } if startByte > offset { first = startByte - offset } if last != currentSize { /* * To avoid modifying the string in place we copy over just * the segment that we want. Since DumpSegment can modify the * text, we could not confidently revert the modification * here. */ length = last - first range1 = libtcl9_0.XTcl_Alloc(tls, libc.Uint64FromInt32(length+int32(1))) libc.Xmemcpy(tls, range1, segPtr+24+uintptr(first), libc.Uint64FromInt32(length)) *(*uint8)(unsafe.Pointer(range1 + uintptr(length))) = uint8('\000') XTkTextMakeByteIndex(tls, (*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).Ftree, textPtr, lineno, int64(offset+first), bp) lineChanged = _DumpSegment(tls, textPtr, interp, __ccgo_ts+17996, range1, command, bp, what) libtcl9_0.XTcl_Free(tls, range1) } else { XTkTextMakeByteIndex(tls, (*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).Ftree, textPtr, lineno, int64(offset+first), bp) lineChanged = _DumpSegment(tls, textPtr, interp, __ccgo_ts+17996, segPtr+24+uintptr(first), command, bp, what) } } else { if offset >= startByte { if what&int32(TK_DUMP_MARK) != 0 && ((*TTkTextSegment)(unsafe.Pointer(segPtr)).FtypePtr == uintptr(unsafe.Pointer(&XtkTextLeftMarkType)) || (*TTkTextSegment)(unsafe.Pointer(segPtr)).FtypePtr == uintptr(unsafe.Pointer(&XtkTextRightMarkType))) { markPtr = segPtr + 24 if segPtr == (*TTkText)(unsafe.Pointer(textPtr)).FinsertMarkPtr { name = __ccgo_ts + 22158 } else { if segPtr == (*TTkText)(unsafe.Pointer(textPtr)).FcurrentMarkPtr { name = __ccgo_ts + 3279 } else { if (*TTkTextMark)(unsafe.Pointer(markPtr)).FhPtr == libc.UintptrFromInt32(0) { name = libc.UintptrFromInt32(0) lineChanged = 0 } else { if (*TTcl_HashTable)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr+128)).FkeyType == int32(TCL_ONE_WORD_KEYS) || (*TTcl_HashTable)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr+128)).FkeyType == -int32(1) { v1 = *(*uintptr)(unsafe.Pointer((*TTkTextMark)(unsafe.Pointer(markPtr)).FhPtr + 32)) } else { v1 = (*TTkTextMark)(unsafe.Pointer(markPtr)).FhPtr + 32 } name = v1 } } } if name != libc.UintptrFromInt32(0) { XTkTextMakeByteIndex(tls, (*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).Ftree, textPtr, lineno, int64(offset), bp) lineChanged = _DumpSegment(tls, textPtr, interp, __ccgo_ts+2046, name, command, bp, what) } } else { if what&int32(TK_DUMP_TAG) != 0 && (*TTkTextSegment)(unsafe.Pointer(segPtr)).FtypePtr == uintptr(unsafe.Pointer(&XtkTextToggleOnType)) { XTkTextMakeByteIndex(tls, (*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).Ftree, textPtr, lineno, int64(offset), bp) lineChanged = _DumpSegment(tls, textPtr, interp, __ccgo_ts+44381, (*TTkTextTag1)(unsafe.Pointer((*(*TTkTextToggle)(unsafe.Pointer(&(*TTkTextSegment)(unsafe.Pointer(segPtr)).Fbody))).FtagPtr)).Fname, command, bp, what) } else { if what&int32(TK_DUMP_TAG) != 0 && (*TTkTextSegment)(unsafe.Pointer(segPtr)).FtypePtr == uintptr(unsafe.Pointer(&XtkTextToggleOffType)) { XTkTextMakeByteIndex(tls, (*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).Ftree, textPtr, lineno, int64(offset), bp) lineChanged = _DumpSegment(tls, textPtr, interp, __ccgo_ts+44387, (*TTkTextTag1)(unsafe.Pointer((*(*TTkTextToggle)(unsafe.Pointer(&(*TTkTextSegment)(unsafe.Pointer(segPtr)).Fbody))).FtagPtr)).Fname, command, bp, what) } else { if what&int32(TK_DUMP_IMG) != 0 && (*TTkTextSegment)(unsafe.Pointer(segPtr)).FtypePtr == uintptr(unsafe.Pointer(&XtkTextEmbImageType)) { eiPtr = segPtr + 24 name1 = (*TTkTextEmbImage)(unsafe.Pointer(eiPtr)).Fname XTkTextMakeByteIndex(tls, (*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).Ftree, textPtr, lineno, int64(offset), bp) lineChanged = _DumpSegment(tls, textPtr, interp, __ccgo_ts+17810, name1, command, bp, what) } else { if what&int32(TK_DUMP_WIN) != 0 && (*TTkTextSegment)(unsafe.Pointer(segPtr)).FtypePtr == uintptr(unsafe.Pointer(&XtkTextEmbWindowType)) { ewPtr = segPtr + 24 if (*TTkTextEmbWindow)(unsafe.Pointer(ewPtr)).Ftkwin == libc.UintptrFromInt32(0) { pathname = __ccgo_ts + 195 } else { pathname = (*TTk_FakeWin)(unsafe.Pointer((*TTkTextEmbWindow)(unsafe.Pointer(ewPtr)).Ftkwin)).FpathName } XTkTextMakeByteIndex(tls, (*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).Ftree, textPtr, lineno, int64(offset), bp) lineChanged = _DumpSegment(tls, textPtr, interp, __ccgo_ts+4814, pathname, command, bp, what) } } } } } } } offset += currentSize if lineChanged != 0 { newOffset = 0 textChanged = int32(1) /* * Our indices are no longer valid. */ if (*TTkText)(unsafe.Pointer(textPtr)).Fflags&int32(DESTROYED) != 0 { return textChanged } linePtr = XTkBTreeFindLine(tls, (*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).Ftree, textPtr, lineno) newSegPtr = (*TTkTextLine)(unsafe.Pointer(linePtr)).FsegPtr if segPtr != newSegPtr { for newOffset < endByte && newOffset < offset && newSegPtr != libc.UintptrFromInt32(0) { newOffset += currentSize newSegPtr = (*TTkTextSegment)(unsafe.Pointer(newSegPtr)).FnextPtr if segPtr == newSegPtr { break } } if segPtr != newSegPtr && newOffset == offset && currentSize == 0 { searchPtr = newSegPtr for searchPtr != libc.UintptrFromInt32(0) && (*TTkTextSegment)(unsafe.Pointer(searchPtr)).Fsize == 0 { if searchPtr == segPtr { newSegPtr = searchPtr break } searchPtr = (*TTkTextSegment)(unsafe.Pointer(searchPtr)).FnextPtr } } segPtr = newSegPtr } } if segPtr != libc.UintptrFromInt32(0) { segPtr = (*TTkTextSegment)(unsafe.Pointer(segPtr)).FnextPtr } } return textChanged } /* *---------------------------------------------------------------------- * * DumpSegment * * Either append information about the current segment to the result, or * make a script callback with that information as arguments. * * Results: * Returns 1 if the command callback made any changes to the text widget * which will have invalidated internal structures such as TkTextSegment, * TkTextIndex, pointers. Our caller can then take action to recompute * such entities. Returns 0 otherwise. * * Side effects: * Either evals the callback or appends elements to the result string. * The callback can have arbitrary side-effects. * *---------------------------------------------------------------------- */ func _DumpSegment(tls *libc.TLS, textPtr uintptr, interp uintptr, key uintptr, value uintptr, command uintptr, index uintptr, dummy5075 int32) (r int32) { bp := tls.Alloc(288) defer tls.Free(288) /* Look for TK_DUMP_INDEX bit. */ var _objPtr, _objPtr1, tuple, v2, v4 uintptr var code int32 var oldStateEpoch, v1, v3 TTcl_Size var _ /* buf at bp+56 */ TTcl_DString var _ /* buffer at bp+0 */ [30]uint8 var _ /* values at bp+32 */ [3]uintptr _, _, _, _, _, _, _, _, _ = _objPtr, _objPtr1, code, oldStateEpoch, tuple, v1, v2, v3, v4 XTkTextPrintIndex(tls, textPtr, index, bp) (*(*[3]uintptr)(unsafe.Pointer(bp + 32)))[0] = libtcl9_0.XTcl_NewStringObj(tls, key, int64(-int32(1))) (*(*[3]uintptr)(unsafe.Pointer(bp + 32)))[int32(1)] = libtcl9_0.XTcl_NewStringObj(tls, value, int64(-int32(1))) (*(*[3]uintptr)(unsafe.Pointer(bp + 32)))[int32(2)] = libtcl9_0.XTcl_NewStringObj(tls, bp, int64(-int32(1))) tuple = libtcl9_0.XTcl_NewListObj(tls, int64(3), bp+32) if command == libc.UintptrFromInt32(0) { libtcl9_0.XTcl_ListObjAppendList(tls, libc.UintptrFromInt32(0), libtcl9_0.XTcl_GetObjResult(tls, interp), tuple) _objPtr = tuple v2 = _objPtr v1 = *(*TTcl_Size)(unsafe.Pointer(v2)) *(*TTcl_Size)(unsafe.Pointer(v2))-- if v1 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr) } return 0 } else { oldStateEpoch = XTkBTreeEpoch(tls, (*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).Ftree) libtcl9_0.XTcl_DStringInit(tls, bp+56) libtcl9_0.XTcl_DStringAppend(tls, bp+56, libtcl9_0.XTcl_GetStringFromObj(tls, command, libc.UintptrFromInt32(0)), int64(-libc.Int32FromInt32(1))) libtcl9_0.XTcl_DStringAppend(tls, bp+56, __ccgo_ts+634, int64(-libc.Int32FromInt32(1))) libtcl9_0.XTcl_DStringAppend(tls, bp+56, libtcl9_0.XTcl_GetStringFromObj(tls, tuple, libc.UintptrFromInt32(0)), int64(-libc.Int32FromInt32(1))) code = libtcl9_0.XTcl_EvalEx(tls, interp, (*TTcl_DString)(unsafe.Pointer(bp+56)).Fstring1, int64(-libc.Int32FromInt32(1)), int32(TCL_EVAL_GLOBAL)) libtcl9_0.XTcl_DStringFree(tls, bp+56) if code != TCL_OK { libtcl9_0.XTcl_AppendObjToErrorInfo(tls, interp, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+44394, int64(-int32(1)))) libtcl9_0.XTcl_BackgroundException(tls, interp, code) } _objPtr1 = tuple v4 = _objPtr1 v3 = *(*TTcl_Size)(unsafe.Pointer(v4)) *(*TTcl_Size)(unsafe.Pointer(v4))-- if v3 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr1) } return libc.BoolInt32((*TTkText)(unsafe.Pointer(textPtr)).Fflags&int32(DESTROYED) != 0 || XTkBTreeEpoch(tls, (*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).Ftree) != oldStateEpoch) } return r } /* *---------------------------------------------------------------------- * * TextEditUndo -- * * Undo the last change. * * Results: * None. * * Side effects: * Apart from manipulating the undo and redo stacks, the state of the * rest of the widget may also change (due to whatever is being undone). * *---------------------------------------------------------------------- */ func _TextEditUndo(tls *libc.TLS, textPtr uintptr) (r int32) { bp := tls.Alloc(16) defer tls.Free(16) /* Overall information about text widget. */ var _objPtr, cmdObj, v2 uintptr var code, status int32 var v1 TTcl_Size _, _, _, _, _, _ = _objPtr, cmdObj, code, status, v1, v2 if !((*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).Fundo != 0) { return TCL_OK } if (*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).FautoSeparators != 0 { XTkUndoInsertUndoSeparator(tls, (*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).FundoStack) } /* * Turn off the undo feature while we revert a compound action, setting * the dirty handling mode to undo for the duration (unless it is * 'fixed'). */ (*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).Fundo = 0 if (*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).FdirtyMode != int32(TK_TEXT_DIRTY_FIXED) { (*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).FdirtyMode = int32(TK_TEXT_DIRTY_UNDO) } status = XTkUndoRevert(tls, (*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).FundoStack) if (*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).FdirtyMode != int32(TK_TEXT_DIRTY_FIXED) { (*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).FdirtyMode = int32(TK_TEXT_DIRTY_NORMAL) } (*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).Fundo = int32(1) if (*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).FautoSeparators != 0 { XTkUndoInsertUndoSeparator(tls, (*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).FundoStack) } /* * Convert undo/redo temporary marks set by TkUndoRevert() into * indices left in the interp result. */ cmdObj = libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+44442, libc.VaList(bp+8, (*TTk_FakeWin)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).Ftkwin)).FpathName)) (*TTcl_Obj)(unsafe.Pointer(cmdObj)).FrefCount++ code = libtcl9_0.XTcl_EvalObjEx(tls, (*TTkText)(unsafe.Pointer(textPtr)).Finterp, cmdObj, int32(TCL_EVAL_GLOBAL)) if code != TCL_OK { libtcl9_0.XTcl_AppendObjToErrorInfo(tls, (*TTkText)(unsafe.Pointer(textPtr)).Finterp, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+44476, int64(-int32(1)))) libtcl9_0.XTcl_BackgroundException(tls, (*TTkText)(unsafe.Pointer(textPtr)).Finterp, code) } _objPtr = cmdObj v2 = _objPtr v1 = *(*TTcl_Size)(unsafe.Pointer(v2)) *(*TTcl_Size)(unsafe.Pointer(v2))-- if v1 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr) } return status } /* *---------------------------------------------------------------------- * * TextEditRedo -- * * Redo the last undone change. * * Results: * None. * * Side effects: * Apart from manipulating the undo and redo stacks, the state of the * rest of the widget may also change (due to whatever is being redone). * *---------------------------------------------------------------------- */ func _TextEditRedo(tls *libc.TLS, textPtr uintptr) (r int32) { bp := tls.Alloc(16) defer tls.Free(16) /* Overall information about text widget. */ var _objPtr, cmdObj, v2 uintptr var code, status int32 var v1 TTcl_Size _, _, _, _, _, _ = _objPtr, cmdObj, code, status, v1, v2 if !((*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).Fundo != 0) { return TCL_OK } /* * Turn off the undo feature temporarily while we revert a previously * undone compound action, setting the dirty handling mode to redo for the * duration (unless it is 'fixed'). */ (*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).Fundo = 0 if (*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).FdirtyMode != int32(TK_TEXT_DIRTY_FIXED) { (*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).FdirtyMode = int32(TK_TEXT_DIRTY_REDO) } status = XTkUndoApply(tls, (*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).FundoStack) if (*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).FdirtyMode != int32(TK_TEXT_DIRTY_FIXED) { (*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).FdirtyMode = int32(TK_TEXT_DIRTY_NORMAL) } (*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).Fundo = int32(1) /* * Convert undo/redo temporary marks set by TkUndoApply() into * indices left in the interp result. */ cmdObj = libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+44442, libc.VaList(bp+8, (*TTk_FakeWin)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).Ftkwin)).FpathName)) (*TTcl_Obj)(unsafe.Pointer(cmdObj)).FrefCount++ code = libtcl9_0.XTcl_EvalObjEx(tls, (*TTkText)(unsafe.Pointer(textPtr)).Finterp, cmdObj, int32(TCL_EVAL_GLOBAL)) if code != TCL_OK { libtcl9_0.XTcl_AppendObjToErrorInfo(tls, (*TTkText)(unsafe.Pointer(textPtr)).Finterp, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+44476, int64(-int32(1)))) libtcl9_0.XTcl_BackgroundException(tls, (*TTkText)(unsafe.Pointer(textPtr)).Finterp, code) } _objPtr = cmdObj v2 = _objPtr v1 = *(*TTcl_Size)(unsafe.Pointer(v2)) *(*TTcl_Size)(unsafe.Pointer(v2))-- if v1 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr) } return status } /* *---------------------------------------------------------------------- * * TextEditCmd -- * * Handle the subcommands to "$text edit ...". See documentation for * details. * * Results: * None * * Side effects: * None. * *---------------------------------------------------------------------- */ func _TextEditCmd(tls *libc.TLS, textPtr uintptr, interp uintptr, objc TTcl_Size, objv uintptr) (r int32) { bp := tls.Alloc(48) defer tls.Free(48) /* Argument objects. */ var canRedo, canUndo, oldModified, v1 int32 var _ /* index at bp+0 */ int32 var _ /* setModified at bp+4 */ int32 _, _, _, _ = canRedo, canUndo, oldModified, v1 canRedo = 0 canUndo = 0 if objc < int64(3) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(2), objv, __ccgo_ts+4953) return int32(TCL_ERROR) } if libtcl9_0.XTcl_GetIndexFromObjStruct(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), uintptr(unsafe.Pointer(&_editOptionStrings)), libc.Int64FromUint64(libc.Uint64FromInt64(8)), __ccgo_ts+44524, libc.Int32FromInt32(0)|libc.Int32FromUint64(libc.Uint64FromInt64(4)<> event if the flag actually changed. * However, degree of modified-ness doesn't matter. [Bug 1799782] */ if libc.BoolInt32(!(oldModified != 0)) != libc.BoolInt32(!(*(*int32)(unsafe.Pointer(bp + 4)) != 0)) { _GenerateModifiedEvent(tls, textPtr) } case 3: if objc != int64(3) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(3), objv, libc.UintptrFromInt32(0)) return int32(TCL_ERROR) } canUndo = XTkUndoCanUndo(tls, (*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).FundoStack) if _TextEditRedo(tls, textPtr) != 0 { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+44546, int64(-int32(1)))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+16, __ccgo_ts+179, __ccgo_ts+16417, __ccgo_ts+44562, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) } canRedo = XTkUndoCanRedo(tls, (*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).FundoStack) if !(canUndo != 0) || !(canRedo != 0) { _GenerateUndoStackEvent(tls, textPtr) } case 4: if objc != int64(3) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(3), objv, libc.UintptrFromInt32(0)) return int32(TCL_ERROR) } canUndo = XTkUndoCanUndo(tls, (*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).FundoStack) canRedo = XTkUndoCanRedo(tls, (*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).FundoStack) XTkUndoClearStacks(tls, (*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).FundoStack) if canUndo != 0 || canRedo != 0 { _GenerateUndoStackEvent(tls, textPtr) } case 5: if objc != int64(3) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(3), objv, libc.UintptrFromInt32(0)) return int32(TCL_ERROR) } XTkUndoInsertUndoSeparator(tls, (*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).FundoStack) case 6: if objc != int64(3) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(3), objv, libc.UintptrFromInt32(0)) return int32(TCL_ERROR) } canRedo = XTkUndoCanRedo(tls, (*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).FundoStack) if _TextEditUndo(tls, textPtr) != 0 { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+44570, int64(-int32(1)))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+16, __ccgo_ts+179, __ccgo_ts+16417, __ccgo_ts+44586, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) } canUndo = XTkUndoCanUndo(tls, (*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).FundoStack) if !(canRedo != 0) || !(canUndo != 0) { _GenerateUndoStackEvent(tls, textPtr) } break } return TCL_OK } var _editOptionStrings = [8]uintptr{ 0: __ccgo_ts + 44494, 1: __ccgo_ts + 44502, 2: __ccgo_ts + 44510, 3: __ccgo_ts + 44519, 4: __ccgo_ts + 5748, 5: __ccgo_ts + 24143, 6: __ccgo_ts + 42879, 7: libc.UintptrFromInt32(0), } /* *---------------------------------------------------------------------- * * TextGetText -- * * Returns the text from indexPtr1 to indexPtr2, placing that text in a * string object which is returned with a refCount of zero. * * Since the amount of text may potentially be several megabytes (e.g. * in text editors built on the text widget), efficiency is very * important. We may want to investigate the efficiency of the * Tcl_AppendToObj more carefully (e.g. if we know we are going to be * appending several thousand lines, we could attempt to pre-allocate a * larger space). * * Results: * Tcl_Obj of string type containing the specified text. If the * visibleOnly flag is set to 1, then only those characters which are not * elided will be returned. Otherwise (flag is 0) all characters in the * given range are returned. * * Side effects: * Memory will be allocated for the new object. Remember to free it if it * isn't going to be stored appropriately. * *---------------------------------------------------------------------- */ func _TextGetText(tls *libc.TLS, textPtr uintptr, indexPtr1 uintptr, indexPtr2 uintptr, visibleOnly int32) (r uintptr) { bp := tls.Alloc(48) defer tls.Free(48) /* If non-zero, then only return non-elided * characters. */ var last, last2 int32 var resultPtr, segPtr uintptr var _ /* offset at bp+32 */ TTcl_Size var _ /* tmpIndex at bp+0 */ TTkTextIndex _, _, _, _ = last, last2, resultPtr, segPtr resultPtr = libtcl9_0.XTcl_NewObj(tls) XTkTextMakeByteIndex(tls, (*TTkTextIndex)(unsafe.Pointer(indexPtr1)).Ftree, textPtr, XTkBTreeLinesTo(tls, textPtr, (*TTkTextIndex)(unsafe.Pointer(indexPtr1)).FlinePtr), (*TTkTextIndex)(unsafe.Pointer(indexPtr1)).FbyteIndex, bp) if XTkTextIndexCmp(tls, indexPtr1, indexPtr2) < 0 { for int32(1) != 0 { segPtr = XTkTextIndexToSeg(tls, bp, bp+32) last = int32((*TTkTextSegment)(unsafe.Pointer(segPtr)).Fsize) if (*(*TTkTextIndex)(unsafe.Pointer(bp))).FlinePtr == (*TTkTextIndex)(unsafe.Pointer(indexPtr2)).FlinePtr { /* * The last line that was requested must be handled carefully, * because we may need to break out of this loop in the middle * of the line. */ if (*TTkTextIndex)(unsafe.Pointer(indexPtr2)).FbyteIndex == (*(*TTkTextIndex)(unsafe.Pointer(bp))).FbyteIndex { break } last2 = int32((*TTkTextIndex)(unsafe.Pointer(indexPtr2)).FbyteIndex - (*(*TTkTextIndex)(unsafe.Pointer(bp))).FbyteIndex + *(*TTcl_Size)(unsafe.Pointer(bp + 32))) if last2 < last { last = last2 } } if (*TTkTextSegment)(unsafe.Pointer(segPtr)).FtypePtr == uintptr(unsafe.Pointer(&XtkTextCharType)) && !(visibleOnly != 0 && XTkTextIsElided(tls, textPtr, bp, libc.UintptrFromInt32(0)) != 0) { libtcl9_0.XTcl_AppendToObj(tls, resultPtr, segPtr+24+uintptr(*(*TTcl_Size)(unsafe.Pointer(bp + 32))), int64(last)-*(*TTcl_Size)(unsafe.Pointer(bp + 32))) } XTkTextIndexForwBytes(tls, textPtr, bp, int64(last)-*(*TTcl_Size)(unsafe.Pointer(bp + 32)), bp) } } return resultPtr } /* *---------------------------------------------------------------------- * * GenerateModifiedEvent -- * * Send an event that the text was modified. This is equivalent to: * event generate $textWidget <> * for all peers of $textWidget. * * Results: * None * * Side effects: * May force the text window into existence. * *---------------------------------------------------------------------- */ func _GenerateModifiedEvent(tls *libc.TLS, textPtr uintptr) { /* Information about text widget. */ textPtr = (*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).Fpeers for { if !(textPtr != libc.UintptrFromInt32(0)) { break } XTk_MakeWindowExist(tls, (*TTkText)(unsafe.Pointer(textPtr)).Ftkwin) XTk_SendVirtualEvent(tls, (*TTkText)(unsafe.Pointer(textPtr)).Ftkwin, __ccgo_ts+44594, libc.UintptrFromInt32(0)) goto _1 _1: ; textPtr = (*TTkText)(unsafe.Pointer(textPtr)).Fnext } } /* *---------------------------------------------------------------------- * * GenerateUndoStackEvent -- * * Send an event that the undo or redo stack became empty or unempty. * This is equivalent to: * event generate $textWidget <> * for all peers of $textWidget. * * Results: * None * * Side effects: * May force the text window (and all peers) into existence. * *---------------------------------------------------------------------- */ func _GenerateUndoStackEvent(tls *libc.TLS, textPtr uintptr) { /* Information about text widget. */ textPtr = (*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).Fpeers for { if !(textPtr != libc.UintptrFromInt32(0)) { break } XTk_MakeWindowExist(tls, (*TTkText)(unsafe.Pointer(textPtr)).Ftkwin) XTk_SendVirtualEvent(tls, (*TTkText)(unsafe.Pointer(textPtr)).Ftkwin, __ccgo_ts+44603, libc.UintptrFromInt32(0)) goto _1 _1: ; textPtr = (*TTkText)(unsafe.Pointer(textPtr)).Fnext } } /* *---------------------------------------------------------------------- * * UpdateDirtyFlag -- * * Updates the dirtyness of the text widget * * Results: * None * * Side effects: * None. * *---------------------------------------------------------------------- */ func _UpdateDirtyFlag(tls *libc.TLS, sharedTextPtr uintptr) { /* Information about text widget. */ var oldDirtyFlag int32 _ = oldDirtyFlag /* * If we've been forced to be dirty, we stay dirty (until explicitly * reset, of course). */ if (*TTkSharedText)(unsafe.Pointer(sharedTextPtr)).FdirtyMode == int32(TK_TEXT_DIRTY_FIXED) { return } if (*TTkSharedText)(unsafe.Pointer(sharedTextPtr)).FisDirty < 0 && (*TTkSharedText)(unsafe.Pointer(sharedTextPtr)).FdirtyMode == int32(TK_TEXT_DIRTY_NORMAL) { /* * If dirty flag is negative, only redo operations can make it zero * again. If we do a normal operation, it can never become zero any * more (other than by explicit reset). */ (*TTkSharedText)(unsafe.Pointer(sharedTextPtr)).FdirtyMode = int32(TK_TEXT_DIRTY_FIXED) return } oldDirtyFlag = (*TTkSharedText)(unsafe.Pointer(sharedTextPtr)).FisDirty if (*TTkSharedText)(unsafe.Pointer(sharedTextPtr)).FdirtyMode == int32(TK_TEXT_DIRTY_UNDO) { (*TTkSharedText)(unsafe.Pointer(sharedTextPtr)).FisDirty-- } else { (*TTkSharedText)(unsafe.Pointer(sharedTextPtr)).FisDirty++ } if (*TTkSharedText)(unsafe.Pointer(sharedTextPtr)).FisDirty == 0 || oldDirtyFlag == 0 { _GenerateModifiedEvent(tls, (*TTkSharedText)(unsafe.Pointer(sharedTextPtr)).Fpeers) } } /* *---------------------------------------------------------------------- * * TkTextRunAfterSyncCmd -- * * This function is called by the event loop and executes the command * scheduled by [.text sync -command $cmd]. * * Results: * None. * * Side effects: * Anything may happen, depending on $cmd contents. * *---------------------------------------------------------------------- */ func XTkTextRunAfterSyncCmd(tls *libc.TLS, clientData uintptr) { /* Information about text widget. */ var _objPtr, textPtr, v2, v4 uintptr var code int32 var v1, v3 TTcl_Size _, _, _, _, _, _, _ = _objPtr, code, textPtr, v1, v2, v3, v4 textPtr = clientData if (*TTkText)(unsafe.Pointer(textPtr)).Ftkwin == libc.UintptrFromInt32(0) || (*TTkText)(unsafe.Pointer(textPtr)).Fflags&int32(DESTROYED) != 0 { /* * The widget has been deleted. Don't do anything. */ v2 = textPtr + 688 v1 = *(*TTcl_Size)(unsafe.Pointer(v2)) *(*TTcl_Size)(unsafe.Pointer(v2))-- if v1 <= int64(1) { libtcl9_0.XTcl_Free(tls, textPtr) } return } libtcl9_0.XTcl_Preserve(tls, (*TTkText)(unsafe.Pointer(textPtr)).Finterp) code = libtcl9_0.XTcl_EvalObjEx(tls, (*TTkText)(unsafe.Pointer(textPtr)).Finterp, (*TTkText)(unsafe.Pointer(textPtr)).FafterSyncCmd, int32(TCL_EVAL_GLOBAL)) if code == int32(TCL_ERROR) { libtcl9_0.XTcl_AppendObjToErrorInfo(tls, (*TTkText)(unsafe.Pointer(textPtr)).Finterp, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+44613, int64(-int32(1)))) libtcl9_0.XTcl_BackgroundException(tls, (*TTkText)(unsafe.Pointer(textPtr)).Finterp, int32(TCL_ERROR)) } libtcl9_0.XTcl_Release(tls, (*TTkText)(unsafe.Pointer(textPtr)).Finterp) _objPtr = (*TTkText)(unsafe.Pointer(textPtr)).FafterSyncCmd v4 = _objPtr v3 = *(*TTcl_Size)(unsafe.Pointer(v4)) *(*TTcl_Size)(unsafe.Pointer(v4))-- if v3 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr) } (*TTkText)(unsafe.Pointer(textPtr)).FafterSyncCmd = libc.UintptrFromInt32(0) } /* *---------------------------------------------------------------------- * * SearchPerform -- * * Overall control of search process. Is given a pattern, a starting * index and an ending index, and attempts to perform a search. This * function is actually completely independent of Tk, and could in the * future be split off. * * Results: * Standard Tcl result code. In particular, if fromPtr or toPtr are not * considered valid by the 'lineIndexProc', an error will be thrown and * no search performed. * * Side effects: * See 'SearchCore'. * *---------------------------------------------------------------------- */ func _SearchPerform(tls *libc.TLS, interp uintptr, searchSpecPtr uintptr, patObj uintptr, fromPtr uintptr, toPtr uintptr) (r int32) { /* NULL or information describing the last * index. */ var indexFromPtr, indexToPtr, textPtr uintptr var v1 int32 _, _, _, _ = indexFromPtr, indexToPtr, textPtr, v1 /* * Find the starting line and starting offset (measured in Unicode chars * for regexp search, utf-8 bytes for exact search). */ if (*(*func(*libc.TLS, uintptr, uintptr, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*TSearchSpec)(unsafe.Pointer(searchSpecPtr)).FlineIndexProc})))(tls, interp, fromPtr, searchSpecPtr, searchSpecPtr+24, searchSpecPtr+32) != TCL_OK { return int32(TCL_ERROR) } /* * Find the optional end location, similarly. */ if toPtr != libc.UintptrFromInt32(0) { textPtr = (*TSearchSpec)(unsafe.Pointer(searchSpecPtr)).FclientData indexToPtr = XTkTextGetIndexFromObj(tls, interp, textPtr, toPtr) if indexToPtr == libc.UintptrFromInt32(0) { return int32(TCL_ERROR) } indexFromPtr = XTkTextGetIndexFromObj(tls, interp, textPtr, fromPtr) /* * Check for any empty search range here. It might be better in the * future to embed that in SearchCore (whose default behaviour is to * wrap when given a negative search range). */ if (*TSearchSpec)(unsafe.Pointer(searchSpecPtr)).Fbackwards != 0 { v1 = -int32(1) } else { v1 = int32(1) } if XTkTextIndexCmp(tls, indexFromPtr, indexToPtr) == v1 { return TCL_OK } if (*(*func(*libc.TLS, uintptr, uintptr, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*TSearchSpec)(unsafe.Pointer(searchSpecPtr)).FlineIndexProc})))(tls, interp, toPtr, searchSpecPtr, searchSpecPtr+40, searchSpecPtr+48) != TCL_OK { return int32(TCL_ERROR) } } else { (*TSearchSpec)(unsafe.Pointer(searchSpecPtr)).FstopLine = -int32(1) } /* * Scan through all of the lines of the text circularly, starting at the * given index. 'patObj' is the pattern which may be an exact string or a * regexp pattern depending on the flags in searchSpecPtr. */ return _SearchCore(tls, interp, searchSpecPtr, patObj) } /* *---------------------------------------------------------------------- * * SearchCore -- * * The core of the search function. This function is actually completely * independent of Tk, and could in the future be split off. * * The function assumes regexp-based searches operate on Unicode strings, * and exact searches on utf-8 strings. Therefore the 'foundMatchProc' * and 'addLineProc' need to be aware of this distinction. * * Results: * Standard Tcl result code. * * Side effects: * Only those of the 'searchSpecPtr->foundMatchProc' which is called * whenever a match is found. * * Note that the way matching across multiple lines is implemented, we * start afresh with each line we have available, even though we may * already have examined the contents of that line (and further ones) if * we were attempting a multi-line match using the previous line. This * means there may be ways to speed this up a lot by not throwing away * all the multi-line information one has accumulated. Profiling should * be done to see where the bottlenecks lie before attempting this, * however. We would also need to be very careful such optimisation keep * within the specified search bounds. * *---------------------------------------------------------------------- */ func _SearchCore(tls *libc.TLS, interp uintptr, searchSpecPtr uintptr, patObj uintptr) (r int32) { bp := tls.Alloc(384) defer tls.Free(384) /* Contains an exact string or a regexp * pattern. Must have a refCount > 0. */ var _objPtr, _objPtr1, lineInfo, newArray, nl, p, pattern, startOfLine, storeLength, storeMatch, theLine, v15, v17 uintptr var alreadySearchOffset, code, extraLinesSearched, firstNewLine, firstOffset, lastBackwardsLineMatch, lastBackwardsMatchOffset, lastNonOverlap, lineNum, match, matchNum, matches, maxExtraLines, maxExtraLines1, passes, skipFirst, thisOffset, v1, v10, v12, v13, v2, v4, v7 int32 var c uint8 var lastFullLine, lastFullLine1, matchOffset, prevFullLine, v14, v16 TTcl_Size var regexp TTcl_RegExp var v5, v6 int64 var _ /* ch at bp+340 */ int32 var _ /* extraLines at bp+344 */ int32 var _ /* extraLines at bp+376 */ int32 var _ /* info at bp+352 */ TTcl_RegExpInfo var _ /* lastOffset at bp+0 */ int32 var _ /* lastTotal at bp+348 */ int32 var _ /* lastTotal at bp+380 */ int32 var _ /* linesSearched at bp+336 */ int32 var _ /* matchLength at bp+8 */ TTcl_Size var _ /* smArray at bp+16 */ [40]TTcl_Size _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = _objPtr, _objPtr1, alreadySearchOffset, c, code, extraLinesSearched, firstNewLine, firstOffset, lastBackwardsLineMatch, lastBackwardsMatchOffset, lastFullLine, lastFullLine1, lastNonOverlap, lineInfo, lineNum, match, matchNum, matchOffset, matches, maxExtraLines, maxExtraLines1, newArray, nl, p, passes, pattern, prevFullLine, regexp, skipFirst, startOfLine, storeLength, storeMatch, theLine, thisOffset, v1, v10, v12, v13, v14, v15, v16, v17, v2, v4, v5, v6, v7 lineNum = (*TSearchSpec)(unsafe.Pointer(searchSpecPtr)).FstartLine code = TCL_OK alreadySearchOffset = -int32(1) pattern = libc.UintptrFromInt32(0) /* For exact searches only. */ firstNewLine = -int32(1) /* For exact searches only. */ regexp = libc.UintptrFromInt32(0) /* For regexp searches only. */ /* * These items are for backward regexp searches only. They are for two * purposes: to allow us to report backwards matches in the correct order, * even though the implementation uses repeated forward searches; and to * provide for overlap checking between backwards matches on different * text lines. */ matchNum = int32(LOTS_OF_MATCHES) storeMatch = bp + 16 storeLength = bp + 16 + uintptr(LOTS_OF_MATCHES)*8 lastBackwardsLineMatch = -int32(1) lastBackwardsMatchOffset = -int32(1) if (*TSearchSpec)(unsafe.Pointer(searchSpecPtr)).Fexact != 0 { /* * Convert the pattern to lower-case if we're supposed to ignore case. */ if (*TSearchSpec)(unsafe.Pointer(searchSpecPtr)).FnoCase != 0 { patObj = libtcl9_0.XTcl_DuplicateObj(tls, patObj) /* * This can change the length of the string behind the object's * back, so ensure it is correctly synchronised. */ libtcl9_0.XTcl_SetObjLength(tls, patObj, libtcl9_0.XTcl_UtfToLower(tls, libtcl9_0.XTcl_GetStringFromObj(tls, patObj, libc.UintptrFromInt32(0)))) } } else { /* * Compile the regular expression. We want '^$' to match after and * before \n respectively, so use the TCL_REG_NLANCH flag. */ if (*TSearchSpec)(unsafe.Pointer(searchSpecPtr)).FnoCase != 0 { v1 = int32(TCL_REG_NOCASE) } else { v1 = 0 } if (*TSearchSpec)(unsafe.Pointer(searchSpecPtr)).FnoLineStop != 0 { v2 = 0 } else { v2 = int32(TCL_REG_NLSTOP) } regexp = libtcl9_0.XTcl_GetRegExpFromObj(tls, interp, patObj, v1|v2|int32(TCL_REG_ADVANCED)|int32(TCL_REG_CANMATCH)|int32(TCL_REG_NLANCH)) if regexp == libc.UintptrFromInt32(0) { return int32(TCL_ERROR) } } /* * For exact strings, we want to know where the first newline is, and we * will also use this as a flag to test whether it is even possible to * match the pattern on a single line. If not we will have to search * across multiple lines. */ if (*TSearchSpec)(unsafe.Pointer(searchSpecPtr)).Fexact != 0 { /* * We only need to set the matchLength once for exact searches, and we * do it here. It is also used below as the actual pattern length, so * it has dual purpose. */ pattern = libtcl9_0.XTcl_GetStringFromObj(tls, patObj, bp+8) nl = libc.Xstrchr(tls, pattern, int32('\n')) /* * If there is no newline, or it is the very end of the string, then * we don't need any special treatment, since single-line matching * will work fine. */ if nl != libc.UintptrFromInt32(0) && libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(nl + 1))) != int32('\000') { firstNewLine = int32(int64(nl) - int64(pattern)) } } else { *(*TTcl_Size)(unsafe.Pointer(bp + 8)) = 0 /* Only needed to prevent compiler warnings. */ } /* * Keep a reference here, so that we can be sure the object doesn't * disappear behind our backs and invalidate its contents which we are * using. */ (*TTcl_Obj)(unsafe.Pointer(patObj)).FrefCount++ /* * For building up the current line being checked. */ theLine = libtcl9_0.XTcl_NewObj(tls) (*TTcl_Obj)(unsafe.Pointer(theLine)).FrefCount++ passes = 0 for { if !(passes < int32(2)) { break } *(*int32)(unsafe.Pointer(bp + 336)) = int32(1) extraLinesSearched = 0 if lineNum >= (*TSearchSpec)(unsafe.Pointer(searchSpecPtr)).FnumLines { /* * Don't search the dummy last line of the text. */ goto nextLine } /* * Extract the text from the line, storing its length in 'lastOffset' * (in bytes if exact, chars if regexp), since obviously the length is * the maximum offset at which it is possible to find something on * this line, which is what 'lastOffset' represents. */ lineInfo = (*(*func(*libc.TLS, int32, uintptr, uintptr, uintptr, uintptr) uintptr)(unsafe.Pointer(&struct{ uintptr }{(*TSearchSpec)(unsafe.Pointer(searchSpecPtr)).FaddLineProc})))(tls, lineNum, searchSpecPtr, theLine, bp, bp+336) if lineInfo == libc.UintptrFromInt32(0) { /* * This should not happen, since 'lineNum' should be valid in the * call above. However, let's try to be flexible and not cause a * crash below. */ goto nextLine } if lineNum == (*TSearchSpec)(unsafe.Pointer(searchSpecPtr)).FstopLine && (*TSearchSpec)(unsafe.Pointer(searchSpecPtr)).Fbackwards != 0 { firstOffset = int32((*TSearchSpec)(unsafe.Pointer(searchSpecPtr)).FstopOffset) } else { firstOffset = 0 } if alreadySearchOffset >= 0 { if (*TSearchSpec)(unsafe.Pointer(searchSpecPtr)).Fbackwards != 0 { if alreadySearchOffset < *(*int32)(unsafe.Pointer(bp)) { *(*int32)(unsafe.Pointer(bp)) = alreadySearchOffset } } else { if alreadySearchOffset > firstOffset { firstOffset = alreadySearchOffset } } alreadySearchOffset = -int32(1) } if lineNum == (*TSearchSpec)(unsafe.Pointer(searchSpecPtr)).FstartLine { /* * The starting line is tricky: the first time we see it we check * one part of the line, and the second pass through we check the * other part of the line. */ passes++ if libc.BoolInt32(passes == int32(1))^(*TSearchSpec)(unsafe.Pointer(searchSpecPtr)).Fbackwards != 0 { /* * Forward search and first pass, or backward search and * second pass. * * Only use the last part of the line. */ if (*TSearchSpec)(unsafe.Pointer(searchSpecPtr)).FstartOffset > int64(firstOffset) { firstOffset = int32((*TSearchSpec)(unsafe.Pointer(searchSpecPtr)).FstartOffset) } if firstOffset >= *(*int32)(unsafe.Pointer(bp)) && (*(*int32)(unsafe.Pointer(bp)) != 0 || (*TSearchSpec)(unsafe.Pointer(searchSpecPtr)).Fexact != 0) { goto nextLine } } else { /* * Use only the first part of the line. */ if (*TSearchSpec)(unsafe.Pointer(searchSpecPtr)).FstartOffset < int64(*(*int32)(unsafe.Pointer(bp))) { *(*int32)(unsafe.Pointer(bp)) = int32((*TSearchSpec)(unsafe.Pointer(searchSpecPtr)).FstartOffset) } } } /* * Check for matches within the current line 'lineNum'. If so, and if * we're searching backwards or for all matches, repeat the search * until we find the last match in the line. The 'lastOffset' is one * beyond the last position in the line at which a match is allowed to * begin. */ matchOffset = int64(-libc.Int32FromInt32(1)) if (*TSearchSpec)(unsafe.Pointer(searchSpecPtr)).Fexact != 0 { maxExtraLines = 0 startOfLine = libtcl9_0.XTcl_GetStringFromObj(tls, theLine, libc.UintptrFromInt32(0)) for cond := true; cond; cond = (*TSearchSpec)(unsafe.Pointer(searchSpecPtr)).Fall != 0 { lastFullLine = int64(*(*int32)(unsafe.Pointer(bp))) if firstNewLine == -int32(1) { if (*TSearchSpec)(unsafe.Pointer(searchSpecPtr)).FstrictLimits != 0 && int64(firstOffset)+*(*TTcl_Size)(unsafe.Pointer(bp + 8)) > int64(*(*int32)(unsafe.Pointer(bp))) { /* * Not enough characters to match. */ break } /* * Single line matching. We want to scan forwards or * backwards as appropriate. */ if (*TSearchSpec)(unsafe.Pointer(searchSpecPtr)).Fbackwards != 0 { if *(*TTcl_Size)(unsafe.Pointer(bp + 8)) != 0 { v4 = libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(pattern))) } else { v4 = int32('\000') } /* * Search back either from the previous match or from * 'startOfLine + lastOffset - 1' until we find a * match. */ c = libc.Uint8FromInt32(v4) if alreadySearchOffset >= 0 { p = startOfLine + uintptr(alreadySearchOffset) alreadySearchOffset = -int32(1) } else { p = startOfLine + uintptr(*(*int32)(unsafe.Pointer(bp))) - uintptr(1) } for p >= startOfLine+uintptr(firstOffset) { if *(*TTcl_Size)(unsafe.Pointer(bp + 8)) == 0 || libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(p))) == libc.Int32FromUint8(c) && !(libc.Xstrncmp(tls, p, pattern, libc.Uint64FromInt64(*(*TTcl_Size)(unsafe.Pointer(bp + 8)))) != 0) { goto backwardsMatch } p-- } break } else { p = libc.Xstrstr(tls, startOfLine+uintptr(firstOffset), pattern) } if p == libc.UintptrFromInt32(0) { /* * Single line match failed. */ break } } else { if firstNewLine >= *(*int32)(unsafe.Pointer(bp))-firstOffset { /* * Multi-line match, but not enough characters to match. */ break } else { /* * Multi-line match has only one possible match position, * because we know where the '\n' is. */ p = startOfLine + uintptr(*(*int32)(unsafe.Pointer(bp))) - uintptr(firstNewLine) - uintptr(1) if libc.Xstrncmp(tls, p, pattern, libc.Uint64FromInt32(firstNewLine+int32(1))) != 0 { /* * No match. */ break } else { *(*int32)(unsafe.Pointer(bp + 344)) = int32(1) /* * If we find a match that overlaps more than one * line, we will use this value to determine the first * allowed starting offset for the following search * (to avoid overlapping results). */ *(*int32)(unsafe.Pointer(bp + 348)) = *(*int32)(unsafe.Pointer(bp)) skipFirst = *(*int32)(unsafe.Pointer(bp)) - firstNewLine - int32(1) /* * We may be able to match if given more text. The * following 'while' block handles multi-line exact * searches. */ for int32(1) != 0 { lastFullLine = int64(*(*int32)(unsafe.Pointer(bp + 348))) if lineNum+*(*int32)(unsafe.Pointer(bp + 344)) >= (*TSearchSpec)(unsafe.Pointer(searchSpecPtr)).FnumLines { p = libc.UintptrFromInt32(0) break } /* * Only add the line if we haven't already done so * already. */ if *(*int32)(unsafe.Pointer(bp + 344)) > maxExtraLines { if (*(*func(*libc.TLS, int32, uintptr, uintptr, uintptr, uintptr) uintptr)(unsafe.Pointer(&struct{ uintptr }{(*TSearchSpec)(unsafe.Pointer(searchSpecPtr)).FaddLineProc})))(tls, lineNum+*(*int32)(unsafe.Pointer(bp + 344)), searchSpecPtr, theLine, bp+348, bp+344) == libc.UintptrFromInt32(0) { p = libc.UintptrFromInt32(0) if !((*TSearchSpec)(unsafe.Pointer(searchSpecPtr)).Fbackwards != 0) { extraLinesSearched = *(*int32)(unsafe.Pointer(bp + 344)) } break } maxExtraLines = *(*int32)(unsafe.Pointer(bp + 344)) } startOfLine = libtcl9_0.XTcl_GetStringFromObj(tls, theLine, libc.UintptrFromInt32(0)) p = startOfLine + uintptr(skipFirst) /* * Use the fact that 'matchLength = patLength' for * exact searches. */ if int64(*(*int32)(unsafe.Pointer(bp + 348)))-int64(skipFirst) >= *(*TTcl_Size)(unsafe.Pointer(bp + 8)) { /* * We now have enough text to match, so we * make a final test and break whatever the * result. */ if libc.Xstrncmp(tls, p, pattern, libc.Uint64FromInt64(*(*TTcl_Size)(unsafe.Pointer(bp + 8)))) != 0 { p = libc.UintptrFromInt32(0) } break } else { /* * Not enough text yet, but check the prefix. */ if libc.Xstrncmp(tls, p, pattern, uint64(libc.Uint32FromInt32(*(*int32)(unsafe.Pointer(bp + 348))-skipFirst))) != 0 { p = libc.UintptrFromInt32(0) break } /* * The prefix matches, so keep looking. */ } *(*int32)(unsafe.Pointer(bp + 344))++ } /* * If we reach here, with p != NULL, we've found a * multi-line match, else we started a multi-match but * didn't finish it off, so we go to the next line. */ if p == libc.UintptrFromInt32(0) { break } /* * We've found a multi-line match. */ if *(*int32)(unsafe.Pointer(bp + 344)) > 0 { extraLinesSearched = *(*int32)(unsafe.Pointer(bp + 344)) - int32(1) } } } } goto backwardsMatch backwardsMatch: ; if int64(p)-int64(startOfLine) >= int64(*(*int32)(unsafe.Pointer(bp))) { break } /* * Remember the match. */ matchOffset = int64(p) - int64(startOfLine) if (*TSearchSpec)(unsafe.Pointer(searchSpecPtr)).Fall != 0 && !((*(*func(*libc.TLS, int32, uintptr, uintptr, uintptr, TTcl_Size, TTcl_Size) int32)(unsafe.Pointer(&struct{ uintptr }{(*TSearchSpec)(unsafe.Pointer(searchSpecPtr)).FfoundMatchProc})))(tls, lineNum, searchSpecPtr, lineInfo, theLine, matchOffset, *(*TTcl_Size)(unsafe.Pointer(bp + 8))) != 0) { /* * We reached the end of the search. */ goto searchDone } if !((*TSearchSpec)(unsafe.Pointer(searchSpecPtr)).Foverlap != 0) { if (*TSearchSpec)(unsafe.Pointer(searchSpecPtr)).Fbackwards != 0 { alreadySearchOffset = int32(int64(p) - int64(startOfLine)) if firstNewLine != -int32(1) { break } else { if *(*TTcl_Size)(unsafe.Pointer(bp + 8)) != 0 { v5 = *(*TTcl_Size)(unsafe.Pointer(bp + 8)) } else { v5 = int64(1) } alreadySearchOffset = int32(int64(alreadySearchOffset) - v5) if alreadySearchOffset < 0 { break } } } else { if *(*TTcl_Size)(unsafe.Pointer(bp + 8)) != 0 { v6 = int64(p) - int64(startOfLine) + *(*TTcl_Size)(unsafe.Pointer(bp + 8)) } else { v6 = int64(p) - int64(startOfLine) + libc.Int64FromInt32(1) } firstOffset = int32(v6) if firstOffset >= *(*int32)(unsafe.Pointer(bp)) { /* * Now, we have to be careful not to find * overlapping matches either on the same or * following lines. Assume that if we did find * something, it goes until the last extra line we * added. * * We can break out of the loop, since we know no * more will be found. */ if !((*TSearchSpec)(unsafe.Pointer(searchSpecPtr)).Fbackwards != 0) { alreadySearchOffset = int32(int64(firstOffset) - lastFullLine) break } } } } else { if (*TSearchSpec)(unsafe.Pointer(searchSpecPtr)).Fbackwards != 0 { alreadySearchOffset = int32(int64(p) - int64(startOfLine) - int64(1)) if alreadySearchOffset < 0 { break } } else { firstOffset = int32(int64(p) - int64(startOfLine) + libtcl9_0.XTcl_UtfToUniChar(tls, startOfLine+uintptr(matchOffset), bp+340)) } } } } else { maxExtraLines1 = 0 matches = 0 lastNonOverlap = -int32(1) for cond := true; cond; cond = (*TSearchSpec)(unsafe.Pointer(searchSpecPtr)).Fbackwards != 0 || (*TSearchSpec)(unsafe.Pointer(searchSpecPtr)).Fall != 0 { lastFullLine1 = int64(*(*int32)(unsafe.Pointer(bp))) if firstOffset > 0 { v7 = int32(TCL_REG_NOTBOL) } else { v7 = 0 } match = libtcl9_0.XTcl_RegExpExecObj(tls, interp, regexp, theLine, int64(firstOffset), int64(1), v7) if match < 0 { code = int32(TCL_ERROR) goto searchDone } libtcl9_0.XTcl_RegExpGetInfo(tls, regexp, bp+352) /* * If we don't have a match, or if we do, but it extends to * the end of the line, we must try to add more lines to get a * full greedy match. */ if !(!(match != 0) || (*(*TTcl_RegExpInfo)(unsafe.Pointer(bp + 352))).FextendStart == (*(*TTcl_RegExpIndices)(unsafe.Pointer((*(*TTcl_RegExpInfo)(unsafe.Pointer(bp + 352))).Fmatches))).Fstart && (*(*TTcl_RegExpIndices)(unsafe.Pointer((*(*TTcl_RegExpInfo)(unsafe.Pointer(bp + 352))).Fmatches))).Fend == int64(*(*int32)(unsafe.Pointer(bp))-firstOffset)) { goto _8 } *(*int32)(unsafe.Pointer(bp + 376)) = 0 /* * If we find a match that overlaps more than one line, we * will use this value to determine the first allowed * starting offset for the following search (to avoid * overlapping results). */ *(*int32)(unsafe.Pointer(bp + 380)) = *(*int32)(unsafe.Pointer(bp)) if lastBackwardsLineMatch != -int32(1) && lastBackwardsLineMatch == lineNum+int32(1) { lastNonOverlap = *(*int32)(unsafe.Pointer(bp + 380)) } if (*(*TTcl_RegExpInfo)(unsafe.Pointer(bp + 352))).FextendStart < 0 { /* * No multi-line match is possible. */ break } /* * We may be able to match if given more text. The * following 'while' block handles multi-line regexp * searches. */ for int32(1) != 0 { prevFullLine = int64(*(*int32)(unsafe.Pointer(bp + 380))) /* * Move firstOffset to first possible start. */ if !(match != 0) { firstOffset = int32(int64(firstOffset) + (*(*TTcl_RegExpInfo)(unsafe.Pointer(bp + 352))).FextendStart) } if firstOffset >= *(*int32)(unsafe.Pointer(bp)) { /* * We're being told that the only possible new * match is starting after the end of the line. * But, that is the next line which we will handle * when we look at that line. */ if !(match != 0) && !((*TSearchSpec)(unsafe.Pointer(searchSpecPtr)).Fbackwards != 0) && firstOffset == 0 { extraLinesSearched = *(*int32)(unsafe.Pointer(bp + 376)) } break } if lineNum+*(*int32)(unsafe.Pointer(bp + 376)) >= (*TSearchSpec)(unsafe.Pointer(searchSpecPtr)).FnumLines { break } /* * Add next line, provided we haven't already done so. */ if *(*int32)(unsafe.Pointer(bp + 376)) > maxExtraLines1 { if (*(*func(*libc.TLS, int32, uintptr, uintptr, uintptr, uintptr) uintptr)(unsafe.Pointer(&struct{ uintptr }{(*TSearchSpec)(unsafe.Pointer(searchSpecPtr)).FaddLineProc})))(tls, lineNum+*(*int32)(unsafe.Pointer(bp + 376)), searchSpecPtr, theLine, bp+380, bp+376) == libc.UintptrFromInt32(0) { /* * There are no more acceptable lines, so we * can say we have searched all of these. */ if !(match != 0) && !((*TSearchSpec)(unsafe.Pointer(searchSpecPtr)).Fbackwards != 0) { extraLinesSearched = *(*int32)(unsafe.Pointer(bp + 376)) } break } maxExtraLines1 = *(*int32)(unsafe.Pointer(bp + 376)) if lastBackwardsLineMatch != -int32(1) && lastBackwardsLineMatch == lineNum+*(*int32)(unsafe.Pointer(bp + 376))+int32(1) { lastNonOverlap = *(*int32)(unsafe.Pointer(bp + 380)) } } if firstOffset > 0 { v10 = int32(TCL_REG_NOTBOL) } else { v10 = 0 } match = libtcl9_0.XTcl_RegExpExecObj(tls, interp, regexp, theLine, int64(firstOffset), int64(1), v10) if match < 0 { code = int32(TCL_ERROR) goto searchDone } libtcl9_0.XTcl_RegExpGetInfo(tls, regexp, bp+352) /* * Unfortunately there are bugs in Tcl's regexp * library, which tells us that info.extendStart is * zero when it should not be (should be -1), which * makes our task a bit more complicated here. We * check if there was a match, and the end of the * match leaves an entire extra line unmatched, then * we stop searching. Clearly it still might sometimes * be possible to add more text and match again, but * Tcl's regexp library doesn't tell us that. * * This means we often add and search one more line * than might be necessary if Tcl were able to give us * a correct value of info.extendStart under all * circumstances. */ if match != 0 && int64(firstOffset)+(*(*TTcl_RegExpIndices)(unsafe.Pointer((*(*TTcl_RegExpInfo)(unsafe.Pointer(bp + 352))).Fmatches))).Fend != int64(*(*int32)(unsafe.Pointer(bp + 380))) && int64(firstOffset)+(*(*TTcl_RegExpIndices)(unsafe.Pointer((*(*TTcl_RegExpInfo)(unsafe.Pointer(bp + 352))).Fmatches))).Fend < prevFullLine || (*(*TTcl_RegExpInfo)(unsafe.Pointer(bp + 352))).FextendStart < 0 { break } /* * If there is a match, but that match starts after * the end of the first line, then we'll handle that * next time around, when we're actually looking at * that line. */ if match != 0 && (*(*TTcl_RegExpIndices)(unsafe.Pointer((*(*TTcl_RegExpInfo)(unsafe.Pointer(bp + 352))).Fmatches))).Fstart >= int64(*(*int32)(unsafe.Pointer(bp))) { break } if match != 0 && int64(firstOffset)+(*(*TTcl_RegExpIndices)(unsafe.Pointer((*(*TTcl_RegExpInfo)(unsafe.Pointer(bp + 352))).Fmatches))).Fend >= prevFullLine { if *(*int32)(unsafe.Pointer(bp + 376)) > 0 { extraLinesSearched = *(*int32)(unsafe.Pointer(bp + 376)) - int32(1) } lastFullLine1 = prevFullLine } /* * The prefix matches, so keep looking. */ *(*int32)(unsafe.Pointer(bp + 376))++ } /* * If we reach here with 'match == 1', we've found a * multi-line match, which we will record in the code * which follows directly else we started a multi-line * match but didn't finish it off, so we go to the next * line. */ if !(match != 0) { /* * Here is where we could perform an optimisation, * since we have already retrieved the contents of the * next line (perhaps many more), so we shouldn't * really throw it all away and start again. This * could be particularly important for complex regexp * searches. * * This 'break' will take us to just before the * 'nextLine:' below. */ break } if lastBackwardsLineMatch != -int32(1) { if lineNum+*(*int32)(unsafe.Pointer(bp + 336))+extraLinesSearched == lastBackwardsLineMatch { /* * Possible overlap or inclusion. */ thisOffset = int32(int64(firstOffset) + (*(*TTcl_RegExpIndices)(unsafe.Pointer((*(*TTcl_RegExpInfo)(unsafe.Pointer(bp + 352))).Fmatches))).Fend - (*(*TTcl_RegExpIndices)(unsafe.Pointer((*(*TTcl_RegExpInfo)(unsafe.Pointer(bp + 352))).Fmatches))).Fstart) if lastNonOverlap != -int32(1) { /* * Possible overlap or enclosure. */ if int64(thisOffset)-int64(lastNonOverlap) >= int64(lastBackwardsMatchOffset)+*(*TTcl_Size)(unsafe.Pointer(bp + 8))+int64(1) { /* * Totally encloses previous match, so * forget the previous match. */ lastBackwardsLineMatch = -int32(1) } else { if thisOffset-lastNonOverlap > lastBackwardsMatchOffset { /* * Overlap. Previous match is ok, and the * current match is only ok if we are * searching with -overlap. */ if (*TSearchSpec)(unsafe.Pointer(searchSpecPtr)).Foverlap != 0 { goto recordBackwardsMatch } else { match = 0 break } } else { /* * No overlap, although the same line was * reached. */ goto recordBackwardsMatch } } } else { /* * No overlap. */ goto recordBackwardsMatch } } else { if lineNum+*(*int32)(unsafe.Pointer(bp + 336))+extraLinesSearched < lastBackwardsLineMatch { /* * No overlap. */ goto recordBackwardsMatch } else { /* * Totally enclosed. */ lastBackwardsLineMatch = -int32(1) } } } goto _9 _8: ; /* * Matched in a single line. */ if !(lastBackwardsLineMatch != -int32(1)) { goto _11 } goto recordBackwardsMatch recordBackwardsMatch: ; (*(*func(*libc.TLS, int32, uintptr, uintptr, uintptr, TTcl_Size, TTcl_Size) int32)(unsafe.Pointer(&struct{ uintptr }{(*TSearchSpec)(unsafe.Pointer(searchSpecPtr)).FfoundMatchProc})))(tls, lastBackwardsLineMatch, searchSpecPtr, libc.UintptrFromInt32(0), libc.UintptrFromInt32(0), int64(lastBackwardsMatchOffset), *(*TTcl_Size)(unsafe.Pointer(bp + 8))) lastBackwardsLineMatch = -int32(1) if !((*TSearchSpec)(unsafe.Pointer(searchSpecPtr)).Fall != 0) { goto searchDone } _11: ; _9: ; firstOffset = int32(int64(firstOffset) + (*(*TTcl_RegExpIndices)(unsafe.Pointer((*(*TTcl_RegExpInfo)(unsafe.Pointer(bp + 352))).Fmatches))).Fstart) if firstOffset >= *(*int32)(unsafe.Pointer(bp)) { break } /* * Update our local variables with the match, if we haven't * yet found anything, or if we're doing '-all' or * '-backwards' _and_ this match isn't fully enclosed in the * previous match. */ if matchOffset == int64(-int32(1)) || ((*TSearchSpec)(unsafe.Pointer(searchSpecPtr)).Fall != 0 || (*TSearchSpec)(unsafe.Pointer(searchSpecPtr)).Fbackwards != 0) && (int64(firstOffset) < matchOffset || int64(firstOffset)+(*(*TTcl_RegExpIndices)(unsafe.Pointer((*(*TTcl_RegExpInfo)(unsafe.Pointer(bp + 352))).Fmatches))).Fend-(*(*TTcl_RegExpIndices)(unsafe.Pointer((*(*TTcl_RegExpInfo)(unsafe.Pointer(bp + 352))).Fmatches))).Fstart > matchOffset+*(*TTcl_Size)(unsafe.Pointer(bp + 8))) { matchOffset = int64(firstOffset) *(*TTcl_Size)(unsafe.Pointer(bp + 8)) = (*(*TTcl_RegExpIndices)(unsafe.Pointer((*(*TTcl_RegExpInfo)(unsafe.Pointer(bp + 352))).Fmatches))).Fend - (*(*TTcl_RegExpIndices)(unsafe.Pointer((*(*TTcl_RegExpInfo)(unsafe.Pointer(bp + 352))).Fmatches))).Fstart if (*TSearchSpec)(unsafe.Pointer(searchSpecPtr)).Fbackwards != 0 { /* * To get backwards searches in the correct order, we * must store them away here. */ if matches == matchNum { /* * We've run out of space in our normal store, so * we must allocate space for these backwards * matches on the heap. */ newArray = libtcl9_0.XTcl_Alloc(tls, libc.Uint64FromInt32(int32(4)*matchNum)*uint64(8)) libc.Xmemcpy(tls, newArray, storeMatch, libc.Uint64FromInt32(matchNum)*uint64(8)) libc.Xmemcpy(tls, newArray+uintptr(int32(2)*matchNum)*8, storeLength, libc.Uint64FromInt32(matchNum)*uint64(8)) if storeMatch != bp+16 { libtcl9_0.XTcl_Free(tls, storeMatch) } matchNum *= int32(2) storeMatch = newArray storeLength = newArray + uintptr(matchNum)*8 } *(*TTcl_Size)(unsafe.Pointer(storeMatch + uintptr(matches)*8)) = matchOffset *(*TTcl_Size)(unsafe.Pointer(storeLength + uintptr(matches)*8)) = *(*TTcl_Size)(unsafe.Pointer(bp + 8)) matches++ } else { /* * Now actually record the match, but only if we are * doing an '-all' search. */ if (*TSearchSpec)(unsafe.Pointer(searchSpecPtr)).Fall != 0 && !((*(*func(*libc.TLS, int32, uintptr, uintptr, uintptr, TTcl_Size, TTcl_Size) int32)(unsafe.Pointer(&struct{ uintptr }{(*TSearchSpec)(unsafe.Pointer(searchSpecPtr)).FfoundMatchProc})))(tls, lineNum, searchSpecPtr, lineInfo, theLine, matchOffset, *(*TTcl_Size)(unsafe.Pointer(bp + 8))) != 0) { /* * We reached the end of the search. */ goto searchDone } } /* * For forward matches, unless we allow overlaps, we move * this on by the length of the current match so that we * explicitly disallow overlapping matches. */ if *(*TTcl_Size)(unsafe.Pointer(bp + 8)) > 0 && !((*TSearchSpec)(unsafe.Pointer(searchSpecPtr)).Foverlap != 0) && !((*TSearchSpec)(unsafe.Pointer(searchSpecPtr)).Fbackwards != 0) { firstOffset = int32(int64(firstOffset) + *(*TTcl_Size)(unsafe.Pointer(bp + 8))) if firstOffset >= *(*int32)(unsafe.Pointer(bp)) { /* * Now, we have to be careful not to find * overlapping matches either on the same or * following lines. Assume that if we did find * something, it goes until the last extra line we * added. * * We can break out of the loop, since we know no * more will be found. */ alreadySearchOffset = int32(int64(firstOffset) - lastFullLine1) break } /* * We'll add this on again just below. */ firstOffset-- } } /* * Move the starting point on, in case we are doing repeated * or backwards searches (for the latter, we actually do * repeated forward searches). */ firstOffset++ } if matches > 0 { /* * Now we have all the matches in our array, but not stored * with 'foundMatchProc' yet. */ matches-- matchOffset = *(*TTcl_Size)(unsafe.Pointer(storeMatch + uintptr(matches)*8)) *(*TTcl_Size)(unsafe.Pointer(bp + 8)) = *(*TTcl_Size)(unsafe.Pointer(storeLength + uintptr(matches)*8)) for { matches-- v12 = matches if !(v12 >= 0) { break } if lineNum == (*TSearchSpec)(unsafe.Pointer(searchSpecPtr)).FstopLine { /* * It appears as if a condition like: * * if (storeMatch[matches]stopOffset) * break; * * might be needed here, but no test case has been * found which would exercise such a problem. */ } if *(*TTcl_Size)(unsafe.Pointer(storeMatch + uintptr(matches)*8))+*(*TTcl_Size)(unsafe.Pointer(storeLength + uintptr(matches)*8)) >= matchOffset+*(*TTcl_Size)(unsafe.Pointer(bp + 8)) { /* * The new match totally encloses the previous one, so * we overwrite the previous one. */ matchOffset = *(*TTcl_Size)(unsafe.Pointer(storeMatch + uintptr(matches)*8)) *(*TTcl_Size)(unsafe.Pointer(bp + 8)) = *(*TTcl_Size)(unsafe.Pointer(storeLength + uintptr(matches)*8)) continue } if !((*TSearchSpec)(unsafe.Pointer(searchSpecPtr)).Foverlap != 0) { if *(*TTcl_Size)(unsafe.Pointer(storeMatch + uintptr(matches)*8))+*(*TTcl_Size)(unsafe.Pointer(storeLength + uintptr(matches)*8)) > matchOffset { continue } } (*(*func(*libc.TLS, int32, uintptr, uintptr, uintptr, TTcl_Size, TTcl_Size) int32)(unsafe.Pointer(&struct{ uintptr }{(*TSearchSpec)(unsafe.Pointer(searchSpecPtr)).FfoundMatchProc})))(tls, lineNum, searchSpecPtr, lineInfo, theLine, matchOffset, *(*TTcl_Size)(unsafe.Pointer(bp + 8))) if !((*TSearchSpec)(unsafe.Pointer(searchSpecPtr)).Fall != 0) { goto searchDone } matchOffset = *(*TTcl_Size)(unsafe.Pointer(storeMatch + uintptr(matches)*8)) *(*TTcl_Size)(unsafe.Pointer(bp + 8)) = *(*TTcl_Size)(unsafe.Pointer(storeLength + uintptr(matches)*8)) } if (*TSearchSpec)(unsafe.Pointer(searchSpecPtr)).Fall != 0 && matches > 0 { /* * We only need to do this for the '-all' case, because * just below we will call the foundMatchProc for the * non-all case. */ (*(*func(*libc.TLS, int32, uintptr, uintptr, uintptr, TTcl_Size, TTcl_Size) int32)(unsafe.Pointer(&struct{ uintptr }{(*TSearchSpec)(unsafe.Pointer(searchSpecPtr)).FfoundMatchProc})))(tls, lineNum, searchSpecPtr, lineInfo, theLine, matchOffset, *(*TTcl_Size)(unsafe.Pointer(bp + 8))) } else { lastBackwardsLineMatch = lineNum lastBackwardsMatchOffset = int32(matchOffset) } } } /* * If the 'all' flag is set, we will already have stored all matches, * so we just proceed to the next line. * * If not, and there is a match we need to store that information and * we are done. */ if lastBackwardsLineMatch == -int32(1) && matchOffset != int64(-libc.Int32FromInt32(1)) && !((*TSearchSpec)(unsafe.Pointer(searchSpecPtr)).Fall != 0) { (*(*func(*libc.TLS, int32, uintptr, uintptr, uintptr, TTcl_Size, TTcl_Size) int32)(unsafe.Pointer(&struct{ uintptr }{(*TSearchSpec)(unsafe.Pointer(searchSpecPtr)).FfoundMatchProc})))(tls, lineNum, searchSpecPtr, lineInfo, theLine, matchOffset, *(*TTcl_Size)(unsafe.Pointer(bp + 8))) goto searchDone } /* * Go to the next (or previous) line; */ goto nextLine nextLine: ; *(*int32)(unsafe.Pointer(bp + 336)) += extraLinesSearched for { v13 = *(*int32)(unsafe.Pointer(bp + 336)) *(*int32)(unsafe.Pointer(bp + 336))-- if !(v13 > 0) { break } /* * If we have just completed the 'stopLine', we are done. */ if lineNum == (*TSearchSpec)(unsafe.Pointer(searchSpecPtr)).FstopLine { goto searchDone } if (*TSearchSpec)(unsafe.Pointer(searchSpecPtr)).Fbackwards != 0 { lineNum-- if lastBackwardsLineMatch != -int32(1) && (lineNum < 0 || lineNum+int32(2) < lastBackwardsLineMatch) { (*(*func(*libc.TLS, int32, uintptr, uintptr, uintptr, TTcl_Size, TTcl_Size) int32)(unsafe.Pointer(&struct{ uintptr }{(*TSearchSpec)(unsafe.Pointer(searchSpecPtr)).FfoundMatchProc})))(tls, lastBackwardsLineMatch, searchSpecPtr, libc.UintptrFromInt32(0), libc.UintptrFromInt32(0), int64(lastBackwardsMatchOffset), *(*TTcl_Size)(unsafe.Pointer(bp + 8))) lastBackwardsLineMatch = -int32(1) if !((*TSearchSpec)(unsafe.Pointer(searchSpecPtr)).Fall != 0) { goto searchDone } } if lineNum < 0 { lineNum = (*TSearchSpec)(unsafe.Pointer(searchSpecPtr)).FnumLines - int32(1) } if !((*TSearchSpec)(unsafe.Pointer(searchSpecPtr)).Fexact != 0) { /* * The 'exact' search loops above are designed to give us * an accurate picture of the number of lines which we can * skip here. For 'regexp' searches, on the other hand, * which can match potentially variable lengths, we cannot * skip multiple lines when searching backwards. Therefore * we only allow one line to be skipped here. */ break } } else { lineNum++ if lineNum >= (*TSearchSpec)(unsafe.Pointer(searchSpecPtr)).FnumLines { lineNum = 0 } } if lineNum == (*TSearchSpec)(unsafe.Pointer(searchSpecPtr)).FstartLine && *(*int32)(unsafe.Pointer(bp + 336)) > 0 { /* * We've just searched all the way round and have gone right * through the start line without finding anything in the last * attempt. */ break } } libtcl9_0.XTcl_SetObjLength(tls, theLine, 0) goto _3 _3: } goto searchDone searchDone: ; if lastBackwardsLineMatch != -int32(1) { (*(*func(*libc.TLS, int32, uintptr, uintptr, uintptr, TTcl_Size, TTcl_Size) int32)(unsafe.Pointer(&struct{ uintptr }{(*TSearchSpec)(unsafe.Pointer(searchSpecPtr)).FfoundMatchProc})))(tls, lastBackwardsLineMatch, searchSpecPtr, libc.UintptrFromInt32(0), libc.UintptrFromInt32(0), int64(lastBackwardsMatchOffset), *(*TTcl_Size)(unsafe.Pointer(bp + 8))) } /* * Free up the cached line and pattern. */ _objPtr = theLine v15 = _objPtr v14 = *(*TTcl_Size)(unsafe.Pointer(v15)) *(*TTcl_Size)(unsafe.Pointer(v15))-- if v14 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr) } _objPtr1 = patObj v17 = _objPtr1 v16 = *(*TTcl_Size)(unsafe.Pointer(v17)) *(*TTcl_Size)(unsafe.Pointer(v17))-- if v16 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr1) } /* * Free up any extra space we allocated. */ if storeMatch != bp+16 { libtcl9_0.XTcl_Free(tls, storeMatch) } return code } /* *---------------------------------------------------------------------- * * GetLineStartEnd - * * Converts an internal TkTextLine ptr into a Tcl string obj containing * the line number. (Handler for the 'line' configuration option type.) * * Results: * Tcl_Obj containing the string representation of the line value. * * Side effects: * Creates a new Tcl_Obj. * *---------------------------------------------------------------------- */ func _GetLineStartEnd(tls *libc.TLS, dummy6799 uintptr, dummy6800 TTk_Window, recordPtr uintptr, internalOffset TTcl_Size) (r uintptr) { /* Offset within *recordPtr containing the * line value. */ var linePtr uintptr _ = linePtr linePtr = *(*uintptr)(unsafe.Pointer(recordPtr + uintptr(internalOffset))) if linePtr == libc.UintptrFromInt32(0) { return libtcl9_0.XTcl_NewObj(tls) } return libtcl9_0.XTcl_NewWideIntObj(tls, int64(int32(1)+XTkBTreeLinesTo(tls, libc.UintptrFromInt32(0), linePtr))) } /* *---------------------------------------------------------------------- * * SetLineStartEnd -- * * Converts a Tcl_Obj representing a widget's (start or end) line into a * TkTextLine* value. (Handler for the 'line' configuration option type.) * * Results: * Standard Tcl result. * * Side effects: * May store the TkTextLine* value into the internal representation * pointer. May change the pointer to the Tcl_Obj to NULL to indicate * that the specified string was empty and that is acceptable. * *---------------------------------------------------------------------- */ func _SetLineStartEnd(tls *libc.TLS, dummy6834 uintptr, interp uintptr, dummy6836 TTk_Window, value uintptr, recordPtr uintptr, internalOffset TTcl_Size, oldInternalPtr uintptr, flags int32) (r int32) { bp := tls.Alloc(16) defer tls.Free(16) /* Flags for the option, set Tk_SetOptions. */ var internalPtr, linePtr, textPtr uintptr var _ /* line at bp+0 */ int32 _, _, _ = internalPtr, linePtr, textPtr linePtr = libc.UintptrFromInt32(0) textPtr = recordPtr if internalOffset != int64(-libc.Int32FromInt32(1)) { internalPtr = recordPtr + uintptr(internalOffset) } else { internalPtr = libc.UintptrFromInt32(0) } if flags&int32(TCL_NULL_OK) != 0 && _ObjectIsEmpty2(tls, *(*uintptr)(unsafe.Pointer(value))) != 0 { *(*uintptr)(unsafe.Pointer(value)) = libc.UintptrFromInt32(0) } else { if libtcl9_0.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(value)), bp) != TCL_OK { return int32(TCL_ERROR) } linePtr = XTkBTreeFindLine(tls, (*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).Ftree, libc.UintptrFromInt32(0), *(*int32)(unsafe.Pointer(bp))-int32(1)) } if internalPtr != libc.UintptrFromInt32(0) { *(*uintptr)(unsafe.Pointer(oldInternalPtr)) = *(*uintptr)(unsafe.Pointer(internalPtr)) *(*uintptr)(unsafe.Pointer(internalPtr)) = linePtr } return TCL_OK } /* *---------------------------------------------------------------------- * * RestoreLineStartEnd -- * * Restore a line option value from a saved value. (Handler for the * 'line' configuration option type.) * * Results: * None. * * Side effects: * Restores the old value. * *---------------------------------------------------------------------- */ func _RestoreLineStartEnd(tls *libc.TLS, dummy6893 uintptr, dummy6894 TTk_Window, internalPtr uintptr, oldInternalPtr uintptr) { /* Pointer to old value. */ *(*uintptr)(unsafe.Pointer(internalPtr)) = *(*uintptr)(unsafe.Pointer(oldInternalPtr)) } /* *---------------------------------------------------------------------- * * ObjectIsEmpty -- * * This function tests whether the string value of an object is empty. * * Results: * The return value is 1 if the string value of objPtr has length zero, * and 0 otherwise. * * Side effects: * May cause object shimmering, since this function can force a * conversion to a string object. * *---------------------------------------------------------------------- */ func _ObjectIsEmpty2(tls *libc.TLS, objPtr uintptr) (r int32) { /* Object to test. May be NULL. */ if objPtr == libc.UintptrFromInt32(0) { return int32(1) } if (*TTcl_Obj)(unsafe.Pointer(objPtr)).Fbytes == libc.UintptrFromInt32(0) { libtcl9_0.XTcl_GetStringFromObj(tls, objPtr, libc.UintptrFromInt32(0)) } return libc.BoolInt32((*TTcl_Obj)(unsafe.Pointer(objPtr)).Flength == 0) } /* *---------------------------------------------------------------------- * * TkpTesttextCmd -- * * This function implements the "testtext" command. It provides a set of * functions for testing text widgets and the associated functions in * tkText*.c. * * Results: * A standard Tcl result. * * Side effects: * Depends on option; see below. * *---------------------------------------------------------------------- */ func XTkpTesttextCmd(tls *libc.TLS, dummy6952 uintptr, interp uintptr, objc TTcl_Size, objv uintptr) (r int32) { bp := tls.Alloc(192) defer tls.Free(192) /* Argument strings. */ var len1 TTcl_Size var textPtr uintptr var _ /* buf at bp+56 */ [30]uint8 var _ /* byteIndex at bp+8 */ TTcl_WideInt var _ /* byteOffset at bp+16 */ TTcl_WideInt var _ /* index at bp+24 */ TTkTextIndex var _ /* info at bp+88 */ TTcl_CmdInfo var _ /* lineIndex at bp+0 */ TTcl_WideInt _, _ = len1, textPtr if objc < int64(3) { return int32(TCL_ERROR) } if libtcl9_0.XTcl_GetCommandInfo(tls, interp, libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8)), libc.UintptrFromInt32(0)), bp+88) == 0 { return int32(TCL_ERROR) } textPtr = (*(*TTcl_CmdInfo)(unsafe.Pointer(bp + 88))).FobjClientData len1 = libc.Int64FromUint64(libc.Xstrlen(tls, libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8)), libc.UintptrFromInt32(0)))) if libc.Xstrncmp(tls, libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8)), libc.UintptrFromInt32(0)), __ccgo_ts+44630, libc.Uint64FromInt64(len1)) == 0 { if objc != int64(5) { return int32(TCL_ERROR) } if libtcl9_0.XTcl_GetWideIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 3*8)), bp) != 0 { return int32(TCL_ERROR) } *(*TTcl_WideInt)(unsafe.Pointer(bp))-- if libtcl9_0.XTcl_GetWideIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 4*8)), bp+8) != 0 { return int32(TCL_ERROR) } XTkTextMakeByteIndex(tls, (*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).Ftree, textPtr, int32(*(*TTcl_WideInt)(unsafe.Pointer(bp))), *(*TTcl_WideInt)(unsafe.Pointer(bp + 8)), bp+24) } else { if libc.Xstrncmp(tls, libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8)), libc.UintptrFromInt32(0)), __ccgo_ts+44640, libc.Uint64FromInt64(len1)) == 0 { if objc != int64(5) { return int32(TCL_ERROR) } if XTkTextGetIndex(tls, interp, textPtr, libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 3*8)), libc.UintptrFromInt32(0)), bp+24) != TCL_OK { return int32(TCL_ERROR) } if libtcl9_0.XTcl_GetWideIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 4*8)), bp+16) != 0 { return int32(TCL_ERROR) } XTkTextIndexForwBytes(tls, textPtr, bp+24, *(*TTcl_WideInt)(unsafe.Pointer(bp + 16)), bp+24) } else { if libc.Xstrncmp(tls, libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8)), libc.UintptrFromInt32(0)), __ccgo_ts+44650, libc.Uint64FromInt64(len1)) == 0 { if objc != int64(5) { return int32(TCL_ERROR) } if XTkTextGetIndex(tls, interp, textPtr, libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 3*8)), libc.UintptrFromInt32(0)), bp+24) != TCL_OK { return int32(TCL_ERROR) } if libtcl9_0.XTcl_GetWideIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 4*8)), bp+16) != 0 { return int32(TCL_ERROR) } XTkTextIndexBackBytes(tls, textPtr, bp+24, *(*TTcl_WideInt)(unsafe.Pointer(bp + 16)), bp+24) } else { return int32(TCL_ERROR) } } } XTkTextSetMark(tls, textPtr, __ccgo_ts+22158, bp+24) XTkTextPrintIndex(tls, textPtr, bp+24, bp+56) libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+44660, libc.VaList(bp+176, bp+56, (*(*TTkTextIndex)(unsafe.Pointer(bp + 24))).FbyteIndex))) return TCL_OK } type TTkTextTag1 = struct { Fname uintptr FtextPtr uintptr Fpriority TTcl_Size FtagRootPtr uintptr FtoggleCount TTcl_Size Fborder TTk_3DBorder FborderWidthObj uintptr Frelief int32 FbgStipple TPixmap FfgColor uintptr Ftkfont TTk_Font FfgStipple TPixmap Fjustify TTk_Justify FlMargin1Obj uintptr FlMargin1 int32 FlMargin2Obj uintptr FlMargin2 int32 FlMarginColor TTk_3DBorder FoffsetObj uintptr Foffset int32 Foverstrike int32 FoverstrikeColor uintptr FrMarginObj uintptr FrMargin int32 FrMarginColor TTk_3DBorder FselBorder TTk_3DBorder FselFgColor uintptr Fspacing1Obj uintptr Fspacing2Obj uintptr Fspacing3Obj uintptr FtabStringPtr uintptr FtabArrayPtr uintptr FtabStyle TTkTextTabStyle Funderline int32 FunderlineColor uintptr FwrapMode TTkWrapMode Felide int32 FaffectsDisplay int32 FoptionTable TTk_OptionTable FaffectsDisplayGeometry int32 } const MAX_CHILDREN = 12 const MIN_CHILDREN = 6 const NUM_TAG_INFOS = 10 const TEXT_ADD_REFS = 1 const TEXT_REMOVE_REFS = 2 /* * Local Variables: * mode: c * c-basic-offset: 4 * fill-column: 78 * End: */ /* * Implementation notes: * * Most of this file is independent of the text widget implementation and * representation now. Without much effort this could be developed further * into a new Tcl object type of which the Tk text widget is one example of a * client. * * The B-tree is set up with a dummy last line of text which must not be * displayed, and must _never_ have a non-zero pixel count. This dummy line is * a historical convenience to avoid other code having to deal with NULL * TkTextLines. Since Tk 8.5, with pixel line height calculations and peer * widgets, this dummy line is becoming somewhat of a liability, and special * case code has been required to deal with it. It is probably a good idea to * investigate removing the dummy line completely. This could result in an * overall simplification (although it would require new special case code to * deal with the fact that '.text index end' would then not really point to a * valid line, rather it would point to the beginning of a non-existent line * one beyond all current lines - we could perhaps define that as a * TkTextIndex with a NULL TkTextLine ptr). */ /* * The data structure below keeps summary information about one tag as part of * the tag information in a node. */ type TSummary = struct { FtagPtr uintptr FtoggleCount TTcl_Size FnextPtr uintptr } /* * The data structure below defines a node in the B-tree. */ type TNode = struct { FparentPtr uintptr FnextPtr uintptr FsummaryPtr uintptr Flevel TTcl_Size Fchildren struct { FlinePtr [0]uintptr FnodePtr uintptr } FnumChildren int32 FnumLines int32 FnumPixels uintptr } /* * Used to avoid having to allocate and deallocate arrays on the fly for * commonly used functions. Must be > 0. */ /* * Upper and lower bounds on how many children a node may have: rebalance when * either of these limits is exceeded. MAX_CHILDREN should be twice * MIN_CHILDREN and MIN_CHILDREN must be >= 2. */ /* * The data structure below defines an entire B-tree. Since text widgets are * the only current B-tree clients, 'clients' and 'pixelReferences' are * identical. */ type TBTree = struct { FrootPtr uintptr Fclients int32 FpixelReferences int32 FstateEpoch TTcl_Size FsharedTextPtr uintptr FstartEndCount int32 FstartEnd uintptr FstartEndRef uintptr } /* * The structure below is used to pass information between * TkBTreeGetTags and IncCount: */ type TTagInfo = struct { FnumTags int32 FarraySize int32 FtagPtrs uintptr Fcounts uintptr } func init() { p := unsafe.Pointer(&XtkTextCharType) *(*uintptr)(unsafe.Add(p, 16)) = __ccgo_fp(_CharSplitProc) *(*uintptr)(unsafe.Add(p, 24)) = __ccgo_fp(_CharDeleteProc) *(*uintptr)(unsafe.Add(p, 32)) = __ccgo_fp(_CharCleanupProc) *(*uintptr)(unsafe.Add(p, 48)) = __ccgo_fp(XTkTextCharLayoutProc) *(*uintptr)(unsafe.Add(p, 56)) = __ccgo_fp(_CharCheckProc) } func init() { p := unsafe.Pointer(&XtkTextToggleOnType) *(*uintptr)(unsafe.Add(p, 24)) = __ccgo_fp(_ToggleDeleteProc) *(*uintptr)(unsafe.Add(p, 32)) = __ccgo_fp(_ToggleCleanupProc) *(*uintptr)(unsafe.Add(p, 40)) = __ccgo_fp(_ToggleLineChangeProc) *(*uintptr)(unsafe.Add(p, 56)) = __ccgo_fp(_ToggleCheckProc) } func init() { p := unsafe.Pointer(&XtkTextToggleOffType) *(*uintptr)(unsafe.Add(p, 24)) = __ccgo_fp(_ToggleDeleteProc) *(*uintptr)(unsafe.Add(p, 32)) = __ccgo_fp(_ToggleCleanupProc) *(*uintptr)(unsafe.Add(p, 40)) = __ccgo_fp(_ToggleLineChangeProc) *(*uintptr)(unsafe.Add(p, 56)) = __ccgo_fp(_ToggleCheckProc) } /* *---------------------------------------------------------------------- * * TkBTreeCreate -- * * This function is called to create a new text B-tree. * * Results: * The return value is a pointer to a new B-tree containing one line with * nothing but a newline character. * * Side effects: * Memory is allocated and initialized. * *---------------------------------------------------------------------- */ func XTkBTreeCreate(tls *libc.TLS, sharedTextPtr uintptr) (r TTkTextBTree) { var linePtr, linePtr2, rootPtr, segPtr, treePtr uintptr _, _, _, _, _ = linePtr, linePtr2, rootPtr, segPtr, treePtr /* * The tree will initially have two empty lines. The second line isn't * actually part of the tree's contents, but its presence makes several * operations easier. The tree will have one node, which is also the root * of the tree. */ rootPtr = libtcl9_0.XTcl_Alloc(tls, uint64(56)) linePtr = libtcl9_0.XTcl_Alloc(tls, uint64(32)) linePtr2 = libtcl9_0.XTcl_Alloc(tls, uint64(32)) (*TNode)(unsafe.Pointer(rootPtr)).FparentPtr = libc.UintptrFromInt32(0) (*TNode)(unsafe.Pointer(rootPtr)).FnextPtr = libc.UintptrFromInt32(0) (*TNode)(unsafe.Pointer(rootPtr)).FsummaryPtr = libc.UintptrFromInt32(0) (*TNode)(unsafe.Pointer(rootPtr)).Flevel = 0 *(*uintptr)(unsafe.Pointer(rootPtr + 32)) = linePtr (*TNode)(unsafe.Pointer(rootPtr)).FnumChildren = int32(2) (*TNode)(unsafe.Pointer(rootPtr)).FnumLines = int32(2) /* * The tree currently has no registered clients, so all pixel count * pointers are simply NULL. */ (*TNode)(unsafe.Pointer(rootPtr)).FnumPixels = libc.UintptrFromInt32(0) (*TTkTextLine)(unsafe.Pointer(linePtr)).Fpixels = libc.UintptrFromInt32(0) (*TTkTextLine)(unsafe.Pointer(linePtr2)).Fpixels = libc.UintptrFromInt32(0) (*TTkTextLine)(unsafe.Pointer(linePtr)).FparentPtr = rootPtr (*TTkTextLine)(unsafe.Pointer(linePtr)).FnextPtr = linePtr2 segPtr = libtcl9_0.XTcl_Alloc(tls, uint64(libc.UintptrFromInt32(0)+24)+libc.Uint64FromInt32(1)+libc.Uint64FromInt32(libc.Int32FromInt32(1))) (*TTkTextLine)(unsafe.Pointer(linePtr)).FsegPtr = segPtr (*TTkTextSegment)(unsafe.Pointer(segPtr)).FtypePtr = uintptr(unsafe.Pointer(&XtkTextCharType)) (*TTkTextSegment)(unsafe.Pointer(segPtr)).FnextPtr = libc.UintptrFromInt32(0) (*TTkTextSegment)(unsafe.Pointer(segPtr)).Fsize = int64(1) *(*uint8)(unsafe.Pointer(segPtr + 24)) = uint8('\n') *(*uint8)(unsafe.Pointer(segPtr + 24 + 1)) = uint8(0) (*TTkTextLine)(unsafe.Pointer(linePtr2)).FparentPtr = rootPtr (*TTkTextLine)(unsafe.Pointer(linePtr2)).FnextPtr = libc.UintptrFromInt32(0) segPtr = libtcl9_0.XTcl_Alloc(tls, uint64(libc.UintptrFromInt32(0)+24)+libc.Uint64FromInt32(1)+libc.Uint64FromInt32(libc.Int32FromInt32(1))) (*TTkTextLine)(unsafe.Pointer(linePtr2)).FsegPtr = segPtr (*TTkTextSegment)(unsafe.Pointer(segPtr)).FtypePtr = uintptr(unsafe.Pointer(&XtkTextCharType)) (*TTkTextSegment)(unsafe.Pointer(segPtr)).FnextPtr = libc.UintptrFromInt32(0) (*TTkTextSegment)(unsafe.Pointer(segPtr)).Fsize = int64(1) *(*uint8)(unsafe.Pointer(segPtr + 24)) = uint8('\n') *(*uint8)(unsafe.Pointer(segPtr + 24 + 1)) = uint8(0) treePtr = libtcl9_0.XTcl_Alloc(tls, uint64(56)) (*TBTree)(unsafe.Pointer(treePtr)).FsharedTextPtr = sharedTextPtr (*TBTree)(unsafe.Pointer(treePtr)).FrootPtr = rootPtr (*TBTree)(unsafe.Pointer(treePtr)).Fclients = 0 (*TBTree)(unsafe.Pointer(treePtr)).FstateEpoch = 0 (*TBTree)(unsafe.Pointer(treePtr)).FpixelReferences = 0 (*TBTree)(unsafe.Pointer(treePtr)).FstartEndCount = 0 (*TBTree)(unsafe.Pointer(treePtr)).FstartEnd = libc.UintptrFromInt32(0) (*TBTree)(unsafe.Pointer(treePtr)).FstartEndRef = libc.UintptrFromInt32(0) return treePtr } /* *---------------------------------------------------------------------- * * TkBTreeAddClient -- * * This function is called to provide a client with access to a given * B-tree. If the client wishes to make use of the B-tree's pixel height * storage, caching and calculation mechanisms, then a non-negative * 'defaultHeight' must be provided. In this case the return value is a * pixel tree reference which must be provided in all of the B-tree API * which refers to or modifies pixel heights: * * TkBTreeAdjustPixelHeight, * TkBTreeFindPixelLine, * TkBTreeNumPixels, * TkBTreePixelsTo, * (and two private functions AdjustPixelClient, RemovePixelClient). * * If this is not provided, then the above functions must never be called * for this client. * * Results: * The return value is the pixelReference used by the B-tree to refer to * pixel counts for the new client. It should be stored by the caller. If * defaultHeight was negative, then the return value will be -1. * * Side effects: * Memory may be allocated and initialized. * *---------------------------------------------------------------------- */ func XTkBTreeAddClient(tls *libc.TLS, tree TTkTextBTree, textPtr uintptr, defaultHeight int32) { bp := tls.Alloc(16) defer tls.Free(16) /* Default line height for the new client, or * -1 if no pixel heights are to be kept. */ var end, treePtr uintptr var useReference, v1 int32 var _ /* counting at bp+0 */ int32 _, _, _, _ = end, treePtr, useReference, v1 treePtr = tree if treePtr == libc.UintptrFromInt32(0) { libtcl9_0.XTcl_Panic(tls, __ccgo_ts+44696, 0) } if (*TTkText)(unsafe.Pointer(textPtr)).Fstart != libc.UintptrFromInt32(0) || (*TTkText)(unsafe.Pointer(textPtr)).Fend != libc.UintptrFromInt32(0) { _AdjustStartEndRefs(tls, treePtr, textPtr, int32(TEXT_ADD_REFS)) } if defaultHeight >= 0 { if (*TTkText)(unsafe.Pointer(textPtr)).Fstart == libc.UintptrFromInt32(0) { v1 = int32(1) } else { v1 = 0 } *(*int32)(unsafe.Pointer(bp)) = v1 useReference = (*TBTree)(unsafe.Pointer(treePtr)).FpixelReferences /* * We must set the 'end' value in AdjustPixelClient so that the last * dummy line in the B-tree doesn't contain a pixel height. */ end = (*TTkText)(unsafe.Pointer(textPtr)).Fend if end == libc.UintptrFromInt32(0) { end = XTkBTreeFindLine(tls, tree, libc.UintptrFromInt32(0), XTkBTreeNumLines(tls, tree, libc.UintptrFromInt32(0))) } _AdjustPixelClient(tls, treePtr, defaultHeight, (*TBTree)(unsafe.Pointer(treePtr)).FrootPtr, (*TTkText)(unsafe.Pointer(textPtr)).Fstart, end, useReference, useReference+int32(1), bp) (*TTkText)(unsafe.Pointer(textPtr)).FpixelReference = useReference (*TBTree)(unsafe.Pointer(treePtr)).FpixelReferences++ } else { (*TTkText)(unsafe.Pointer(textPtr)).FpixelReference = -int32(1) } (*TBTree)(unsafe.Pointer(treePtr)).Fclients++ } /* *---------------------------------------------------------------------- * * TkBTreeClientRangeChanged -- * * Called when the -startline or -endline options of a text widget client * of the B-tree have changed. * * Results: * None. * * Side effects: * Lots of processing of the B-tree is done, with potential for memory to * be allocated and initialized for the pixel heights of the widget. * *---------------------------------------------------------------------- */ func XTkBTreeClientRangeChanged(tls *libc.TLS, textPtr uintptr, defaultHeight int32) { bp := tls.Alloc(16) defer tls.Free(16) /* Default line height for the new client, or * -1 if no pixel heights are to be kept. */ var end, treePtr uintptr var useReference, v1 int32 var _ /* counting at bp+0 */ int32 _, _, _, _ = end, treePtr, useReference, v1 treePtr = (*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).Ftree if (*TTkText)(unsafe.Pointer(textPtr)).Fstart == libc.UintptrFromInt32(0) { v1 = int32(1) } else { v1 = 0 } *(*int32)(unsafe.Pointer(bp)) = v1 useReference = (*TTkText)(unsafe.Pointer(textPtr)).FpixelReference _AdjustStartEndRefs(tls, treePtr, textPtr, libc.Int32FromInt32(TEXT_ADD_REFS)|libc.Int32FromInt32(TEXT_REMOVE_REFS)) /* * We must set the 'end' value in AdjustPixelClient so that the last dummy * line in the B-tree doesn't contain a pixel height. */ end = (*TTkText)(unsafe.Pointer(textPtr)).Fend if end == libc.UintptrFromInt32(0) { end = XTkBTreeFindLine(tls, (*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).Ftree, libc.UintptrFromInt32(0), XTkBTreeNumLines(tls, (*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).Ftree, libc.UintptrFromInt32(0))) } _AdjustPixelClient(tls, treePtr, defaultHeight, (*TBTree)(unsafe.Pointer(treePtr)).FrootPtr, (*TTkText)(unsafe.Pointer(textPtr)).Fstart, end, useReference, (*TBTree)(unsafe.Pointer(treePtr)).FpixelReferences, bp) } /* *---------------------------------------------------------------------- * * TkBTreeDestroy -- * * Delete a B-tree, recycling all of the storage it contains. * * Results: * The tree is deleted, so 'tree' should never again be used. * * Side effects: * Memory is freed. * *---------------------------------------------------------------------- */ func XTkBTreeDestroy(tls *libc.TLS, tree TTkTextBTree) { /* Tree to clean up. */ var treePtr uintptr _ = treePtr treePtr = tree /* * There's no need to loop over each client of the tree, calling * 'TkBTreeRemoveClient', since the 'DestroyNode' will clean everything up * itself. */ _DestroyNode(tls, (*TBTree)(unsafe.Pointer(treePtr)).FrootPtr) if (*TBTree)(unsafe.Pointer(treePtr)).FstartEnd != libc.UintptrFromInt32(0) { libtcl9_0.XTcl_Free(tls, (*TBTree)(unsafe.Pointer(treePtr)).FstartEnd) libtcl9_0.XTcl_Free(tls, (*TBTree)(unsafe.Pointer(treePtr)).FstartEndRef) } libtcl9_0.XTcl_Free(tls, treePtr) } /* *---------------------------------------------------------------------- * * TkBTreeEpoch -- * * Return the epoch for the B-tree. This number is incremented any time * anything changes in the tree. * * Results: * The epoch number. * * Side effects: * None. * *---------------------------------------------------------------------- */ func XTkBTreeEpoch(tls *libc.TLS, tree TTkTextBTree) (r TTcl_Size) { /* Tree to get epoch for. */ var treePtr uintptr _ = treePtr treePtr = tree return (*TBTree)(unsafe.Pointer(treePtr)).FstateEpoch } /* *---------------------------------------------------------------------- * * TkBTreeRemoveClient -- * * Remove a client widget from its B-tree, cleaning up the pixel arrays * which it uses if necessary. If this is the last such widget, we also * destroy the whole tree. * * Results: * All tree-specific aspects of the given client are deleted. If no more * references exist, then the given tree is also deleted (in which case * 'tree' must not be used again). * * Side effects: * Memory may be freed. * *---------------------------------------------------------------------- */ func XTkBTreeRemoveClient(tls *libc.TLS, tree TTkTextBTree, textPtr uintptr) { /* Client to remove. */ var adjustPtr, treePtr uintptr var pixelReference int32 _, _, _ = adjustPtr, pixelReference, treePtr treePtr = tree pixelReference = (*TTkText)(unsafe.Pointer(textPtr)).FpixelReference if (*TBTree)(unsafe.Pointer(treePtr)).Fclients == int32(1) { /* * The last reference to the tree. */ _DestroyNode(tls, (*TBTree)(unsafe.Pointer(treePtr)).FrootPtr) libtcl9_0.XTcl_Free(tls, treePtr) return } else { if pixelReference == -int32(1) { /* * A client which doesn't care about pixels. */ (*TBTree)(unsafe.Pointer(treePtr)).Fclients-- } else { /* * Clean up pixel data for the given reference. */ if pixelReference == (*TBTree)(unsafe.Pointer(treePtr)).FpixelReferences-int32(1) { /* * The widget we're removing has the last index, so deletion is * easier. */ _RemovePixelClient(tls, treePtr, (*TBTree)(unsafe.Pointer(treePtr)).FrootPtr, -int32(1)) } else { _RemovePixelClient(tls, treePtr, (*TBTree)(unsafe.Pointer(treePtr)).FrootPtr, pixelReference) /* * Now we need to adjust the 'pixelReference' of the peer widget * whose storage we've just moved. */ adjustPtr = (*TTkSharedText)(unsafe.Pointer((*TBTree)(unsafe.Pointer(treePtr)).FsharedTextPtr)).Fpeers for adjustPtr != libc.UintptrFromInt32(0) { if (*TTkText)(unsafe.Pointer(adjustPtr)).FpixelReference == (*TBTree)(unsafe.Pointer(treePtr)).FpixelReferences-int32(1) { (*TTkText)(unsafe.Pointer(adjustPtr)).FpixelReference = pixelReference break } adjustPtr = (*TTkText)(unsafe.Pointer(adjustPtr)).Fnext } if adjustPtr == libc.UintptrFromInt32(0) { libtcl9_0.XTcl_Panic(tls, __ccgo_ts+44729, 0) } } (*TBTree)(unsafe.Pointer(treePtr)).FpixelReferences-- (*TBTree)(unsafe.Pointer(treePtr)).Fclients-- } } if (*TTkText)(unsafe.Pointer(textPtr)).Fstart != libc.UintptrFromInt32(0) || (*TTkText)(unsafe.Pointer(textPtr)).Fend != libc.UintptrFromInt32(0) { _AdjustStartEndRefs(tls, treePtr, textPtr, int32(TEXT_REMOVE_REFS)) } } /* *---------------------------------------------------------------------- * * AdjustStartEndRefs -- * * Modify B-tree's cache of start, end lines for the given text widget. * * Results: * None. * * Side effects: * The number of cached items may change (treePtr->startEndCount). * *---------------------------------------------------------------------- */ func _AdjustStartEndRefs(tls *libc.TLS, treePtr uintptr, textPtr uintptr, action int32) { /* Action to perform. */ var count, count1, i int32 _, _, _ = count, count1, i if action&int32(TEXT_REMOVE_REFS) != 0 { i = 0 count = 0 for i < (*TBTree)(unsafe.Pointer(treePtr)).FstartEndCount { if i != count { *(*uintptr)(unsafe.Pointer((*TBTree)(unsafe.Pointer(treePtr)).FstartEnd + uintptr(count)*8)) = *(*uintptr)(unsafe.Pointer((*TBTree)(unsafe.Pointer(treePtr)).FstartEnd + uintptr(i)*8)) *(*uintptr)(unsafe.Pointer((*TBTree)(unsafe.Pointer(treePtr)).FstartEndRef + uintptr(count)*8)) = *(*uintptr)(unsafe.Pointer((*TBTree)(unsafe.Pointer(treePtr)).FstartEndRef + uintptr(i)*8)) } if *(*uintptr)(unsafe.Pointer((*TBTree)(unsafe.Pointer(treePtr)).FstartEndRef + uintptr(i)*8)) != textPtr { count++ } i++ } (*TBTree)(unsafe.Pointer(treePtr)).FstartEndCount = count if count > 0 { (*TBTree)(unsafe.Pointer(treePtr)).FstartEnd = libtcl9_0.XTcl_Realloc(tls, (*TBTree)(unsafe.Pointer(treePtr)).FstartEnd, uint64(8)*libc.Uint64FromInt32(count)) (*TBTree)(unsafe.Pointer(treePtr)).FstartEndRef = libtcl9_0.XTcl_Realloc(tls, (*TBTree)(unsafe.Pointer(treePtr)).FstartEndRef, uint64(8)*libc.Uint64FromInt32(count)) } else { libtcl9_0.XTcl_Free(tls, (*TBTree)(unsafe.Pointer(treePtr)).FstartEndRef) (*TBTree)(unsafe.Pointer(treePtr)).FstartEndRef = libc.UintptrFromInt32(0) libtcl9_0.XTcl_Free(tls, (*TBTree)(unsafe.Pointer(treePtr)).FstartEnd) (*TBTree)(unsafe.Pointer(treePtr)).FstartEnd = libc.UintptrFromInt32(0) } } if action&int32(TEXT_ADD_REFS) != 0 && ((*TTkText)(unsafe.Pointer(textPtr)).Fstart != libc.UintptrFromInt32(0) || (*TTkText)(unsafe.Pointer(textPtr)).Fend != libc.UintptrFromInt32(0)) { if (*TTkText)(unsafe.Pointer(textPtr)).Fstart != libc.UintptrFromInt32(0) { (*TBTree)(unsafe.Pointer(treePtr)).FstartEndCount++ } if (*TTkText)(unsafe.Pointer(textPtr)).Fend != libc.UintptrFromInt32(0) { (*TBTree)(unsafe.Pointer(treePtr)).FstartEndCount++ } count1 = (*TBTree)(unsafe.Pointer(treePtr)).FstartEndCount (*TBTree)(unsafe.Pointer(treePtr)).FstartEnd = libtcl9_0.XTcl_Realloc(tls, (*TBTree)(unsafe.Pointer(treePtr)).FstartEnd, uint64(8)*libc.Uint64FromInt32(count1)) (*TBTree)(unsafe.Pointer(treePtr)).FstartEndRef = libtcl9_0.XTcl_Realloc(tls, (*TBTree)(unsafe.Pointer(treePtr)).FstartEndRef, uint64(8)*libc.Uint64FromInt32(count1)) if (*TTkText)(unsafe.Pointer(textPtr)).Fstart != libc.UintptrFromInt32(0) { count1-- *(*uintptr)(unsafe.Pointer((*TBTree)(unsafe.Pointer(treePtr)).FstartEnd + uintptr(count1)*8)) = (*TTkText)(unsafe.Pointer(textPtr)).Fstart *(*uintptr)(unsafe.Pointer((*TBTree)(unsafe.Pointer(treePtr)).FstartEndRef + uintptr(count1)*8)) = textPtr } if (*TTkText)(unsafe.Pointer(textPtr)).Fend != libc.UintptrFromInt32(0) { count1-- *(*uintptr)(unsafe.Pointer((*TBTree)(unsafe.Pointer(treePtr)).FstartEnd + uintptr(count1)*8)) = (*TTkText)(unsafe.Pointer(textPtr)).Fend *(*uintptr)(unsafe.Pointer((*TBTree)(unsafe.Pointer(treePtr)).FstartEndRef + uintptr(count1)*8)) = textPtr } } } /* *---------------------------------------------------------------------- * * AdjustPixelClient -- * * Utility function used to update all data structures for the existence * of a new peer widget based on this B-tree, or for the modification of * the start, end lines of an existing peer widget. * * Immediately _after_ calling this, treePtr->pixelReferences and * treePtr->clients should be adjusted if needed (i.e. if this is a new * peer). * * Results: * None. * * Side effects: * All the storage for Nodes and TkTextLines in the tree may be adjusted. * *---------------------------------------------------------------------- */ func _AdjustPixelClient(tls *libc.TLS, treePtr uintptr, defaultHeight int32, nodePtr uintptr, start uintptr, end uintptr, useReference int32, newPixelReferences int32, counting uintptr) (r int32) { /* References an integer which is zero if * we're outside the relevant range for this * client, and 1 if we're inside. */ var linePtr, loopPtr uintptr var pixelCount, v1, v2 int32 _, _, _, _, _ = linePtr, loopPtr, pixelCount, v1, v2 pixelCount = 0 /* * Traverse entire tree down from nodePtr, reallocating pixel structures * for each Node and TkTextLine, adding room for the new peer's pixel * information (1 extra int per Node, 2 extra ints per TkTextLine). Also * copy the information from the last peer into the new space (so it * contains something sensible). */ if (*TNode)(unsafe.Pointer(nodePtr)).Flevel != 0 { loopPtr = *(*uintptr)(unsafe.Pointer(nodePtr + 32)) for loopPtr != libc.UintptrFromInt32(0) { pixelCount += _AdjustPixelClient(tls, treePtr, defaultHeight, loopPtr, start, end, useReference, newPixelReferences, counting) loopPtr = (*TNode)(unsafe.Pointer(loopPtr)).FnextPtr } } else { linePtr = *(*uintptr)(unsafe.Pointer(nodePtr + 32)) for linePtr != libc.UintptrFromInt32(0) { if !(*(*int32)(unsafe.Pointer(counting)) != 0) && linePtr == start { *(*int32)(unsafe.Pointer(counting)) = int32(1) } if *(*int32)(unsafe.Pointer(counting)) != 0 && linePtr == end { *(*int32)(unsafe.Pointer(counting)) = 0 } if newPixelReferences != (*TBTree)(unsafe.Pointer(treePtr)).FpixelReferences { (*TTkTextLine)(unsafe.Pointer(linePtr)).Fpixels = libtcl9_0.XTcl_Realloc(tls, (*TTkTextLine)(unsafe.Pointer(linePtr)).Fpixels, libc.Uint64FromInt64(4)*libc.Uint64FromInt32(2)*libc.Uint64FromInt32(newPixelReferences)) } /* * Notice that for the very last line, we are never counting and * therefore this always has a height of 0 and an epoch of 1. */ if *(*int32)(unsafe.Pointer(counting)) != 0 { v1 = defaultHeight } else { v1 = 0 } *(*int32)(unsafe.Pointer((*TTkTextLine)(unsafe.Pointer(linePtr)).Fpixels + uintptr(int32(2)*useReference)*4)) = v1 if *(*int32)(unsafe.Pointer(counting)) != 0 { v2 = 0 } else { v2 = int32(1) } *(*int32)(unsafe.Pointer((*TTkTextLine)(unsafe.Pointer(linePtr)).Fpixels + uintptr(int32(2)*useReference+int32(1))*4)) = v2 pixelCount += *(*int32)(unsafe.Pointer((*TTkTextLine)(unsafe.Pointer(linePtr)).Fpixels + uintptr(int32(2)*useReference)*4)) linePtr = (*TTkTextLine)(unsafe.Pointer(linePtr)).FnextPtr } } if newPixelReferences != (*TBTree)(unsafe.Pointer(treePtr)).FpixelReferences { (*TNode)(unsafe.Pointer(nodePtr)).FnumPixels = libtcl9_0.XTcl_Realloc(tls, (*TNode)(unsafe.Pointer(nodePtr)).FnumPixels, uint64(4)*libc.Uint64FromInt32(newPixelReferences)) } *(*int32)(unsafe.Pointer((*TNode)(unsafe.Pointer(nodePtr)).FnumPixels + uintptr(useReference)*4)) = pixelCount return pixelCount } /* *---------------------------------------------------------------------- * * RemovePixelClient -- * * Utility function used to update all data structures for the removal of * a peer widget which used to be based on this B-tree. * * Immediately _after_ calling this, treePtr->clients should be * decremented. * * Results: * None. * * Side effects: * All the storage for Nodes and TkTextLines in the tree may be adjusted. * *---------------------------------------------------------------------- */ func _RemovePixelClient(tls *libc.TLS, treePtr uintptr, nodePtr uintptr, overwriteWithLast int32) { /* Over-write this peer widget's information * with the last one. */ var linePtr uintptr _ = linePtr /* * Traverse entire tree down from nodePtr, reallocating pixel structures * for each Node and TkTextLine, removing space allocated for one peer. If * 'overwriteWithLast' is not -1, then copy the information which was in * the last slot on top of one of the others (i.e. it's not the last one * we're deleting). */ if overwriteWithLast != -int32(1) { *(*int32)(unsafe.Pointer((*TNode)(unsafe.Pointer(nodePtr)).FnumPixels + uintptr(overwriteWithLast)*4)) = *(*int32)(unsafe.Pointer((*TNode)(unsafe.Pointer(nodePtr)).FnumPixels + uintptr((*TBTree)(unsafe.Pointer(treePtr)).FpixelReferences-int32(1))*4)) } if (*TBTree)(unsafe.Pointer(treePtr)).FpixelReferences == int32(1) { libtcl9_0.XTcl_Free(tls, (*TNode)(unsafe.Pointer(nodePtr)).FnumPixels) (*TNode)(unsafe.Pointer(nodePtr)).FnumPixels = libc.UintptrFromInt32(0) } else { (*TNode)(unsafe.Pointer(nodePtr)).FnumPixels = libtcl9_0.XTcl_Realloc(tls, (*TNode)(unsafe.Pointer(nodePtr)).FnumPixels, uint64(4)*libc.Uint64FromInt32((*TBTree)(unsafe.Pointer(treePtr)).FpixelReferences-libc.Int32FromInt32(1))) } if (*TNode)(unsafe.Pointer(nodePtr)).Flevel != 0 { nodePtr = *(*uintptr)(unsafe.Pointer(nodePtr + 32)) for nodePtr != libc.UintptrFromInt32(0) { _RemovePixelClient(tls, treePtr, nodePtr, overwriteWithLast) nodePtr = (*TNode)(unsafe.Pointer(nodePtr)).FnextPtr } } else { linePtr = *(*uintptr)(unsafe.Pointer(nodePtr + 32)) for linePtr != libc.UintptrFromInt32(0) { if overwriteWithLast != -int32(1) { *(*int32)(unsafe.Pointer((*TTkTextLine)(unsafe.Pointer(linePtr)).Fpixels + uintptr(int32(2)*overwriteWithLast)*4)) = *(*int32)(unsafe.Pointer((*TTkTextLine)(unsafe.Pointer(linePtr)).Fpixels + uintptr(int32(2)*((*TBTree)(unsafe.Pointer(treePtr)).FpixelReferences-int32(1)))*4)) *(*int32)(unsafe.Pointer((*TTkTextLine)(unsafe.Pointer(linePtr)).Fpixels + uintptr(int32(1)+int32(2)*overwriteWithLast)*4)) = *(*int32)(unsafe.Pointer((*TTkTextLine)(unsafe.Pointer(linePtr)).Fpixels + uintptr(int32(1)+int32(2)*((*TBTree)(unsafe.Pointer(treePtr)).FpixelReferences-int32(1)))*4)) } if (*TBTree)(unsafe.Pointer(treePtr)).FpixelReferences == int32(1) { (*TTkTextLine)(unsafe.Pointer(linePtr)).Fpixels = libc.UintptrFromInt32(0) } else { (*TTkTextLine)(unsafe.Pointer(linePtr)).Fpixels = libtcl9_0.XTcl_Realloc(tls, (*TTkTextLine)(unsafe.Pointer(linePtr)).Fpixels, libc.Uint64FromInt64(4)*libc.Uint64FromInt32(2)*libc.Uint64FromInt32((*TBTree)(unsafe.Pointer(treePtr)).FpixelReferences-libc.Int32FromInt32(1))) } linePtr = (*TTkTextLine)(unsafe.Pointer(linePtr)).FnextPtr } } } /* *---------------------------------------------------------------------- * * DestroyNode -- * * This is a recursive utility function used during the deletion of a * B-tree. * * Results: * None. * * Side effects: * All the storage for nodePtr and its descendants is freed. * *---------------------------------------------------------------------- */ func _DestroyNode(tls *libc.TLS, nodePtr uintptr) { /* Destroy from this node downwards. */ var childPtr, linePtr, segPtr uintptr _, _, _ = childPtr, linePtr, segPtr if (*TNode)(unsafe.Pointer(nodePtr)).Flevel == 0 { for *(*uintptr)(unsafe.Pointer(nodePtr + 32)) != libc.UintptrFromInt32(0) { linePtr = *(*uintptr)(unsafe.Pointer(nodePtr + 32)) *(*uintptr)(unsafe.Pointer(nodePtr + 32)) = (*TTkTextLine)(unsafe.Pointer(linePtr)).FnextPtr for (*TTkTextLine)(unsafe.Pointer(linePtr)).FsegPtr != libc.UintptrFromInt32(0) { segPtr = (*TTkTextLine)(unsafe.Pointer(linePtr)).FsegPtr (*TTkTextLine)(unsafe.Pointer(linePtr)).FsegPtr = (*TTkTextSegment)(unsafe.Pointer(segPtr)).FnextPtr (*(*func(*libc.TLS, uintptr, uintptr, int32) int32)(unsafe.Pointer(&struct{ uintptr }{(*TTk_SegType1)(unsafe.Pointer((*TTkTextSegment)(unsafe.Pointer(segPtr)).FtypePtr)).FdeleteProc})))(tls, segPtr, linePtr, int32(1)) } libtcl9_0.XTcl_Free(tls, (*TTkTextLine)(unsafe.Pointer(linePtr)).Fpixels) libtcl9_0.XTcl_Free(tls, linePtr) } } else { for *(*uintptr)(unsafe.Pointer(nodePtr + 32)) != libc.UintptrFromInt32(0) { childPtr = *(*uintptr)(unsafe.Pointer(nodePtr + 32)) *(*uintptr)(unsafe.Pointer(nodePtr + 32)) = (*TNode)(unsafe.Pointer(childPtr)).FnextPtr _DestroyNode(tls, childPtr) } } _DeleteSummaries(tls, (*TNode)(unsafe.Pointer(nodePtr)).FsummaryPtr) libtcl9_0.XTcl_Free(tls, (*TNode)(unsafe.Pointer(nodePtr)).FnumPixels) libtcl9_0.XTcl_Free(tls, nodePtr) } /* *---------------------------------------------------------------------- * * DeleteSummaries -- * * Free up all of the memory in a list of tag summaries associated with a * node. * * Results: * None. * * Side effects: * Storage is released. * *---------------------------------------------------------------------- */ func _DeleteSummaries(tls *libc.TLS, summaryPtr uintptr) { /* First in list of node's tag summaries. */ var nextPtr uintptr _ = nextPtr for summaryPtr != libc.UintptrFromInt32(0) { nextPtr = (*TSummary)(unsafe.Pointer(summaryPtr)).FnextPtr libtcl9_0.XTcl_Free(tls, summaryPtr) summaryPtr = nextPtr } } /* *---------------------------------------------------------------------- * * TkBTreeAdjustPixelHeight -- * * Adjust the pixel height of a given logical line to the specified * value. * * Results: * Total number of valid pixels currently known in the tree. * * Side effects: * Updates overall data structures so pixel height count is consistent. * *---------------------------------------------------------------------- */ func XTkBTreeAdjustPixelHeight(tls *libc.TLS, textPtr uintptr, linePtr uintptr, newPixelHeight int32, mergedLogicalLines int32) (r int32) { /* The number of extra logical lines which * have been merged with this one (due to * elided eols). They will have their pixel * height set to zero, and the total pixel * height associated with the given * linePtr. */ var changeToPixelCount, pixelReference, v1 int32 var nodePtr uintptr _, _, _, _ = changeToPixelCount, nodePtr, pixelReference, v1 /* Counts change to total number of pixels in * file. */ pixelReference = (*TTkText)(unsafe.Pointer(textPtr)).FpixelReference changeToPixelCount = newPixelHeight - *(*int32)(unsafe.Pointer((*TTkTextLine)(unsafe.Pointer(linePtr)).Fpixels + uintptr(int32(2)*pixelReference)*4)) /* * Increment the pixel counts in all the parent nodes of the current line, * then rebalance the tree if necessary. */ nodePtr = (*TTkTextLine)(unsafe.Pointer(linePtr)).FparentPtr *(*int32)(unsafe.Pointer((*TNode)(unsafe.Pointer(nodePtr)).FnumPixels + uintptr(pixelReference)*4)) += changeToPixelCount for (*TNode)(unsafe.Pointer(nodePtr)).FparentPtr != libc.UintptrFromInt32(0) { nodePtr = (*TNode)(unsafe.Pointer(nodePtr)).FparentPtr *(*int32)(unsafe.Pointer((*TNode)(unsafe.Pointer(nodePtr)).FnumPixels + uintptr(pixelReference)*4)) += changeToPixelCount } *(*int32)(unsafe.Pointer((*TTkTextLine)(unsafe.Pointer(linePtr)).Fpixels + uintptr(int32(2)*pixelReference)*4)) = newPixelHeight /* * Any merged logical lines must have their height set to zero. */ for { v1 = mergedLogicalLines mergedLogicalLines-- if !(v1 > 0) { break } linePtr = XTkBTreeNextLine(tls, textPtr, linePtr) XTkBTreeAdjustPixelHeight(tls, textPtr, linePtr, 0, 0) } /* * Return total number of pixels in the tree. */ return *(*int32)(unsafe.Pointer((*TNode)(unsafe.Pointer(nodePtr)).FnumPixels + uintptr(pixelReference)*4)) } /* *---------------------------------------------------------------------- * * TkBTreeInsertChars -- * * Insert characters at a given position in a B-tree. * * Results: * None. * * Side effects: * Characters are added to the B-tree at the given position. If the * string contains newlines, new lines will be added, which could cause * the structure of the B-tree to change. * *---------------------------------------------------------------------- */ func XTkBTreeInsertChars(tls *libc.TLS, tree TTkTextBTree, indexPtr uintptr, string1 uintptr) { bp := tls.Alloc(32) defer tls.Free(32) /* Pointer to bytes to insert (may contain * newlines, must be null-terminated). */ var changeToLineCount, ref int32 var changeToPixelCount, curPtr, eol, linePtr, newLinePtr, nodePtr, prevPtr, segPtr, treePtr uintptr var chunkSize Tsize_t var _ /* pixels at bp+0 */ [5]int32 _, _, _, _, _, _, _, _, _, _, _, _ = changeToLineCount, changeToPixelCount, chunkSize, curPtr, eol, linePtr, newLinePtr, nodePtr, prevPtr, ref, segPtr, treePtr treePtr = tree (*TBTree)(unsafe.Pointer(treePtr)).FstateEpoch++ prevPtr = _SplitSeg(tls, indexPtr) linePtr = (*TTkTextIndex)(unsafe.Pointer(indexPtr)).FlinePtr curPtr = prevPtr /* * Chop the string up into lines and create a new segment for each line, * plus a new line for the leftovers from the previous line. */ changeToLineCount = 0 if (*TBTree)(unsafe.Pointer(treePtr)).FpixelReferences > int32(PIXEL_CLIENTS) { changeToPixelCount = libtcl9_0.XTcl_Alloc(tls, uint64(4)*libc.Uint64FromInt32((*TBTree)(unsafe.Pointer(treePtr)).FpixelReferences)) } else { changeToPixelCount = bp } ref = 0 for { if !(ref < (*TBTree)(unsafe.Pointer(treePtr)).FpixelReferences) { break } *(*int32)(unsafe.Pointer(changeToPixelCount + uintptr(ref)*4)) = 0 goto _1 _1: ; ref++ } for libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(string1))) != 0 { eol = string1 for { if !(libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(eol))) != 0) { break } if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(eol))) == int32('\n') { eol++ break } goto _2 _2: ; eol++ } chunkSize = libc.Uint64FromInt64(int64(eol) - int64(string1)) segPtr = libtcl9_0.XTcl_Alloc(tls, uint64(libc.UintptrFromInt32(0)+24)+libc.Uint64FromInt32(1)+chunkSize) (*TTkTextSegment)(unsafe.Pointer(segPtr)).FtypePtr = uintptr(unsafe.Pointer(&XtkTextCharType)) if curPtr == libc.UintptrFromInt32(0) { (*TTkTextSegment)(unsafe.Pointer(segPtr)).FnextPtr = (*TTkTextLine)(unsafe.Pointer(linePtr)).FsegPtr (*TTkTextLine)(unsafe.Pointer(linePtr)).FsegPtr = segPtr } else { (*TTkTextSegment)(unsafe.Pointer(segPtr)).FnextPtr = (*TTkTextSegment)(unsafe.Pointer(curPtr)).FnextPtr (*TTkTextSegment)(unsafe.Pointer(curPtr)).FnextPtr = segPtr } (*TTkTextSegment)(unsafe.Pointer(segPtr)).Fsize = libc.Int64FromUint64(chunkSize) libc.Xmemcpy(tls, segPtr+24, string1, chunkSize) *(*uint8)(unsafe.Pointer(segPtr + 24 + uintptr(chunkSize))) = uint8(0) if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(eol + uintptr(-libc.Int32FromInt32(1))))) != int32('\n') { break } /* * The chunk ended with a newline, so create a new TkTextLine and move * the remainder of the old line to it. */ newLinePtr = libtcl9_0.XTcl_Alloc(tls, uint64(32)) (*TTkTextLine)(unsafe.Pointer(newLinePtr)).Fpixels = libtcl9_0.XTcl_Alloc(tls, libc.Uint64FromInt64(4)*libc.Uint64FromInt32(2)*libc.Uint64FromInt32((*TBTree)(unsafe.Pointer(treePtr)).FpixelReferences)) (*TTkTextLine)(unsafe.Pointer(newLinePtr)).FparentPtr = (*TTkTextLine)(unsafe.Pointer(linePtr)).FparentPtr (*TTkTextLine)(unsafe.Pointer(newLinePtr)).FnextPtr = (*TTkTextLine)(unsafe.Pointer(linePtr)).FnextPtr (*TTkTextLine)(unsafe.Pointer(linePtr)).FnextPtr = newLinePtr (*TTkTextLine)(unsafe.Pointer(newLinePtr)).FsegPtr = (*TTkTextSegment)(unsafe.Pointer(segPtr)).FnextPtr /* * Set up a starting default height, which will be re-adjusted later. * We need to do this for each referenced widget. */ ref = 0 for { if !(ref < (*TBTree)(unsafe.Pointer(treePtr)).FpixelReferences) { break } *(*int32)(unsafe.Pointer((*TTkTextLine)(unsafe.Pointer(newLinePtr)).Fpixels + uintptr(int32(2)*ref)*4)) = *(*int32)(unsafe.Pointer((*TTkTextLine)(unsafe.Pointer(linePtr)).Fpixels + uintptr(int32(2)*ref)*4)) *(*int32)(unsafe.Pointer((*TTkTextLine)(unsafe.Pointer(newLinePtr)).Fpixels + uintptr(int32(2)*ref+int32(1))*4)) = 0 *(*int32)(unsafe.Pointer(changeToPixelCount + uintptr(ref)*4)) += *(*int32)(unsafe.Pointer((*TTkTextLine)(unsafe.Pointer(newLinePtr)).Fpixels + uintptr(int32(2)*ref)*4)) goto _3 _3: ; ref++ } (*TTkTextSegment)(unsafe.Pointer(segPtr)).FnextPtr = libc.UintptrFromInt32(0) linePtr = newLinePtr curPtr = libc.UintptrFromInt32(0) changeToLineCount++ string1 = eol } /* * I don't believe it's possible for either of the two lines passed to * this function to be the last line of text, but the function is robust * to that case anyway. (We must never re-calculate the line height of * the last line). */ XTkTextInvalidateLineMetrics(tls, (*TBTree)(unsafe.Pointer(treePtr)).FsharedTextPtr, libc.UintptrFromInt32(0), (*TTkTextIndex)(unsafe.Pointer(indexPtr)).FlinePtr, changeToLineCount, int32(TK_TEXT_INVALIDATE_INSERT)) /* * Cleanup the starting line for the insertion, plus the ending line if * it's different. */ _CleanupLine(tls, (*TTkTextIndex)(unsafe.Pointer(indexPtr)).FlinePtr) if linePtr != (*TTkTextIndex)(unsafe.Pointer(indexPtr)).FlinePtr { _CleanupLine(tls, linePtr) } /* * Increment the line and pixel counts in all the parent nodes of the * insertion point, then rebalance the tree if necessary. */ nodePtr = (*TTkTextLine)(unsafe.Pointer(linePtr)).FparentPtr for { if !(nodePtr != libc.UintptrFromInt32(0)) { break } *(*int32)(unsafe.Pointer(nodePtr + 44)) += changeToLineCount ref = 0 for { if !(ref < (*TBTree)(unsafe.Pointer(treePtr)).FpixelReferences) { break } *(*int32)(unsafe.Pointer((*TNode)(unsafe.Pointer(nodePtr)).FnumPixels + uintptr(ref)*4)) += *(*int32)(unsafe.Pointer(changeToPixelCount + uintptr(ref)*4)) goto _5 _5: ; ref++ } goto _4 _4: ; nodePtr = (*TNode)(unsafe.Pointer(nodePtr)).FparentPtr } if (*TBTree)(unsafe.Pointer(treePtr)).FpixelReferences > int32(PIXEL_CLIENTS) { libtcl9_0.XTcl_Free(tls, changeToPixelCount) } nodePtr = (*TTkTextLine)(unsafe.Pointer(linePtr)).FparentPtr *(*int32)(unsafe.Pointer(nodePtr + 40)) += changeToLineCount if (*TNode)(unsafe.Pointer(nodePtr)).FnumChildren > int32(MAX_CHILDREN) { _Rebalance(tls, treePtr, nodePtr) } if XtkBTreeDebug != 0 { XTkBTreeCheck(tls, (*TTkTextIndex)(unsafe.Pointer(indexPtr)).Ftree) } } /* *-------------------------------------------------------------- * * SplitSeg -- * * This function is called before adding or deleting segments. It does * three things: (a) it finds the segment containing indexPtr; (b) if * there are several such segments (because some segments have zero * length) then it picks the first segment that does not have left * gravity; (c) if the index refers to the middle of a segment then it * splits the segment so that the index now refers to the beginning of a * segment. * * Results: * The return value is a pointer to the segment just before the segment * corresponding to indexPtr (as described above). If the segment * corresponding to indexPtr is the first in its line then the return * value is NULL. * * Side effects: * The segment referred to by indexPtr is split unless indexPtr refers to * its first character. * *-------------------------------------------------------------- */ func _SplitSeg(tls *libc.TLS, indexPtr uintptr) (r uintptr) { /* Index identifying position at which to * split a segment. */ var count TTcl_Size var linePtr, prevPtr, segPtr uintptr _, _, _, _ = count, linePtr, prevPtr, segPtr count = (*TTkTextIndex)(unsafe.Pointer(indexPtr)).FbyteIndex linePtr = (*TTkTextIndex)(unsafe.Pointer(indexPtr)).FlinePtr prevPtr = libc.UintptrFromInt32(0) segPtr = (*TTkTextLine)(unsafe.Pointer(linePtr)).FsegPtr for segPtr != libc.UintptrFromInt32(0) { if (*TTkTextSegment)(unsafe.Pointer(segPtr)).Fsize > count { if count == 0 { return prevPtr } segPtr = (*(*func(*libc.TLS, uintptr, TTcl_Size) uintptr)(unsafe.Pointer(&struct{ uintptr }{(*TTk_SegType1)(unsafe.Pointer((*TTkTextSegment)(unsafe.Pointer(segPtr)).FtypePtr)).FsplitProc})))(tls, segPtr, count) if prevPtr == libc.UintptrFromInt32(0) { (*TTkTextLine)(unsafe.Pointer((*TTkTextIndex)(unsafe.Pointer(indexPtr)).FlinePtr)).FsegPtr = segPtr } else { (*TTkTextSegment)(unsafe.Pointer(prevPtr)).FnextPtr = segPtr } return segPtr } else { if (*TTkTextSegment)(unsafe.Pointer(segPtr)).Fsize == 0 && count == 0 && !((*TTk_SegType1)(unsafe.Pointer((*TTkTextSegment)(unsafe.Pointer(segPtr)).FtypePtr)).FleftGravity != 0) { return prevPtr } } count -= (*TTkTextSegment)(unsafe.Pointer(segPtr)).Fsize prevPtr = segPtr segPtr = (*TTkTextSegment)(unsafe.Pointer(segPtr)).FnextPtr if segPtr == libc.UintptrFromInt32(0) { /* * Two logical lines merged into one display line through eliding * of a newline. */ linePtr = XTkBTreeNextLine(tls, libc.UintptrFromInt32(0), linePtr) if linePtr == libc.UintptrFromInt32(0) { /* * Reached end of the text. */ } else { segPtr = (*TTkTextLine)(unsafe.Pointer(linePtr)).FsegPtr } } } libtcl9_0.XTcl_Panic(tls, __ccgo_ts+44778, 0) return libc.UintptrFromInt32(0) } /* *-------------------------------------------------------------- * * CleanupLine -- * * This function is called after modifications have been made to a line. * It scans over all of the segments in the line, giving each a chance to * clean itself up, e.g. by merging with the following segments, updating * internal information, etc. * * Results: * None. * * Side effects: * Depends on what the segment-specific cleanup functions do. * *-------------------------------------------------------------- */ func _CleanupLine(tls *libc.TLS, linePtr uintptr) { /* Line to be cleaned up. */ var anyChanges int32 var prevPtrPtr, segPtr uintptr _, _, _ = anyChanges, prevPtrPtr, segPtr /* * Make a pass over all of the segments in the line, giving each a chance * to clean itself up. This could potentially change the structure of the * line, e.g. by merging two segments together or having two segments * cancel themselves; if so, then repeat the whole process again, since * the first structure change might make other structure changes possible. * Repeat until eventually there are no changes. */ for int32(1) != 0 { anyChanges = 0 prevPtrPtr = linePtr + 16 segPtr = *(*uintptr)(unsafe.Pointer(prevPtrPtr)) for { if !(segPtr != libc.UintptrFromInt32(0)) { break } if (*TTk_SegType1)(unsafe.Pointer((*TTkTextSegment)(unsafe.Pointer(segPtr)).FtypePtr)).FcleanupProc != libc.UintptrFromInt32(0) { *(*uintptr)(unsafe.Pointer(prevPtrPtr)) = (*(*func(*libc.TLS, uintptr, uintptr) uintptr)(unsafe.Pointer(&struct{ uintptr }{(*TTk_SegType1)(unsafe.Pointer((*TTkTextSegment)(unsafe.Pointer(segPtr)).FtypePtr)).FcleanupProc})))(tls, segPtr, linePtr) if segPtr != *(*uintptr)(unsafe.Pointer(prevPtrPtr)) { anyChanges = int32(1) } } goto _1 _1: ; prevPtrPtr = *(*uintptr)(unsafe.Pointer(prevPtrPtr)) + 8 segPtr = *(*uintptr)(unsafe.Pointer(prevPtrPtr)) } if !(anyChanges != 0) { break } } } /* *---------------------------------------------------------------------- * * TkBTreeDeleteIndexRange -- * * Delete a range of characters from a B-tree. The caller must make sure * that the final newline of the B-tree is never deleted. * * Results: * None. * * Side effects: * Information is deleted from the B-tree. This can cause the internal * structure of the B-tree to change. Note: because of changes to the * B-tree structure, the indices pointed to by index1Ptr and index2Ptr * should not be used after this function returns. * *---------------------------------------------------------------------- */ func XTkBTreeDeleteIndexRange(tls *libc.TLS, tree TTkTextBTree, index1Ptr uintptr, index2Ptr uintptr) { /* Indicates character just after the last one * that is to be deleted. */ var changeToLineCount, checkCount, checkCount1, ref int32 var curLinePtr, curNodePtr, lastPtr, nextLinePtr, nextPtr, nodePtr, parentPtr, peer, peer1, prevLinePtr, prevNodePtr, prevPtr, segPtr, treePtr uintptr _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = changeToLineCount, checkCount, checkCount1, curLinePtr, curNodePtr, lastPtr, nextLinePtr, nextPtr, nodePtr, parentPtr, peer, peer1, prevLinePtr, prevNodePtr, prevPtr, ref, segPtr, treePtr changeToLineCount = 0 treePtr = tree (*TBTree)(unsafe.Pointer(treePtr)).FstateEpoch++ /* * Tricky point: split at index2Ptr first; otherwise the split at * index2Ptr may invalidate segPtr and/or prevPtr. */ lastPtr = _SplitSeg(tls, index2Ptr) if lastPtr != libc.UintptrFromInt32(0) { lastPtr = (*TTkTextSegment)(unsafe.Pointer(lastPtr)).FnextPtr } else { lastPtr = (*TTkTextLine)(unsafe.Pointer((*TTkTextIndex)(unsafe.Pointer(index2Ptr)).FlinePtr)).FsegPtr } prevPtr = _SplitSeg(tls, index1Ptr) if prevPtr != libc.UintptrFromInt32(0) { segPtr = (*TTkTextSegment)(unsafe.Pointer(prevPtr)).FnextPtr (*TTkTextSegment)(unsafe.Pointer(prevPtr)).FnextPtr = lastPtr } else { segPtr = (*TTkTextLine)(unsafe.Pointer((*TTkTextIndex)(unsafe.Pointer(index1Ptr)).FlinePtr)).FsegPtr (*TTkTextLine)(unsafe.Pointer((*TTkTextIndex)(unsafe.Pointer(index1Ptr)).FlinePtr)).FsegPtr = lastPtr } /* * Delete all of the segments between prevPtr and lastPtr. */ curLinePtr = (*TTkTextIndex)(unsafe.Pointer(index1Ptr)).FlinePtr curNodePtr = (*TTkTextLine)(unsafe.Pointer(curLinePtr)).FparentPtr for segPtr != lastPtr { if segPtr == libc.UintptrFromInt32(0) { /* * We just ran off the end of a line. First find the next line, * then go back to the old line and delete it (unless it's the * starting line for the range). */ nextLinePtr = XTkBTreeNextLine(tls, libc.UintptrFromInt32(0), curLinePtr) if curLinePtr != (*TTkTextIndex)(unsafe.Pointer(index1Ptr)).FlinePtr { if curNodePtr == (*TTkTextLine)(unsafe.Pointer((*TTkTextIndex)(unsafe.Pointer(index1Ptr)).FlinePtr)).FparentPtr { (*TTkTextLine)(unsafe.Pointer((*TTkTextIndex)(unsafe.Pointer(index1Ptr)).FlinePtr)).FnextPtr = (*TTkTextLine)(unsafe.Pointer(curLinePtr)).FnextPtr } else { *(*uintptr)(unsafe.Pointer(curNodePtr + 32)) = (*TTkTextLine)(unsafe.Pointer(curLinePtr)).FnextPtr } nodePtr = curNodePtr for { if !(nodePtr != libc.UintptrFromInt32(0)) { break } (*TNode)(unsafe.Pointer(nodePtr)).FnumLines-- ref = 0 for { if !(ref < (*TBTree)(unsafe.Pointer(treePtr)).FpixelReferences) { break } *(*int32)(unsafe.Pointer((*TNode)(unsafe.Pointer(nodePtr)).FnumPixels + uintptr(ref)*4)) -= *(*int32)(unsafe.Pointer((*TTkTextLine)(unsafe.Pointer(curLinePtr)).Fpixels + uintptr(int32(2)*ref)*4)) goto _2 _2: ; ref++ } goto _1 _1: ; nodePtr = (*TNode)(unsafe.Pointer(nodePtr)).FparentPtr } changeToLineCount++ (*TNode)(unsafe.Pointer(curNodePtr)).FnumChildren-- /* * Check if we need to adjust any partial clients. */ if (*TBTree)(unsafe.Pointer(treePtr)).FstartEnd != libc.UintptrFromInt32(0) { checkCount = 0 for checkCount < (*TBTree)(unsafe.Pointer(treePtr)).FstartEndCount { if *(*uintptr)(unsafe.Pointer((*TBTree)(unsafe.Pointer(treePtr)).FstartEnd + uintptr(checkCount)*8)) == curLinePtr { peer = *(*uintptr)(unsafe.Pointer((*TBTree)(unsafe.Pointer(treePtr)).FstartEndRef + uintptr(checkCount)*8)) /* * We're deleting a line which is the start or end * of a current client. This means we need to * adjust that client. */ *(*uintptr)(unsafe.Pointer((*TBTree)(unsafe.Pointer(treePtr)).FstartEnd + uintptr(checkCount)*8)) = nextLinePtr if (*TTkText)(unsafe.Pointer(peer)).Fstart == curLinePtr { (*TTkText)(unsafe.Pointer(peer)).Fstart = nextLinePtr } if (*TTkText)(unsafe.Pointer(peer)).Fend == curLinePtr { (*TTkText)(unsafe.Pointer(peer)).Fend = nextLinePtr } } checkCount++ } } libtcl9_0.XTcl_Free(tls, (*TTkTextLine)(unsafe.Pointer(curLinePtr)).Fpixels) libtcl9_0.XTcl_Free(tls, curLinePtr) } curLinePtr = nextLinePtr segPtr = (*TTkTextLine)(unsafe.Pointer(curLinePtr)).FsegPtr /* * If the node is empty then delete it and its parents recursively * upwards until a non-empty node is found. */ for (*TNode)(unsafe.Pointer(curNodePtr)).FnumChildren == 0 { parentPtr = (*TNode)(unsafe.Pointer(curNodePtr)).FparentPtr if *(*uintptr)(unsafe.Pointer(parentPtr + 32)) == curNodePtr { *(*uintptr)(unsafe.Pointer(parentPtr + 32)) = (*TNode)(unsafe.Pointer(curNodePtr)).FnextPtr } else { prevNodePtr = *(*uintptr)(unsafe.Pointer(parentPtr + 32)) for (*TNode)(unsafe.Pointer(prevNodePtr)).FnextPtr != curNodePtr { prevNodePtr = (*TNode)(unsafe.Pointer(prevNodePtr)).FnextPtr } (*TNode)(unsafe.Pointer(prevNodePtr)).FnextPtr = (*TNode)(unsafe.Pointer(curNodePtr)).FnextPtr } (*TNode)(unsafe.Pointer(parentPtr)).FnumChildren-- _DeleteSummaries(tls, (*TNode)(unsafe.Pointer(curNodePtr)).FsummaryPtr) libtcl9_0.XTcl_Free(tls, (*TNode)(unsafe.Pointer(curNodePtr)).FnumPixels) libtcl9_0.XTcl_Free(tls, curNodePtr) curNodePtr = parentPtr } curNodePtr = (*TTkTextLine)(unsafe.Pointer(curLinePtr)).FparentPtr continue } nextPtr = (*TTkTextSegment)(unsafe.Pointer(segPtr)).FnextPtr if (*(*func(*libc.TLS, uintptr, uintptr, int32) int32)(unsafe.Pointer(&struct{ uintptr }{(*TTk_SegType1)(unsafe.Pointer((*TTkTextSegment)(unsafe.Pointer(segPtr)).FtypePtr)).FdeleteProc})))(tls, segPtr, curLinePtr, 0) != 0 { /* * This segment refuses to die. Move it to prevPtr and advance * prevPtr if the segment has left gravity. */ if prevPtr == libc.UintptrFromInt32(0) { (*TTkTextSegment)(unsafe.Pointer(segPtr)).FnextPtr = (*TTkTextLine)(unsafe.Pointer((*TTkTextIndex)(unsafe.Pointer(index1Ptr)).FlinePtr)).FsegPtr (*TTkTextLine)(unsafe.Pointer((*TTkTextIndex)(unsafe.Pointer(index1Ptr)).FlinePtr)).FsegPtr = segPtr } else { (*TTkTextSegment)(unsafe.Pointer(segPtr)).FnextPtr = (*TTkTextSegment)(unsafe.Pointer(prevPtr)).FnextPtr (*TTkTextSegment)(unsafe.Pointer(prevPtr)).FnextPtr = segPtr } if (*TTk_SegType1)(unsafe.Pointer((*TTkTextSegment)(unsafe.Pointer(segPtr)).FtypePtr)).FleftGravity != 0 { prevPtr = segPtr } } segPtr = nextPtr } /* * If the beginning and end of the deletion range are in different lines, * join the two lines together and discard the ending line. */ if (*TTkTextIndex)(unsafe.Pointer(index1Ptr)).FlinePtr != (*TTkTextIndex)(unsafe.Pointer(index2Ptr)).FlinePtr { segPtr = lastPtr for { if !(segPtr != libc.UintptrFromInt32(0)) { break } if (*TTk_SegType1)(unsafe.Pointer((*TTkTextSegment)(unsafe.Pointer(segPtr)).FtypePtr)).FlineChangeProc != libc.UintptrFromInt32(0) { (*(*func(*libc.TLS, uintptr, uintptr))(unsafe.Pointer(&struct{ uintptr }{(*TTk_SegType1)(unsafe.Pointer((*TTkTextSegment)(unsafe.Pointer(segPtr)).FtypePtr)).FlineChangeProc})))(tls, segPtr, (*TTkTextIndex)(unsafe.Pointer(index2Ptr)).FlinePtr) } goto _3 _3: ; segPtr = (*TTkTextSegment)(unsafe.Pointer(segPtr)).FnextPtr } curNodePtr = (*TTkTextLine)(unsafe.Pointer((*TTkTextIndex)(unsafe.Pointer(index2Ptr)).FlinePtr)).FparentPtr nodePtr = curNodePtr for { if !(nodePtr != libc.UintptrFromInt32(0)) { break } (*TNode)(unsafe.Pointer(nodePtr)).FnumLines-- ref = 0 for { if !(ref < (*TBTree)(unsafe.Pointer(treePtr)).FpixelReferences) { break } *(*int32)(unsafe.Pointer((*TNode)(unsafe.Pointer(nodePtr)).FnumPixels + uintptr(ref)*4)) -= *(*int32)(unsafe.Pointer((*TTkTextLine)(unsafe.Pointer((*TTkTextIndex)(unsafe.Pointer(index2Ptr)).FlinePtr)).Fpixels + uintptr(int32(2)*ref)*4)) goto _5 _5: ; ref++ } goto _4 _4: ; nodePtr = (*TNode)(unsafe.Pointer(nodePtr)).FparentPtr } changeToLineCount++ (*TNode)(unsafe.Pointer(curNodePtr)).FnumChildren-- prevLinePtr = *(*uintptr)(unsafe.Pointer(curNodePtr + 32)) if prevLinePtr == (*TTkTextIndex)(unsafe.Pointer(index2Ptr)).FlinePtr { *(*uintptr)(unsafe.Pointer(curNodePtr + 32)) = (*TTkTextLine)(unsafe.Pointer((*TTkTextIndex)(unsafe.Pointer(index2Ptr)).FlinePtr)).FnextPtr } else { for (*TTkTextLine)(unsafe.Pointer(prevLinePtr)).FnextPtr != (*TTkTextIndex)(unsafe.Pointer(index2Ptr)).FlinePtr { prevLinePtr = (*TTkTextLine)(unsafe.Pointer(prevLinePtr)).FnextPtr } (*TTkTextLine)(unsafe.Pointer(prevLinePtr)).FnextPtr = (*TTkTextLine)(unsafe.Pointer((*TTkTextIndex)(unsafe.Pointer(index2Ptr)).FlinePtr)).FnextPtr } /* * Check if we need to adjust any partial clients. In this case if * we're deleting the line, we actually move back to the previous line * for our (start,end) storage. We do this because we still want the * portion of the second line that still exists to be in the start,end * range. */ if (*TBTree)(unsafe.Pointer(treePtr)).FstartEnd != libc.UintptrFromInt32(0) { checkCount1 = 0 for checkCount1 < (*TBTree)(unsafe.Pointer(treePtr)).FstartEndCount && *(*uintptr)(unsafe.Pointer((*TBTree)(unsafe.Pointer(treePtr)).FstartEnd + uintptr(checkCount1)*8)) != libc.UintptrFromInt32(0) { if *(*uintptr)(unsafe.Pointer((*TBTree)(unsafe.Pointer(treePtr)).FstartEnd + uintptr(checkCount1)*8)) == (*TTkTextIndex)(unsafe.Pointer(index2Ptr)).FlinePtr { peer1 = *(*uintptr)(unsafe.Pointer((*TBTree)(unsafe.Pointer(treePtr)).FstartEndRef + uintptr(checkCount1)*8)) /* * We're deleting a line which is the start or end of a * current client. This means we need to adjust that * client. */ *(*uintptr)(unsafe.Pointer((*TBTree)(unsafe.Pointer(treePtr)).FstartEnd + uintptr(checkCount1)*8)) = (*TTkTextIndex)(unsafe.Pointer(index1Ptr)).FlinePtr if (*TTkText)(unsafe.Pointer(peer1)).Fstart == (*TTkTextIndex)(unsafe.Pointer(index2Ptr)).FlinePtr { (*TTkText)(unsafe.Pointer(peer1)).Fstart = (*TTkTextIndex)(unsafe.Pointer(index1Ptr)).FlinePtr } if (*TTkText)(unsafe.Pointer(peer1)).Fend == (*TTkTextIndex)(unsafe.Pointer(index2Ptr)).FlinePtr { (*TTkText)(unsafe.Pointer(peer1)).Fend = (*TTkTextIndex)(unsafe.Pointer(index1Ptr)).FlinePtr } } checkCount1++ } } libtcl9_0.XTcl_Free(tls, (*TTkTextLine)(unsafe.Pointer((*TTkTextIndex)(unsafe.Pointer(index2Ptr)).FlinePtr)).Fpixels) libtcl9_0.XTcl_Free(tls, (*TTkTextIndex)(unsafe.Pointer(index2Ptr)).FlinePtr) _Rebalance(tls, (*TTkTextIndex)(unsafe.Pointer(index2Ptr)).Ftree, curNodePtr) } /* * Cleanup the segments in the new line. */ _CleanupLine(tls, (*TTkTextIndex)(unsafe.Pointer(index1Ptr)).FlinePtr) /* * This line now needs to have its height recalculated. For safety, ensure * we don't call this function with the last artificial line of text. I * _believe_ that it isn't possible to get this far with the last line, * but it is good to be safe. */ if XTkBTreeNextLine(tls, libc.UintptrFromInt32(0), (*TTkTextIndex)(unsafe.Pointer(index1Ptr)).FlinePtr) != libc.UintptrFromInt32(0) { XTkTextInvalidateLineMetrics(tls, (*TBTree)(unsafe.Pointer(treePtr)).FsharedTextPtr, libc.UintptrFromInt32(0), (*TTkTextIndex)(unsafe.Pointer(index1Ptr)).FlinePtr, changeToLineCount, int32(TK_TEXT_INVALIDATE_DELETE)) } /* * Lastly, rebalance the first node of the range. */ _Rebalance(tls, (*TTkTextIndex)(unsafe.Pointer(index1Ptr)).Ftree, (*TTkTextLine)(unsafe.Pointer((*TTkTextIndex)(unsafe.Pointer(index1Ptr)).FlinePtr)).FparentPtr) if XtkBTreeDebug != 0 { XTkBTreeCheck(tls, (*TTkTextIndex)(unsafe.Pointer(index1Ptr)).Ftree) } } /* *---------------------------------------------------------------------- * * TkBTreeFindLine -- * * Find a particular line in a B-tree based on its line number. * * Results: * The return value is a pointer to the line structure for the line whose * index is "line", or NULL if no such line exists. * * Side effects: * None. * *---------------------------------------------------------------------- */ func XTkBTreeFindLine(tls *libc.TLS, tree TTkTextBTree, textPtr uintptr, line int32) (r uintptr) { /* Index of desired line. */ var linePtr, nodePtr, treePtr uintptr _, _, _ = linePtr, nodePtr, treePtr treePtr = tree if treePtr == libc.UintptrFromInt32(0) { treePtr = (*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).Ftree } nodePtr = (*TBTree)(unsafe.Pointer(treePtr)).FrootPtr if line < 0 || line >= (*TNode)(unsafe.Pointer(nodePtr)).FnumLines { return libc.UintptrFromInt32(0) } /* * Check for any start/end offset for this text widget. */ if textPtr != libc.UintptrFromInt32(0) { if (*TTkText)(unsafe.Pointer(textPtr)).Fstart != libc.UintptrFromInt32(0) { line += XTkBTreeLinesTo(tls, libc.UintptrFromInt32(0), (*TTkText)(unsafe.Pointer(textPtr)).Fstart) if line >= (*TNode)(unsafe.Pointer(nodePtr)).FnumLines { return libc.UintptrFromInt32(0) } } if (*TTkText)(unsafe.Pointer(textPtr)).Fend != libc.UintptrFromInt32(0) { if line > XTkBTreeLinesTo(tls, libc.UintptrFromInt32(0), (*TTkText)(unsafe.Pointer(textPtr)).Fend) { return libc.UintptrFromInt32(0) } } } /* * Work down through levels of the tree until a node is found at level 0. */ for (*TNode)(unsafe.Pointer(nodePtr)).Flevel != 0 { nodePtr = *(*uintptr)(unsafe.Pointer(nodePtr + 32)) for { if !((*TNode)(unsafe.Pointer(nodePtr)).FnumLines <= line) { break } if nodePtr == libc.UintptrFromInt32(0) { libtcl9_0.XTcl_Panic(tls, __ccgo_ts+44808, 0) } line -= (*TNode)(unsafe.Pointer(nodePtr)).FnumLines goto _1 _1: ; nodePtr = (*TNode)(unsafe.Pointer(nodePtr)).FnextPtr } } /* * Work through the lines attached to the level-0 node. */ linePtr = *(*uintptr)(unsafe.Pointer(nodePtr + 32)) for { if !(line > 0) { break } if linePtr == libc.UintptrFromInt32(0) { libtcl9_0.XTcl_Panic(tls, __ccgo_ts+44841, 0) } line -= int32(1) goto _2 _2: ; linePtr = (*TTkTextLine)(unsafe.Pointer(linePtr)).FnextPtr } return linePtr } /* *---------------------------------------------------------------------- * * TkBTreeFindPixelLine -- * * Find a particular line in a B-tree based on its pixel count. * * Results: * The return value is a pointer to the line structure for the line which * contains the pixel "pixels", or NULL if no such line exists. If the * first line is of height 20, then pixels 0-19 will return it, and * pixels = 20 will return the next line. * * If pixelOffset is non-NULL, it is set to the amount by which 'pixels' * exceeds the first pixel located on the returned line. This should * always be non-negative. * * Side effects: * None. * *---------------------------------------------------------------------- */ func XTkBTreeFindPixelLine(tls *libc.TLS, tree TTkTextBTree, textPtr uintptr, pixels int32, pixelOffset uintptr) (r uintptr) { /* Used to return offset. */ var lineBoundary, lineBoundary1, pixelReference int32 var linePtr, nodePtr, treePtr uintptr _, _, _, _, _, _ = lineBoundary, lineBoundary1, linePtr, nodePtr, pixelReference, treePtr treePtr = tree pixelReference = (*TTkText)(unsafe.Pointer(textPtr)).FpixelReference nodePtr = (*TBTree)(unsafe.Pointer(treePtr)).FrootPtr if pixels < 0 || pixels > *(*int32)(unsafe.Pointer((*TNode)(unsafe.Pointer(nodePtr)).FnumPixels + uintptr(pixelReference)*4)) { return libc.UintptrFromInt32(0) } if *(*int32)(unsafe.Pointer((*TNode)(unsafe.Pointer(nodePtr)).FnumPixels + uintptr(pixelReference)*4)) == 0 { libtcl9_0.XTcl_Panic(tls, __ccgo_ts+44874, 0) } /* * Work down through levels of the tree until a node is found at level 0. */ for (*TNode)(unsafe.Pointer(nodePtr)).Flevel != 0 { nodePtr = *(*uintptr)(unsafe.Pointer(nodePtr + 32)) for { if !(*(*int32)(unsafe.Pointer((*TNode)(unsafe.Pointer(nodePtr)).FnumPixels + uintptr(pixelReference)*4)) <= pixels) { break } if nodePtr == libc.UintptrFromInt32(0) { libtcl9_0.XTcl_Panic(tls, __ccgo_ts+44920, 0) } pixels -= *(*int32)(unsafe.Pointer((*TNode)(unsafe.Pointer(nodePtr)).FnumPixels + uintptr(pixelReference)*4)) goto _1 _1: ; nodePtr = (*TNode)(unsafe.Pointer(nodePtr)).FnextPtr } } /* * Work through the lines attached to the level-0 node. */ linePtr = *(*uintptr)(unsafe.Pointer(nodePtr + 32)) for { if !(*(*int32)(unsafe.Pointer((*TTkTextLine)(unsafe.Pointer(linePtr)).Fpixels + uintptr(int32(2)*pixelReference)*4)) < pixels) { break } if linePtr == libc.UintptrFromInt32(0) { libtcl9_0.XTcl_Panic(tls, __ccgo_ts+44958, 0) } pixels -= *(*int32)(unsafe.Pointer((*TTkTextLine)(unsafe.Pointer(linePtr)).Fpixels + uintptr(int32(2)*pixelReference)*4)) goto _2 _2: ; linePtr = (*TTkTextLine)(unsafe.Pointer(linePtr)).FnextPtr } /* * Check for any start/end offset for this text widget. */ if (*TTkText)(unsafe.Pointer(textPtr)).Fstart != libc.UintptrFromInt32(0) { lineBoundary = XTkBTreeLinesTo(tls, libc.UintptrFromInt32(0), (*TTkText)(unsafe.Pointer(textPtr)).Fstart) if XTkBTreeLinesTo(tls, libc.UintptrFromInt32(0), linePtr) < lineBoundary { linePtr = XTkBTreeFindLine(tls, tree, libc.UintptrFromInt32(0), lineBoundary) } } if (*TTkText)(unsafe.Pointer(textPtr)).Fend != libc.UintptrFromInt32(0) { lineBoundary1 = XTkBTreeLinesTo(tls, libc.UintptrFromInt32(0), (*TTkText)(unsafe.Pointer(textPtr)).Fend) if XTkBTreeLinesTo(tls, libc.UintptrFromInt32(0), linePtr) > lineBoundary1 { linePtr = XTkBTreeFindLine(tls, tree, libc.UintptrFromInt32(0), lineBoundary1) } } if pixelOffset != libc.UintptrFromInt32(0) && linePtr != libc.UintptrFromInt32(0) { *(*int32)(unsafe.Pointer(pixelOffset)) = pixels } return linePtr } /* *---------------------------------------------------------------------- * * TkBTreeNextLine -- * * Given an existing line in a B-tree, this function locates the next * line in the B-tree. This function is used for scanning through the * B-tree. * * Results: * The return value is a pointer to the line that immediately follows * linePtr, or NULL if there is no such line. * * Side effects: * None. * *---------------------------------------------------------------------- */ func XTkBTreeNextLine(tls *libc.TLS, textPtr uintptr, linePtr uintptr) (r uintptr) { /* Pointer to existing line in B-tree. */ var nodePtr uintptr _ = nodePtr if (*TTkTextLine)(unsafe.Pointer(linePtr)).FnextPtr != libc.UintptrFromInt32(0) { if textPtr != libc.UintptrFromInt32(0) && linePtr == (*TTkText)(unsafe.Pointer(textPtr)).Fend { return libc.UintptrFromInt32(0) } else { return (*TTkTextLine)(unsafe.Pointer(linePtr)).FnextPtr } } /* * This was the last line associated with the particular parent node. * Search up the tree for the next node, then search down from that node * to find the first line. */ nodePtr = (*TTkTextLine)(unsafe.Pointer(linePtr)).FparentPtr for { if (*TNode)(unsafe.Pointer(nodePtr)).FnextPtr != libc.UintptrFromInt32(0) { nodePtr = (*TNode)(unsafe.Pointer(nodePtr)).FnextPtr break } if (*TNode)(unsafe.Pointer(nodePtr)).FparentPtr == libc.UintptrFromInt32(0) { return libc.UintptrFromInt32(0) } goto _1 _1: ; nodePtr = (*TNode)(unsafe.Pointer(nodePtr)).FparentPtr } for (*TNode)(unsafe.Pointer(nodePtr)).Flevel > 0 { nodePtr = *(*uintptr)(unsafe.Pointer(nodePtr + 32)) } return *(*uintptr)(unsafe.Pointer(nodePtr + 32)) } /* *---------------------------------------------------------------------- * * TkBTreePreviousLine -- * * Given an existing line in a B-tree, this function locates the previous * line in the B-tree. This function is used for scanning through the * B-tree in the reverse direction. * * Results: * The return value is a pointer to the line that immediately preceeds * linePtr, or NULL if there is no such line. * * Side effects: * None. * *---------------------------------------------------------------------- */ func XTkBTreePreviousLine(tls *libc.TLS, textPtr uintptr, linePtr uintptr) (r uintptr) { /* Pointer to existing line in B-tree. */ var node2Ptr, nodePtr, prevPtr uintptr _, _, _ = node2Ptr, nodePtr, prevPtr if textPtr != libc.UintptrFromInt32(0) && (*TTkText)(unsafe.Pointer(textPtr)).Fstart == linePtr { return libc.UintptrFromInt32(0) } /* * Find the line under this node just before the starting line. */ prevPtr = *(*uintptr)(unsafe.Pointer((*TTkTextLine)(unsafe.Pointer(linePtr)).FparentPtr + 32)) /* First line at leaf. */ for prevPtr != linePtr { if (*TTkTextLine)(unsafe.Pointer(prevPtr)).FnextPtr == linePtr { return prevPtr } prevPtr = (*TTkTextLine)(unsafe.Pointer(prevPtr)).FnextPtr if prevPtr == libc.UintptrFromInt32(0) { libtcl9_0.XTcl_Panic(tls, __ccgo_ts+44996, 0) } } /* * This was the first line associated with the particular parent node. * Search up the tree for the previous node, then search down from that * node to find its last line. */ nodePtr = (*TTkTextLine)(unsafe.Pointer(linePtr)).FparentPtr for { if nodePtr == libc.UintptrFromInt32(0) || (*TNode)(unsafe.Pointer(nodePtr)).FparentPtr == libc.UintptrFromInt32(0) { return libc.UintptrFromInt32(0) } if nodePtr != *(*uintptr)(unsafe.Pointer((*TNode)(unsafe.Pointer(nodePtr)).FparentPtr + 32)) { break } goto _1 _1: ; nodePtr = (*TNode)(unsafe.Pointer(nodePtr)).FparentPtr } node2Ptr = *(*uintptr)(unsafe.Pointer((*TNode)(unsafe.Pointer(nodePtr)).FparentPtr + 32)) for { for (*TNode)(unsafe.Pointer(node2Ptr)).FnextPtr != nodePtr { node2Ptr = (*TNode)(unsafe.Pointer(node2Ptr)).FnextPtr } if (*TNode)(unsafe.Pointer(node2Ptr)).Flevel == 0 { break } nodePtr = libc.UintptrFromInt32(0) goto _2 _2: ; node2Ptr = *(*uintptr)(unsafe.Pointer(node2Ptr + 32)) } prevPtr = *(*uintptr)(unsafe.Pointer(node2Ptr + 32)) for { if (*TTkTextLine)(unsafe.Pointer(prevPtr)).FnextPtr == libc.UintptrFromInt32(0) { return prevPtr } goto _3 _3: ; prevPtr = (*TTkTextLine)(unsafe.Pointer(prevPtr)).FnextPtr } return r } /* *---------------------------------------------------------------------- * * TkBTreePixelsTo -- * * Given a pointer to a line in a B-tree, return the numerical pixel * index of the top of that line (i.e. the result does not include the * height of the given line). * * Since the last line of text (the artificial one) has zero height by * definition, calling this with the last line will return the total * number of pixels in the widget. * * Results: * The result is the pixel height of the top of the given line. * * Side effects: * None. * *---------------------------------------------------------------------- */ func XTkBTreePixelsTo(tls *libc.TLS, textPtr uintptr, linePtr uintptr) (r int32) { /* Pointer to existing line in B-tree. */ var index, pixelReference int32 var linePtr2, nodePtr, nodePtr2, parentPtr uintptr _, _, _, _, _, _ = index, linePtr2, nodePtr, nodePtr2, parentPtr, pixelReference pixelReference = (*TTkText)(unsafe.Pointer(textPtr)).FpixelReference /* * First count how many pixels precede this line in its level-0 node. */ nodePtr = (*TTkTextLine)(unsafe.Pointer(linePtr)).FparentPtr index = 0 linePtr2 = *(*uintptr)(unsafe.Pointer(nodePtr + 32)) for { if !(linePtr2 != linePtr) { break } if linePtr2 == libc.UintptrFromInt32(0) { libtcl9_0.XTcl_Panic(tls, __ccgo_ts+45033, 0) } index += *(*int32)(unsafe.Pointer((*TTkTextLine)(unsafe.Pointer(linePtr2)).Fpixels + uintptr(int32(2)*pixelReference)*4)) goto _1 _1: ; linePtr2 = (*TTkTextLine)(unsafe.Pointer(linePtr2)).FnextPtr } /* * Now work up through the levels of the tree one at a time, counting how * many pixels are in nodes preceding the current node. */ parentPtr = (*TNode)(unsafe.Pointer(nodePtr)).FparentPtr for { if !(parentPtr != libc.UintptrFromInt32(0)) { break } nodePtr2 = *(*uintptr)(unsafe.Pointer(parentPtr + 32)) for { if !(nodePtr2 != nodePtr) { break } if nodePtr2 == libc.UintptrFromInt32(0) { libtcl9_0.XTcl_Panic(tls, __ccgo_ts+45068, 0) } index += *(*int32)(unsafe.Pointer((*TNode)(unsafe.Pointer(nodePtr2)).FnumPixels + uintptr(pixelReference)*4)) goto _3 _3: ; nodePtr2 = (*TNode)(unsafe.Pointer(nodePtr2)).FnextPtr } goto _2 _2: ; nodePtr = parentPtr parentPtr = (*TNode)(unsafe.Pointer(parentPtr)).FparentPtr } return index } /* *---------------------------------------------------------------------- * * TkBTreeLinesTo -- * * Given a pointer to a line in a B-tree, return the numerical index of * that line. * * Results: * The result is the index of linePtr within the tree, where 0 * corresponds to the first line in the tree. * * Side effects: * None. * *---------------------------------------------------------------------- */ func XTkBTreeLinesTo(tls *libc.TLS, textPtr uintptr, linePtr uintptr) (r int32) { /* Pointer to existing line in B-tree. */ var index, indexEnd, indexStart int32 var linePtr2, nodePtr, nodePtr2, parentPtr uintptr _, _, _, _, _, _, _ = index, indexEnd, indexStart, linePtr2, nodePtr, nodePtr2, parentPtr /* * First count how many lines precede this one in its level-0 node. */ nodePtr = (*TTkTextLine)(unsafe.Pointer(linePtr)).FparentPtr index = 0 linePtr2 = *(*uintptr)(unsafe.Pointer(nodePtr + 32)) for { if !(linePtr2 != linePtr) { break } if linePtr2 == libc.UintptrFromInt32(0) { libtcl9_0.XTcl_Panic(tls, __ccgo_ts+45103, 0) } index += int32(1) goto _1 _1: ; linePtr2 = (*TTkTextLine)(unsafe.Pointer(linePtr2)).FnextPtr } /* * Now work up through the levels of the tree one at a time, counting how * many lines are in nodes preceding the current node. */ parentPtr = (*TNode)(unsafe.Pointer(nodePtr)).FparentPtr for { if !(parentPtr != libc.UintptrFromInt32(0)) { break } nodePtr2 = *(*uintptr)(unsafe.Pointer(parentPtr + 32)) for { if !(nodePtr2 != nodePtr) { break } if nodePtr2 == libc.UintptrFromInt32(0) { libtcl9_0.XTcl_Panic(tls, __ccgo_ts+45137, 0) } index += (*TNode)(unsafe.Pointer(nodePtr2)).FnumLines goto _3 _3: ; nodePtr2 = (*TNode)(unsafe.Pointer(nodePtr2)).FnextPtr } goto _2 _2: ; nodePtr = parentPtr parentPtr = (*TNode)(unsafe.Pointer(parentPtr)).FparentPtr } if textPtr != libc.UintptrFromInt32(0) { if (*TTkText)(unsafe.Pointer(textPtr)).Fstart != libc.UintptrFromInt32(0) { indexStart = XTkBTreeLinesTo(tls, libc.UintptrFromInt32(0), (*TTkText)(unsafe.Pointer(textPtr)).Fstart) } else { indexStart = 0 } if (*TTkText)(unsafe.Pointer(textPtr)).Fend != libc.UintptrFromInt32(0) { indexEnd = XTkBTreeLinesTo(tls, libc.UintptrFromInt32(0), (*TTkText)(unsafe.Pointer(textPtr)).Fend) } else { indexEnd = XTkBTreeNumLines(tls, (*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).Ftree, libc.UintptrFromInt32(0)) } if index < indexStart { index = 0 } else { if index > indexEnd { index = XTkBTreeNumLines(tls, (*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).Ftree, textPtr) } else { index -= indexStart } } } return index } /* *---------------------------------------------------------------------- * * TkBTreeLinkSegment -- * * This function adds a new segment to a B-tree at a given location. * * Results: * None. * * Side effects: * SegPtr will be linked into its tree. * *---------------------------------------------------------------------- */ func XTkBTreeLinkSegment(tls *libc.TLS, segPtr uintptr, indexPtr uintptr) { /* Where to add segment: it gets linked in * just before the segment indicated here. */ var prevPtr uintptr _ = prevPtr prevPtr = _SplitSeg(tls, indexPtr) if prevPtr == libc.UintptrFromInt32(0) { (*TTkTextSegment)(unsafe.Pointer(segPtr)).FnextPtr = (*TTkTextLine)(unsafe.Pointer((*TTkTextIndex)(unsafe.Pointer(indexPtr)).FlinePtr)).FsegPtr (*TTkTextLine)(unsafe.Pointer((*TTkTextIndex)(unsafe.Pointer(indexPtr)).FlinePtr)).FsegPtr = segPtr } else { (*TTkTextSegment)(unsafe.Pointer(segPtr)).FnextPtr = (*TTkTextSegment)(unsafe.Pointer(prevPtr)).FnextPtr (*TTkTextSegment)(unsafe.Pointer(prevPtr)).FnextPtr = segPtr } _CleanupLine(tls, (*TTkTextIndex)(unsafe.Pointer(indexPtr)).FlinePtr) if XtkBTreeDebug != 0 { XTkBTreeCheck(tls, (*TTkTextIndex)(unsafe.Pointer(indexPtr)).Ftree) } (*TBTree)(unsafe.Pointer((*TTkTextIndex)(unsafe.Pointer(indexPtr)).Ftree)).FstateEpoch++ } /* *---------------------------------------------------------------------- * * TkBTreeUnlinkSegment -- * * This function unlinks a segment from its line in a B-tree. * * Results: * None. * * Side effects: * SegPtr will be unlinked from linePtr. The segment itself isn't * modified by this function. * *---------------------------------------------------------------------- */ func XTkBTreeUnlinkSegment(tls *libc.TLS, segPtr uintptr, linePtr uintptr) { /* Line that currently contains segment. */ var prevPtr uintptr _ = prevPtr if (*TTkTextLine)(unsafe.Pointer(linePtr)).FsegPtr == segPtr { (*TTkTextLine)(unsafe.Pointer(linePtr)).FsegPtr = (*TTkTextSegment)(unsafe.Pointer(segPtr)).FnextPtr } else { prevPtr = (*TTkTextLine)(unsafe.Pointer(linePtr)).FsegPtr for (*TTkTextSegment)(unsafe.Pointer(prevPtr)).FnextPtr != segPtr { prevPtr = (*TTkTextSegment)(unsafe.Pointer(prevPtr)).FnextPtr if prevPtr == libc.UintptrFromInt32(0) { /* * Two logical lines merged into one display line through * eliding of a newline. */ linePtr = XTkBTreeNextLine(tls, libc.UintptrFromInt32(0), linePtr) prevPtr = (*TTkTextLine)(unsafe.Pointer(linePtr)).FsegPtr } } (*TTkTextSegment)(unsafe.Pointer(prevPtr)).FnextPtr = (*TTkTextSegment)(unsafe.Pointer(segPtr)).FnextPtr } _CleanupLine(tls, linePtr) } /* *---------------------------------------------------------------------- * * TkBTreeTag -- * * Turn a given tag on or off for a given range of characters in a B-tree * of text. * * Results: * 1 if the tags on any characters in the range were changed, and zero * otherwise (i.e. if the tag was already absent (add = 0) or present * (add = 1) on the index range in question). * * Side effects: * The given tag is added to the given range of characters in the tree or * removed from all those characters, depending on the "add" argument. * The structure of the btree is modified enough that index1Ptr and * index2Ptr are no longer valid after this function returns, and the * indexes may be modified by this function. * *---------------------------------------------------------------------- */ func XTkBTreeTag(tls *libc.TLS, index1Ptr uintptr, index2Ptr uintptr, tagPtr uintptr, add int32) (r int32) { bp := tls.Alloc(80) defer tls.Free(80) /* One means add tag to the given range of * characters; zero means remove the tag from * the range. */ var anyChanges, changed, oldState int32 var cleanupLinePtr, prevPtr, segPtr, v1, v2 uintptr var _ /* search at bp+0 */ TTkTextSearch _, _, _, _, _, _, _, _ = anyChanges, changed, cleanupLinePtr, oldState, prevPtr, segPtr, v1, v2 anyChanges = 0 /* * See whether the tag is present at the start of the range. If the state * doesn't already match what we want then add a toggle there. */ oldState = XTkBTreeCharTagged(tls, index1Ptr, tagPtr) if libc.BoolInt32(add != 0)^oldState != 0 { segPtr = libtcl9_0.XTcl_Alloc(tls, uint64(libc.UintptrFromInt32(0)+24)+libc.Uint64FromInt64(16)) if add != 0 { v1 = uintptr(unsafe.Pointer(&XtkTextToggleOnType)) } else { v1 = uintptr(unsafe.Pointer(&XtkTextToggleOffType)) } (*TTkTextSegment)(unsafe.Pointer(segPtr)).FtypePtr = v1 prevPtr = _SplitSeg(tls, index1Ptr) if prevPtr == libc.UintptrFromInt32(0) { (*TTkTextSegment)(unsafe.Pointer(segPtr)).FnextPtr = (*TTkTextLine)(unsafe.Pointer((*TTkTextIndex)(unsafe.Pointer(index1Ptr)).FlinePtr)).FsegPtr (*TTkTextLine)(unsafe.Pointer((*TTkTextIndex)(unsafe.Pointer(index1Ptr)).FlinePtr)).FsegPtr = segPtr } else { (*TTkTextSegment)(unsafe.Pointer(segPtr)).FnextPtr = (*TTkTextSegment)(unsafe.Pointer(prevPtr)).FnextPtr (*TTkTextSegment)(unsafe.Pointer(prevPtr)).FnextPtr = segPtr } (*TTkTextSegment)(unsafe.Pointer(segPtr)).Fsize = 0 (*(*TTkTextToggle)(unsafe.Pointer(&(*TTkTextSegment)(unsafe.Pointer(segPtr)).Fbody))).FtagPtr = tagPtr (*(*TTkTextToggle)(unsafe.Pointer(&(*TTkTextSegment)(unsafe.Pointer(segPtr)).Fbody))).FinNodeCounts = 0 anyChanges = int32(1) } /* * Scan the range of characters and delete any internal tag transitions. * Keep track of what the old state was at the end of the range, and add a * toggle there if it's needed. */ XTkBTreeStartSearch(tls, index1Ptr, index2Ptr, tagPtr, bp) cleanupLinePtr = (*TTkTextIndex)(unsafe.Pointer(index1Ptr)).FlinePtr for XTkBTreeNextTag(tls, bp) != 0 { anyChanges = int32(1) oldState ^= int32(1) segPtr = (*(*TTkTextSearch)(unsafe.Pointer(bp))).FsegPtr prevPtr = (*TTkTextLine)(unsafe.Pointer((*(*TTkTextSearch)(unsafe.Pointer(bp))).FcurIndex.FlinePtr)).FsegPtr if prevPtr == segPtr { (*TTkTextLine)(unsafe.Pointer((*(*TTkTextSearch)(unsafe.Pointer(bp))).FcurIndex.FlinePtr)).FsegPtr = (*TTkTextSegment)(unsafe.Pointer(segPtr)).FnextPtr } else { for (*TTkTextSegment)(unsafe.Pointer(prevPtr)).FnextPtr != segPtr { prevPtr = (*TTkTextSegment)(unsafe.Pointer(prevPtr)).FnextPtr } (*TTkTextSegment)(unsafe.Pointer(prevPtr)).FnextPtr = (*TTkTextSegment)(unsafe.Pointer(segPtr)).FnextPtr } if (*(*TTkTextToggle)(unsafe.Pointer(&(*TTkTextSegment)(unsafe.Pointer(segPtr)).Fbody))).FinNodeCounts != 0 { _ChangeNodeToggleCount(tls, (*TTkTextLine)(unsafe.Pointer((*(*TTkTextSearch)(unsafe.Pointer(bp))).FcurIndex.FlinePtr)).FparentPtr, (*(*TTkTextToggle)(unsafe.Pointer(&(*TTkTextSegment)(unsafe.Pointer(segPtr)).Fbody))).FtagPtr, int64(-int32(1))) (*(*TTkTextToggle)(unsafe.Pointer(&(*TTkTextSegment)(unsafe.Pointer(segPtr)).Fbody))).FinNodeCounts = 0 changed = int32(1) } else { changed = 0 } libtcl9_0.XTcl_Free(tls, segPtr) /* * The code below is a bit tricky. After deleting a toggle we * eventually have to call CleanupLine, in order to allow character * segments to be merged together. To do this, we remember in * cleanupLinePtr a line that needs to be cleaned up, but we don't * clean it up until we've moved on to a different line. That way the * cleanup process won't goof up segPtr. */ if cleanupLinePtr != (*(*TTkTextSearch)(unsafe.Pointer(bp))).FcurIndex.FlinePtr { _CleanupLine(tls, cleanupLinePtr) cleanupLinePtr = (*(*TTkTextSearch)(unsafe.Pointer(bp))).FcurIndex.FlinePtr } /* * Quick hack. ChangeNodeToggleCount may move the tag's root location * around and leave the search in the void. This resets the search. */ if changed != 0 { XTkBTreeStartSearch(tls, index1Ptr, index2Ptr, tagPtr, bp) } } if libc.BoolInt32(add != 0)^oldState != 0 { segPtr = libtcl9_0.XTcl_Alloc(tls, uint64(libc.UintptrFromInt32(0)+24)+libc.Uint64FromInt64(16)) if add != 0 { v2 = uintptr(unsafe.Pointer(&XtkTextToggleOffType)) } else { v2 = uintptr(unsafe.Pointer(&XtkTextToggleOnType)) } (*TTkTextSegment)(unsafe.Pointer(segPtr)).FtypePtr = v2 prevPtr = _SplitSeg(tls, index2Ptr) if prevPtr == libc.UintptrFromInt32(0) { (*TTkTextSegment)(unsafe.Pointer(segPtr)).FnextPtr = (*TTkTextLine)(unsafe.Pointer((*TTkTextIndex)(unsafe.Pointer(index2Ptr)).FlinePtr)).FsegPtr (*TTkTextLine)(unsafe.Pointer((*TTkTextIndex)(unsafe.Pointer(index2Ptr)).FlinePtr)).FsegPtr = segPtr } else { (*TTkTextSegment)(unsafe.Pointer(segPtr)).FnextPtr = (*TTkTextSegment)(unsafe.Pointer(prevPtr)).FnextPtr (*TTkTextSegment)(unsafe.Pointer(prevPtr)).FnextPtr = segPtr } (*TTkTextSegment)(unsafe.Pointer(segPtr)).Fsize = 0 (*(*TTkTextToggle)(unsafe.Pointer(&(*TTkTextSegment)(unsafe.Pointer(segPtr)).Fbody))).FtagPtr = tagPtr (*(*TTkTextToggle)(unsafe.Pointer(&(*TTkTextSegment)(unsafe.Pointer(segPtr)).Fbody))).FinNodeCounts = 0 anyChanges = int32(1) } /* * Cleanup cleanupLinePtr and the last line of the range, if these are * different. */ if anyChanges != 0 { _CleanupLine(tls, cleanupLinePtr) if cleanupLinePtr != (*TTkTextIndex)(unsafe.Pointer(index2Ptr)).FlinePtr { _CleanupLine(tls, (*TTkTextIndex)(unsafe.Pointer(index2Ptr)).FlinePtr) } (*TBTree)(unsafe.Pointer((*TTkTextIndex)(unsafe.Pointer(index1Ptr)).Ftree)).FstateEpoch++ } if XtkBTreeDebug != 0 { XTkBTreeCheck(tls, (*TTkTextIndex)(unsafe.Pointer(index1Ptr)).Ftree) } return anyChanges } /* *---------------------------------------------------------------------- * * ChangeNodeToggleCount -- * * This function increments or decrements the toggle count for a * particular tag in a particular node and all its ancestors up to the * per-tag root node. * * Results: * None. * * Side effects: * The toggle count for tag is adjusted up or down by "delta" in nodePtr. * This routine maintains the tagRootPtr that identifies the root node * for the tag, moving it up or down the tree as needed. * *---------------------------------------------------------------------- */ func _ChangeNodeToggleCount(tls *libc.TLS, nodePtr uintptr, tagPtr uintptr, delta TTcl_Size) { bp := tls.Alloc(32) defer tls.Free(32) /* Amount to add to current toggle count for * tag (may be negative). */ var node2Ptr, prevPtr, rootNodePtr, summaryPtr uintptr var rootLevel TTcl_Size _, _, _, _, _ = node2Ptr, prevPtr, rootLevel, rootNodePtr, summaryPtr /* Level of original tag root. */ *(*TTcl_Size)(unsafe.Pointer(tagPtr + 32)) += delta if (*TTkTextTag)(unsafe.Pointer(tagPtr)).FtagRootPtr == libc.UintptrFromInt32(0) { (*TTkTextTag)(unsafe.Pointer(tagPtr)).FtagRootPtr = nodePtr return } /* * Note the level of the existing root for the tag so we can detect if it * needs to be moved because of the toggle count change. */ rootLevel = (*TNode1)(unsafe.Pointer((*TTkTextTag)(unsafe.Pointer(tagPtr)).FtagRootPtr)).Flevel /* * Iterate over the node and its ancestors up to the tag root, adjusting * summary counts at each node and moving the tag's root upwards if * necessary. */ for { if !(nodePtr != (*TTkTextTag)(unsafe.Pointer(tagPtr)).FtagRootPtr) { break } /* * See if there's already an entry for this tag for this node. If so, * perhaps all we have to do is adjust its count. */ prevPtr = libc.UintptrFromInt32(0) summaryPtr = (*TNode)(unsafe.Pointer(nodePtr)).FsummaryPtr for { if !(summaryPtr != libc.UintptrFromInt32(0)) { break } if (*TSummary)(unsafe.Pointer(summaryPtr)).FtagPtr == tagPtr { break } goto _2 _2: ; prevPtr = summaryPtr summaryPtr = (*TSummary)(unsafe.Pointer(summaryPtr)).FnextPtr } if summaryPtr != libc.UintptrFromInt32(0) { *(*TTcl_Size)(unsafe.Pointer(summaryPtr + 8)) += delta if (*TSummary)(unsafe.Pointer(summaryPtr)).FtoggleCount > 0 && (*TSummary)(unsafe.Pointer(summaryPtr)).FtoggleCount < (*TTkTextTag)(unsafe.Pointer(tagPtr)).FtoggleCount { goto _1 } if (*TSummary)(unsafe.Pointer(summaryPtr)).FtoggleCount != 0 { /* * Should never find a node with max toggle count at this * point (there shouldn't have been a summary entry in the * first place). */ libtcl9_0.XTcl_Panic(tls, __ccgo_ts+45171, libc.VaList(bp+8, (*TSummary)(unsafe.Pointer(summaryPtr)).FtoggleCount, (*TTkTextTag)(unsafe.Pointer(tagPtr)).FtoggleCount)) } /* * Zero toggle count; must remove this tag from the list. */ if prevPtr == libc.UintptrFromInt32(0) { (*TNode)(unsafe.Pointer(nodePtr)).FsummaryPtr = (*TSummary)(unsafe.Pointer(summaryPtr)).FnextPtr } else { (*TSummary)(unsafe.Pointer(prevPtr)).FnextPtr = (*TSummary)(unsafe.Pointer(summaryPtr)).FnextPtr } libtcl9_0.XTcl_Free(tls, summaryPtr) } else { /* * This tag isn't currently in the summary information list. */ if rootLevel == (*TNode)(unsafe.Pointer(nodePtr)).Flevel { /* * The old tag root is at the same level in the tree as this * node, but it isn't at this node. Move the tag root up a * level, in the hopes that it will now cover this node as * well as the old root (if not, we'll move it up again the * next time through the loop). To push it up one level we * copy the original toggle count into the summary information * at the old root and change the root to its parent node. */ rootNodePtr = (*TTkTextTag)(unsafe.Pointer(tagPtr)).FtagRootPtr summaryPtr = libtcl9_0.XTcl_Alloc(tls, uint64(24)) (*TSummary)(unsafe.Pointer(summaryPtr)).FtagPtr = tagPtr (*TSummary)(unsafe.Pointer(summaryPtr)).FtoggleCount = (*TTkTextTag)(unsafe.Pointer(tagPtr)).FtoggleCount - delta (*TSummary)(unsafe.Pointer(summaryPtr)).FnextPtr = (*TNode)(unsafe.Pointer(rootNodePtr)).FsummaryPtr (*TNode)(unsafe.Pointer(rootNodePtr)).FsummaryPtr = summaryPtr rootNodePtr = (*TNode)(unsafe.Pointer(rootNodePtr)).FparentPtr rootLevel = (*TNode)(unsafe.Pointer(rootNodePtr)).Flevel (*TTkTextTag)(unsafe.Pointer(tagPtr)).FtagRootPtr = rootNodePtr } summaryPtr = libtcl9_0.XTcl_Alloc(tls, uint64(24)) (*TSummary)(unsafe.Pointer(summaryPtr)).FtagPtr = tagPtr (*TSummary)(unsafe.Pointer(summaryPtr)).FtoggleCount = delta (*TSummary)(unsafe.Pointer(summaryPtr)).FnextPtr = (*TNode)(unsafe.Pointer(nodePtr)).FsummaryPtr (*TNode)(unsafe.Pointer(nodePtr)).FsummaryPtr = summaryPtr } goto _1 _1: ; nodePtr = (*TNode)(unsafe.Pointer(nodePtr)).FparentPtr } /* * If we've decremented the toggle count, then it may be necessary to push * the tag root down one or more levels. */ if delta >= 0 { return } if (*TTkTextTag)(unsafe.Pointer(tagPtr)).FtoggleCount == 0 { (*TTkTextTag)(unsafe.Pointer(tagPtr)).FtagRootPtr = libc.UintptrFromInt32(0) return } nodePtr = (*TTkTextTag)(unsafe.Pointer(tagPtr)).FtagRootPtr for (*TNode)(unsafe.Pointer(nodePtr)).Flevel > 0 { /* * See if a single child node accounts for all of the tag's toggles. * If so, push the root down one level. */ node2Ptr = *(*uintptr)(unsafe.Pointer(nodePtr + 32)) for { if !(node2Ptr != libc.UintptrFromInt32(0)) { break } prevPtr = libc.UintptrFromInt32(0) summaryPtr = (*TNode)(unsafe.Pointer(node2Ptr)).FsummaryPtr for { if !(summaryPtr != libc.UintptrFromInt32(0)) { break } if (*TSummary)(unsafe.Pointer(summaryPtr)).FtagPtr == tagPtr { break } goto _4 _4: ; prevPtr = summaryPtr summaryPtr = (*TSummary)(unsafe.Pointer(summaryPtr)).FnextPtr } if summaryPtr == libc.UintptrFromInt32(0) { goto _3 } if (*TSummary)(unsafe.Pointer(summaryPtr)).FtoggleCount != (*TTkTextTag)(unsafe.Pointer(tagPtr)).FtoggleCount { /* * No node has all toggles, so the root is still valid. */ return } /* * This node has all the toggles, so push down the root. */ if prevPtr == libc.UintptrFromInt32(0) { (*TNode)(unsafe.Pointer(node2Ptr)).FsummaryPtr = (*TSummary)(unsafe.Pointer(summaryPtr)).FnextPtr } else { (*TSummary)(unsafe.Pointer(prevPtr)).FnextPtr = (*TSummary)(unsafe.Pointer(summaryPtr)).FnextPtr } libtcl9_0.XTcl_Free(tls, summaryPtr) (*TTkTextTag)(unsafe.Pointer(tagPtr)).FtagRootPtr = node2Ptr break goto _3 _3: ; node2Ptr = (*TNode)(unsafe.Pointer(node2Ptr)).FnextPtr } nodePtr = (*TTkTextTag)(unsafe.Pointer(tagPtr)).FtagRootPtr } } /* *---------------------------------------------------------------------- * * FindTagStart -- * * Find the start of the first range of a tag. * * Results: * The return value is a pointer to the first tag toggle segment for the * tag. This can be either a tagon or tagoff segments because of the way * TkBTreeAdd removes a tag. Sets *indexPtr to be the index of the tag * toggle. * * Side effects: * None. * *---------------------------------------------------------------------- */ func _FindTagStart(tls *libc.TLS, tree TTkTextBTree, tagPtr uintptr, indexPtr uintptr) (r uintptr) { /* Return - index information. */ var linePtr, nodePtr, segPtr, summaryPtr uintptr var offset int32 _, _, _, _, _ = linePtr, nodePtr, offset, segPtr, summaryPtr nodePtr = (*TTkTextTag)(unsafe.Pointer(tagPtr)).FtagRootPtr if nodePtr == libc.UintptrFromInt32(0) { return libc.UintptrFromInt32(0) } /* * Search from the root of the subtree that contains the tag down to the * level 0 node. */ for nodePtr != 0 && (*TNode)(unsafe.Pointer(nodePtr)).Flevel > 0 { nodePtr = *(*uintptr)(unsafe.Pointer(nodePtr + 32)) for { if !(nodePtr != libc.UintptrFromInt32(0)) { break } summaryPtr = (*TNode)(unsafe.Pointer(nodePtr)).FsummaryPtr for { if !(summaryPtr != libc.UintptrFromInt32(0)) { break } if (*TSummary)(unsafe.Pointer(summaryPtr)).FtagPtr == tagPtr { goto gotNodeWithTag } goto _2 _2: ; summaryPtr = (*TSummary)(unsafe.Pointer(summaryPtr)).FnextPtr } goto _1 _1: ; nodePtr = (*TNode)(unsafe.Pointer(nodePtr)).FnextPtr } goto gotNodeWithTag gotNodeWithTag: ; continue } if nodePtr == libc.UintptrFromInt32(0) { return libc.UintptrFromInt32(0) } /* * Work through the lines attached to the level-0 node. */ linePtr = *(*uintptr)(unsafe.Pointer(nodePtr + 32)) for { if !(linePtr != libc.UintptrFromInt32(0)) { break } offset = 0 segPtr = (*TTkTextLine)(unsafe.Pointer(linePtr)).FsegPtr for { if !(segPtr != libc.UintptrFromInt32(0)) { break } if ((*TTkTextSegment)(unsafe.Pointer(segPtr)).FtypePtr == uintptr(unsafe.Pointer(&XtkTextToggleOnType)) || (*TTkTextSegment)(unsafe.Pointer(segPtr)).FtypePtr == uintptr(unsafe.Pointer(&XtkTextToggleOffType))) && (*(*TTkTextToggle)(unsafe.Pointer(&(*TTkTextSegment)(unsafe.Pointer(segPtr)).Fbody))).FtagPtr == tagPtr { /* * It is possible that this is a tagoff tag, but that gets * cleaned up later. */ (*TTkTextIndex)(unsafe.Pointer(indexPtr)).Ftree = tree (*TTkTextIndex)(unsafe.Pointer(indexPtr)).FlinePtr = linePtr (*TTkTextIndex)(unsafe.Pointer(indexPtr)).FbyteIndex = int64(offset) return segPtr } goto _4 _4: ; offset = int32(int64(offset) + (*TTkTextSegment)(unsafe.Pointer(segPtr)).Fsize) segPtr = (*TTkTextSegment)(unsafe.Pointer(segPtr)).FnextPtr } goto _3 _3: ; linePtr = (*TTkTextLine)(unsafe.Pointer(linePtr)).FnextPtr } return libc.UintptrFromInt32(0) } /* *---------------------------------------------------------------------- * * FindTagEnd -- * * Find the end of the last range of a tag. * * Results: * The return value is a pointer to the last tag toggle segment for the * tag. This can be either a tagon or tagoff segments because of the way * TkBTreeAdd removes a tag. Sets *indexPtr to be the index of the tag * toggle. * * Side effects: * None. * *---------------------------------------------------------------------- */ func _FindTagEnd(tls *libc.TLS, tree TTkTextBTree, tagPtr uintptr, indexPtr uintptr) (r uintptr) { /* Return - index information. */ var last2SegPtr, lastLinePtr, lastNodePtr, lastSegPtr, linePtr, nodePtr, segPtr, summaryPtr uintptr var lastoffset, lastoffset2, offset int32 _, _, _, _, _, _, _, _, _, _, _ = last2SegPtr, lastLinePtr, lastNodePtr, lastSegPtr, lastoffset, lastoffset2, linePtr, nodePtr, offset, segPtr, summaryPtr nodePtr = (*TTkTextTag)(unsafe.Pointer(tagPtr)).FtagRootPtr if nodePtr == libc.UintptrFromInt32(0) { return libc.UintptrFromInt32(0) } /* * Search from the root of the subtree that contains the tag down to the * level 0 node. */ for nodePtr != 0 && (*TNode)(unsafe.Pointer(nodePtr)).Flevel > 0 { lastNodePtr = libc.UintptrFromInt32(0) nodePtr = *(*uintptr)(unsafe.Pointer(nodePtr + 32)) for { if !(nodePtr != libc.UintptrFromInt32(0)) { break } summaryPtr = (*TNode)(unsafe.Pointer(nodePtr)).FsummaryPtr for { if !(summaryPtr != libc.UintptrFromInt32(0)) { break } if (*TSummary)(unsafe.Pointer(summaryPtr)).FtagPtr == tagPtr { lastNodePtr = nodePtr break } goto _2 _2: ; summaryPtr = (*TSummary)(unsafe.Pointer(summaryPtr)).FnextPtr } goto _1 _1: ; nodePtr = (*TNode)(unsafe.Pointer(nodePtr)).FnextPtr } nodePtr = lastNodePtr } if nodePtr == libc.UintptrFromInt32(0) { return libc.UintptrFromInt32(0) } /* * Work through the lines attached to the level-0 node. */ last2SegPtr = libc.UintptrFromInt32(0) lastoffset2 = 0 lastoffset = 0 lastLinePtr = libc.UintptrFromInt32(0) linePtr = *(*uintptr)(unsafe.Pointer(nodePtr + 32)) for { if !(linePtr != libc.UintptrFromInt32(0)) { break } offset = 0 lastSegPtr = libc.UintptrFromInt32(0) segPtr = (*TTkTextLine)(unsafe.Pointer(linePtr)).FsegPtr for { if !(segPtr != libc.UintptrFromInt32(0)) { break } if ((*TTkTextSegment)(unsafe.Pointer(segPtr)).FtypePtr == uintptr(unsafe.Pointer(&XtkTextToggleOnType)) || (*TTkTextSegment)(unsafe.Pointer(segPtr)).FtypePtr == uintptr(unsafe.Pointer(&XtkTextToggleOffType))) && (*(*TTkTextToggle)(unsafe.Pointer(&(*TTkTextSegment)(unsafe.Pointer(segPtr)).Fbody))).FtagPtr == tagPtr { lastSegPtr = segPtr lastoffset = offset } goto _4 _4: ; offset = int32(int64(offset) + (*TTkTextSegment)(unsafe.Pointer(segPtr)).Fsize) segPtr = (*TTkTextSegment)(unsafe.Pointer(segPtr)).FnextPtr } if lastSegPtr != libc.UintptrFromInt32(0) { lastLinePtr = linePtr last2SegPtr = lastSegPtr lastoffset2 = lastoffset } goto _3 _3: ; linePtr = (*TTkTextLine)(unsafe.Pointer(linePtr)).FnextPtr } (*TTkTextIndex)(unsafe.Pointer(indexPtr)).Ftree = tree (*TTkTextIndex)(unsafe.Pointer(indexPtr)).FlinePtr = lastLinePtr (*TTkTextIndex)(unsafe.Pointer(indexPtr)).FbyteIndex = int64(lastoffset2) return last2SegPtr } /* *---------------------------------------------------------------------- * * TkBTreeStartSearch -- * * This function sets up a search for tag transitions involving a given * tag (or all tags) in a given range of the text. * * Results: * None. * * Side effects: * The information at *searchPtr is set up so that subsequent calls to * TkBTreeNextTag or TkBTreePrevTag will return information about the * locations of tag transitions. Note that TkBTreeNextTag or * TkBTreePrevTag must be called to get the first transition. Note: * unlike TkBTreeNextTag and TkBTreePrevTag, this routine does not * guarantee that searchPtr->curIndex is equal to *index1Ptr. It may be * greater than that if *index1Ptr is less than the first tag transition. * *---------------------------------------------------------------------- */ func XTkBTreeStartSearch(tls *libc.TLS, index1Ptr uintptr, index2Ptr uintptr, tagPtr uintptr, searchPtr uintptr) { bp := tls.Alloc(48) defer tls.Free(48) /* Where to store information about search's * progress. */ var seg0Ptr uintptr var _ /* index0 at bp+8 */ TTkTextIndex var _ /* offset at bp+0 */ TTcl_Size _ = seg0Ptr /* First segment of the tag. */ /* * Find the segment that contains the first toggle for the tag. This may * become the starting point in the search. */ seg0Ptr = _FindTagStart(tls, (*TTkTextIndex)(unsafe.Pointer(index1Ptr)).Ftree, tagPtr, bp+8) if seg0Ptr == libc.UintptrFromInt32(0) { /* * Even though there are no toggles, the display code still uses the * search curIndex, so initialize that anyway. */ (*TTkTextSearch)(unsafe.Pointer(searchPtr)).FlinesLeft = 0 (*TTkTextSearch)(unsafe.Pointer(searchPtr)).FcurIndex = *(*TTkTextIndex)(unsafe.Pointer(index1Ptr)) (*TTkTextSearch)(unsafe.Pointer(searchPtr)).FsegPtr = libc.UintptrFromInt32(0) (*TTkTextSearch)(unsafe.Pointer(searchPtr)).FnextPtr = libc.UintptrFromInt32(0) return } if XTkTextIndexCmp(tls, index1Ptr, bp+8) < 0 { /* * Adjust start of search up to the first range of the tag. */ (*TTkTextSearch)(unsafe.Pointer(searchPtr)).FcurIndex = *(*TTkTextIndex)(unsafe.Pointer(bp + 8)) (*TTkTextSearch)(unsafe.Pointer(searchPtr)).FsegPtr = libc.UintptrFromInt32(0) (*TTkTextSearch)(unsafe.Pointer(searchPtr)).FnextPtr = seg0Ptr /* Will be returned by NextTag. */ index1Ptr = bp + 8 } else { (*TTkTextSearch)(unsafe.Pointer(searchPtr)).FcurIndex = *(*TTkTextIndex)(unsafe.Pointer(index1Ptr)) (*TTkTextSearch)(unsafe.Pointer(searchPtr)).FsegPtr = libc.UintptrFromInt32(0) (*TTkTextSearch)(unsafe.Pointer(searchPtr)).FnextPtr = XTkTextIndexToSeg(tls, index1Ptr, bp) (*TTkTextSearch)(unsafe.Pointer(searchPtr)).FcurIndex.FbyteIndex -= *(*TTcl_Size)(unsafe.Pointer(bp)) } (*TTkTextSearch)(unsafe.Pointer(searchPtr)).FlastPtr = XTkTextIndexToSeg(tls, index2Ptr, libc.UintptrFromInt32(0)) (*TTkTextSearch)(unsafe.Pointer(searchPtr)).FtagPtr = tagPtr (*TTkTextSearch)(unsafe.Pointer(searchPtr)).FlinesLeft = XTkBTreeLinesTo(tls, libc.UintptrFromInt32(0), (*TTkTextIndex)(unsafe.Pointer(index2Ptr)).FlinePtr) + int32(1) - XTkBTreeLinesTo(tls, libc.UintptrFromInt32(0), (*TTkTextIndex)(unsafe.Pointer(index1Ptr)).FlinePtr) (*TTkTextSearch)(unsafe.Pointer(searchPtr)).FallTags = libc.BoolInt32(tagPtr == libc.UintptrFromInt32(0)) if (*TTkTextSearch)(unsafe.Pointer(searchPtr)).FlinesLeft == int32(1) { /* * Starting and stopping segments are in the same line; mark the * search as over immediately if the second segment is before the * first. A search does not return a toggle at the very start of the * range, unless the range is artificially moved up to index0. */ if index1Ptr == bp+8 && (*TTkTextIndex)(unsafe.Pointer(index1Ptr)).FbyteIndex > (*TTkTextIndex)(unsafe.Pointer(index2Ptr)).FbyteIndex || index1Ptr != bp+8 && (*TTkTextIndex)(unsafe.Pointer(index1Ptr)).FbyteIndex >= (*TTkTextIndex)(unsafe.Pointer(index2Ptr)).FbyteIndex { (*TTkTextSearch)(unsafe.Pointer(searchPtr)).FlinesLeft = 0 } } } /* *---------------------------------------------------------------------- * * TkBTreeStartSearchBack -- * * This function sets up a search backwards for tag transitions involving * a given tag (or all tags) in a given range of the text. In the normal * case the first index (*index1Ptr) is beyond the second index * (*index2Ptr). * * Results: * None. * * Side effects: * The information at *searchPtr is set up so that subsequent calls to * TkBTreePrevTag will return information about the locations of tag * transitions. Note that TkBTreePrevTag must be called to get the first * transition. Note: unlike TkBTreeNextTag and TkBTreePrevTag, this * routine does not guarantee that searchPtr->curIndex is equal to * *index1Ptr. It may be less than that if *index1Ptr is greater than the * last tag transition. * *---------------------------------------------------------------------- */ func XTkBTreeStartSearchBack(tls *libc.TLS, index1Ptr uintptr, index2Ptr uintptr, tagPtr uintptr, searchPtr uintptr) { bp := tls.Alloc(80) defer tls.Free(80) /* Where to store information about search's * progress. */ var seg0Ptr uintptr var _ /* backOne at bp+40 */ TTkTextIndex var _ /* index0 at bp+8 */ TTkTextIndex var _ /* offset at bp+0 */ TTcl_Size _ = seg0Ptr /* Last segment of the tag. */ /* * Find the segment that contains the last toggle for the tag. This may * become the starting point in the search. */ seg0Ptr = _FindTagEnd(tls, (*TTkTextIndex)(unsafe.Pointer(index1Ptr)).Ftree, tagPtr, bp+8) if seg0Ptr == libc.UintptrFromInt32(0) { /* * Even though there are no toggles, the display code still uses the * search curIndex, so initialize that anyway. */ (*TTkTextSearch)(unsafe.Pointer(searchPtr)).FlinesLeft = 0 (*TTkTextSearch)(unsafe.Pointer(searchPtr)).FcurIndex = *(*TTkTextIndex)(unsafe.Pointer(index1Ptr)) (*TTkTextSearch)(unsafe.Pointer(searchPtr)).FsegPtr = libc.UintptrFromInt32(0) (*TTkTextSearch)(unsafe.Pointer(searchPtr)).FnextPtr = libc.UintptrFromInt32(0) return } /* * Adjust the start of the search so it doesn't find any tag toggles * that are right at the index specified by the user. */ if XTkTextIndexCmp(tls, index1Ptr, bp+8) > 0 { (*TTkTextSearch)(unsafe.Pointer(searchPtr)).FcurIndex = *(*TTkTextIndex)(unsafe.Pointer(bp + 8)) index1Ptr = bp + 8 } else { XTkTextIndexBackChars(tls, libc.UintptrFromInt32(0), index1Ptr, int32(1), searchPtr, int32(COUNT_INDICES)) } (*TTkTextSearch)(unsafe.Pointer(searchPtr)).FsegPtr = libc.UintptrFromInt32(0) (*TTkTextSearch)(unsafe.Pointer(searchPtr)).FnextPtr = XTkTextIndexToSeg(tls, searchPtr, bp) (*TTkTextSearch)(unsafe.Pointer(searchPtr)).FcurIndex.FbyteIndex -= *(*TTcl_Size)(unsafe.Pointer(bp)) /* * Adjust the end of the search so it does find toggles that are right at * the second index specified by the user. */ if XTkBTreeLinesTo(tls, libc.UintptrFromInt32(0), (*TTkTextIndex)(unsafe.Pointer(index2Ptr)).FlinePtr) == 0 && (*TTkTextIndex)(unsafe.Pointer(index2Ptr)).FbyteIndex == 0 { *(*TTkTextIndex)(unsafe.Pointer(bp + 40)) = *(*TTkTextIndex)(unsafe.Pointer(index2Ptr)) (*TTkTextSearch)(unsafe.Pointer(searchPtr)).FlastPtr = libc.UintptrFromInt32(0) /* Signals special case for 1.0. */ } else { XTkTextIndexBackChars(tls, libc.UintptrFromInt32(0), index2Ptr, int32(1), bp+40, int32(COUNT_INDICES)) (*TTkTextSearch)(unsafe.Pointer(searchPtr)).FlastPtr = XTkTextIndexToSeg(tls, bp+40, libc.UintptrFromInt32(0)) } (*TTkTextSearch)(unsafe.Pointer(searchPtr)).FtagPtr = tagPtr (*TTkTextSearch)(unsafe.Pointer(searchPtr)).FlinesLeft = XTkBTreeLinesTo(tls, libc.UintptrFromInt32(0), (*TTkTextIndex)(unsafe.Pointer(index1Ptr)).FlinePtr) + int32(1) - XTkBTreeLinesTo(tls, libc.UintptrFromInt32(0), (*(*TTkTextIndex)(unsafe.Pointer(bp + 40))).FlinePtr) (*TTkTextSearch)(unsafe.Pointer(searchPtr)).FallTags = libc.BoolInt32(tagPtr == libc.UintptrFromInt32(0)) if (*TTkTextSearch)(unsafe.Pointer(searchPtr)).FlinesLeft == int32(1) { /* * Starting and stopping segments are in the same line; mark the * search as over immediately if the second segment is after the * first. */ if (*TTkTextIndex)(unsafe.Pointer(index1Ptr)).FbyteIndex <= (*(*TTkTextIndex)(unsafe.Pointer(bp + 40))).FbyteIndex { (*TTkTextSearch)(unsafe.Pointer(searchPtr)).FlinesLeft = 0 } } } /* *---------------------------------------------------------------------- * * TkBTreeNextTag -- * * Once a tag search has begun, successive calls to this function return * successive tag toggles. Note: it is NOT SAFE to call this function if * characters have been inserted into or deleted from the B-tree since * the call to TkBTreeStartSearch. * * Results: * The return value is 1 if another toggle was found that met the * criteria specified in the call to TkBTreeStartSearch; in this case * searchPtr->curIndex gives the toggle's position and * searchPtr->curTagPtr points to its segment. 0 is returned if no more * matching tag transitions were found; in this case searchPtr->curIndex * is the same as searchPtr->stopIndex. * * Side effects: * Information in *searchPtr is modified to update the state of the * search and indicate where the next tag toggle is located. * *---------------------------------------------------------------------- */ func XTkBTreeNextTag(tls *libc.TLS, searchPtr uintptr) (r int32) { /* Information about search in progress; must * have been set up by call to * TkBTreeStartSearch. */ var nodePtr, segPtr, summaryPtr uintptr _, _, _ = nodePtr, segPtr, summaryPtr if (*TTkTextSearch)(unsafe.Pointer(searchPtr)).FlinesLeft <= 0 { goto searchOver } /* * The outermost loop iterates over lines that may potentially contain a * relevant tag transition, starting from the current segment in the * current line. */ segPtr = (*TTkTextSearch)(unsafe.Pointer(searchPtr)).FnextPtr for int32(1) != 0 { /* * Check for more tags on the current line. */ for { if !(segPtr != libc.UintptrFromInt32(0)) { break } if segPtr == (*TTkTextSearch)(unsafe.Pointer(searchPtr)).FlastPtr { goto searchOver } if ((*TTkTextSegment)(unsafe.Pointer(segPtr)).FtypePtr == uintptr(unsafe.Pointer(&XtkTextToggleOnType)) || (*TTkTextSegment)(unsafe.Pointer(segPtr)).FtypePtr == uintptr(unsafe.Pointer(&XtkTextToggleOffType))) && ((*TTkTextSearch)(unsafe.Pointer(searchPtr)).FallTags != 0 || (*(*TTkTextToggle)(unsafe.Pointer(&(*TTkTextSegment)(unsafe.Pointer(segPtr)).Fbody))).FtagPtr == (*TTkTextSearch)(unsafe.Pointer(searchPtr)).FtagPtr) { (*TTkTextSearch)(unsafe.Pointer(searchPtr)).FsegPtr = segPtr (*TTkTextSearch)(unsafe.Pointer(searchPtr)).FnextPtr = (*TTkTextSegment)(unsafe.Pointer(segPtr)).FnextPtr (*TTkTextSearch)(unsafe.Pointer(searchPtr)).FtagPtr = (*(*TTkTextToggle)(unsafe.Pointer(&(*TTkTextSegment)(unsafe.Pointer(segPtr)).Fbody))).FtagPtr return int32(1) } (*TTkTextSearch)(unsafe.Pointer(searchPtr)).FcurIndex.FbyteIndex += (*TTkTextSegment)(unsafe.Pointer(segPtr)).Fsize goto _1 _1: ; segPtr = (*TTkTextSegment)(unsafe.Pointer(segPtr)).FnextPtr } /* * See if there are more lines associated with the current parent * node. If so, go back to the top of the loop to search the next one. */ nodePtr = (*TTkTextLine)(unsafe.Pointer((*TTkTextSearch)(unsafe.Pointer(searchPtr)).FcurIndex.FlinePtr)).FparentPtr (*TTkTextSearch)(unsafe.Pointer(searchPtr)).FcurIndex.FlinePtr = (*TTkTextLine)(unsafe.Pointer((*TTkTextSearch)(unsafe.Pointer(searchPtr)).FcurIndex.FlinePtr)).FnextPtr (*TTkTextSearch)(unsafe.Pointer(searchPtr)).FlinesLeft-- if (*TTkTextSearch)(unsafe.Pointer(searchPtr)).FlinesLeft <= 0 { goto searchOver } if (*TTkTextSearch)(unsafe.Pointer(searchPtr)).FcurIndex.FlinePtr != libc.UintptrFromInt32(0) { segPtr = (*TTkTextLine)(unsafe.Pointer((*TTkTextSearch)(unsafe.Pointer(searchPtr)).FcurIndex.FlinePtr)).FsegPtr (*TTkTextSearch)(unsafe.Pointer(searchPtr)).FcurIndex.FbyteIndex = 0 continue } if nodePtr == (*TTkTextTag)(unsafe.Pointer((*TTkTextSearch)(unsafe.Pointer(searchPtr)).FtagPtr)).FtagRootPtr { goto searchOver } /* * Search across and up through the B-tree's node hierarchy looking * for the next node that has a relevant tag transition somewhere in * its subtree. Be sure to update linesLeft as we skip over large * chunks of lines. */ for int32(1) != 0 { for (*TNode)(unsafe.Pointer(nodePtr)).FnextPtr == libc.UintptrFromInt32(0) { if (*TNode)(unsafe.Pointer(nodePtr)).FparentPtr == libc.UintptrFromInt32(0) || (*TNode)(unsafe.Pointer(nodePtr)).FparentPtr == (*TTkTextTag)(unsafe.Pointer((*TTkTextSearch)(unsafe.Pointer(searchPtr)).FtagPtr)).FtagRootPtr { goto searchOver } nodePtr = (*TNode)(unsafe.Pointer(nodePtr)).FparentPtr } nodePtr = (*TNode)(unsafe.Pointer(nodePtr)).FnextPtr summaryPtr = (*TNode)(unsafe.Pointer(nodePtr)).FsummaryPtr for { if !(summaryPtr != libc.UintptrFromInt32(0)) { break } if (*TTkTextSearch)(unsafe.Pointer(searchPtr)).FallTags != 0 || (*TSummary)(unsafe.Pointer(summaryPtr)).FtagPtr == (*TTkTextSearch)(unsafe.Pointer(searchPtr)).FtagPtr { goto gotNodeWithTag } goto _2 _2: ; summaryPtr = (*TSummary)(unsafe.Pointer(summaryPtr)).FnextPtr } *(*int32)(unsafe.Pointer(searchPtr + 64)) -= (*TNode)(unsafe.Pointer(nodePtr)).FnumLines } /* * At this point we've found a subtree that has a relevant tag * transition. Now search down (and across) through that subtree to * find the first level-0 node that has a relevant tag transition. */ goto gotNodeWithTag gotNodeWithTag: ; for (*TNode)(unsafe.Pointer(nodePtr)).Flevel > 0 { nodePtr = *(*uintptr)(unsafe.Pointer(nodePtr + 32)) for { summaryPtr = (*TNode)(unsafe.Pointer(nodePtr)).FsummaryPtr for { if !(summaryPtr != libc.UintptrFromInt32(0)) { break } if (*TTkTextSearch)(unsafe.Pointer(searchPtr)).FallTags != 0 || (*TSummary)(unsafe.Pointer(summaryPtr)).FtagPtr == (*TTkTextSearch)(unsafe.Pointer(searchPtr)).FtagPtr { /* * Would really like a multi-level continue here... */ goto nextChild } goto _4 _4: ; summaryPtr = (*TSummary)(unsafe.Pointer(summaryPtr)).FnextPtr } *(*int32)(unsafe.Pointer(searchPtr + 64)) -= (*TNode)(unsafe.Pointer(nodePtr)).FnumLines if (*TNode)(unsafe.Pointer(nodePtr)).FnextPtr == libc.UintptrFromInt32(0) { libtcl9_0.XTcl_Panic(tls, __ccgo_ts+45227, 0) } goto _3 _3: ; nodePtr = (*TNode)(unsafe.Pointer(nodePtr)).FnextPtr } goto nextChild nextChild: ; continue } /* * Now we're down to a level-0 node that contains a line that contains * a relevant tag transition. Set up line information and go back to * the beginning of the loop to search through lines. */ (*TTkTextSearch)(unsafe.Pointer(searchPtr)).FcurIndex.FlinePtr = *(*uintptr)(unsafe.Pointer(nodePtr + 32)) (*TTkTextSearch)(unsafe.Pointer(searchPtr)).FcurIndex.FbyteIndex = 0 segPtr = (*TTkTextLine)(unsafe.Pointer((*TTkTextSearch)(unsafe.Pointer(searchPtr)).FcurIndex.FlinePtr)).FsegPtr if (*TTkTextSearch)(unsafe.Pointer(searchPtr)).FlinesLeft <= 0 { goto searchOver } continue } goto searchOver searchOver: ; (*TTkTextSearch)(unsafe.Pointer(searchPtr)).FlinesLeft = 0 (*TTkTextSearch)(unsafe.Pointer(searchPtr)).FsegPtr = libc.UintptrFromInt32(0) return 0 } /* *---------------------------------------------------------------------- * * TkBTreePrevTag -- * * Once a tag search has begun, successive calls to this function return * successive tag toggles in the reverse direction. Note: it is NOT SAFE * to call this function if characters have been inserted into or deleted * from the B-tree since the call to TkBTreeStartSearch. * * Results: * The return value is 1 if another toggle was found that met the * criteria specified in the call to TkBTreeStartSearch; in this case * searchPtr->curIndex gives the toggle's position and * searchPtr->curTagPtr points to its segment. 0 is returned if no more * matching tag transitions were found; in this case searchPtr->curIndex * is the same as searchPtr->stopIndex. * * Side effects: * Information in *searchPtr is modified to update the state of the * search and indicate where the next tag toggle is located. * *---------------------------------------------------------------------- */ func XTkBTreePrevTag(tls *libc.TLS, searchPtr uintptr) (r int32) { /* Information about search in progress; must * have been set up by call to * TkBTreeStartSearch. */ var byteIndex, linesSkipped, pastLast int32 var linePtr, node2Ptr, nodePtr, prevLinePtr, prevNodePtr, prevPtr, segPtr, summaryPtr uintptr _, _, _, _, _, _, _, _, _, _, _ = byteIndex, linePtr, linesSkipped, node2Ptr, nodePtr, pastLast, prevLinePtr, prevNodePtr, prevPtr, segPtr, summaryPtr /* Saw last marker during scan. */ if (*TTkTextSearch)(unsafe.Pointer(searchPtr)).FlinesLeft <= 0 { goto searchOver } /* * The outermost loop iterates over lines that may potentially contain a * relevant tag transition, starting from the current segment in the * current line. "nextPtr" is maintained as the last segment in a line * that we can look at. */ for int32(1) != 0 { /* * Check for the last toggle before the current segment on this line. */ byteIndex = 0 if (*TTkTextSearch)(unsafe.Pointer(searchPtr)).FlastPtr == libc.UintptrFromInt32(0) { /* * Search back to the very beginning, so pastLast is irrelevent. */ pastLast = int32(1) } else { pastLast = 0 } prevPtr = libc.UintptrFromInt32(0) segPtr = (*TTkTextLine)(unsafe.Pointer((*TTkTextSearch)(unsafe.Pointer(searchPtr)).FcurIndex.FlinePtr)).FsegPtr for { if !(segPtr != libc.UintptrFromInt32(0) && segPtr != (*TTkTextSearch)(unsafe.Pointer(searchPtr)).FnextPtr) { break } if ((*TTkTextSegment)(unsafe.Pointer(segPtr)).FtypePtr == uintptr(unsafe.Pointer(&XtkTextToggleOnType)) || (*TTkTextSegment)(unsafe.Pointer(segPtr)).FtypePtr == uintptr(unsafe.Pointer(&XtkTextToggleOffType))) && ((*TTkTextSearch)(unsafe.Pointer(searchPtr)).FallTags != 0 || (*(*TTkTextToggle)(unsafe.Pointer(&(*TTkTextSegment)(unsafe.Pointer(segPtr)).Fbody))).FtagPtr == (*TTkTextSearch)(unsafe.Pointer(searchPtr)).FtagPtr) { prevPtr = segPtr (*TTkTextSearch)(unsafe.Pointer(searchPtr)).FcurIndex.FbyteIndex = int64(byteIndex) } if segPtr == (*TTkTextSearch)(unsafe.Pointer(searchPtr)).FlastPtr { prevPtr = libc.UintptrFromInt32(0) /* Segments earlier than last don't * count. */ pastLast = int32(1) } byteIndex = int32(int64(byteIndex) + (*TTkTextSegment)(unsafe.Pointer(segPtr)).Fsize) goto _1 _1: ; segPtr = (*TTkTextSegment)(unsafe.Pointer(segPtr)).FnextPtr } if prevPtr != libc.UintptrFromInt32(0) { if (*TTkTextSearch)(unsafe.Pointer(searchPtr)).FlinesLeft == int32(1) && !(pastLast != 0) { /* * We found a segment that is before the stopping index. Note * that it is OK if prevPtr == lastPtr. */ goto searchOver } (*TTkTextSearch)(unsafe.Pointer(searchPtr)).FsegPtr = prevPtr (*TTkTextSearch)(unsafe.Pointer(searchPtr)).FnextPtr = prevPtr (*TTkTextSearch)(unsafe.Pointer(searchPtr)).FtagPtr = (*(*TTkTextToggle)(unsafe.Pointer(&(*TTkTextSegment)(unsafe.Pointer(prevPtr)).Fbody))).FtagPtr return int32(1) } (*TTkTextSearch)(unsafe.Pointer(searchPtr)).FlinesLeft-- if (*TTkTextSearch)(unsafe.Pointer(searchPtr)).FlinesLeft <= 0 { goto searchOver } /* * See if there are more lines associated with the current parent * node. If so, go back to the top of the loop to search the previous * one. */ nodePtr = (*TTkTextLine)(unsafe.Pointer((*TTkTextSearch)(unsafe.Pointer(searchPtr)).FcurIndex.FlinePtr)).FparentPtr prevLinePtr = libc.UintptrFromInt32(0) linePtr = *(*uintptr)(unsafe.Pointer(nodePtr + 32)) for { if !(linePtr != libc.UintptrFromInt32(0) && linePtr != (*TTkTextSearch)(unsafe.Pointer(searchPtr)).FcurIndex.FlinePtr) { break } /* empty loop body */ goto _2 _2: ; prevLinePtr = linePtr linePtr = (*TTkTextLine)(unsafe.Pointer(linePtr)).FnextPtr } if prevLinePtr != libc.UintptrFromInt32(0) { (*TTkTextSearch)(unsafe.Pointer(searchPtr)).FcurIndex.FlinePtr = prevLinePtr (*TTkTextSearch)(unsafe.Pointer(searchPtr)).FnextPtr = libc.UintptrFromInt32(0) continue } if nodePtr == (*TTkTextTag)(unsafe.Pointer((*TTkTextSearch)(unsafe.Pointer(searchPtr)).FtagPtr)).FtagRootPtr { goto searchOver } /* * Search across and up through the B-tree's node hierarchy looking * for the previous node that has a relevant tag transition somewhere * in its subtree. The search and line counting is trickier with/out * back pointers. We'll scan all the nodes under a parent up to the * current node, searching all of them for tag state. The last one we * find, if any, is recorded in prevNodePtr, and any nodes past * prevNodePtr that don't have tag state increment linesSkipped. */ for int32(1) != 0 { prevNodePtr = libc.UintptrFromInt32(0) linesSkipped = 0 node2Ptr = *(*uintptr)(unsafe.Pointer((*TNode)(unsafe.Pointer(nodePtr)).FparentPtr + 32)) for { if !(node2Ptr != nodePtr) { break } summaryPtr = (*TNode)(unsafe.Pointer(node2Ptr)).FsummaryPtr for { if !(summaryPtr != libc.UintptrFromInt32(0)) { break } if (*TTkTextSearch)(unsafe.Pointer(searchPtr)).FallTags != 0 || (*TSummary)(unsafe.Pointer(summaryPtr)).FtagPtr == (*TTkTextSearch)(unsafe.Pointer(searchPtr)).FtagPtr { prevNodePtr = node2Ptr linesSkipped = 0 goto keepLooking } goto _4 _4: ; summaryPtr = (*TSummary)(unsafe.Pointer(summaryPtr)).FnextPtr } linesSkipped += (*TNode)(unsafe.Pointer(node2Ptr)).FnumLines goto keepLooking keepLooking: ; goto _3 goto _3 _3: ; node2Ptr = (*TNode)(unsafe.Pointer(node2Ptr)).FnextPtr } if prevNodePtr != libc.UintptrFromInt32(0) { nodePtr = prevNodePtr *(*int32)(unsafe.Pointer(searchPtr + 64)) -= linesSkipped goto gotNodeWithTag } nodePtr = (*TNode)(unsafe.Pointer(nodePtr)).FparentPtr if (*TNode)(unsafe.Pointer(nodePtr)).FparentPtr == libc.UintptrFromInt32(0) || nodePtr == (*TTkTextTag)(unsafe.Pointer((*TTkTextSearch)(unsafe.Pointer(searchPtr)).FtagPtr)).FtagRootPtr { goto searchOver } } /* * At this point we've found a subtree that has a relevant tag * transition. Now search down (and across) through that subtree to * find the last level-0 node that has a relevant tag transition. */ goto gotNodeWithTag gotNodeWithTag: ; for (*TNode)(unsafe.Pointer(nodePtr)).Flevel > 0 { linesSkipped = 0 prevNodePtr = libc.UintptrFromInt32(0) nodePtr = *(*uintptr)(unsafe.Pointer(nodePtr + 32)) for { if !(nodePtr != libc.UintptrFromInt32(0)) { break } summaryPtr = (*TNode)(unsafe.Pointer(nodePtr)).FsummaryPtr for { if !(summaryPtr != libc.UintptrFromInt32(0)) { break } if (*TTkTextSearch)(unsafe.Pointer(searchPtr)).FallTags != 0 || (*TSummary)(unsafe.Pointer(summaryPtr)).FtagPtr == (*TTkTextSearch)(unsafe.Pointer(searchPtr)).FtagPtr { prevNodePtr = nodePtr linesSkipped = 0 goto keepLooking2 } goto _6 _6: ; summaryPtr = (*TSummary)(unsafe.Pointer(summaryPtr)).FnextPtr } linesSkipped += (*TNode)(unsafe.Pointer(nodePtr)).FnumLines goto keepLooking2 keepLooking2: ; goto _5 goto _5 _5: ; nodePtr = (*TNode)(unsafe.Pointer(nodePtr)).FnextPtr } if prevNodePtr == libc.UintptrFromInt32(0) { libtcl9_0.XTcl_Panic(tls, __ccgo_ts+45275, 0) } *(*int32)(unsafe.Pointer(searchPtr + 64)) -= linesSkipped nodePtr = prevNodePtr } /* * Now we're down to a level-0 node that contains a line that contains * a relevant tag transition. Set up line information and go back to * the beginning of the loop to search through lines. We start with * the last line below the node. */ prevLinePtr = libc.UintptrFromInt32(0) linePtr = *(*uintptr)(unsafe.Pointer(nodePtr + 32)) for { if !(linePtr != libc.UintptrFromInt32(0)) { break } /* empty loop body */ goto _7 _7: ; prevLinePtr = linePtr linePtr = (*TTkTextLine)(unsafe.Pointer(linePtr)).FnextPtr } (*TTkTextSearch)(unsafe.Pointer(searchPtr)).FcurIndex.FlinePtr = prevLinePtr (*TTkTextSearch)(unsafe.Pointer(searchPtr)).FcurIndex.FbyteIndex = 0 if (*TTkTextSearch)(unsafe.Pointer(searchPtr)).FlinesLeft <= 0 { goto searchOver } continue } goto searchOver searchOver: ; (*TTkTextSearch)(unsafe.Pointer(searchPtr)).FlinesLeft = 0 (*TTkTextSearch)(unsafe.Pointer(searchPtr)).FsegPtr = libc.UintptrFromInt32(0) return 0 } /* *---------------------------------------------------------------------- * * TkBTreeCharTagged -- * * Determine whether a particular character has a particular tag. * * Results: * The return value is 1 if the given tag is in effect at the character * given by linePtr and ch, and 0 otherwise. * * Side effects: * None. * *---------------------------------------------------------------------- */ func XTkBTreeCharTagged(tls *libc.TLS, indexPtr uintptr, tagPtr uintptr) (r int32) { /* Tag of interest. */ var index, toggles int32 var nodePtr, segPtr, siblingLinePtr, siblingPtr, summaryPtr, toggleSegPtr uintptr _, _, _, _, _, _, _, _ = index, nodePtr, segPtr, siblingLinePtr, siblingPtr, summaryPtr, toggleSegPtr, toggles /* * Check for toggles for the tag in indexPtr's line but before indexPtr. * If there is one, its type indicates whether or not the character is * tagged. */ toggleSegPtr = libc.UintptrFromInt32(0) index = 0 segPtr = (*TTkTextLine)(unsafe.Pointer((*TTkTextIndex)(unsafe.Pointer(indexPtr)).FlinePtr)).FsegPtr for { if !(int64(index+int32((*TTkTextSegment)(unsafe.Pointer(segPtr)).Fsize)) <= (*TTkTextIndex)(unsafe.Pointer(indexPtr)).FbyteIndex) { break } if ((*TTkTextSegment)(unsafe.Pointer(segPtr)).FtypePtr == uintptr(unsafe.Pointer(&XtkTextToggleOnType)) || (*TTkTextSegment)(unsafe.Pointer(segPtr)).FtypePtr == uintptr(unsafe.Pointer(&XtkTextToggleOffType))) && (*(*TTkTextToggle)(unsafe.Pointer(&(*TTkTextSegment)(unsafe.Pointer(segPtr)).Fbody))).FtagPtr == tagPtr { toggleSegPtr = segPtr } goto _1 _1: ; index = int32(int64(index) + (*TTkTextSegment)(unsafe.Pointer(segPtr)).Fsize) segPtr = (*TTkTextSegment)(unsafe.Pointer(segPtr)).FnextPtr } if toggleSegPtr != libc.UintptrFromInt32(0) { return libc.BoolInt32((*TTkTextSegment)(unsafe.Pointer(toggleSegPtr)).FtypePtr == uintptr(unsafe.Pointer(&XtkTextToggleOnType))) } /* * No toggle in this line. Look for toggles for the tag in lines that are * predecessors of indexPtr->linePtr but under the same level-0 node. */ siblingLinePtr = *(*uintptr)(unsafe.Pointer((*TTkTextLine)(unsafe.Pointer((*TTkTextIndex)(unsafe.Pointer(indexPtr)).FlinePtr)).FparentPtr + 32)) for { if !(siblingLinePtr != (*TTkTextIndex)(unsafe.Pointer(indexPtr)).FlinePtr) { break } segPtr = (*TTkTextLine)(unsafe.Pointer(siblingLinePtr)).FsegPtr for { if !(segPtr != libc.UintptrFromInt32(0)) { break } if ((*TTkTextSegment)(unsafe.Pointer(segPtr)).FtypePtr == uintptr(unsafe.Pointer(&XtkTextToggleOnType)) || (*TTkTextSegment)(unsafe.Pointer(segPtr)).FtypePtr == uintptr(unsafe.Pointer(&XtkTextToggleOffType))) && (*(*TTkTextToggle)(unsafe.Pointer(&(*TTkTextSegment)(unsafe.Pointer(segPtr)).Fbody))).FtagPtr == tagPtr { toggleSegPtr = segPtr } goto _3 _3: ; segPtr = (*TTkTextSegment)(unsafe.Pointer(segPtr)).FnextPtr } goto _2 _2: ; siblingLinePtr = (*TTkTextLine)(unsafe.Pointer(siblingLinePtr)).FnextPtr } if toggleSegPtr != libc.UintptrFromInt32(0) { return libc.BoolInt32((*TTkTextSegment)(unsafe.Pointer(toggleSegPtr)).FtypePtr == uintptr(unsafe.Pointer(&XtkTextToggleOnType))) } /* * No toggle in this node. Scan upwards through the ancestors of this * node, counting the number of toggles of the given tag in siblings that * precede that node. */ toggles = 0 nodePtr = (*TTkTextLine)(unsafe.Pointer((*TTkTextIndex)(unsafe.Pointer(indexPtr)).FlinePtr)).FparentPtr for { if !((*TNode)(unsafe.Pointer(nodePtr)).FparentPtr != libc.UintptrFromInt32(0)) { break } siblingPtr = *(*uintptr)(unsafe.Pointer((*TNode)(unsafe.Pointer(nodePtr)).FparentPtr + 32)) for { if !(siblingPtr != nodePtr) { break } summaryPtr = (*TNode)(unsafe.Pointer(siblingPtr)).FsummaryPtr for { if !(summaryPtr != libc.UintptrFromInt32(0)) { break } if (*TSummary)(unsafe.Pointer(summaryPtr)).FtagPtr == tagPtr { toggles = int32(int64(toggles) + (*TSummary)(unsafe.Pointer(summaryPtr)).FtoggleCount) } goto _6 _6: ; summaryPtr = (*TSummary)(unsafe.Pointer(summaryPtr)).FnextPtr } goto _5 _5: ; siblingPtr = (*TNode)(unsafe.Pointer(siblingPtr)).FnextPtr } if nodePtr == (*TTkTextTag)(unsafe.Pointer(tagPtr)).FtagRootPtr { break } goto _4 _4: ; nodePtr = (*TNode)(unsafe.Pointer(nodePtr)).FparentPtr } /* * An odd number of toggles means that the tag is present at the given * point. */ return toggles & int32(1) } /* *---------------------------------------------------------------------- * * TkBTreeGetTags -- * * Return information about all of the tags that are associated with a * particular character in a B-tree of text. * * Results: * The return value is a malloc-ed array containing pointers to * information for each of the tags that is associated with the character * at the position given by linePtr and ch. The word at *numTagsPtr is * filled in with the number of pointers in the array. It is up to the * caller to free the array by passing it to free. If there are no tags * at the given character then a NULL pointer is returned and *numTagsPtr * will be set to 0. * * Side effects: * None. * *---------------------------------------------------------------------- */ func XTkBTreeGetTags(tls *libc.TLS, indexPtr uintptr, textPtr uintptr, numTagsPtr uintptr) (r uintptr) { bp := tls.Alloc(32) defer tls.Free(32) /* Store number of tags found at this * location. */ var dst, index, src int32 var linePtr, nodePtr, segPtr, siblingLinePtr, siblingPtr, summaryPtr, tagTextPtr uintptr var _ /* tagInfo at bp+0 */ TTagInfo _, _, _, _, _, _, _, _, _, _ = dst, index, linePtr, nodePtr, segPtr, siblingLinePtr, siblingPtr, src, summaryPtr, tagTextPtr (*(*TTagInfo)(unsafe.Pointer(bp))).FnumTags = 0 (*(*TTagInfo)(unsafe.Pointer(bp))).FarraySize = int32(NUM_TAG_INFOS) (*(*TTagInfo)(unsafe.Pointer(bp))).FtagPtrs = libtcl9_0.XTcl_Alloc(tls, libc.Uint64FromInt32(NUM_TAG_INFOS)*libc.Uint64FromInt64(8)) (*(*TTagInfo)(unsafe.Pointer(bp))).Fcounts = libtcl9_0.XTcl_Alloc(tls, libc.Uint64FromInt32(NUM_TAG_INFOS)*libc.Uint64FromInt64(4)) /* * Record tag toggles within the line of indexPtr but preceding indexPtr. */ linePtr = (*TTkTextIndex)(unsafe.Pointer(indexPtr)).FlinePtr index = 0 segPtr = (*TTkTextLine)(unsafe.Pointer(linePtr)).FsegPtr for int64(index+int32((*TTkTextSegment)(unsafe.Pointer(segPtr)).Fsize)) <= (*TTkTextIndex)(unsafe.Pointer(indexPtr)).FbyteIndex { if (*TTkTextSegment)(unsafe.Pointer(segPtr)).FtypePtr == uintptr(unsafe.Pointer(&XtkTextToggleOnType)) || (*TTkTextSegment)(unsafe.Pointer(segPtr)).FtypePtr == uintptr(unsafe.Pointer(&XtkTextToggleOffType)) { _IncCount(tls, (*(*TTkTextToggle)(unsafe.Pointer(&(*TTkTextSegment)(unsafe.Pointer(segPtr)).Fbody))).FtagPtr, int32(1), bp) } index = int32(int64(index) + (*TTkTextSegment)(unsafe.Pointer(segPtr)).Fsize) segPtr = (*TTkTextSegment)(unsafe.Pointer(segPtr)).FnextPtr if segPtr == libc.UintptrFromInt32(0) { /* * Two logical lines merged into one display line through eliding * of a newline. */ linePtr = XTkBTreeNextLine(tls, libc.UintptrFromInt32(0), linePtr) segPtr = (*TTkTextLine)(unsafe.Pointer(linePtr)).FsegPtr } } /* * Record toggles for tags in lines that are predecessors of * indexPtr->linePtr but under the same level-0 node. */ siblingLinePtr = *(*uintptr)(unsafe.Pointer((*TTkTextLine)(unsafe.Pointer((*TTkTextIndex)(unsafe.Pointer(indexPtr)).FlinePtr)).FparentPtr + 32)) for { if !(siblingLinePtr != (*TTkTextIndex)(unsafe.Pointer(indexPtr)).FlinePtr) { break } segPtr = (*TTkTextLine)(unsafe.Pointer(siblingLinePtr)).FsegPtr for { if !(segPtr != libc.UintptrFromInt32(0)) { break } if (*TTkTextSegment)(unsafe.Pointer(segPtr)).FtypePtr == uintptr(unsafe.Pointer(&XtkTextToggleOnType)) || (*TTkTextSegment)(unsafe.Pointer(segPtr)).FtypePtr == uintptr(unsafe.Pointer(&XtkTextToggleOffType)) { _IncCount(tls, (*(*TTkTextToggle)(unsafe.Pointer(&(*TTkTextSegment)(unsafe.Pointer(segPtr)).Fbody))).FtagPtr, int32(1), bp) } goto _2 _2: ; segPtr = (*TTkTextSegment)(unsafe.Pointer(segPtr)).FnextPtr } goto _1 _1: ; siblingLinePtr = (*TTkTextLine)(unsafe.Pointer(siblingLinePtr)).FnextPtr } /* * For each node in the ancestry of this line, record tag toggles for all * siblings that precede that node. */ nodePtr = (*TTkTextLine)(unsafe.Pointer((*TTkTextIndex)(unsafe.Pointer(indexPtr)).FlinePtr)).FparentPtr for { if !((*TNode)(unsafe.Pointer(nodePtr)).FparentPtr != libc.UintptrFromInt32(0)) { break } siblingPtr = *(*uintptr)(unsafe.Pointer((*TNode)(unsafe.Pointer(nodePtr)).FparentPtr + 32)) for { if !(siblingPtr != nodePtr) { break } summaryPtr = (*TNode)(unsafe.Pointer(siblingPtr)).FsummaryPtr for { if !(summaryPtr != libc.UintptrFromInt32(0)) { break } if (*TSummary)(unsafe.Pointer(summaryPtr)).FtoggleCount&int64(1) != 0 { _IncCount(tls, (*TSummary)(unsafe.Pointer(summaryPtr)).FtagPtr, int32((*TSummary)(unsafe.Pointer(summaryPtr)).FtoggleCount), bp) } goto _5 _5: ; summaryPtr = (*TSummary)(unsafe.Pointer(summaryPtr)).FnextPtr } goto _4 _4: ; siblingPtr = (*TNode)(unsafe.Pointer(siblingPtr)).FnextPtr } goto _3 _3: ; nodePtr = (*TNode)(unsafe.Pointer(nodePtr)).FparentPtr } /* * Go through the tag information and squash out all of the tags that have * even toggle counts (these tags exist before the point of interest, but * not at the desired character itself). Also squash out all tags that * don't belong to the requested widget. */ src = 0 dst = libc.Int32FromInt32(0) for { if !(src < (*(*TTagInfo)(unsafe.Pointer(bp))).FnumTags) { break } if *(*int32)(unsafe.Pointer((*(*TTagInfo)(unsafe.Pointer(bp))).Fcounts + uintptr(src)*4))&int32(1) != 0 { tagTextPtr = (*TTkTextTag)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer((*(*TTagInfo)(unsafe.Pointer(bp))).FtagPtrs + uintptr(src)*8)))).FtextPtr if tagTextPtr == libc.UintptrFromInt32(0) || textPtr == libc.UintptrFromInt32(0) || tagTextPtr == textPtr { *(*uintptr)(unsafe.Pointer((*(*TTagInfo)(unsafe.Pointer(bp))).FtagPtrs + uintptr(dst)*8)) = *(*uintptr)(unsafe.Pointer((*(*TTagInfo)(unsafe.Pointer(bp))).FtagPtrs + uintptr(src)*8)) dst++ } } goto _6 _6: ; src++ } *(*TTcl_Size)(unsafe.Pointer(numTagsPtr)) = int64(dst) libtcl9_0.XTcl_Free(tls, (*(*TTagInfo)(unsafe.Pointer(bp))).Fcounts) if dst == 0 { libtcl9_0.XTcl_Free(tls, (*(*TTagInfo)(unsafe.Pointer(bp))).FtagPtrs) return libc.UintptrFromInt32(0) } return (*(*TTagInfo)(unsafe.Pointer(bp))).FtagPtrs } /* *---------------------------------------------------------------------- * * TkTextIsElided -- * * Special case to just return information about elided attribute. * Specialized from TkBTreeGetTags(indexPtr, textPtr, numTagsPtr) and * GetStyle(textPtr, indexPtr). Just need to keep track of invisibility * settings for each priority, pick highest one active at end. * * Note that this returns all elide information up to and including the * given index (quite obviously). However, this does mean that if * indexPtr is a line-start and one then iterates from the beginning of * that line forwards, one will actually revisit the segPtrs of size zero * (for tag toggling, for example) which have already been seen here. * * For this reason we fill in the fields 'segPtr' and 'segOffset' of * elideInfo, enabling our caller easily to calculate incremental changes * from where we left off. * * Results: * Returns whether this text should be elided or not. * * Optionally returns more detailed information in elideInfo. * * Side effects: * None. * *---------------------------------------------------------------------- */ func XTkTextIsElided(tls *libc.TLS, textPtr uintptr, indexPtr uintptr, elideInfo uintptr) (r int32) { /* NULL or a pointer to a structure in which * indexPtr's elide state will be stored and * returned. */ var elide, index int32 var i TTcl_Size var infoPtr, linePtr, nodePtr, segPtr, siblingLinePtr, siblingPtr, summaryPtr, tagPtr, p7 uintptr _, _, _, _, _, _, _, _, _, _, _, _ = elide, i, index, infoPtr, linePtr, nodePtr, segPtr, siblingLinePtr, siblingPtr, summaryPtr, tagPtr, p7 tagPtr = libc.UintptrFromInt32(0) if elideInfo == libc.UintptrFromInt32(0) { infoPtr = libtcl9_0.XTcl_Alloc(tls, uint64(12056)) } else { infoPtr = elideInfo } (*TTkTextElideInfo)(unsafe.Pointer(infoPtr)).Felide = 0 /* If nobody says otherwise, it's visible. */ (*TTkTextElideInfo)(unsafe.Pointer(infoPtr)).FtagCnts = infoPtr + 36 (*TTkTextElideInfo)(unsafe.Pointer(infoPtr)).FtagPtrs = infoPtr + 4040 (*TTkTextElideInfo)(unsafe.Pointer(infoPtr)).FnumTags = (*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).FnumTags /* * Almost always avoid malloc, so stay out of system calls. */ if int64(LOTSA_TAGS) < (*TTkTextElideInfo)(unsafe.Pointer(infoPtr)).FnumTags { (*TTkTextElideInfo)(unsafe.Pointer(infoPtr)).FtagCnts = libtcl9_0.XTcl_Alloc(tls, uint64(4)*libc.Uint64FromInt64((*TTkTextElideInfo)(unsafe.Pointer(infoPtr)).FnumTags)) (*TTkTextElideInfo)(unsafe.Pointer(infoPtr)).FtagPtrs = libtcl9_0.XTcl_Alloc(tls, uint64(8)*libc.Uint64FromInt64((*TTkTextElideInfo)(unsafe.Pointer(infoPtr)).FnumTags)) } i = 0 for { if !(i < (*TTkTextElideInfo)(unsafe.Pointer(infoPtr)).FnumTags) { break } *(*int32)(unsafe.Pointer((*TTkTextElideInfo)(unsafe.Pointer(infoPtr)).FtagCnts + uintptr(i)*4)) = 0 goto _1 _1: ; i++ } /* * Record tag toggles within the line of indexPtr but preceding indexPtr. */ index = 0 linePtr = (*TTkTextIndex)(unsafe.Pointer(indexPtr)).FlinePtr segPtr = (*TTkTextLine)(unsafe.Pointer(linePtr)).FsegPtr for int64(index+int32((*TTkTextSegment)(unsafe.Pointer(segPtr)).Fsize)) <= (*TTkTextIndex)(unsafe.Pointer(indexPtr)).FbyteIndex { if (*TTkTextSegment)(unsafe.Pointer(segPtr)).FtypePtr == uintptr(unsafe.Pointer(&XtkTextToggleOnType)) || (*TTkTextSegment)(unsafe.Pointer(segPtr)).FtypePtr == uintptr(unsafe.Pointer(&XtkTextToggleOffType)) { tagPtr = (*(*TTkTextToggle)(unsafe.Pointer(&(*TTkTextSegment)(unsafe.Pointer(segPtr)).Fbody))).FtagPtr if (*TTkTextTag)(unsafe.Pointer(tagPtr)).Felide >= 0 { *(*uintptr)(unsafe.Pointer((*TTkTextElideInfo)(unsafe.Pointer(infoPtr)).FtagPtrs + uintptr((*TTkTextTag)(unsafe.Pointer(tagPtr)).Fpriority)*8)) = tagPtr *(*int32)(unsafe.Pointer((*TTkTextElideInfo)(unsafe.Pointer(infoPtr)).FtagCnts + uintptr((*TTkTextTag)(unsafe.Pointer(tagPtr)).Fpriority)*4))++ } } index = int32(int64(index) + (*TTkTextSegment)(unsafe.Pointer(segPtr)).Fsize) segPtr = (*TTkTextSegment)(unsafe.Pointer(segPtr)).FnextPtr if segPtr == libc.UintptrFromInt32(0) { /* * Two logical lines merged into one display line through eliding * of a newline. */ linePtr = XTkBTreeNextLine(tls, libc.UintptrFromInt32(0), linePtr) segPtr = (*TTkTextLine)(unsafe.Pointer(linePtr)).FsegPtr } } /* * Store the first segPtr we haven't examined completely so that our * caller knows where to start. */ (*TTkTextElideInfo)(unsafe.Pointer(infoPtr)).FsegPtr = segPtr (*TTkTextElideInfo)(unsafe.Pointer(infoPtr)).FsegOffset = index /* * Record toggles for tags in lines that are predecessors of * indexPtr->linePtr but under the same level-0 node. */ siblingLinePtr = *(*uintptr)(unsafe.Pointer((*TTkTextLine)(unsafe.Pointer((*TTkTextIndex)(unsafe.Pointer(indexPtr)).FlinePtr)).FparentPtr + 32)) for { if !(siblingLinePtr != (*TTkTextIndex)(unsafe.Pointer(indexPtr)).FlinePtr) { break } segPtr = (*TTkTextLine)(unsafe.Pointer(siblingLinePtr)).FsegPtr for { if !(segPtr != libc.UintptrFromInt32(0)) { break } if (*TTkTextSegment)(unsafe.Pointer(segPtr)).FtypePtr == uintptr(unsafe.Pointer(&XtkTextToggleOnType)) || (*TTkTextSegment)(unsafe.Pointer(segPtr)).FtypePtr == uintptr(unsafe.Pointer(&XtkTextToggleOffType)) { tagPtr = (*(*TTkTextToggle)(unsafe.Pointer(&(*TTkTextSegment)(unsafe.Pointer(segPtr)).Fbody))).FtagPtr if (*TTkTextTag)(unsafe.Pointer(tagPtr)).Felide >= 0 { *(*uintptr)(unsafe.Pointer((*TTkTextElideInfo)(unsafe.Pointer(infoPtr)).FtagPtrs + uintptr((*TTkTextTag)(unsafe.Pointer(tagPtr)).Fpriority)*8)) = tagPtr *(*int32)(unsafe.Pointer((*TTkTextElideInfo)(unsafe.Pointer(infoPtr)).FtagCnts + uintptr((*TTkTextTag)(unsafe.Pointer(tagPtr)).Fpriority)*4))++ } } goto _3 _3: ; segPtr = (*TTkTextSegment)(unsafe.Pointer(segPtr)).FnextPtr } goto _2 _2: ; siblingLinePtr = (*TTkTextLine)(unsafe.Pointer(siblingLinePtr)).FnextPtr } /* * For each node in the ancestry of this line, record tag toggles for all * siblings that precede that node. */ nodePtr = (*TTkTextLine)(unsafe.Pointer((*TTkTextIndex)(unsafe.Pointer(indexPtr)).FlinePtr)).FparentPtr for { if !((*TNode)(unsafe.Pointer(nodePtr)).FparentPtr != libc.UintptrFromInt32(0)) { break } siblingPtr = *(*uintptr)(unsafe.Pointer((*TNode)(unsafe.Pointer(nodePtr)).FparentPtr + 32)) for { if !(siblingPtr != nodePtr) { break } summaryPtr = (*TNode)(unsafe.Pointer(siblingPtr)).FsummaryPtr for { if !(summaryPtr != libc.UintptrFromInt32(0)) { break } if (*TSummary)(unsafe.Pointer(summaryPtr)).FtoggleCount&int64(1) != 0 { tagPtr = (*TSummary)(unsafe.Pointer(summaryPtr)).FtagPtr if (*TTkTextTag)(unsafe.Pointer(tagPtr)).Felide >= 0 { *(*uintptr)(unsafe.Pointer((*TTkTextElideInfo)(unsafe.Pointer(infoPtr)).FtagPtrs + uintptr((*TTkTextTag)(unsafe.Pointer(tagPtr)).Fpriority)*8)) = tagPtr p7 = (*TTkTextElideInfo)(unsafe.Pointer(infoPtr)).FtagCnts + uintptr((*TTkTextTag)(unsafe.Pointer(tagPtr)).Fpriority)*4 *(*int32)(unsafe.Pointer(p7)) = int32(int64(*(*int32)(unsafe.Pointer(p7))) + (*TSummary)(unsafe.Pointer(summaryPtr)).FtoggleCount) } } goto _6 _6: ; summaryPtr = (*TSummary)(unsafe.Pointer(summaryPtr)).FnextPtr } goto _5 _5: ; siblingPtr = (*TNode)(unsafe.Pointer(siblingPtr)).FnextPtr } goto _4 _4: ; nodePtr = (*TNode)(unsafe.Pointer(nodePtr)).FparentPtr } /* * Now traverse from highest priority to lowest, take elided value from * first odd count (= on). */ (*TTkTextElideInfo)(unsafe.Pointer(infoPtr)).FelidePriority = int64(-int32(1)) i = (*TTkTextElideInfo)(unsafe.Pointer(infoPtr)).FnumTags - int64(1) for { if !(i >= 0) { break } if *(*int32)(unsafe.Pointer((*TTkTextElideInfo)(unsafe.Pointer(infoPtr)).FtagCnts + uintptr(i)*4))&int32(1) != 0 { (*TTkTextElideInfo)(unsafe.Pointer(infoPtr)).Felide = libc.BoolInt32((*TTkTextTag)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer((*TTkTextElideInfo)(unsafe.Pointer(infoPtr)).FtagPtrs + uintptr(i)*8)))).Felide > 0) /* * Note: i == infoPtr->tagPtrs[i]->priority */ (*TTkTextElideInfo)(unsafe.Pointer(infoPtr)).FelidePriority = i break } goto _8 _8: ; i-- } elide = (*TTkTextElideInfo)(unsafe.Pointer(infoPtr)).Felide if elideInfo == libc.UintptrFromInt32(0) { if int64(LOTSA_TAGS) < (*TTkTextElideInfo)(unsafe.Pointer(infoPtr)).FnumTags { libtcl9_0.XTcl_Free(tls, (*TTkTextElideInfo)(unsafe.Pointer(infoPtr)).FtagCnts) libtcl9_0.XTcl_Free(tls, (*TTkTextElideInfo)(unsafe.Pointer(infoPtr)).FtagPtrs) } libtcl9_0.XTcl_Free(tls, infoPtr) } return elide } /* *---------------------------------------------------------------------- * * TkTextFreeElideInfo -- * * This is a utility function used to free up any memory allocated by the * TkTextIsElided function above. * * Results: * None. * * Side effects: * Memory may be freed. * *---------------------------------------------------------------------- */ func XTkTextFreeElideInfo(tls *libc.TLS, elideInfo uintptr) { /* Free any allocated memory in this * structure. */ if int64(LOTSA_TAGS) < (*TTkTextElideInfo)(unsafe.Pointer(elideInfo)).FnumTags { libtcl9_0.XTcl_Free(tls, (*TTkTextElideInfo)(unsafe.Pointer(elideInfo)).FtagCnts) libtcl9_0.XTcl_Free(tls, (*TTkTextElideInfo)(unsafe.Pointer(elideInfo)).FtagPtrs) } } /* *---------------------------------------------------------------------- * * IncCount -- * * This is a utility function used by TkBTreeGetTags. It increments the * count for a particular tag, adding a new entry for that tag if there * wasn't one previously. * * Results: * None. * * Side effects: * The information at *tagInfoPtr may be modified, and the arrays may be * reallocated to make them larger. * *---------------------------------------------------------------------- */ func _IncCount(tls *libc.TLS, tagPtr uintptr, inc int32, tagInfoPtr uintptr) { /* Holds cumulative information about tags; * increment count here. */ var count, newSize int32 var newCounts, newTags, tagPtrPtr uintptr _, _, _, _, _ = count, newCounts, newSize, newTags, tagPtrPtr tagPtrPtr = (*TTagInfo)(unsafe.Pointer(tagInfoPtr)).FtagPtrs count = (*TTagInfo)(unsafe.Pointer(tagInfoPtr)).FnumTags for { if !(count > 0) { break } if *(*uintptr)(unsafe.Pointer(tagPtrPtr)) == tagPtr { *(*int32)(unsafe.Pointer((*TTagInfo)(unsafe.Pointer(tagInfoPtr)).Fcounts + uintptr((*TTagInfo)(unsafe.Pointer(tagInfoPtr)).FnumTags-count)*4)) += inc return } goto _1 _1: ; tagPtrPtr += 8 count-- } /* * There isn't currently an entry for this tag, so we have to make a new * one. If the arrays are full, then enlarge the arrays first. */ if (*TTagInfo)(unsafe.Pointer(tagInfoPtr)).FnumTags == (*TTagInfo)(unsafe.Pointer(tagInfoPtr)).FarraySize { newSize = int32(2) * (*TTagInfo)(unsafe.Pointer(tagInfoPtr)).FarraySize newTags = libtcl9_0.XTcl_Alloc(tls, libc.Uint64FromInt32(newSize)*uint64(8)) libc.Xmemcpy(tls, newTags, (*TTagInfo)(unsafe.Pointer(tagInfoPtr)).FtagPtrs, libc.Uint64FromInt32((*TTagInfo)(unsafe.Pointer(tagInfoPtr)).FarraySize)*uint64(8)) libtcl9_0.XTcl_Free(tls, (*TTagInfo)(unsafe.Pointer(tagInfoPtr)).FtagPtrs) (*TTagInfo)(unsafe.Pointer(tagInfoPtr)).FtagPtrs = newTags newCounts = libtcl9_0.XTcl_Alloc(tls, libc.Uint64FromInt32(newSize)*uint64(4)) libc.Xmemcpy(tls, newCounts, (*TTagInfo)(unsafe.Pointer(tagInfoPtr)).Fcounts, libc.Uint64FromInt32((*TTagInfo)(unsafe.Pointer(tagInfoPtr)).FarraySize)*uint64(4)) libtcl9_0.XTcl_Free(tls, (*TTagInfo)(unsafe.Pointer(tagInfoPtr)).Fcounts) (*TTagInfo)(unsafe.Pointer(tagInfoPtr)).Fcounts = newCounts (*TTagInfo)(unsafe.Pointer(tagInfoPtr)).FarraySize = newSize } *(*uintptr)(unsafe.Pointer((*TTagInfo)(unsafe.Pointer(tagInfoPtr)).FtagPtrs + uintptr((*TTagInfo)(unsafe.Pointer(tagInfoPtr)).FnumTags)*8)) = tagPtr *(*int32)(unsafe.Pointer((*TTagInfo)(unsafe.Pointer(tagInfoPtr)).Fcounts + uintptr((*TTagInfo)(unsafe.Pointer(tagInfoPtr)).FnumTags)*4)) = inc (*TTagInfo)(unsafe.Pointer(tagInfoPtr)).FnumTags++ } /* *---------------------------------------------------------------------- * * TkBTreeCheck -- * * This function runs a set of consistency checks over a B-tree and * panics if any inconsistencies are found. * * Results: * None. * * Side effects: * If a structural defect is found, the function panics with an error * message. * *---------------------------------------------------------------------- */ func XTkBTreeCheck(tls *libc.TLS, tree TTkTextBTree) { bp := tls.Alloc(64) defer tls.Free(64) /* Tree to check. */ var count TTcl_Size var entryPtr, linePtr, nodePtr, segPtr, summaryPtr, tagPtr, treePtr uintptr var _ /* search at bp+0 */ TTcl_HashSearch _, _, _, _, _, _, _, _ = count, entryPtr, linePtr, nodePtr, segPtr, summaryPtr, tagPtr, treePtr treePtr = tree /* * Make sure that the tag toggle counts and the tag root pointers are OK. */ entryPtr = libtcl9_0.XTcl_FirstHashEntry(tls, (*TBTree)(unsafe.Pointer(treePtr)).FsharedTextPtr+16, bp) for { if !(entryPtr != libc.UintptrFromInt32(0)) { break } tagPtr = (*TTcl_HashEntry)(unsafe.Pointer(entryPtr)).FclientData nodePtr = (*TTkTextTag)(unsafe.Pointer(tagPtr)).FtagRootPtr if nodePtr == libc.UintptrFromInt32(0) { if (*TTkTextTag)(unsafe.Pointer(tagPtr)).FtoggleCount != 0 { libtcl9_0.XTcl_Panic(tls, __ccgo_ts+45323, libc.VaList(bp+32, (*TTkTextTag)(unsafe.Pointer(tagPtr)).Fname, (*TTkTextTag)(unsafe.Pointer(tagPtr)).FtoggleCount)) } goto _1 /* No ranges for the tag. */ } else { if (*TTkTextTag)(unsafe.Pointer(tagPtr)).FtoggleCount == 0 { libtcl9_0.XTcl_Panic(tls, __ccgo_ts+45378, libc.VaList(bp+32, (*TTkTextTag)(unsafe.Pointer(tagPtr)).Fname)) } else { if (*TTkTextTag)(unsafe.Pointer(tagPtr)).FtoggleCount&int64(1) != 0 { libtcl9_0.XTcl_Panic(tls, __ccgo_ts+45427, libc.VaList(bp+32, (*TTkTextTag)(unsafe.Pointer(tagPtr)).Fname, (*TTkTextTag)(unsafe.Pointer(tagPtr)).FtoggleCount)) } } } summaryPtr = (*TNode)(unsafe.Pointer(nodePtr)).FsummaryPtr for { if !(summaryPtr != libc.UintptrFromInt32(0)) { break } if (*TSummary)(unsafe.Pointer(summaryPtr)).FtagPtr == tagPtr { libtcl9_0.XTcl_Panic(tls, __ccgo_ts+45478, 0) } goto _2 _2: ; summaryPtr = (*TSummary)(unsafe.Pointer(summaryPtr)).FnextPtr } count = 0 if (*TNode)(unsafe.Pointer(nodePtr)).Flevel > 0 { nodePtr = *(*uintptr)(unsafe.Pointer(nodePtr + 32)) for { if !(nodePtr != libc.UintptrFromInt32(0)) { break } summaryPtr = (*TNode)(unsafe.Pointer(nodePtr)).FsummaryPtr for { if !(summaryPtr != libc.UintptrFromInt32(0)) { break } if (*TSummary)(unsafe.Pointer(summaryPtr)).FtagPtr == tagPtr { count += (*TSummary)(unsafe.Pointer(summaryPtr)).FtoggleCount } goto _4 _4: ; summaryPtr = (*TSummary)(unsafe.Pointer(summaryPtr)).FnextPtr } goto _3 _3: ; nodePtr = (*TNode)(unsafe.Pointer(nodePtr)).FnextPtr } } else { linePtr = *(*uintptr)(unsafe.Pointer(nodePtr + 32)) for { if !(linePtr != libc.UintptrFromInt32(0)) { break } segPtr = (*TTkTextLine)(unsafe.Pointer(linePtr)).FsegPtr for { if !(segPtr != libc.UintptrFromInt32(0)) { break } if ((*TTkTextSegment)(unsafe.Pointer(segPtr)).FtypePtr == uintptr(unsafe.Pointer(&XtkTextToggleOnType)) || (*TTkTextSegment)(unsafe.Pointer(segPtr)).FtypePtr == uintptr(unsafe.Pointer(&XtkTextToggleOffType))) && (*(*TTkTextToggle)(unsafe.Pointer(&(*TTkTextSegment)(unsafe.Pointer(segPtr)).Fbody))).FtagPtr == tagPtr { count++ } goto _6 _6: ; segPtr = (*TTkTextSegment)(unsafe.Pointer(segPtr)).FnextPtr } goto _5 _5: ; linePtr = (*TTkTextLine)(unsafe.Pointer(linePtr)).FnextPtr } } if count != (*TTkTextTag)(unsafe.Pointer(tagPtr)).FtoggleCount { libtcl9_0.XTcl_Panic(tls, __ccgo_ts+45525, libc.VaList(bp+32, (*TTkTextTag)(unsafe.Pointer(tagPtr)).FtoggleCount, (*TTkTextTag)(unsafe.Pointer(tagPtr)).Fname, count)) } goto _1 _1: ; entryPtr = libtcl9_0.XTcl_NextHashEntry(tls, bp) } /* * Call a recursive function to do the main body of checks. */ nodePtr = (*TBTree)(unsafe.Pointer(treePtr)).FrootPtr _CheckNodeConsistency(tls, (*TBTree)(unsafe.Pointer(treePtr)).FrootPtr, (*TBTree)(unsafe.Pointer(treePtr)).FpixelReferences) /* * Make sure that there are at least two lines in the text and that the * last line has no characters except a newline. */ if (*TNode)(unsafe.Pointer(nodePtr)).FnumLines < int32(2) { libtcl9_0.XTcl_Panic(tls, __ccgo_ts+45587, 0) } for (*TNode)(unsafe.Pointer(nodePtr)).Flevel > 0 { nodePtr = *(*uintptr)(unsafe.Pointer(nodePtr + 32)) for (*TNode)(unsafe.Pointer(nodePtr)).FnextPtr != libc.UintptrFromInt32(0) { nodePtr = (*TNode)(unsafe.Pointer(nodePtr)).FnextPtr } } linePtr = *(*uintptr)(unsafe.Pointer(nodePtr + 32)) for (*TTkTextLine)(unsafe.Pointer(linePtr)).FnextPtr != libc.UintptrFromInt32(0) { linePtr = (*TTkTextLine)(unsafe.Pointer(linePtr)).FnextPtr } segPtr = (*TTkTextLine)(unsafe.Pointer(linePtr)).FsegPtr for (*TTkTextSegment)(unsafe.Pointer(segPtr)).FtypePtr == uintptr(unsafe.Pointer(&XtkTextToggleOffType)) || (*TTkTextSegment)(unsafe.Pointer(segPtr)).FtypePtr == uintptr(unsafe.Pointer(&XtkTextRightMarkType)) || (*TTkTextSegment)(unsafe.Pointer(segPtr)).FtypePtr == uintptr(unsafe.Pointer(&XtkTextLeftMarkType)) { /* * It's OK to toggle a tag off in the last line, but not to start a * new range. It's also OK to have marks in the last line. */ segPtr = (*TTkTextSegment)(unsafe.Pointer(segPtr)).FnextPtr } if (*TTkTextSegment)(unsafe.Pointer(segPtr)).FtypePtr != uintptr(unsafe.Pointer(&XtkTextCharType)) { libtcl9_0.XTcl_Panic(tls, __ccgo_ts+45627, 0) } if (*TTkTextSegment)(unsafe.Pointer(segPtr)).FnextPtr != libc.UintptrFromInt32(0) { libtcl9_0.XTcl_Panic(tls, __ccgo_ts+45674, 0) } if (*TTkTextSegment)(unsafe.Pointer(segPtr)).Fsize != int64(1) { libtcl9_0.XTcl_Panic(tls, __ccgo_ts+45720, libc.VaList(bp+32, int32((*TTkTextSegment)(unsafe.Pointer(segPtr)).Fsize))) } if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(segPtr + 24))) != int32('\n') || libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(segPtr + 24 + 1))) != 0 { libtcl9_0.XTcl_Panic(tls, __ccgo_ts+45771, libc.VaList(bp+32, segPtr+24)) } } /* *---------------------------------------------------------------------- * * CheckNodeConsistency -- * * This function is called as part of consistency checking for B-trees: * it checks several aspects of a node and also runs checks recursively * on the node's children. * * Results: * None. * * Side effects: * If anything suspicious is found in the tree structure, the function * panics. * *---------------------------------------------------------------------- */ func _CheckNodeConsistency(tls *libc.TLS, nodePtr uintptr, references int32) { bp := tls.Alloc(64) defer tls.Free(64) /* Number of referring widgets which have * pixel counts. */ var childNodePtr, linePtr, numPixels, segPtr, summaryPtr, summaryPtr2 uintptr var i, minChildren, numChildren, numLines int32 var toggleCount TTcl_Size var _ /* pixels at bp+0 */ [5]int32 _, _, _, _, _, _, _, _, _, _, _ = childNodePtr, i, linePtr, minChildren, numChildren, numLines, numPixels, segPtr, summaryPtr, summaryPtr2, toggleCount if (*TNode)(unsafe.Pointer(nodePtr)).FparentPtr != libc.UintptrFromInt32(0) { minChildren = int32(MIN_CHILDREN) } else { if (*TNode)(unsafe.Pointer(nodePtr)).Flevel > 0 { minChildren = int32(2) } else { minChildren = int32(1) } } if (*TNode)(unsafe.Pointer(nodePtr)).FnumChildren < minChildren || (*TNode)(unsafe.Pointer(nodePtr)).FnumChildren > int32(MAX_CHILDREN) { libtcl9_0.XTcl_Panic(tls, __ccgo_ts+45813, libc.VaList(bp+32, (*TNode)(unsafe.Pointer(nodePtr)).FnumChildren)) } numChildren = 0 numLines = 0 if references > int32(PIXEL_CLIENTS) { numPixels = libtcl9_0.XTcl_Alloc(tls, uint64(4)*libc.Uint64FromInt32(references)) } else { numPixels = bp } i = 0 for { if !(i < references) { break } *(*int32)(unsafe.Pointer(numPixels + uintptr(i)*4)) = 0 goto _1 _1: ; i++ } if (*TNode)(unsafe.Pointer(nodePtr)).Flevel == 0 { linePtr = *(*uintptr)(unsafe.Pointer(nodePtr + 32)) for { if !(linePtr != libc.UintptrFromInt32(0)) { break } if (*TTkTextLine)(unsafe.Pointer(linePtr)).FparentPtr != nodePtr { libtcl9_0.XTcl_Panic(tls, __ccgo_ts+45856, 0) } if (*TTkTextLine)(unsafe.Pointer(linePtr)).FsegPtr == libc.UintptrFromInt32(0) { libtcl9_0.XTcl_Panic(tls, __ccgo_ts+45907, 0) } segPtr = (*TTkTextLine)(unsafe.Pointer(linePtr)).FsegPtr for { if !(segPtr != libc.UintptrFromInt32(0)) { break } if (*TTk_SegType1)(unsafe.Pointer((*TTkTextSegment)(unsafe.Pointer(segPtr)).FtypePtr)).FcheckProc != libc.UintptrFromInt32(0) { (*(*func(*libc.TLS, uintptr, uintptr))(unsafe.Pointer(&struct{ uintptr }{(*TTk_SegType1)(unsafe.Pointer((*TTkTextSegment)(unsafe.Pointer(segPtr)).FtypePtr)).FcheckProc})))(tls, segPtr, linePtr) } if (*TTkTextSegment)(unsafe.Pointer(segPtr)).Fsize == 0 && !((*TTk_SegType1)(unsafe.Pointer((*TTkTextSegment)(unsafe.Pointer(segPtr)).FtypePtr)).FleftGravity != 0) && (*TTkTextSegment)(unsafe.Pointer(segPtr)).FnextPtr != libc.UintptrFromInt32(0) && (*TTkTextSegment1)(unsafe.Pointer((*TTkTextSegment)(unsafe.Pointer(segPtr)).FnextPtr)).Fsize == 0 && (*TTk_SegType1)(unsafe.Pointer((*TTkTextSegment1)(unsafe.Pointer((*TTkTextSegment)(unsafe.Pointer(segPtr)).FnextPtr)).FtypePtr)).FleftGravity != 0 { libtcl9_0.XTcl_Panic(tls, __ccgo_ts+45950, 0) } if (*TTkTextSegment)(unsafe.Pointer(segPtr)).FnextPtr == libc.UintptrFromInt32(0) && (*TTkTextSegment)(unsafe.Pointer(segPtr)).FtypePtr != uintptr(unsafe.Pointer(&XtkTextCharType)) { libtcl9_0.XTcl_Panic(tls, __ccgo_ts+46004, 0) } goto _3 _3: ; segPtr = (*TTkTextSegment)(unsafe.Pointer(segPtr)).FnextPtr } numChildren++ numLines++ i = 0 for { if !(i < references) { break } *(*int32)(unsafe.Pointer(numPixels + uintptr(i)*4)) += *(*int32)(unsafe.Pointer((*TTkTextLine)(unsafe.Pointer(linePtr)).Fpixels + uintptr(int32(2)*i)*4)) goto _4 _4: ; i++ } goto _2 _2: ; linePtr = (*TTkTextLine)(unsafe.Pointer(linePtr)).FnextPtr } } else { childNodePtr = *(*uintptr)(unsafe.Pointer(nodePtr + 32)) for { if !(childNodePtr != libc.UintptrFromInt32(0)) { break } if (*TNode)(unsafe.Pointer(childNodePtr)).FparentPtr != nodePtr { libtcl9_0.XTcl_Panic(tls, __ccgo_ts+46053, 0) } if (*TNode)(unsafe.Pointer(childNodePtr)).Flevel != (*TNode)(unsafe.Pointer(nodePtr)).Flevel-int64(1) { libtcl9_0.XTcl_Panic(tls, __ccgo_ts+46104, libc.VaList(bp+32, (*TNode)(unsafe.Pointer(nodePtr)).Flevel, (*TNode)(unsafe.Pointer(childNodePtr)).Flevel)) } _CheckNodeConsistency(tls, childNodePtr, references) summaryPtr = (*TNode)(unsafe.Pointer(childNodePtr)).FsummaryPtr for { if !(summaryPtr != libc.UintptrFromInt32(0)) { break } summaryPtr2 = (*TNode)(unsafe.Pointer(nodePtr)).FsummaryPtr for { if summaryPtr2 == libc.UintptrFromInt32(0) { if (*TTkTextTag)(unsafe.Pointer((*TSummary)(unsafe.Pointer(summaryPtr)).FtagPtr)).FtagRootPtr == nodePtr { break } libtcl9_0.XTcl_Panic(tls, __ccgo_ts+46151, libc.VaList(bp+32, (*TTkTextTag)(unsafe.Pointer((*TSummary)(unsafe.Pointer(summaryPtr)).FtagPtr)).Fname, __ccgo_ts+46194)) } if (*TSummary)(unsafe.Pointer(summaryPtr)).FtagPtr == (*TSummary)(unsafe.Pointer(summaryPtr2)).FtagPtr { break } goto _7 _7: ; summaryPtr2 = (*TSummary)(unsafe.Pointer(summaryPtr2)).FnextPtr } goto _6 _6: ; summaryPtr = (*TSummary)(unsafe.Pointer(summaryPtr)).FnextPtr } numChildren++ numLines += (*TNode)(unsafe.Pointer(childNodePtr)).FnumLines i = 0 for { if !(i < references) { break } *(*int32)(unsafe.Pointer(numPixels + uintptr(i)*4)) += *(*int32)(unsafe.Pointer((*TNode)(unsafe.Pointer(childNodePtr)).FnumPixels + uintptr(i)*4)) goto _8 _8: ; i++ } goto _5 _5: ; childNodePtr = (*TNode)(unsafe.Pointer(childNodePtr)).FnextPtr } } if numChildren != (*TNode)(unsafe.Pointer(nodePtr)).FnumChildren { libtcl9_0.XTcl_Panic(tls, __ccgo_ts+46222, libc.VaList(bp+32, numChildren, (*TNode)(unsafe.Pointer(nodePtr)).FnumChildren)) } if numLines != (*TNode)(unsafe.Pointer(nodePtr)).FnumLines { libtcl9_0.XTcl_Panic(tls, __ccgo_ts+46276, libc.VaList(bp+32, numLines, (*TNode)(unsafe.Pointer(nodePtr)).FnumLines)) } i = 0 for { if !(i < references) { break } if *(*int32)(unsafe.Pointer(numPixels + uintptr(i)*4)) != *(*int32)(unsafe.Pointer((*TNode)(unsafe.Pointer(nodePtr)).FnumPixels + uintptr(i)*4)) { libtcl9_0.XTcl_Panic(tls, __ccgo_ts+46327, libc.VaList(bp+32, *(*int32)(unsafe.Pointer(numPixels + uintptr(i)*4)), *(*int32)(unsafe.Pointer((*TNode)(unsafe.Pointer(nodePtr)).FnumPixels + uintptr(i)*4)), i)) } goto _9 _9: ; i++ } if references > int32(PIXEL_CLIENTS) { libtcl9_0.XTcl_Free(tls, numPixels) } summaryPtr = (*TNode)(unsafe.Pointer(nodePtr)).FsummaryPtr for { if !(summaryPtr != libc.UintptrFromInt32(0)) { break } if (*TTkTextTag)(unsafe.Pointer((*TSummary)(unsafe.Pointer(summaryPtr)).FtagPtr)).FtoggleCount == (*TSummary)(unsafe.Pointer(summaryPtr)).FtoggleCount { libtcl9_0.XTcl_Panic(tls, __ccgo_ts+46395, libc.VaList(bp+32, (*TTkTextTag)(unsafe.Pointer((*TSummary)(unsafe.Pointer(summaryPtr)).FtagPtr)).Fname)) } toggleCount = 0 if (*TNode)(unsafe.Pointer(nodePtr)).Flevel == 0 { linePtr = *(*uintptr)(unsafe.Pointer(nodePtr + 32)) for { if !(linePtr != libc.UintptrFromInt32(0)) { break } segPtr = (*TTkTextLine)(unsafe.Pointer(linePtr)).FsegPtr for { if !(segPtr != libc.UintptrFromInt32(0)) { break } if (*TTkTextSegment)(unsafe.Pointer(segPtr)).FtypePtr != uintptr(unsafe.Pointer(&XtkTextToggleOnType)) && (*TTkTextSegment)(unsafe.Pointer(segPtr)).FtypePtr != uintptr(unsafe.Pointer(&XtkTextToggleOffType)) { goto _12 } if (*(*TTkTextToggle)(unsafe.Pointer(&(*TTkTextSegment)(unsafe.Pointer(segPtr)).Fbody))).FtagPtr == (*TSummary)(unsafe.Pointer(summaryPtr)).FtagPtr { toggleCount++ } goto _12 _12: ; segPtr = (*TTkTextSegment)(unsafe.Pointer(segPtr)).FnextPtr } goto _11 _11: ; linePtr = (*TTkTextLine)(unsafe.Pointer(linePtr)).FnextPtr } } else { childNodePtr = *(*uintptr)(unsafe.Pointer(nodePtr + 32)) for { if !(childNodePtr != libc.UintptrFromInt32(0)) { break } summaryPtr2 = (*TNode)(unsafe.Pointer(childNodePtr)).FsummaryPtr for { if !(summaryPtr2 != libc.UintptrFromInt32(0)) { break } if (*TSummary)(unsafe.Pointer(summaryPtr2)).FtagPtr == (*TSummary)(unsafe.Pointer(summaryPtr)).FtagPtr { toggleCount += (*TSummary)(unsafe.Pointer(summaryPtr2)).FtoggleCount } goto _14 _14: ; summaryPtr2 = (*TSummary)(unsafe.Pointer(summaryPtr2)).FnextPtr } goto _13 _13: ; childNodePtr = (*TNode)(unsafe.Pointer(childNodePtr)).FnextPtr } } if toggleCount != (*TSummary)(unsafe.Pointer(summaryPtr)).FtoggleCount { libtcl9_0.XTcl_Panic(tls, __ccgo_ts+46446, libc.VaList(bp+32, toggleCount, (*TSummary)(unsafe.Pointer(summaryPtr)).FtoggleCount)) } summaryPtr2 = (*TSummary)(unsafe.Pointer(summaryPtr)).FnextPtr for { if !(summaryPtr2 != libc.UintptrFromInt32(0)) { break } if (*TSummary)(unsafe.Pointer(summaryPtr2)).FtagPtr == (*TSummary)(unsafe.Pointer(summaryPtr)).FtagPtr { libtcl9_0.XTcl_Panic(tls, __ccgo_ts+46502, libc.VaList(bp+32, (*TTkTextTag)(unsafe.Pointer((*TSummary)(unsafe.Pointer(summaryPtr)).FtagPtr)).Fname)) } goto _15 _15: ; summaryPtr2 = (*TSummary)(unsafe.Pointer(summaryPtr2)).FnextPtr } goto _10 _10: ; summaryPtr = (*TSummary)(unsafe.Pointer(summaryPtr)).FnextPtr } } /* *---------------------------------------------------------------------- * * Rebalance -- * * This function is called when a node of a B-tree appears to be out of * balance (too many children, or too few). It rebalances that node and * all of its ancestors in the tree. * * Results: * None. * * Side effects: * The internal structure of treePtr may change. * *---------------------------------------------------------------------- */ func _Rebalance(tls *libc.TLS, treePtr uintptr, nodePtr uintptr) { /* Node that may be out of balance. */ var childPtr, halfwayLinePtr, halfwayNodePtr, linePtr, newPtr, otherPtr uintptr var firstChildren, i, totalChildren int32 _, _, _, _, _, _, _, _, _ = childPtr, firstChildren, halfwayLinePtr, halfwayNodePtr, i, linePtr, newPtr, otherPtr, totalChildren /* * Loop over the entire ancestral chain of the node, working up through * the tree one node at a time until the root node has been processed. */ for { if !(nodePtr != libc.UintptrFromInt32(0)) { break } /* * Check to see if the node has too many children. If it does, then * split off all but the first MIN_CHILDREN into a separate node * following the original one. Then repeat until the node has a decent * size. */ if (*TNode)(unsafe.Pointer(nodePtr)).FnumChildren > int32(MAX_CHILDREN) { for int32(1) != 0 { /* * If the node being split is the root node, then make a new * root node above it first. */ if (*TNode)(unsafe.Pointer(nodePtr)).FparentPtr == libc.UintptrFromInt32(0) { newPtr = libtcl9_0.XTcl_Alloc(tls, uint64(56)) (*TNode)(unsafe.Pointer(newPtr)).FparentPtr = libc.UintptrFromInt32(0) (*TNode)(unsafe.Pointer(newPtr)).FnextPtr = libc.UintptrFromInt32(0) (*TNode)(unsafe.Pointer(newPtr)).FsummaryPtr = libc.UintptrFromInt32(0) (*TNode)(unsafe.Pointer(newPtr)).Flevel = (*TNode)(unsafe.Pointer(nodePtr)).Flevel + int64(1) *(*uintptr)(unsafe.Pointer(newPtr + 32)) = nodePtr (*TNode)(unsafe.Pointer(newPtr)).FnumChildren = int32(1) (*TNode)(unsafe.Pointer(newPtr)).FnumLines = (*TNode)(unsafe.Pointer(nodePtr)).FnumLines (*TNode)(unsafe.Pointer(newPtr)).FnumPixels = libtcl9_0.XTcl_Alloc(tls, uint64(4)*libc.Uint64FromInt32((*TBTree)(unsafe.Pointer(treePtr)).FpixelReferences)) i = 0 for { if !(i < (*TBTree)(unsafe.Pointer(treePtr)).FpixelReferences) { break } *(*int32)(unsafe.Pointer((*TNode)(unsafe.Pointer(newPtr)).FnumPixels + uintptr(i)*4)) = *(*int32)(unsafe.Pointer((*TNode)(unsafe.Pointer(nodePtr)).FnumPixels + uintptr(i)*4)) goto _2 _2: ; i++ } _RecomputeNodeCounts(tls, treePtr, newPtr) (*TBTree)(unsafe.Pointer(treePtr)).FrootPtr = newPtr } newPtr = libtcl9_0.XTcl_Alloc(tls, uint64(56)) (*TNode)(unsafe.Pointer(newPtr)).FnumPixels = libtcl9_0.XTcl_Alloc(tls, uint64(4)*libc.Uint64FromInt32((*TBTree)(unsafe.Pointer(treePtr)).FpixelReferences)) i = 0 for { if !(i < (*TBTree)(unsafe.Pointer(treePtr)).FpixelReferences) { break } *(*int32)(unsafe.Pointer((*TNode)(unsafe.Pointer(newPtr)).FnumPixels + uintptr(i)*4)) = 0 goto _3 _3: ; i++ } (*TNode)(unsafe.Pointer(newPtr)).FparentPtr = (*TNode)(unsafe.Pointer(nodePtr)).FparentPtr (*TNode)(unsafe.Pointer(newPtr)).FnextPtr = (*TNode)(unsafe.Pointer(nodePtr)).FnextPtr (*TNode)(unsafe.Pointer(nodePtr)).FnextPtr = newPtr (*TNode)(unsafe.Pointer(newPtr)).FsummaryPtr = libc.UintptrFromInt32(0) (*TNode)(unsafe.Pointer(newPtr)).Flevel = (*TNode)(unsafe.Pointer(nodePtr)).Flevel (*TNode)(unsafe.Pointer(newPtr)).FnumChildren = (*TNode)(unsafe.Pointer(nodePtr)).FnumChildren - int32(MIN_CHILDREN) if (*TNode)(unsafe.Pointer(nodePtr)).Flevel == 0 { i = libc.Int32FromInt32(MIN_CHILDREN) - libc.Int32FromInt32(1) linePtr = *(*uintptr)(unsafe.Pointer(nodePtr + 32)) for { if !(i > 0) { break } /* Empty loop body. */ goto _4 _4: ; i-- linePtr = (*TTkTextLine)(unsafe.Pointer(linePtr)).FnextPtr } *(*uintptr)(unsafe.Pointer(newPtr + 32)) = (*TTkTextLine)(unsafe.Pointer(linePtr)).FnextPtr (*TTkTextLine)(unsafe.Pointer(linePtr)).FnextPtr = libc.UintptrFromInt32(0) } else { i = libc.Int32FromInt32(MIN_CHILDREN) - libc.Int32FromInt32(1) childPtr = *(*uintptr)(unsafe.Pointer(nodePtr + 32)) for { if !(i > 0) { break } /* Empty loop body. */ goto _5 _5: ; i-- childPtr = (*TNode)(unsafe.Pointer(childPtr)).FnextPtr } *(*uintptr)(unsafe.Pointer(newPtr + 32)) = (*TNode)(unsafe.Pointer(childPtr)).FnextPtr (*TNode)(unsafe.Pointer(childPtr)).FnextPtr = libc.UintptrFromInt32(0) } _RecomputeNodeCounts(tls, treePtr, nodePtr) (*TNode1)(unsafe.Pointer((*TNode)(unsafe.Pointer(nodePtr)).FparentPtr)).FnumChildren++ nodePtr = newPtr if (*TNode)(unsafe.Pointer(nodePtr)).FnumChildren <= int32(MAX_CHILDREN) { _RecomputeNodeCounts(tls, treePtr, nodePtr) break } } } for (*TNode)(unsafe.Pointer(nodePtr)).FnumChildren < int32(MIN_CHILDREN) { halfwayNodePtr = libc.UintptrFromInt32(0) /* Initialization needed only */ halfwayLinePtr = libc.UintptrFromInt32(0) /* * Too few children for this node. If this is the root then, it's * OK for it to have less than MIN_CHILDREN children as long as * it's got at least two. If it has only one (and isn't at level * 0), then chop the root node out of the tree and use its child * as the new root. */ if (*TNode)(unsafe.Pointer(nodePtr)).FparentPtr == libc.UintptrFromInt32(0) { if (*TNode)(unsafe.Pointer(nodePtr)).FnumChildren == int32(1) && (*TNode)(unsafe.Pointer(nodePtr)).Flevel > 0 { (*TBTree)(unsafe.Pointer(treePtr)).FrootPtr = *(*uintptr)(unsafe.Pointer(nodePtr + 32)) (*TNode)(unsafe.Pointer((*TBTree)(unsafe.Pointer(treePtr)).FrootPtr)).FparentPtr = libc.UintptrFromInt32(0) _DeleteSummaries(tls, (*TNode)(unsafe.Pointer(nodePtr)).FsummaryPtr) libtcl9_0.XTcl_Free(tls, (*TNode)(unsafe.Pointer(nodePtr)).FnumPixels) libtcl9_0.XTcl_Free(tls, nodePtr) } return } /* * Not the root. Make sure that there are siblings to balance * with. */ if (*TNode1)(unsafe.Pointer((*TNode)(unsafe.Pointer(nodePtr)).FparentPtr)).FnumChildren < int32(2) { _Rebalance(tls, treePtr, (*TNode)(unsafe.Pointer(nodePtr)).FparentPtr) continue } /* * Find a sibling neighbor to borrow from, and arrange for nodePtr * to be the earlier of the pair. */ if (*TNode)(unsafe.Pointer(nodePtr)).FnextPtr == libc.UintptrFromInt32(0) { otherPtr = *(*uintptr)(unsafe.Pointer((*TNode)(unsafe.Pointer(nodePtr)).FparentPtr + 32)) for { if !((*TNode)(unsafe.Pointer(otherPtr)).FnextPtr != nodePtr) { break } /* Empty loop body. */ goto _6 _6: ; otherPtr = (*TNode)(unsafe.Pointer(otherPtr)).FnextPtr } nodePtr = otherPtr } otherPtr = (*TNode)(unsafe.Pointer(nodePtr)).FnextPtr /* * We're going to either merge the two siblings together into one * node or redivide the children among them to balance their * loads. As preparation, join their two child lists into a single * list and remember the half-way point in the list. */ totalChildren = (*TNode)(unsafe.Pointer(nodePtr)).FnumChildren + (*TNode)(unsafe.Pointer(otherPtr)).FnumChildren firstChildren = totalChildren / int32(2) if *(*uintptr)(unsafe.Pointer(nodePtr + 32)) == libc.UintptrFromInt32(0) { (*TNode)(unsafe.Pointer(nodePtr)).Fchildren = (*TNode)(unsafe.Pointer(otherPtr)).Fchildren *(*uintptr)(unsafe.Pointer(otherPtr + 32)) = libc.UintptrFromInt32(0) *(*uintptr)(unsafe.Pointer(otherPtr + 32)) = libc.UintptrFromInt32(0) } if (*TNode)(unsafe.Pointer(nodePtr)).Flevel == 0 { linePtr = *(*uintptr)(unsafe.Pointer(nodePtr + 32)) i = libc.Int32FromInt32(1) for { if !((*TTkTextLine)(unsafe.Pointer(linePtr)).FnextPtr != libc.UintptrFromInt32(0)) { break } if i == firstChildren { halfwayLinePtr = linePtr } goto _7 _7: ; linePtr = (*TTkTextLine)(unsafe.Pointer(linePtr)).FnextPtr i++ } (*TTkTextLine)(unsafe.Pointer(linePtr)).FnextPtr = *(*uintptr)(unsafe.Pointer(otherPtr + 32)) for i <= firstChildren { halfwayLinePtr = linePtr linePtr = (*TTkTextLine)(unsafe.Pointer(linePtr)).FnextPtr i++ } } else { childPtr = *(*uintptr)(unsafe.Pointer(nodePtr + 32)) i = libc.Int32FromInt32(1) for { if !((*TNode)(unsafe.Pointer(childPtr)).FnextPtr != libc.UintptrFromInt32(0)) { break } if i <= firstChildren { if i == firstChildren { halfwayNodePtr = childPtr } } goto _8 _8: ; childPtr = (*TNode)(unsafe.Pointer(childPtr)).FnextPtr i++ } (*TNode)(unsafe.Pointer(childPtr)).FnextPtr = *(*uintptr)(unsafe.Pointer(otherPtr + 32)) for i <= firstChildren { halfwayNodePtr = childPtr childPtr = (*TNode)(unsafe.Pointer(childPtr)).FnextPtr i++ } } /* * If the two siblings can simply be merged together, do it. */ if totalChildren <= int32(MAX_CHILDREN) { _RecomputeNodeCounts(tls, treePtr, nodePtr) (*TNode)(unsafe.Pointer(nodePtr)).FnextPtr = (*TNode)(unsafe.Pointer(otherPtr)).FnextPtr (*TNode1)(unsafe.Pointer((*TNode)(unsafe.Pointer(nodePtr)).FparentPtr)).FnumChildren-- _DeleteSummaries(tls, (*TNode)(unsafe.Pointer(otherPtr)).FsummaryPtr) libtcl9_0.XTcl_Free(tls, (*TNode)(unsafe.Pointer(otherPtr)).FnumPixels) libtcl9_0.XTcl_Free(tls, otherPtr) continue } /* * The siblings can't be merged, so just divide their children * evenly between them. */ if (*TNode)(unsafe.Pointer(nodePtr)).Flevel == 0 { *(*uintptr)(unsafe.Pointer(otherPtr + 32)) = (*TTkTextLine)(unsafe.Pointer(halfwayLinePtr)).FnextPtr (*TTkTextLine)(unsafe.Pointer(halfwayLinePtr)).FnextPtr = libc.UintptrFromInt32(0) } else { *(*uintptr)(unsafe.Pointer(otherPtr + 32)) = (*TNode)(unsafe.Pointer(halfwayNodePtr)).FnextPtr (*TNode)(unsafe.Pointer(halfwayNodePtr)).FnextPtr = libc.UintptrFromInt32(0) } _RecomputeNodeCounts(tls, treePtr, nodePtr) _RecomputeNodeCounts(tls, treePtr, otherPtr) } goto _1 _1: ; nodePtr = (*TNode)(unsafe.Pointer(nodePtr)).FparentPtr } } /* *---------------------------------------------------------------------- * * RecomputeNodeCounts -- * * This function is called to recompute all the counts in a node (tags, * child information, etc.) by scanning the information in its * descendants. This function is called during rebalancing when a node's * child structure has changed. * * Results: * None. * * Side effects: * The tag counts for nodePtr are modified to reflect its current child * structure, as are its numChildren and numLines fields. Also, all of * the childrens' parentPtr fields are made to point to nodePtr. * *---------------------------------------------------------------------- */ func _RecomputeNodeCounts(tls *libc.TLS, treePtr uintptr, nodePtr uintptr) { /* Node whose tag summary information must be * recomputed. */ var childPtr, linePtr, segPtr, summaryPtr, summaryPtr2, tagPtr uintptr var ref int32 _, _, _, _, _, _, _ = childPtr, linePtr, ref, segPtr, summaryPtr, summaryPtr2, tagPtr /* * Zero out all the existing counts for the node, but don't delete the * existing Summary records (most of them will probably be reused). */ summaryPtr = (*TNode)(unsafe.Pointer(nodePtr)).FsummaryPtr for { if !(summaryPtr != libc.UintptrFromInt32(0)) { break } (*TSummary)(unsafe.Pointer(summaryPtr)).FtoggleCount = 0 goto _1 _1: ; summaryPtr = (*TSummary)(unsafe.Pointer(summaryPtr)).FnextPtr } (*TNode)(unsafe.Pointer(nodePtr)).FnumChildren = 0 (*TNode)(unsafe.Pointer(nodePtr)).FnumLines = 0 ref = 0 for { if !(ref < (*TBTree)(unsafe.Pointer(treePtr)).FpixelReferences) { break } *(*int32)(unsafe.Pointer((*TNode)(unsafe.Pointer(nodePtr)).FnumPixels + uintptr(ref)*4)) = 0 goto _2 _2: ; ref++ } /* * Scan through the children, adding the childrens' tag counts into the * node's tag counts and adding new Summary structures if necessary. */ if (*TNode)(unsafe.Pointer(nodePtr)).Flevel == 0 { linePtr = *(*uintptr)(unsafe.Pointer(nodePtr + 32)) for { if !(linePtr != libc.UintptrFromInt32(0)) { break } (*TNode)(unsafe.Pointer(nodePtr)).FnumChildren++ (*TNode)(unsafe.Pointer(nodePtr)).FnumLines++ ref = 0 for { if !(ref < (*TBTree)(unsafe.Pointer(treePtr)).FpixelReferences) { break } *(*int32)(unsafe.Pointer((*TNode)(unsafe.Pointer(nodePtr)).FnumPixels + uintptr(ref)*4)) += *(*int32)(unsafe.Pointer((*TTkTextLine)(unsafe.Pointer(linePtr)).Fpixels + uintptr(int32(2)*ref)*4)) goto _4 _4: ; ref++ } (*TTkTextLine)(unsafe.Pointer(linePtr)).FparentPtr = nodePtr segPtr = (*TTkTextLine)(unsafe.Pointer(linePtr)).FsegPtr for { if !(segPtr != libc.UintptrFromInt32(0)) { break } if (*TTkTextSegment)(unsafe.Pointer(segPtr)).FtypePtr != uintptr(unsafe.Pointer(&XtkTextToggleOnType)) && (*TTkTextSegment)(unsafe.Pointer(segPtr)).FtypePtr != uintptr(unsafe.Pointer(&XtkTextToggleOffType)) || !((*(*TTkTextToggle)(unsafe.Pointer(&(*TTkTextSegment)(unsafe.Pointer(segPtr)).Fbody))).FinNodeCounts != 0) { goto _5 } tagPtr = (*(*TTkTextToggle)(unsafe.Pointer(&(*TTkTextSegment)(unsafe.Pointer(segPtr)).Fbody))).FtagPtr summaryPtr = (*TNode)(unsafe.Pointer(nodePtr)).FsummaryPtr for { if summaryPtr == libc.UintptrFromInt32(0) { summaryPtr = libtcl9_0.XTcl_Alloc(tls, uint64(24)) (*TSummary)(unsafe.Pointer(summaryPtr)).FtagPtr = tagPtr (*TSummary)(unsafe.Pointer(summaryPtr)).FtoggleCount = int64(1) (*TSummary)(unsafe.Pointer(summaryPtr)).FnextPtr = (*TNode)(unsafe.Pointer(nodePtr)).FsummaryPtr (*TNode)(unsafe.Pointer(nodePtr)).FsummaryPtr = summaryPtr break } if (*TSummary)(unsafe.Pointer(summaryPtr)).FtagPtr == tagPtr { (*TSummary)(unsafe.Pointer(summaryPtr)).FtoggleCount++ break } goto _6 _6: ; summaryPtr = (*TSummary)(unsafe.Pointer(summaryPtr)).FnextPtr } goto _5 _5: ; segPtr = (*TTkTextSegment)(unsafe.Pointer(segPtr)).FnextPtr } goto _3 _3: ; linePtr = (*TTkTextLine)(unsafe.Pointer(linePtr)).FnextPtr } } else { childPtr = *(*uintptr)(unsafe.Pointer(nodePtr + 32)) for { if !(childPtr != libc.UintptrFromInt32(0)) { break } (*TNode)(unsafe.Pointer(nodePtr)).FnumChildren++ *(*int32)(unsafe.Pointer(nodePtr + 44)) += (*TNode)(unsafe.Pointer(childPtr)).FnumLines ref = 0 for { if !(ref < (*TBTree)(unsafe.Pointer(treePtr)).FpixelReferences) { break } *(*int32)(unsafe.Pointer((*TNode)(unsafe.Pointer(nodePtr)).FnumPixels + uintptr(ref)*4)) += *(*int32)(unsafe.Pointer((*TNode)(unsafe.Pointer(childPtr)).FnumPixels + uintptr(ref)*4)) goto _8 _8: ; ref++ } (*TNode)(unsafe.Pointer(childPtr)).FparentPtr = nodePtr summaryPtr2 = (*TNode)(unsafe.Pointer(childPtr)).FsummaryPtr for { if !(summaryPtr2 != libc.UintptrFromInt32(0)) { break } summaryPtr = (*TNode)(unsafe.Pointer(nodePtr)).FsummaryPtr for { if summaryPtr == libc.UintptrFromInt32(0) { summaryPtr = libtcl9_0.XTcl_Alloc(tls, uint64(24)) (*TSummary)(unsafe.Pointer(summaryPtr)).FtagPtr = (*TSummary)(unsafe.Pointer(summaryPtr2)).FtagPtr (*TSummary)(unsafe.Pointer(summaryPtr)).FtoggleCount = (*TSummary)(unsafe.Pointer(summaryPtr2)).FtoggleCount (*TSummary)(unsafe.Pointer(summaryPtr)).FnextPtr = (*TNode)(unsafe.Pointer(nodePtr)).FsummaryPtr (*TNode)(unsafe.Pointer(nodePtr)).FsummaryPtr = summaryPtr break } if (*TSummary)(unsafe.Pointer(summaryPtr)).FtagPtr == (*TSummary)(unsafe.Pointer(summaryPtr2)).FtagPtr { *(*TTcl_Size)(unsafe.Pointer(summaryPtr + 8)) += (*TSummary)(unsafe.Pointer(summaryPtr2)).FtoggleCount break } goto _10 _10: ; summaryPtr = (*TSummary)(unsafe.Pointer(summaryPtr)).FnextPtr } goto _9 _9: ; summaryPtr2 = (*TSummary)(unsafe.Pointer(summaryPtr2)).FnextPtr } goto _7 _7: ; childPtr = (*TNode)(unsafe.Pointer(childPtr)).FnextPtr } } /* * Scan through the node's tag records again and delete any Summary * records that still have a zero count, or that have all the toggles. * The node with the children that account for all the tags toggles have * no summary information, and they become the tagRootPtr for the tag. */ summaryPtr2 = libc.UintptrFromInt32(0) summaryPtr = (*TNode)(unsafe.Pointer(nodePtr)).FsummaryPtr for { if !(summaryPtr != libc.UintptrFromInt32(0)) { break } if (*TSummary)(unsafe.Pointer(summaryPtr)).FtoggleCount > 0 && (*TSummary)(unsafe.Pointer(summaryPtr)).FtoggleCount < (*TTkTextTag)(unsafe.Pointer((*TSummary)(unsafe.Pointer(summaryPtr)).FtagPtr)).FtoggleCount { if (*TNode)(unsafe.Pointer(nodePtr)).Flevel == (*TNode1)(unsafe.Pointer((*TTkTextTag)(unsafe.Pointer((*TSummary)(unsafe.Pointer(summaryPtr)).FtagPtr)).FtagRootPtr)).Flevel { /* * The tag's root node split and some toggles left. The tag * root must move up a level. */ (*TTkTextTag)(unsafe.Pointer((*TSummary)(unsafe.Pointer(summaryPtr)).FtagPtr)).FtagRootPtr = (*TNode)(unsafe.Pointer(nodePtr)).FparentPtr } summaryPtr2 = summaryPtr summaryPtr = (*TSummary)(unsafe.Pointer(summaryPtr)).FnextPtr goto _11 } if (*TSummary)(unsafe.Pointer(summaryPtr)).FtoggleCount == (*TTkTextTag)(unsafe.Pointer((*TSummary)(unsafe.Pointer(summaryPtr)).FtagPtr)).FtoggleCount { /* * A node merge has collected all the toggles under one node. Push * the root down to this level. */ (*TTkTextTag)(unsafe.Pointer((*TSummary)(unsafe.Pointer(summaryPtr)).FtagPtr)).FtagRootPtr = nodePtr } if summaryPtr2 != libc.UintptrFromInt32(0) { (*TSummary)(unsafe.Pointer(summaryPtr2)).FnextPtr = (*TSummary)(unsafe.Pointer(summaryPtr)).FnextPtr libtcl9_0.XTcl_Free(tls, summaryPtr) summaryPtr = (*TSummary)(unsafe.Pointer(summaryPtr2)).FnextPtr } else { (*TNode)(unsafe.Pointer(nodePtr)).FsummaryPtr = (*TSummary)(unsafe.Pointer(summaryPtr)).FnextPtr libtcl9_0.XTcl_Free(tls, summaryPtr) summaryPtr = (*TNode)(unsafe.Pointer(nodePtr)).FsummaryPtr } goto _11 _11: } } /* *---------------------------------------------------------------------- * * TkBTreeNumLines -- * * This function returns a count of the number of logical lines of text * present in a given B-tree. * * Results: * The return value is a count of the number of usable lines in tree * (i.e. it doesn't include the dummy line that is just used to mark the * end of the tree). * * Side effects: * None. * *---------------------------------------------------------------------- */ func XTkBTreeNumLines(tls *libc.TLS, tree TTkTextBTree, textPtr uintptr) (r int32) { /* Relative to this client of the B-tree. */ var count int32 var treePtr uintptr _, _ = count, treePtr treePtr = tree if textPtr != libc.UintptrFromInt32(0) && (*TTkText)(unsafe.Pointer(textPtr)).Fend != libc.UintptrFromInt32(0) { count = XTkBTreeLinesTo(tls, libc.UintptrFromInt32(0), (*TTkText)(unsafe.Pointer(textPtr)).Fend) } else { count = (*TNode)(unsafe.Pointer((*TBTree)(unsafe.Pointer(treePtr)).FrootPtr)).FnumLines - int32(1) } if textPtr != libc.UintptrFromInt32(0) && (*TTkText)(unsafe.Pointer(textPtr)).Fstart != libc.UintptrFromInt32(0) { count -= XTkBTreeLinesTo(tls, libc.UintptrFromInt32(0), (*TTkText)(unsafe.Pointer(textPtr)).Fstart) } return count } /* *---------------------------------------------------------------------- * * TkBTreeNumPixels -- * * This function returns a count of the number of pixels of text present * in a given widget's B-tree representation. * * Results: * The return value is a count of the number of usable pixels in tree * (since the dummy line used to mark the end of the B-tree is maintained * with zero height, as are any lines that are before or after the * '-start -end' range of the text widget in question, the number stored * at the root is the number we want). * * Side effects: * None. * *---------------------------------------------------------------------- */ func XTkBTreeNumPixels(tls *libc.TLS, tree TTkTextBTree, textPtr uintptr) (r int32) { /* Relative to this client of the B-tree. */ var treePtr uintptr _ = treePtr treePtr = tree return *(*int32)(unsafe.Pointer((*TNode)(unsafe.Pointer((*TBTree)(unsafe.Pointer(treePtr)).FrootPtr)).FnumPixels + uintptr((*TTkText)(unsafe.Pointer(textPtr)).FpixelReference)*4)) } /* *-------------------------------------------------------------- * * CharSplitProc -- * * This function implements splitting for character segments. * * Results: * The return value is a pointer to a chain of two segments that have the * same characters as segPtr except split among the two segments. * * Side effects: * Storage for segPtr is freed. * *-------------------------------------------------------------- */ func _CharSplitProc(tls *libc.TLS, segPtr uintptr, index TTcl_Size) (r uintptr) { /* Position within segment at which to * split. */ var newPtr1, newPtr2 uintptr _, _ = newPtr1, newPtr2 newPtr1 = libtcl9_0.XTcl_Alloc(tls, uint64(libc.UintptrFromInt32(0)+24)+libc.Uint64FromInt32(1)+libc.Uint64FromInt64(index)) newPtr2 = libtcl9_0.XTcl_Alloc(tls, uint64(libc.UintptrFromInt32(0)+24)+libc.Uint64FromInt32(1)+libc.Uint64FromInt64((*TTkTextSegment)(unsafe.Pointer(segPtr)).Fsize-index)) (*TTkTextSegment)(unsafe.Pointer(newPtr1)).FtypePtr = uintptr(unsafe.Pointer(&XtkTextCharType)) (*TTkTextSegment)(unsafe.Pointer(newPtr1)).FnextPtr = newPtr2 (*TTkTextSegment)(unsafe.Pointer(newPtr1)).Fsize = index libc.Xmemcpy(tls, newPtr1+24, segPtr+24, libc.Uint64FromInt64(index)) *(*uint8)(unsafe.Pointer(newPtr1 + 24 + uintptr(index))) = uint8(0) (*TTkTextSegment)(unsafe.Pointer(newPtr2)).FtypePtr = uintptr(unsafe.Pointer(&XtkTextCharType)) (*TTkTextSegment)(unsafe.Pointer(newPtr2)).FnextPtr = (*TTkTextSegment)(unsafe.Pointer(segPtr)).FnextPtr (*TTkTextSegment)(unsafe.Pointer(newPtr2)).Fsize = (*TTkTextSegment)(unsafe.Pointer(segPtr)).Fsize - index libc.Xmemcpy(tls, newPtr2+24, segPtr+24+uintptr(index), libc.Uint64FromInt64((*TTkTextSegment)(unsafe.Pointer(newPtr2)).Fsize)) *(*uint8)(unsafe.Pointer(newPtr2 + 24 + uintptr((*TTkTextSegment)(unsafe.Pointer(newPtr2)).Fsize))) = uint8(0) libtcl9_0.XTcl_Free(tls, segPtr) return newPtr1 } /* *-------------------------------------------------------------- * * CharCleanupProc -- * * This function merges adjacent character segments into a single * character segment, if possible. * * Results: * The return value is a pointer to the first segment in the (new) list * of segments that used to start with segPtr. * * Side effects: * Storage for the segments may be allocated and freed. * *-------------------------------------------------------------- */ func _CharCleanupProc(tls *libc.TLS, segPtr uintptr, dummy4620 uintptr) (r uintptr) { /* Line containing segments (not used). */ var newPtr, segPtr2 uintptr _, _ = newPtr, segPtr2 segPtr2 = (*TTkTextSegment)(unsafe.Pointer(segPtr)).FnextPtr if segPtr2 == libc.UintptrFromInt32(0) || (*TTkTextSegment)(unsafe.Pointer(segPtr2)).FtypePtr != uintptr(unsafe.Pointer(&XtkTextCharType)) { return segPtr } newPtr = libtcl9_0.XTcl_Alloc(tls, uint64(libc.UintptrFromInt32(0)+24)+libc.Uint64FromInt32(1)+libc.Uint64FromInt64((*TTkTextSegment)(unsafe.Pointer(segPtr)).Fsize+(*TTkTextSegment)(unsafe.Pointer(segPtr2)).Fsize)) (*TTkTextSegment)(unsafe.Pointer(newPtr)).FtypePtr = uintptr(unsafe.Pointer(&XtkTextCharType)) (*TTkTextSegment)(unsafe.Pointer(newPtr)).FnextPtr = (*TTkTextSegment)(unsafe.Pointer(segPtr2)).FnextPtr (*TTkTextSegment)(unsafe.Pointer(newPtr)).Fsize = (*TTkTextSegment)(unsafe.Pointer(segPtr)).Fsize + (*TTkTextSegment)(unsafe.Pointer(segPtr2)).Fsize libc.Xmemcpy(tls, newPtr+24, segPtr+24, libc.Uint64FromInt64((*TTkTextSegment)(unsafe.Pointer(segPtr)).Fsize)) libc.Xmemcpy(tls, newPtr+24+uintptr((*TTkTextSegment)(unsafe.Pointer(segPtr)).Fsize), segPtr2+24, libc.Uint64FromInt64((*TTkTextSegment)(unsafe.Pointer(segPtr2)).Fsize)) *(*uint8)(unsafe.Pointer(newPtr + 24 + uintptr((*TTkTextSegment)(unsafe.Pointer(newPtr)).Fsize))) = uint8(0) libtcl9_0.XTcl_Free(tls, segPtr) libtcl9_0.XTcl_Free(tls, segPtr2) return newPtr } /* *-------------------------------------------------------------- * * CharDeleteProc -- * * This function is invoked to delete a character segment. * * Results: * Always returns 0 to indicate that the segment was deleted. * * Side effects: * Storage for the segment is freed. * *-------------------------------------------------------------- */ func _CharDeleteProc(tls *libc.TLS, segPtr uintptr, dummy4659 uintptr, dummy4660 int32) (r int32) { /* Non-zero means the entire tree is being * deleted, so everything must get cleaned * up. */ libtcl9_0.XTcl_Free(tls, segPtr) return 0 } /* *-------------------------------------------------------------- * * CharCheckProc -- * * This function is invoked to perform consistency checks on character * segments. * * Results: * None. * * Side effects: * If the segment isn't inconsistent then the function panics. * *-------------------------------------------------------------- */ func _CharCheckProc(tls *libc.TLS, segPtr uintptr, dummy4688 uintptr) { /* Line containing segment. */ /* * Make sure that the segment contains the number of characters indicated * by its header, and that the last segment in a line ends in a newline. * Also make sure that there aren't ever two character segments adjacent * to each other: they should be merged together. */ if (*TTkTextSegment)(unsafe.Pointer(segPtr)).Fsize+int64(1) <= int64(1) { libtcl9_0.XTcl_Panic(tls, __ccgo_ts+46548, 0) } if libc.Xstrlen(tls, segPtr+24) != libc.Uint64FromInt64((*TTkTextSegment)(unsafe.Pointer(segPtr)).Fsize) { libtcl9_0.XTcl_Panic(tls, __ccgo_ts+46585, 0) } if (*TTkTextSegment)(unsafe.Pointer(segPtr)).FnextPtr == libc.UintptrFromInt32(0) { if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(segPtr + 24 + uintptr((*TTkTextSegment)(unsafe.Pointer(segPtr)).Fsize-int64(1))))) != int32('\n') { libtcl9_0.XTcl_Panic(tls, __ccgo_ts+46623, 0) } } else { if (*TTkTextSegment1)(unsafe.Pointer((*TTkTextSegment)(unsafe.Pointer(segPtr)).FnextPtr)).FtypePtr == uintptr(unsafe.Pointer(&XtkTextCharType)) { libtcl9_0.XTcl_Panic(tls, __ccgo_ts+46668, 0) } } } /* *-------------------------------------------------------------- * * ToggleDeleteProc -- * * This function is invoked to delete toggle segments. * * Results: * Returns 1 to indicate that the segment may not be deleted, unless the * entire B-tree is going away. * * Side effects: * If the tree is going away then the toggle's memory is freed; otherwise * the toggle counts in nodes above the segment get updated. * *-------------------------------------------------------------- */ func _ToggleDeleteProc(tls *libc.TLS, segPtr uintptr, linePtr uintptr, treeGone int32) (r int32) { /* Non-zero means the entire tree is being * deleted, so everything must get cleaned * up. */ if treeGone != 0 { libtcl9_0.XTcl_Free(tls, segPtr) return 0 } /* * This toggle is in the middle of a range of characters that's being * deleted. Refuse to die. We'll be moved to the end of the deleted range * and our cleanup function will be called later. Decrement node toggle * counts here, and set a flag so we'll re-increment them in the cleanup * function. */ if (*(*TTkTextToggle)(unsafe.Pointer(&(*TTkTextSegment)(unsafe.Pointer(segPtr)).Fbody))).FinNodeCounts != 0 { _ChangeNodeToggleCount(tls, (*TTkTextLine)(unsafe.Pointer(linePtr)).FparentPtr, (*(*TTkTextToggle)(unsafe.Pointer(&(*TTkTextSegment)(unsafe.Pointer(segPtr)).Fbody))).FtagPtr, int64(-int32(1))) (*(*TTkTextToggle)(unsafe.Pointer(&(*TTkTextSegment)(unsafe.Pointer(segPtr)).Fbody))).FinNodeCounts = 0 } return int32(1) } /* *-------------------------------------------------------------- * * ToggleCleanupProc -- * * This function is called when a toggle is part of a line that's been * modified in some way. It's invoked after the modifications are * complete. * * Results: * The return value is the head segment in a new list that is to replace * the tail of the line that used to start at segPtr. This allows the * function to delete or modify segPtr. * * Side effects: * Toggle counts in the nodes above the new line will be updated if * they're not already. Toggles may be collapsed if there are duplicate * toggles at the same position. * *-------------------------------------------------------------- */ func _ToggleCleanupProc(tls *libc.TLS, segPtr uintptr, linePtr uintptr) (r uintptr) { /* Line that now contains segment. */ var counts int32 var prevPtr, segPtr2 uintptr _, _, _ = counts, prevPtr, segPtr2 /* * If this is a toggle-off segment, look ahead through the next segments * to see if there's a toggle-on segment for the same tag before any * segments with non-zero size. If so then the two toggles cancel each * other; remove them both. */ if (*TTkTextSegment)(unsafe.Pointer(segPtr)).FtypePtr == uintptr(unsafe.Pointer(&XtkTextToggleOffType)) { prevPtr = segPtr segPtr2 = (*TTkTextSegment)(unsafe.Pointer(prevPtr)).FnextPtr for { if !(segPtr2 != libc.UintptrFromInt32(0) && (*TTkTextSegment)(unsafe.Pointer(segPtr2)).Fsize == 0) { break } if (*TTkTextSegment)(unsafe.Pointer(segPtr2)).FtypePtr != uintptr(unsafe.Pointer(&XtkTextToggleOnType)) { goto _1 } if (*(*TTkTextToggle)(unsafe.Pointer(&(*TTkTextSegment)(unsafe.Pointer(segPtr2)).Fbody))).FtagPtr != (*(*TTkTextToggle)(unsafe.Pointer(&(*TTkTextSegment)(unsafe.Pointer(segPtr)).Fbody))).FtagPtr { goto _1 } counts = (*(*TTkTextToggle)(unsafe.Pointer(&(*TTkTextSegment)(unsafe.Pointer(segPtr)).Fbody))).FinNodeCounts + (*(*TTkTextToggle)(unsafe.Pointer(&(*TTkTextSegment)(unsafe.Pointer(segPtr2)).Fbody))).FinNodeCounts if counts != 0 { _ChangeNodeToggleCount(tls, (*TTkTextLine)(unsafe.Pointer(linePtr)).FparentPtr, (*(*TTkTextToggle)(unsafe.Pointer(&(*TTkTextSegment)(unsafe.Pointer(segPtr)).Fbody))).FtagPtr, int64(-counts)) } (*TTkTextSegment)(unsafe.Pointer(prevPtr)).FnextPtr = (*TTkTextSegment)(unsafe.Pointer(segPtr2)).FnextPtr libtcl9_0.XTcl_Free(tls, segPtr2) segPtr2 = (*TTkTextSegment)(unsafe.Pointer(segPtr)).FnextPtr libtcl9_0.XTcl_Free(tls, segPtr) return segPtr2 goto _1 _1: ; prevPtr = segPtr2 segPtr2 = (*TTkTextSegment)(unsafe.Pointer(prevPtr)).FnextPtr } } if !((*(*TTkTextToggle)(unsafe.Pointer(&(*TTkTextSegment)(unsafe.Pointer(segPtr)).Fbody))).FinNodeCounts != 0) { _ChangeNodeToggleCount(tls, (*TTkTextLine)(unsafe.Pointer(linePtr)).FparentPtr, (*(*TTkTextToggle)(unsafe.Pointer(&(*TTkTextSegment)(unsafe.Pointer(segPtr)).Fbody))).FtagPtr, int64(1)) (*(*TTkTextToggle)(unsafe.Pointer(&(*TTkTextSegment)(unsafe.Pointer(segPtr)).Fbody))).FinNodeCounts = int32(1) } return segPtr } /* *-------------------------------------------------------------- * * ToggleLineChangeProc -- * * This function is invoked when a toggle segment is about to move from * one line to another. * * Results: * None. * * Side effects: * Toggle counts are decremented in the nodes above the line. * *-------------------------------------------------------------- */ func _ToggleLineChangeProc(tls *libc.TLS, segPtr uintptr, linePtr uintptr) { /* Line that used to contain segment. */ if (*(*TTkTextToggle)(unsafe.Pointer(&(*TTkTextSegment)(unsafe.Pointer(segPtr)).Fbody))).FinNodeCounts != 0 { _ChangeNodeToggleCount(tls, (*TTkTextLine)(unsafe.Pointer(linePtr)).FparentPtr, (*(*TTkTextToggle)(unsafe.Pointer(&(*TTkTextSegment)(unsafe.Pointer(segPtr)).Fbody))).FtagPtr, int64(-int32(1))) (*(*TTkTextToggle)(unsafe.Pointer(&(*TTkTextSegment)(unsafe.Pointer(segPtr)).Fbody))).FinNodeCounts = 0 } } /* *-------------------------------------------------------------- * * ToggleCheckProc -- * * This function is invoked to perform consistency checks on toggle * segments. * * Results: * None. * * Side effects: * If a consistency problem is found the function panics. * *-------------------------------------------------------------- */ func _ToggleCheckProc(tls *libc.TLS, segPtr uintptr, linePtr uintptr) { /* Line containing segment. */ var needSummary int32 var summaryPtr uintptr _, _ = needSummary, summaryPtr if (*TTkTextSegment)(unsafe.Pointer(segPtr)).Fsize != 0 { libtcl9_0.XTcl_Panic(tls, __ccgo_ts+46726, 0) } if !((*(*TTkTextToggle)(unsafe.Pointer(&(*TTkTextSegment)(unsafe.Pointer(segPtr)).Fbody))).FinNodeCounts != 0) { libtcl9_0.XTcl_Panic(tls, __ccgo_ts+46769, 0) } needSummary = libc.BoolInt32((*TTkTextTag1)(unsafe.Pointer((*(*TTkTextToggle)(unsafe.Pointer(&(*TTkTextSegment)(unsafe.Pointer(segPtr)).Fbody))).FtagPtr)).FtagRootPtr != (*TTkTextLine)(unsafe.Pointer(linePtr)).FparentPtr) summaryPtr = (*TNode1)(unsafe.Pointer((*TTkTextLine)(unsafe.Pointer(linePtr)).FparentPtr)).FsummaryPtr for { if summaryPtr == libc.UintptrFromInt32(0) { if needSummary != 0 { libtcl9_0.XTcl_Panic(tls, __ccgo_ts+46821, 0) } else { break } } if (*TSummary)(unsafe.Pointer(summaryPtr)).FtagPtr == (*(*TTkTextToggle)(unsafe.Pointer(&(*TTkTextSegment)(unsafe.Pointer(segPtr)).Fbody))).FtagPtr { if !(needSummary != 0) { libtcl9_0.XTcl_Panic(tls, __ccgo_ts+46862, 0) } break } goto _1 _1: ; summaryPtr = (*TSummary)(unsafe.Pointer(summaryPtr)).FnextPtr } } type TNode1 = struct { FparentPtr uintptr FnextPtr uintptr FsummaryPtr uintptr Flevel TTcl_Size Fchildren struct { FlinePtr [0]uintptr FnodePtr uintptr } FnumChildren int32 FnumLines int32 FnumPixels uintptr } type TTk_SegType1 = struct { Fname uintptr FleftGravity int32 FsplitProc uintptr FdeleteProc uintptr FcleanupProc uintptr FlineChangeProc uintptr FlayoutProc uintptr FcheckProc uintptr } const BOTTOM_LINE = 8 const DINFO_OUT_OF_DATE = 1 const DLINE_FREE = 0 const DLINE_FREE_TEMP = 2 const DLINE_UNLINK = 1 const HAS_3D_BORDER = 1 const NEW_LAYOUT = 2 const OLD_Y_INVALID = 16 const OUT_OF_SYNC = 16 const REDRAW_BORDERS1 = 4 const REDRAW_PENDING3 = 2 const REPICK_NEEDED1 = 8 const TKTEXT_SCROLL_ERROR = 4 const TKTEXT_SCROLL_MOVETO = 1 const TKTEXT_SCROLL_PAGES = 2 const TKTEXT_SCROLL_PIXELS = 5 const TKTEXT_SCROLL_UNITS = 3 const TOP_LINE = 4 /* * Local Variables: * mode: c * c-basic-offset: 4 * fill-column: 78 * End: */ /* * "Calculations of line pixel heights and the size of the vertical * scrollbar." * * Given that tag, font and elide changes can happen to large numbers of * diverse chunks in a text widget containing megabytes of text, it is not * possible to recalculate all affected height information immediately any * such change takes place and maintain a responsive user-experience. Yet, for * an accurate vertical scrollbar to be drawn, we must know the total number * of vertical pixels shown on display versus the number available to be * displayed. * * The way the text widget solves this problem is by maintaining cached line * pixel heights (in the BTree for each logical line), and having asynchronous * timer callbacks (i) to iterate through the logical lines recalculating * their heights, and (ii) to recalculate the vertical scrollbar's position * and size. * * Typically this works well but there are some situations where the overall * functional design of this file causes some problems. These problems can * only arise because the calculations used to display lines on screen are not * connected to those in the iterating-line- recalculation-process. * * The reason for this disconnect is that the display calculations operate in * display lines, and the iteration and cache operates in logical lines. * Given that the display calculations both need not contain complete logical * lines (at top or bottom of display), and that they do not actually keep * track of logical lines (for simplicity of code and historical design), this * means a line may be known and drawn with a different pixel height to that * which is cached in the BTree, and this might cause some temporary * undesirable mismatch between display and the vertical scrollbar. * * All such mismatches should be temporary, however, since the asynchronous * height calculations will always catch up eventually. * * For further details see the comments before and within the following * functions below: LayoutDLine, AsyncUpdateLineMetrics, GetYView, * GetYPixelCount, TkTextUpdateOneLine, TkTextUpdateLineMetrics. * * For details of the way in which the BTree keeps track of pixel heights, see * tkTextBTree.c. Basically the BTree maintains two pieces of information: the * logical line indices and the pixel height cache. */ /* * TK_LAYOUT_WITH_BASE_CHUNKS: * * With this macro set, collect all char chunks that have no holes * between them, that are on the same line and use the same font and font * size. Allocate the chars of all these chunks, the so-called "stretch", * in a DString in the first chunk, the so-called "base chunk". Use the * base chunk string for measuring and drawing, so that these actions are * always performed with maximum context. * * This is necessary for text rendering engines that provide ligatures * and sub-pixel layout, like ATSU on Mac. If we don't do this, the * measuring will change all the time, leading to an ugly "tremble and * shiver" effect. This is because of the continuous splitting and * re-merging of chunks that goes on in a text widget, when the cursor or * the selection move. * * Side effects: * * Memory management changes. Instead of attaching the character data to * the clientData structures of the char chunks, an additional DString is * used. The collection process will even lead to resizing this DString * for large stretches (> TCL_DSTRING_STATIC_SIZE == 200). We could * reduce the overall memory footprint by copying the result to a plain * char array after the line breaking process, but that would complicate * the code and make performance even worse speedwise. See also TODOs. * * TODOs: * * - Move the character collection process from the LayoutProc into * LayoutDLine(), so that the collection can be done before actual * layout. In this way measuring can look at the following text, too, * right from the beginning. Memory handling can also be improved with * this. Problem: We don't easily know which chunks are adjacent until * all the other chunks have calculated their width. Apparently marks * would return width==0. A separate char collection loop would have to * know these things. * * - Use a new context parameter to pass the context from LayoutDLine() to * the LayoutProc instead of using a global variable like now. Not * pressing until the previous point gets implemented. */ /* * The following structure describes how to display a range of characters. * The information is generated by scanning all of the tags associated with * the characters and combining that with default information for the overall * widget. These structures form the hash keys for dInfoPtr->styleTable. */ type TStyleValues = struct { Fborder TTk_3DBorder FborderWidth int32 Frelief int32 FbgStipple TPixmap FfgColor uintptr Ftkfont TTk_Font FfgStipple TPixmap Fjustify int32 FlMargin1 int32 FlMargin2 int32 FlMarginColor TTk_3DBorder Foffset int32 Foverstrike int32 FoverstrikeColor uintptr FrMargin int32 FrMarginColor TTk_3DBorder Fspacing1 int32 Fspacing2 int32 Fspacing3 int32 FtabArrayPtr uintptr FtabStyle TTkTextTabStyle Funderline int32 FunderlineColor uintptr Felide int32 FwrapMode TTkWrapMode } /* * The following structure extends the StyleValues structure above with * graphics contexts used to actually draw the characters. The entries in * dInfoPtr->styleTable point to structures of this type. */ type TTextStyle = struct { FrefCount TTcl_Size FbgGC TGC FfgGC TGC FulGC TGC FovGC TGC FsValuePtr uintptr FhPtr uintptr } /* * The following macro determines whether two styles have the same background * so that, for example, no beveled border should be drawn between them. */ /* * The following macro is used to compare two floating-point numbers to within * a certain degree of scale. Direct comparison fails on processors where the * processor and memory representations of FP numbers of a particular * precision is different (e.g. Intel) */ /* * Macros to make debugging/testing logging a little easier. */ /* * The following structure describes one line of the display, which may be * either part or all of one line of the text. */ type TDLine = struct { Findex TTkTextIndex FbyteCount int32 FlogicalLinesMerged int32 Fy int32 FoldY int32 Fheight int32 Fbaseline int32 FspaceAbove int32 FspaceBelow int32 FlMarginColor TTk_3DBorder FlMarginWidth int32 FrMarginColor TTk_3DBorder FrMarginWidth int32 Flength int32 FchunkPtr uintptr FnextPtr uintptr Fflags int32 } /* * Flag bits for DLine structures: * * HAS_3D_BORDER - Non-zero means that at least one of the chunks * in this line has a 3D border, so it * potentially interacts with 3D borders in * neighboring lines (see DisplayLineBackground). * NEW_LAYOUT - Non-zero means that the line has been * re-layed out since the last time the display * was updated. * TOP_LINE - Non-zero means that this was the top line in * in the window the last time that the window * was laid out. This is important because a line * may be displayed differently if it's at the top * or bottom than if it's in the middle * (e.g. beveled edges aren't displayed for * middle lines if the adjacent line has a * similar background). * BOTTOM_LINE - Non-zero means that this was the bottom line * in the window the last time that the window * was laid out. * OLD_Y_INVALID - The value of oldY in the structure is not * valid or useful and should not be examined. * 'oldY' is only useful when the DLine is * currently displayed at a different position * and we wish to re-display it via scrolling, so * this means the DLine needs redrawing. */ /* * Overall display information for a text widget: */ type TTextDInfo = struct { FstyleTable TTcl_HashTable FdLinePtr uintptr FtopPixelOffset int32 FnewTopPixelOffset int32 FcopyGC TGC FscrollGC TGC Fx int32 Fy int32 FmaxX int32 FmaxY int32 FtopOfEof int32 FnewXPixelOffset int32 FcurXPixelOffset int32 FmaxLength int32 FxScrollFirst float64 FxScrollLast float64 FyScrollFirst float64 FyScrollLast float64 FscanMarkXPixel int32 FscanMarkX int32 FscanTotalYScroll int32 FscanMarkY int32 FdLinesInvalidated int32 Fflags int32 FlineMetricUpdateEpoch int32 FcurrentMetricUpdateLine int32 FmetricIndex TTkTextIndex FmetricPixelHeight int32 FmetricEpoch TTcl_Size FlastMetricUpdateLine int32 FlineUpdateTimer TTcl_TimerToken FscrollbarTimer TTcl_TimerToken } /* * In TkTextDispChunk structures for character segments, the clientData field * points to one of the following structures: */ type TCharInfo = struct { FnumBytes TTcl_Size } /* * Flag values for TextDInfo structures: * * DINFO_OUT_OF_DATE: Non-zero means that the DLine structures for * this window are partially or completely out of * date and need to be recomputed. * REDRAW_PENDING: Means that a when-idle handler has been * scheduled to update the display. * REDRAW_BORDERS: Means window border or pad area has * potentially been damaged and must be redrawn. * REPICK_NEEDED: 1 means that the widget has been modified in a * way that could change the current character (a * different character might be under the mouse * cursor now). Need to recompute the current * character before the next redisplay. * OUT_OF_SYNC 1 means that the last <> event had * value 0, indicating that the widget is out of sync. */ /* * Action values for FreeDLines: * * DLINE_FREE: Free the lines, but no need to unlink them from the * current list of actual display lines. * DLINE_UNLINK: Free and unlink from current display. * DLINE_FREE_TEMP: Free, but don't unlink, and also don't set * 'dLinesInvalidated'. */ /* * The following counters keep statistics about redisplay that can be checked * to see how clever this code is at reducing redisplays. */ var _numRedisplays int32 /* Number of calls to DisplayText. */ var _linesRedrawn int32 /* Number of calls to DisplayDLine. */ var _numCopies int32 /* Number of calls to XCopyArea to copy part * of the screen. */ var _lineHeightsRecalculated int32 /* * Result values returned by TextGetScrollInfoObj: */ /* *---------------------------------------------------------------------- * * TkTextCreateDInfo -- * * This function is called when a new text widget is created. Its job is * to set up display-related information for the widget. * * Results: * None. * * Side effects: * A TextDInfo data structure is allocated and initialized and attached * to textPtr. * *---------------------------------------------------------------------- */ func XTkTextCreateDInfo(tls *libc.TLS, textPtr uintptr) { bp := tls.Alloc(128) defer tls.Free(128) /* Overall information for text widget. */ var dInfoPtr uintptr var _ /* gcValues at bp+0 */ TXGCValues _ = dInfoPtr dInfoPtr = libtcl9_0.XTcl_Alloc(tls, uint64(304)) libtcl9_0.XTcl_InitHashTable(tls, dInfoPtr, libc.Int32FromUint64(libc.Uint64FromInt64(152)/libc.Uint64FromInt64(4))) (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FdLinePtr = libc.UintptrFromInt32(0) (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FcopyGC = libc.UintptrFromInt32(0) (*(*TXGCValues)(unsafe.Pointer(bp))).Fgraphics_exposures = int32(True) (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FscrollGC = XTk_GetGC(tls, (*TTkText)(unsafe.Pointer(textPtr)).Ftkwin, libc.Uint64FromInt64(libc.Int64FromInt64(1)< borderPrio { (*(*TStyleValues)(unsafe.Pointer(bp))).Fborder = border borderPrio = (*TTkTextTag)(unsafe.Pointer(tagPtr)).Fpriority } if (*TTkTextTag)(unsafe.Pointer(tagPtr)).FborderWidthObj != libc.UintptrFromInt32(0) && libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(libtcl9_0.XTcl_GetStringFromObj(tls, (*TTkTextTag)(unsafe.Pointer(tagPtr)).FborderWidthObj, libc.UintptrFromInt32(0))))) != int32('\000') && (*TTkTextTag)(unsafe.Pointer(tagPtr)).Fpriority > borderWidthPrio { XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), (*TTkText)(unsafe.Pointer(textPtr)).Ftkwin, (*TTkTextTag)(unsafe.Pointer(tagPtr)).FborderWidthObj, bp+8) borderWidthPrio = (*TTkTextTag)(unsafe.Pointer(tagPtr)).Fpriority } if (*TTkTextTag)(unsafe.Pointer(tagPtr)).Frelief != -int32(1) && (*TTkTextTag)(unsafe.Pointer(tagPtr)).Fpriority > reliefPrio { if (*(*TStyleValues)(unsafe.Pointer(bp))).Fborder == libc.UintptrFromInt32(0) { (*(*TStyleValues)(unsafe.Pointer(bp))).Fborder = (*TTkText)(unsafe.Pointer(textPtr)).Fborder } (*(*TStyleValues)(unsafe.Pointer(bp))).Frelief = (*TTkTextTag)(unsafe.Pointer(tagPtr)).Frelief reliefPrio = (*TTkTextTag)(unsafe.Pointer(tagPtr)).Fpriority } if (*TTkTextTag)(unsafe.Pointer(tagPtr)).FbgStipple != uint64(0) && (*TTkTextTag)(unsafe.Pointer(tagPtr)).Fpriority > bgStipplePrio { (*(*TStyleValues)(unsafe.Pointer(bp))).FbgStipple = (*TTkTextTag)(unsafe.Pointer(tagPtr)).FbgStipple bgStipplePrio = (*TTkTextTag)(unsafe.Pointer(tagPtr)).Fpriority } if fgColor != libc.UintptrFromInt32(0) && (*TTkTextTag)(unsafe.Pointer(tagPtr)).Fpriority > fgPrio { (*(*TStyleValues)(unsafe.Pointer(bp))).FfgColor = fgColor fgPrio = (*TTkTextTag)(unsafe.Pointer(tagPtr)).Fpriority } if (*TTkTextTag)(unsafe.Pointer(tagPtr)).Ftkfont != libc.UintptrFromInt32(0) && (*TTkTextTag)(unsafe.Pointer(tagPtr)).Fpriority > fontPrio { (*(*TStyleValues)(unsafe.Pointer(bp))).Ftkfont = (*TTkTextTag)(unsafe.Pointer(tagPtr)).Ftkfont fontPrio = (*TTkTextTag)(unsafe.Pointer(tagPtr)).Fpriority } if (*TTkTextTag)(unsafe.Pointer(tagPtr)).FfgStipple != uint64(0) && (*TTkTextTag)(unsafe.Pointer(tagPtr)).Fpriority > fgStipplePrio { (*(*TStyleValues)(unsafe.Pointer(bp))).FfgStipple = (*TTkTextTag)(unsafe.Pointer(tagPtr)).FfgStipple fgStipplePrio = (*TTkTextTag)(unsafe.Pointer(tagPtr)).Fpriority } if (*TTkTextTag)(unsafe.Pointer(tagPtr)).Fjustify != int32(TK_JUSTIFY_NULL) && (*TTkTextTag)(unsafe.Pointer(tagPtr)).Fpriority > justifyPrio { (*(*TStyleValues)(unsafe.Pointer(bp))).Fjustify = (*TTkTextTag)(unsafe.Pointer(tagPtr)).Fjustify justifyPrio = (*TTkTextTag)(unsafe.Pointer(tagPtr)).Fpriority } if (*TTkTextTag)(unsafe.Pointer(tagPtr)).FlMargin1Obj != libc.UintptrFromInt32(0) && (*TTkTextTag)(unsafe.Pointer(tagPtr)).Fpriority > lMargin1Prio { XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), (*TTkText)(unsafe.Pointer(textPtr)).Ftkwin, (*TTkTextTag)(unsafe.Pointer(tagPtr)).FlMargin1Obj, bp+52) lMargin1Prio = (*TTkTextTag)(unsafe.Pointer(tagPtr)).Fpriority } if (*TTkTextTag)(unsafe.Pointer(tagPtr)).FlMargin2Obj != libc.UintptrFromInt32(0) && (*TTkTextTag)(unsafe.Pointer(tagPtr)).Fpriority > lMargin2Prio { XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), (*TTkText)(unsafe.Pointer(textPtr)).Ftkwin, (*TTkTextTag)(unsafe.Pointer(tagPtr)).FlMargin2Obj, bp+56) lMargin2Prio = (*TTkTextTag)(unsafe.Pointer(tagPtr)).Fpriority } if (*TTkTextTag)(unsafe.Pointer(tagPtr)).FlMarginColor != libc.UintptrFromInt32(0) && (*TTkTextTag)(unsafe.Pointer(tagPtr)).Fpriority > lMarginColorPrio { (*(*TStyleValues)(unsafe.Pointer(bp))).FlMarginColor = (*TTkTextTag)(unsafe.Pointer(tagPtr)).FlMarginColor lMarginColorPrio = (*TTkTextTag)(unsafe.Pointer(tagPtr)).Fpriority } if (*TTkTextTag)(unsafe.Pointer(tagPtr)).FoffsetObj != libc.UintptrFromInt32(0) && (*TTkTextTag)(unsafe.Pointer(tagPtr)).Fpriority > offsetPrio { XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), (*TTkText)(unsafe.Pointer(textPtr)).Ftkwin, (*TTkTextTag)(unsafe.Pointer(tagPtr)).FoffsetObj, bp+72) offsetPrio = (*TTkTextTag)(unsafe.Pointer(tagPtr)).Fpriority } if (*TTkTextTag)(unsafe.Pointer(tagPtr)).Foverstrike >= 0 && (*TTkTextTag)(unsafe.Pointer(tagPtr)).Fpriority > overstrikePrio { (*(*TStyleValues)(unsafe.Pointer(bp))).Foverstrike = libc.BoolInt32((*TTkTextTag)(unsafe.Pointer(tagPtr)).Foverstrike > 0) overstrikePrio = (*TTkTextTag)(unsafe.Pointer(tagPtr)).Fpriority if (*TTkTextTag)(unsafe.Pointer(tagPtr)).FoverstrikeColor != libc.UintptrFromInt32(0) { (*(*TStyleValues)(unsafe.Pointer(bp))).FoverstrikeColor = (*TTkTextTag)(unsafe.Pointer(tagPtr)).FoverstrikeColor } else { if fgColor != libc.UintptrFromInt32(0) { (*(*TStyleValues)(unsafe.Pointer(bp))).FoverstrikeColor = fgColor } } } if (*TTkTextTag)(unsafe.Pointer(tagPtr)).FrMarginObj != libc.UintptrFromInt32(0) && (*TTkTextTag)(unsafe.Pointer(tagPtr)).Fpriority > rMarginPrio { XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), (*TTkText)(unsafe.Pointer(textPtr)).Ftkwin, (*TTkTextTag)(unsafe.Pointer(tagPtr)).FrMarginObj, bp+88) rMarginPrio = (*TTkTextTag)(unsafe.Pointer(tagPtr)).Fpriority } if (*TTkTextTag)(unsafe.Pointer(tagPtr)).FrMarginColor != libc.UintptrFromInt32(0) && (*TTkTextTag)(unsafe.Pointer(tagPtr)).Fpriority > rMarginColorPrio { (*(*TStyleValues)(unsafe.Pointer(bp))).FrMarginColor = (*TTkTextTag)(unsafe.Pointer(tagPtr)).FrMarginColor rMarginColorPrio = (*TTkTextTag)(unsafe.Pointer(tagPtr)).Fpriority } if (*TTkTextTag)(unsafe.Pointer(tagPtr)).Fspacing1Obj != libc.UintptrFromInt32(0) && (*TTkTextTag)(unsafe.Pointer(tagPtr)).Fpriority > spacing1Prio { XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), (*TTkText)(unsafe.Pointer(textPtr)).Ftkwin, (*TTkTextTag)(unsafe.Pointer(tagPtr)).Fspacing1Obj, bp+104) spacing1Prio = (*TTkTextTag)(unsafe.Pointer(tagPtr)).Fpriority } if (*TTkTextTag)(unsafe.Pointer(tagPtr)).Fspacing2Obj != libc.UintptrFromInt32(0) && (*TTkTextTag)(unsafe.Pointer(tagPtr)).Fpriority > spacing2Prio { XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), (*TTkText)(unsafe.Pointer(textPtr)).Ftkwin, (*TTkTextTag)(unsafe.Pointer(tagPtr)).Fspacing2Obj, bp+108) spacing2Prio = (*TTkTextTag)(unsafe.Pointer(tagPtr)).Fpriority } if (*TTkTextTag)(unsafe.Pointer(tagPtr)).Fspacing3Obj != libc.UintptrFromInt32(0) && (*TTkTextTag)(unsafe.Pointer(tagPtr)).Fpriority > spacing3Prio { XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), (*TTkText)(unsafe.Pointer(textPtr)).Ftkwin, (*TTkTextTag)(unsafe.Pointer(tagPtr)).Fspacing3Obj, bp+112) spacing3Prio = (*TTkTextTag)(unsafe.Pointer(tagPtr)).Fpriority } if (*TTkTextTag)(unsafe.Pointer(tagPtr)).FtabStringPtr != libc.UintptrFromInt32(0) && (*TTkTextTag)(unsafe.Pointer(tagPtr)).Fpriority > tabPrio { (*(*TStyleValues)(unsafe.Pointer(bp))).FtabArrayPtr = (*TTkTextTag)(unsafe.Pointer(tagPtr)).FtabArrayPtr tabPrio = (*TTkTextTag)(unsafe.Pointer(tagPtr)).Fpriority } if ((*TTkTextTag)(unsafe.Pointer(tagPtr)).FtabStyle == int32(TK_TEXT_TABSTYLE_TABULAR) || (*TTkTextTag)(unsafe.Pointer(tagPtr)).FtabStyle == int32(TK_TEXT_TABSTYLE_WORDPROCESSOR)) && (*TTkTextTag)(unsafe.Pointer(tagPtr)).Fpriority > tabStylePrio { (*(*TStyleValues)(unsafe.Pointer(bp))).FtabStyle = (*TTkTextTag)(unsafe.Pointer(tagPtr)).FtabStyle tabStylePrio = (*TTkTextTag)(unsafe.Pointer(tagPtr)).Fpriority } if (*TTkTextTag)(unsafe.Pointer(tagPtr)).Funderline >= 0 && (*TTkTextTag)(unsafe.Pointer(tagPtr)).Fpriority > underlinePrio { (*(*TStyleValues)(unsafe.Pointer(bp))).Funderline = libc.BoolInt32((*TTkTextTag)(unsafe.Pointer(tagPtr)).Funderline > 0) underlinePrio = (*TTkTextTag)(unsafe.Pointer(tagPtr)).Fpriority if (*TTkTextTag)(unsafe.Pointer(tagPtr)).FunderlineColor != libc.UintptrFromInt32(0) { (*(*TStyleValues)(unsafe.Pointer(bp))).FunderlineColor = (*TTkTextTag)(unsafe.Pointer(tagPtr)).FunderlineColor } else { if fgColor != libc.UintptrFromInt32(0) { (*(*TStyleValues)(unsafe.Pointer(bp))).FunderlineColor = fgColor } } } if (*TTkTextTag)(unsafe.Pointer(tagPtr)).Felide >= 0 && (*TTkTextTag)(unsafe.Pointer(tagPtr)).Fpriority > elidePrio { (*(*TStyleValues)(unsafe.Pointer(bp))).Felide = libc.BoolInt32((*TTkTextTag)(unsafe.Pointer(tagPtr)).Felide > 0) elidePrio = (*TTkTextTag)(unsafe.Pointer(tagPtr)).Fpriority } if ((*TTkTextTag)(unsafe.Pointer(tagPtr)).FwrapMode == int32(TEXT_WRAPMODE_CHAR) || (*TTkTextTag)(unsafe.Pointer(tagPtr)).FwrapMode == int32(TEXT_WRAPMODE_NONE) || (*TTkTextTag)(unsafe.Pointer(tagPtr)).FwrapMode == int32(TEXT_WRAPMODE_WORD)) && (*TTkTextTag)(unsafe.Pointer(tagPtr)).Fpriority > wrapPrio { (*(*TStyleValues)(unsafe.Pointer(bp))).FwrapMode = (*TTkTextTag)(unsafe.Pointer(tagPtr)).FwrapMode wrapPrio = (*TTkTextTag)(unsafe.Pointer(tagPtr)).Fpriority } goto _18 _18: ; i++ } if tagPtrs != libc.UintptrFromInt32(0) { libtcl9_0.XTcl_Free(tls, tagPtrs) } /* * Use an existing style if there's one around that matches. */ hPtr = (*(*func(*libc.TLS, uintptr, uintptr, uintptr) uintptr)(unsafe.Pointer(&struct{ uintptr }{(*TTcl_HashTable)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FdInfoPtr)).FcreateProc})))(tls, (*TTkText)(unsafe.Pointer(textPtr)).FdInfoPtr, bp, bp+160) if !(*(*int32)(unsafe.Pointer(bp + 160)) != 0) { stylePtr = (*TTcl_HashEntry)(unsafe.Pointer(hPtr)).FclientData (*TTextStyle)(unsafe.Pointer(stylePtr)).FrefCount++ return stylePtr } /* * No existing style matched. Make a new one. */ stylePtr = libtcl9_0.XTcl_Alloc(tls, uint64(56)) (*TTextStyle)(unsafe.Pointer(stylePtr)).FrefCount = int64(1) if (*(*TStyleValues)(unsafe.Pointer(bp))).Fborder != libc.UintptrFromInt32(0) { (*(*TXGCValues)(unsafe.Pointer(bp + 168))).Fforeground = (*TXColor)(unsafe.Pointer(XTk_3DBorderColor(tls, (*(*TStyleValues)(unsafe.Pointer(bp))).Fborder))).Fpixel mask = libc.Uint64FromInt64(libc.Int64FromInt64(1) << libc.Int32FromInt32(2)) if (*(*TStyleValues)(unsafe.Pointer(bp))).FbgStipple != uint64(0) { (*(*TXGCValues)(unsafe.Pointer(bp + 168))).Fstipple = (*(*TStyleValues)(unsafe.Pointer(bp))).FbgStipple (*(*TXGCValues)(unsafe.Pointer(bp + 168))).Ffill_style = int32(FillStippled) mask |= libc.Uint64FromInt64(libc.Int64FromInt64(1)<pixelHeight with the sum of the results of this * function operating on all display lines within each logical line. * Ideally the code should be refactored to ensure the cached pixel * height is never behind what is known when this function is called * elsewhere. * * Unfortunately, this function is currently called from many different * places, not just to layout a display line for actual display, but also * simply to calculate some metric or other of one or more display lines * (typically the height). It would be a good idea to do some profiling * of typical text widget usage and the way in which this is called and * see if some optimization could or should be done. * *---------------------------------------------------------------------- */ func _LayoutDLine(tls *libc.TLS, textPtr uintptr, indexPtr uintptr) (r uintptr) { bp := tls.Alloc(12144) defer tls.Free(12144) /* Beginning of display line. May not * necessarily point to a character * segment. */ var ascent, breakByteOffset, code, descent, elide, elidesize, gotTab, jIndent, justify, maxBytes, maxX, noCharsYet, paragraphStart, rMargin, tabSize, wholeLine, x, v10, v11, v4, v5, v9 int32 var breakChunkPtr, chunkPtr, dlPtr, lastCharChunkPtr, lastChunkPtr, linePtr, linePtr1, linePtr2, p, sValuePtr, segPtr, tabArrayPtr, tabChunkPtr, tagPtr, v3, p13 uintptr var tabStyle TTkTextTabStyle var wrapMode TTkWrapMode var v2, v6, v8 TTcl_Size var _ /* breakIndex at bp+32 */ TTkTextIndex var _ /* byteOffset at bp+72 */ TTcl_Size var _ /* curIndex at bp+0 */ TTkTextIndex var _ /* info at bp+80 */ TTkTextElideInfo var _ /* tabIndex at bp+64 */ int32 _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = ascent, breakByteOffset, breakChunkPtr, chunkPtr, code, descent, dlPtr, elide, elidesize, gotTab, jIndent, justify, lastCharChunkPtr, lastChunkPtr, linePtr, linePtr1, linePtr2, maxBytes, maxX, noCharsYet, p, paragraphStart, rMargin, sValuePtr, segPtr, tabArrayPtr, tabChunkPtr, tabSize, tabStyle, tagPtr, wholeLine, wrapMode, x, v10, v11, v2, v3, v4, v5, v6, v8, v9, p13 /* Wrap mode to use for this line. */ x = 0 maxX = 0 /* Keep track of elide state. */ /* * Create and initialize a new DLine structure. */ dlPtr = libtcl9_0.XTcl_Alloc(tls, uint64(120)) (*TDLine)(unsafe.Pointer(dlPtr)).Findex = *(*TTkTextIndex)(unsafe.Pointer(indexPtr)) (*TDLine)(unsafe.Pointer(dlPtr)).FbyteCount = 0 (*TDLine)(unsafe.Pointer(dlPtr)).Fy = 0 (*TDLine)(unsafe.Pointer(dlPtr)).FoldY = 0 /* Only set to avoid compiler warnings. */ (*TDLine)(unsafe.Pointer(dlPtr)).Fheight = 0 (*TDLine)(unsafe.Pointer(dlPtr)).Fbaseline = 0 (*TDLine)(unsafe.Pointer(dlPtr)).FchunkPtr = libc.UintptrFromInt32(0) (*TDLine)(unsafe.Pointer(dlPtr)).FnextPtr = libc.UintptrFromInt32(0) (*TDLine)(unsafe.Pointer(dlPtr)).Fflags = libc.Int32FromInt32(NEW_LAYOUT) | libc.Int32FromInt32(OLD_Y_INVALID) (*TDLine)(unsafe.Pointer(dlPtr)).FlogicalLinesMerged = 0 (*TDLine)(unsafe.Pointer(dlPtr)).FlMarginColor = libc.UintptrFromInt32(0) (*TDLine)(unsafe.Pointer(dlPtr)).FlMarginWidth = 0 (*TDLine)(unsafe.Pointer(dlPtr)).FrMarginColor = libc.UintptrFromInt32(0) (*TDLine)(unsafe.Pointer(dlPtr)).FrMarginWidth = 0 /* * This is not necessarily totally correct, where we have merged logical * lines. Fixing this would require a quite significant overhaul, though, * so currently we make do with this. */ paragraphStart = libc.BoolInt32((*TTkTextIndex)(unsafe.Pointer(indexPtr)).FbyteIndex == 0) /* * Special case entirely elide line as there may be 1000s or more. */ elide = XTkTextIsElided(tls, textPtr, indexPtr, bp+80) if elide != 0 && (*TTkTextIndex)(unsafe.Pointer(indexPtr)).FbyteIndex == 0 { maxBytes = 0 segPtr = (*(*TTkTextElideInfo)(unsafe.Pointer(bp + 80))).FsegPtr for { if !(segPtr != libc.UintptrFromInt32(0)) { break } if (*TTkTextSegment)(unsafe.Pointer(segPtr)).Fsize > 0 { if elide == 0 { /* * We toggled a tag and the elide state changed to * visible, and we have something of non-zero size. * Therefore we must bail out. */ break } maxBytes = int32(int64(maxBytes) + (*TTkTextSegment)(unsafe.Pointer(segPtr)).Fsize) /* * Reset tag elide priority, since we're on a new character. */ } else { if (*TTkTextSegment)(unsafe.Pointer(segPtr)).FtypePtr == uintptr(unsafe.Pointer(&XtkTextToggleOffType)) || (*TTkTextSegment)(unsafe.Pointer(segPtr)).FtypePtr == uintptr(unsafe.Pointer(&XtkTextToggleOnType)) { tagPtr = (*(*TTkTextToggle)(unsafe.Pointer(&(*TTkTextSegment)(unsafe.Pointer(segPtr)).Fbody))).FtagPtr /* * The elide state only changes if this tag is either the * current highest priority tag (and is therefore being * toggled off), or it's a new tag with higher priority. */ if (*TTkTextTag)(unsafe.Pointer(tagPtr)).Felide >= 0 { *(*int32)(unsafe.Pointer((*(*TTkTextElideInfo)(unsafe.Pointer(bp + 80))).FtagCnts + uintptr((*TTkTextTag)(unsafe.Pointer(tagPtr)).Fpriority)*4))++ if *(*int32)(unsafe.Pointer((*(*TTkTextElideInfo)(unsafe.Pointer(bp + 80))).FtagCnts + uintptr((*TTkTextTag)(unsafe.Pointer(tagPtr)).Fpriority)*4))&int32(1) != 0 { *(*uintptr)(unsafe.Pointer((*(*TTkTextElideInfo)(unsafe.Pointer(bp + 80))).FtagPtrs + uintptr((*TTkTextTag)(unsafe.Pointer(tagPtr)).Fpriority)*8)) = tagPtr } if (*TTkTextTag)(unsafe.Pointer(tagPtr)).Fpriority >= (*(*TTkTextElideInfo)(unsafe.Pointer(bp + 80))).FelidePriority { if (*TTkTextSegment)(unsafe.Pointer(segPtr)).FtypePtr == uintptr(unsafe.Pointer(&XtkTextToggleOffType)) { /* * If it is being toggled off, and it has an elide * string, it must actually be the current highest * priority tag, so this check is redundant: */ if (*TTkTextTag)(unsafe.Pointer(tagPtr)).Fpriority != (*(*TTkTextElideInfo)(unsafe.Pointer(bp + 80))).FelidePriority { libtcl9_0.XTcl_Panic(tls, __ccgo_ts+46912, 0) } /* * Find previous elide tag, if any (if not then * elide will be zero, of course). */ elide = 0 for { v3 = bp + 80 + 16 *(*TTcl_Size)(unsafe.Pointer(v3))-- v2 = *(*TTcl_Size)(unsafe.Pointer(v3)) if !(v2 > 0) { break } if *(*int32)(unsafe.Pointer((*(*TTkTextElideInfo)(unsafe.Pointer(bp + 80))).FtagCnts + uintptr((*(*TTkTextElideInfo)(unsafe.Pointer(bp + 80))).FelidePriority)*4))&int32(1) != 0 { elide = libc.BoolInt32((*TTkTextTag)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer((*(*TTkTextElideInfo)(unsafe.Pointer(bp + 80))).FtagPtrs + uintptr((*(*TTkTextElideInfo)(unsafe.Pointer(bp + 80))).FelidePriority)*8)))).Felide > 0) break } } } else { elide = libc.BoolInt32((*TTkTextTag)(unsafe.Pointer(tagPtr)).Felide > 0) (*(*TTkTextElideInfo)(unsafe.Pointer(bp + 80))).FelidePriority = (*TTkTextTag)(unsafe.Pointer(tagPtr)).Fpriority } } } } } goto _1 _1: ; segPtr = (*TTkTextSegment)(unsafe.Pointer(segPtr)).FnextPtr } if elide != 0 { (*TDLine)(unsafe.Pointer(dlPtr)).FbyteCount = maxBytes v5 = libc.Int32FromInt32(0) (*TDLine)(unsafe.Pointer(dlPtr)).Flength = v5 v4 = v5 (*TDLine)(unsafe.Pointer(dlPtr)).FspaceBelow = v4 (*TDLine)(unsafe.Pointer(dlPtr)).FspaceAbove = v4 if (*TDLine)(unsafe.Pointer(dlPtr)).Findex.FbyteIndex == 0 { /* * Elided state goes from beginning to end of an entire * logical line. This means we can update the line's pixel * height, and bring its pixel calculation up to date. */ *(*int32)(unsafe.Pointer((*TTkTextLine)(unsafe.Pointer((*TDLine)(unsafe.Pointer(dlPtr)).Findex.FlinePtr)).Fpixels + uintptr(int32(1)+int32(2)*(*TTkText)(unsafe.Pointer(textPtr)).FpixelReference)*4)) = (*TTextDInfo1)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FdInfoPtr)).FlineMetricUpdateEpoch if *(*int32)(unsafe.Pointer((*TTkTextLine)(unsafe.Pointer((*TDLine)(unsafe.Pointer(dlPtr)).Findex.FlinePtr)).Fpixels + uintptr(int32(2)*(*TTkText)(unsafe.Pointer(textPtr)).FpixelReference)*4)) != 0 { XTkBTreeAdjustPixelHeight(tls, textPtr, (*TDLine)(unsafe.Pointer(dlPtr)).Findex.FlinePtr, 0, 0) } } XTkTextFreeElideInfo(tls, bp+80) return dlPtr } } XTkTextFreeElideInfo(tls, bp+80) /* * Each iteration of the loop below creates one TkTextDispChunk for the * new display line. The line will always have at least one chunk (for the * newline character at the end, if there's nothing else available). */ *(*TTkTextIndex)(unsafe.Pointer(bp)) = *(*TTkTextIndex)(unsafe.Pointer(indexPtr)) lastChunkPtr = libc.UintptrFromInt32(0) chunkPtr = libc.UintptrFromInt32(0) noCharsYet = int32(1) elide = 0 breakChunkPtr = libc.UintptrFromInt32(0) breakByteOffset = 0 justify = int32(TK_JUSTIFY_LEFT) *(*int32)(unsafe.Pointer(bp + 64)) = -int32(1) tabChunkPtr = libc.UintptrFromInt32(0) tabArrayPtr = libc.UintptrFromInt32(0) tabStyle = int32(TK_TEXT_TABSTYLE_TABULAR) rMargin = 0 wrapMode = int32(TEXT_WRAPMODE_CHAR) tabSize = 0 lastCharChunkPtr = libc.UintptrFromInt32(0) /* * Find the first segment to consider for the line. Can't call * TkTextIndexToSeg for this because it won't return a segment with zero * size (such as the insertion cursor's mark). */ goto connectNextLogicalLine connectNextLogicalLine: ; *(*TTcl_Size)(unsafe.Pointer(bp + 72)) = (*(*TTkTextIndex)(unsafe.Pointer(bp))).FbyteIndex segPtr = (*TTkTextLine)(unsafe.Pointer((*(*TTkTextIndex)(unsafe.Pointer(bp))).FlinePtr)).FsegPtr for *(*TTcl_Size)(unsafe.Pointer(bp + 72)) > 0 && *(*TTcl_Size)(unsafe.Pointer(bp + 72)) >= (*TTkTextSegment)(unsafe.Pointer(segPtr)).Fsize { *(*TTcl_Size)(unsafe.Pointer(bp + 72)) -= (*TTkTextSegment)(unsafe.Pointer(segPtr)).Fsize segPtr = (*TTkTextSegment)(unsafe.Pointer(segPtr)).FnextPtr if segPtr == libc.UintptrFromInt32(0) { /* * Two logical lines merged into one display line through eliding * of a newline. */ linePtr = XTkBTreeNextLine(tls, libc.UintptrFromInt32(0), (*(*TTkTextIndex)(unsafe.Pointer(bp))).FlinePtr) if linePtr == libc.UintptrFromInt32(0) { break } (*TDLine)(unsafe.Pointer(dlPtr)).FlogicalLinesMerged++ (*(*TTkTextIndex)(unsafe.Pointer(bp))).FbyteIndex = 0 (*(*TTkTextIndex)(unsafe.Pointer(bp))).FlinePtr = linePtr segPtr = (*TTkTextLine)(unsafe.Pointer((*(*TTkTextIndex)(unsafe.Pointer(bp))).FlinePtr)).FsegPtr } } for segPtr != libc.UintptrFromInt32(0) { /* * Every logical line still gets at least one chunk due to * expectations in the rest of the code, but we are able to skip * elided portions of the line quickly. * * If current chunk is elided and last chunk was too, coalesce. * * This also means that each logical line which is entirely elided * still gets laid out into a DLine, but with zero height. This isn't * particularly a problem, but it does seem somewhat unnecessary. We * may wish to redesign the code to remove these zero height DLines in * the future. */ if elide != 0 && lastChunkPtr != libc.UintptrFromInt32(0) && (*TTkTextDispChunk)(unsafe.Pointer(lastChunkPtr)).FdisplayProc == libc.UintptrFromInt32(0) { elidesize = int32((*TTkTextSegment)(unsafe.Pointer(segPtr)).Fsize - *(*TTcl_Size)(unsafe.Pointer(bp + 72))) if (*TTkTextSegment)(unsafe.Pointer(segPtr)).Fsize > *(*TTcl_Size)(unsafe.Pointer(bp + 72)) { (*(*TTkTextIndex)(unsafe.Pointer(bp))).FbyteIndex += int64(elidesize) *(*TTcl_Size)(unsafe.Pointer(lastChunkPtr + 56)) += int64(elidesize) v6 = (*TTkTextDispChunk)(unsafe.Pointer(lastChunkPtr)).FnumBytes (*TTkTextDispChunk)(unsafe.Pointer(lastChunkPtr)).FbreakIndex = v6 breakByteOffset = int32(v6) /* * If have we have a tag toggle, there is a chance that * invisibility state changed, so bail out. */ } else { if (*TTkTextSegment)(unsafe.Pointer(segPtr)).FtypePtr == uintptr(unsafe.Pointer(&XtkTextToggleOffType)) || (*TTkTextSegment)(unsafe.Pointer(segPtr)).FtypePtr == uintptr(unsafe.Pointer(&XtkTextToggleOnType)) { if (*TTkTextTag1)(unsafe.Pointer((*(*TTkTextToggle)(unsafe.Pointer(&(*TTkTextSegment)(unsafe.Pointer(segPtr)).Fbody))).FtagPtr)).Felide >= 0 { elide = libc.BoolInt32((*TTkTextSegment)(unsafe.Pointer(segPtr)).FtypePtr == uintptr(unsafe.Pointer(&XtkTextToggleOffType))) ^ libc.BoolInt32((*TTkTextTag1)(unsafe.Pointer((*(*TTkTextToggle)(unsafe.Pointer(&(*TTkTextSegment)(unsafe.Pointer(segPtr)).Fbody))).FtagPtr)).Felide > 0) } } } *(*TTcl_Size)(unsafe.Pointer(bp + 72)) = 0 segPtr = (*TTkTextSegment)(unsafe.Pointer(segPtr)).FnextPtr if segPtr == libc.UintptrFromInt32(0) { /* * Two logical lines merged into one display line through * eliding of a newline. */ linePtr1 = XTkBTreeNextLine(tls, libc.UintptrFromInt32(0), (*(*TTkTextIndex)(unsafe.Pointer(bp))).FlinePtr) if linePtr1 != libc.UintptrFromInt32(0) { (*TDLine)(unsafe.Pointer(dlPtr)).FlogicalLinesMerged++ (*(*TTkTextIndex)(unsafe.Pointer(bp))).FbyteIndex = 0 (*(*TTkTextIndex)(unsafe.Pointer(bp))).FlinePtr = linePtr1 goto connectNextLogicalLine } } /* * Code no longer needed, now that we allow logical lines to merge * into a single display line. * if (segPtr == NULL && chunkPtr != NULL) { ckfree(chunkPtr); chunkPtr = NULL; } */ continue } if (*TTk_SegType1)(unsafe.Pointer((*TTkTextSegment)(unsafe.Pointer(segPtr)).FtypePtr)).FlayoutProc == libc.UintptrFromInt32(0) { segPtr = (*TTkTextSegment)(unsafe.Pointer(segPtr)).FnextPtr *(*TTcl_Size)(unsafe.Pointer(bp + 72)) = 0 continue } if chunkPtr == libc.UintptrFromInt32(0) { chunkPtr = libtcl9_0.XTcl_Alloc(tls, uint64(96)) (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FnextPtr = libc.UintptrFromInt32(0) (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FclientData = libc.UintptrFromInt32(0) } (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FstylePtr = _GetStyle(tls, textPtr, bp) elide = (*TStyleValues)(unsafe.Pointer((*TTextStyle1)(unsafe.Pointer((*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FstylePtr)).FsValuePtr)).Felide /* * Save style information such as justification and indentation, up * until the first character is encountered, then retain that * information for the rest of the line. */ if !(elide != 0) && noCharsYet != 0 { tabArrayPtr = (*TStyleValues)(unsafe.Pointer((*TTextStyle1)(unsafe.Pointer((*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FstylePtr)).FsValuePtr)).FtabArrayPtr tabStyle = (*TStyleValues)(unsafe.Pointer((*TTextStyle1)(unsafe.Pointer((*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FstylePtr)).FsValuePtr)).FtabStyle justify = (*TStyleValues)(unsafe.Pointer((*TTextStyle1)(unsafe.Pointer((*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FstylePtr)).FsValuePtr)).Fjustify rMargin = (*TStyleValues)(unsafe.Pointer((*TTextStyle1)(unsafe.Pointer((*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FstylePtr)).FsValuePtr)).FrMargin wrapMode = (*TStyleValues)(unsafe.Pointer((*TTextStyle1)(unsafe.Pointer((*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FstylePtr)).FsValuePtr)).FwrapMode /* * See above - this test may not be entirely correct where we have * partially elided lines (and therefore merged logical lines). * In such a case a byteIndex of zero doesn't necessarily mean the * beginning of a logical line. */ if paragraphStart != 0 { /* * Beginning of logical line. */ x = (*TStyleValues)(unsafe.Pointer((*TTextStyle1)(unsafe.Pointer((*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FstylePtr)).FsValuePtr)).FlMargin1 } else { /* * Beginning of display line. */ x = (*TStyleValues)(unsafe.Pointer((*TTextStyle1)(unsafe.Pointer((*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FstylePtr)).FsValuePtr)).FlMargin2 } (*TDLine)(unsafe.Pointer(dlPtr)).FlMarginWidth = x if wrapMode == int32(TEXT_WRAPMODE_NONE) { maxX = -int32(1) } else { maxX = (*TTextDInfo1)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FdInfoPtr)).FmaxX - (*TTextDInfo1)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FdInfoPtr)).Fx - rMargin if maxX < x { maxX = x } } } gotTab = 0 maxBytes = int32((*TTkTextSegment)(unsafe.Pointer(segPtr)).Fsize - *(*TTcl_Size)(unsafe.Pointer(bp + 72))) if (*TTkTextSegment)(unsafe.Pointer(segPtr)).FtypePtr == uintptr(unsafe.Pointer(&XtkTextCharType)) { /* * See if there is a tab in the current chunk; if so, only layout * characters up to (and including) the tab. */ if !(elide != 0) && justify == int32(TK_JUSTIFY_LEFT) { p = segPtr + 24 + uintptr(*(*TTcl_Size)(unsafe.Pointer(bp + 72))) for { if !(libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(p))) != 0) { break } if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(p))) == int32('\t') { maxBytes = int32(int64(p+libc.UintptrFromInt32(1)) - T__predefined_ptrdiff_t(segPtr+24) - *(*TTcl_Size)(unsafe.Pointer(bp + 72))) gotTab = int32(1) break } goto _7 _7: ; p++ } } } (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).Fx = x if elide != 0 { /* * Don't free style here, as other code expects to be able to do * that. */ /* breakByteOffset =*/ v8 = int64(maxBytes) (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FnumBytes = v8 (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FbreakIndex = v8 (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).Fwidth = 0 v10 = libc.Int32FromInt32(0) (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FminHeight = v10 v9 = v10 (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FminDescent = v9 (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FminAscent = v9 /* * Would just like to point to canonical empty chunk. */ (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FdisplayProc = libc.UintptrFromInt32(0) (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FundisplayProc = libc.UintptrFromInt32(0) (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FmeasureProc = __ccgo_fp(_ElideMeasureProc) (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FbboxProc = __ccgo_fp(_ElideBboxProc) code = int32(1) } else { code = (*(*func(*libc.TLS, uintptr, uintptr, uintptr, TTcl_Size, int32, TTcl_Size, int32, TTkWrapMode, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*TTk_SegType1)(unsafe.Pointer((*TTkTextSegment)(unsafe.Pointer(segPtr)).FtypePtr)).FlayoutProc})))(tls, textPtr, bp, segPtr, *(*TTcl_Size)(unsafe.Pointer(bp + 72)), maxX-tabSize, int64(maxBytes), noCharsYet, wrapMode, chunkPtr) } if code <= 0 { _FreeStyle(tls, textPtr, (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FstylePtr) if code < 0 { /* * This segment doesn't wish to display itself (e.g. most * marks). */ segPtr = (*TTkTextSegment)(unsafe.Pointer(segPtr)).FnextPtr *(*TTcl_Size)(unsafe.Pointer(bp + 72)) = 0 continue } /* * No characters from this segment fit in the window: this means * we're at the end of the display line. */ if chunkPtr != libc.UintptrFromInt32(0) { libtcl9_0.XTcl_Free(tls, chunkPtr) } break } /* * We currently say we have some characters (and therefore something * from which to examine tag values for the first character of the * line) even if those characters are actually elided. This behaviour * is not well documented, and it might be more consistent to * completely ignore such elided characters and their tags. To do so * change this to: * * if (!elide && chunkPtr->numBytes > 0). */ if !(elide != 0) && (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FnumBytes > 0 { noCharsYet = 0 lastCharChunkPtr = chunkPtr } if lastChunkPtr == libc.UintptrFromInt32(0) { (*TDLine)(unsafe.Pointer(dlPtr)).FchunkPtr = chunkPtr } else { (*TTkTextDispChunk)(unsafe.Pointer(lastChunkPtr)).FnextPtr = chunkPtr } lastChunkPtr = chunkPtr x += (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).Fwidth if (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FbreakIndex > 0 { breakByteOffset = int32((*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FbreakIndex) *(*TTkTextIndex)(unsafe.Pointer(bp + 32)) = *(*TTkTextIndex)(unsafe.Pointer(bp)) breakChunkPtr = chunkPtr } if (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FnumBytes != int64(maxBytes) { break } /* * If we're at a new tab, adjust the layout for all the chunks * pertaining to the previous tab. Also adjust the amount of space * left in the line to account for space that will be eaten up by the * tab. */ if gotTab != 0 { if *(*int32)(unsafe.Pointer(bp + 64)) >= 0 { _AdjustForTab(tls, textPtr, tabArrayPtr, *(*int32)(unsafe.Pointer(bp + 64)), tabChunkPtr) x = (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).Fx + (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).Fwidth } tabChunkPtr = chunkPtr tabSize = _SizeOfTab(tls, textPtr, tabStyle, tabArrayPtr, bp+64, x, maxX) if maxX >= 0 && tabSize >= maxX-x { break } } (*(*TTkTextIndex)(unsafe.Pointer(bp))).FbyteIndex += (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FnumBytes *(*TTcl_Size)(unsafe.Pointer(bp + 72)) += (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FnumBytes if *(*TTcl_Size)(unsafe.Pointer(bp + 72)) >= (*TTkTextSegment)(unsafe.Pointer(segPtr)).Fsize { *(*TTcl_Size)(unsafe.Pointer(bp + 72)) = 0 segPtr = (*TTkTextSegment)(unsafe.Pointer(segPtr)).FnextPtr if elide != 0 && segPtr == libc.UintptrFromInt32(0) { /* * An elided section started on this line, and carries on * until the newline. Hence the newline is actually elided, * and we want to merge the display of the next logical line * with this one. */ linePtr2 = XTkBTreeNextLine(tls, libc.UintptrFromInt32(0), (*(*TTkTextIndex)(unsafe.Pointer(bp))).FlinePtr) if linePtr2 != libc.UintptrFromInt32(0) { (*TDLine)(unsafe.Pointer(dlPtr)).FlogicalLinesMerged++ (*(*TTkTextIndex)(unsafe.Pointer(bp))).FbyteIndex = 0 (*(*TTkTextIndex)(unsafe.Pointer(bp))).FlinePtr = linePtr2 chunkPtr = libc.UintptrFromInt32(0) goto connectNextLogicalLine } } } chunkPtr = libc.UintptrFromInt32(0) } if noCharsYet != 0 { (*TDLine)(unsafe.Pointer(dlPtr)).FspaceAbove = 0 (*TDLine)(unsafe.Pointer(dlPtr)).FspaceBelow = 0 (*TDLine)(unsafe.Pointer(dlPtr)).Flength = 0 /* * We used to Tcl_Panic here, saying that LayoutDLine couldn't place * any characters on a line, but I believe a more appropriate response * is to return a DLine with zero height. With elided lines, tag * transitions and asynchronous line height calculations, it is hard * to avoid this situation ever arising with the current code design. */ return dlPtr } wholeLine = libc.BoolInt32(segPtr == libc.UintptrFromInt32(0)) /* * We're at the end of the display line. Throw away everything after the * most recent word break, if there is one; this may potentially require * the last chunk to be layed out again. */ if breakChunkPtr == libc.UintptrFromInt32(0) { /* * This code makes sure that we don't accidentally display chunks with * no characters at the end of the line (such as the insertion * cursor). These chunks belong on the next line. So, throw away * everything after the last chunk that has characters in it. */ breakChunkPtr = lastCharChunkPtr breakByteOffset = int32((*TTkTextDispChunk)(unsafe.Pointer(breakChunkPtr)).FnumBytes) } if breakChunkPtr != libc.UintptrFromInt32(0) && (lastChunkPtr != breakChunkPtr || int64(breakByteOffset) != (*TTkTextDispChunk)(unsafe.Pointer(lastChunkPtr)).FnumBytes) { for int32(1) != 0 { chunkPtr = (*TTkTextDispChunk)(unsafe.Pointer(breakChunkPtr)).FnextPtr if chunkPtr == libc.UintptrFromInt32(0) { break } _FreeStyle(tls, textPtr, (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FstylePtr) (*TTkTextDispChunk)(unsafe.Pointer(breakChunkPtr)).FnextPtr = (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FnextPtr if (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FundisplayProc != libc.UintptrFromInt32(0) { (*(*func(*libc.TLS, uintptr, uintptr))(unsafe.Pointer(&struct{ uintptr }{(*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FundisplayProc})))(tls, textPtr, chunkPtr) } libtcl9_0.XTcl_Free(tls, chunkPtr) } if int64(breakByteOffset) != (*TTkTextDispChunk)(unsafe.Pointer(breakChunkPtr)).FnumBytes { if (*TTkTextDispChunk)(unsafe.Pointer(breakChunkPtr)).FundisplayProc != libc.UintptrFromInt32(0) { (*(*func(*libc.TLS, uintptr, uintptr))(unsafe.Pointer(&struct{ uintptr }{(*TTkTextDispChunk)(unsafe.Pointer(breakChunkPtr)).FundisplayProc})))(tls, textPtr, breakChunkPtr) } segPtr = XTkTextIndexToSeg(tls, bp+32, bp+72) (*(*func(*libc.TLS, uintptr, uintptr, uintptr, TTcl_Size, int32, TTcl_Size, int32, TTkWrapMode, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*TTk_SegType1)(unsafe.Pointer((*TTkTextSegment)(unsafe.Pointer(segPtr)).FtypePtr)).FlayoutProc})))(tls, textPtr, bp+32, segPtr, *(*TTcl_Size)(unsafe.Pointer(bp + 72)), maxX, int64(breakByteOffset), 0, wrapMode, breakChunkPtr) } lastChunkPtr = breakChunkPtr wholeLine = 0 } /* * Make tab adjustments for the last tab stop, if there is one. */ if *(*int32)(unsafe.Pointer(bp + 64)) >= 0 && tabChunkPtr != libc.UintptrFromInt32(0) { _AdjustForTab(tls, textPtr, tabArrayPtr, *(*int32)(unsafe.Pointer(bp + 64)), tabChunkPtr) } /* * Make one more pass over the line to recompute various things like its * height, length, and total number of bytes. Also modify the x-locations * of chunks to reflect justification. If we're not wrapping, I'm not sure * what is the best way to handle right and center justification: should * the total length, for purposes of justification, be (a) the window * width, (b) the length of the longest line in the window, or (c) the * length of the longest line in the text? (c) isn't available, (b) seems * weird, since it can change with vertical scrolling, so (a) is what is * implemented below. */ if wrapMode == int32(TEXT_WRAPMODE_NONE) { maxX = (*TTextDInfo1)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FdInfoPtr)).FmaxX - (*TTextDInfo1)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FdInfoPtr)).Fx - rMargin } (*TDLine)(unsafe.Pointer(dlPtr)).Flength = (*TTkTextDispChunk)(unsafe.Pointer(lastChunkPtr)).Fx + (*TTkTextDispChunk)(unsafe.Pointer(lastChunkPtr)).Fwidth if justify == int32(TK_JUSTIFY_LEFT) { jIndent = 0 } else { if justify == int32(TK_JUSTIFY_RIGHT) { jIndent = maxX - (*TDLine)(unsafe.Pointer(dlPtr)).Flength } else { jIndent = (maxX - (*TDLine)(unsafe.Pointer(dlPtr)).Flength) / int32(2) } } v11 = libc.Int32FromInt32(0) descent = v11 ascent = v11 chunkPtr = (*TDLine)(unsafe.Pointer(dlPtr)).FchunkPtr for { if !(chunkPtr != libc.UintptrFromInt32(0)) { break } *(*int32)(unsafe.Pointer(chunkPtr)) += jIndent p13 = dlPtr + 32 *(*int32)(unsafe.Pointer(p13)) = int32(int64(*(*int32)(unsafe.Pointer(p13))) + (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FnumBytes) if (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FminAscent > ascent { ascent = (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FminAscent } if (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FminDescent > descent { descent = (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FminDescent } if (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FminHeight > (*TDLine)(unsafe.Pointer(dlPtr)).Fheight { (*TDLine)(unsafe.Pointer(dlPtr)).Fheight = (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FminHeight } sValuePtr = (*TTextStyle1)(unsafe.Pointer((*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FstylePtr)).FsValuePtr if (*TStyleValues)(unsafe.Pointer(sValuePtr)).FborderWidth > 0 && (*TStyleValues)(unsafe.Pointer(sValuePtr)).Frelief != TK_RELIEF_FLAT { *(*int32)(unsafe.Pointer(dlPtr + 112)) |= int32(HAS_3D_BORDER) } goto _12 _12: ; chunkPtr = (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FnextPtr } if (*TDLine)(unsafe.Pointer(dlPtr)).Fheight < ascent+descent { (*TDLine)(unsafe.Pointer(dlPtr)).Fheight = ascent + descent (*TDLine)(unsafe.Pointer(dlPtr)).Fbaseline = ascent } else { (*TDLine)(unsafe.Pointer(dlPtr)).Fbaseline = ascent + ((*TDLine)(unsafe.Pointer(dlPtr)).Fheight-ascent-descent)/int32(2) } sValuePtr = (*TTextStyle1)(unsafe.Pointer((*TTkTextDispChunk)(unsafe.Pointer((*TDLine)(unsafe.Pointer(dlPtr)).FchunkPtr)).FstylePtr)).FsValuePtr if (*TDLine)(unsafe.Pointer(dlPtr)).Findex.FbyteIndex == 0 { (*TDLine)(unsafe.Pointer(dlPtr)).FspaceAbove = (*TStyleValues)(unsafe.Pointer(sValuePtr)).Fspacing1 } else { (*TDLine)(unsafe.Pointer(dlPtr)).FspaceAbove = (*TStyleValues)(unsafe.Pointer(sValuePtr)).Fspacing2 - (*TStyleValues)(unsafe.Pointer(sValuePtr)).Fspacing2/int32(2) } if wholeLine != 0 { (*TDLine)(unsafe.Pointer(dlPtr)).FspaceBelow = (*TStyleValues)(unsafe.Pointer(sValuePtr)).Fspacing3 } else { (*TDLine)(unsafe.Pointer(dlPtr)).FspaceBelow = (*TStyleValues)(unsafe.Pointer(sValuePtr)).Fspacing2 / int32(2) } *(*int32)(unsafe.Pointer(dlPtr + 48)) += (*TDLine)(unsafe.Pointer(dlPtr)).FspaceAbove + (*TDLine)(unsafe.Pointer(dlPtr)).FspaceBelow *(*int32)(unsafe.Pointer(dlPtr + 52)) += (*TDLine)(unsafe.Pointer(dlPtr)).FspaceAbove (*TDLine)(unsafe.Pointer(dlPtr)).FlMarginColor = (*TStyleValues)(unsafe.Pointer(sValuePtr)).FlMarginColor (*TDLine)(unsafe.Pointer(dlPtr)).FrMarginColor = (*TStyleValues)(unsafe.Pointer(sValuePtr)).FrMarginColor if wrapMode != int32(TEXT_WRAPMODE_NONE) { (*TDLine)(unsafe.Pointer(dlPtr)).FrMarginWidth = rMargin } /* * Recompute line length: may have changed because of justification. */ (*TDLine)(unsafe.Pointer(dlPtr)).Flength = (*TTkTextDispChunk)(unsafe.Pointer(lastChunkPtr)).Fx + (*TTkTextDispChunk)(unsafe.Pointer(lastChunkPtr)).Fwidth return dlPtr } /* *---------------------------------------------------------------------- * * UpdateDisplayInfo -- * * This function is invoked to recompute some or all of the DLine * structures for a text widget. At the time it is called the DLine * structures still left in the widget are guaranteed to be correct * except that (a) the y-coordinates aren't necessarily correct, (b) * there may be missing structures (the DLine structures get removed as * soon as they are potentially out-of-date), and (c) DLine structures * that don't start at the beginning of a line may be incorrect if * previous information in the same line changed size in a way that moved * a line boundary (DLines for any info that changed will have been * deleted, but not DLines for unchanged info in the same text line). * * Results: * None. * * Side effects: * Upon return, the DLine information for textPtr correctly reflects the * positions where characters will be displayed. However, this function * doesn't actually bring the display up-to-date. * *---------------------------------------------------------------------- */ func _UpdateDisplayInfo(tls *libc.TLS, textPtr uintptr) { bp := tls.Alloc(96) defer tls.Free(96) /* Text widget to update. */ var bytesToCount, lineHeight, lineNum, maxOffset, maxY, pixelHeight, spaceLeft, xPixelOffset, y int32 var dInfoPtr, dlPtr, lastLinePtr, lowestPtr, newPtr, nextPtr, prevPtr uintptr var _ /* index at bp+0 */ TTkTextIndex var _ /* string at bp+32 */ [30]uint8 var _ /* string at bp+62 */ [30]uint8 _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = bytesToCount, dInfoPtr, dlPtr, lastLinePtr, lineHeight, lineNum, lowestPtr, maxOffset, maxY, newPtr, nextPtr, pixelHeight, prevPtr, spaceLeft, xPixelOffset, y dInfoPtr = (*TTkText)(unsafe.Pointer(textPtr)).FdInfoPtr if !((*TTextDInfo)(unsafe.Pointer(dInfoPtr)).Fflags&libc.Int32FromInt32(DINFO_OUT_OF_DATE) != 0) { return } *(*int32)(unsafe.Pointer(dInfoPtr + 220)) &= ^libc.Int32FromInt32(DINFO_OUT_OF_DATE) /* * Delete any DLines that are now above the top of the window. */ *(*TTkTextIndex)(unsafe.Pointer(bp)) = (*TTkText)(unsafe.Pointer(textPtr)).FtopIndex dlPtr = _FindDLine(tls, textPtr, (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FdLinePtr, bp) if dlPtr != libc.UintptrFromInt32(0) && dlPtr != (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FdLinePtr { _FreeDLines(tls, textPtr, (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FdLinePtr, dlPtr, int32(DLINE_UNLINK)) } if (*(*TTkTextIndex)(unsafe.Pointer(bp))).FbyteIndex == 0 { lineHeight = 0 } else { lineHeight = -int32(1) } /* * Scan through the contents of the window from top to bottom, recomputing * information for lines that are missing. */ lastLinePtr = XTkBTreeFindLine(tls, (*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).Ftree, textPtr, XTkBTreeNumLines(tls, (*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).Ftree, textPtr)) dlPtr = (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FdLinePtr prevPtr = libc.UintptrFromInt32(0) y = (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).Fy - (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FnewTopPixelOffset maxY = (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FmaxY for int32(1) != 0 { if (*(*TTkTextIndex)(unsafe.Pointer(bp))).FlinePtr == lastLinePtr { break } /* * There are three possibilities right now: * (a) the next DLine (dlPtr) corresponds exactly to the next * information we want to display: just use it as-is. * (b) the next DLine corresponds to a different line, or to a segment * that will be coming later in the same line: leave this DLine * alone in the hopes that we'll be able to use it later, then * create a new DLine in front of it. * (c) the next DLine corresponds to a segment in the line we want, * but it's a segment that has already been processed or will * never be processed. Delete the DLine and try again. * * One other twist on all this. It's possible for 3D borders to * interact between lines (see DisplayLineBackground) so if a line is * relayed out and has styles with 3D borders, its neighbors have to * be redrawn if they have 3D borders too, since the interactions * could have changed (the neighbors don't have to be relayed out, * just redrawn). */ if !(dlPtr == libc.UintptrFromInt32(0) || (*TDLine)(unsafe.Pointer(dlPtr)).Findex.FlinePtr != (*(*TTkTextIndex)(unsafe.Pointer(bp))).FlinePtr) { goto _1 } /* * Case (b) -- must make new DLine. */ goto makeNewDLine makeNewDLine: ; if XtkTextDebug != 0 { /* * Debugging is enabled, so keep a log of all the lines that * were re-layed out. The test suite uses this information. */ XTkTextPrintIndex(tls, textPtr, bp, bp+32) libtcl9_0.XTcl_SetVar2(tls, (*TTkText)(unsafe.Pointer(textPtr)).Finterp, __ccgo_ts+46947, libc.UintptrFromInt32(0), bp+32, libc.Int32FromInt32(TCL_GLOBAL_ONLY)|libc.Int32FromInt32(TCL_APPEND_VALUE)|libc.Int32FromInt32(TCL_LIST_ELEMENT)) } newPtr = _LayoutDLine(tls, textPtr, bp) if prevPtr == libc.UintptrFromInt32(0) { (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FdLinePtr = newPtr } else { (*TDLine)(unsafe.Pointer(prevPtr)).FnextPtr = newPtr if (*TDLine)(unsafe.Pointer(prevPtr)).Fflags&int32(HAS_3D_BORDER) != 0 { *(*int32)(unsafe.Pointer(prevPtr + 112)) |= int32(OLD_Y_INVALID) } } (*TDLine)(unsafe.Pointer(newPtr)).FnextPtr = dlPtr dlPtr = newPtr goto _2 _1: ; /* * DlPtr refers to the line we want. Next check the index within * the line. */ if (*(*TTkTextIndex)(unsafe.Pointer(bp))).FbyteIndex == (*TDLine)(unsafe.Pointer(dlPtr)).Findex.FbyteIndex { /* * Case (a) - can use existing display line as-is. */ if (*TDLine)(unsafe.Pointer(dlPtr)).Fflags&int32(HAS_3D_BORDER) != 0 && prevPtr != libc.UintptrFromInt32(0) && (*TDLine)(unsafe.Pointer(prevPtr)).Fflags&int32(NEW_LAYOUT) != 0 { *(*int32)(unsafe.Pointer(dlPtr + 112)) |= int32(OLD_Y_INVALID) } goto lineOK } if (*(*TTkTextIndex)(unsafe.Pointer(bp))).FbyteIndex < (*TDLine)(unsafe.Pointer(dlPtr)).Findex.FbyteIndex { goto makeNewDLine } /* * Case (c) - dlPtr is useless. Discard it and start again with * the next display line. */ newPtr = (*TDLine)(unsafe.Pointer(dlPtr)).FnextPtr _FreeDLines(tls, textPtr, dlPtr, newPtr, DLINE_FREE) dlPtr = newPtr if prevPtr != libc.UintptrFromInt32(0) { (*TDLine)(unsafe.Pointer(prevPtr)).FnextPtr = newPtr } else { (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FdLinePtr = newPtr } continue _2: ; /* * Advance to the start of the next line. */ goto lineOK lineOK: ; (*TDLine)(unsafe.Pointer(dlPtr)).Fy = y y += (*TDLine)(unsafe.Pointer(dlPtr)).Fheight if lineHeight != -int32(1) { lineHeight += (*TDLine)(unsafe.Pointer(dlPtr)).Fheight } XTkTextIndexForwBytes(tls, textPtr, bp, int64((*TDLine)(unsafe.Pointer(dlPtr)).FbyteCount), bp) prevPtr = dlPtr dlPtr = (*TDLine)(unsafe.Pointer(dlPtr)).FnextPtr /* * If we switched text lines, delete any DLines left for the old text * line. */ if (*(*TTkTextIndex)(unsafe.Pointer(bp))).FlinePtr != (*TDLine)(unsafe.Pointer(prevPtr)).Findex.FlinePtr { nextPtr = dlPtr for nextPtr != libc.UintptrFromInt32(0) && (*TDLine)(unsafe.Pointer(nextPtr)).Findex.FlinePtr == (*TDLine)(unsafe.Pointer(prevPtr)).Findex.FlinePtr { nextPtr = (*TDLine)(unsafe.Pointer(nextPtr)).FnextPtr } if nextPtr != dlPtr { _FreeDLines(tls, textPtr, dlPtr, nextPtr, DLINE_FREE) (*TDLine)(unsafe.Pointer(prevPtr)).FnextPtr = nextPtr dlPtr = nextPtr } if lineHeight != -int32(1) && *(*int32)(unsafe.Pointer((*TTkTextLine)(unsafe.Pointer((*TDLine)(unsafe.Pointer(prevPtr)).Findex.FlinePtr)).Fpixels + uintptr(int32(2)*(*TTkText)(unsafe.Pointer(textPtr)).FpixelReference)*4)) != lineHeight { /* * The logical line height we just calculated is actually * different to the currently cached height of the text line. * That is fine (the text line heights are only calculated * asynchronously), but we must update the cached height so * that any counts made with DLine pointers are the same as * counts made through the BTree. This helps to ensure that * the scrollbar size corresponds accurately to that displayed * contents, even as the window is re-sized. */ XTkBTreeAdjustPixelHeight(tls, textPtr, (*TDLine)(unsafe.Pointer(prevPtr)).Findex.FlinePtr, lineHeight, 0) /* * I believe we can be 100% sure that we started at the * beginning of the logical line, so we can also adjust the * 'pixelCalculationEpoch' to mark it as being up to date. * There is a slight concern that we might not have got this * right for the first line in the re-display. */ *(*int32)(unsafe.Pointer((*TTkTextLine)(unsafe.Pointer((*TDLine)(unsafe.Pointer(prevPtr)).Findex.FlinePtr)).Fpixels + uintptr(int32(1)+int32(2)*(*TTkText)(unsafe.Pointer(textPtr)).FpixelReference)*4)) = (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FlineMetricUpdateEpoch } lineHeight = 0 } /* * It's important to have the following check here rather than in the * while statement for the loop, so that there's always at least one * DLine generated, regardless of how small the window is. This keeps * a lot of other code from breaking. */ if y >= maxY { break } } /* * Delete any DLine structures that don't fit on the screen. */ _FreeDLines(tls, textPtr, dlPtr, libc.UintptrFromInt32(0), int32(DLINE_UNLINK)) /* * If there is extra space at the bottom of the window (because we've hit * the end of the text), then bring in more lines at the top of the * window, if there are any, to fill in the view. * * Since the top line may only be partially visible, we try first to * simply show more pixels from that line (newTopPixelOffset). If that * isn't enough, we have to layout more lines. */ if y < maxY { /* * This counts how many vertical pixels we have left to fill by * pulling in more display pixels either from the first currently * displayed, or the lines above it. */ spaceLeft = maxY - y if spaceLeft <= (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FnewTopPixelOffset { /* * We can fill up all the needed space just by showing more of the * current top line. */ *(*int32)(unsafe.Pointer(dInfoPtr + 116)) -= spaceLeft y += spaceLeft spaceLeft = 0 } else { /* * Add in all of the current top line, which won't be enough to * bring y up to maxY (if it was we would be in the 'if' block * above). */ y += (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FnewTopPixelOffset (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FnewTopPixelOffset = 0 /* * Layout an entire text line (potentially > 1 display line), then * link in as many display lines as fit without moving the bottom * line out of the window. Repeat this until all the extra space * has been used up or we've reached the beginning of the text. */ spaceLeft = maxY - y if (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FdLinePtr == libc.UintptrFromInt32(0) { /* * No lines have been laid out. This must be an empty peer * widget. */ lineNum = XTkBTreeNumLines(tls, (*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).Ftree, textPtr) - int32(1) bytesToCount = int32(INT_MAX) } else { lineNum = XTkBTreeLinesTo(tls, textPtr, (*TDLine)(unsafe.Pointer((*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FdLinePtr)).Findex.FlinePtr) bytesToCount = int32((*TDLine)(unsafe.Pointer((*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FdLinePtr)).Findex.FbyteIndex) if bytesToCount == 0 { bytesToCount = int32(INT_MAX) lineNum-- } } for { if !(lineNum >= 0 && spaceLeft > 0) { break } pixelHeight = 0 (*(*TTkTextIndex)(unsafe.Pointer(bp))).FlinePtr = XTkBTreeFindLine(tls, (*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).Ftree, textPtr, lineNum) (*(*TTkTextIndex)(unsafe.Pointer(bp))).FbyteIndex = 0 lowestPtr = libc.UintptrFromInt32(0) for cond := true; cond; cond = bytesToCount > 0 && (*(*TTkTextIndex)(unsafe.Pointer(bp))).FlinePtr == (*TDLine)(unsafe.Pointer(lowestPtr)).Findex.FlinePtr { dlPtr = _LayoutDLine(tls, textPtr, bp) pixelHeight += (*TDLine)(unsafe.Pointer(dlPtr)).Fheight (*TDLine)(unsafe.Pointer(dlPtr)).FnextPtr = lowestPtr lowestPtr = dlPtr if (*TDLine)(unsafe.Pointer(dlPtr)).Flength == 0 && (*TDLine)(unsafe.Pointer(dlPtr)).Fheight == 0 { bytesToCount-- break } /* elide */ XTkTextIndexForwBytes(tls, textPtr, bp, int64((*TDLine)(unsafe.Pointer(dlPtr)).FbyteCount), bp) bytesToCount -= (*TDLine)(unsafe.Pointer(dlPtr)).FbyteCount } /* * We may not have examined the entire line (depending on the * value of 'bytesToCount', so we only want to set this if it * is genuinely bigger). */ if pixelHeight > *(*int32)(unsafe.Pointer((*TTkTextLine)(unsafe.Pointer((*TDLine)(unsafe.Pointer(lowestPtr)).Findex.FlinePtr)).Fpixels + uintptr(int32(2)*(*TTkText)(unsafe.Pointer(textPtr)).FpixelReference)*4)) { XTkBTreeAdjustPixelHeight(tls, textPtr, (*TDLine)(unsafe.Pointer(lowestPtr)).Findex.FlinePtr, pixelHeight, 0) if (*(*TTkTextIndex)(unsafe.Pointer(bp))).FlinePtr != (*TDLine)(unsafe.Pointer(lowestPtr)).Findex.FlinePtr { /* * We examined the entire line, so can update the * epoch. */ *(*int32)(unsafe.Pointer((*TTkTextLine)(unsafe.Pointer((*TDLine)(unsafe.Pointer(lowestPtr)).Findex.FlinePtr)).Fpixels + uintptr(int32(1)+int32(2)*(*TTkText)(unsafe.Pointer(textPtr)).FpixelReference)*4)) = (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FlineMetricUpdateEpoch } } /* * Scan through the display lines from the bottom one up to * the top one. */ for lowestPtr != libc.UintptrFromInt32(0) { dlPtr = lowestPtr spaceLeft -= (*TDLine)(unsafe.Pointer(dlPtr)).Fheight lowestPtr = (*TDLine)(unsafe.Pointer(dlPtr)).FnextPtr (*TDLine)(unsafe.Pointer(dlPtr)).FnextPtr = (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FdLinePtr (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FdLinePtr = dlPtr if XtkTextDebug != 0 { XTkTextPrintIndex(tls, textPtr, dlPtr, bp+62) libtcl9_0.XTcl_SetVar2(tls, (*TTkText)(unsafe.Pointer(textPtr)).Finterp, __ccgo_ts+46947, libc.UintptrFromInt32(0), bp+62, libc.Int32FromInt32(TCL_GLOBAL_ONLY)|libc.Int32FromInt32(TCL_APPEND_VALUE)|libc.Int32FromInt32(TCL_LIST_ELEMENT)) } if spaceLeft <= 0 { break } } _FreeDLines(tls, textPtr, lowestPtr, libc.UintptrFromInt32(0), DLINE_FREE) bytesToCount = int32(INT_MAX) goto _3 _3: ; lineNum-- } /* * We've either filled in the space we wanted to or we've run out * of display lines at the top of the text. Note that we already * set dInfoPtr->newTopPixelOffset to zero above. */ if spaceLeft < 0 { /* * We've laid out a few too many vertical pixels at or above * the first line. Therefore we only want to show part of the * first displayed line, so that the last displayed line just * fits in the window. */ (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FnewTopPixelOffset = -spaceLeft if (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FnewTopPixelOffset >= (*TDLine)(unsafe.Pointer((*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FdLinePtr)).Fheight { /* * Somehow the entire first line we laid out is shorter * than the new offset. This should not occur and would * indicate a bad problem in the logic above. */ libtcl9_0.XTcl_Panic(tls, __ccgo_ts+46963, 0) } } } /* * Now we're all done except that the y-coordinates in all the DLines * are wrong and the top index for the text is wrong. Update them. */ if (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FdLinePtr != libc.UintptrFromInt32(0) { (*TTkText)(unsafe.Pointer(textPtr)).FtopIndex = (*TDLine)(unsafe.Pointer((*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FdLinePtr)).Findex y = (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).Fy - (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FnewTopPixelOffset dlPtr = (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FdLinePtr for { if !(dlPtr != libc.UintptrFromInt32(0)) { break } if y > (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FmaxY { libtcl9_0.XTcl_Panic(tls, __ccgo_ts+47025, 0) } (*TDLine)(unsafe.Pointer(dlPtr)).Fy = y y += (*TDLine)(unsafe.Pointer(dlPtr)).Fheight goto _4 _4: ; dlPtr = (*TDLine)(unsafe.Pointer(dlPtr)).FnextPtr } } } /* * If the old top or bottom line has scrolled elsewhere on the screen, we * may not be able to re-use its old contents by copying bits (e.g., a * beveled edge that was drawn when it was at the top or bottom won't be * drawn when the line is in the middle and its neighbor has a matching * background). Similarly, if the new top or bottom line came from * somewhere else on the screen, we may not be able to copy the old bits. */ dlPtr = (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FdLinePtr if dlPtr != libc.UintptrFromInt32(0) { if (*TDLine)(unsafe.Pointer(dlPtr)).Fflags&int32(HAS_3D_BORDER) != 0 && !((*TDLine)(unsafe.Pointer(dlPtr)).Fflags&libc.Int32FromInt32(TOP_LINE) != 0) { *(*int32)(unsafe.Pointer(dlPtr + 112)) |= int32(OLD_Y_INVALID) } for int32(1) != 0 { if (*TDLine)(unsafe.Pointer(dlPtr)).Fflags&int32(TOP_LINE) != 0 && dlPtr != (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FdLinePtr && (*TDLine)(unsafe.Pointer(dlPtr)).Fflags&int32(HAS_3D_BORDER) != 0 { *(*int32)(unsafe.Pointer(dlPtr + 112)) |= int32(OLD_Y_INVALID) } /* * If the old top-line was not completely showing (i.e. the * pixelOffset is non-zero) and is no longer the top-line, then we * must re-draw it. */ if (*TDLine)(unsafe.Pointer(dlPtr)).Fflags&int32(TOP_LINE) != 0 && (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FtopPixelOffset != 0 && dlPtr != (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FdLinePtr { *(*int32)(unsafe.Pointer(dlPtr + 112)) |= int32(OLD_Y_INVALID) } if (*TDLine)(unsafe.Pointer(dlPtr)).Fflags&int32(BOTTOM_LINE) != 0 && (*TDLine)(unsafe.Pointer(dlPtr)).FnextPtr != libc.UintptrFromInt32(0) && (*TDLine)(unsafe.Pointer(dlPtr)).Fflags&int32(HAS_3D_BORDER) != 0 { *(*int32)(unsafe.Pointer(dlPtr + 112)) |= int32(OLD_Y_INVALID) } if (*TDLine)(unsafe.Pointer(dlPtr)).FnextPtr == libc.UintptrFromInt32(0) { if (*TDLine)(unsafe.Pointer(dlPtr)).Fflags&int32(HAS_3D_BORDER) != 0 && !((*TDLine)(unsafe.Pointer(dlPtr)).Fflags&libc.Int32FromInt32(BOTTOM_LINE) != 0) { *(*int32)(unsafe.Pointer(dlPtr + 112)) |= int32(OLD_Y_INVALID) } *(*int32)(unsafe.Pointer(dlPtr + 112)) &= ^libc.Int32FromInt32(TOP_LINE) *(*int32)(unsafe.Pointer(dlPtr + 112)) |= int32(BOTTOM_LINE) break } *(*int32)(unsafe.Pointer(dlPtr + 112)) &= ^(libc.Int32FromInt32(TOP_LINE) | libc.Int32FromInt32(BOTTOM_LINE)) dlPtr = (*TDLine)(unsafe.Pointer(dlPtr)).FnextPtr } *(*int32)(unsafe.Pointer((*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FdLinePtr + 112)) |= int32(TOP_LINE) (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FtopPixelOffset = (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FnewTopPixelOffset } /* * Arrange for scrollbars to be updated. */ *(*int32)(unsafe.Pointer(textPtr + 672)) |= int32(UPDATE_SCROLLBARS1) /* * Deal with horizontal scrolling: * 1. If there's empty space to the right of the longest line, shift the * screen to the right to fill in the empty space. * 2. If the desired horizontal scroll position has changed, force a full * redisplay of all the lines in the widget. * 3. If the wrap mode isn't "none" then re-scroll to the base position. */ (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FmaxLength = 0 dlPtr = (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FdLinePtr for { if !(dlPtr != libc.UintptrFromInt32(0)) { break } if (*TDLine)(unsafe.Pointer(dlPtr)).Flength > (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FmaxLength { (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FmaxLength = (*TDLine)(unsafe.Pointer(dlPtr)).Flength } goto _5 _5: ; dlPtr = (*TDLine)(unsafe.Pointer(dlPtr)).FnextPtr } maxOffset = (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FmaxLength - ((*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FmaxX - (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).Fx) xPixelOffset = (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FnewXPixelOffset if xPixelOffset > maxOffset { xPixelOffset = maxOffset } if xPixelOffset < 0 { xPixelOffset = 0 } /* * Here's a problem: see the tests textDisp-29.2.1-4 * * If the widget is being created, but has not yet been configured it will * have a maxY of 1 above, and we won't have examined all the lines * (just the first line, in fact), and so maxOffset will not be a true * reflection of the widget's lines. Therefore we must not overwrite the * original newXPixelOffset in this case. */ if !((*TTk_FakeWin)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).Ftkwin)).Fflags&libc.Uint32FromInt32(TK_NEED_CONFIG_NOTIFY) != 0) { (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FnewXPixelOffset = xPixelOffset } if xPixelOffset != (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FcurXPixelOffset { (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FcurXPixelOffset = xPixelOffset dlPtr = (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FdLinePtr for { if !(dlPtr != libc.UintptrFromInt32(0)) { break } *(*int32)(unsafe.Pointer(dlPtr + 112)) |= int32(OLD_Y_INVALID) goto _6 _6: ; dlPtr = (*TDLine)(unsafe.Pointer(dlPtr)).FnextPtr } } } /* *---------------------------------------------------------------------- * * FreeDLines -- * * This function is called to free up all of the resources associated * with one or more DLine structures. * * Results: * None. * * Side effects: * Memory gets freed and various other resources are released. * *---------------------------------------------------------------------- */ func _FreeDLines(tls *libc.TLS, textPtr uintptr, firstPtr uintptr, lastPtr uintptr, action int32) { bp := tls.Alloc(32) defer tls.Free(32) /* DLINE_UNLINK means DLines are currently * linked into the list rooted at * textPtr->dInfoPtr->dLinePtr and they have * to be unlinked. DLINE_FREE means just free * without unlinking. DLINE_FREE_TEMP means * the DLine given is just a temporary one and * we shouldn't invalidate anything for the * overall widget. */ var chunkPtr, nextChunkPtr, nextDLinePtr, prevPtr uintptr var _ /* string at bp+0 */ [30]uint8 _, _, _, _ = chunkPtr, nextChunkPtr, nextDLinePtr, prevPtr if action == int32(DLINE_FREE_TEMP) { _lineHeightsRecalculated++ if XtkTextDebug != 0 { /* * Debugging is enabled, so keep a log of all the lines whose * height was recalculated. The test suite uses this information. */ XTkTextPrintIndex(tls, textPtr, firstPtr, bp) libtcl9_0.XTcl_SetVar2(tls, (*TTkText)(unsafe.Pointer(textPtr)).Finterp, __ccgo_ts+47071, libc.UintptrFromInt32(0), bp, libc.Int32FromInt32(TCL_GLOBAL_ONLY)|libc.Int32FromInt32(TCL_APPEND_VALUE)|libc.Int32FromInt32(TCL_LIST_ELEMENT)) } } else { if action == int32(DLINE_UNLINK) { if (*TTextDInfo1)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FdInfoPtr)).FdLinePtr == firstPtr { (*TTextDInfo1)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FdInfoPtr)).FdLinePtr = lastPtr } else { prevPtr = (*TTextDInfo1)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FdInfoPtr)).FdLinePtr for { if !((*TDLine)(unsafe.Pointer(prevPtr)).FnextPtr != firstPtr) { break } /* Empty loop body. */ goto _1 _1: ; prevPtr = (*TDLine)(unsafe.Pointer(prevPtr)).FnextPtr } (*TDLine)(unsafe.Pointer(prevPtr)).FnextPtr = lastPtr } } } for firstPtr != lastPtr { nextDLinePtr = (*TDLine)(unsafe.Pointer(firstPtr)).FnextPtr chunkPtr = (*TDLine)(unsafe.Pointer(firstPtr)).FchunkPtr for { if !(chunkPtr != libc.UintptrFromInt32(0)) { break } if (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FundisplayProc != libc.UintptrFromInt32(0) { (*(*func(*libc.TLS, uintptr, uintptr))(unsafe.Pointer(&struct{ uintptr }{(*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FundisplayProc})))(tls, textPtr, chunkPtr) } _FreeStyle(tls, textPtr, (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FstylePtr) nextChunkPtr = (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FnextPtr libtcl9_0.XTcl_Free(tls, chunkPtr) goto _2 _2: ; chunkPtr = nextChunkPtr } libtcl9_0.XTcl_Free(tls, firstPtr) firstPtr = nextDLinePtr } if action != int32(DLINE_FREE_TEMP) { (*TTextDInfo1)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FdInfoPtr)).FdLinesInvalidated = int32(1) } } /* *---------------------------------------------------------------------- * * DisplayDLine -- * * This function is invoked to draw a single line on the screen. * * Results: * None. * * Side effects: * The line given by dlPtr is drawn at its correct position in textPtr's * window. Note that this is one *display* line, not one *text* line. * *---------------------------------------------------------------------- */ func _DisplayDLine(tls *libc.TLS, textPtr uintptr, dlPtr uintptr, prevPtr uintptr, pixmap TPixmap) { /* Pixmap to use for double-buffering. Caller * must make sure it's large enough to hold * line. */ var chunkPtr, dInfoPtr, display uintptr var height, x, x1, y, y_off int32 _, _, _, _, _, _, _, _ = chunkPtr, dInfoPtr, display, height, x, x1, y, y_off dInfoPtr = (*TTkText)(unsafe.Pointer(textPtr)).FdInfoPtr y = 0 if (*TDLine)(unsafe.Pointer(dlPtr)).FchunkPtr == libc.UintptrFromInt32(0) { return } display = (*TTk_FakeWin)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).Ftkwin)).Fdisplay height = (*TDLine)(unsafe.Pointer(dlPtr)).Fheight if height+(*TDLine)(unsafe.Pointer(dlPtr)).Fy > (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FmaxY { height = (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FmaxY - (*TDLine)(unsafe.Pointer(dlPtr)).Fy } if (*TDLine)(unsafe.Pointer(dlPtr)).Fy < (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).Fy { y_off = (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).Fy - (*TDLine)(unsafe.Pointer(dlPtr)).Fy height -= y_off } else { y_off = 0 } /* * First, clear the area of the line to the background color for the text * widget. */ XTk_Fill3DRectangle(tls, (*TTkText)(unsafe.Pointer(textPtr)).Ftkwin, pixmap, (*TTkText)(unsafe.Pointer(textPtr)).Fborder, 0, y, (*TTk_FakeWin)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).Ftkwin)).Fchanges.Fwidth, (*TDLine)(unsafe.Pointer(dlPtr)).Fheight, 0, TK_RELIEF_FLAT) /* * Second, draw background information for the whole line. */ _DisplayLineBackground(tls, textPtr, dlPtr, prevPtr, pixmap) /* * Third, draw the background color of the left and right margins. */ if (*TDLine)(unsafe.Pointer(dlPtr)).FlMarginColor != libc.UintptrFromInt32(0) { XTk_Fill3DRectangle(tls, (*TTkText)(unsafe.Pointer(textPtr)).Ftkwin, pixmap, (*TDLine)(unsafe.Pointer(dlPtr)).FlMarginColor, 0, y, (*TDLine)(unsafe.Pointer(dlPtr)).FlMarginWidth+(*TTextDInfo)(unsafe.Pointer(dInfoPtr)).Fx-(*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FcurXPixelOffset, (*TDLine)(unsafe.Pointer(dlPtr)).Fheight, 0, TK_RELIEF_FLAT) } if (*TDLine)(unsafe.Pointer(dlPtr)).FrMarginColor != libc.UintptrFromInt32(0) { XTk_Fill3DRectangle(tls, (*TTkText)(unsafe.Pointer(textPtr)).Ftkwin, pixmap, (*TDLine)(unsafe.Pointer(dlPtr)).FrMarginColor, (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FmaxX-(*TDLine)(unsafe.Pointer(dlPtr)).FrMarginWidth+(*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FcurXPixelOffset, y, (*TDLine)(unsafe.Pointer(dlPtr)).FrMarginWidth, (*TDLine)(unsafe.Pointer(dlPtr)).Fheight, 0, TK_RELIEF_FLAT) } /* * Make another pass through all of the chunks to redraw the insertion * cursor, if it is visible on this line. Must do it here rather than in * the foreground pass below because otherwise a wide insertion cursor * will obscure the character to its left. */ if (*TTkText)(unsafe.Pointer(textPtr)).Fstate != int32(TK_TEXT_STATE_DISABLED) { chunkPtr = (*TDLine)(unsafe.Pointer(dlPtr)).FchunkPtr for { if !(chunkPtr != libc.UintptrFromInt32(0)) { break } if (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FdisplayProc == __ccgo_fp(XTkTextInsertDisplayProc) { x = (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).Fx + (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).Fx - (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FcurXPixelOffset (*(*func(*libc.TLS, uintptr, uintptr, int32, int32, int32, int32, uintptr, TDrawable, int32))(unsafe.Pointer(&struct{ uintptr }{(*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FdisplayProc})))(tls, textPtr, chunkPtr, x, y+(*TDLine)(unsafe.Pointer(dlPtr)).FspaceAbove, (*TDLine)(unsafe.Pointer(dlPtr)).Fheight-(*TDLine)(unsafe.Pointer(dlPtr)).FspaceAbove-(*TDLine)(unsafe.Pointer(dlPtr)).FspaceBelow, (*TDLine)(unsafe.Pointer(dlPtr)).Fbaseline-(*TDLine)(unsafe.Pointer(dlPtr)).FspaceAbove, display, pixmap, (*TDLine)(unsafe.Pointer(dlPtr)).Fy+(*TDLine)(unsafe.Pointer(dlPtr)).FspaceAbove) } goto _1 _1: ; chunkPtr = (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FnextPtr } } /* * Make yet another pass through all of the chunks to redraw all of * foreground information. Note: we have to call the displayProc even for * chunks that are off-screen. This is needed, for example, so that * embedded windows can be unmapped in this case. */ chunkPtr = (*TDLine)(unsafe.Pointer(dlPtr)).FchunkPtr for { if !(chunkPtr != libc.UintptrFromInt32(0)) { break } if (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FdisplayProc == __ccgo_fp(XTkTextInsertDisplayProc) { /* * Already displayed the insertion cursor above. Don't do it again * here. */ goto _2 } /* * Don't call if elide. This tax OK since not very many visible DLines * in an area, but potentially many elide ones. */ if (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FdisplayProc != libc.UintptrFromInt32(0) { x1 = (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).Fx + (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).Fx - (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FcurXPixelOffset if x1+(*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).Fwidth <= 0 || x1 >= (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FmaxX { /* * Note: we have to call the displayProc even for chunks that * are off-screen. This is needed, for example, so that * embedded windows can be unmapped in this case. Display the * chunk at a coordinate that can be clearly identified by the * displayProc as being off-screen to the left (the * displayProc may not be able to tell if something is off to * the right). */ x1 = -(*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).Fwidth } (*(*func(*libc.TLS, uintptr, uintptr, int32, int32, int32, int32, uintptr, TDrawable, int32))(unsafe.Pointer(&struct{ uintptr }{(*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FdisplayProc})))(tls, textPtr, chunkPtr, x1, y+(*TDLine)(unsafe.Pointer(dlPtr)).FspaceAbove, (*TDLine)(unsafe.Pointer(dlPtr)).Fheight-(*TDLine)(unsafe.Pointer(dlPtr)).FspaceAbove-(*TDLine)(unsafe.Pointer(dlPtr)).FspaceBelow, (*TDLine)(unsafe.Pointer(dlPtr)).Fbaseline-(*TDLine)(unsafe.Pointer(dlPtr)).FspaceAbove, display, pixmap, (*TDLine)(unsafe.Pointer(dlPtr)).Fy+(*TDLine)(unsafe.Pointer(dlPtr)).FspaceAbove) } if (*TTkText)(unsafe.Pointer(textPtr)).Ftkwin == libc.UintptrFromInt32(0) || (*TTkText)(unsafe.Pointer(textPtr)).Fflags&int32(DESTROYED) != 0 { /* * A displayProc called in the loop above invoked a binding * that caused the widget to be deleted. Don't do anything. */ return } if (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FdLinesInvalidated != 0 { return } goto _2 _2: ; chunkPtr = (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FnextPtr } /* * Copy the pixmap onto the screen. If this is the first or last line on * the screen then copy a piece of the line, so that it doesn't overflow * into the border area. Another special trick: copy the padding area to * the left of the line; this is because the insertion cursor sometimes * overflows onto that area and we want to get as much of the cursor as * possible. */ libx11.XXCopyArea(tls, display, pixmap, (*TTk_FakeWin)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).Ftkwin)).Fwindow, (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FcopyGC, (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).Fx, y+y_off, libc.Uint32FromInt32((*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FmaxX-(*TTextDInfo)(unsafe.Pointer(dInfoPtr)).Fx), libc.Uint32FromInt32(height), (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).Fx, (*TDLine)(unsafe.Pointer(dlPtr)).Fy+y_off) _linesRedrawn++ } /* *-------------------------------------------------------------- * * DisplayLineBackground -- * * This function is called to fill in the background for a display line. * It draws 3D borders cleverly so that adjacent chunks with the same * style (whether on the same line or different lines) have a single 3D * border around the whole region. * * Results: * There is no return value. Pixmap is filled in with background * information for dlPtr. * * Side effects: * None. * *-------------------------------------------------------------- */ func _DisplayLineBackground(tls *libc.TLS, textPtr uintptr, dlPtr uintptr, prevPtr uintptr, pixmap TPixmap) { /* Pixmap to use for double-buffering. Caller * must make sure it's large enough to hold * line. Caller must also have filled it with * the background color for the widget. */ var bw, leftX, leftXIn, matchLeft, matchRight, maxX, minX, rightX, rightX2, xOffset, y int32 var chunkPtr, chunkPtr2, dInfoPtr, display, nextPtr2, sValuePtr uintptr _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = bw, chunkPtr, chunkPtr2, dInfoPtr, display, leftX, leftXIn, matchLeft, matchRight, maxX, minX, nextPtr2, rightX, rightX2, sValuePtr, xOffset, y dInfoPtr = (*TTkText)(unsafe.Pointer(textPtr)).FdInfoPtr y = 0 /* * Pass 1: scan through dlPtr from left to right. For each range of chunks * with the same style, draw the main background for the style plus the * vertical parts of the 3D borders (the left and right edges). */ display = (*TTk_FakeWin)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).Ftkwin)).Fdisplay minX = (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FcurXPixelOffset xOffset = (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).Fx - minX maxX = minX + (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FmaxX - (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).Fx chunkPtr = (*TDLine)(unsafe.Pointer(dlPtr)).FchunkPtr /* * Note A: in the following statement, and a few others later in this file * marked with "See Note A above", the right side of the assignment was * replaced with 0 on 6/18/97. This has the effect of highlighting the * empty space to the left of a line whenever the leftmost character of * the line is highlighted. This way, multi-line highlights always line up * along their left edges. However, this may look funny in the case where * a single word is highlighted. To undo the change, replace "leftX = 0" * with "leftX = chunkPtr->x" and "rightX2 = 0" with "rightX2 = * nextPtr2->x" here and at all the marked points below. This restores the * old behavior where empty space to the left of a line is not * highlighted, leaving a ragged left edge for multi-line highlights. */ leftX = 0 for { if !(leftX < maxX) { break } if (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FnextPtr != libc.UintptrFromInt32(0) && ((*TStyleValues)(unsafe.Pointer((*TTextStyle1)(unsafe.Pointer((*TTkTextDispChunk1)(unsafe.Pointer((*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FnextPtr)).FstylePtr)).FsValuePtr)).Fborder == (*TStyleValues)(unsafe.Pointer((*TTextStyle1)(unsafe.Pointer((*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FstylePtr)).FsValuePtr)).Fborder && (*TStyleValues)(unsafe.Pointer((*TTextStyle1)(unsafe.Pointer((*TTkTextDispChunk1)(unsafe.Pointer((*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FnextPtr)).FstylePtr)).FsValuePtr)).FborderWidth == (*TStyleValues)(unsafe.Pointer((*TTextStyle1)(unsafe.Pointer((*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FstylePtr)).FsValuePtr)).FborderWidth && (*TStyleValues)(unsafe.Pointer((*TTextStyle1)(unsafe.Pointer((*TTkTextDispChunk1)(unsafe.Pointer((*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FnextPtr)).FstylePtr)).FsValuePtr)).Frelief == (*TStyleValues)(unsafe.Pointer((*TTextStyle1)(unsafe.Pointer((*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FstylePtr)).FsValuePtr)).Frelief && (*TStyleValues)(unsafe.Pointer((*TTextStyle1)(unsafe.Pointer((*TTkTextDispChunk1)(unsafe.Pointer((*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FnextPtr)).FstylePtr)).FsValuePtr)).FbgStipple == (*TStyleValues)(unsafe.Pointer((*TTextStyle1)(unsafe.Pointer((*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FstylePtr)).FsValuePtr)).FbgStipple) { goto _1 } sValuePtr = (*TTextStyle1)(unsafe.Pointer((*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FstylePtr)).FsValuePtr rightX = (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).Fx + (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).Fwidth if (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FnextPtr == libc.UintptrFromInt32(0) && rightX < maxX { rightX = maxX } if (*TTextStyle1)(unsafe.Pointer((*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FstylePtr)).FbgGC != libc.UintptrFromInt32(0) { /* * Not visible - bail out now. */ if rightX+xOffset <= 0 { leftX = rightX goto _1 } /* * Trim the start position for drawing to be no further away than * -borderWidth. The reason is that on many X servers drawing from * -32768 (or less) to +something simply does not display * correctly. [Patch #541999] */ if leftX+xOffset < -(*TStyleValues)(unsafe.Pointer(sValuePtr)).FborderWidth { leftX = -(*TStyleValues)(unsafe.Pointer(sValuePtr)).FborderWidth - xOffset } if rightX-leftX > int32(32767) { rightX = leftX + int32(32767) } /* * Prevent the borders from leaking on adjacent characters, * which would happen for too large border width. */ bw = (*TStyleValues)(unsafe.Pointer(sValuePtr)).FborderWidth if leftX+(*TStyleValues)(unsafe.Pointer(sValuePtr)).FborderWidth > rightX { bw = rightX - leftX } libx11.XXFillRectangle(tls, display, pixmap, (*TTextStyle1)(unsafe.Pointer((*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FstylePtr)).FbgGC, leftX+xOffset, y, libc.Uint32FromInt32(rightX-leftX), libc.Uint32FromInt32((*TDLine)(unsafe.Pointer(dlPtr)).Fheight)) if (*TStyleValues)(unsafe.Pointer(sValuePtr)).Frelief != TK_RELIEF_FLAT { XTk_3DVerticalBevel(tls, (*TTkText)(unsafe.Pointer(textPtr)).Ftkwin, pixmap, (*TStyleValues)(unsafe.Pointer(sValuePtr)).Fborder, leftX+xOffset, y, bw, (*TDLine)(unsafe.Pointer(dlPtr)).Fheight, int32(1), (*TStyleValues)(unsafe.Pointer(sValuePtr)).Frelief) XTk_3DVerticalBevel(tls, (*TTkText)(unsafe.Pointer(textPtr)).Ftkwin, pixmap, (*TStyleValues)(unsafe.Pointer(sValuePtr)).Fborder, rightX-bw+xOffset, y, bw, (*TDLine)(unsafe.Pointer(dlPtr)).Fheight, 0, (*TStyleValues)(unsafe.Pointer(sValuePtr)).Frelief) } } leftX = rightX goto _1 _1: ; chunkPtr = (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FnextPtr } /* * Pass 2: draw the horizontal bevels along the top of the line. To do * this, scan through dlPtr from left to right while simultaneously * scanning through the line just above dlPtr. ChunkPtr2 and nextPtr2 * refer to two adjacent chunks in the line above. */ chunkPtr = (*TDLine)(unsafe.Pointer(dlPtr)).FchunkPtr leftX = 0 /* See Note A above. */ leftXIn = int32(1) rightX = (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).Fx + (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).Fwidth if (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FnextPtr == libc.UintptrFromInt32(0) && rightX < maxX { rightX = maxX } chunkPtr2 = libc.UintptrFromInt32(0) if prevPtr != libc.UintptrFromInt32(0) && (*TDLine)(unsafe.Pointer(prevPtr)).FchunkPtr != libc.UintptrFromInt32(0) { /* * Find the chunk in the previous line that covers leftX. */ nextPtr2 = (*TDLine)(unsafe.Pointer(prevPtr)).FchunkPtr rightX2 = 0 /* See Note A above. */ for rightX2 <= leftX { chunkPtr2 = nextPtr2 if chunkPtr2 == libc.UintptrFromInt32(0) { break } nextPtr2 = (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr2)).FnextPtr rightX2 = (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr2)).Fx + (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr2)).Fwidth if nextPtr2 == libc.UintptrFromInt32(0) { rightX2 = int32(INT_MAX) } } } else { nextPtr2 = libc.UintptrFromInt32(0) rightX2 = int32(INT_MAX) } for leftX < maxX { matchLeft = libc.BoolInt32(chunkPtr2 != libc.UintptrFromInt32(0) && ((*TStyleValues)(unsafe.Pointer((*TTextStyle1)(unsafe.Pointer((*TTkTextDispChunk)(unsafe.Pointer(chunkPtr2)).FstylePtr)).FsValuePtr)).Fborder == (*TStyleValues)(unsafe.Pointer((*TTextStyle1)(unsafe.Pointer((*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FstylePtr)).FsValuePtr)).Fborder && (*TStyleValues)(unsafe.Pointer((*TTextStyle1)(unsafe.Pointer((*TTkTextDispChunk)(unsafe.Pointer(chunkPtr2)).FstylePtr)).FsValuePtr)).FborderWidth == (*TStyleValues)(unsafe.Pointer((*TTextStyle1)(unsafe.Pointer((*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FstylePtr)).FsValuePtr)).FborderWidth && (*TStyleValues)(unsafe.Pointer((*TTextStyle1)(unsafe.Pointer((*TTkTextDispChunk)(unsafe.Pointer(chunkPtr2)).FstylePtr)).FsValuePtr)).Frelief == (*TStyleValues)(unsafe.Pointer((*TTextStyle1)(unsafe.Pointer((*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FstylePtr)).FsValuePtr)).Frelief && (*TStyleValues)(unsafe.Pointer((*TTextStyle1)(unsafe.Pointer((*TTkTextDispChunk)(unsafe.Pointer(chunkPtr2)).FstylePtr)).FsValuePtr)).FbgStipple == (*TStyleValues)(unsafe.Pointer((*TTextStyle1)(unsafe.Pointer((*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FstylePtr)).FsValuePtr)).FbgStipple)) sValuePtr = (*TTextStyle1)(unsafe.Pointer((*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FstylePtr)).FsValuePtr if rightX <= rightX2 { /* * The chunk in our line is about to end. If its style changes * then draw the bevel for the current style. */ if (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FnextPtr == libc.UintptrFromInt32(0) || !((*TStyleValues)(unsafe.Pointer((*TTextStyle1)(unsafe.Pointer((*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FstylePtr)).FsValuePtr)).Fborder == (*TStyleValues)(unsafe.Pointer((*TTextStyle1)(unsafe.Pointer((*TTkTextDispChunk1)(unsafe.Pointer((*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FnextPtr)).FstylePtr)).FsValuePtr)).Fborder && (*TStyleValues)(unsafe.Pointer((*TTextStyle1)(unsafe.Pointer((*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FstylePtr)).FsValuePtr)).FborderWidth == (*TStyleValues)(unsafe.Pointer((*TTextStyle1)(unsafe.Pointer((*TTkTextDispChunk1)(unsafe.Pointer((*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FnextPtr)).FstylePtr)).FsValuePtr)).FborderWidth && (*TStyleValues)(unsafe.Pointer((*TTextStyle1)(unsafe.Pointer((*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FstylePtr)).FsValuePtr)).Frelief == (*TStyleValues)(unsafe.Pointer((*TTextStyle1)(unsafe.Pointer((*TTkTextDispChunk1)(unsafe.Pointer((*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FnextPtr)).FstylePtr)).FsValuePtr)).Frelief && (*TStyleValues)(unsafe.Pointer((*TTextStyle1)(unsafe.Pointer((*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FstylePtr)).FsValuePtr)).FbgStipple == (*TStyleValues)(unsafe.Pointer((*TTextStyle1)(unsafe.Pointer((*TTkTextDispChunk1)(unsafe.Pointer((*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FnextPtr)).FstylePtr)).FsValuePtr)).FbgStipple) { if !(matchLeft != 0) && (*TStyleValues)(unsafe.Pointer(sValuePtr)).Frelief != TK_RELIEF_FLAT { XTk_3DHorizontalBevel(tls, (*TTkText)(unsafe.Pointer(textPtr)).Ftkwin, pixmap, (*TStyleValues)(unsafe.Pointer(sValuePtr)).Fborder, leftX+xOffset, y, rightX-leftX, (*TStyleValues)(unsafe.Pointer(sValuePtr)).FborderWidth, leftXIn, int32(1), int32(1), (*TStyleValues)(unsafe.Pointer(sValuePtr)).Frelief) } leftX = rightX leftXIn = int32(1) /* * If the chunk in the line above is also ending at the same * point then advance to the next chunk in that line. */ if rightX == rightX2 && chunkPtr2 != libc.UintptrFromInt32(0) { goto nextChunk2 } } chunkPtr = (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FnextPtr if chunkPtr == libc.UintptrFromInt32(0) { break } rightX = (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).Fx + (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).Fwidth if (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FnextPtr == libc.UintptrFromInt32(0) && rightX < maxX { rightX = maxX } continue } /* * The chunk in the line above is ending at an x-position where there * is no change in the style of the current line. If the style above * matches the current line on one side of the change but not on the * other, we have to draw an L-shaped piece of bevel. */ matchRight = libc.BoolInt32(nextPtr2 != libc.UintptrFromInt32(0) && ((*TStyleValues)(unsafe.Pointer((*TTextStyle1)(unsafe.Pointer((*TTkTextDispChunk)(unsafe.Pointer(nextPtr2)).FstylePtr)).FsValuePtr)).Fborder == (*TStyleValues)(unsafe.Pointer((*TTextStyle1)(unsafe.Pointer((*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FstylePtr)).FsValuePtr)).Fborder && (*TStyleValues)(unsafe.Pointer((*TTextStyle1)(unsafe.Pointer((*TTkTextDispChunk)(unsafe.Pointer(nextPtr2)).FstylePtr)).FsValuePtr)).FborderWidth == (*TStyleValues)(unsafe.Pointer((*TTextStyle1)(unsafe.Pointer((*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FstylePtr)).FsValuePtr)).FborderWidth && (*TStyleValues)(unsafe.Pointer((*TTextStyle1)(unsafe.Pointer((*TTkTextDispChunk)(unsafe.Pointer(nextPtr2)).FstylePtr)).FsValuePtr)).Frelief == (*TStyleValues)(unsafe.Pointer((*TTextStyle1)(unsafe.Pointer((*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FstylePtr)).FsValuePtr)).Frelief && (*TStyleValues)(unsafe.Pointer((*TTextStyle1)(unsafe.Pointer((*TTkTextDispChunk)(unsafe.Pointer(nextPtr2)).FstylePtr)).FsValuePtr)).FbgStipple == (*TStyleValues)(unsafe.Pointer((*TTextStyle1)(unsafe.Pointer((*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FstylePtr)).FsValuePtr)).FbgStipple)) if matchLeft != 0 && !(matchRight != 0) { bw = (*TStyleValues)(unsafe.Pointer(sValuePtr)).FborderWidth if rightX2-(*TStyleValues)(unsafe.Pointer(sValuePtr)).FborderWidth < leftX { bw = rightX2 - leftX } if (*TStyleValues)(unsafe.Pointer(sValuePtr)).Frelief != TK_RELIEF_FLAT { XTk_3DVerticalBevel(tls, (*TTkText)(unsafe.Pointer(textPtr)).Ftkwin, pixmap, (*TStyleValues)(unsafe.Pointer(sValuePtr)).Fborder, rightX2-bw+xOffset, y, bw, (*TStyleValues)(unsafe.Pointer(sValuePtr)).FborderWidth, 0, (*TStyleValues)(unsafe.Pointer(sValuePtr)).Frelief) } leftX = rightX2 - bw leftXIn = 0 } else { if !(matchLeft != 0) && matchRight != 0 && (*TStyleValues)(unsafe.Pointer(sValuePtr)).Frelief != TK_RELIEF_FLAT { bw = (*TStyleValues)(unsafe.Pointer(sValuePtr)).FborderWidth if rightX2+(*TStyleValues)(unsafe.Pointer(sValuePtr)).FborderWidth > rightX { bw = rightX - rightX2 } XTk_3DVerticalBevel(tls, (*TTkText)(unsafe.Pointer(textPtr)).Ftkwin, pixmap, (*TStyleValues)(unsafe.Pointer(sValuePtr)).Fborder, rightX2+xOffset, y, bw, (*TStyleValues)(unsafe.Pointer(sValuePtr)).FborderWidth, int32(1), (*TStyleValues)(unsafe.Pointer(sValuePtr)).Frelief) XTk_3DHorizontalBevel(tls, (*TTkText)(unsafe.Pointer(textPtr)).Ftkwin, pixmap, (*TStyleValues)(unsafe.Pointer(sValuePtr)).Fborder, leftX+xOffset, y, rightX2+bw-leftX, (*TStyleValues)(unsafe.Pointer(sValuePtr)).FborderWidth, leftXIn, 0, int32(1), (*TStyleValues)(unsafe.Pointer(sValuePtr)).Frelief) } } goto nextChunk2 nextChunk2: ; chunkPtr2 = nextPtr2 if chunkPtr2 == libc.UintptrFromInt32(0) { rightX2 = int32(INT_MAX) } else { nextPtr2 = (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr2)).FnextPtr rightX2 = (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr2)).Fx + (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr2)).Fwidth if nextPtr2 == libc.UintptrFromInt32(0) { rightX2 = int32(INT_MAX) } } } /* * Pass 3: draw the horizontal bevels along the bottom of the line. This * uses the same approach as pass 2. */ chunkPtr = (*TDLine)(unsafe.Pointer(dlPtr)).FchunkPtr leftX = 0 /* See Note A above. */ leftXIn = 0 rightX = (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).Fx + (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).Fwidth if (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FnextPtr == libc.UintptrFromInt32(0) && rightX < maxX { rightX = maxX } chunkPtr2 = libc.UintptrFromInt32(0) if (*TDLine)(unsafe.Pointer(dlPtr)).FnextPtr != libc.UintptrFromInt32(0) && (*TDLine1)(unsafe.Pointer((*TDLine)(unsafe.Pointer(dlPtr)).FnextPtr)).FchunkPtr != libc.UintptrFromInt32(0) { /* * Find the chunk in the next line that covers leftX. */ nextPtr2 = (*TDLine1)(unsafe.Pointer((*TDLine)(unsafe.Pointer(dlPtr)).FnextPtr)).FchunkPtr rightX2 = 0 /* See Note A above. */ for rightX2 <= leftX { chunkPtr2 = nextPtr2 if chunkPtr2 == libc.UintptrFromInt32(0) { break } nextPtr2 = (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr2)).FnextPtr rightX2 = (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr2)).Fx + (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr2)).Fwidth if nextPtr2 == libc.UintptrFromInt32(0) { rightX2 = int32(INT_MAX) } } } else { nextPtr2 = libc.UintptrFromInt32(0) rightX2 = int32(INT_MAX) } for leftX < maxX { matchLeft = libc.BoolInt32(chunkPtr2 != libc.UintptrFromInt32(0) && ((*TStyleValues)(unsafe.Pointer((*TTextStyle1)(unsafe.Pointer((*TTkTextDispChunk)(unsafe.Pointer(chunkPtr2)).FstylePtr)).FsValuePtr)).Fborder == (*TStyleValues)(unsafe.Pointer((*TTextStyle1)(unsafe.Pointer((*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FstylePtr)).FsValuePtr)).Fborder && (*TStyleValues)(unsafe.Pointer((*TTextStyle1)(unsafe.Pointer((*TTkTextDispChunk)(unsafe.Pointer(chunkPtr2)).FstylePtr)).FsValuePtr)).FborderWidth == (*TStyleValues)(unsafe.Pointer((*TTextStyle1)(unsafe.Pointer((*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FstylePtr)).FsValuePtr)).FborderWidth && (*TStyleValues)(unsafe.Pointer((*TTextStyle1)(unsafe.Pointer((*TTkTextDispChunk)(unsafe.Pointer(chunkPtr2)).FstylePtr)).FsValuePtr)).Frelief == (*TStyleValues)(unsafe.Pointer((*TTextStyle1)(unsafe.Pointer((*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FstylePtr)).FsValuePtr)).Frelief && (*TStyleValues)(unsafe.Pointer((*TTextStyle1)(unsafe.Pointer((*TTkTextDispChunk)(unsafe.Pointer(chunkPtr2)).FstylePtr)).FsValuePtr)).FbgStipple == (*TStyleValues)(unsafe.Pointer((*TTextStyle1)(unsafe.Pointer((*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FstylePtr)).FsValuePtr)).FbgStipple)) sValuePtr = (*TTextStyle1)(unsafe.Pointer((*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FstylePtr)).FsValuePtr if rightX <= rightX2 { if (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FnextPtr == libc.UintptrFromInt32(0) || !((*TStyleValues)(unsafe.Pointer((*TTextStyle1)(unsafe.Pointer((*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FstylePtr)).FsValuePtr)).Fborder == (*TStyleValues)(unsafe.Pointer((*TTextStyle1)(unsafe.Pointer((*TTkTextDispChunk1)(unsafe.Pointer((*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FnextPtr)).FstylePtr)).FsValuePtr)).Fborder && (*TStyleValues)(unsafe.Pointer((*TTextStyle1)(unsafe.Pointer((*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FstylePtr)).FsValuePtr)).FborderWidth == (*TStyleValues)(unsafe.Pointer((*TTextStyle1)(unsafe.Pointer((*TTkTextDispChunk1)(unsafe.Pointer((*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FnextPtr)).FstylePtr)).FsValuePtr)).FborderWidth && (*TStyleValues)(unsafe.Pointer((*TTextStyle1)(unsafe.Pointer((*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FstylePtr)).FsValuePtr)).Frelief == (*TStyleValues)(unsafe.Pointer((*TTextStyle1)(unsafe.Pointer((*TTkTextDispChunk1)(unsafe.Pointer((*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FnextPtr)).FstylePtr)).FsValuePtr)).Frelief && (*TStyleValues)(unsafe.Pointer((*TTextStyle1)(unsafe.Pointer((*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FstylePtr)).FsValuePtr)).FbgStipple == (*TStyleValues)(unsafe.Pointer((*TTextStyle1)(unsafe.Pointer((*TTkTextDispChunk1)(unsafe.Pointer((*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FnextPtr)).FstylePtr)).FsValuePtr)).FbgStipple) { if !(matchLeft != 0) && (*TStyleValues)(unsafe.Pointer(sValuePtr)).Frelief != TK_RELIEF_FLAT { XTk_3DHorizontalBevel(tls, (*TTkText)(unsafe.Pointer(textPtr)).Ftkwin, pixmap, (*TStyleValues)(unsafe.Pointer(sValuePtr)).Fborder, leftX+xOffset, y+(*TDLine)(unsafe.Pointer(dlPtr)).Fheight-(*TStyleValues)(unsafe.Pointer(sValuePtr)).FborderWidth, rightX-leftX, (*TStyleValues)(unsafe.Pointer(sValuePtr)).FborderWidth, leftXIn, 0, 0, (*TStyleValues)(unsafe.Pointer(sValuePtr)).Frelief) } leftX = rightX leftXIn = 0 if rightX == rightX2 && chunkPtr2 != libc.UintptrFromInt32(0) { goto nextChunk2b } } chunkPtr = (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FnextPtr if chunkPtr == libc.UintptrFromInt32(0) { break } rightX = (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).Fx + (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).Fwidth if (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FnextPtr == libc.UintptrFromInt32(0) && rightX < maxX { rightX = maxX } continue } matchRight = libc.BoolInt32(nextPtr2 != libc.UintptrFromInt32(0) && ((*TStyleValues)(unsafe.Pointer((*TTextStyle1)(unsafe.Pointer((*TTkTextDispChunk)(unsafe.Pointer(nextPtr2)).FstylePtr)).FsValuePtr)).Fborder == (*TStyleValues)(unsafe.Pointer((*TTextStyle1)(unsafe.Pointer((*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FstylePtr)).FsValuePtr)).Fborder && (*TStyleValues)(unsafe.Pointer((*TTextStyle1)(unsafe.Pointer((*TTkTextDispChunk)(unsafe.Pointer(nextPtr2)).FstylePtr)).FsValuePtr)).FborderWidth == (*TStyleValues)(unsafe.Pointer((*TTextStyle1)(unsafe.Pointer((*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FstylePtr)).FsValuePtr)).FborderWidth && (*TStyleValues)(unsafe.Pointer((*TTextStyle1)(unsafe.Pointer((*TTkTextDispChunk)(unsafe.Pointer(nextPtr2)).FstylePtr)).FsValuePtr)).Frelief == (*TStyleValues)(unsafe.Pointer((*TTextStyle1)(unsafe.Pointer((*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FstylePtr)).FsValuePtr)).Frelief && (*TStyleValues)(unsafe.Pointer((*TTextStyle1)(unsafe.Pointer((*TTkTextDispChunk)(unsafe.Pointer(nextPtr2)).FstylePtr)).FsValuePtr)).FbgStipple == (*TStyleValues)(unsafe.Pointer((*TTextStyle1)(unsafe.Pointer((*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FstylePtr)).FsValuePtr)).FbgStipple)) if matchLeft != 0 && !(matchRight != 0) { bw = (*TStyleValues)(unsafe.Pointer(sValuePtr)).FborderWidth if rightX2-(*TStyleValues)(unsafe.Pointer(sValuePtr)).FborderWidth < leftX { bw = rightX2 - leftX } if (*TStyleValues)(unsafe.Pointer(sValuePtr)).Frelief != TK_RELIEF_FLAT { XTk_3DVerticalBevel(tls, (*TTkText)(unsafe.Pointer(textPtr)).Ftkwin, pixmap, (*TStyleValues)(unsafe.Pointer(sValuePtr)).Fborder, rightX2-bw+xOffset, y+(*TDLine)(unsafe.Pointer(dlPtr)).Fheight-(*TStyleValues)(unsafe.Pointer(sValuePtr)).FborderWidth, bw, (*TStyleValues)(unsafe.Pointer(sValuePtr)).FborderWidth, 0, (*TStyleValues)(unsafe.Pointer(sValuePtr)).Frelief) } leftX = rightX2 - bw leftXIn = int32(1) } else { if !(matchLeft != 0) && matchRight != 0 && (*TStyleValues)(unsafe.Pointer(sValuePtr)).Frelief != TK_RELIEF_FLAT { bw = (*TStyleValues)(unsafe.Pointer(sValuePtr)).FborderWidth if rightX2+(*TStyleValues)(unsafe.Pointer(sValuePtr)).FborderWidth > rightX { bw = rightX - rightX2 } XTk_3DVerticalBevel(tls, (*TTkText)(unsafe.Pointer(textPtr)).Ftkwin, pixmap, (*TStyleValues)(unsafe.Pointer(sValuePtr)).Fborder, rightX2+xOffset, y+(*TDLine)(unsafe.Pointer(dlPtr)).Fheight-(*TStyleValues)(unsafe.Pointer(sValuePtr)).FborderWidth, bw, (*TStyleValues)(unsafe.Pointer(sValuePtr)).FborderWidth, int32(1), (*TStyleValues)(unsafe.Pointer(sValuePtr)).Frelief) XTk_3DHorizontalBevel(tls, (*TTkText)(unsafe.Pointer(textPtr)).Ftkwin, pixmap, (*TStyleValues)(unsafe.Pointer(sValuePtr)).Fborder, leftX+xOffset, y+(*TDLine)(unsafe.Pointer(dlPtr)).Fheight-(*TStyleValues)(unsafe.Pointer(sValuePtr)).FborderWidth, rightX2+bw-leftX, (*TStyleValues)(unsafe.Pointer(sValuePtr)).FborderWidth, leftXIn, int32(1), 0, (*TStyleValues)(unsafe.Pointer(sValuePtr)).Frelief) } } goto nextChunk2b nextChunk2b: ; chunkPtr2 = nextPtr2 if chunkPtr2 == libc.UintptrFromInt32(0) { rightX2 = int32(INT_MAX) } else { nextPtr2 = (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr2)).FnextPtr rightX2 = (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr2)).Fx + (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr2)).Fwidth if nextPtr2 == libc.UintptrFromInt32(0) { rightX2 = int32(INT_MAX) } } } } /* *---------------------------------------------------------------------- * * AsyncUpdateLineMetrics -- * * This function is invoked as a background handler to update the pixel- * height calculations of individual lines in an asychronous manner. * * Currently a timer-handler is used for this purpose, which continuously * reschedules itself. It may well be better to use some other approach * (e.g., a background thread). We can't use an idle-callback because of * a known bug in Tcl/Tk in which idle callbacks are not allowed to * re-schedule themselves. This just causes an effective infinite loop. * * Results: * None. * * Side effects: * Line heights may be recalculated. * *---------------------------------------------------------------------- */ func _AsyncUpdateLineMetrics(tls *libc.TLS, clientData uintptr) { bp := tls.Alloc(80) defer tls.Free(80) /* Information about widget. */ var _objPtr, dInfoPtr, textPtr, v2, v4, v6 uintptr var code, lineNum int32 var v1, v3, v5 TTcl_Size var _ /* buffer at bp+0 */ [49]uint8 _, _, _, _, _, _, _, _, _, _, _ = _objPtr, code, dInfoPtr, lineNum, textPtr, v1, v2, v3, v4, v5, v6 textPtr = clientData dInfoPtr = (*TTkText)(unsafe.Pointer(textPtr)).FdInfoPtr (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FlineUpdateTimer = libc.UintptrFromInt32(0) if (*TTkText)(unsafe.Pointer(textPtr)).Ftkwin == libc.UintptrFromInt32(0) || (*TTkText)(unsafe.Pointer(textPtr)).Fflags&int32(DESTROYED) != 0 || !((*TTk_FakeWin)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).Ftkwin)).Fflags&libc.Uint32FromInt32(TK_MAPPED) != 0) { /* * The widget has been deleted, or is not mapped. Don't do anything. */ v2 = textPtr + 688 v1 = *(*TTcl_Size)(unsafe.Pointer(v2)) *(*TTcl_Size)(unsafe.Pointer(v2))-- if v1 <= int64(1) { libtcl9_0.XTcl_Free(tls, textPtr) } return } if (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).Fflags&int32(REDRAW_PENDING3) != 0 { (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FlineUpdateTimer = libtcl9_0.XTcl_CreateTimerHandler(tls, int32(1), __ccgo_fp(_AsyncUpdateLineMetrics), clientData) return } /* * Reify where we end or all hell breaks loose with the calculations when * we try to update. [Bug 2677890] */ lineNum = (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FcurrentMetricUpdateLine if (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FlastMetricUpdateLine == -int32(1) { (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FlastMetricUpdateLine = XTkBTreeNumLines(tls, (*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).Ftree, textPtr) } /* * Update the lines in blocks of about 24 recalculations, or 250+ lines * examined, so we pass in 256 for 'doThisMuch'. */ lineNum = XTkTextUpdateLineMetrics(tls, textPtr, lineNum, (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FlastMetricUpdateLine, int32(256)) (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FcurrentMetricUpdateLine = lineNum if XtkTextDebug != 0 { libc.X__builtin_snprintf(tls, bp, uint64(49), __ccgo_ts+47089, libc.VaList(bp+64, lineNum, (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FlastMetricUpdateLine)) libtcl9_0.XTcl_SetVar2(tls, (*TTkText)(unsafe.Pointer(textPtr)).Finterp, __ccgo_ts+47095, libc.UintptrFromInt32(0), bp, libc.Int32FromInt32(TCL_GLOBAL_ONLY)|libc.Int32FromInt32(TCL_APPEND_VALUE)|libc.Int32FromInt32(TCL_LIST_ELEMENT)) } /* * If we're not in the middle of a long-line calculation (metricEpoch==-1) * and we've reached the last line, then we're done. */ if (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FmetricEpoch == int64(-int32(1)) && lineNum == (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FlastMetricUpdateLine { /* * We have looped over all lines, so we're done. We must release our * refCount on the widget (the timer token was already set to NULL * above). If there is a registered aftersync command, run that first. * Cancel any pending idle task which would try to run the command * after the afterSyncCmd pointer had been set to NULL. */ if (*TTkText)(unsafe.Pointer(textPtr)).FafterSyncCmd != 0 { libtcl9_0.XTcl_CancelIdleCall(tls, __ccgo_fp(XTkTextRunAfterSyncCmd), textPtr) libtcl9_0.XTcl_Preserve(tls, (*TTkText)(unsafe.Pointer(textPtr)).Finterp) code = libtcl9_0.XTcl_EvalObjEx(tls, (*TTkText)(unsafe.Pointer(textPtr)).Finterp, (*TTkText)(unsafe.Pointer(textPtr)).FafterSyncCmd, int32(TCL_EVAL_GLOBAL)) if code == int32(TCL_ERROR) { libtcl9_0.XTcl_AppendObjToErrorInfo(tls, (*TTkText)(unsafe.Pointer(textPtr)).Finterp, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+44613, int64(-int32(1)))) libtcl9_0.XTcl_BackgroundException(tls, (*TTkText)(unsafe.Pointer(textPtr)).Finterp, int32(TCL_ERROR)) } libtcl9_0.XTcl_Release(tls, (*TTkText)(unsafe.Pointer(textPtr)).Finterp) _objPtr = (*TTkText)(unsafe.Pointer(textPtr)).FafterSyncCmd v4 = _objPtr v3 = *(*TTcl_Size)(unsafe.Pointer(v4)) *(*TTcl_Size)(unsafe.Pointer(v4))-- if v3 <= int64(1) { libtcl9_0.XTclFreeObj(tls, _objPtr) } (*TTkText)(unsafe.Pointer(textPtr)).FafterSyncCmd = libc.UintptrFromInt32(0) } /* * Fire the <> event since the widget view is in sync * with its internal data (actually it will be after the next trip * through the event loop, because the widget redraws at idle-time). */ _GenerateWidgetViewSyncEvent(tls, textPtr, int32(1)) v6 = textPtr + 688 v5 = *(*TTcl_Size)(unsafe.Pointer(v6)) *(*TTcl_Size)(unsafe.Pointer(v6))-- if v5 <= int64(1) { libtcl9_0.XTcl_Free(tls, textPtr) } return } /* * Re-arm the timer. We already have a refCount on the text widget so no * need to adjust that. */ (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FlineUpdateTimer = libtcl9_0.XTcl_CreateTimerHandler(tls, int32(1), __ccgo_fp(_AsyncUpdateLineMetrics), textPtr) } /* *---------------------------------------------------------------------- * * GenerateWidgetViewSyncEvent -- * * Send the <> event related to the text widget * line metrics asynchronous update. These events should only * be sent when the sync status has changed. So this function * compares the requested state with the state saved in the * TkText structure, and only generates the event if they are * different. This means that it is safe to call this function * at any time when the state is known. * * If an event is sent, the effect is equivalent to: * event generate $textWidget <> -data $s * where $s is the sync status: true (when the widget view is in * sync with its internal data) or false (when it is not). * * Results: * None * * Side effects: * If corresponding bindings are present, they will trigger. * *---------------------------------------------------------------------- */ func _GenerateWidgetViewSyncEvent(tls *libc.TLS, textPtr uintptr, InSync int32) { /* true if becoming in sync, false otherwise */ var NewSyncState, OldSyncState int32 _, _ = NewSyncState, OldSyncState NewSyncState = libc.BoolInt32(InSync != 0) /* ensure 0 or 1 value */ OldSyncState = libc.BoolInt32(!((*TTextDInfo1)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FdInfoPtr)).Fflags&libc.Int32FromInt32(OUT_OF_SYNC) != 0)) /* * OSX 10.14 needs to be told to display the window when the Text Widget * is in sync. (That is, to run DisplayText inside of the drawRect * method.) Otherwise the screen might not get updated until an event * like a mouse click is received. But that extra drawing corrupts the * data that the test suite is trying to collect. */ if !(XtkTextDebug != 0) { } if NewSyncState != OldSyncState { if NewSyncState != 0 { *(*int32)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FdInfoPtr + 220)) &= ^libc.Int32FromInt32(OUT_OF_SYNC) } else { *(*int32)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FdInfoPtr + 220)) |= int32(OUT_OF_SYNC) } XTk_SendVirtualEvent(tls, (*TTkText)(unsafe.Pointer(textPtr)).Ftkwin, __ccgo_ts+47117, libtcl9_0.XTcl_NewWideIntObj(tls, libc.BoolInt64(NewSyncState != 0))) } } /* *---------------------------------------------------------------------- * * TkTextUpdateLineMetrics -- * * This function updates the pixel height calculations of a range of * lines in the widget. The range is from lineNum to endLine, but, if * doThisMuch is positive, then the function may return earlier, once a * certain number of lines has been examined. The line counts are from 0. * * If doThisMuch is -1, then all lines in the range will be updated. This * will potentially take quite some time for a large text widget. * * Note: with bad input for lineNum and endLine, this function can loop * indefinitely. * * Results: * The index of the last line examined (or -1 if we are about to wrap * around from end to beginning of the widget, and the next line will be * the first line). * * Side effects: * Line heights may be recalculated. * *---------------------------------------------------------------------- */ func XTkTextUpdateLineMetrics(tls *libc.TLS, textPtr uintptr, lineNum int32, endLine int32, doThisMuch int32) (r int32) { bp := tls.Alloc(176) defer tls.Free(176) /* How many lines to check, or how many 10s of * lines to recalculate. If '-1' then do * everything in the range (which may take a * while). */ var count, fullUpdateRequested, pixelHeight, totalLines int32 var indexPtr, linePtr uintptr var _ /* buffer at bp+0 */ [99]uint8 var _ /* index at bp+104 */ TTkTextIndex _, _, _, _, _, _ = count, fullUpdateRequested, indexPtr, linePtr, pixelHeight, totalLines linePtr = libc.UintptrFromInt32(0) count = 0 totalLines = XTkBTreeNumLines(tls, (*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).Ftree, textPtr) fullUpdateRequested = libc.BoolInt32(lineNum == 0 && endLine == totalLines && doThisMuch == -int32(1)) if totalLines == 0 { /* * Empty peer widget. */ return endLine } for int32(1) != 0 { /* * Get a suitable line. */ if lineNum == -int32(1) && linePtr == libc.UintptrFromInt32(0) { lineNum = 0 linePtr = XTkBTreeFindLine(tls, (*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).Ftree, textPtr, lineNum) } else { if lineNum == -int32(1) || linePtr == libc.UintptrFromInt32(0) { if lineNum == -int32(1) { lineNum = 0 } linePtr = XTkBTreeFindLine(tls, (*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).Ftree, textPtr, lineNum) } else { lineNum++ linePtr = XTkBTreeNextLine(tls, textPtr, linePtr) } /* * If we're in the middle of a partial-line height calculation, * then we can't be done. */ if (*TTextDInfo1)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FdInfoPtr)).FmetricEpoch == int64(-int32(1)) && lineNum == endLine { /* * We have looped over all lines, so we're done. */ break } } if lineNum < totalLines { if XtkTextDebug != 0 { libc.X__builtin_snprintf(tls, bp, uint64(99), __ccgo_ts+47132, libc.VaList(bp+144, lineNum, endLine, totalLines, count)) libtcl9_0.XTcl_SetVar2(tls, (*TTkText)(unsafe.Pointer(textPtr)).Finterp, __ccgo_ts+47095, libc.UintptrFromInt32(0), bp, libc.Int32FromInt32(TCL_GLOBAL_ONLY)|libc.Int32FromInt32(TCL_APPEND_VALUE)|libc.Int32FromInt32(TCL_LIST_ELEMENT)) } /* * Now update the line's metrics if necessary. */ if *(*int32)(unsafe.Pointer((*TTkTextLine)(unsafe.Pointer(linePtr)).Fpixels + uintptr(int32(1)+int32(2)*(*TTkText)(unsafe.Pointer(textPtr)).FpixelReference)*4)) == (*TTextDInfo1)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FdInfoPtr)).FlineMetricUpdateEpoch { /* * This line is already up to date. That means there's nothing * to do here. */ } else { if doThisMuch == -int32(1) { count += int32(8) * XTkTextUpdateOneLine(tls, textPtr, linePtr, 0, libc.UintptrFromInt32(0), 0) } else { /* * If the metric epoch is the same as the widget's epoch, then * we know that indexPtrs are still valid, and if the cached * metricIndex (if any) is for the same line as we wish to * examine, then we are looking at a long line wrapped many * times, which we will examine in pieces. */ if (*TTextDInfo1)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FdInfoPtr)).FmetricEpoch == (*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).FstateEpoch && (*TTextDInfo1)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FdInfoPtr)).FmetricIndex.FlinePtr == linePtr { indexPtr = (*TTkText)(unsafe.Pointer(textPtr)).FdInfoPtr + 232 pixelHeight = (*TTextDInfo1)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FdInfoPtr)).FmetricPixelHeight } else { /* * We must reset the partial line height calculation data * here, so we don't use it when it is out of date. */ (*TTextDInfo1)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FdInfoPtr)).FmetricEpoch = int64(-int32(1)) (*(*TTkTextIndex)(unsafe.Pointer(bp + 104))).Ftree = (*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).Ftree (*(*TTkTextIndex)(unsafe.Pointer(bp + 104))).FlinePtr = linePtr (*(*TTkTextIndex)(unsafe.Pointer(bp + 104))).FbyteIndex = 0 (*(*TTkTextIndex)(unsafe.Pointer(bp + 104))).FtextPtr = libc.UintptrFromInt32(0) indexPtr = bp + 104 pixelHeight = 0 } /* * Update the line and update the counter, counting 8 for each * display line we actually re-layout. */ count += int32(8) * XTkTextUpdateOneLine(tls, textPtr, linePtr, pixelHeight, indexPtr, int32(1)) if (*TTkTextIndex)(unsafe.Pointer(indexPtr)).FlinePtr == linePtr { /* * We didn't complete the logical line, because it * produced very many display lines, which must be because * it must be a long line wrapped many times. So we must * cache as far as we got for next time around. */ if pixelHeight == 0 { /* * These have already been stored, unless we just * started the new line. */ (*TTextDInfo1)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FdInfoPtr)).FmetricIndex = *(*TTkTextIndex)(unsafe.Pointer(bp + 104)) (*TTextDInfo1)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FdInfoPtr)).FmetricEpoch = (*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).FstateEpoch } (*TTextDInfo1)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FdInfoPtr)).FmetricPixelHeight = *(*int32)(unsafe.Pointer((*TTkTextLine)(unsafe.Pointer(linePtr)).Fpixels + uintptr(int32(2)*(*TTkText)(unsafe.Pointer(textPtr)).FpixelReference)*4)) break } /* * We're done with this long line. */ (*TTextDInfo1)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FdInfoPtr)).FmetricEpoch = int64(-int32(1)) } } } else { /* * We must never recalculate the height of the last artificial * line. It must stay at zero, and if we recalculate it, it will * change. */ if endLine >= totalLines { lineNum = endLine break } /* * Set things up for the next loop through. */ lineNum = -int32(1) } count++ if doThisMuch != -int32(1) && count >= doThisMuch { break } } if doThisMuch == -int32(1) { /* * If we were requested to update the entire range, then also update * the scrollbar. */ _GetYView(tls, (*TTkText)(unsafe.Pointer(textPtr)).Finterp, textPtr, int32(1)) } if fullUpdateRequested != 0 { _GenerateWidgetViewSyncEvent(tls, textPtr, int32(1)) } return lineNum } /* *---------------------------------------------------------------------- * * TkTextInvalidateLineMetrics, TextInvalidateLineMetrics -- * * Mark a number of text lines as having invalid line metric * calculations. Never call this with linePtr as the last (artificial) * line in the text. Depending on 'action' which indicates whether the * given lines are simply invalid or have been inserted or deleted, the * pre-existing asynchronous line update range may need to be adjusted. * * If linePtr is NULL then 'lineCount' and 'action' are ignored and all * lines are invalidated. * * Results: * None. * * Side effects: * May schedule an asychronous callback. * *---------------------------------------------------------------------- */ func XTkTextInvalidateLineMetrics(tls *libc.TLS, sharedTextPtr uintptr, textPtr uintptr, linePtr uintptr, lineCount int32, action TTkTextInvalidateAction) { /* Indicates what type of invalidation * occurred, TK_TEXT_INVALIDATE_(ONLY|INSERT|DELETE). */ if sharedTextPtr == libc.UintptrFromInt32(0) { _TextInvalidateLineMetrics(tls, textPtr, linePtr, lineCount, action) } else { textPtr = (*TTkSharedText)(unsafe.Pointer(sharedTextPtr)).Fpeers for textPtr != libc.UintptrFromInt32(0) { _TextInvalidateLineMetrics(tls, textPtr, linePtr, lineCount, action) textPtr = (*TTkText)(unsafe.Pointer(textPtr)).Fnext } } } func _TextInvalidateLineMetrics(tls *libc.TLS, textPtr uintptr, linePtr uintptr, lineCount int32, action TTkTextInvalidateAction) { /* Indicates what type of invalidation * occurred, TK_TEXT_INVALIDATE_(ONLY|INSERT|DELETE). */ var counter, fromLine, toLine, v1 int32 var dInfoPtr, v2 uintptr _, _, _, _, _, _ = counter, dInfoPtr, fromLine, toLine, v1, v2 dInfoPtr = (*TTkText)(unsafe.Pointer(textPtr)).FdInfoPtr if linePtr != libc.UintptrFromInt32(0) { counter = lineCount fromLine = XTkBTreeLinesTo(tls, textPtr, linePtr) /* * Invalidate the height calculations of each line in the given range. */ *(*int32)(unsafe.Pointer((*TTkTextLine)(unsafe.Pointer(linePtr)).Fpixels + uintptr(int32(1)+int32(2)*(*TTkText)(unsafe.Pointer(textPtr)).FpixelReference)*4)) = 0 for counter > 0 && linePtr != libc.UintptrFromInt32(0) { linePtr = XTkBTreeNextLine(tls, textPtr, linePtr) if linePtr != libc.UintptrFromInt32(0) { *(*int32)(unsafe.Pointer((*TTkTextLine)(unsafe.Pointer(linePtr)).Fpixels + uintptr(int32(1)+int32(2)*(*TTkText)(unsafe.Pointer(textPtr)).FpixelReference)*4)) = 0 } counter-- } /* * Now schedule an examination of each line in the union of the old * and new update ranges, including the (possibly empty) range in * between. If that between range is not-empty, then we are examining * more lines than is strictly necessary (but the examination of the * extra lines should be quick, since their pixelCalculationEpoch will * be up to date). However, to keep track of that would require more * complex record-keeping than what we have. */ if (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FlineUpdateTimer == libc.UintptrFromInt32(0) { (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FcurrentMetricUpdateLine = fromLine if action == int32(TK_TEXT_INVALIDATE_DELETE) { lineCount = 0 } (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FlastMetricUpdateLine = fromLine + lineCount + int32(1) } else { toLine = fromLine + lineCount + int32(1) if action == int32(TK_TEXT_INVALIDATE_DELETE) { if toLine <= (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FcurrentMetricUpdateLine { (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FcurrentMetricUpdateLine = fromLine if (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FlastMetricUpdateLine != -int32(1) { *(*int32)(unsafe.Pointer(dInfoPtr + 280)) -= lineCount } } else { if fromLine <= (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FcurrentMetricUpdateLine { (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FcurrentMetricUpdateLine = fromLine if toLine <= (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FlastMetricUpdateLine { *(*int32)(unsafe.Pointer(dInfoPtr + 280)) -= lineCount } } else { if (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FlastMetricUpdateLine != -int32(1) { (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FlastMetricUpdateLine = toLine } } } } else { if action == int32(TK_TEXT_INVALIDATE_INSERT) { if toLine <= (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FcurrentMetricUpdateLine { (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FcurrentMetricUpdateLine = fromLine if (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FlastMetricUpdateLine != -int32(1) { *(*int32)(unsafe.Pointer(dInfoPtr + 280)) += lineCount } } else { if fromLine <= (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FcurrentMetricUpdateLine { (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FcurrentMetricUpdateLine = fromLine if toLine <= (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FlastMetricUpdateLine { *(*int32)(unsafe.Pointer(dInfoPtr + 280)) += lineCount } if toLine > (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FlastMetricUpdateLine { (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FlastMetricUpdateLine = toLine } } else { if (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FlastMetricUpdateLine != -int32(1) { (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FlastMetricUpdateLine = toLine } } } } else { if fromLine < (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FcurrentMetricUpdateLine { (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FcurrentMetricUpdateLine = fromLine } if (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FlastMetricUpdateLine != -int32(1) && toLine > (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FlastMetricUpdateLine { (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FlastMetricUpdateLine = toLine } } } } } else { /* * This invalidates the height of all lines in the widget. */ v2 = dInfoPtr + 224 *(*int32)(unsafe.Pointer(v2))++ v1 = *(*int32)(unsafe.Pointer(v2)) if v1 == 0 { (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FlineMetricUpdateEpoch++ } /* * This has the effect of forcing an entire new loop of update checks * on all lines in the widget. */ if (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FlineUpdateTimer == libc.UintptrFromInt32(0) { (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FcurrentMetricUpdateLine = -int32(1) } (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FlastMetricUpdateLine = (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FcurrentMetricUpdateLine } /* * Now re-set the current update calculations. */ if (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FlineUpdateTimer == libc.UintptrFromInt32(0) { (*TTkText)(unsafe.Pointer(textPtr)).FrefCount++ (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FlineUpdateTimer = libtcl9_0.XTcl_CreateTimerHandler(tls, int32(1), __ccgo_fp(_AsyncUpdateLineMetrics), textPtr) } /* * The widget is out of sync: send a <> event. */ _GenerateWidgetViewSyncEvent(tls, textPtr, 0) } /* *---------------------------------------------------------------------- * * TkTextFindDisplayLineEnd -- * * This function is invoked to find the index of the beginning or end of * the particular display line on which the given index sits, whether * that line is displayed or not. * * If 'end' is zero, we look for the start, and if 'end' is one we look * for the end. * * If the beginning of the current display line is elided, and we are * looking for the start of the line, then the returned index will be the * first elided index on the display line. * * Similarly if the end of the current display line is elided and we are * looking for the end, then the returned index will be the last elided * index on the display line. * * Results: * Modifies indexPtr to point to the given end. * * If xOffset is non-NULL, it is set to the x-pixel offset of the given * original index within the given display line. * * Side effects: * The combination of 'LayoutDLine' and 'FreeDLines' seems like a rather * time-consuming way of gathering the information we need, so this would * be a good place to look to speed up the calculations. In particular * these calls will map and unmap embedded windows respectively, which I * would hope isn't exactly necessary! * *---------------------------------------------------------------------- */ func XTkTextFindDisplayLineEnd(tls *libc.TLS, textPtr uintptr, indexPtr uintptr, end int32, xOffset uintptr) { bp := tls.Alloc(96) defer tls.Free(96) /* NULL, or used to store the x-pixel offset * of the original index within its display * line. */ var byteCount TTcl_Size var dlPtr uintptr var _ /* endOfLastLine at bp+32 */ TTkTextIndex var _ /* index at bp+0 */ TTkTextIndex var _ /* nextLineStart at bp+64 */ TTkTextIndex _, _ = byteCount, dlPtr if !(end != 0) && _IsStartOfNotMergedLine(tls, textPtr, indexPtr) != 0 { /* * Nothing to do. */ if xOffset != libc.UintptrFromInt32(0) { *(*int32)(unsafe.Pointer(xOffset)) = 0 } return } *(*TTkTextIndex)(unsafe.Pointer(bp)) = *(*TTkTextIndex)(unsafe.Pointer(indexPtr)) (*(*TTkTextIndex)(unsafe.Pointer(bp))).FbyteIndex = 0 (*(*TTkTextIndex)(unsafe.Pointer(bp))).FtextPtr = libc.UintptrFromInt32(0) for int32(1) != 0 { if XTkTextIndexBackBytes(tls, textPtr, bp, int64(1), bp+32) != 0 { /* * Reached beginning of text. */ break } if !(XTkTextIsElided(tls, textPtr, bp+32, libc.UintptrFromInt32(0)) != 0) { /* * The eol is not elided, so 'index' points to the start of a * display line (as well as logical line). */ break } /* * indexPtr's logical line is actually merged with the previous * logical line whose eol is elided. Continue searching back to get a * real line start. */ *(*TTkTextIndex)(unsafe.Pointer(bp)) = *(*TTkTextIndex)(unsafe.Pointer(bp + 32)) (*(*TTkTextIndex)(unsafe.Pointer(bp))).FbyteIndex = 0 } for int32(1) != 0 { dlPtr = _LayoutDLine(tls, textPtr, bp) byteCount = int64((*TDLine)(unsafe.Pointer(dlPtr)).FbyteCount) XTkTextIndexForwBytes(tls, textPtr, bp, byteCount, bp+64) /* * 'byteCount' goes up to the beginning of the next display line, so * equality here says we need one more line. We try to perform a quick * comparison which is valid for the case where the logical line is * the same, but otherwise fall back on a full TkTextIndexCmp. */ if (*(*TTkTextIndex)(unsafe.Pointer(bp))).FlinePtr == (*TTkTextIndex)(unsafe.Pointer(indexPtr)).FlinePtr && (*(*TTkTextIndex)(unsafe.Pointer(bp))).FbyteIndex+byteCount > (*TTkTextIndex)(unsafe.Pointer(indexPtr)).FbyteIndex || (*TDLine)(unsafe.Pointer(dlPtr)).FlogicalLinesMerged > 0 && XTkTextIndexCmp(tls, bp+64, indexPtr) > 0 { /* * It's on this display line. */ if xOffset != libc.UintptrFromInt32(0) { /* * This call takes a byte index relative to the start of the * current _display_ line, not logical line. We are about to * overwrite indexPtr->byteIndex, so we must do this now. */ *(*int32)(unsafe.Pointer(xOffset)) = _DlineXOfIndex(tls, textPtr, dlPtr, XTkTextIndexCountBytes(tls, textPtr, dlPtr, indexPtr)) } if end != 0 { /* * The index we want is one less than the number of bytes in * the display line. */ XTkTextIndexBackBytes(tls, textPtr, bp+64, int64(1), indexPtr) } else { *(*TTkTextIndex)(unsafe.Pointer(indexPtr)) = *(*TTkTextIndex)(unsafe.Pointer(bp)) } _FreeDLines(tls, textPtr, dlPtr, libc.UintptrFromInt32(0), int32(DLINE_FREE_TEMP)) return } _FreeDLines(tls, textPtr, dlPtr, libc.UintptrFromInt32(0), int32(DLINE_FREE_TEMP)) *(*TTkTextIndex)(unsafe.Pointer(bp)) = *(*TTkTextIndex)(unsafe.Pointer(bp + 64)) } } /* *---------------------------------------------------------------------- * * CalculateDisplayLineHeight -- * * This function is invoked to recalculate the height of the particular * display line which starts with the given index, whether that line is * displayed or not. * * This function does not, in itself, update any cached information about * line heights. That should be done, where necessary, by its callers. * * The behaviour of this function is _undefined_ if indexPtr is not * currently at the beginning of a display line. * * Results: * The number of vertical pixels used by the display line. * * If 'byteCountPtr' is non-NULL, then returns in that pointer the number * of byte indices on the given display line (which can be used to update * indexPtr in a loop). * * If 'mergedLinePtr' is non-NULL, then returns in that pointer the * number of extra logical lines merged into the given display line. * * Side effects: * The combination of 'LayoutDLine' and 'FreeDLines' seems like a rather * time-consuming way of gathering the information we need, so this would * be a good place to look to speed up the calculations. In particular * these calls will map and unmap embedded windows respectively, which I * would hope isn't exactly necessary! * *---------------------------------------------------------------------- */ func _CalculateDisplayLineHeight(tls *libc.TLS, textPtr uintptr, indexPtr uintptr, byteCountPtr uintptr, mergedLinePtr uintptr) (r int32) { bp := tls.Alloc(32) defer tls.Free(32) /* NULL or used to return if the given display * line merges with a following logical line * (because the eol is elided). */ var dlPtr uintptr var oldtkTextDebug, pixelHeight int32 var _ /* indexPtr2 at bp+0 */ TTkTextIndex _, _, _ = dlPtr, oldtkTextDebug, pixelHeight if XtkTextDebug != 0 { oldtkTextDebug = XtkTextDebug /* * Check that the indexPtr we are given really is at the start of a * display line. The gymnastics with tkTextDebug is to prevent * failure of a test suite test, that checks that lines are rendered * exactly once. TkTextFindDisplayLineEnd is used here for checking * indexPtr but it calls LayoutDLine/FreeDLine which makes the * counting wrong. The debug mode shall therefore be switched off * when calling TkTextFindDisplayLineEnd. */ *(*TTkTextIndex)(unsafe.Pointer(bp)) = *(*TTkTextIndex)(unsafe.Pointer(indexPtr)) XtkTextDebug = 0 XTkTextFindDisplayLineEnd(tls, textPtr, bp, 0, libc.UintptrFromInt32(0)) XtkTextDebug = oldtkTextDebug if XTkTextIndexCmp(tls, bp, indexPtr) != 0 { libtcl9_0.XTcl_Panic(tls, __ccgo_ts+47144, 0) } } /* * Special case for artificial last line. May be better to move this * inside LayoutDLine. */ if (*TTkTextIndex)(unsafe.Pointer(indexPtr)).FbyteIndex == 0 && XTkBTreeNextLine(tls, textPtr, (*TTkTextIndex)(unsafe.Pointer(indexPtr)).FlinePtr) == libc.UintptrFromInt32(0) { if byteCountPtr != libc.UintptrFromInt32(0) { *(*int32)(unsafe.Pointer(byteCountPtr)) = 0 } if mergedLinePtr != libc.UintptrFromInt32(0) { *(*int32)(unsafe.Pointer(mergedLinePtr)) = 0 } return 0 } /* * Layout, find the information we need and then free the display-line we * laid-out. We must use 'FreeDLines' because it will actually call the * relevant code to unmap any embedded windows which were mapped in the * LayoutDLine call! */ dlPtr = _LayoutDLine(tls, textPtr, indexPtr) pixelHeight = (*TDLine)(unsafe.Pointer(dlPtr)).Fheight if byteCountPtr != libc.UintptrFromInt32(0) { *(*int32)(unsafe.Pointer(byteCountPtr)) = (*TDLine)(unsafe.Pointer(dlPtr)).FbyteCount } if mergedLinePtr != libc.UintptrFromInt32(0) { *(*int32)(unsafe.Pointer(mergedLinePtr)) = (*TDLine)(unsafe.Pointer(dlPtr)).FlogicalLinesMerged } _FreeDLines(tls, textPtr, dlPtr, libc.UintptrFromInt32(0), int32(DLINE_FREE_TEMP)) return pixelHeight } /* *---------------------------------------------------------------------- * * TkTextIndexYPixels -- * * This function is invoked to calculate the number of vertical pixels * between the first index of the text widget and the given index. The * range from first logical line to given logical line is determined * using the cached values, and the range inside the given logical line * is calculated on the fly. * * Results: * The pixel distance between first pixel in the widget and the * top of the index's current display line (could be zero). * * Side effects: * Just those of 'CalculateDisplayLineHeight'. * *---------------------------------------------------------------------- */ func XTkTextIndexYPixels(tls *libc.TLS, textPtr uintptr, indexPtr uintptr) (r int32) { bp := tls.Alloc(48) defer tls.Free(48) /* The index of which we want the pixel * distance from top of logical line to top of * index. */ var alreadyStartOfLine, compare, height, pixelHeight int32 var _ /* bytes at bp+32 */ int32 var _ /* index at bp+0 */ TTkTextIndex _, _, _, _ = alreadyStartOfLine, compare, height, pixelHeight alreadyStartOfLine = int32(1) /* * Find the index denoting the closest position being at the same time * the start of a logical line above indexPtr and the start of a display * line. */ *(*TTkTextIndex)(unsafe.Pointer(bp)) = *(*TTkTextIndex)(unsafe.Pointer(indexPtr)) for int32(1) != 0 { XTkTextFindDisplayLineEnd(tls, textPtr, bp, 0, libc.UintptrFromInt32(0)) if (*(*TTkTextIndex)(unsafe.Pointer(bp))).FbyteIndex == 0 { break } XTkTextIndexBackBytes(tls, textPtr, bp, int64(1), bp) alreadyStartOfLine = 0 } pixelHeight = XTkBTreePixelsTo(tls, textPtr, (*(*TTkTextIndex)(unsafe.Pointer(bp))).FlinePtr) /* * Shortcut to avoid layout of a superfluous display line. We know there * is nothing more to add up to the height if the index we were given was * already on the first display line of a logical line. */ if alreadyStartOfLine != 0 { return pixelHeight } /* * Iterate through display lines, starting at the logical line belonging * to index, adding up the pixel height of each such display line as we * go along, until we go past 'indexPtr'. */ for int32(1) != 0 { /* * Currently this call doesn't have many side-effects. However, if in * the future we change the code so there are side-effects (such as * adjusting linePtr->pixelHeight), then the code might not quite work * as intended, specifically the 'linePtr->pixelHeight == pixelHeight' * test below this while loop. */ height = _CalculateDisplayLineHeight(tls, textPtr, bp, bp+32, libc.UintptrFromInt32(0)) XTkTextIndexForwBytes(tls, textPtr, bp, int64(*(*int32)(unsafe.Pointer(bp + 32))), bp) compare = XTkTextIndexCmp(tls, bp, indexPtr) if compare > 0 { return pixelHeight } if height > 0 { pixelHeight += height } if compare == 0 { return pixelHeight } } return r } /* *---------------------------------------------------------------------- * * TkTextUpdateOneLine -- * * This function is invoked to recalculate the height of a particular * logical line, whether that line is displayed or not. * * It must NEVER be called for the artificial last TkTextLine which is * used internally for administrative purposes only. That line must * retain its initial height of 0 otherwise the pixel height calculation * maintained by the B-tree will be wrong. * * Results: * The number of display lines in the logical line. This could be zero if * the line is totally elided. * * Side effects: * Line heights may be recalculated, and a timer to update the scrollbar * may be installed. Also see the called function * CalculateDisplayLineHeight for its side effects. * *---------------------------------------------------------------------- */ func XTkTextUpdateOneLine(tls *libc.TLS, textPtr uintptr, linePtr uintptr, pixelHeight int32, indexPtr uintptr, partialCalc int32) (r int32) { bp := tls.Alloc(128) defer tls.Free(128) /* Set to 1 if we are allowed to do partial * height calculations of long-lines. In this * case we'll only return what we know so * far. */ var changed, displayLines, height, i, mergedLines, v1 int32 var mergedLinePtr uintptr var _ /* buffer at bp+40 */ [49]uint8 var _ /* bytes at bp+32 */ int32 var _ /* index at bp+0 */ TTkTextIndex var _ /* logicalLines at bp+36 */ int32 _, _, _, _, _, _, _ = changed, displayLines, height, i, mergedLinePtr, mergedLines, v1 if indexPtr == libc.UintptrFromInt32(0) { (*(*TTkTextIndex)(unsafe.Pointer(bp))).Ftree = (*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).Ftree (*(*TTkTextIndex)(unsafe.Pointer(bp))).FlinePtr = linePtr (*(*TTkTextIndex)(unsafe.Pointer(bp))).FbyteIndex = 0 (*(*TTkTextIndex)(unsafe.Pointer(bp))).FtextPtr = libc.UintptrFromInt32(0) indexPtr = bp pixelHeight = 0 } /* * CalculateDisplayLineHeight _must_ be called (below) with an index at * the beginning of a display line. Force this to happen. This is needed * when TkTextUpdateOneLine is called with a line that is merged with its * previous line: the number of merged logical lines in a display line is * calculated correctly only when CalculateDisplayLineHeight receives * an index at the beginning of a display line. In turn this causes the * merged lines to receive their correct zero pixel height in * TkBTreeAdjustPixelHeight. */ XTkTextFindDisplayLineEnd(tls, textPtr, indexPtr, 0, libc.UintptrFromInt32(0)) linePtr = (*TTkTextIndex)(unsafe.Pointer(indexPtr)).FlinePtr /* * Iterate through all display-lines corresponding to the single logical * line 'linePtr' (and lines merged into this line due to eol elision), * adding up the pixel height of each such display line as we go along. * The final total is, therefore, the total height of all display lines * made up by the logical line 'linePtr' and subsequent logical lines * merged into this line. */ displayLines = 0 mergedLines = 0 for int32(1) != 0 { /* * Currently this call doesn't have many side-effects. However, if in * the future we change the code so there are side-effects (such as * adjusting linePtr->pixelHeight), then the code might not quite work * as intended, specifically the 'linePtr->pixelHeight == pixelHeight' * test below this while loop. */ height = _CalculateDisplayLineHeight(tls, textPtr, indexPtr, bp+32, bp+36) if height > 0 { pixelHeight += height displayLines++ } mergedLines += *(*int32)(unsafe.Pointer(bp + 36)) if XTkTextIndexForwBytes(tls, textPtr, indexPtr, int64(*(*int32)(unsafe.Pointer(bp + 32))), indexPtr) != 0 { break } if mergedLines == 0 { if (*TTkTextIndex)(unsafe.Pointer(indexPtr)).FlinePtr != linePtr { /* * If we reached the end of the logical line, then either way * we don't have a partial calculation. */ partialCalc = 0 break } } else { if _IsStartOfNotMergedLine(tls, textPtr, indexPtr) != 0 { /* * We've ended a logical line. */ partialCalc = 0 break } /* * We must still be on the same wrapped line, on a new logical * line merged with the logical line 'linePtr'. */ } if partialCalc != 0 && displayLines > int32(50) && mergedLines == 0 { /* * Only calculate 50 display lines at a time, to avoid huge * delays. In any case it is very rare that a single line wraps 50 * times! * * If we have any merged lines, we must complete the full logical * line layout here and now, because the partial-calculation code * isn't designed to handle merged logical lines. Hence the * 'mergedLines == 0' check. */ break } } if !(partialCalc != 0) { changed = 0 /* * Cancel any partial line height calculation state. */ (*TTextDInfo1)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FdInfoPtr)).FmetricEpoch = int64(-int32(1)) /* * Mark the logical line as being up to date (caution: it isn't yet up * to date, that will happen in TkBTreeAdjustPixelHeight just below). */ *(*int32)(unsafe.Pointer((*TTkTextLine)(unsafe.Pointer(linePtr)).Fpixels + uintptr(int32(1)+int32(2)*(*TTkText)(unsafe.Pointer(textPtr)).FpixelReference)*4)) = (*TTextDInfo1)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FdInfoPtr)).FlineMetricUpdateEpoch if *(*int32)(unsafe.Pointer((*TTkTextLine)(unsafe.Pointer(linePtr)).Fpixels + uintptr(int32(2)*(*TTkText)(unsafe.Pointer(textPtr)).FpixelReference)*4)) != pixelHeight { changed = int32(1) } if mergedLines > 0 { i = mergedLines /* * Loop over all merged logical lines, marking them up to date * (again, the pixel count setting will actually happen in * TkBTreeAdjustPixelHeight). */ mergedLinePtr = linePtr for { v1 = i i-- if !(v1 > 0) { break } mergedLinePtr = XTkBTreeNextLine(tls, textPtr, mergedLinePtr) *(*int32)(unsafe.Pointer((*TTkTextLine)(unsafe.Pointer(mergedLinePtr)).Fpixels + uintptr(int32(1)+int32(2)*(*TTkText)(unsafe.Pointer(textPtr)).FpixelReference)*4)) = (*TTextDInfo1)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FdInfoPtr)).FlineMetricUpdateEpoch if *(*int32)(unsafe.Pointer((*TTkTextLine)(unsafe.Pointer(mergedLinePtr)).Fpixels + uintptr(int32(2)*(*TTkText)(unsafe.Pointer(textPtr)).FpixelReference)*4)) != 0 { changed = int32(1) } } } if !(changed != 0) { /* * If there's nothing to change, then we can already return. */ return displayLines } } /* * We set the line's height, but the return value is now the height of the * entire widget, which may be used just below for reporting/debugging * purposes. */ pixelHeight = XTkBTreeAdjustPixelHeight(tls, textPtr, linePtr, pixelHeight, mergedLines) if XtkTextDebug != 0 { if XTkBTreeNextLine(tls, textPtr, linePtr) == libc.UintptrFromInt32(0) { libtcl9_0.XTcl_Panic(tls, __ccgo_ts+47196, 0) } libc.X__builtin_snprintf(tls, bp+40, uint64(49), __ccgo_ts+47089, libc.VaList(bp+104, XTkBTreeLinesTo(tls, textPtr, linePtr), pixelHeight)) libtcl9_0.XTcl_SetVar2(tls, (*TTkText)(unsafe.Pointer(textPtr)).Finterp, __ccgo_ts+47252, libc.UintptrFromInt32(0), bp+40, libc.Int32FromInt32(TCL_GLOBAL_ONLY)|libc.Int32FromInt32(TCL_APPEND_VALUE)|libc.Int32FromInt32(TCL_LIST_ELEMENT)) } if (*TTextDInfo1)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FdInfoPtr)).FscrollbarTimer == libc.UintptrFromInt32(0) { (*TTkText)(unsafe.Pointer(textPtr)).FrefCount++ (*TTextDInfo1)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FdInfoPtr)).FscrollbarTimer = libtcl9_0.XTcl_CreateTimerHandler(tls, int32(200), __ccgo_fp(_AsyncUpdateYScrollbar), textPtr) } return displayLines } /* *---------------------------------------------------------------------- * * DisplayText -- * * This function is invoked as a when-idle handler to update the display. * It only redisplays the parts of the text widget that are out of date. * * Results: * None. * * Side effects: * Information is redrawn on the screen. * *---------------------------------------------------------------------- */ func _DisplayText(tls *libc.TLS, clientData uintptr) { bp := tls.Alloc(80) defer tls.Free(80) /* Information about widget. */ var bgGC, fgGC TGC var borders, bottomY, height, maxHeight, offset, oldY, x, y, y_off int32 var chunkPtr, dInfoPtr, dlPtr, dlPtr2, interp, prevPtr, textPtr, v2 uintptr var damageRgn TRegion var pixmap TPixmap var v1 TTcl_Size var _ /* borderWidth at bp+8 */ int32 var _ /* highlightWidth at bp+12 */ int32 var _ /* padX at bp+0 */ int32 var _ /* padY at bp+4 */ int32 var _ /* string at bp+16 */ [30]uint8 var _ /* string at bp+46 */ [30]uint8 _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = bgGC, borders, bottomY, chunkPtr, dInfoPtr, damageRgn, dlPtr, dlPtr2, fgGC, height, interp, maxHeight, offset, oldY, pixmap, prevPtr, textPtr, x, y, y_off, v1, v2 textPtr = clientData dInfoPtr = (*TTkText)(unsafe.Pointer(textPtr)).FdInfoPtr bottomY = 0 if (*TTkText)(unsafe.Pointer(textPtr)).Ftkwin == libc.UintptrFromInt32(0) || (*TTkText)(unsafe.Pointer(textPtr)).Fflags&int32(DESTROYED) != 0 { /* * The widget has been deleted. Don't do anything. */ return } interp = (*TTkText)(unsafe.Pointer(textPtr)).Finterp libtcl9_0.XTcl_Preserve(tls, interp) if XtkTextDebug != 0 { libtcl9_0.XTcl_SetVar2(tls, interp, __ccgo_ts+46947, libc.UintptrFromInt32(0), __ccgo_ts+195, int32(TCL_GLOBAL_ONLY)) } if !((*TTk_FakeWin)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).Ftkwin)).Fflags&libc.Uint32FromInt32(TK_MAPPED) != 0) || (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FmaxX <= (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).Fx || (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FmaxY <= (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).Fy { _UpdateDisplayInfo(tls, textPtr) *(*int32)(unsafe.Pointer(dInfoPtr + 220)) &= ^libc.Int32FromInt32(REDRAW_PENDING3) goto doScrollbars } _numRedisplays++ if XtkTextDebug != 0 { libtcl9_0.XTcl_SetVar2(tls, interp, __ccgo_ts+47269, libc.UintptrFromInt32(0), __ccgo_ts+195, int32(TCL_GLOBAL_ONLY)) } /* * Choose a new current item if that is needed (this could cause event * handlers to be invoked, hence the refcount management and the loop, * since the handlers could conceivably necessitate yet another current * item calculation). The tkwin check is because the whole window could go * away in the Tcl_Release call. */ for (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).Fflags&int32(REPICK_NEEDED1) != 0 { (*TTkText)(unsafe.Pointer(textPtr)).FrefCount++ *(*int32)(unsafe.Pointer(dInfoPtr + 220)) &= ^libc.Int32FromInt32(REPICK_NEEDED1) XTkTextPickCurrent(tls, textPtr, textPtr+440) v2 = textPtr + 688 v1 = *(*TTcl_Size)(unsafe.Pointer(v2)) *(*TTcl_Size)(unsafe.Pointer(v2))-- if v1 <= int64(1) { libtcl9_0.XTcl_Free(tls, textPtr) goto end } if (*TTkText)(unsafe.Pointer(textPtr)).Ftkwin == libc.UintptrFromInt32(0) || (*TTkText)(unsafe.Pointer(textPtr)).Fflags&int32(DESTROYED) != 0 { goto end } } /* * First recompute what's supposed to be displayed. */ _UpdateDisplayInfo(tls, textPtr) (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FdLinesInvalidated = 0 /* * See if it's possible to bring some parts of the screen up-to-date by * scrolling (copying from other parts of the screen). We have to be * particularly careful with the top and bottom lines of the display, * since these may only be partially visible and therefore not helpful for * some scrolling purposes. */ dlPtr = (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FdLinePtr for { if !(dlPtr != libc.UintptrFromInt32(0)) { break } /* * These tests are, in order: * * 1. If the line is already marked as invalid * 2. If the line hasn't moved * 3. If the line overlaps the bottom of the window and we are * scrolling up. * 4. If the line overlaps the top of the window and we are scrolling * down. * * If any of these tests are true, then we can't scroll this line's * part of the display. * * Note that even if tests 3 or 4 aren't true, we may be able to * scroll the line, but we still need to be sure to call embedded * window display procs on top and bottom lines if they have any * portion non-visible (see below). */ if (*TDLine)(unsafe.Pointer(dlPtr)).Fflags&int32(OLD_Y_INVALID) != 0 || (*TDLine)(unsafe.Pointer(dlPtr)).Fy == (*TDLine)(unsafe.Pointer(dlPtr)).FoldY || (*TDLine)(unsafe.Pointer(dlPtr)).FoldY+(*TDLine)(unsafe.Pointer(dlPtr)).Fheight > (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FmaxY && (*TDLine)(unsafe.Pointer(dlPtr)).Fy < (*TDLine)(unsafe.Pointer(dlPtr)).FoldY || (*TDLine)(unsafe.Pointer(dlPtr)).FoldY < (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).Fy && (*TDLine)(unsafe.Pointer(dlPtr)).Fy > (*TDLine)(unsafe.Pointer(dlPtr)).FoldY { goto _3 } /* * This line is already drawn somewhere in the window so it only needs * to be copied to its new location. See if there's a group of lines * that can all be copied together. */ offset = (*TDLine)(unsafe.Pointer(dlPtr)).Fy - (*TDLine)(unsafe.Pointer(dlPtr)).FoldY height = (*TDLine)(unsafe.Pointer(dlPtr)).Fheight y = (*TDLine)(unsafe.Pointer(dlPtr)).Fy dlPtr2 = (*TDLine)(unsafe.Pointer(dlPtr)).FnextPtr for { if !(dlPtr2 != libc.UintptrFromInt32(0)) { break } if (*TDLine)(unsafe.Pointer(dlPtr2)).Fflags&int32(OLD_Y_INVALID) != 0 || (*TDLine)(unsafe.Pointer(dlPtr2)).FoldY+offset != (*TDLine)(unsafe.Pointer(dlPtr2)).Fy || (*TDLine)(unsafe.Pointer(dlPtr2)).FoldY+(*TDLine)(unsafe.Pointer(dlPtr2)).Fheight > (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FmaxY { break } height += (*TDLine)(unsafe.Pointer(dlPtr2)).Fheight goto _4 _4: ; dlPtr2 = (*TDLine)(unsafe.Pointer(dlPtr2)).FnextPtr } /* * Reduce the height of the area being copied if necessary to avoid * overwriting the border area. */ if y+height > (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FmaxY { height = (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FmaxY - y } oldY = (*TDLine)(unsafe.Pointer(dlPtr)).FoldY if y < (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).Fy { /* * Adjust if the area being copied is going to overwrite the top * border of the window (so the top line is only half onscreen). */ y_off = (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).Fy - (*TDLine)(unsafe.Pointer(dlPtr)).Fy height -= y_off oldY += y_off y = (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).Fy } /* * Update the lines we are going to scroll to show that they have been * copied. */ for int32(1) != 0 { /* * The DLine already has OLD_Y_INVALID cleared. */ (*TDLine)(unsafe.Pointer(dlPtr)).FoldY = (*TDLine)(unsafe.Pointer(dlPtr)).Fy if (*TDLine)(unsafe.Pointer(dlPtr)).FnextPtr == dlPtr2 { break } dlPtr = (*TDLine)(unsafe.Pointer(dlPtr)).FnextPtr } /* * Scan through the lines following the copied ones to see if we are * going to overwrite them with the copy operation. If so, mark them * for redisplay. */ for { if !(dlPtr2 != libc.UintptrFromInt32(0)) { break } if !((*TDLine)(unsafe.Pointer(dlPtr2)).Fflags&libc.Int32FromInt32(OLD_Y_INVALID) != 0) && (*TDLine)(unsafe.Pointer(dlPtr2)).FoldY+(*TDLine)(unsafe.Pointer(dlPtr2)).Fheight > y && (*TDLine)(unsafe.Pointer(dlPtr2)).FoldY < y+height { *(*int32)(unsafe.Pointer(dlPtr2 + 112)) |= int32(OLD_Y_INVALID) } goto _5 _5: ; dlPtr2 = (*TDLine)(unsafe.Pointer(dlPtr2)).FnextPtr } /* * Now scroll the lines. This may generate damage which we handle by * calling TextInvalidateRegion to mark the display blocks as stale. */ damageRgn = libx11.XXCreateRegion(tls) if XTkScrollWindow(tls, (*TTkText)(unsafe.Pointer(textPtr)).Ftkwin, (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FscrollGC, (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).Fx, oldY, (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FmaxX-(*TTextDInfo)(unsafe.Pointer(dInfoPtr)).Fx, height, 0, y-oldY, damageRgn) != 0 { _TextInvalidateRegion(tls, textPtr, damageRgn) } _numCopies++ libx11.XXDestroyRegion(tls, damageRgn) goto _3 _3: ; dlPtr = (*TDLine)(unsafe.Pointer(dlPtr)).FnextPtr } /* * Clear the REDRAW_PENDING flag here. This is actually pretty tricky. We * want to wait until *after* doing the scrolling, since that could * generate more areas to redraw and don't want to reschedule a redisplay * for them. On the other hand, we can't wait until after all the * redisplaying, because the act of redisplaying could actually generate * more redisplays (e.g. in the case of a nested window with event * bindings triggered by redisplay). */ *(*int32)(unsafe.Pointer(dInfoPtr + 220)) &= ^libc.Int32FromInt32(REDRAW_PENDING3) XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), (*TTkText)(unsafe.Pointer(textPtr)).Ftkwin, (*TTkText)(unsafe.Pointer(textPtr)).FpadXObj, bp) XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), (*TTkText)(unsafe.Pointer(textPtr)).Ftkwin, (*TTkText)(unsafe.Pointer(textPtr)).FpadYObj, bp+4) /* * Redraw the borders if that's needed. */ if (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).Fflags&int32(REDRAW_BORDERS1) != 0 { if XtkTextDebug != 0 { libtcl9_0.XTcl_SetVar2(tls, (*TTkText)(unsafe.Pointer(textPtr)).Finterp, __ccgo_ts+47269, libc.UintptrFromInt32(0), __ccgo_ts+47283, libc.Int32FromInt32(TCL_GLOBAL_ONLY)|libc.Int32FromInt32(TCL_APPEND_VALUE)|libc.Int32FromInt32(TCL_LIST_ELEMENT)) } if (*TTkText)(unsafe.Pointer(textPtr)).Ftkwin == libc.UintptrFromInt32(0) { /* * The widget has been deleted. Don't do anything. */ goto end } XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), (*TTkText)(unsafe.Pointer(textPtr)).Ftkwin, (*TTkText)(unsafe.Pointer(textPtr)).FborderWidthObj, bp+8) XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), (*TTkText)(unsafe.Pointer(textPtr)).Ftkwin, (*TTkText)(unsafe.Pointer(textPtr)).FhighlightWidthObj, bp+12) XTk_Draw3DRectangle(tls, (*TTkText)(unsafe.Pointer(textPtr)).Ftkwin, (*TTk_FakeWin)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).Ftkwin)).Fwindow, (*TTkText)(unsafe.Pointer(textPtr)).Fborder, *(*int32)(unsafe.Pointer(bp + 12)), *(*int32)(unsafe.Pointer(bp + 12)), (*TTk_FakeWin)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).Ftkwin)).Fchanges.Fwidth-int32(2)**(*int32)(unsafe.Pointer(bp + 12)), (*TTk_FakeWin)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).Ftkwin)).Fchanges.Fheight-int32(2)**(*int32)(unsafe.Pointer(bp + 12)), *(*int32)(unsafe.Pointer(bp + 8)), (*TTkText)(unsafe.Pointer(textPtr)).Frelief) if *(*int32)(unsafe.Pointer(bp + 12)) > 0 { bgGC = XTk_GCForColor(tls, (*TTkText)(unsafe.Pointer(textPtr)).FhighlightBgColorPtr, (*TTk_FakeWin)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).Ftkwin)).Fwindow) if (*TTkText)(unsafe.Pointer(textPtr)).Fflags&int32(GOT_FOCUS8) != 0 { fgGC = XTk_GCForColor(tls, (*TTkText)(unsafe.Pointer(textPtr)).FhighlightColorPtr, (*TTk_FakeWin)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).Ftkwin)).Fwindow) XTk_DrawHighlightBorder(tls, (*TTkText)(unsafe.Pointer(textPtr)).Ftkwin, fgGC, bgGC, *(*int32)(unsafe.Pointer(bp + 12)), (*TTk_FakeWin)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).Ftkwin)).Fwindow) } else { XTk_DrawHighlightBorder(tls, (*TTkText)(unsafe.Pointer(textPtr)).Ftkwin, bgGC, bgGC, *(*int32)(unsafe.Pointer(bp + 12)), (*TTk_FakeWin)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).Ftkwin)).Fwindow) } } borders = *(*int32)(unsafe.Pointer(bp + 8)) + *(*int32)(unsafe.Pointer(bp + 12)) if *(*int32)(unsafe.Pointer(bp + 4)) > 0 { XTk_Fill3DRectangle(tls, (*TTkText)(unsafe.Pointer(textPtr)).Ftkwin, (*TTk_FakeWin)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).Ftkwin)).Fwindow, (*TTkText)(unsafe.Pointer(textPtr)).Fborder, borders, borders, (*TTk_FakeWin)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).Ftkwin)).Fchanges.Fwidth-int32(2)*borders, *(*int32)(unsafe.Pointer(bp + 4)), 0, TK_RELIEF_FLAT) XTk_Fill3DRectangle(tls, (*TTkText)(unsafe.Pointer(textPtr)).Ftkwin, (*TTk_FakeWin)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).Ftkwin)).Fwindow, (*TTkText)(unsafe.Pointer(textPtr)).Fborder, borders, (*TTk_FakeWin)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).Ftkwin)).Fchanges.Fheight-borders-*(*int32)(unsafe.Pointer(bp + 4)), (*TTk_FakeWin)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).Ftkwin)).Fchanges.Fwidth-int32(2)*borders, *(*int32)(unsafe.Pointer(bp + 4)), 0, TK_RELIEF_FLAT) } if *(*int32)(unsafe.Pointer(bp)) > 0 { XTk_Fill3DRectangle(tls, (*TTkText)(unsafe.Pointer(textPtr)).Ftkwin, (*TTk_FakeWin)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).Ftkwin)).Fwindow, (*TTkText)(unsafe.Pointer(textPtr)).Fborder, borders, borders+*(*int32)(unsafe.Pointer(bp + 4)), *(*int32)(unsafe.Pointer(bp)), (*TTk_FakeWin)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).Ftkwin)).Fchanges.Fheight-int32(2)*borders-int32(2)**(*int32)(unsafe.Pointer(bp + 4)), 0, TK_RELIEF_FLAT) XTk_Fill3DRectangle(tls, (*TTkText)(unsafe.Pointer(textPtr)).Ftkwin, (*TTk_FakeWin)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).Ftkwin)).Fwindow, (*TTkText)(unsafe.Pointer(textPtr)).Fborder, (*TTk_FakeWin)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).Ftkwin)).Fchanges.Fwidth-borders-*(*int32)(unsafe.Pointer(bp)), borders+*(*int32)(unsafe.Pointer(bp + 4)), *(*int32)(unsafe.Pointer(bp)), (*TTk_FakeWin)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).Ftkwin)).Fchanges.Fheight-int32(2)*borders-int32(2)**(*int32)(unsafe.Pointer(bp + 4)), 0, TK_RELIEF_FLAT) } *(*int32)(unsafe.Pointer(dInfoPtr + 220)) &= ^libc.Int32FromInt32(REDRAW_BORDERS1) } /* * Now we have to redraw the lines that couldn't be updated by scrolling. * First, compute the height of the largest line and allocate an off- * screen pixmap to use for double-buffered displays. */ maxHeight = -int32(1) dlPtr = (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FdLinePtr for { if !(dlPtr != libc.UintptrFromInt32(0)) { break } if (*TDLine)(unsafe.Pointer(dlPtr)).Fheight > maxHeight && ((*TDLine)(unsafe.Pointer(dlPtr)).Fflags&int32(OLD_Y_INVALID) != 0 || (*TDLine)(unsafe.Pointer(dlPtr)).FoldY != (*TDLine)(unsafe.Pointer(dlPtr)).Fy) { maxHeight = (*TDLine)(unsafe.Pointer(dlPtr)).Fheight } bottomY = (*TDLine)(unsafe.Pointer(dlPtr)).Fy + (*TDLine)(unsafe.Pointer(dlPtr)).Fheight goto _6 _6: ; dlPtr = (*TDLine)(unsafe.Pointer(dlPtr)).FnextPtr } /* * There used to be a line here which restricted 'maxHeight' to be no * larger than 'dInfoPtr->maxY', but this is incorrect for the case where * individual lines may be taller than the widget _and_ we have smooth * scrolling. What we can do is restrict maxHeight to be no larger than * 'dInfoPtr->maxY + dInfoPtr->topPixelOffset'. */ if maxHeight > (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FmaxY+(*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FtopPixelOffset { maxHeight = (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FmaxY + (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FtopPixelOffset } if maxHeight > 0 { pixmap = XTk_GetPixmap(tls, (*TTk_FakeWin)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).Ftkwin)).Fdisplay, (*TTk_FakeWin)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).Ftkwin)).Fwindow, (*TTk_FakeWin)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).Ftkwin)).Fchanges.Fwidth, maxHeight, (*TTk_FakeWin)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).Ftkwin)).Fdepth) prevPtr = libc.UintptrFromInt32(0) dlPtr = (*TTextDInfo1)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FdInfoPtr)).FdLinePtr for { if !(dlPtr != libc.UintptrFromInt32(0) && (*TDLine)(unsafe.Pointer(dlPtr)).Fy < (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FmaxY) { break } if (*TDLine)(unsafe.Pointer(dlPtr)).FchunkPtr == libc.UintptrFromInt32(0) { goto _7 } if (*TDLine)(unsafe.Pointer(dlPtr)).Fflags&int32(OLD_Y_INVALID) != 0 || (*TDLine)(unsafe.Pointer(dlPtr)).FoldY != (*TDLine)(unsafe.Pointer(dlPtr)).Fy { if XtkTextDebug != 0 { XTkTextPrintIndex(tls, textPtr, dlPtr, bp+16) libtcl9_0.XTcl_SetVar2(tls, (*TTkText)(unsafe.Pointer(textPtr)).Finterp, __ccgo_ts+47269, libc.UintptrFromInt32(0), bp+16, libc.Int32FromInt32(TCL_GLOBAL_ONLY)|libc.Int32FromInt32(TCL_APPEND_VALUE)|libc.Int32FromInt32(TCL_LIST_ELEMENT)) } _DisplayDLine(tls, textPtr, dlPtr, prevPtr, pixmap) if (*TTkText)(unsafe.Pointer(textPtr)).Ftkwin == libc.UintptrFromInt32(0) || (*TTkText)(unsafe.Pointer(textPtr)).Fflags&int32(DESTROYED) != 0 { /* * DisplayDLine called a displayProc which invoked a binding * that caused the widget to be deleted. Don't do anything. */ goto end } if (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FdLinesInvalidated != 0 { XTk_FreePixmap(tls, (*TTk_FakeWin)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).Ftkwin)).Fdisplay, pixmap) goto end } (*TDLine)(unsafe.Pointer(dlPtr)).FoldY = (*TDLine)(unsafe.Pointer(dlPtr)).Fy *(*int32)(unsafe.Pointer(dlPtr + 112)) &= ^(libc.Int32FromInt32(NEW_LAYOUT) | libc.Int32FromInt32(OLD_Y_INVALID)) } else { if (*TDLine)(unsafe.Pointer(dlPtr)).FchunkPtr != libc.UintptrFromInt32(0) && ((*TDLine)(unsafe.Pointer(dlPtr)).Fy < 0 || (*TDLine)(unsafe.Pointer(dlPtr)).Fy+(*TDLine)(unsafe.Pointer(dlPtr)).Fheight > (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FmaxY) { chunkPtr = (*TDLine)(unsafe.Pointer(dlPtr)).FchunkPtr for { if !(chunkPtr != libc.UintptrFromInt32(0)) { break } if (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FdisplayProc != __ccgo_fp(XTkTextEmbWinDisplayProc) { goto _8 } x = (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).Fx + (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).Fx - (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FcurXPixelOffset if x+(*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).Fwidth <= 0 || x >= (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FmaxX { /* * Note: we have to call the displayProc even for * chunks that are off-screen. This is needed, for * example, so that embedded windows can be unmapped * in this case. Display the chunk at a coordinate * that can be clearly identified by the displayProc * as being off-screen to the left (the displayProc * may not be able to tell if something is off to the * right). */ x = -(*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).Fwidth } if XtkTextDebug != 0 { XTkTextPrintIndex(tls, textPtr, dlPtr, bp+46) libtcl9_0.XTcl_SetVar2(tls, (*TTkText)(unsafe.Pointer(textPtr)).Finterp, __ccgo_ts+47291, libc.UintptrFromInt32(0), bp+46, libc.Int32FromInt32(TCL_GLOBAL_ONLY)|libc.Int32FromInt32(TCL_APPEND_VALUE)|libc.Int32FromInt32(TCL_LIST_ELEMENT)) } XTkTextEmbWinDisplayProc(tls, textPtr, chunkPtr, x, (*TDLine)(unsafe.Pointer(dlPtr)).FspaceAbove, (*TDLine)(unsafe.Pointer(dlPtr)).Fheight-(*TDLine)(unsafe.Pointer(dlPtr)).FspaceAbove-(*TDLine)(unsafe.Pointer(dlPtr)).FspaceBelow, (*TDLine)(unsafe.Pointer(dlPtr)).Fbaseline-(*TDLine)(unsafe.Pointer(dlPtr)).FspaceAbove, libc.UintptrFromInt32(0), uint64(0), (*TDLine)(unsafe.Pointer(dlPtr)).Fy+(*TDLine)(unsafe.Pointer(dlPtr)).FspaceAbove) goto _8 _8: ; chunkPtr = (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FnextPtr } } } goto _7 _7: ; prevPtr = dlPtr dlPtr = (*TDLine)(unsafe.Pointer(dlPtr)).FnextPtr } XTk_FreePixmap(tls, (*TTk_FakeWin)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).Ftkwin)).Fdisplay, pixmap) } /* * See if we need to refresh the part of the window below the last line of * text (if there is any such area). Refresh the padding area on the left * too, since the insertion cursor might have been displayed there * previously). */ if (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FtopOfEof > (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FmaxY { (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FtopOfEof = (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FmaxY } if bottomY < (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FtopOfEof { if XtkTextDebug != 0 { libtcl9_0.XTcl_SetVar2(tls, (*TTkText)(unsafe.Pointer(textPtr)).Finterp, __ccgo_ts+47269, libc.UintptrFromInt32(0), __ccgo_ts+47312, libc.Int32FromInt32(TCL_GLOBAL_ONLY)|libc.Int32FromInt32(TCL_APPEND_VALUE)|libc.Int32FromInt32(TCL_LIST_ELEMENT)) } if (*TTkText)(unsafe.Pointer(textPtr)).Ftkwin == libc.UintptrFromInt32(0) || (*TTkText)(unsafe.Pointer(textPtr)).Fflags&int32(DESTROYED) != 0 { /* * The widget has been deleted. Don't do anything. */ goto end } XTk_Fill3DRectangle(tls, (*TTkText)(unsafe.Pointer(textPtr)).Ftkwin, (*TTk_FakeWin)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).Ftkwin)).Fwindow, (*TTkText)(unsafe.Pointer(textPtr)).Fborder, (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).Fx-*(*int32)(unsafe.Pointer(bp)), bottomY, (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FmaxX-((*TTextDInfo)(unsafe.Pointer(dInfoPtr)).Fx-*(*int32)(unsafe.Pointer(bp))), (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FtopOfEof-bottomY, 0, TK_RELIEF_FLAT) } (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FtopOfEof = bottomY /* * Update the vertical scrollbar, if there is one. Note: it's important to * clear REDRAW_PENDING here, just in case the scroll function does * something that requires redisplay. */ goto doScrollbars doScrollbars: ; if (*TTkText)(unsafe.Pointer(textPtr)).Fflags&int32(UPDATE_SCROLLBARS1) != 0 { *(*int32)(unsafe.Pointer(textPtr + 672)) &= ^libc.Int32FromInt32(UPDATE_SCROLLBARS1) if (*TTkText)(unsafe.Pointer(textPtr)).FyScrollCmdObj != libc.UintptrFromInt32(0) { _GetYView(tls, (*TTkText)(unsafe.Pointer(textPtr)).Finterp, textPtr, int32(1)) } if (*TTkText)(unsafe.Pointer(textPtr)).Ftkwin == libc.UintptrFromInt32(0) || (*TTkText)(unsafe.Pointer(textPtr)).Fflags&int32(DESTROYED) != 0 { /* * The widget has been deleted. Don't do anything. */ goto end } /* * Update the horizontal scrollbar, if any. */ if (*TTkText)(unsafe.Pointer(textPtr)).FxScrollCmdObj != libc.UintptrFromInt32(0) { _GetXView(tls, (*TTkText)(unsafe.Pointer(textPtr)).Finterp, textPtr, int32(1)) } } goto end end: ; libtcl9_0.XTcl_Release(tls, interp) } /* *---------------------------------------------------------------------- * * TkTextEventuallyRepick -- * * This function is invoked whenever something happens that could change * the current character or the tags associated with it. * * Results: * None. * * Side effects: * A repick is scheduled as an idle handler. * *---------------------------------------------------------------------- */ func XTkTextEventuallyRepick(tls *libc.TLS, textPtr uintptr) { /* Widget record for text widget. */ var dInfoPtr uintptr _ = dInfoPtr dInfoPtr = (*TTkText)(unsafe.Pointer(textPtr)).FdInfoPtr *(*int32)(unsafe.Pointer(dInfoPtr + 220)) |= int32(REPICK_NEEDED1) if !((*TTextDInfo)(unsafe.Pointer(dInfoPtr)).Fflags&libc.Int32FromInt32(REDRAW_PENDING3) != 0) { *(*int32)(unsafe.Pointer(dInfoPtr + 220)) |= int32(REDRAW_PENDING3) libtcl9_0.XTcl_DoWhenIdle(tls, __ccgo_fp(_DisplayText), textPtr) } } /* *---------------------------------------------------------------------- * * TkTextRedrawRegion -- * * This function is invoked to schedule a redisplay for a given region of * a text widget. The redisplay itself may not occur immediately: it's * scheduled as a when-idle handler. * * Results: * None. * * Side effects: * Information will eventually be redrawn on the screen. * *---------------------------------------------------------------------- */ func XTkTextRedrawRegion(tls *libc.TLS, textPtr uintptr, x int32, y int32, width int32, height int32) { bp := tls.Alloc(16) defer tls.Free(16) /* Width and height of area to be redrawn. */ var dInfoPtr uintptr var damageRgn TRegion var _ /* rect at bp+0 */ TXRectangle _, _ = dInfoPtr, damageRgn dInfoPtr = (*TTkText)(unsafe.Pointer(textPtr)).FdInfoPtr damageRgn = libx11.XXCreateRegion(tls) (*(*TXRectangle)(unsafe.Pointer(bp))).Fx = int16(x) (*(*TXRectangle)(unsafe.Pointer(bp))).Fy = int16(y) (*(*TXRectangle)(unsafe.Pointer(bp))).Fwidth = libc.Uint16FromInt32(width) (*(*TXRectangle)(unsafe.Pointer(bp))).Fheight = libc.Uint16FromInt32(height) libx11.XXUnionRectWithRegion(tls, bp, damageRgn, damageRgn) _TextInvalidateRegion(tls, textPtr, damageRgn) libx11.XXDestroyRegion(tls, damageRgn) /* * Schedule the redisplay operation if there isn't one already scheduled. */ if !((*TTextDInfo)(unsafe.Pointer(dInfoPtr)).Fflags&libc.Int32FromInt32(REDRAW_PENDING3) != 0) { *(*int32)(unsafe.Pointer(dInfoPtr + 220)) |= int32(REDRAW_PENDING3) libtcl9_0.XTcl_DoWhenIdle(tls, __ccgo_fp(_DisplayText), textPtr) } } /* *---------------------------------------------------------------------- * * TextInvalidateRegion -- * * Mark a region of text as invalid. * * Results: * None. * * Side effects: * Updates the display information for the text widget. * *---------------------------------------------------------------------- */ func _TextInvalidateRegion(tls *libc.TLS, textPtr uintptr, region TRegion) { bp := tls.Alloc(32) defer tls.Free(32) /* Region of area to redraw. */ var dInfoPtr, dlPtr uintptr var inset, maxY int32 var _ /* borderWidth at bp+16 */ int32 var _ /* highlightWidth at bp+20 */ int32 var _ /* padX at bp+8 */ int32 var _ /* padY at bp+12 */ int32 var _ /* rect at bp+0 */ TXRectangle _, _, _, _ = dInfoPtr, dlPtr, inset, maxY dInfoPtr = (*TTkText)(unsafe.Pointer(textPtr)).FdInfoPtr /* * Find all lines that overlap the given region and mark them for * redisplay. */ libx11.XXClipBox(tls, region, bp) maxY = int32((*(*TXRectangle)(unsafe.Pointer(bp))).Fy) + libc.Int32FromUint16((*(*TXRectangle)(unsafe.Pointer(bp))).Fheight) dlPtr = (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FdLinePtr for { if !(dlPtr != libc.UintptrFromInt32(0)) { break } if !((*TDLine)(unsafe.Pointer(dlPtr)).Fflags&libc.Int32FromInt32(OLD_Y_INVALID) != 0) && libx11.XXRectInRegion(tls, region, int32((*(*TXRectangle)(unsafe.Pointer(bp))).Fx), (*TDLine)(unsafe.Pointer(dlPtr)).Fy, uint32((*(*TXRectangle)(unsafe.Pointer(bp))).Fwidth), libc.Uint32FromInt32((*TDLine)(unsafe.Pointer(dlPtr)).Fheight)) != RectangleOut { *(*int32)(unsafe.Pointer(dlPtr + 112)) |= int32(OLD_Y_INVALID) } goto _1 _1: ; dlPtr = (*TDLine)(unsafe.Pointer(dlPtr)).FnextPtr } if (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FtopOfEof < maxY { (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FtopOfEof = maxY } XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), (*TTkText)(unsafe.Pointer(textPtr)).Ftkwin, (*TTkText)(unsafe.Pointer(textPtr)).FpadXObj, bp+8) XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), (*TTkText)(unsafe.Pointer(textPtr)).Ftkwin, (*TTkText)(unsafe.Pointer(textPtr)).FpadYObj, bp+12) XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), (*TTkText)(unsafe.Pointer(textPtr)).Ftkwin, (*TTkText)(unsafe.Pointer(textPtr)).FborderWidthObj, bp+16) XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), (*TTkText)(unsafe.Pointer(textPtr)).Ftkwin, (*TTkText)(unsafe.Pointer(textPtr)).FhighlightWidthObj, bp+20) inset = *(*int32)(unsafe.Pointer(bp + 16)) + *(*int32)(unsafe.Pointer(bp + 20)) if int32((*(*TXRectangle)(unsafe.Pointer(bp))).Fx) < inset+*(*int32)(unsafe.Pointer(bp + 8)) || int32((*(*TXRectangle)(unsafe.Pointer(bp))).Fy) < inset+*(*int32)(unsafe.Pointer(bp + 12)) || int32((*(*TXRectangle)(unsafe.Pointer(bp))).Fx)+libc.Int32FromUint16((*(*TXRectangle)(unsafe.Pointer(bp))).Fwidth) > (*TTk_FakeWin)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).Ftkwin)).Fchanges.Fwidth-inset-*(*int32)(unsafe.Pointer(bp + 8)) || maxY > (*TTk_FakeWin)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).Ftkwin)).Fchanges.Fheight-inset-*(*int32)(unsafe.Pointer(bp + 12)) { *(*int32)(unsafe.Pointer(dInfoPtr + 220)) |= int32(REDRAW_BORDERS1) } } /* *---------------------------------------------------------------------- * * TkTextChanged, TextChanged -- * * This function is invoked when info in a text widget is about to be * modified in a way that changes how it is displayed (e.g. characters * were inserted or deleted, or tag information was changed). This * function must be called *before* a change is made, so that indexes in * the display information are still valid. * * Note: if the range of indices may change geometry as well as simply * requiring redisplay, then the caller should also call * TkTextInvalidateLineMetrics. * * Results: * None. * * Side effects: * The range of character between index1Ptr (inclusive) and index2Ptr * (exclusive) will be redisplayed at some point in the future (the * actual redisplay is scheduled as a when-idle handler). * *---------------------------------------------------------------------- */ func XTkTextChanged(tls *libc.TLS, sharedTextPtr uintptr, textPtr uintptr, index1Ptr uintptr, index2Ptr uintptr) { /* Index of character just after last one to * redisplay. */ if sharedTextPtr == libc.UintptrFromInt32(0) { _TextChanged(tls, textPtr, index1Ptr, index2Ptr) } else { textPtr = (*TTkSharedText)(unsafe.Pointer(sharedTextPtr)).Fpeers for textPtr != libc.UintptrFromInt32(0) { _TextChanged(tls, textPtr, index1Ptr, index2Ptr) textPtr = (*TTkText)(unsafe.Pointer(textPtr)).Fnext } } } func _TextChanged(tls *libc.TLS, textPtr uintptr, index1Ptr uintptr, index2Ptr uintptr) { bp := tls.Alloc(32) defer tls.Free(32) /* Index of character just after last one to * redisplay. */ var dInfoPtr, firstPtr, lastPtr, linePtr uintptr var notBegin int32 var _ /* rounded at bp+0 */ TTkTextIndex _, _, _, _, _ = dInfoPtr, firstPtr, lastPtr, linePtr, notBegin dInfoPtr = (*TTkText)(unsafe.Pointer(textPtr)).FdInfoPtr /* * Schedule both a redisplay and a recomputation of display information. * It's done here rather than the end of the function for two reasons: * * 1. If there are no display lines to update we'll want to return * immediately, well before the end of the function. * 2. It's important to arrange for the redisplay BEFORE calling * FreeDLines. The reason for this is subtle and has to do with * embedded windows. The chunk delete function for an embedded window * will schedule an idle handler to unmap the window. However, we want * the idle handler for redisplay to be called first, so that it can * put the embedded window back on the screen again (if appropriate). * This will prevent the window from ever being unmapped, and thereby * avoid flashing. */ if !((*TTextDInfo)(unsafe.Pointer(dInfoPtr)).Fflags&libc.Int32FromInt32(REDRAW_PENDING3) != 0) { libtcl9_0.XTcl_DoWhenIdle(tls, __ccgo_fp(_DisplayText), textPtr) } *(*int32)(unsafe.Pointer(dInfoPtr + 220)) |= libc.Int32FromInt32(REDRAW_PENDING3) | libc.Int32FromInt32(DINFO_OUT_OF_DATE) | libc.Int32FromInt32(REPICK_NEEDED1) /* * Find the DLines corresponding to index1Ptr and index2Ptr. There is one * tricky thing here, which is that we have to relayout in units of whole * text lines: This is necessary because the indices stored in the display * lines will no longer be valid. It's also needed because any edit could * change the way lines wrap. * To relayout in units of whole text (logical) lines, round index1Ptr * back to the beginning of its text line (or, if this line start is * elided, to the beginning of the text line that starts the display line * it is included in), and include all the display lines after index2Ptr, * up to the end of its text line (or, if this line end is elided, up to * the end of the first non elided text line after this line end). */ *(*TTkTextIndex)(unsafe.Pointer(bp)) = *(*TTkTextIndex)(unsafe.Pointer(index1Ptr)) (*(*TTkTextIndex)(unsafe.Pointer(bp))).FbyteIndex = 0 notBegin = 0 for !(_IsStartOfNotMergedLine(tls, textPtr, bp) != 0) && notBegin != 0 { notBegin = libc.BoolInt32(!(XTkTextIndexBackBytes(tls, textPtr, bp, int64(1), bp) != 0)) (*(*TTkTextIndex)(unsafe.Pointer(bp))).FbyteIndex = 0 } /* * 'rounded' now points to the start of a display line as well as the * real (non elided) start of a logical line, and this index is the * closest before index1Ptr. */ firstPtr = _FindDLine(tls, textPtr, (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FdLinePtr, bp) if firstPtr == libc.UintptrFromInt32(0) { /* * index1Ptr pertains to no display line, i.e this index is after * the last display line. Since index2Ptr is after index1Ptr, there * is no display line to free/redisplay and we can return early. */ return } *(*TTkTextIndex)(unsafe.Pointer(bp)) = *(*TTkTextIndex)(unsafe.Pointer(index2Ptr)) linePtr = (*TTkTextIndex)(unsafe.Pointer(index2Ptr)).FlinePtr for cond := true; cond; cond = !(_IsStartOfNotMergedLine(tls, textPtr, bp) != 0) { linePtr = XTkBTreeNextLine(tls, textPtr, linePtr) if linePtr == libc.UintptrFromInt32(0) { break } (*(*TTkTextIndex)(unsafe.Pointer(bp))).FlinePtr = linePtr (*(*TTkTextIndex)(unsafe.Pointer(bp))).FbyteIndex = 0 } if linePtr == libc.UintptrFromInt32(0) { lastPtr = libc.UintptrFromInt32(0) } else { /* * 'rounded' now points to the start of a display line as well as the * start of a logical line not merged with its previous line, and * this index is the closest after index2Ptr. */ lastPtr = _FindDLine(tls, textPtr, (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FdLinePtr, bp) /* * At least one display line is supposed to change. This makes the * redisplay OK in case the display line we expect to get here was * unlinked by a previous call to TkTextChanged and the text widget * did not update before reaching this point. This happens for * instance when moving the cursor up one line. * Note that lastPtr != NULL here, otherwise we would have returned * earlier when we tested for firstPtr being NULL. */ if lastPtr == firstPtr { lastPtr = (*TDLine)(unsafe.Pointer(lastPtr)).FnextPtr } } /* * Delete all the DLines from firstPtr up to but not including lastPtr. */ _FreeDLines(tls, textPtr, firstPtr, lastPtr, int32(DLINE_UNLINK)) } /* *---------------------------------------------------------------------- * * TkTextRedrawTag, TextRedrawTag -- * * This function is invoked to request a redraw of all characters in a * given range that have a particular tag on or off. It's called, for * example, when tag options change. * * Results: * None. * * Side effects: * Information on the screen may be redrawn, and the layout of the screen * may change. * *---------------------------------------------------------------------- */ func XTkTextRedrawTag(tls *libc.TLS, sharedTextPtr uintptr, textPtr uintptr, index1Ptr uintptr, index2Ptr uintptr, tagPtr uintptr, withTag int32) { /* 1 means redraw characters that have the * tag, 0 means redraw those without. */ if sharedTextPtr == libc.UintptrFromInt32(0) { _TextRedrawTag(tls, textPtr, index1Ptr, index2Ptr, tagPtr, withTag) } else { textPtr = (*TTkSharedText)(unsafe.Pointer(sharedTextPtr)).Fpeers for textPtr != libc.UintptrFromInt32(0) { _TextRedrawTag(tls, textPtr, index1Ptr, index2Ptr, tagPtr, withTag) textPtr = (*TTkText)(unsafe.Pointer(textPtr)).Fnext } } } func _TextRedrawTag(tls *libc.TLS, textPtr uintptr, index1Ptr uintptr, index2Ptr uintptr, tagPtr uintptr, withTag int32) { bp := tls.Alloc(144) defer tls.Free(144) /* 1 means redraw characters that have the * tag, 0 means redraw those without. */ var curIndexPtr, dInfoPtr, dlPtr, endIndexPtr, endLine, endPtr, startLine uintptr var lastLine, lineCount, tagOn int32 var _ /* endOfText at bp+72 */ TTkTextIndex var _ /* search at bp+0 */ TTkTextSearch var _ /* tmp at bp+104 */ TTkTextIndex _, _, _, _, _, _, _, _, _, _ = curIndexPtr, dInfoPtr, dlPtr, endIndexPtr, endLine, endPtr, lastLine, lineCount, startLine, tagOn dInfoPtr = (*TTkText)(unsafe.Pointer(textPtr)).FdInfoPtr /* * Invalidate the pixel calculation of all lines in the given range. This * may be a bit over-aggressive, so we could consider more subtle * techniques here in the future. In particular, when we create a tag for * the first time with '.t tag configure foo -font "Arial 20"', say, even * though that obviously can't apply to anything at all (the tag didn't * exist a moment ago), we invalidate every single line in the widget. */ if (*TTkTextTag)(unsafe.Pointer(tagPtr)).FaffectsDisplayGeometry != 0 { if index2Ptr == libc.UintptrFromInt32(0) { endLine = libc.UintptrFromInt32(0) lineCount = XTkBTreeNumLines(tls, (*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).Ftree, textPtr) } else { endLine = (*TTkTextIndex)(unsafe.Pointer(index2Ptr)).FlinePtr lineCount = XTkBTreeLinesTo(tls, textPtr, endLine) } if index1Ptr == libc.UintptrFromInt32(0) { startLine = libc.UintptrFromInt32(0) } else { startLine = (*TTkTextIndex)(unsafe.Pointer(index1Ptr)).FlinePtr lineCount -= XTkBTreeLinesTo(tls, textPtr, startLine) } XTkTextInvalidateLineMetrics(tls, libc.UintptrFromInt32(0), textPtr, startLine, lineCount, int32(TK_TEXT_INVALIDATE_ONLY)) } /* * Round up the starting position if it's before the first line visible on * the screen (we only care about what's on the screen). */ dlPtr = (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FdLinePtr if dlPtr == libc.UintptrFromInt32(0) { return } if index1Ptr == libc.UintptrFromInt32(0) || XTkTextIndexCmp(tls, dlPtr, index1Ptr) > 0 { index1Ptr = dlPtr } /* * Set the stopping position if it wasn't specified. */ if index2Ptr == libc.UintptrFromInt32(0) { lastLine = XTkBTreeNumLines(tls, (*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).Ftree, textPtr) index2Ptr = XTkTextMakeByteIndex(tls, (*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).Ftree, textPtr, lastLine, 0, bp+72) } /* * Initialize a search through all transitions on the tag, starting with * the first transition where the tag's current state is different from * what it will eventually be. */ XTkBTreeStartSearch(tls, index1Ptr, index2Ptr, tagPtr, bp) /* * Make our own curIndex because at this point search.curIndex may not * equal index1Ptr->curIndex in the case the first tag toggle comes after * index1Ptr (See the use of FindTagStart in TkBTreeStartSearch). */ curIndexPtr = index1Ptr tagOn = XTkBTreeCharTagged(tls, index1Ptr, tagPtr) if tagOn != withTag { if !(XTkBTreeNextTag(tls, bp) != 0) { return } curIndexPtr = bp } /* * Schedule a redisplay and layout recalculation if they aren't already * pending. This has to be done before calling FreeDLines, for the reason * given in TkTextChanged. */ if !((*TTextDInfo)(unsafe.Pointer(dInfoPtr)).Fflags&libc.Int32FromInt32(REDRAW_PENDING3) != 0) { libtcl9_0.XTcl_DoWhenIdle(tls, __ccgo_fp(_DisplayText), textPtr) } *(*int32)(unsafe.Pointer(dInfoPtr + 220)) |= libc.Int32FromInt32(REDRAW_PENDING3) | libc.Int32FromInt32(DINFO_OUT_OF_DATE) | libc.Int32FromInt32(REPICK_NEEDED1) /* * Each loop through the loop below is for one range of characters where * the tag's current state is different than its eventual state. At the * top of the loop, search contains information about the first character * in the range. */ for int32(1) != 0 { /* * Find the first DLine structure in the range. Note: if the desired * character isn't the first in its text line, then look for the * character just before it instead. This is needed to handle the case * where the first character of a wrapped display line just got * smaller, so that it now fits on the line before: need to relayout * the line containing the previous character. */ if _IsStartOfNotMergedLine(tls, textPtr, curIndexPtr) != 0 { dlPtr = _FindDLine(tls, textPtr, dlPtr, curIndexPtr) } else { *(*TTkTextIndex)(unsafe.Pointer(bp + 104)) = *(*TTkTextIndex)(unsafe.Pointer(curIndexPtr)) XTkTextIndexBackBytes(tls, textPtr, bp+104, int64(1), bp+104) dlPtr = _FindDLine(tls, textPtr, dlPtr, bp+104) } if dlPtr == libc.UintptrFromInt32(0) { break } /* * Find the first DLine structure that's past the end of the range. */ if !(XTkBTreeNextTag(tls, bp) != 0) { endIndexPtr = index2Ptr } else { curIndexPtr = bp endIndexPtr = curIndexPtr } endPtr = _FindDLine(tls, textPtr, dlPtr, endIndexPtr) if endPtr != libc.UintptrFromInt32(0) && XTkTextIndexCmp(tls, endPtr, endIndexPtr) < 0 { endPtr = (*TDLine)(unsafe.Pointer(endPtr)).FnextPtr } /* * Delete all of the display lines in the range, so that they'll be * re-layed out and redrawn. */ _FreeDLines(tls, textPtr, dlPtr, endPtr, int32(DLINE_UNLINK)) dlPtr = endPtr /* * Find the first text line in the next range. */ if !(XTkBTreeNextTag(tls, bp) != 0) { break } } } /* *---------------------------------------------------------------------- * * TkTextRelayoutWindow -- * * This function is called when something has happened that invalidates * the whole layout of characters on the screen, such as a change in a * configuration option for the overall text widget or a change in the * window size. It causes all display information to be recomputed and * the window to be redrawn. * * Results: * None. * * Side effects: * All the display information will be recomputed for the window and the * window will be redrawn. * *---------------------------------------------------------------------- */ func XTkTextRelayoutWindow(tls *libc.TLS, textPtr uintptr, mask int32) { bp := tls.Alloc(144) defer tls.Free(144) /* OR'd collection of bits showing what has * changed. */ var _objPtr, dInfoPtr, v2, v6 uintptr var inSync, v5 int32 var newGC TGC var v1 TTcl_Size var v3, v4 float64 var _ /* borderWidth at bp+136 */ int32 var _ /* gcValues at bp+0 */ TXGCValues var _ /* highlightWidth at bp+140 */ int32 var _ /* padX at bp+128 */ int32 var _ /* padY at bp+132 */ int32 _, _, _, _, _, _, _, _, _, _ = _objPtr, dInfoPtr, inSync, newGC, v1, v2, v3, v4, v5, v6 dInfoPtr = (*TTkText)(unsafe.Pointer(textPtr)).FdInfoPtr inSync = int32(1) /* * Schedule the window redisplay. See TkTextChanged for the reason why * this has to be done before any calls to FreeDLines. */ if !((*TTextDInfo)(unsafe.Pointer(dInfoPtr)).Fflags&libc.Int32FromInt32(REDRAW_PENDING3) != 0) { libtcl9_0.XTcl_DoWhenIdle(tls, __ccgo_fp(_DisplayText), textPtr) inSync = 0 } *(*int32)(unsafe.Pointer(dInfoPtr + 220)) |= libc.Int32FromInt32(REDRAW_PENDING3) | libc.Int32FromInt32(REDRAW_BORDERS1) | libc.Int32FromInt32(DINFO_OUT_OF_DATE) | libc.Int32FromInt32(REPICK_NEEDED1) /* * (Re-)create the graphics context for drawing the traversal highlight. */ (*(*TXGCValues)(unsafe.Pointer(bp))).Fgraphics_exposures = False newGC = XTk_GetGC(tls, (*TTkText)(unsafe.Pointer(textPtr)).Ftkwin, libc.Uint64FromInt64(libc.Int64FromInt64(1)<maxY is set. */ (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FmaxY = (*TTk_FakeWin)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).Ftkwin)).Fchanges.Fheight - *(*int32)(unsafe.Pointer(bp + 140)) - *(*int32)(unsafe.Pointer(bp + 136)) - *(*int32)(unsafe.Pointer(bp + 132)) if (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FmaxY <= (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).Fy { (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FmaxY = (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).Fy + int32(1) } (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FtopOfEof = (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FmaxY /* * If the upper-left character isn't the first in a line, recompute it. * This is necessary because a change in the window's size or options * could change the way lines wrap. */ if !(_IsStartOfNotMergedLine(tls, textPtr, textPtr+256) != 0) { XTkTextFindDisplayLineEnd(tls, textPtr, textPtr+256, 0, libc.UintptrFromInt32(0)) } /* * Invalidate cached scrollbar positions, so that scrollbars sliders will * be updated. */ v3 = float64(-libc.Int32FromInt32(1)) (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FxScrollLast = v3 (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FxScrollFirst = v3 v4 = float64(-libc.Int32FromInt32(1)) (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FyScrollLast = v4 (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FyScrollFirst = v4 if mask&(libc.Int32FromInt32(1)< (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FmaxY { /* * Part of the line hangs off the bottom of the screen; pretend * the whole line is off-screen. */ dlPtr = libc.UintptrFromInt32(0) } else { if XTkTextIndexCmp(tls, dlPtr, indexPtr) <= 0 { if (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FdLinePtr == dlPtr && (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FtopPixelOffset != 0 { /* * It is on the top line, but that line is hanging off the top * of the screen. Change the top overlap to zero and update. */ (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FnewTopPixelOffset = 0 goto scheduleUpdate } /* * The line is already on screen, with no need to scroll. */ return } } } /* * The desired line isn't already on-screen. Figure out what it means to * be "close" to the top or bottom of the screen. Close means within 1/3 * of the screen height or within three lines, whichever is greater. * * If the line is not close, place it in the center of the window. */ *(*TTkTextIndex)(unsafe.Pointer(bp)) = *(*TTkTextIndex)(unsafe.Pointer(indexPtr)) XTkTextFindDisplayLineEnd(tls, textPtr, bp, 0, libc.UintptrFromInt32(0)) lineHeight = _CalculateDisplayLineHeight(tls, textPtr, bp, libc.UintptrFromInt32(0), libc.UintptrFromInt32(0)) /* * It would be better if 'bottomY' were calculated using the actual height * of the given line, not 'textPtr->charHeight'. */ bottomY = ((*TTextDInfo)(unsafe.Pointer(dInfoPtr)).Fy + (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FmaxY + lineHeight) / int32(2) close1 = ((*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FmaxY - (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).Fy) / int32(3) if close1 < int32(3)*(*TTkText)(unsafe.Pointer(textPtr)).FcharHeight { close1 = int32(3) * (*TTkText)(unsafe.Pointer(textPtr)).FcharHeight } if dlPtr != libc.UintptrFromInt32(0) { /* * The desired line is above the top of screen. If it is "close" to * the top of the window then make it the top line on the screen. * MeasureUp counts from the bottom of the given index upwards, so we * add an extra half line to be sure we count far enough. */ _MeasureUp(tls, textPtr, textPtr+256, close1+(*TTkText)(unsafe.Pointer(textPtr)).FcharHeight/int32(2), bp, bp+64) if XTkTextIndexCmp(tls, bp, indexPtr) <= 0 { (*TTkText)(unsafe.Pointer(textPtr)).FtopIndex = *(*TTkTextIndex)(unsafe.Pointer(indexPtr)) XTkTextFindDisplayLineEnd(tls, textPtr, textPtr+256, 0, libc.UintptrFromInt32(0)) (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FnewTopPixelOffset = 0 goto scheduleUpdate } } else { /* * The desired line is below the bottom of the screen. If it is * "close" to the bottom of the screen then position it at the bottom * of the screen. */ _MeasureUp(tls, textPtr, indexPtr, close1+lineHeight-(*TTkText)(unsafe.Pointer(textPtr)).FcharHeight/int32(2), bp, bp+68) if _FindDLine(tls, textPtr, (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FdLinePtr, bp) != libc.UintptrFromInt32(0) { bottomY = (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FmaxY - (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).Fy } } /* * If the window height is smaller than the line height, prefer to make * the top of the line visible. */ if (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FmaxY-(*TTextDInfo)(unsafe.Pointer(dInfoPtr)).Fy < lineHeight { bottomY = lineHeight } /* * Our job now is to arrange the display so that indexPtr appears as low * on the screen as possible but with its bottom no lower than bottomY. * BottomY is the bottom of the window if the desired line is just below * the current screen, otherwise it is a half-line lower than the center * of the window. */ _MeasureUp(tls, textPtr, indexPtr, bottomY, textPtr+256, dInfoPtr+116) goto scheduleUpdate scheduleUpdate: ; if !((*TTextDInfo)(unsafe.Pointer(dInfoPtr)).Fflags&libc.Int32FromInt32(REDRAW_PENDING3) != 0) { libtcl9_0.XTcl_DoWhenIdle(tls, __ccgo_fp(_DisplayText), textPtr) } *(*int32)(unsafe.Pointer(dInfoPtr + 220)) |= libc.Int32FromInt32(REDRAW_PENDING3) | libc.Int32FromInt32(DINFO_OUT_OF_DATE) | libc.Int32FromInt32(REPICK_NEEDED1) } /* *-------------------------------------------------------------- * * TkTextMeasureDown -- * * Given one index, find the index of the first character on the highest * display line that would be displayed no more than "distance" pixels * below the top of the given index. * * Results: * The srcPtr is manipulated in place to reflect the new position. We * return the number of pixels by which 'distance' overlaps the srcPtr. * * Side effects: * None. * *-------------------------------------------------------------- */ func XTkTextMeasureDown(tls *libc.TLS, textPtr uintptr, srcPtr uintptr, distance int32) (r int32) { bp := tls.Alloc(32) defer tls.Free(32) /* Vertical distance in pixels measured from * the top pixel in srcPtr's logical line. */ var dlPtr, lastLinePtr uintptr var _ /* loop at bp+0 */ TTkTextIndex _, _ = dlPtr, lastLinePtr lastLinePtr = XTkBTreeFindLine(tls, (*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).Ftree, textPtr, XTkBTreeNumLines(tls, (*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).Ftree, textPtr)) for cond := true; cond; cond = distance > 0 { dlPtr = _LayoutDLine(tls, textPtr, srcPtr) (*TDLine)(unsafe.Pointer(dlPtr)).FnextPtr = libc.UintptrFromInt32(0) if distance < (*TDLine)(unsafe.Pointer(dlPtr)).Fheight { _FreeDLines(tls, textPtr, dlPtr, libc.UintptrFromInt32(0), int32(DLINE_FREE_TEMP)) break } distance -= (*TDLine)(unsafe.Pointer(dlPtr)).Fheight XTkTextIndexForwBytes(tls, textPtr, srcPtr, int64((*TDLine)(unsafe.Pointer(dlPtr)).FbyteCount), bp) _FreeDLines(tls, textPtr, dlPtr, libc.UintptrFromInt32(0), int32(DLINE_FREE_TEMP)) if (*(*TTkTextIndex)(unsafe.Pointer(bp))).FlinePtr == lastLinePtr { break } *(*TTkTextIndex)(unsafe.Pointer(srcPtr)) = *(*TTkTextIndex)(unsafe.Pointer(bp)) } return distance } /* *-------------------------------------------------------------- * * MeasureUp -- * * Given one index, find the index of the first character on the highest * display line that would be displayed no more than "distance" pixels * above the given index. * * If this function is called with distance=0, it simply finds the first * index on the same display line as srcPtr. However, there is a another * function TkTextFindDisplayLineEnd designed just for that task which is * probably better to use. * * Results: * *dstPtr is filled in with the index of the first character on a * display line. The display line is found by measuring up "distance" * pixels above the pixel just below an imaginary display line that * contains srcPtr. If the display line that covers this coordinate * actually extends above the coordinate, then return any excess pixels * in *overlap, if that is non-NULL. * * Side effects: * None. * *-------------------------------------------------------------- */ func _MeasureUp(tls *libc.TLS, textPtr uintptr, srcPtr uintptr, distance int32, dstPtr uintptr, overlap uintptr) { bp := tls.Alloc(32) defer tls.Free(32) /* Used to store how much of the final index * returned was not covered by 'distance'. */ var bytesToCount, lineNum int32 var dlPtr, lowestPtr uintptr var _ /* index at bp+0 */ TTkTextIndex _, _, _, _ = bytesToCount, dlPtr, lineNum, lowestPtr bytesToCount = int32((*TTkTextIndex)(unsafe.Pointer(srcPtr)).FbyteIndex + int64(1)) (*(*TTkTextIndex)(unsafe.Pointer(bp))).Ftree = (*TTkTextIndex)(unsafe.Pointer(srcPtr)).Ftree lineNum = XTkBTreeLinesTo(tls, textPtr, (*TTkTextIndex)(unsafe.Pointer(srcPtr)).FlinePtr) for { if !(lineNum >= 0) { break } /* * Layout an entire text line (potentially > 1 display line). * * For the first line, which contains srcPtr, only layout the part up * through srcPtr (bytesToCount is non-infinite to accomplish this). * Make a list of all the display lines in backwards order (the lowest * DLine on the screen is first in the list). */ (*(*TTkTextIndex)(unsafe.Pointer(bp))).FlinePtr = XTkBTreeFindLine(tls, (*TTkTextIndex)(unsafe.Pointer(srcPtr)).Ftree, textPtr, lineNum) (*(*TTkTextIndex)(unsafe.Pointer(bp))).FbyteIndex = 0 XTkTextFindDisplayLineEnd(tls, textPtr, bp, 0, libc.UintptrFromInt32(0)) lineNum = XTkBTreeLinesTo(tls, textPtr, (*(*TTkTextIndex)(unsafe.Pointer(bp))).FlinePtr) lowestPtr = libc.UintptrFromInt32(0) for cond := true; cond; cond = bytesToCount > 0 && (*(*TTkTextIndex)(unsafe.Pointer(bp))).FlinePtr == (*TDLine)(unsafe.Pointer(dlPtr)).Findex.FlinePtr { dlPtr = _LayoutDLine(tls, textPtr, bp) (*TDLine)(unsafe.Pointer(dlPtr)).FnextPtr = lowestPtr lowestPtr = dlPtr XTkTextIndexForwBytes(tls, textPtr, bp, int64((*TDLine)(unsafe.Pointer(dlPtr)).FbyteCount), bp) bytesToCount -= (*TDLine)(unsafe.Pointer(dlPtr)).FbyteCount } /* * Scan through the display lines to see if we've covered enough * vertical distance. If so, save the starting index for the line at * the desired location. If distance was zero to start with then we * simply get the first index on the same display line as the original * index. */ dlPtr = lowestPtr for { if !(dlPtr != libc.UintptrFromInt32(0)) { break } distance -= (*TDLine)(unsafe.Pointer(dlPtr)).Fheight if distance <= 0 { *(*TTkTextIndex)(unsafe.Pointer(dstPtr)) = (*TDLine)(unsafe.Pointer(dlPtr)).Findex /* * dstPtr is the start of a display line that is or is not * the start of a logical line. If it is the start of a * logical line, we must check whether this line is merged * with the previous logical line, and if so we must adjust * dstPtr to the start of the display line since a display * line start needs to be returned. */ if !(_IsStartOfNotMergedLine(tls, textPtr, dstPtr) != 0) { XTkTextFindDisplayLineEnd(tls, textPtr, dstPtr, 0, libc.UintptrFromInt32(0)) } if overlap != libc.UintptrFromInt32(0) { *(*int32)(unsafe.Pointer(overlap)) = -distance } break } goto _2 _2: ; dlPtr = (*TDLine)(unsafe.Pointer(dlPtr)).FnextPtr } /* * Discard the display lines, then either return or prepare for the * next display line to lay out. */ _FreeDLines(tls, textPtr, lowestPtr, libc.UintptrFromInt32(0), DLINE_FREE) if distance <= 0 { return } bytesToCount = int32(INT_MAX) /* Consider all chars. in next line. */ goto _1 _1: ; lineNum-- } /* * Ran off the beginning of the text. Return the first character in the * text. */ XTkTextMakeByteIndex(tls, (*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).Ftree, textPtr, 0, 0, dstPtr) if overlap != libc.UintptrFromInt32(0) { *(*int32)(unsafe.Pointer(overlap)) = 0 } } /* *-------------------------------------------------------------- * * TkTextSeeCmd -- * * This function is invoked to process the "see" option for the widget * command for text widgets. See the user documentation for details on * what it does. * * Results: * A standard Tcl result. * * Side effects: * See the user documentation. * *-------------------------------------------------------------- */ func XTkTextSeeCmd(tls *libc.TLS, textPtr uintptr, interp uintptr, objc TTcl_Size, objv uintptr) (r int32) { bp := tls.Alloc(48) defer tls.Free(48) /* Argument objects. Someone else has already * parsed this command enough to know that * objv[1] is "see". */ var byteCount, delta, lineWidth, oneThird int32 var chunkPtr, dInfoPtr, dlPtr uintptr var _ /* height at bp+44 */ int32 var _ /* index at bp+0 */ TTkTextIndex var _ /* width at bp+40 */ int32 var _ /* x at bp+32 */ int32 var _ /* y at bp+36 */ int32 _, _, _, _, _, _, _ = byteCount, chunkPtr, dInfoPtr, delta, dlPtr, lineWidth, oneThird dInfoPtr = (*TTkText)(unsafe.Pointer(textPtr)).FdInfoPtr if objc != int64(3) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(2), objv, __ccgo_ts+22152) return int32(TCL_ERROR) } if XTkTextGetObjIndex(tls, interp, textPtr, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp) != TCL_OK { return int32(TCL_ERROR) } /* * If the specified position is the extra line at the end of the text, * round it back to the last real line. */ if XTkBTreeLinesTo(tls, textPtr, (*(*TTkTextIndex)(unsafe.Pointer(bp))).FlinePtr) == XTkBTreeNumLines(tls, (*(*TTkTextIndex)(unsafe.Pointer(bp))).Ftree, textPtr) { XTkTextIndexBackChars(tls, textPtr, bp, int32(1), bp, int32(COUNT_INDICES)) } /* * First get the desired position into the vertical range of the window. */ XTkTextSetYView(tls, textPtr, bp, -int32(1)) /* * Now make sure that the character is in view horizontally. */ if (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).Fflags&int32(DINFO_OUT_OF_DATE) != 0 { _UpdateDisplayInfo(tls, textPtr) } lineWidth = (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FmaxX - (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).Fx if (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FmaxLength < lineWidth { return TCL_OK } /* * Find the display line containing the desired index. dlPtr may be NULL * if the widget is not mapped. [Bug #641778] */ dlPtr = _FindDLine(tls, textPtr, (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FdLinePtr, bp) if dlPtr == libc.UintptrFromInt32(0) { return TCL_OK } /* * Find the chunk within the display line that contains the desired * index. The chunks making the display line are skipped up to but not * including the one crossing index. Skipping is done based on a * byteCount offset possibly spanning several logical lines in case * they are elided. */ byteCount = XTkTextIndexCountBytes(tls, textPtr, dlPtr, bp) chunkPtr = (*TDLine)(unsafe.Pointer(dlPtr)).FchunkPtr for { if !(chunkPtr != libc.UintptrFromInt32(0)) { break } if int64(byteCount) < (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FnumBytes { break } byteCount = int32(int64(byteCount) - (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FnumBytes) goto _1 _1: ; chunkPtr = (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FnextPtr } /* * Call a chunk-specific function to find the horizontal range of the * character within the chunk. chunkPtr is NULL if trying to see in elided * region. */ if chunkPtr != libc.UintptrFromInt32(0) { (*(*func(*libc.TLS, uintptr, uintptr, TTcl_Size, int32, int32, int32, uintptr, uintptr, uintptr, uintptr))(unsafe.Pointer(&struct{ uintptr }{(*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FbboxProc})))(tls, textPtr, chunkPtr, int64(byteCount), (*TDLine)(unsafe.Pointer(dlPtr)).Fy+(*TDLine)(unsafe.Pointer(dlPtr)).FspaceAbove, (*TDLine)(unsafe.Pointer(dlPtr)).Fheight-(*TDLine)(unsafe.Pointer(dlPtr)).FspaceAbove-(*TDLine)(unsafe.Pointer(dlPtr)).FspaceBelow, (*TDLine)(unsafe.Pointer(dlPtr)).Fbaseline-(*TDLine)(unsafe.Pointer(dlPtr)).FspaceAbove, bp+32, bp+36, bp+40, bp+44) delta = *(*int32)(unsafe.Pointer(bp + 32)) - (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FcurXPixelOffset oneThird = lineWidth / int32(3) if delta < 0 { if delta < -oneThird { (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FnewXPixelOffset = *(*int32)(unsafe.Pointer(bp + 32)) - lineWidth/int32(2) } else { *(*int32)(unsafe.Pointer(dInfoPtr + 156)) += delta } } else { delta -= lineWidth - *(*int32)(unsafe.Pointer(bp + 40)) if delta <= 0 { return TCL_OK } if delta > oneThird { (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FnewXPixelOffset = *(*int32)(unsafe.Pointer(bp + 32)) - lineWidth/int32(2) } else { *(*int32)(unsafe.Pointer(dInfoPtr + 156)) += delta } } } *(*int32)(unsafe.Pointer(dInfoPtr + 220)) |= int32(DINFO_OUT_OF_DATE) if !((*TTextDInfo)(unsafe.Pointer(dInfoPtr)).Fflags&libc.Int32FromInt32(REDRAW_PENDING3) != 0) { *(*int32)(unsafe.Pointer(dInfoPtr + 220)) |= int32(REDRAW_PENDING3) libtcl9_0.XTcl_DoWhenIdle(tls, __ccgo_fp(_DisplayText), textPtr) } return TCL_OK } /* *-------------------------------------------------------------- * * TkTextXviewCmd -- * * This function is invoked to process the "xview" option for the widget * command for text widgets. See the user documentation for details on * what it does. * * Results: * A standard Tcl result. * * Side effects: * See the user documentation. * *-------------------------------------------------------------- */ func XTkTextXviewCmd(tls *libc.TLS, textPtr uintptr, interp uintptr, objc TTcl_Size, objv uintptr) (r int32) { bp := tls.Alloc(16) defer tls.Free(16) /* Argument objects. Someone else has already * parsed this command enough to know that * objv[1] is "xview". */ var dInfoPtr uintptr var pixelsPerPage, type1 int32 var _ /* count at bp+0 */ int32 var _ /* fraction at bp+8 */ float64 _, _, _ = dInfoPtr, pixelsPerPage, type1 dInfoPtr = (*TTkText)(unsafe.Pointer(textPtr)).FdInfoPtr if (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).Fflags&int32(DINFO_OUT_OF_DATE) != 0 { _UpdateDisplayInfo(tls, textPtr) } if objc == int64(2) { _GetXView(tls, interp, textPtr, 0) return TCL_OK } type1 = _TextGetScrollInfoObj(tls, interp, textPtr, objc, objv, bp+8, bp) switch type1 { case int32(TKTEXT_SCROLL_ERROR): return int32(TCL_ERROR) case int32(TKTEXT_SCROLL_MOVETO): if *(*float64)(unsafe.Pointer(bp + 8)) > float64(1) { *(*float64)(unsafe.Pointer(bp + 8)) = float64(1) } if *(*float64)(unsafe.Pointer(bp + 8)) < libc.Float64FromInt32(0) { *(*float64)(unsafe.Pointer(bp + 8)) = libc.Float64FromInt32(0) } (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FnewXPixelOffset = int32(float64(*(*float64)(unsafe.Pointer(bp + 8))*float64((*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FmaxLength)) + libc.Float64FromFloat64(0.5)) case int32(TKTEXT_SCROLL_PAGES): pixelsPerPage = (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FmaxX - (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).Fx - int32(2)*(*TTkText)(unsafe.Pointer(textPtr)).FcharWidth if pixelsPerPage < int32(1) { pixelsPerPage = int32(1) } *(*int32)(unsafe.Pointer(dInfoPtr + 156)) += pixelsPerPage * *(*int32)(unsafe.Pointer(bp)) case int32(TKTEXT_SCROLL_UNITS): *(*int32)(unsafe.Pointer(dInfoPtr + 156)) += *(*int32)(unsafe.Pointer(bp)) * (*TTkText)(unsafe.Pointer(textPtr)).FcharWidth case int32(TKTEXT_SCROLL_PIXELS): *(*int32)(unsafe.Pointer(dInfoPtr + 156)) += *(*int32)(unsafe.Pointer(bp)) break } *(*int32)(unsafe.Pointer(dInfoPtr + 220)) |= int32(DINFO_OUT_OF_DATE) if !((*TTextDInfo)(unsafe.Pointer(dInfoPtr)).Fflags&libc.Int32FromInt32(REDRAW_PENDING3) != 0) { *(*int32)(unsafe.Pointer(dInfoPtr + 220)) |= int32(REDRAW_PENDING3) libtcl9_0.XTcl_DoWhenIdle(tls, __ccgo_fp(_DisplayText), textPtr) } return TCL_OK } /* *---------------------------------------------------------------------- * * YScrollByPixels -- * * This function is called to scroll a text widget up or down by a given * number of pixels. * * Results: * None. * * Side effects: * The view in textPtr's window changes to reflect the value of "offset". * *---------------------------------------------------------------------- */ func _YScrollByPixels(tls *libc.TLS, textPtr uintptr, offset int32) { bp := tls.Alloc(32) defer tls.Free(32) /* Amount by which to scroll, in pixels. * Positive means that information later in * text becomes visible, negative means that * information earlier in the text becomes * visible. */ var dInfoPtr, dlPtr, lastLinePtr uintptr var _ /* newIdx at bp+0 */ TTkTextIndex _, _, _ = dInfoPtr, dlPtr, lastLinePtr dInfoPtr = (*TTkText)(unsafe.Pointer(textPtr)).FdInfoPtr if offset < 0 { /* * Now we want to measure up this number of pixels from the top of the * screen. But the top line may not be totally visible. Note that * 'count' is negative here. */ offset -= _CalculateDisplayLineHeight(tls, textPtr, textPtr+256, libc.UintptrFromInt32(0), libc.UintptrFromInt32(0)) - (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FtopPixelOffset _MeasureUp(tls, textPtr, textPtr+256, -offset, textPtr+256, dInfoPtr+116) } else { if offset > 0 { /* * Scrolling down by pixels. Layout lines starting at the top index * and count through the desired vertical distance. */ lastLinePtr = XTkBTreeFindLine(tls, (*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).Ftree, textPtr, XTkBTreeNumLines(tls, (*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).Ftree, textPtr)) offset += (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FtopPixelOffset (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FnewTopPixelOffset = 0 for offset > 0 { dlPtr = _LayoutDLine(tls, textPtr, textPtr+256) (*TDLine)(unsafe.Pointer(dlPtr)).FnextPtr = libc.UintptrFromInt32(0) XTkTextIndexForwBytes(tls, textPtr, textPtr+256, int64((*TDLine)(unsafe.Pointer(dlPtr)).FbyteCount), bp) if offset <= (*TDLine)(unsafe.Pointer(dlPtr)).Fheight { /* * Adjust the top overlap accordingly. */ (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FnewTopPixelOffset = offset } offset -= (*TDLine)(unsafe.Pointer(dlPtr)).Fheight _FreeDLines(tls, textPtr, dlPtr, libc.UintptrFromInt32(0), int32(DLINE_FREE_TEMP)) if (*(*TTkTextIndex)(unsafe.Pointer(bp))).FlinePtr == lastLinePtr || offset <= 0 { break } (*TTkText)(unsafe.Pointer(textPtr)).FtopIndex = *(*TTkTextIndex)(unsafe.Pointer(bp)) } } else { /* * offset = 0, so no scrolling required. */ return } } if !((*TTextDInfo)(unsafe.Pointer(dInfoPtr)).Fflags&libc.Int32FromInt32(REDRAW_PENDING3) != 0) { libtcl9_0.XTcl_DoWhenIdle(tls, __ccgo_fp(_DisplayText), textPtr) } *(*int32)(unsafe.Pointer(dInfoPtr + 220)) |= libc.Int32FromInt32(REDRAW_PENDING3) | libc.Int32FromInt32(DINFO_OUT_OF_DATE) | libc.Int32FromInt32(REPICK_NEEDED1) } /* *---------------------------------------------------------------------- * * YScrollByLines -- * * This function is called to scroll a text widget up or down by a given * number of lines. * * Results: * None. * * Side effects: * The view in textPtr's window changes to reflect the value of "offset". * *---------------------------------------------------------------------- */ func _YScrollByLines(tls *libc.TLS, textPtr uintptr, offset int32) { bp := tls.Alloc(64) defer tls.Free(64) /* Amount by which to scroll, in display * lines. Positive means that information * later in text becomes visible, negative * means that information earlier in the text * becomes visible. */ var bytesToCount, i, lineNum int32 var dInfoPtr, dlPtr, lastLinePtr, lowestPtr uintptr var _ /* index at bp+32 */ TTkTextIndex var _ /* newIdx at bp+0 */ TTkTextIndex _, _, _, _, _, _, _ = bytesToCount, dInfoPtr, dlPtr, i, lastLinePtr, lineNum, lowestPtr dInfoPtr = (*TTkText)(unsafe.Pointer(textPtr)).FdInfoPtr if offset < 0 { /* * Must scroll up (to show earlier information in the text). The code * below is similar to that in MeasureUp, except that it counts lines * instead of pixels. */ bytesToCount = int32((*TTkText)(unsafe.Pointer(textPtr)).FtopIndex.FbyteIndex + int64(1)) (*(*TTkTextIndex)(unsafe.Pointer(bp + 32))).Ftree = (*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).Ftree offset-- /* Skip line containing topIndex. */ lineNum = XTkBTreeLinesTo(tls, textPtr, (*TTkText)(unsafe.Pointer(textPtr)).FtopIndex.FlinePtr) for { if !(lineNum >= 0) { break } (*(*TTkTextIndex)(unsafe.Pointer(bp + 32))).FlinePtr = XTkBTreeFindLine(tls, (*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).Ftree, textPtr, lineNum) (*(*TTkTextIndex)(unsafe.Pointer(bp + 32))).FbyteIndex = 0 lowestPtr = libc.UintptrFromInt32(0) for cond := true; cond; cond = bytesToCount > 0 && (*(*TTkTextIndex)(unsafe.Pointer(bp + 32))).FlinePtr == (*TDLine)(unsafe.Pointer(dlPtr)).Findex.FlinePtr { dlPtr = _LayoutDLine(tls, textPtr, bp+32) (*TDLine)(unsafe.Pointer(dlPtr)).FnextPtr = lowestPtr lowestPtr = dlPtr XTkTextIndexForwBytes(tls, textPtr, bp+32, int64((*TDLine)(unsafe.Pointer(dlPtr)).FbyteCount), bp+32) bytesToCount -= (*TDLine)(unsafe.Pointer(dlPtr)).FbyteCount } dlPtr = lowestPtr for { if !(dlPtr != libc.UintptrFromInt32(0)) { break } offset++ if offset == 0 { (*TTkText)(unsafe.Pointer(textPtr)).FtopIndex = (*TDLine)(unsafe.Pointer(dlPtr)).Findex /* * topIndex is the start of a logical line. However, if * the eol of the previous logical line is elided, then * topIndex may be elsewhere than the first character of * a display line, which is unwanted. Adjust to the start * of the display line, if needed. * topIndex is the start of a display line that is or is * not the start of a logical line. If it is the start of * a logical line, we must check whether this line is * merged with the previous logical line, and if so we * must adjust topIndex to the start of the display line. */ if !(_IsStartOfNotMergedLine(tls, textPtr, textPtr+256) != 0) { XTkTextFindDisplayLineEnd(tls, textPtr, textPtr+256, 0, libc.UintptrFromInt32(0)) } break } goto _2 _2: ; dlPtr = (*TDLine)(unsafe.Pointer(dlPtr)).FnextPtr } /* * Discard the display lines, then either return or prepare for * the next display line to lay out. */ _FreeDLines(tls, textPtr, lowestPtr, libc.UintptrFromInt32(0), DLINE_FREE) if offset >= 0 { goto scheduleUpdate } bytesToCount = int32(INT_MAX) goto _1 _1: ; lineNum-- } /* * Ran off the beginning of the text. Return the first character in * the text, and make sure we haven't left anything overlapping the * top window border. */ XTkTextMakeByteIndex(tls, (*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).Ftree, textPtr, 0, 0, textPtr+256) (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FnewTopPixelOffset = 0 } else { /* * Scrolling down, to show later information in the text. Just count * lines from the current top of the window. */ lastLinePtr = XTkBTreeFindLine(tls, (*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).Ftree, textPtr, XTkBTreeNumLines(tls, (*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).Ftree, textPtr)) i = 0 for { if !(i < offset) { break } dlPtr = _LayoutDLine(tls, textPtr, textPtr+256) if (*TDLine)(unsafe.Pointer(dlPtr)).Flength == 0 && (*TDLine)(unsafe.Pointer(dlPtr)).Fheight == 0 { offset++ } (*TDLine)(unsafe.Pointer(dlPtr)).FnextPtr = libc.UintptrFromInt32(0) XTkTextIndexForwBytes(tls, textPtr, textPtr+256, int64((*TDLine)(unsafe.Pointer(dlPtr)).FbyteCount), bp) _FreeDLines(tls, textPtr, dlPtr, libc.UintptrFromInt32(0), DLINE_FREE) if (*(*TTkTextIndex)(unsafe.Pointer(bp))).FlinePtr == lastLinePtr { break } (*TTkText)(unsafe.Pointer(textPtr)).FtopIndex = *(*TTkTextIndex)(unsafe.Pointer(bp)) goto _3 _3: ; i++ } } goto scheduleUpdate scheduleUpdate: ; if !((*TTextDInfo)(unsafe.Pointer(dInfoPtr)).Fflags&libc.Int32FromInt32(REDRAW_PENDING3) != 0) { libtcl9_0.XTcl_DoWhenIdle(tls, __ccgo_fp(_DisplayText), textPtr) } *(*int32)(unsafe.Pointer(dInfoPtr + 220)) |= libc.Int32FromInt32(REDRAW_PENDING3) | libc.Int32FromInt32(DINFO_OUT_OF_DATE) | libc.Int32FromInt32(REPICK_NEEDED1) } /* *-------------------------------------------------------------- * * TkTextYviewCmd -- * * This function is invoked to process the "yview" option for the widget * command for text widgets. See the user documentation for details on * what it does. * * Results: * A standard Tcl result. * * Side effects: * See the user documentation. * *-------------------------------------------------------------- */ func XTkTextYviewCmd(tls *libc.TLS, textPtr uintptr, interp uintptr, objc TTcl_Size, objv uintptr) (r int32) { bp := tls.Alloc(64) defer tls.Free(64) /* Argument objects. Someone else has already * parsed this command enough to know that * objv[1] is "yview". */ var dInfoPtr, switchStr uintptr var height, numPixels, pickPlace, pixels, topMostPixel, type1, v1 int32 var _ /* count at bp+0 */ int32 var _ /* fraction at bp+16 */ float64 var _ /* index at bp+24 */ TTkTextIndex var _ /* lineNum at bp+56 */ int32 var _ /* switchLength at bp+8 */ TTcl_Size _, _, _, _, _, _, _, _, _ = dInfoPtr, height, numPixels, pickPlace, pixels, switchStr, topMostPixel, type1, v1 dInfoPtr = (*TTkText)(unsafe.Pointer(textPtr)).FdInfoPtr if (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).Fflags&int32(DINFO_OUT_OF_DATE) != 0 { _UpdateDisplayInfo(tls, textPtr) } if objc == int64(2) { _GetYView(tls, interp, textPtr, 0) return TCL_OK } /* * Next, handle the old syntax: "pathName yview ?-pickplace? where" */ pickPlace = 0 if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8)), libc.UintptrFromInt32(0))))) == int32('-') { switchStr = libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+8) if *(*TTcl_Size)(unsafe.Pointer(bp + 8)) >= int64(2) && libc.Xstrncmp(tls, switchStr, __ccgo_ts+47316, uint64(libc.Uint32FromInt64(*(*TTcl_Size)(unsafe.Pointer(bp + 8))))) == 0 { pickPlace = int32(1) if objc != int64(4) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(3), objv, __ccgo_ts+47327) return int32(TCL_ERROR) } } } if objc == int64(3) || pickPlace != 0 { if libtcl9_0.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(int32(2)+pickPlace)*8)), bp+56) == TCL_OK { XTkTextMakeByteIndex(tls, (*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).Ftree, textPtr, *(*int32)(unsafe.Pointer(bp + 56)), 0, bp+24) XTkTextSetYView(tls, textPtr, bp+24, 0) return TCL_OK } /* * The argument must be a regular text index. */ libtcl9_0.XTcl_ResetResult(tls, interp) if XTkTextGetObjIndex(tls, interp, textPtr, *(*uintptr)(unsafe.Pointer(objv + uintptr(int32(2)+pickPlace)*8)), bp+24) != TCL_OK { return int32(TCL_ERROR) } if pickPlace != 0 { v1 = -int32(1) } else { v1 = 0 } XTkTextSetYView(tls, textPtr, bp+24, v1) return TCL_OK } /* * New syntax: dispatch based on objv[2]. */ type1 = _TextGetScrollInfoObj(tls, interp, textPtr, objc, objv, bp+16, bp) switch type1 { case int32(TKTEXT_SCROLL_ERROR): return int32(TCL_ERROR) case int32(TKTEXT_SCROLL_MOVETO): numPixels = XTkBTreeNumPixels(tls, (*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).Ftree, textPtr) if numPixels == 0 { /* * If the window is totally empty no scrolling is needed, and the * TkTextMakePixelIndex call below will fail. */ break } if *(*float64)(unsafe.Pointer(bp + 16)) > float64(1) { *(*float64)(unsafe.Pointer(bp + 16)) = float64(1) } if *(*float64)(unsafe.Pointer(bp + 16)) < libc.Float64FromInt32(0) { *(*float64)(unsafe.Pointer(bp + 16)) = libc.Float64FromInt32(0) } /* * Calculate the pixel count for the new topmost pixel in the topmost * line of the window. Note that the interpretation of 'fraction' is * that it counts from 0 (top pixel in buffer) to 1.0 (one pixel past * the last pixel in buffer). */ topMostPixel = int32(libc.Float64FromFloat64(0.5) + float64(*(*float64)(unsafe.Pointer(bp + 16))*float64(numPixels))) if topMostPixel >= numPixels { topMostPixel = numPixels - int32(1) } /* * This function returns the number of pixels by which the given line * should overlap the top of the visible screen. * * This is then used to provide smooth scrolling. */ pixels = XTkTextMakePixelIndex(tls, textPtr, topMostPixel, bp+24) XTkTextSetYView(tls, textPtr, bp+24, pixels) case int32(TKTEXT_SCROLL_PAGES): /* * Scroll up or down by screenfuls. Actually, use the window height * minus two lines, so that there's some overlap between adjacent * pages. */ height = (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FmaxY - (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).Fy if (*TTkText)(unsafe.Pointer(textPtr)).FcharHeight*int32(4) >= height { /* * A single line is more than a quarter of the display. We choose * to scroll by 3/4 of the height instead. */ pixels = int32(3) * height / int32(4) if pixels < (*TTkText)(unsafe.Pointer(textPtr)).FcharHeight { /* * But, if 3/4 of the height is actually less than a single * typical character height, then scroll by the minimum of the * linespace or the total height. */ if (*TTkText)(unsafe.Pointer(textPtr)).FcharHeight < height { pixels = (*TTkText)(unsafe.Pointer(textPtr)).FcharHeight } else { pixels = height } } pixels *= *(*int32)(unsafe.Pointer(bp)) } else { pixels = (height - int32(2)*(*TTkText)(unsafe.Pointer(textPtr)).FcharHeight) * *(*int32)(unsafe.Pointer(bp)) } _YScrollByPixels(tls, textPtr, pixels) case int32(TKTEXT_SCROLL_PIXELS): _YScrollByPixels(tls, textPtr, *(*int32)(unsafe.Pointer(bp))) case int32(TKTEXT_SCROLL_UNITS): _YScrollByLines(tls, textPtr, *(*int32)(unsafe.Pointer(bp))) break } return TCL_OK } /* *-------------------------------------------------------------- * * TkTextPendingsync -- * * This function checks if any line heights are not up-to-date. * * Results: * Returns a boolean true if it is the case, or false if all line * heights are up-to-date. * * Side effects: * None. * *-------------------------------------------------------------- */ func XTkTextPendingsync(tls *libc.TLS, textPtr uintptr) (r int32) { /* Information about text widget. */ var dInfoPtr uintptr _ = dInfoPtr dInfoPtr = (*TTkText)(unsafe.Pointer(textPtr)).FdInfoPtr return libc.BoolInt32((*TTextDInfo)(unsafe.Pointer(dInfoPtr)).Fflags&int32(OUT_OF_SYNC) != 0) } /* *-------------------------------------------------------------- * * TkTextScanCmd -- * * This function is invoked to process the "scan" option for the widget * command for text widgets. See the user documentation for details on * what it does. * * Results: * A standard Tcl result. * * Side effects: * See the user documentation. * *-------------------------------------------------------------- */ func XTkTextScanCmd(tls *libc.TLS, textPtr uintptr, interp uintptr, objc TTcl_Size, objv uintptr) (r int32) { bp := tls.Alloc(80) defer tls.Free(80) /* Argument objects. Someone else has already * parsed this command enough to know that * objv[1] is "scan". */ var c, maxX, newX, totalScroll int32 var dInfoPtr uintptr var index TTkTextIndex var _ /* gain at bp+8 */ int32 var _ /* length at bp+16 */ TTcl_Size var _ /* x at bp+0 */ int32 var _ /* y at bp+4 */ int32 _, _, _, _, _, _ = c, dInfoPtr, index, maxX, newX, totalScroll dInfoPtr = (*TTkText)(unsafe.Pointer(textPtr)).FdInfoPtr *(*int32)(unsafe.Pointer(bp + 8)) = int32(10) if objc != int64(5) && objc != int64(6) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(2), objv, __ccgo_ts+47341) libtcl9_0.XTcl_AppendResult(tls, interp, libc.VaList(bp+32, __ccgo_ts+11755, libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv)), libc.UintptrFromInt32(0)), __ccgo_ts+47350, libc.UintptrFromInt32(0))) /* * Ought to be: * Tcl_WrongNumArgs(interp, 2, objc, "dragto x y ?gain?"); */ return int32(TCL_ERROR) } if libtcl9_0.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 3*8)), bp) != TCL_OK { return int32(TCL_ERROR) } if libtcl9_0.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 4*8)), bp+4) != TCL_OK { return int32(TCL_ERROR) } if objc == int64(6) && libtcl9_0.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 5*8)), bp+8) != TCL_OK { return int32(TCL_ERROR) } c = libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+16)))) if c == int32('d') && libc.Xstrncmp(tls, libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8)), libc.UintptrFromInt32(0)), __ccgo_ts+22299, libc.Uint64FromInt64(*(*TTcl_Size)(unsafe.Pointer(bp + 16)))) == 0 { /* * Amplify the difference between the current position and the mark * position to compute how much the view should shift, then update the * mark position to correspond to the new view. If we run off the edge * of the text, reset the mark point so that the current position * continues to correspond to the edge of the window. This means that * the picture will start dragging as soon as the mouse reverses * direction (without this reset, might have to slide mouse a long * ways back before the picture starts moving again). */ newX = (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FscanMarkXPixel + *(*int32)(unsafe.Pointer(bp + 8))*((*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FscanMarkX-*(*int32)(unsafe.Pointer(bp))) maxX = int32(1) + (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FmaxLength - ((*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FmaxX - (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).Fx) if newX < 0 { newX = 0 (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FscanMarkXPixel = 0 (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FscanMarkX = *(*int32)(unsafe.Pointer(bp)) } else { if newX > maxX { newX = maxX (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FscanMarkXPixel = maxX (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FscanMarkX = *(*int32)(unsafe.Pointer(bp)) } } (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FnewXPixelOffset = newX totalScroll = *(*int32)(unsafe.Pointer(bp + 8)) * ((*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FscanMarkY - *(*int32)(unsafe.Pointer(bp + 4))) if totalScroll != (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FscanTotalYScroll { index = (*TTkText)(unsafe.Pointer(textPtr)).FtopIndex _YScrollByPixels(tls, textPtr, totalScroll-(*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FscanTotalYScroll) (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FscanTotalYScroll = totalScroll if index.FlinePtr == (*TTkText)(unsafe.Pointer(textPtr)).FtopIndex.FlinePtr && index.FbyteIndex == (*TTkText)(unsafe.Pointer(textPtr)).FtopIndex.FbyteIndex { (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FscanTotalYScroll = 0 (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FscanMarkY = *(*int32)(unsafe.Pointer(bp + 4)) } } *(*int32)(unsafe.Pointer(dInfoPtr + 220)) |= int32(DINFO_OUT_OF_DATE) if !((*TTextDInfo)(unsafe.Pointer(dInfoPtr)).Fflags&libc.Int32FromInt32(REDRAW_PENDING3) != 0) { *(*int32)(unsafe.Pointer(dInfoPtr + 220)) |= int32(REDRAW_PENDING3) libtcl9_0.XTcl_DoWhenIdle(tls, __ccgo_fp(_DisplayText), textPtr) } } else { if c == int32('m') && libc.Xstrncmp(tls, libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8)), libc.UintptrFromInt32(0)), __ccgo_ts+2046, libc.Uint64FromInt64(*(*TTcl_Size)(unsafe.Pointer(bp + 16)))) == 0 { (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FscanMarkXPixel = (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FnewXPixelOffset (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FscanMarkX = *(*int32)(unsafe.Pointer(bp)) (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FscanTotalYScroll = 0 (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FscanMarkY = *(*int32)(unsafe.Pointer(bp + 4)) } else { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+22306, libc.VaList(bp+32, libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8)), libc.UintptrFromInt32(0))))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+32, __ccgo_ts+5785, __ccgo_ts+3058, __ccgo_ts+5789, __ccgo_ts+22351, libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8)), libc.UintptrFromInt32(0)), libc.UintptrFromInt32(0))) return int32(TCL_ERROR) } } return TCL_OK } /* *---------------------------------------------------------------------- * * GetXView -- * * This function computes the fractions that indicate what's visible in a * text window and, optionally, evaluates a Tcl script to report them to * the text's associated scrollbar. * * Results: * If report is zero, then the interp's result is filled in with two real * numbers separated by a space, giving the position of the left and * right edges of the window as fractions from 0 to 1, where 0 means the * left edge of the text and 1 means the right edge. If report is * non-zero, then the interp's result isn't modified directly, but * instead a script is evaluated in interp to report the new horizontal * scroll position to the scrollbar (if the scroll position hasn't * changed then no script is invoked). * * Side effects: * None. * *---------------------------------------------------------------------- */ func _GetXView(tls *libc.TLS, interp uintptr, textPtr uintptr, report int32) { bp := tls.Alloc(288) defer tls.Free(288) /* Non-zero means report info to scrollbar if * it has changed. */ var code int32 var dInfoPtr, listObj uintptr var first, last float64 var _ /* buf at bp+56 */ TTcl_DString var _ /* buf1 at bp+0 */ [28]uint8 var _ /* buf2 at bp+28 */ [28]uint8 _, _, _, _, _ = code, dInfoPtr, first, last, listObj dInfoPtr = (*TTkText)(unsafe.Pointer(textPtr)).FdInfoPtr if (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FmaxLength > 0 { first = float64((*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FcurXPixelOffset) / float64((*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FmaxLength) last = float64((*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FcurXPixelOffset+(*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FmaxX-(*TTextDInfo)(unsafe.Pointer(dInfoPtr)).Fx) / float64((*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FmaxLength) if last > float64(1) { last = float64(1) } } else { first = libc.Float64FromInt32(0) last = float64(1) } if !(report != 0) { listObj = libtcl9_0.XTcl_NewListObj(tls, 0, libc.UintptrFromInt32(0)) libtcl9_0.XTcl_ListObjAppendElement(tls, interp, listObj, libtcl9_0.XTcl_NewDoubleObj(tls, first)) libtcl9_0.XTcl_ListObjAppendElement(tls, interp, listObj, libtcl9_0.XTcl_NewDoubleObj(tls, last)) libtcl9_0.XTcl_SetObjResult(tls, interp, listObj) return } if float64(libc.Xfabs(tls, first-(*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FxScrollFirst)*(float64((*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FmaxLength)+float64(1))) < float64(0.3) && float64(libc.Xfabs(tls, last-(*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FxScrollLast)*(float64((*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FmaxLength)+float64(1))) < float64(0.3) { return } (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FxScrollFirst = first (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FxScrollLast = last if (*TTkText)(unsafe.Pointer(textPtr)).FxScrollCmdObj != libc.UintptrFromInt32(0) { (*(*[28]uint8)(unsafe.Pointer(bp)))[0] = uint8(' ') (*(*[28]uint8)(unsafe.Pointer(bp + 28)))[0] = uint8(' ') libtcl9_0.XTcl_PrintDouble(tls, libc.UintptrFromInt32(0), first, bp+uintptr(1)) libtcl9_0.XTcl_PrintDouble(tls, libc.UintptrFromInt32(0), last, bp+28+uintptr(1)) libtcl9_0.XTcl_DStringInit(tls, bp+56) libtcl9_0.XTcl_DStringAppend(tls, bp+56, libtcl9_0.XTcl_GetStringFromObj(tls, (*TTkText)(unsafe.Pointer(textPtr)).FxScrollCmdObj, libc.UintptrFromInt32(0)), int64(-libc.Int32FromInt32(1))) libtcl9_0.XTcl_DStringAppend(tls, bp+56, bp, int64(-libc.Int32FromInt32(1))) libtcl9_0.XTcl_DStringAppend(tls, bp+56, bp+28, int64(-libc.Int32FromInt32(1))) code = libtcl9_0.XTcl_EvalEx(tls, interp, (*TTcl_DString)(unsafe.Pointer(bp+56)).Fstring1, int64(-libc.Int32FromInt32(1)), int32(TCL_EVAL_GLOBAL)) libtcl9_0.XTcl_DStringFree(tls, bp+56) if code != TCL_OK { libtcl9_0.XTcl_AppendObjToErrorInfo(tls, interp, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+47375, int64(-int32(1)))) libtcl9_0.XTcl_BackgroundException(tls, interp, code) } } } /* *---------------------------------------------------------------------- * * GetYPixelCount -- * * How many pixels are there between the absolute top of the widget and * the top of the given DLine. * * While this function will work for any valid DLine, it is only ever * called when dlPtr is the first display line in the widget (by * 'GetYView'). This means that usually this function is a very quick * calculation, since it can use the pre-calculated linked-list of DLines * for height information. * * The only situation where this breaks down is if dlPtr's logical line * wraps enough times to fill the text widget's current view - in this * case we won't have enough dlPtrs in the linked list to be able to * subtract off what we want. * * Results: * The number of pixels. * * This value has a valid range between '0' (the very top of the widget) * and the number of pixels in the total widget minus the pixel-height of * the last line. * * Side effects: * None. * *---------------------------------------------------------------------- */ func _GetYPixelCount(tls *libc.TLS, textPtr uintptr, dlPtr uintptr) (r int32) { bp := tls.Alloc(64) defer tls.Free(64) /* Information about the layout of a given * index. */ var count, notFirst int32 var linePtr uintptr var _ /* index at bp+0 */ TTkTextIndex var _ /* string at bp+32 */ [30]uint8 _, _, _ = count, linePtr, notFirst linePtr = (*TDLine)(unsafe.Pointer(dlPtr)).Findex.FlinePtr /* * Get the pixel count to the top of dlPtr's logical line. The rest of the * function is then concerned with updating 'count' for any difference * between the top of the logical line and the display line. */ count = XTkBTreePixelsTo(tls, textPtr, linePtr) /* * For the common case where this dlPtr is also the start of the logical * line, we can return right away. */ if _IsStartOfNotMergedLine(tls, textPtr, dlPtr) != 0 { return count } /* * Add on the logical line's height to reach one pixel beyond the bottom * of the logical line. And then subtract off the heights of all the * display lines from dlPtr to the end of its logical line. * * A different approach would be to lay things out from the start of the * logical line until we reach dlPtr, but since none of those are * pre-calculated, it'll usually take a lot longer. (But there are cases * where it would be more efficient: say if we're on the second of 1000 * wrapped lines all from a single logical line - but that sort of * optimization is left for the future). */ count += *(*int32)(unsafe.Pointer((*TTkTextLine)(unsafe.Pointer(linePtr)).Fpixels + uintptr(int32(2)*(*TTkText)(unsafe.Pointer(textPtr)).FpixelReference)*4)) for cond := true; cond; cond = (*TDLine)(unsafe.Pointer(dlPtr)).Findex.FlinePtr == linePtr { count -= (*TDLine)(unsafe.Pointer(dlPtr)).Fheight if (*TDLine)(unsafe.Pointer(dlPtr)).FnextPtr == libc.UintptrFromInt32(0) { notFirst = 0 for int32(1) != 0 { XTkTextIndexForwBytes(tls, textPtr, dlPtr, int64((*TDLine)(unsafe.Pointer(dlPtr)).FbyteCount), bp) if notFirst != 0 { _FreeDLines(tls, textPtr, dlPtr, libc.UintptrFromInt32(0), int32(DLINE_FREE_TEMP)) } if (*(*TTkTextIndex)(unsafe.Pointer(bp))).FlinePtr != linePtr { break } dlPtr = _LayoutDLine(tls, textPtr, bp) if XtkTextDebug != 0 { /* * Debugging is enabled, so keep a log of all the lines * whose height was recalculated. The test suite uses this * information. */ XTkTextPrintIndex(tls, textPtr, bp, bp+32) libtcl9_0.XTcl_SetVar2(tls, (*TTkText)(unsafe.Pointer(textPtr)).Finterp, __ccgo_ts+47071, libc.UintptrFromInt32(0), bp+32, libc.Int32FromInt32(TCL_GLOBAL_ONLY)|libc.Int32FromInt32(TCL_APPEND_VALUE)|libc.Int32FromInt32(TCL_LIST_ELEMENT)) } count -= (*TDLine)(unsafe.Pointer(dlPtr)).Fheight notFirst = int32(1) } break } dlPtr = (*TDLine)(unsafe.Pointer(dlPtr)).FnextPtr } return count } /* *---------------------------------------------------------------------- * * GetYView -- * * This function computes the fractions that indicate what's visible in a * text window and, optionally, evaluates a Tcl script to report them to * the text's associated scrollbar. * * Results: * If report is zero, then the interp's result is filled in with two real * numbers separated by a space, giving the position of the top and * bottom of the window as fractions from 0 to 1, where 0 means the * beginning of the text and 1 means the end. If report is non-zero, then * the interp's result isn't modified directly, but a script is evaluated * in interp to report the new scroll position to the scrollbar (if the * scroll position hasn't changed then no script is invoked). * * Side effects: * None. * *---------------------------------------------------------------------- */ func _GetYView(tls *libc.TLS, interp uintptr, textPtr uintptr, report int32) { bp := tls.Alloc(288) defer tls.Free(288) /* Non-zero means report info to scrollbar if * it has changed. */ var code, count, extra, totalPixels int32 var dInfoPtr, dlPtr, listObj uintptr var first, last float64 var _ /* buf at bp+56 */ TTcl_DString var _ /* buf1 at bp+0 */ [28]uint8 var _ /* buf2 at bp+28 */ [28]uint8 _, _, _, _, _, _, _, _, _ = code, count, dInfoPtr, dlPtr, extra, first, last, listObj, totalPixels dInfoPtr = (*TTkText)(unsafe.Pointer(textPtr)).FdInfoPtr dlPtr = (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FdLinePtr if dlPtr == libc.UintptrFromInt32(0) { return } totalPixels = XTkBTreeNumPixels(tls, (*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).Ftree, textPtr) if totalPixels == 0 { first = float64(0) last = float64(1) } else { /* * Get the pixel count for the first visible pixel of the first * visible line. If the first visible line is only partially visible, * then we use 'topPixelOffset' to get the difference. */ count = _GetYPixelCount(tls, textPtr, dlPtr) first = float64(count+(*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FtopPixelOffset) / float64(totalPixels) /* * Add on the total number of visible pixels to get the count to one * pixel _past_ the last visible pixel. This is how the 'yview' * command is documented, and also explains why we are dividing by * 'totalPixels' and not 'totalPixels-1'. */ for int32(1) != 0 { count += (*TDLine)(unsafe.Pointer(dlPtr)).Fheight extra = (*TDLine)(unsafe.Pointer(dlPtr)).Fy + (*TDLine)(unsafe.Pointer(dlPtr)).Fheight - (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FmaxY if extra > 0 { /* * This much of the last line is not visible, so don't count * these pixels. Since we've reached the bottom of the window, * we break out of the loop. */ count -= extra break } if (*TDLine)(unsafe.Pointer(dlPtr)).FnextPtr == libc.UintptrFromInt32(0) { break } dlPtr = (*TDLine)(unsafe.Pointer(dlPtr)).FnextPtr } if count > totalPixels { /* * It can be possible, if we do not update each line's pixelHeight * cache when we lay out individual DLines that the count * generated here is more up-to-date than that maintained by the * BTree. In such a case, the best we can do here is to fix up * 'count' and continue, which might result in small, temporary * perturbations to the size of the scrollbar. This is basically * harmless, but in a perfect world we would not have this * problem. * * For debugging purposes, if anyone wishes to improve the text * widget further, the following 'panic' can be activated. In * principle it should be possible to ensure the BTree is always * at least as up to date as the display, so in the future we * might be able to leave the 'panic' in permanently when we * believe we have resolved the cache synchronisation issue. * * However, to achieve that goal would, I think, require a fairly * substantial refactorisation of the code in this file so that * there is much more obvious and explicit coordination between * calls to LayoutDLine and updating of each TkTextLine's * pixelHeight. The complicated bit is that LayoutDLine deals with * individual display lines, but pixelHeight is for a logical * line. */ count = totalPixels } last = float64(count) / float64(totalPixels) } if !(report != 0) { listObj = libtcl9_0.XTcl_NewListObj(tls, 0, libc.UintptrFromInt32(0)) libtcl9_0.XTcl_ListObjAppendElement(tls, interp, listObj, libtcl9_0.XTcl_NewDoubleObj(tls, first)) libtcl9_0.XTcl_ListObjAppendElement(tls, interp, listObj, libtcl9_0.XTcl_NewDoubleObj(tls, last)) libtcl9_0.XTcl_SetObjResult(tls, interp, listObj) return } if float64(libc.Xfabs(tls, first-(*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FyScrollFirst)*(float64(totalPixels)+float64(1))) < float64(0.3) && float64(libc.Xfabs(tls, last-(*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FyScrollLast)*(float64(totalPixels)+float64(1))) < float64(0.3) { return } (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FyScrollFirst = first (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FyScrollLast = last if (*TTkText)(unsafe.Pointer(textPtr)).FyScrollCmdObj != libc.UintptrFromInt32(0) { (*(*[28]uint8)(unsafe.Pointer(bp)))[0] = uint8(' ') (*(*[28]uint8)(unsafe.Pointer(bp + 28)))[0] = uint8(' ') libtcl9_0.XTcl_PrintDouble(tls, libc.UintptrFromInt32(0), first, bp+uintptr(1)) libtcl9_0.XTcl_PrintDouble(tls, libc.UintptrFromInt32(0), last, bp+28+uintptr(1)) libtcl9_0.XTcl_DStringInit(tls, bp+56) libtcl9_0.XTcl_DStringAppend(tls, bp+56, libtcl9_0.XTcl_GetStringFromObj(tls, (*TTkText)(unsafe.Pointer(textPtr)).FyScrollCmdObj, libc.UintptrFromInt32(0)), int64(-libc.Int32FromInt32(1))) libtcl9_0.XTcl_DStringAppend(tls, bp+56, bp, int64(-libc.Int32FromInt32(1))) libtcl9_0.XTcl_DStringAppend(tls, bp+56, bp+28, int64(-libc.Int32FromInt32(1))) code = libtcl9_0.XTcl_EvalEx(tls, interp, (*TTcl_DString)(unsafe.Pointer(bp+56)).Fstring1, int64(-libc.Int32FromInt32(1)), int32(TCL_EVAL_GLOBAL)) libtcl9_0.XTcl_DStringFree(tls, bp+56) if code != TCL_OK { libtcl9_0.XTcl_AppendObjToErrorInfo(tls, interp, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+47428, int64(-int32(1)))) libtcl9_0.XTcl_BackgroundException(tls, interp, code) } } } /* *---------------------------------------------------------------------- * * AsyncUpdateYScrollbar -- * * This function is called to update the vertical scrollbar asychronously * as the pixel height calculations progress for lines in the widget. * * Results: * None. * * Side effects: * See 'GetYView'. In particular the scrollbar position and size may be * changed. * *---------------------------------------------------------------------- */ func _AsyncUpdateYScrollbar(tls *libc.TLS, clientData uintptr) { /* Information about widget. */ var textPtr, v2 uintptr var v1 TTcl_Size _, _, _ = textPtr, v1, v2 textPtr = clientData (*TTextDInfo1)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FdInfoPtr)).FscrollbarTimer = libc.UintptrFromInt32(0) if !((*TTkText)(unsafe.Pointer(textPtr)).Fflags&libc.Int32FromInt32(DESTROYED) != 0) { _GetYView(tls, (*TTkText)(unsafe.Pointer(textPtr)).Finterp, textPtr, int32(1)) } v2 = textPtr + 688 v1 = *(*TTcl_Size)(unsafe.Pointer(v2)) *(*TTcl_Size)(unsafe.Pointer(v2))-- if v1 <= int64(1) { libtcl9_0.XTcl_Free(tls, textPtr) } } /* *---------------------------------------------------------------------- * * FindDLine -- * * This function is called to find the DLine corresponding to a given * text index. * * Results: * The return value is a pointer to the first DLine found in the list * headed by dlPtr that displays information at or after the specified * position. If there is no such line in the list then NULL is returned. * * Side effects: * None. * *---------------------------------------------------------------------- */ func _FindDLine(tls *libc.TLS, textPtr uintptr, dlPtr uintptr, indexPtr uintptr) (r uintptr) { bp := tls.Alloc(32) defer tls.Free(32) /* Index of desired character. */ var dlPtrPrev uintptr var _ /* indexPtr2 at bp+0 */ TTkTextIndex _ = dlPtrPrev if dlPtr == libc.UintptrFromInt32(0) { return libc.UintptrFromInt32(0) } if XTkBTreeLinesTo(tls, libc.UintptrFromInt32(0), (*TTkTextIndex)(unsafe.Pointer(indexPtr)).FlinePtr) < XTkBTreeLinesTo(tls, libc.UintptrFromInt32(0), (*TDLine)(unsafe.Pointer(dlPtr)).Findex.FlinePtr) { /* * The first display line is already past the desired line. */ return dlPtr } /* * The display line containing the desired index is such that the index * of the first character of this display line is at or before the * desired index, and the index of the first character of the next * display line is after the desired index. */ for XTkTextIndexCmp(tls, dlPtr, indexPtr) < 0 { dlPtrPrev = dlPtr dlPtr = (*TDLine)(unsafe.Pointer(dlPtr)).FnextPtr if dlPtr == libc.UintptrFromInt32(0) { /* * We're past the last display line, either because the desired * index lies past the visible text, or because the desired index * is on the last display line. */ *(*TTkTextIndex)(unsafe.Pointer(bp)) = (*TDLine)(unsafe.Pointer(dlPtrPrev)).Findex XTkTextIndexForwBytes(tls, textPtr, bp, int64((*TDLine)(unsafe.Pointer(dlPtrPrev)).FbyteCount), bp) if XTkTextIndexCmp(tls, bp, indexPtr) > 0 { /* * The desired index is on the last display line. * --> return this display line. */ dlPtr = dlPtrPrev } else { /* * The desired index is past the visible text. There is no * display line displaying something at the desired index. * --> return NULL. */ } break } if XTkTextIndexCmp(tls, dlPtr, indexPtr) > 0 { /* * If we're here then we would normally expect that: * dlPtrPrev->index <= indexPtr < dlPtr->index * i.e. we have found the searched display line being dlPtr. * However it is possible that some DLines were unlinked * previously, leading to a situation where going through * the list of display lines skips display lines that did * exist just a moment ago. */ *(*TTkTextIndex)(unsafe.Pointer(bp)) = (*TDLine)(unsafe.Pointer(dlPtrPrev)).Findex XTkTextIndexForwBytes(tls, textPtr, bp, int64((*TDLine)(unsafe.Pointer(dlPtrPrev)).FbyteCount), bp) if XTkTextIndexCmp(tls, bp, indexPtr) > 0 { /* * Confirmed: * dlPtrPrev->index <= indexPtr < dlPtr->index * --> return dlPtrPrev. */ dlPtr = dlPtrPrev } else { /* * The last (rightmost) index shown by dlPtrPrev is still * before the desired index. This may be because there was * previously a display line between dlPtrPrev and dlPtr * and this display line has been unlinked. * --> return dlPtr. */ } break } } return dlPtr } /* *---------------------------------------------------------------------- * * IsStartOfNotMergedLine -- * * This function checks whether the given index is the start of a * logical line that is not merged with the previous logical line * (due to elision of the eol of the previous line). * * Results: * Returns whether the given index denotes the first index of a * logical line not merged with its previous line. * * Side effects: * None. * *---------------------------------------------------------------------- */ func _IsStartOfNotMergedLine(tls *libc.TLS, textPtr uintptr, indexPtr uintptr) (r int32) { bp := tls.Alloc(32) defer tls.Free(32) /* Index to check. */ var _ /* indexPtr2 at bp+0 */ TTkTextIndex if (*TTkTextIndex)(unsafe.Pointer(indexPtr)).FbyteIndex != 0 { /* * Not the start of a logical line. */ return 0 } if XTkTextIndexBackBytes(tls, textPtr, indexPtr, int64(1), bp) != 0 { /* * indexPtr is the first index of the text widget. */ return int32(1) } if !(XTkTextIsElided(tls, textPtr, bp, libc.UintptrFromInt32(0)) != 0) { /* * The eol of the line just before indexPtr is elided. */ return int32(1) } return 0 } /* *---------------------------------------------------------------------- * * TkTextPixelIndex -- * * Given an (x,y) coordinate on the screen, find the location of the * character closest to that location. * * Results: * The index at *indexPtr is modified to refer to the character on the * display that is closest to (x,y). * * Side effects: * None. * *---------------------------------------------------------------------- */ func XTkTextPixelIndex(tls *libc.TLS, textPtr uintptr, x int32, y int32, indexPtr uintptr, nearest uintptr) { /* If non-NULL then gets set to 0 if (x,y) is * actually over the returned index, and 1 if * it is just nearby (e.g. if x,y is on the * border of the widget). */ var dInfoPtr, dlPtr, validDlPtr, v2 uintptr var nearby int32 _, _, _, _, _ = dInfoPtr, dlPtr, nearby, validDlPtr, v2 dInfoPtr = (*TTkText)(unsafe.Pointer(textPtr)).FdInfoPtr nearby = 0 /* * Make sure that all of the layout information about what's displayed * where on the screen is up-to-date. */ if (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).Fflags&int32(DINFO_OUT_OF_DATE) != 0 { _UpdateDisplayInfo(tls, textPtr) } /* * If the coordinates are above the top of the window, then adjust them to * refer to the upper-right corner of the window. If they're off to one * side or the other, then adjust to the closest side. */ if y < (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).Fy { y = (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).Fy x = (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).Fx nearby = int32(1) } if x >= (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FmaxX { x = (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FmaxX - int32(1) nearby = int32(1) } if x < (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).Fx { x = (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).Fx nearby = int32(1) } /* * Find the display line containing the desired y-coordinate. */ if (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FdLinePtr == libc.UintptrFromInt32(0) { if nearest != libc.UintptrFromInt32(0) { *(*int32)(unsafe.Pointer(nearest)) = int32(1) } *(*TTkTextIndex)(unsafe.Pointer(indexPtr)) = (*TTkText)(unsafe.Pointer(textPtr)).FtopIndex return } v2 = (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FdLinePtr validDlPtr = v2 dlPtr = v2 for { if !(y >= (*TDLine)(unsafe.Pointer(dlPtr)).Fy+(*TDLine)(unsafe.Pointer(dlPtr)).Fheight) { break } if (*TDLine)(unsafe.Pointer(dlPtr)).FchunkPtr != libc.UintptrFromInt32(0) { validDlPtr = dlPtr } if (*TDLine)(unsafe.Pointer(dlPtr)).FnextPtr == libc.UintptrFromInt32(0) { /* * Y-coordinate is off the bottom of the displayed text. Use the * last character on the last line. */ x = (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FmaxX - int32(1) nearby = int32(1) break } goto _1 _1: ; dlPtr = (*TDLine)(unsafe.Pointer(dlPtr)).FnextPtr } if (*TDLine)(unsafe.Pointer(dlPtr)).FchunkPtr == libc.UintptrFromInt32(0) { dlPtr = validDlPtr } if nearest != libc.UintptrFromInt32(0) { *(*int32)(unsafe.Pointer(nearest)) = nearby } _DlineIndexOfX(tls, textPtr, dlPtr, x, indexPtr) } /* *---------------------------------------------------------------------- * * DlineIndexOfX -- * * Given an x coordinate in a display line, find the index of the * character closest to that location. * * This is effectively the opposite of DlineXOfIndex. * * Results: * The index at *indexPtr is modified to refer to the character on the * display line that is closest to x. * * Side effects: * None. * *---------------------------------------------------------------------- */ func _DlineIndexOfX(tls *libc.TLS, textPtr uintptr, dlPtr uintptr, x int32, indexPtr uintptr) { /* This index gets filled in with the index of * the character nearest to x. */ var chunkPtr, dInfoPtr uintptr _, _ = chunkPtr, dInfoPtr dInfoPtr = (*TTkText)(unsafe.Pointer(textPtr)).FdInfoPtr /* * Scan through the line's chunks to find the one that contains the * desired x-coordinate. Before doing this, translate the x-coordinate * from the coordinate system of the window to the coordinate system of * the line (to take account of x-scrolling). */ *(*TTkTextIndex)(unsafe.Pointer(indexPtr)) = (*TDLine)(unsafe.Pointer(dlPtr)).Findex x = x - (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).Fx + (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FcurXPixelOffset chunkPtr = (*TDLine)(unsafe.Pointer(dlPtr)).FchunkPtr if chunkPtr == libc.UintptrFromInt32(0) || x == 0 { /* * This may occur if everything is elided, or if we're simply already * at the beginning of the line. */ return } for x >= (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).Fx+(*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).Fwidth { /* * Note that this forward then backward movement of the index can be * problematic at the end of the buffer (we can't move forward, and * then when we move backward, we do, leading to the wrong position). * Hence when x == 0 we take special action above. */ if XTkTextIndexForwBytes(tls, libc.UintptrFromInt32(0), indexPtr, (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FnumBytes, indexPtr) != 0 { /* * We've reached the end of the text. */ XTkTextIndexBackChars(tls, libc.UintptrFromInt32(0), indexPtr, int32(1), indexPtr, int32(COUNT_INDICES)) return } if (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FnextPtr == libc.UintptrFromInt32(0) { /* * We've reached the end of the display line. */ XTkTextIndexBackChars(tls, libc.UintptrFromInt32(0), indexPtr, int32(1), indexPtr, int32(COUNT_INDICES)) return } chunkPtr = (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FnextPtr } /* * If the chunk has more than one byte in it, ask it which character is at * the desired location. In this case we can manipulate * 'indexPtr->byteIndex' directly, because we know we're staying inside a * single logical line. */ if (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FnumBytes > int64(1) { *(*TTcl_Size)(unsafe.Pointer(indexPtr + 16)) += (*(*func(*libc.TLS, uintptr, int32) TTcl_Size)(unsafe.Pointer(&struct{ uintptr }{(*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FmeasureProc})))(tls, chunkPtr, x) } } /* *---------------------------------------------------------------------- * * TkTextIndexOfX -- * * Given a logical x coordinate (i.e. distance in pixels from the * beginning of the display line, not taking into account any information * about the window, scrolling etc.) on the display line starting with * the given index, adjust that index to refer to the object under the x * coordinate. * * Results: * None. * * Side effects: * None. * *---------------------------------------------------------------------- */ func XTkTextIndexOfX(tls *libc.TLS, textPtr uintptr, x int32, indexPtr uintptr) { /* Index of display line start, which will be * adjusted to the index under the given x * coordinate. */ var dlPtr uintptr _ = dlPtr dlPtr = _LayoutDLine(tls, textPtr, indexPtr) _DlineIndexOfX(tls, textPtr, dlPtr, x+(*TTextDInfo1)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FdInfoPtr)).Fx-(*TTextDInfo1)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FdInfoPtr)).FcurXPixelOffset, indexPtr) _FreeDLines(tls, textPtr, dlPtr, libc.UintptrFromInt32(0), int32(DLINE_FREE_TEMP)) } /* *---------------------------------------------------------------------- * * DlineXOfIndex -- * * Given a relative byte index on a given display line (i.e. the number * of byte indices from the beginning of the given display line), find * the x coordinate of that index within the abstract display line, * without adjusting for the x-scroll state of the line. * * This is effectively the opposite of DlineIndexOfX. * * NB. The 'byteIndex' is relative to the display line, NOT the logical * line. * * Results: * The x coordinate. * * Side effects: * None. * *---------------------------------------------------------------------- */ func _DlineXOfIndex(tls *libc.TLS, textPtr uintptr, dlPtr uintptr, byteIndex int32) (r int32) { bp := tls.Alloc(16) defer tls.Free(16) /* The byte index for which we want the * coordinate. */ var chunkPtr uintptr var _ /* height at bp+12 */ int32 var _ /* width at bp+8 */ int32 var _ /* x at bp+0 */ int32 var _ /* y at bp+4 */ int32 _ = chunkPtr chunkPtr = (*TDLine)(unsafe.Pointer(dlPtr)).FchunkPtr *(*int32)(unsafe.Pointer(bp)) = 0 if byteIndex == 0 || chunkPtr == libc.UintptrFromInt32(0) { return *(*int32)(unsafe.Pointer(bp)) } /* * Scan through the line's chunks to find the one that contains the * desired byte index. */ chunkPtr = (*TDLine)(unsafe.Pointer(dlPtr)).FchunkPtr for byteIndex > 0 { if int64(byteIndex) < (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FnumBytes { (*(*func(*libc.TLS, uintptr, uintptr, TTcl_Size, int32, int32, int32, uintptr, uintptr, uintptr, uintptr))(unsafe.Pointer(&struct{ uintptr }{(*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FbboxProc})))(tls, textPtr, chunkPtr, int64(byteIndex), (*TDLine)(unsafe.Pointer(dlPtr)).Fy+(*TDLine)(unsafe.Pointer(dlPtr)).FspaceAbove, (*TDLine)(unsafe.Pointer(dlPtr)).Fheight-(*TDLine)(unsafe.Pointer(dlPtr)).FspaceAbove-(*TDLine)(unsafe.Pointer(dlPtr)).FspaceBelow, (*TDLine)(unsafe.Pointer(dlPtr)).Fbaseline-(*TDLine)(unsafe.Pointer(dlPtr)).FspaceAbove, bp, bp+4, bp+8, bp+12) break } byteIndex = int32(int64(byteIndex) - (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FnumBytes) if (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FnextPtr == libc.UintptrFromInt32(0) || byteIndex == 0 { *(*int32)(unsafe.Pointer(bp)) = (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).Fx + (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).Fwidth break } chunkPtr = (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FnextPtr } return *(*int32)(unsafe.Pointer(bp)) } /* *---------------------------------------------------------------------- * * TkTextIndexBbox -- * * Given an index, find the bounding box of the screen area occupied by * the entity (character, window, image) at that index. * * Results: * Zero is returned if the index is on the screen. -1 means the index is * not on the screen. If the return value is 0, then the bounding box of * the part of the index that's visible on the screen is returned to * *xPtr, *yPtr, *widthPtr, and *heightPtr. * * Side effects: * None. * *---------------------------------------------------------------------- */ func XTkTextIndexBbox(tls *libc.TLS, textPtr uintptr, indexPtr uintptr, xPtr uintptr, yPtr uintptr, widthPtr uintptr, heightPtr uintptr, charWidthPtr uintptr) (r int32) { /* If the 'index' is at the end of a display * line and therefore takes up a very large * width, this is used to return the smaller * width actually desired by the index. */ var byteCount TTcl_Size var chunkPtr, dInfoPtr, dlPtr uintptr _, _, _, _ = byteCount, chunkPtr, dInfoPtr, dlPtr dInfoPtr = (*TTkText)(unsafe.Pointer(textPtr)).FdInfoPtr /* * Make sure that all of the screen layout information is up to date. */ if (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).Fflags&int32(DINFO_OUT_OF_DATE) != 0 { _UpdateDisplayInfo(tls, textPtr) } /* * Find the display line containing the desired index. */ dlPtr = _FindDLine(tls, textPtr, (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FdLinePtr, indexPtr) /* * Two cases shall be trapped here because the logic later really * needs dlPtr to be the display line containing indexPtr: * 1. if no display line contains the desired index (NULL dlPtr) * 2. if indexPtr is before the first display line, in which case * dlPtr currently points to the first display line */ if dlPtr == libc.UintptrFromInt32(0) || XTkTextIndexCmp(tls, dlPtr, indexPtr) > 0 { return -int32(1) } /* * Find the chunk within the display line that contains the desired * index. The chunks making the display line are skipped up to but not * including the one crossing indexPtr. Skipping is done based on * a byteCount offset possibly spanning several logical lines in case * they are elided. */ byteCount = int64(XTkTextIndexCountBytes(tls, textPtr, dlPtr, indexPtr)) chunkPtr = (*TDLine)(unsafe.Pointer(dlPtr)).FchunkPtr for { if chunkPtr == libc.UintptrFromInt32(0) { return -int32(1) } if byteCount < (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FnumBytes { break } byteCount -= (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FnumBytes goto _1 _1: ; chunkPtr = (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FnextPtr } /* * Call a chunk-specific function to find the horizontal range of the * character within the chunk, then fill in the vertical range. The * x-coordinate returned by bboxProc is a coordinate within a line, not a * coordinate on the screen. Translate it to reflect horizontal scrolling. */ (*(*func(*libc.TLS, uintptr, uintptr, TTcl_Size, int32, int32, int32, uintptr, uintptr, uintptr, uintptr))(unsafe.Pointer(&struct{ uintptr }{(*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FbboxProc})))(tls, textPtr, chunkPtr, byteCount, (*TDLine)(unsafe.Pointer(dlPtr)).Fy+(*TDLine)(unsafe.Pointer(dlPtr)).FspaceAbove, (*TDLine)(unsafe.Pointer(dlPtr)).Fheight-(*TDLine)(unsafe.Pointer(dlPtr)).FspaceAbove-(*TDLine)(unsafe.Pointer(dlPtr)).FspaceBelow, (*TDLine)(unsafe.Pointer(dlPtr)).Fbaseline-(*TDLine)(unsafe.Pointer(dlPtr)).FspaceAbove, xPtr, yPtr, widthPtr, heightPtr) *(*int32)(unsafe.Pointer(xPtr)) = *(*int32)(unsafe.Pointer(xPtr)) + (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).Fx - (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FcurXPixelOffset if byteCount == (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FnumBytes-int64(1) && (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FnextPtr == libc.UintptrFromInt32(0) { /* * Last character in display line. Give it all the space up to the * line. */ if charWidthPtr != libc.UintptrFromInt32(0) { *(*int32)(unsafe.Pointer(charWidthPtr)) = (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FmaxX - *(*int32)(unsafe.Pointer(xPtr)) if *(*int32)(unsafe.Pointer(charWidthPtr)) > (*TTkText)(unsafe.Pointer(textPtr)).FcharWidth { *(*int32)(unsafe.Pointer(charWidthPtr)) = (*TTkText)(unsafe.Pointer(textPtr)).FcharWidth } } if *(*int32)(unsafe.Pointer(xPtr)) > (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FmaxX { *(*int32)(unsafe.Pointer(xPtr)) = (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FmaxX } *(*int32)(unsafe.Pointer(widthPtr)) = (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FmaxX - *(*int32)(unsafe.Pointer(xPtr)) } else { if charWidthPtr != libc.UintptrFromInt32(0) { *(*int32)(unsafe.Pointer(charWidthPtr)) = *(*int32)(unsafe.Pointer(widthPtr)) } } if *(*int32)(unsafe.Pointer(widthPtr)) == 0 { /* * With zero width (e.g. elided text) we just need to make sure it is * onscreen, where the '=' case here is ok. */ if *(*int32)(unsafe.Pointer(xPtr)) < (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).Fx { return -int32(1) } } else { if *(*int32)(unsafe.Pointer(xPtr))+*(*int32)(unsafe.Pointer(widthPtr)) <= (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).Fx { return -int32(1) } } if *(*int32)(unsafe.Pointer(xPtr))+*(*int32)(unsafe.Pointer(widthPtr)) > (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FmaxX { *(*int32)(unsafe.Pointer(widthPtr)) = (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FmaxX - *(*int32)(unsafe.Pointer(xPtr)) if *(*int32)(unsafe.Pointer(widthPtr)) <= 0 { return -int32(1) } } if *(*int32)(unsafe.Pointer(yPtr))+*(*int32)(unsafe.Pointer(heightPtr)) > (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FmaxY { *(*int32)(unsafe.Pointer(heightPtr)) = (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FmaxY - *(*int32)(unsafe.Pointer(yPtr)) if *(*int32)(unsafe.Pointer(heightPtr)) <= 0 { return -int32(1) } } return 0 } /* *---------------------------------------------------------------------- * * TkTextDLineInfo -- * * Given an index, return information about the display line containing * that character. * * Results: * Zero is returned if the character is on the screen. -1 means the * character isn't on the screen. If the return value is 0, then * information is returned in the variables pointed to by xPtr, yPtr, * widthPtr, heightPtr, and basePtr. * * Side effects: * None. * *---------------------------------------------------------------------- */ func XTkTextDLineInfo(tls *libc.TLS, textPtr uintptr, indexPtr uintptr, xPtr uintptr, yPtr uintptr, widthPtr uintptr, heightPtr uintptr, basePtr uintptr) (r int32) { /* Filled in with the baseline position, * measured as an offset down from *yPtr. */ var dInfoPtr, dlPtr uintptr var dlx, v1 int32 _, _, _, _ = dInfoPtr, dlPtr, dlx, v1 dInfoPtr = (*TTkText)(unsafe.Pointer(textPtr)).FdInfoPtr /* * Make sure that all of the screen layout information is up to date. */ if (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).Fflags&int32(DINFO_OUT_OF_DATE) != 0 { _UpdateDisplayInfo(tls, textPtr) } /* * Find the display line containing the desired index. */ dlPtr = _FindDLine(tls, textPtr, (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FdLinePtr, indexPtr) /* * Two cases shall be trapped here because the logic later really * needs dlPtr to be the display line containing indexPtr: * 1. if no display line contains the desired index (NULL dlPtr) * 2. if indexPtr is before the first display line, in which case * dlPtr currently points to the first display line */ if dlPtr == libc.UintptrFromInt32(0) || XTkTextIndexCmp(tls, dlPtr, indexPtr) > 0 { return -int32(1) } if (*TDLine)(unsafe.Pointer(dlPtr)).FchunkPtr != libc.UintptrFromInt32(0) { v1 = (*TTkTextDispChunk)(unsafe.Pointer((*TDLine)(unsafe.Pointer(dlPtr)).FchunkPtr)).Fx } else { v1 = 0 } dlx = v1 *(*int32)(unsafe.Pointer(xPtr)) = (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).Fx - (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FcurXPixelOffset + dlx *(*int32)(unsafe.Pointer(widthPtr)) = (*TDLine)(unsafe.Pointer(dlPtr)).Flength - dlx *(*int32)(unsafe.Pointer(yPtr)) = (*TDLine)(unsafe.Pointer(dlPtr)).Fy if (*TDLine)(unsafe.Pointer(dlPtr)).Fy+(*TDLine)(unsafe.Pointer(dlPtr)).Fheight > (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FmaxY { *(*int32)(unsafe.Pointer(heightPtr)) = (*TTextDInfo)(unsafe.Pointer(dInfoPtr)).FmaxY - (*TDLine)(unsafe.Pointer(dlPtr)).Fy } else { *(*int32)(unsafe.Pointer(heightPtr)) = (*TDLine)(unsafe.Pointer(dlPtr)).Fheight } *(*int32)(unsafe.Pointer(basePtr)) = (*TDLine)(unsafe.Pointer(dlPtr)).Fbaseline return 0 } /* * Get bounding-box information about an elided chunk. */ func _ElideBboxProc(tls *libc.TLS, dummy7555 uintptr, chunkPtr uintptr, dummy7557 TTcl_Size, y int32, dummy7561 int32, dummy7562 int32, xPtr uintptr, yPtr uintptr, widthPtr uintptr, heightPtr uintptr) { /* Gets filled in with height of character, in * pixels. */ var v1 int32 _ = v1 *(*int32)(unsafe.Pointer(xPtr)) = (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).Fx *(*int32)(unsafe.Pointer(yPtr)) = y v1 = libc.Int32FromInt32(0) *(*int32)(unsafe.Pointer(heightPtr)) = v1 *(*int32)(unsafe.Pointer(widthPtr)) = v1 } /* * Measure an elided chunk. */ func _ElideMeasureProc(tls *libc.TLS, dummy7584 uintptr, dummy7585 int32) (r TTcl_Size) { /* X-coordinate, in same coordinate system as * chunkPtr->x. */ return 0 } /* *-------------------------------------------------------------- * * TkTextCharLayoutProc -- * * This function is the "layoutProc" for character segments. * * Results: * If there is something to display for the chunk then a non-zero value * is returned and the fields of chunkPtr will be filled in (see the * declaration of TkTextDispChunk in tkText.h for details). If zero is * returned it means that no characters from this chunk fit in the * window. If -1 is returned it means that this segment just doesn't need * to be displayed (never happens for text). * * Side effects: * Memory is allocated to hold additional information about the chunk. * *-------------------------------------------------------------- */ func XTkTextCharLayoutProc(tls *libc.TLS, dummy7614 uintptr, dummy7615 uintptr, segPtr uintptr, byteOffset TTcl_Size, maxX int32, maxBytes TTcl_Size, noCharsYet int32, wrapMode TTkWrapMode, chunkPtr uintptr) (r int32) { bp := tls.Alloc(32) defer tls.Free(32) /* Structure to fill in with information about * this chunk. The x field has already been * set by the caller. */ var bytesThatFit TTcl_Size var chLen, count int32 var ciPtr, nextPtr, p uintptr var tkfont TTk_Font var _ /* ch at bp+16 */ int32 var _ /* fm at bp+4 */ TTk_FontMetrics var _ /* nextX at bp+0 */ int32 _, _, _, _, _, _, _ = bytesThatFit, chLen, ciPtr, count, nextPtr, p, tkfont /* * Figure out how many characters will fit in the space we've got. Include * the next character, even though it won't fit completely, if any of the * following is true: * (a) the chunk contains no characters and the display line contains no * characters yet (i.e. the line isn't wide enough to hold even a * single character). * (b) at least one pixel of the character is visible, we have not * already exceeded the character limit, and the next character is a * white space character. * In the specific case of 'word' wrapping mode however, include all space * characters following the characters that fit in the space we've got, * even if no pixel of them is visible. */ p = segPtr + 24 + uintptr(byteOffset) tkfont = (*TStyleValues)(unsafe.Pointer((*TTextStyle1)(unsafe.Pointer((*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FstylePtr)).FsValuePtr)).Ftkfont bytesThatFit = _CharChunkMeasureChars(tls, chunkPtr, p, int32(maxBytes), 0, -int32(1), (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).Fx, maxX, int32(TK_ISOLATE_END), bp) if bytesThatFit+int64(1) <= maxBytes { if bytesThatFit == 0 && noCharsYet != 0 { chLen = int32(libtcl9_0.XTcl_UtfToUniChar(tls, p, bp+16)) bytesThatFit = _CharChunkMeasureChars(tls, chunkPtr, p, chLen, 0, -int32(1), (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).Fx, -int32(1), 0, bp) } if *(*int32)(unsafe.Pointer(bp)) < maxX && (libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(p + uintptr(bytesThatFit)))) == int32(' ') || libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(p + uintptr(bytesThatFit)))) == int32('\t')) { /* * Space characters are funny, in that they are considered to fit * if there is at least one pixel of space left on the line. Just * give the space character whatever space is left. */ *(*int32)(unsafe.Pointer(bp)) = maxX bytesThatFit++ } if wrapMode == int32(TEXT_WRAPMODE_WORD) { for libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(p + uintptr(bytesThatFit)))) == int32(' ') { /* * Space characters that would go at the beginning of the * next line are allocated to the current line. This gives * the effect of trimming white spaces that would otherwise * be seen at the beginning of wrapped lines. * Note that testing for '\t' is useless here because the * chunk always includes at most one trailing \t, see * LayoutDLine. */ bytesThatFit++ } } if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(p + uintptr(bytesThatFit)))) == int32('\n') { /* * A newline character takes up no space, so if the previous * character fits then so does the newline. */ bytesThatFit++ } if bytesThatFit == 0 { return 0 } } XTk_GetFontMetrics(tls, tkfont, bp+4) /* * Fill in the chunk structure and allocate and initialize a CharInfo * structure. If the last character is a newline then don't bother to * display it. */ (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FdisplayProc = __ccgo_fp(_CharDisplayProc) (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FundisplayProc = __ccgo_fp(_CharUndisplayProc) (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FmeasureProc = __ccgo_fp(_CharMeasureProc) (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FbboxProc = __ccgo_fp(_CharBboxProc) (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FnumBytes = bytesThatFit (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FminAscent = (*(*TTk_FontMetrics)(unsafe.Pointer(bp + 4))).Fascent + (*TStyleValues)(unsafe.Pointer((*TTextStyle1)(unsafe.Pointer((*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FstylePtr)).FsValuePtr)).Foffset (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FminDescent = (*(*TTk_FontMetrics)(unsafe.Pointer(bp + 4))).Fdescent - (*TStyleValues)(unsafe.Pointer((*TTextStyle1)(unsafe.Pointer((*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FstylePtr)).FsValuePtr)).Foffset (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FminHeight = 0 (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).Fwidth = *(*int32)(unsafe.Pointer(bp)) - (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).Fx (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FbreakIndex = int64(-int32(1)) ciPtr = libtcl9_0.XTcl_Alloc(tls, uint64(libc.UintptrFromInt32(0)+8)+libc.Uint64FromInt32(1)+libc.Uint64FromInt64(bytesThatFit)) (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FclientData = ciPtr libc.Xmemcpy(tls, ciPtr+8, p, libc.Uint64FromInt64(bytesThatFit)) (*TCharInfo)(unsafe.Pointer(ciPtr)).FnumBytes = bytesThatFit if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(p + uintptr(bytesThatFit-int64(1))))) == int32('\n') { (*TCharInfo)(unsafe.Pointer(ciPtr)).FnumBytes-- } /* * Compute a break location. If we're in word wrap mode, a break can occur * after any space character, or at the end of the chunk if the next * segment (ignoring those with zero size) is not a character segment. */ if wrapMode != int32(TEXT_WRAPMODE_WORD) { (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FbreakIndex = (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FnumBytes } else { count = int32(bytesThatFit) p += uintptr(bytesThatFit - int64(1)) for { if !(count > 0) { break } /* * Don't use isspace(); effects are unpredictable and can lead to * odd word-wrapping problems on some platforms. Also don't use * Tcl_UniCharIsSpace here either, as it identifies non-breaking * spaces as places to break. What we actually want is only the * ASCII space characters, so use them explicitly... */ switch libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(p))) { case int32('\t'): fallthrough case int32('\n'): fallthrough case int32('\v'): fallthrough case int32('\f'): fallthrough case int32('\r'): fallthrough case int32(' '): (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FbreakIndex = int64(count) goto checkForNextChunk } goto _1 _1: ; count-- p-- } goto checkForNextChunk checkForNextChunk: ; if bytesThatFit+byteOffset == (*TTkTextSegment)(unsafe.Pointer(segPtr)).Fsize { nextPtr = (*TTkTextSegment)(unsafe.Pointer(segPtr)).FnextPtr for { if !(nextPtr != libc.UintptrFromInt32(0)) { break } if (*TTkTextSegment)(unsafe.Pointer(nextPtr)).Fsize != 0 { if (*TTkTextSegment)(unsafe.Pointer(nextPtr)).FtypePtr != uintptr(unsafe.Pointer(&XtkTextCharType)) { (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FbreakIndex = (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FnumBytes } break } goto _2 _2: ; nextPtr = (*TTkTextSegment)(unsafe.Pointer(nextPtr)).FnextPtr } } } return int32(1) } /* *--------------------------------------------------------------------------- * * CharChunkMeasureChars -- * * Determine the number of characters from a char chunk that will fit in * the given horizontal span. * * This is the same as MeasureChars (which see), but in the context of a * char chunk, i.e. on a higher level of abstraction. Use this function * whereever possible instead of plain MeasureChars, so that the right * context is used automatically. * * Results: * The return value is the number of bytes from the range of start to end * in source that fit in the span given by startX and maxX. *nextXPtr is * filled in with the x-coordinate at which the first character that * didn't fit would be drawn, if it were to be drawn. * * Side effects: * None. *-------------------------------------------------------------- */ func _CharChunkMeasureChars(tls *libc.TLS, chunkPtr uintptr, chars uintptr, charsLen int32, start int32, end int32, startX int32, maxX int32, flags int32, nextXPtr uintptr) (r TTcl_Size) { /* The function puts the newly calculated * right border x-position of the span * here. */ var ciPtr uintptr var tkfont TTk_Font _, _ = ciPtr, tkfont tkfont = (*TStyleValues)(unsafe.Pointer((*TTextStyle1)(unsafe.Pointer((*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FstylePtr)).FsValuePtr)).Ftkfont ciPtr = (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FclientData if chars == libc.UintptrFromInt32(0) { chars = ciPtr + 8 charsLen = int32((*TCharInfo)(unsafe.Pointer(ciPtr)).FnumBytes) } if end == -int32(1) { end = charsLen } return _MeasureChars(tls, tkfont, chars, charsLen, start, end-start, startX, maxX, flags, nextXPtr) } /* *-------------------------------------------------------------- * * CharDisplayProc -- * * This function is called to display a character chunk on the screen or * in an off-screen pixmap. * * Results: * None. * * Side effects: * Graphics are drawn. * *-------------------------------------------------------------- */ func _CharDisplayProc(tls *libc.TLS, dummy7969 uintptr, chunkPtr uintptr, x int32, y int32, dummy7976 int32, baseline int32, display uintptr, dst TDrawable, dummy7980 int32) { bp := tls.Alloc(16) defer tls.Free(16) /* Y-coordinate in text window that * corresponds to y. */ var ciPtr, sValuePtr, string1, stylePtr uintptr var numBytes, offsetBytes TTcl_Size var _ /* fm at bp+4 */ TTk_FontMetrics var _ /* offsetX at bp+0 */ int32 _, _, _, _, _, _ = ciPtr, numBytes, offsetBytes, sValuePtr, string1, stylePtr ciPtr = (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FclientData if x+(*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).Fwidth <= 0 { /* * The chunk is off-screen. */ return } numBytes = (*TCharInfo)(unsafe.Pointer(ciPtr)).FnumBytes string1 = ciPtr + 8 stylePtr = (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FstylePtr sValuePtr = (*TTextStyle)(unsafe.Pointer(stylePtr)).FsValuePtr /* * If the text sticks out way to the left of the window, skip over the * characters that aren't in the visible part of the window. This is * essential if x is very negative (such as less than 32K); otherwise * overflow problems will occur in servers that use 16-bit arithmetic, * like X. */ *(*int32)(unsafe.Pointer(bp)) = x offsetBytes = 0 if x < 0 { offsetBytes = _CharChunkMeasureChars(tls, chunkPtr, libc.UintptrFromInt32(0), 0, 0, -int32(1), x, 0, 0, bp) } /* * Draw the text, underline, and overstrike for this chunk. */ if !((*TStyleValues)(unsafe.Pointer(sValuePtr)).Felide != 0) && numBytes > offsetBytes && (*TTextStyle)(unsafe.Pointer(stylePtr)).FfgGC != libc.UintptrFromInt32(0) { string1 += uintptr(offsetBytes) numBytes -= offsetBytes if numBytes > 0 && libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(string1 + uintptr(numBytes-int64(1))))) == int32('\t') { numBytes-- } XTk_DrawChars(tls, display, dst, (*TTextStyle)(unsafe.Pointer(stylePtr)).FfgGC, (*TStyleValues)(unsafe.Pointer(sValuePtr)).Ftkfont, string1, numBytes, *(*int32)(unsafe.Pointer(bp)), y+baseline-(*TStyleValues)(unsafe.Pointer(sValuePtr)).Foffset) if (*TStyleValues)(unsafe.Pointer(sValuePtr)).Funderline != 0 { XTk_UnderlineChars(tls, display, dst, (*TTextStyle)(unsafe.Pointer(stylePtr)).FulGC, (*TStyleValues)(unsafe.Pointer(sValuePtr)).Ftkfont, string1, *(*int32)(unsafe.Pointer(bp)), y+baseline-(*TStyleValues)(unsafe.Pointer(sValuePtr)).Foffset, 0, numBytes) } if (*TStyleValues)(unsafe.Pointer(sValuePtr)).Foverstrike != 0 { XTk_GetFontMetrics(tls, (*TStyleValues)(unsafe.Pointer(sValuePtr)).Ftkfont, bp+4) XTk_UnderlineChars(tls, display, dst, (*TTextStyle)(unsafe.Pointer(stylePtr)).FovGC, (*TStyleValues)(unsafe.Pointer(sValuePtr)).Ftkfont, string1, *(*int32)(unsafe.Pointer(bp)), y+baseline-(*TStyleValues)(unsafe.Pointer(sValuePtr)).Foffset-(*(*TTk_FontMetrics)(unsafe.Pointer(bp + 4))).Fdescent-(*(*TTk_FontMetrics)(unsafe.Pointer(bp + 4))).Fascent*int32(3)/int32(10), 0, numBytes) } } } /* *-------------------------------------------------------------- * * CharUndisplayProc -- * * This function is called when a character chunk is no longer going to * be displayed. It frees up resources that were allocated to display the * chunk. * * Results: * None. * * Side effects: * Memory and other resources get freed. * *-------------------------------------------------------------- */ func _CharUndisplayProc(tls *libc.TLS, dummy8132 uintptr, chunkPtr uintptr) { /* Chunk that is about to be freed. */ var ciPtr uintptr _ = ciPtr ciPtr = (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FclientData if ciPtr != 0 { libtcl9_0.XTcl_Free(tls, ciPtr) (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FclientData = libc.UintptrFromInt32(0) } } /* *-------------------------------------------------------------- * * CharMeasureProc -- * * This function is called to determine which character in a character * chunk lies over a given x-coordinate. * * Results: * The return value is the index *within the chunk* of the character that * covers the position given by "x". * * Side effects: * None. * *-------------------------------------------------------------- */ func _CharMeasureProc(tls *libc.TLS, chunkPtr uintptr, x int32) (r TTcl_Size) { bp := tls.Alloc(16) defer tls.Free(16) /* X-coordinate, in same coordinate system as * chunkPtr->x. */ var _ /* endX at bp+0 */ int32 return _CharChunkMeasureChars(tls, chunkPtr, libc.UintptrFromInt32(0), 0, 0, int32((*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FnumBytes-int64(1)), (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).Fx, x, 0, bp) /* CHAR OFFSET */ } /* *-------------------------------------------------------------- * * CharBboxProc -- * * This function is called to compute the bounding box of the area * occupied by a single character. * * Results: * There is no return value. *xPtr and *yPtr are filled in with the * coordinates of the upper left corner of the character, and *widthPtr * and *heightPtr are filled in with the dimensions of the character in * pixels. Note: not all of the returned bbox is necessarily visible on * the screen (the rightmost part might be off-screen to the right, and * the bottommost part might be off-screen to the bottom). * * Side effects: * None. * *-------------------------------------------------------------- */ func _CharBboxProc(tls *libc.TLS, dummy8221 uintptr, chunkPtr uintptr, byteIndex TTcl_Size, y int32, dummy8227 int32, baseline int32, xPtr uintptr, yPtr uintptr, widthPtr uintptr, heightPtr uintptr) { /* Gets filled in with height of character, in * pixels. */ var ciPtr uintptr var maxX int32 _, _ = ciPtr, maxX ciPtr = (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FclientData maxX = (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).Fwidth + (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).Fx _CharChunkMeasureChars(tls, chunkPtr, libc.UintptrFromInt32(0), 0, 0, int32(byteIndex), (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).Fx, -int32(1), 0, xPtr) if byteIndex == (*TCharInfo)(unsafe.Pointer(ciPtr)).FnumBytes { /* * This situation only happens if the last character in a line is a * space character, in which case it absorbs all of the extra space in * the line (see TkTextCharLayoutProc). */ *(*int32)(unsafe.Pointer(widthPtr)) = maxX - *(*int32)(unsafe.Pointer(xPtr)) } else { if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(ciPtr + 8 + uintptr(byteIndex)))) == int32('\t') && byteIndex == (*TCharInfo)(unsafe.Pointer(ciPtr)).FnumBytes-int64(1) { /* * The desired character is a tab character that terminates a chunk; * give it all the space left in the chunk. */ *(*int32)(unsafe.Pointer(widthPtr)) = maxX - *(*int32)(unsafe.Pointer(xPtr)) } else { _CharChunkMeasureChars(tls, chunkPtr, libc.UintptrFromInt32(0), 0, int32(byteIndex), int32(byteIndex+int64(1)), *(*int32)(unsafe.Pointer(xPtr)), -int32(1), 0, widthPtr) if *(*int32)(unsafe.Pointer(widthPtr)) > maxX { *(*int32)(unsafe.Pointer(widthPtr)) = maxX - *(*int32)(unsafe.Pointer(xPtr)) } else { *(*int32)(unsafe.Pointer(widthPtr)) -= *(*int32)(unsafe.Pointer(xPtr)) } } } *(*int32)(unsafe.Pointer(yPtr)) = y + baseline - (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FminAscent *(*int32)(unsafe.Pointer(heightPtr)) = (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FminAscent + (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FminDescent } /* *---------------------------------------------------------------------- * * AdjustForTab -- * * This function is called to move a series of chunks right in order to * align them with a tab stop. * * Results: * None. * * Side effects: * The width of chunkPtr gets adjusted so that it absorbs the extra space * due to the tab. The x locations in all the chunks after chunkPtr are * adjusted rightward to align with the tab stop given by tabArrayPtr and * index. * *---------------------------------------------------------------------- */ func _AdjustForTab(tls *libc.TLS, textPtr uintptr, tabArrayPtr uintptr, index int32, chunkPtr uintptr) { bp := tls.Alloc(16) defer tls.Free(16) /* Chunk whose last character is the tab; the * following chunks contain information to be * shifted right. */ var alignment TTkTextTabAlign var chunkPtr2, ciPtr, decimalChunkPtr, p uintptr var decimal, delta, desired, gotDigit, i, tabWidth, tabX, width, x, v2 int32 var _ /* curX at bp+4 */ int32 var _ /* spaceWidth at bp+0 */ int32 _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = alignment, chunkPtr2, ciPtr, decimal, decimalChunkPtr, delta, desired, gotDigit, i, p, tabWidth, tabX, width, x, v2 if (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FnextPtr == libc.UintptrFromInt32(0) { /* * Nothing after the actual tab; just return. */ return } x = (*TTkTextDispChunk1)(unsafe.Pointer((*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FnextPtr)).Fx /* * If no tab information has been given, assuming tab stops are at 8 * average-sized characters. Still ensure we respect the tabular versus * wordprocessor tab style. */ if tabArrayPtr == libc.UintptrFromInt32(0) || (*TTkTextTabArray)(unsafe.Pointer(tabArrayPtr)).FnumTabs == 0 { /* * No tab information has been given, so use the default * interpretation of tabs. */ if (*TTkText)(unsafe.Pointer(textPtr)).FtabStyle == int32(TK_TEXT_TABSTYLE_TABULAR) { tabWidth = XTk_TextWidth(tls, (*TTkText)(unsafe.Pointer(textPtr)).Ftkfont, __ccgo_ts+10533, int64(1)) * int32(8) if tabWidth == 0 { tabWidth = int32(1) } desired = tabWidth * (index + int32(1)) } else { desired = _NextTabStop(tls, (*TTkText)(unsafe.Pointer(textPtr)).Ftkfont, x, 0) } goto update } if index < (*TTkTextTabArray)(unsafe.Pointer(tabArrayPtr)).FnumTabs { alignment = (*(*TTkTextTab)(unsafe.Pointer(tabArrayPtr + 24 + uintptr(index)*8))).Falignment tabX = (*(*TTkTextTab)(unsafe.Pointer(tabArrayPtr + 24 + uintptr(index)*8))).Flocation } else { /* * Ran out of tab stops; compute a tab position by extrapolating from * the last two tab positions. */ tabX = int32((*TTkTextTabArray)(unsafe.Pointer(tabArrayPtr)).FlastTab + float64(float64(index+libc.Int32FromInt32(1)-(*TTkTextTabArray)(unsafe.Pointer(tabArrayPtr)).FnumTabs)*(*TTkTextTabArray)(unsafe.Pointer(tabArrayPtr)).FtabIncrement) + libc.Float64FromFloat64(0.5)) alignment = (*(*TTkTextTab)(unsafe.Pointer(tabArrayPtr + 24 + uintptr((*TTkTextTabArray)(unsafe.Pointer(tabArrayPtr)).FnumTabs-int32(1))*8))).Falignment } if alignment == int32(LEFT1) { desired = tabX goto update } if alignment == int32(CENTER) || alignment == int32(RIGHT1) { /* * Compute the width of all the information in the tab group, then use * it to pick a desired location. */ width = 0 chunkPtr2 = (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FnextPtr for { if !(chunkPtr2 != libc.UintptrFromInt32(0)) { break } width += (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr2)).Fwidth goto _1 _1: ; chunkPtr2 = (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr2)).FnextPtr } if alignment == int32(CENTER) { desired = tabX - width/int32(2) } else { desired = tabX - width } goto update } /* * Must be numeric alignment. Search through the text to be tabbed, * looking for the last , or . before the first character that isn't a * number, comma, period, or sign. */ decimalChunkPtr = libc.UintptrFromInt32(0) v2 = libc.Int32FromInt32(0) gotDigit = v2 decimal = v2 chunkPtr2 = (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FnextPtr for { if !(chunkPtr2 != libc.UintptrFromInt32(0)) { break } if (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr2)).FdisplayProc != __ccgo_fp(_CharDisplayProc) { goto _3 } ciPtr = (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr2)).FclientData p = ciPtr + 8 i = libc.Int32FromInt32(0) for { if !(int64(i) < (*TCharInfo)(unsafe.Pointer(ciPtr)).FnumBytes) { break } if libc.BoolInt32(uint32(*(*uint8)(unsafe.Pointer(p)))-uint32('0') < uint32(10)) != 0 { gotDigit = int32(1) } else { if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(p))) == int32('.') || libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(p))) == int32(',') { decimal = int32(int64(p) - T__predefined_ptrdiff_t(ciPtr+8)) decimalChunkPtr = chunkPtr2 } else { if gotDigit != 0 { if decimalChunkPtr == libc.UintptrFromInt32(0) { decimal = int32(int64(p) - T__predefined_ptrdiff_t(ciPtr+8)) decimalChunkPtr = chunkPtr2 } goto endOfNumber } } } goto _4 _4: ; p++ i++ } goto _3 _3: ; chunkPtr2 = (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr2)).FnextPtr } goto endOfNumber endOfNumber: ; if decimalChunkPtr != libc.UintptrFromInt32(0) { ciPtr = (*TTkTextDispChunk)(unsafe.Pointer(decimalChunkPtr)).FclientData _CharChunkMeasureChars(tls, decimalChunkPtr, libc.UintptrFromInt32(0), 0, 0, decimal, (*TTkTextDispChunk)(unsafe.Pointer(decimalChunkPtr)).Fx, -int32(1), 0, bp+4) desired = tabX - (*(*int32)(unsafe.Pointer(bp + 4)) - x) goto update } /* * There wasn't a decimal point. Right justify the text. */ width = 0 chunkPtr2 = (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FnextPtr for { if !(chunkPtr2 != libc.UintptrFromInt32(0)) { break } width += (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr2)).Fwidth goto _5 _5: ; chunkPtr2 = (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr2)).FnextPtr } desired = tabX - width /* * Shift all of the chunks to the right so that the left edge is at the * desired location, then expand the chunk containing the tab. Be sure * that the tab occupies at least the width of a space character. */ goto update update: ; delta = desired - x _MeasureChars(tls, (*TTkText)(unsafe.Pointer(textPtr)).Ftkfont, __ccgo_ts+634, int32(1), 0, int32(1), 0, -int32(1), 0, bp) if delta < *(*int32)(unsafe.Pointer(bp)) { delta = *(*int32)(unsafe.Pointer(bp)) } chunkPtr2 = (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FnextPtr for { if !(chunkPtr2 != libc.UintptrFromInt32(0)) { break } *(*int32)(unsafe.Pointer(chunkPtr2)) += delta goto _6 _6: ; chunkPtr2 = (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr2)).FnextPtr } *(*int32)(unsafe.Pointer(chunkPtr + 76)) += delta } /* *---------------------------------------------------------------------- * * SizeOfTab -- * * This returns an estimate of the amount of white space that will be * consumed by a tab. * * Results: * The return value is the minimum number of pixels that will be occupied * by the next tab of tabArrayPtr, assuming that the current position on * the line is x and the end of the line is maxX. The 'next tab' is * determined by a combination of the current position (x) which it must * be equal to or beyond, and the tab count in indexPtr. * * For numeric tabs, this is a conservative estimate. The return value is * always >= 0. * * Side effects: * None. * *---------------------------------------------------------------------- */ func _SizeOfTab(tls *libc.TLS, textPtr uintptr, tabStyle TTkTextTabStyle, tabArrayPtr uintptr, indexPtr uintptr, x int32, maxX int32) (r int32) { bp := tls.Alloc(16) defer tls.Free(16) /* X-location of pixel just past the right * edge of the line. */ var alignment TTkTextTabAlign var index, result, tabWidth, tabX int32 var _ /* spaceWidth at bp+0 */ int32 _, _, _, _, _ = alignment, index, result, tabWidth, tabX index = *(*int32)(unsafe.Pointer(indexPtr)) if tabArrayPtr == libc.UintptrFromInt32(0) || (*TTkTextTabArray)(unsafe.Pointer(tabArrayPtr)).FnumTabs == 0 { /* * We're using a default tab spacing of 8 characters. */ tabWidth = XTk_TextWidth(tls, (*TTkText)(unsafe.Pointer(textPtr)).Ftkfont, __ccgo_ts+10533, int64(1)) * int32(8) if tabWidth == 0 { tabWidth = int32(1) } } else { tabWidth = 0 /* Avoid compiler error. */ } for cond := true; cond; cond = tabX <= x && tabStyle == int32(TK_TEXT_TABSTYLE_WORDPROCESSOR) { /* * We were given the count before this tab, so increment it first. */ index++ if tabArrayPtr == libc.UintptrFromInt32(0) || (*TTkTextTabArray)(unsafe.Pointer(tabArrayPtr)).FnumTabs == 0 { /* * We're using a default tab spacing calculated above. */ tabX = tabWidth * (index + int32(1)) alignment = int32(LEFT1) } else { if index < (*TTkTextTabArray)(unsafe.Pointer(tabArrayPtr)).FnumTabs { tabX = (*(*TTkTextTab)(unsafe.Pointer(tabArrayPtr + 24 + uintptr(index)*8))).Flocation alignment = (*(*TTkTextTab)(unsafe.Pointer(tabArrayPtr + 24 + uintptr(index)*8))).Falignment } else { /* * Ran out of tab stops; compute a tab position by extrapolating. */ tabX = int32((*TTkTextTabArray)(unsafe.Pointer(tabArrayPtr)).FlastTab + float64(float64(index+libc.Int32FromInt32(1)-(*TTkTextTabArray)(unsafe.Pointer(tabArrayPtr)).FnumTabs)*(*TTkTextTabArray)(unsafe.Pointer(tabArrayPtr)).FtabIncrement) + libc.Float64FromFloat64(0.5)) alignment = (*(*TTkTextTab)(unsafe.Pointer(tabArrayPtr + 24 + uintptr((*TTkTextTabArray)(unsafe.Pointer(tabArrayPtr)).FnumTabs-int32(1))*8))).Falignment } } /* * If this tab stop is before the current x position, then we have two * cases: * * With 'wordprocessor' style tabs, we must obviously continue until * we reach the text tab stop. * * With 'tabular' style tabs, we always use the index'th tab stop. */ } /* * Inform our caller of how many tab stops we've used up. */ *(*int32)(unsafe.Pointer(indexPtr)) = index if alignment == int32(CENTER) { /* * Be very careful in the arithmetic below, because maxX may be the * largest positive number: watch out for integer overflow. */ if maxX-tabX < tabX-x { result = maxX - x - int32(2)*(maxX-tabX) } else { result = 0 } goto done } if alignment == int32(RIGHT1) { result = 0 goto done } /* * Note: this treats NUMERIC alignment the same as LEFT alignment, which * is somewhat conservative. However, it's pretty tricky at this point to * figure out exactly where the damn decimal point will be. */ if tabX > x { result = tabX - x } else { result = 0 } goto done done: ; _MeasureChars(tls, (*TTkText)(unsafe.Pointer(textPtr)).Ftkfont, __ccgo_ts+634, int32(1), 0, int32(1), 0, -int32(1), 0, bp) if result < *(*int32)(unsafe.Pointer(bp)) { result = *(*int32)(unsafe.Pointer(bp)) } return result } /* *--------------------------------------------------------------------------- * * NextTabStop -- * * Given the current position, determine where the next default tab stop * would be located. This function is called when the current chunk in * the text has no tabs defined and so the default tab spacing for the * font should be used, provided we are using wordprocessor style tabs. * * Results: * The location in pixels of the next tab stop. * * Side effects: * None. * *--------------------------------------------------------------------------- */ func _NextTabStop(tls *libc.TLS, tkfont TTk_Font, x int32, tabOrigin int32) (r int32) { /* The origin for tab stops. May be non-zero * if text has been scrolled. */ var rem, tabWidth int32 _, _ = rem, tabWidth tabWidth = XTk_TextWidth(tls, tkfont, __ccgo_ts+10533, int64(1)) * int32(8) if tabWidth == 0 { tabWidth = int32(1) } x += tabWidth rem = (x - tabOrigin) % tabWidth if rem < 0 { rem += tabWidth } x -= rem return x } /* *--------------------------------------------------------------------------- * * MeasureChars -- * * Determine the number of characters from the string that will fit in * the given horizontal span. The measurement is done under the * assumption that Tk_DrawChars will be used to actually display the * characters. * * If tabs are encountered in the string, they will be ignored (they * should only occur as last character of the string anyway). * * If a newline is encountered in the string, the line will be broken at * that point. * * Results: * The return value is the number of bytes from the range of start to end * in source that fit in the span given by startX and maxX. *nextXPtr is * filled in with the x-coordinate at which the first character that * didn't fit would be drawn, if it were to be drawn. * * Side effects: * None. * *-------------------------------------------------------------- */ func _MeasureChars(tls *libc.TLS, tkfont TTk_Font, source uintptr, maxBytes int32, rangeStart int32, rangeLength int32, startX int32, maxX int32, flags int32, nextXPtr uintptr) (r TTcl_Size) { bp := tls.Alloc(16) defer tls.Free(16) /* Return x-position of terminating character * here. */ var ch, curX, v2 int32 var end, special, start uintptr var _ /* width at bp+0 */ int32 _, _, _, _, _, _ = ch, curX, end, special, start, v2 ch = 0 curX = startX start = source + uintptr(rangeStart) end = start + uintptr(rangeLength) special = start for start < end { if start >= special { /* * Find the next special character in the string. */ special = start for { if !(special < end) { break } ch = libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(special))) if ch == int32('\t') || ch == int32('\n') { break } goto _1 _1: ; special++ } } /* * Special points at the next special character (or the end of the * string). Process characters between start and special. */ if maxX >= 0 && curX >= maxX { break } _ = maxBytes if maxX >= 0 { v2 = maxX - curX } else { v2 = -int32(1) } start += uintptr(XTk_MeasureChars(tls, tkfont, start, int64(special)-int64(start), v2, flags, bp)) curX += *(*int32)(unsafe.Pointer(bp)) if start < special { /* * No more chars fit in line. */ break } if special < end { if ch != int32('\t') { break } start++ } } *(*int32)(unsafe.Pointer(nextXPtr)) = curX return int64(start) - int64(source+uintptr(rangeStart)) } /* *---------------------------------------------------------------------- * * TextGetScrollInfoObj -- * * This function is invoked to parse "xview" and "yview" scrolling * commands for text widgets using the new scrolling command syntax * ("moveto" or "scroll" options). It extends the public * Tk_GetScrollInfoObj function with the addition of "pixels" as a valid * unit alongside "pages" and "units". It is a shame the core API isn't * more flexible in this regard. * * Results: * The return value is either TKTEXT_SCROLL_MOVETO, TKTEXT_SCROLL_PAGES, * TKTEXT_SCROLL_UNITS, TKTEXT_SCROLL_PIXELS or TKTEXT_SCROLL_ERROR. This * indicates whether the command was successfully parsed and what form * the command took. If TKTEXT_SCROLL_MOVETO, *dblPtr is filled in with * the desired position; if TKTEXT_SCROLL_PAGES, TKTEXT_SCROLL_PIXELS or * TKTEXT_SCROLL_UNITS, *intPtr is filled in with the number of * pages/pixels/lines to move (may be negative); if TKTEXT_SCROLL_ERROR, * the interp's result contains an error message. * * Side effects: * None. * *---------------------------------------------------------------------- */ func _TextGetScrollInfoObj(tls *libc.TLS, interp uintptr, textPtr uintptr, objc TTcl_Size, objv uintptr, dblPtr uintptr, intPtr uintptr) (r int32) { bp := tls.Alloc(16) defer tls.Free(16) /* Filled in with number of pages or lines or * pixels to scroll, if any. */ var v1, v2 float64 var _ /* d at bp+8 */ float64 var _ /* index at bp+0 */ int32 _, _ = v1, v2 if libtcl9_0.XTcl_GetIndexFromObjStruct(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), uintptr(unsafe.Pointer(&_subcommands)), libc.Int64FromUint64(libc.Uint64FromInt64(8)), __ccgo_ts+2689, libc.Int32FromInt32(0)|libc.Int32FromUint64(libc.Uint64FromInt64(4)< libc.Float64FromInt32(0) { v1 = libc.Xceil(tls, *(*float64)(unsafe.Pointer(bp + 8))) } else { v1 = libc.Xfloor(tls, *(*float64)(unsafe.Pointer(bp + 8))) } *(*int32)(unsafe.Pointer(intPtr)) = int32(v1) if dblPtr != 0 { *(*float64)(unsafe.Pointer(dblPtr)) = *(*float64)(unsafe.Pointer(bp + 8)) } return int32(TKTEXT_SCROLL_PAGES) case 1: if XTk_GetPixelsFromObj(tls, interp, (*TTkText)(unsafe.Pointer(textPtr)).Ftkwin, *(*uintptr)(unsafe.Pointer(objv + 3*8)), intPtr) != TCL_OK { return int32(TKTEXT_SCROLL_ERROR) } if dblPtr != 0 { *(*float64)(unsafe.Pointer(dblPtr)) = float64(*(*int32)(unsafe.Pointer(intPtr))) } return int32(TKTEXT_SCROLL_PIXELS) case 2: if libtcl9_0.XTcl_GetDoubleFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 3*8)), bp+8) != TCL_OK { return int32(TKTEXT_SCROLL_ERROR) } if *(*float64)(unsafe.Pointer(bp + 8)) > libc.Float64FromInt32(0) { v2 = libc.Xceil(tls, *(*float64)(unsafe.Pointer(bp + 8))) } else { v2 = libc.Xfloor(tls, *(*float64)(unsafe.Pointer(bp + 8))) } *(*int32)(unsafe.Pointer(intPtr)) = int32(v2) if dblPtr != 0 { *(*float64)(unsafe.Pointer(dblPtr)) = *(*float64)(unsafe.Pointer(bp + 8)) } return int32(TKTEXT_SCROLL_UNITS) } } libtcl9_0.XTcl_Panic(tls, __ccgo_ts+39667, 0) return int32(TKTEXT_SCROLL_ERROR) } var _subcommands = [3]uintptr{ 0: __ccgo_ts + 17015, 1: __ccgo_ts + 17083, 2: libc.UintptrFromInt32(0), } var _units = [4]uintptr{ 0: __ccgo_ts + 17116, 1: __ccgo_ts + 6513, 2: __ccgo_ts + 17122, 3: libc.UintptrFromInt32(0), } type TDLine1 = struct { Findex TTkTextIndex FbyteCount int32 FlogicalLinesMerged int32 Fy int32 FoldY int32 Fheight int32 Fbaseline int32 FspaceAbove int32 FspaceBelow int32 FlMarginColor TTk_3DBorder FlMarginWidth int32 FrMarginColor TTk_3DBorder FrMarginWidth int32 Flength int32 FchunkPtr uintptr FnextPtr uintptr Fflags int32 } type TTextDInfo1 = struct { FstyleTable TTcl_HashTable FdLinePtr uintptr FtopPixelOffset int32 FnewTopPixelOffset int32 FcopyGC TGC FscrollGC TGC Fx int32 Fy int32 FmaxX int32 FmaxY int32 FtopOfEof int32 FnewXPixelOffset int32 FcurXPixelOffset int32 FmaxLength int32 FxScrollFirst float64 FxScrollLast float64 FyScrollFirst float64 FyScrollLast float64 FscanMarkXPixel int32 FscanMarkX int32 FscanTotalYScroll int32 FscanMarkY int32 FdLinesInvalidated int32 Fflags int32 FlineMetricUpdateEpoch int32 FcurrentMetricUpdateLine int32 FmetricIndex TTkTextIndex FmetricPixelHeight int32 FmetricEpoch TTcl_Size FlastMetricUpdateLine int32 FlineUpdateTimer TTcl_TimerToken FscrollbarTimer TTcl_TimerToken } type TTextStyle1 = struct { FrefCount TTcl_Size FbgGC TGC FfgGC TGC FulGC TGC FovGC TGC FsValuePtr uintptr FhPtr uintptr } func init() { p := unsafe.Pointer(&XtkTextEmbImageType) *(*uintptr)(unsafe.Add(p, 24)) = __ccgo_fp(_EmbImageDeleteProc) *(*uintptr)(unsafe.Add(p, 32)) = __ccgo_fp(_EmbImageCleanupProc) *(*uintptr)(unsafe.Add(p, 48)) = __ccgo_fp(_EmbImageLayoutProc) *(*uintptr)(unsafe.Add(p, 56)) = __ccgo_fp(_EmbImageCheckProc) } /* * Definitions for alignment values: */ var _alignStrings = [5]uintptr{ 0: __ccgo_ts + 47514, 1: __ccgo_ts + 15099, 2: __ccgo_ts + 10959, 3: __ccgo_ts + 15106, 4: libc.UintptrFromInt32(0), } /* * Information used for parsing image configuration options: */ var _optionSpecs9 = [6]TTk_OptionSpec{ 0: { Ftype1: int32(TK_OPTION_STRING_TABLE), FoptionName: __ccgo_ts + 47523, FdefValue: __ccgo_ts + 10959, FobjOffset: int64(-libc.Int32FromInt32(1)), FinternalOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 64)), FclientData: uintptr(unsafe.Pointer(&_alignStrings)), }, 1: { Ftype1: int32(TK_OPTION_PIXELS), FoptionName: __ccgo_ts + 12320, FdefValue: __ccgo_ts + 10533, FobjOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 48)), FinternalOffset: int64(-libc.Int32FromInt32(1)), }, 2: { Ftype1: int32(TK_OPTION_PIXELS), FoptionName: __ccgo_ts + 12326, FdefValue: __ccgo_ts + 10533, FobjOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 56)), FinternalOffset: int64(-libc.Int32FromInt32(1)), }, 3: { Ftype1: int32(TK_OPTION_STRING), FoptionName: __ccgo_ts + 20294, FobjOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 16)), FinternalOffset: int64(-libc.Int32FromInt32(1)), Fflags: int32(TCL_NULL_OK), }, 4: { Ftype1: int32(TK_OPTION_STRING), FoptionName: __ccgo_ts + 19198, FobjOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 24)), FinternalOffset: int64(-libc.Int32FromInt32(1)), Fflags: int32(TCL_NULL_OK), }, 5: { Ftype1: int32(TK_OPTION_END), }, } /* *-------------------------------------------------------------- * * TkTextImageCmd -- * * This function implements the "image" widget command for text widgets. * See the user documentation for details on what it does. * * Results: * A standard Tcl result or error. * * Side effects: * See the user documentation. * *-------------------------------------------------------------- */ func XTkTextImageCmd(tls *libc.TLS, textPtr uintptr, interp uintptr, objc TTcl_Size, objv uintptr) (r int32) { bp := tls.Alloc(144) defer tls.Free(144) /* Argument objects. Someone else has already * parsed this command enough to know that * objv[1] is "image". */ var eiPtr, hPtr, objPtr, objPtr1, resultObj, v1, v2, v4 uintptr var lineIndex int32 var _ /* idx at bp+0 */ int32 var _ /* index at bp+8 */ TTkTextIndex var _ /* index2 at bp+40 */ TTkTextIndex var _ /* search at bp+72 */ TTcl_HashSearch _, _, _, _, _, _, _, _, _ = eiPtr, hPtr, lineIndex, objPtr, objPtr1, resultObj, v1, v2, v4 if objc < int64(3) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(2), objv, __ccgo_ts+4953) return int32(TCL_ERROR) } if libtcl9_0.XTcl_GetIndexFromObjStruct(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), uintptr(unsafe.Pointer(&_optionStrings24)), libc.Int64FromUint64(libc.Uint64FromInt64(8)), __ccgo_ts+2689, libc.Int32FromInt32(0)|libc.Int32FromUint64(libc.Uint64FromInt64(4)< maxX-(*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).Fx && !(noCharsYet != 0) && (*TTkText)(unsafe.Pointer(textPtr)).FwrapMode != int32(TEXT_WRAPMODE_NONE) { return 0 } /* * Fill in the chunk structure. */ (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FdisplayProc = __ccgo_fp(_EmbImageDisplayProc) (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FundisplayProc = libc.UintptrFromInt32(0) (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FmeasureProc = libc.UintptrFromInt32(0) (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FbboxProc = __ccgo_fp(_EmbImageBboxProc) (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FnumBytes = int64(1) if (*(*TTkTextEmbImage)(unsafe.Pointer(eiPtr + 24))).Falign == int32(TK_ALIGN_BASELINE) { (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FminAscent = *(*int32)(unsafe.Pointer(bp + 4)) - *(*int32)(unsafe.Pointer(bp + 12)) (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FminDescent = *(*int32)(unsafe.Pointer(bp + 12)) (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FminHeight = 0 } else { (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FminAscent = 0 (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FminDescent = 0 (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FminHeight = *(*int32)(unsafe.Pointer(bp + 4)) } (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).Fwidth = *(*int32)(unsafe.Pointer(bp)) (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FbreakIndex = int64(-int32(1)) (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FbreakIndex = int64(1) (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FclientData = eiPtr (*(*TTkTextEmbImage)(unsafe.Pointer(eiPtr + 24))).FchunkCount += int32(1) return int32(1) } /* *-------------------------------------------------------------- * * EmbImageCheckProc -- * * This function is invoked by the B-tree code to perform consistency * checks on embedded images. * * Results: * None. * * Side effects: * The function panics if it detects anything wrong with the embedded * image. * *-------------------------------------------------------------- */ func _EmbImageCheckProc(tls *libc.TLS, eiPtr uintptr, dummy610 uintptr) { bp := tls.Alloc(16) defer tls.Free(16) /* Line containing segment. */ if (*TTkTextSegment)(unsafe.Pointer(eiPtr)).FnextPtr == libc.UintptrFromInt32(0) { libtcl9_0.XTcl_Panic(tls, __ccgo_ts+47722, 0) } if (*TTkTextSegment)(unsafe.Pointer(eiPtr)).Fsize != int64(1) { libtcl9_0.XTcl_Panic(tls, __ccgo_ts+47780, libc.VaList(bp+8, int32((*TTkTextSegment)(unsafe.Pointer(eiPtr)).Fsize))) } } /* *-------------------------------------------------------------- * * EmbImageDisplayProc -- * * This function is invoked by the text displaying code when it is time * to actually draw an embedded image chunk on the screen. * * Results: * None. * * Side effects: * The embedded image gets moved to the correct location and drawn onto * the display. * *-------------------------------------------------------------- */ func _EmbImageDisplayProc(tls *libc.TLS, textPtr uintptr, chunkPtr uintptr, x int32, y int32, lineHeight int32, baseline int32, dummy651 uintptr, dst TDrawable, dummy653 int32) { bp := tls.Alloc(16) defer tls.Free(16) /* Y-coordinate in text window that * corresponds to y. */ var eiPtr uintptr var image TTk_Image var imageX int32 var _ /* height at bp+12 */ int32 var _ /* imageY at bp+4 */ int32 var _ /* lineX at bp+0 */ int32 var _ /* width at bp+8 */ int32 _, _, _ = eiPtr, image, imageX eiPtr = (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FclientData image = (*(*TTkTextEmbImage)(unsafe.Pointer(eiPtr + 24))).Fimage if image == libc.UintptrFromInt32(0) { return } if x+(*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).Fwidth <= 0 { return } /* * Compute the image's location and size in the text widget, taking into * account the align value for the image. */ _EmbImageBboxProc(tls, textPtr, chunkPtr, 0, y, lineHeight, baseline, bp, bp+4, bp+8, bp+12) imageX = *(*int32)(unsafe.Pointer(bp)) - (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).Fx + x XTk_RedrawImage(tls, image, 0, 0, *(*int32)(unsafe.Pointer(bp + 8)), *(*int32)(unsafe.Pointer(bp + 12)), dst, imageX, *(*int32)(unsafe.Pointer(bp + 4))) } /* *-------------------------------------------------------------- * * EmbImageBboxProc -- * * This function is called to compute the bounding box of the area * occupied by an embedded image. * * Results: * There is no return value. *xPtr and *yPtr are filled in with the * coordinates of the upper left corner of the image, and *widthPtr and * *heightPtr are filled in with the dimensions of the image in pixels. * Note: not all of the returned bbox is necessarily visible on the * screen (the rightmost part might be off-screen to the right, and the * bottommost part might be off-screen to the bottom). * * Side effects: * None. * *-------------------------------------------------------------- */ func _EmbImageBboxProc(tls *libc.TLS, textPtr uintptr, chunkPtr uintptr, dummy706 TTcl_Size, y int32, lineHeight int32, baseline int32, xPtr uintptr, yPtr uintptr, widthPtr uintptr, heightPtr uintptr) { bp := tls.Alloc(16) defer tls.Free(16) /* Gets filled in with height of image, in * pixels. */ var eiPtr uintptr var image TTk_Image var _ /* padX at bp+0 */ int32 var _ /* padY at bp+4 */ int32 _, _ = eiPtr, image eiPtr = (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FclientData *(*int32)(unsafe.Pointer(bp)) = 0 *(*int32)(unsafe.Pointer(bp + 4)) = 0 image = (*(*TTkTextEmbImage)(unsafe.Pointer(eiPtr + 24))).Fimage if image != libc.UintptrFromInt32(0) { XTk_SizeOfImage(tls, image, widthPtr, heightPtr) } else { *(*int32)(unsafe.Pointer(widthPtr)) = 0 *(*int32)(unsafe.Pointer(heightPtr)) = 0 } if (*(*TTkTextEmbImage)(unsafe.Pointer(eiPtr + 24))).FpadXObj != 0 { XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), (*TTkText)(unsafe.Pointer(textPtr)).Ftkwin, (*(*TTkTextEmbImage)(unsafe.Pointer(eiPtr + 24))).FpadXObj, bp) } if (*(*TTkTextEmbImage)(unsafe.Pointer(eiPtr + 24))).FpadYObj != 0 { XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), (*TTkText)(unsafe.Pointer(textPtr)).Ftkwin, (*(*TTkTextEmbImage)(unsafe.Pointer(eiPtr + 24))).FpadYObj, bp+4) } *(*int32)(unsafe.Pointer(xPtr)) = (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).Fx + *(*int32)(unsafe.Pointer(bp)) switch (*(*TTkTextEmbImage)(unsafe.Pointer(eiPtr + 24))).Falign { case int32(TK_ALIGN_BOTTOM): *(*int32)(unsafe.Pointer(yPtr)) = y + (lineHeight - *(*int32)(unsafe.Pointer(heightPtr)) - *(*int32)(unsafe.Pointer(bp + 4))) case int32(TK_ALIGN_CENTER): *(*int32)(unsafe.Pointer(yPtr)) = y + (lineHeight-*(*int32)(unsafe.Pointer(heightPtr)))/int32(2) case int32(TK_ALIGN_TOP): *(*int32)(unsafe.Pointer(yPtr)) = y + *(*int32)(unsafe.Pointer(bp + 4)) case int32(TK_ALIGN_BASELINE): *(*int32)(unsafe.Pointer(yPtr)) = y + (baseline - *(*int32)(unsafe.Pointer(heightPtr))) break } } /* *-------------------------------------------------------------- * * TkTextImageIndex -- * * Given the name of an embedded image within a text widget, returns an * index corresponding to the image's position in the text. * * Results: * The return value is TCL_OK if there is an embedded image by the given * name in the text widget, TCL_ERROR otherwise. If the image exists, * *indexPtr is filled in with its index. * * Side effects: * None. * *-------------------------------------------------------------- */ func XTkTextImageIndex(tls *libc.TLS, textPtr uintptr, name uintptr, indexPtr uintptr) (r int32) { /* Index information gets stored here. */ var eiPtr, hPtr uintptr _, _ = eiPtr, hPtr if textPtr == libc.UintptrFromInt32(0) { return int32(TCL_ERROR) } hPtr = (*(*func(*libc.TLS, uintptr, uintptr) uintptr)(unsafe.Pointer(&struct{ uintptr }{(*TTcl_HashTable)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr + 336)).FfindProc})))(tls, (*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr+336, name) if hPtr == libc.UintptrFromInt32(0) { return int32(TCL_ERROR) } eiPtr = (*TTcl_HashEntry)(unsafe.Pointer(hPtr)).FclientData (*TTkTextIndex)(unsafe.Pointer(indexPtr)).Ftree = (*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).Ftree (*TTkTextIndex)(unsafe.Pointer(indexPtr)).FlinePtr = (*(*TTkTextEmbImage)(unsafe.Pointer(eiPtr + 24))).FlinePtr (*TTkTextIndex)(unsafe.Pointer(indexPtr)).FbyteIndex = XTkTextSegToOffset(tls, eiPtr, (*TTkTextIndex)(unsafe.Pointer(indexPtr)).FlinePtr) /* * If indexPtr refers to somewhere outside the -startline/-endline * range limits of the widget, error out since the image indeed is not * reachable from this text widget (it may be reachable from a peer). */ if XTkTextIndexAdjustToStartEnd(tls, textPtr, indexPtr, int32(1)) == int32(TCL_ERROR) { return int32(TCL_ERROR) } return TCL_OK } /* *-------------------------------------------------------------- * * EmbImageProc -- * * This function is called by the image code whenever an image or its * contents changes. * * Results: * None. * * Side effects: * The image will be redisplayed. * *-------------------------------------------------------------- */ func _EmbImageProc(tls *libc.TLS, clientData uintptr, dummy830 int32, dummy832 int32, dummy833 int32, dummy835 int32, dummy836 int32, dummy837 int32) { bp := tls.Alloc(32) defer tls.Free(32) var eiPtr uintptr var _ /* index at bp+0 */ TTkTextIndex _ = eiPtr eiPtr = clientData (*(*TTkTextIndex)(unsafe.Pointer(bp))).Ftree = (*TTkSharedText1)(unsafe.Pointer((*(*TTkTextEmbImage)(unsafe.Pointer(eiPtr + 24))).FsharedTextPtr)).Ftree (*(*TTkTextIndex)(unsafe.Pointer(bp))).FlinePtr = (*(*TTkTextEmbImage)(unsafe.Pointer(eiPtr + 24))).FlinePtr (*(*TTkTextIndex)(unsafe.Pointer(bp))).FbyteIndex = XTkTextSegToOffset(tls, eiPtr, (*(*TTkTextEmbImage)(unsafe.Pointer(eiPtr + 24))).FlinePtr) XTkTextChanged(tls, (*(*TTkTextEmbImage)(unsafe.Pointer(eiPtr + 24))).FsharedTextPtr, libc.UintptrFromInt32(0), bp, bp) /* * It's probably not true that all image changes can change the line * height, so we could be more efficient here and only call this when * necessary. */ XTkTextInvalidateLineMetrics(tls, (*(*TTkTextEmbImage)(unsafe.Pointer(eiPtr + 24))).FsharedTextPtr, libc.UintptrFromInt32(0), (*(*TTkTextIndex)(unsafe.Pointer(bp))).FlinePtr, 0, int32(TK_TEXT_INVALIDATE_ONLY)) } const LAST_CHAR = 1000000 const TKINDEX_ANY = 2 const TKINDEX_DISPLAY = 1 const TKINDEX_NONE = 0 func init() { p := unsafe.Pointer(&XtkTextIndexType) *(*uintptr)(unsafe.Add(p, 8)) = __ccgo_fp(_FreeTextIndexInternalRep) *(*uintptr)(unsafe.Add(p, 16)) = __ccgo_fp(_DupTextIndexInternalRep) } func _FreeTextIndexInternalRep(tls *libc.TLS, indexObjPtr uintptr) { /* TextIndex object with internal rep to * free. */ var indexPtr, v2 uintptr var v1 TTcl_Size _, _, _ = indexPtr, v1, v2 indexPtr = (*(*struct { Fptr1 uintptr Fptr2 uintptr })(unsafe.Pointer(indexObjPtr + 32))).Fptr1 if (*TTkTextIndex)(unsafe.Pointer(indexPtr)).FtextPtr != libc.UintptrFromInt32(0) { v2 = (*TTkTextIndex)(unsafe.Pointer(indexPtr)).FtextPtr + 688 v1 = *(*TTcl_Size)(unsafe.Pointer(v2)) *(*TTcl_Size)(unsafe.Pointer(v2))-- if v1 <= int64(1) { /* * The text widget has been deleted and we need to free it now. */ libtcl9_0.XTcl_Free(tls, (*TTkTextIndex)(unsafe.Pointer(indexPtr)).FtextPtr) } } libtcl9_0.XTcl_Free(tls, indexPtr) (*TTcl_Obj)(unsafe.Pointer(indexObjPtr)).FtypePtr = libc.UintptrFromInt32(0) } func _DupTextIndexInternalRep(tls *libc.TLS, srcPtr uintptr, copyPtr uintptr) { /* TextIndex obj with internal rep to set. */ var dupIndexPtr, indexPtr uintptr var epoch TTcl_Size _, _, _ = dupIndexPtr, epoch, indexPtr dupIndexPtr = libtcl9_0.XTcl_Alloc(tls, uint64(32)) indexPtr = (*(*struct { Fptr1 uintptr Fptr2 uintptr })(unsafe.Pointer(srcPtr + 32))).Fptr1 epoch = int64((*(*struct { Fptr1 uintptr Fptr2 uintptr })(unsafe.Pointer(srcPtr + 32))).Fptr2) (*TTkTextIndex)(unsafe.Pointer(dupIndexPtr)).Ftree = (*TTkTextIndex)(unsafe.Pointer(indexPtr)).Ftree (*TTkTextIndex)(unsafe.Pointer(dupIndexPtr)).FlinePtr = (*TTkTextIndex)(unsafe.Pointer(indexPtr)).FlinePtr (*TTkTextIndex)(unsafe.Pointer(dupIndexPtr)).FbyteIndex = (*TTkTextIndex)(unsafe.Pointer(indexPtr)).FbyteIndex (*TTkTextIndex)(unsafe.Pointer(dupIndexPtr)).FtextPtr = (*TTkTextIndex)(unsafe.Pointer(indexPtr)).FtextPtr if (*TTkTextIndex)(unsafe.Pointer(dupIndexPtr)).FtextPtr != libc.UintptrFromInt32(0) { (*TTkText1)(unsafe.Pointer((*TTkTextIndex)(unsafe.Pointer(dupIndexPtr)).FtextPtr)).FrefCount++ } (*(*struct { Fptr1 uintptr Fptr2 uintptr })(unsafe.Pointer(copyPtr + 32))).Fptr1 = dupIndexPtr (*(*struct { Fptr1 uintptr Fptr2 uintptr })(unsafe.Pointer(copyPtr + 32))).Fptr2 = uintptr(libc.Uint64FromInt64(epoch)) (*TTcl_Obj)(unsafe.Pointer(copyPtr)).FtypePtr = uintptr(unsafe.Pointer(&XtkTextIndexType)) } /* * This will not be called except by TkTextNewIndexObj below. This is because * if a TkTextIndex is no longer valid, it is not possible to regenerate the * string representation. */ func _UpdateStringOfTextIndex(tls *libc.TLS, objPtr uintptr) { bp := tls.Alloc(32) defer tls.Free(32) var indexPtr uintptr var len1 Tsize_t var _ /* buffer at bp+0 */ [30]uint8 _, _ = indexPtr, len1 indexPtr = (*(*struct { Fptr1 uintptr Fptr2 uintptr })(unsafe.Pointer(objPtr + 32))).Fptr1 len1 = libc.Uint64FromInt64(XTkTextPrintIndex(tls, (*TTkTextIndex)(unsafe.Pointer(indexPtr)).FtextPtr, indexPtr, bp)) (*TTcl_Obj)(unsafe.Pointer(objPtr)).Fbytes = libtcl9_0.XTcl_Alloc(tls, len1+uint64(1)) libc.Xstrcpy(tls, (*TTcl_Obj)(unsafe.Pointer(objPtr)).Fbytes, bp) (*TTcl_Obj)(unsafe.Pointer(objPtr)).Flength = libc.Int64FromUint64(len1) } /* *--------------------------------------------------------------------------- * * MakeObjIndex -- * * This function generates a Tcl_Obj description of an index, suitable * for reading in again later. If the 'textPtr' is NULL then we still * generate an index object, but it's internal description is deemed * non-cacheable, and therefore effectively useless (apart from as a * temporary memory storage). This is used for indices whose meaning is * very temporary (like @0,0 or the name of a mark or tag). The mapping * from such strings/objects to actual TkTextIndex pointers is not stable * to minor text widget changes which we do not track (we track * insertions and deletions). * * Results: * A pointer to an allocated TkTextIndex which will be freed * automatically when the Tcl_Obj is used for other purposes. * * Side effects: * A small amount of memory is allocated. * *--------------------------------------------------------------------------- */ func _MakeObjIndex(tls *libc.TLS, textPtr uintptr, objPtr uintptr, origPtr uintptr) (r uintptr) { /* Pointer to index. */ var indexPtr uintptr _ = indexPtr indexPtr = libtcl9_0.XTcl_Alloc(tls, uint64(32)) (*TTkTextIndex)(unsafe.Pointer(indexPtr)).Ftree = (*TTkTextIndex)(unsafe.Pointer(origPtr)).Ftree (*TTkTextIndex)(unsafe.Pointer(indexPtr)).FlinePtr = (*TTkTextIndex)(unsafe.Pointer(origPtr)).FlinePtr (*TTkTextIndex)(unsafe.Pointer(indexPtr)).FbyteIndex = (*TTkTextIndex)(unsafe.Pointer(origPtr)).FbyteIndex (*(*struct { Fptr1 uintptr Fptr2 uintptr })(unsafe.Pointer(objPtr + 32))).Fptr1 = indexPtr (*TTcl_Obj)(unsafe.Pointer(objPtr)).FtypePtr = uintptr(unsafe.Pointer(&XtkTextIndexType)) (*TTkTextIndex)(unsafe.Pointer(indexPtr)).FtextPtr = textPtr if textPtr != libc.UintptrFromInt32(0) { (*TTkText)(unsafe.Pointer(textPtr)).FrefCount++ (*(*struct { Fptr1 uintptr Fptr2 uintptr })(unsafe.Pointer(objPtr + 32))).Fptr2 = uintptr(libc.Uint64FromInt64((*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).FstateEpoch)) } else { (*(*struct { Fptr1 uintptr Fptr2 uintptr })(unsafe.Pointer(objPtr + 32))).Fptr2 = uintptr(libc.Uint64FromInt32(libc.Int32FromInt32(0))) } return indexPtr } func XTkTextGetIndexFromObj(tls *libc.TLS, interp uintptr, textPtr uintptr, objPtr uintptr) (r uintptr) { bp := tls.Alloc(48) defer tls.Free(48) /* Object containing description of * position. */ var epoch TTcl_Size var indexPtr, v1 uintptr var _ /* cache at bp+32 */ int32 var _ /* index at bp+0 */ TTkTextIndex _, _, _ = epoch, indexPtr, v1 indexPtr = libc.UintptrFromInt32(0) if (*TTcl_Obj)(unsafe.Pointer(objPtr)).FtypePtr == uintptr(unsafe.Pointer(&XtkTextIndexType)) { indexPtr = (*(*struct { Fptr1 uintptr Fptr2 uintptr })(unsafe.Pointer(objPtr + 32))).Fptr1 epoch = int64((*(*struct { Fptr1 uintptr Fptr2 uintptr })(unsafe.Pointer(objPtr + 32))).Fptr2) if epoch == (*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).FstateEpoch { if (*TTkTextIndex)(unsafe.Pointer(indexPtr)).FtextPtr == textPtr { return indexPtr } } } /* * The object is either not an index type or referred to a different text * widget, or referred to the correct widget, but it is out of date (text * has been added/deleted since). */ if _GetIndex(tls, interp, libc.UintptrFromInt32(0), textPtr, libtcl9_0.XTcl_GetStringFromObj(tls, objPtr, libc.UintptrFromInt32(0)), bp, bp+32) != TCL_OK { return libc.UintptrFromInt32(0) } if (*TTcl_Obj)(unsafe.Pointer(objPtr)).FtypePtr != libc.UintptrFromInt32(0) { if (*TTcl_Obj)(unsafe.Pointer(objPtr)).Fbytes == libc.UintptrFromInt32(0) { (*(*func(*libc.TLS, uintptr))(unsafe.Pointer(&struct{ uintptr }{(*TTcl_ObjType)(unsafe.Pointer((*TTcl_Obj)(unsafe.Pointer(objPtr)).FtypePtr)).FupdateStringProc})))(tls, objPtr) } if (*TTcl_ObjType)(unsafe.Pointer((*TTcl_Obj)(unsafe.Pointer(objPtr)).FtypePtr)).FfreeIntRepProc != libc.UintptrFromInt32(0) { (*(*func(*libc.TLS, uintptr))(unsafe.Pointer(&struct{ uintptr }{(*TTcl_ObjType)(unsafe.Pointer((*TTcl_Obj)(unsafe.Pointer(objPtr)).FtypePtr)).FfreeIntRepProc})))(tls, objPtr) } } if *(*int32)(unsafe.Pointer(bp + 32)) != 0 { v1 = textPtr } else { v1 = libc.UintptrFromInt32(0) } return _MakeObjIndex(tls, v1, objPtr, bp) } /* *--------------------------------------------------------------------------- * * TkTextNewIndexObj -- * * This function generates a Tcl_Obj description of an index, suitable * for reading in again later. The index generated is effectively stable * to all except insertion/deletion operations on the widget. * * Results: * A new Tcl_Obj with refCount zero. * * Side effects: * A small amount of memory is allocated. * *--------------------------------------------------------------------------- */ func XTkTextNewIndexObj(tls *libc.TLS, textPtr uintptr, indexPtr uintptr) (r uintptr) { /* Pointer to index. */ var retVal uintptr _ = retVal retVal = libtcl9_0.XTcl_NewObj(tls) (*TTcl_Obj)(unsafe.Pointer(retVal)).Fbytes = libc.UintptrFromInt32(0) /* * Assumption that the above call returns an object with: * retVal->typePtr == NULL */ _MakeObjIndex(tls, textPtr, retVal, indexPtr) /* * Unfortunately, it isn't possible for us to regenerate the string * representation so we have to create it here, while we can be sure the * contents of the index are still valid. */ _UpdateStringOfTextIndex(tls, retVal) return retVal } /* *--------------------------------------------------------------------------- * * TkTextMakePixelIndex -- * * Given a pixel index and a byte index, look things up in the B-tree and * fill in a TkTextIndex structure. * * The valid input range for pixelIndex is from 0 to the number of pixels * in the widget-1. Anything outside that range will be rounded to the * closest acceptable value. * * Results: * * The structure at *indexPtr is filled in with information about the * character at pixelIndex (or the closest existing character, if the * specified one doesn't exist), and the number of excess pixels is * returned as a result. This means if the given pixel index is exactly * correct for the top-edge of the indexPtr, then zero will be returned, * and otherwise we will return the calculation 'desired pixelIndex' - * 'actual pixel index of indexPtr'. * * Side effects: * None. * *--------------------------------------------------------------------------- */ func XTkTextMakePixelIndex(tls *libc.TLS, textPtr uintptr, pixelIndex int32, indexPtr uintptr) (r int32) { bp := tls.Alloc(16) defer tls.Free(16) /* Structure to fill in. */ var lastMinusOne int32 var _ /* pixelOffset at bp+0 */ int32 _ = lastMinusOne *(*int32)(unsafe.Pointer(bp)) = 0 (*TTkTextIndex)(unsafe.Pointer(indexPtr)).Ftree = (*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).Ftree (*TTkTextIndex)(unsafe.Pointer(indexPtr)).FtextPtr = textPtr if pixelIndex < 0 { pixelIndex = 0 } (*TTkTextIndex)(unsafe.Pointer(indexPtr)).FlinePtr = XTkBTreeFindPixelLine(tls, (*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).Ftree, textPtr, pixelIndex, bp) /* * 'pixelIndex' was too large, so we try again, just to find the last * pixel in the window. */ if (*TTkTextIndex)(unsafe.Pointer(indexPtr)).FlinePtr == libc.UintptrFromInt32(0) { lastMinusOne = XTkBTreeNumPixels(tls, (*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).Ftree, textPtr) - int32(1) (*TTkTextIndex)(unsafe.Pointer(indexPtr)).FlinePtr = XTkBTreeFindPixelLine(tls, (*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).Ftree, textPtr, lastMinusOne, bp) (*TTkTextIndex)(unsafe.Pointer(indexPtr)).FbyteIndex = 0 return *(*int32)(unsafe.Pointer(bp)) } (*TTkTextIndex)(unsafe.Pointer(indexPtr)).FbyteIndex = 0 if *(*int32)(unsafe.Pointer(bp)) <= 0 { return 0 } return XTkTextMeasureDown(tls, textPtr, indexPtr, *(*int32)(unsafe.Pointer(bp))) } /* *--------------------------------------------------------------------------- * * TkTextMakeByteIndex -- * * Given a line index and a byte index, look things up in the B-tree and * fill in a TkTextIndex structure. * * Results: * The structure at *indexPtr is filled in with information about the * character at lineIndex and byteIndex (or the closest existing * character, if the specified one doesn't exist), and indexPtr is * returned as result. * * Side effects: * None. * *--------------------------------------------------------------------------- */ func XTkTextMakeByteIndex(tls *libc.TLS, tree TTkTextBTree, textPtr uintptr, lineIndex int32, byteIndex TTcl_Size, indexPtr uintptr) (r uintptr) { bp := tls.Alloc(16) defer tls.Free(16) /* Structure to fill in. */ var index int32 var p, segPtr, start uintptr var _ /* ch at bp+0 */ int32 _, _, _, _ = index, p, segPtr, start (*TTkTextIndex)(unsafe.Pointer(indexPtr)).Ftree = tree if lineIndex < 0 { lineIndex = 0 byteIndex = 0 } if byteIndex < 0 { byteIndex = 0 } (*TTkTextIndex)(unsafe.Pointer(indexPtr)).FlinePtr = XTkBTreeFindLine(tls, tree, textPtr, lineIndex) if (*TTkTextIndex)(unsafe.Pointer(indexPtr)).FlinePtr == libc.UintptrFromInt32(0) { (*TTkTextIndex)(unsafe.Pointer(indexPtr)).FlinePtr = XTkBTreeFindLine(tls, tree, textPtr, XTkBTreeNumLines(tls, tree, textPtr)) byteIndex = 0 } if byteIndex == 0 { (*TTkTextIndex)(unsafe.Pointer(indexPtr)).FbyteIndex = byteIndex return indexPtr } /* * Verify that the index is within the range of the line and points to a * valid character boundary. */ index = 0 segPtr = (*TTkTextLine)(unsafe.Pointer((*TTkTextIndex)(unsafe.Pointer(indexPtr)).FlinePtr)).FsegPtr for { if segPtr == libc.UintptrFromInt32(0) { /* * Use the index of the last character in the line. Since the last * character on the line is guaranteed to be a '\n', we can back * up a constant sizeof(char) bytes. */ (*TTkTextIndex)(unsafe.Pointer(indexPtr)).FbyteIndex = libc.Int64FromUint64(libc.Uint64FromInt32(index) - uint64(1)) break } if int64(index+int32((*TTkTextSegment)(unsafe.Pointer(segPtr)).Fsize)) > byteIndex { (*TTkTextIndex)(unsafe.Pointer(indexPtr)).FbyteIndex = byteIndex if byteIndex > int64(index) && (*TTkTextSegment)(unsafe.Pointer(segPtr)).FtypePtr == uintptr(unsafe.Pointer(&XtkTextCharType)) { /* * Prevent UTF-8 character from being split up by ensuring * that byteIndex falls on a character boundary. If the index * falls in the middle of a UTF-8 character, it will be * adjusted to the end of that UTF-8 character. */ start = segPtr + 24 + uintptr(byteIndex-int64(index)) p = libtcl9_0.XTcl_UtfPrev(tls, start, segPtr+24) p += uintptr(libtcl9_0.XTcl_UtfToUniChar(tls, p, bp)) *(*TTcl_Size)(unsafe.Pointer(indexPtr + 16)) += int64(p) - int64(start) } break } index = int32(int64(index) + (*TTkTextSegment)(unsafe.Pointer(segPtr)).Fsize) goto _1 _1: ; segPtr = (*TTkTextSegment)(unsafe.Pointer(segPtr)).FnextPtr } return indexPtr } /* *--------------------------------------------------------------------------- * * TkTextMakeCharIndex -- * * Given a line index and a character index, look things up in the B-tree * and fill in a TkTextIndex structure. * * Results: * The structure at *indexPtr is filled in with information about the * character at lineIndex and charIndex (or the closest existing * character, if the specified one doesn't exist), and indexPtr is * returned as result. * * Side effects: * None. * *--------------------------------------------------------------------------- */ func XTkTextMakeCharIndex(tls *libc.TLS, tree TTkTextBTree, textPtr uintptr, lineIndex int32, charIndex int32, indexPtr uintptr) (r uintptr) { bp := tls.Alloc(16) defer tls.Free(16) /* Structure to fill in. */ var end, p, segPtr, start uintptr var index, offset int32 var _ /* ch at bp+0 */ TTcl_UniChar _, _, _, _, _, _ = end, index, offset, p, segPtr, start *(*TTcl_UniChar)(unsafe.Pointer(bp)) = 0 (*TTkTextIndex)(unsafe.Pointer(indexPtr)).Ftree = tree if lineIndex < 0 { lineIndex = 0 charIndex = 0 } if charIndex < 0 { charIndex = 0 } (*TTkTextIndex)(unsafe.Pointer(indexPtr)).FlinePtr = XTkBTreeFindLine(tls, tree, textPtr, lineIndex) if (*TTkTextIndex)(unsafe.Pointer(indexPtr)).FlinePtr == libc.UintptrFromInt32(0) { (*TTkTextIndex)(unsafe.Pointer(indexPtr)).FlinePtr = XTkBTreeFindLine(tls, tree, textPtr, XTkBTreeNumLines(tls, tree, textPtr)) charIndex = 0 } /* * Verify that the index is within the range of the line. If not, just use * the index of the last character in the line. */ index = 0 segPtr = (*TTkTextLine)(unsafe.Pointer((*TTkTextIndex)(unsafe.Pointer(indexPtr)).FlinePtr)).FsegPtr for { if segPtr == libc.UintptrFromInt32(0) { /* * Use the index of the last character in the line. Since the last * character on the line is guaranteed to be a '\n', we can back * up a constant sizeof(char) bytes. */ (*TTkTextIndex)(unsafe.Pointer(indexPtr)).FbyteIndex = libc.Int64FromUint64(libc.Uint64FromInt32(index) - uint64(1)) break } if (*TTkTextSegment)(unsafe.Pointer(segPtr)).FtypePtr == uintptr(unsafe.Pointer(&XtkTextCharType)) { /* * Turn character offset into a byte offset. */ start = segPtr + 24 end = start + uintptr((*TTkTextSegment)(unsafe.Pointer(segPtr)).Fsize) p = start for { if !(p < end) { break } if charIndex == 0 { (*TTkTextIndex)(unsafe.Pointer(indexPtr)).FbyteIndex = int64(index) return indexPtr } charIndex-- offset = int32(libtcl9_0.XTcl_UtfToUniChar(tls, p, bp)) index += offset goto _2 _2: ; p += uintptr(offset) } } else { if charIndex < int32((*TTkTextSegment)(unsafe.Pointer(segPtr)).Fsize) { (*TTkTextIndex)(unsafe.Pointer(indexPtr)).FbyteIndex = int64(index) break } charIndex = int32(int64(charIndex) - (*TTkTextSegment)(unsafe.Pointer(segPtr)).Fsize) index = int32(int64(index) + (*TTkTextSegment)(unsafe.Pointer(segPtr)).Fsize) } goto _1 _1: ; segPtr = (*TTkTextSegment)(unsafe.Pointer(segPtr)).FnextPtr } return indexPtr } /* *--------------------------------------------------------------------------- * * TkTextIndexToSeg -- * * Given an index, this function returns the segment and offset within * segment for the index. * * Results: * The return value is a pointer to the segment referred to by indexPtr; * this will always be a segment with non-zero size. The variable at * *offsetPtr is set to hold the integer offset within the segment of the * character given by indexPtr. * * Side effects: * None. * *--------------------------------------------------------------------------- */ func XTkTextIndexToSeg(tls *libc.TLS, indexPtr uintptr, offsetPtr uintptr) (r uintptr) { /* Where to store offset within segment, or * NULL if offset isn't wanted. */ var offset TTcl_Size var segPtr uintptr _, _ = offset, segPtr offset = (*TTkTextIndex)(unsafe.Pointer(indexPtr)).FbyteIndex segPtr = (*TTkTextLine)(unsafe.Pointer((*TTkTextIndex)(unsafe.Pointer(indexPtr)).FlinePtr)).FsegPtr for { if !(offset >= (*TTkTextSegment)(unsafe.Pointer(segPtr)).Fsize) { break } /* Empty loop body. */ goto _1 _1: ; offset -= (*TTkTextSegment)(unsafe.Pointer(segPtr)).Fsize segPtr = (*TTkTextSegment)(unsafe.Pointer(segPtr)).FnextPtr } if offsetPtr != libc.UintptrFromInt32(0) { *(*TTcl_Size)(unsafe.Pointer(offsetPtr)) = offset } return segPtr } /* *--------------------------------------------------------------------------- * * TkTextSegToOffset -- * * Given a segment pointer and the line containing it, this function * returns the offset of the segment within its line. * * Results: * The return value is the offset (within its line) of the first * character in segPtr. * * Side effects: * None. * *--------------------------------------------------------------------------- */ func XTkTextSegToOffset(tls *libc.TLS, segPtr uintptr, linePtr uintptr) (r TTcl_Size) { /* Line containing segPtr. */ var offset TTcl_Size var segPtr2 uintptr _, _ = offset, segPtr2 offset = 0 segPtr2 = (*TTkTextLine)(unsafe.Pointer(linePtr)).FsegPtr for { if !(segPtr2 != segPtr) { break } offset += (*TTkTextSegment)(unsafe.Pointer(segPtr2)).Fsize goto _1 _1: ; segPtr2 = (*TTkTextSegment)(unsafe.Pointer(segPtr2)).FnextPtr } return offset } /* *--------------------------------------------------------------------------- * * TkTextGetObjIndex -- * * Simpler wrapper around the string based function, but could be * enhanced with a new object type in the future. * * Results: * see TkTextGetIndex * * Side effects: * None. * *--------------------------------------------------------------------------- */ func XTkTextGetObjIndex(tls *libc.TLS, interp uintptr, textPtr uintptr, idxObj uintptr, indexPtr uintptr) (r int32) { /* Index structure to fill in. */ return _GetIndex(tls, interp, libc.UintptrFromInt32(0), textPtr, libtcl9_0.XTcl_GetStringFromObj(tls, idxObj, libc.UintptrFromInt32(0)), indexPtr, libc.UintptrFromInt32(0)) } /* *--------------------------------------------------------------------------- * * TkTextSharedGetObjIndex -- * * Simpler wrapper around the string based function, but could be * enhanced with a new object type in the future. * * Results: * see TkTextGetIndex * * Side effects: * None. * *--------------------------------------------------------------------------- */ func XTkTextSharedGetObjIndex(tls *libc.TLS, interp uintptr, sharedTextPtr uintptr, idxObj uintptr, indexPtr uintptr) (r int32) { /* Index structure to fill in. */ return _GetIndex(tls, interp, sharedTextPtr, libc.UintptrFromInt32(0), libtcl9_0.XTcl_GetStringFromObj(tls, idxObj, libc.UintptrFromInt32(0)), indexPtr, libc.UintptrFromInt32(0)) } /* *--------------------------------------------------------------------------- * * TkTextGetIndex -- * * Given a string, return the index that is described. * * Results: * The return value is a standard Tcl return result. If TCL_OK is * returned, then everything went well and the index at *indexPtr is * filled in; otherwise TCL_ERROR is returned and an error message is * left in the interp's result. * * Side effects: * None. * *--------------------------------------------------------------------------- */ func XTkTextGetIndex(tls *libc.TLS, interp uintptr, textPtr uintptr, string1 uintptr, indexPtr uintptr) (r int32) { /* Index structure to fill in. */ return _GetIndex(tls, interp, libc.UintptrFromInt32(0), textPtr, string1, indexPtr, libc.UintptrFromInt32(0)) } /* *--------------------------------------------------------------------------- * * GetIndex -- * * Given a string, return the index that is described. * * Results: * The return value is a standard Tcl return result. If TCL_OK is * returned, then everything went well and the index at *indexPtr is * filled in; otherwise TCL_ERROR is returned and an error message is * left in the interp's result. * * If *canCachePtr is non-NULL, and everything went well, the integer it * points to is set to 1 if the indexPtr is something which can be * cached, and zero otherwise. * * Side effects: * None. * *--------------------------------------------------------------------------- */ func _GetIndex(tls *libc.TLS, interp uintptr, sharedPtr uintptr, textPtr uintptr, string1 uintptr, indexPtr uintptr, canCachePtr uintptr) (r int32) { bp := tls.Alloc(416) defer tls.Free(416) /* Pointer to integer to store whether we can * cache the index (or NULL). */ var c uint8 var canCache, charIndex, lineIndex, result, wantLast, x, y, v3, v4, v6, v7 int32 var cp, endOfBase, hPtr, p, tagName, tagPtr, v1 uintptr var _ /* copy at bp+72 */ TTcl_DString var _ /* end at bp+0 */ uintptr var _ /* first at bp+8 */ TTkTextIndex var _ /* last at bp+40 */ TTkTextIndex var _ /* search at bp+296 */ TTkTextSearch _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = c, canCache, charIndex, cp, endOfBase, hPtr, lineIndex, p, result, tagName, tagPtr, wantLast, x, y, v1, v3, v4, v6, v7 canCache = 0 if sharedPtr == libc.UintptrFromInt32(0) { sharedPtr = (*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr } /* *--------------------------------------------------------------------- * Stage 1: check to see if the index consists of nothing but a mark * name, an embedded window or an embedded image. We do this check * now even though it's also done later, in order to allow mark names, * embedded window names or image names that include funny characters * such as spaces or "+1c". *--------------------------------------------------------------------- */ if XTkTextMarkNameToIndex(tls, textPtr, string1, indexPtr) == TCL_OK { goto done } if XTkTextWindowIndex(tls, textPtr, string1, indexPtr) == TCL_OK { goto done } if XTkTextImageIndex(tls, textPtr, string1, indexPtr) == TCL_OK { goto done } /* *------------------------------------------------ * Stage 2: start again by parsing the base index. *------------------------------------------------ */ (*TTkTextIndex)(unsafe.Pointer(indexPtr)).Ftree = (*TTkSharedText)(unsafe.Pointer(sharedPtr)).Ftree /* * First look for the form "tag.first" or "tag.last" where "tag" is the * name of a valid tag. Try to use up as much as possible of the string in * this check (strrchr instead of strchr below). Doing the check now, and * in this way, allows tag names to include funny characters like "@" or * "+1c". */ libtcl9_0.XTcl_DStringInit(tls, bp+72) p = libc.Xstrrchr(tls, libtcl9_0.XTcl_DStringAppend(tls, bp+72, string1, int64(-libc.Int32FromInt32(1))), int32('.')) if p != libc.UintptrFromInt32(0) { hPtr = libc.UintptrFromInt32(0) if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(p + 1))) == int32('f') && libc.Xstrncmp(tls, p+uintptr(1), __ccgo_ts+24978, uint64(5)) == 0 { wantLast = 0 endOfBase = p + uintptr(6) } else { if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(p + 1))) == int32('l') && libc.Xstrncmp(tls, p+uintptr(1), __ccgo_ts+24701, uint64(4)) == 0 { wantLast = int32(1) endOfBase = p + uintptr(5) } else { goto tryxy } } tagPtr = libc.UintptrFromInt32(0) tagName = (*TTcl_DString)(unsafe.Pointer(bp + 72)).Fstring1 if int64(p)-int64(tagName) == int64(3) && !(libc.Xstrncmp(tls, tagName, __ccgo_ts+42892, uint64(3)) != 0) { /* * Special case for sel tag which is not stored in the hash table. */ tagPtr = (*TTkText)(unsafe.Pointer(textPtr)).FselTagPtr } else { *(*uint8)(unsafe.Pointer(p)) = uint8(0) hPtr = (*(*func(*libc.TLS, uintptr, uintptr) uintptr)(unsafe.Pointer(&struct{ uintptr }{(*TTcl_HashTable)(unsafe.Pointer(sharedPtr + 16)).FfindProc})))(tls, sharedPtr+16, tagName) *(*uint8)(unsafe.Pointer(p)) = uint8('.') if hPtr != libc.UintptrFromInt32(0) { tagPtr = (*TTcl_HashEntry)(unsafe.Pointer(hPtr)).FclientData } } if tagPtr == libc.UintptrFromInt32(0) { goto tryxy } XTkTextMakeByteIndex(tls, (*TTkSharedText)(unsafe.Pointer(sharedPtr)).Ftree, textPtr, 0, 0, bp+8) XTkTextMakeByteIndex(tls, (*TTkSharedText)(unsafe.Pointer(sharedPtr)).Ftree, textPtr, XTkBTreeNumLines(tls, (*TTkSharedText)(unsafe.Pointer(sharedPtr)).Ftree, textPtr), 0, bp+40) XTkBTreeStartSearch(tls, bp+8, bp+40, tagPtr, bp+296) if !(XTkBTreeCharTagged(tls, bp+8, tagPtr) != 0) && !(XTkBTreeNextTag(tls, bp+296) != 0) { if tagPtr == (*TTkText)(unsafe.Pointer(textPtr)).FselTagPtr { tagName = __ccgo_ts + 42892 } else { if hPtr != libc.UintptrFromInt32(0) { if (*TTcl_HashTable)(unsafe.Pointer(sharedPtr+16)).FkeyType == int32(TCL_ONE_WORD_KEYS) || (*TTcl_HashTable)(unsafe.Pointer(sharedPtr+16)).FkeyType == -int32(1) { v1 = *(*uintptr)(unsafe.Pointer(hPtr + 32)) } else { v1 = hPtr + 32 } tagName = v1 } } libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+47836, libc.VaList(bp+376, tagName))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+376, __ccgo_ts+179, __ccgo_ts+3058, __ccgo_ts+47889, tagName, libc.UintptrFromInt32(0))) libtcl9_0.XTcl_DStringFree(tls, bp+72) return int32(TCL_ERROR) } *(*TTkTextIndex)(unsafe.Pointer(indexPtr)) = (*(*TTkTextSearch)(unsafe.Pointer(bp + 296))).FcurIndex if wantLast != 0 { for XTkBTreeNextTag(tls, bp+296) != 0 { *(*TTkTextIndex)(unsafe.Pointer(indexPtr)) = (*(*TTkTextSearch)(unsafe.Pointer(bp + 296))).FcurIndex } } goto gotBase } goto tryxy tryxy: ; if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(string1))) == int32('@') { cp = string1 + uintptr(1) x = int32(libc.Xstrtol(tls, cp, bp, 0)) if *(*uintptr)(unsafe.Pointer(bp)) == cp || libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp))))) != int32(',') { goto error } cp = *(*uintptr)(unsafe.Pointer(bp)) + uintptr(1) y = int32(libc.Xstrtol(tls, cp, bp, 0)) if *(*uintptr)(unsafe.Pointer(bp)) == cp { goto error } XTkTextPixelIndex(tls, textPtr, x, y, indexPtr, libc.UintptrFromInt32(0)) endOfBase = *(*uintptr)(unsafe.Pointer(bp)) goto gotBase } if libc.BoolInt32(uint32(*(*uint8)(unsafe.Pointer(string1)))-uint32('0') < uint32(10)) != 0 || libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(string1))) == int32('-') { /* * Base is identified with line and character indices. */ lineIndex = int32(libc.Xstrtol(tls, string1, bp, 0) - int64(1)) if *(*uintptr)(unsafe.Pointer(bp)) == string1 || libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp))))) != int32('.') { goto error } p = *(*uintptr)(unsafe.Pointer(bp)) + uintptr(1) if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(p))) == int32('e') && libc.Xstrncmp(tls, p, __ccgo_ts+8126, uint64(3)) == 0 { charIndex = int32(LAST_CHAR) endOfBase = p + uintptr(3) } else { charIndex = int32(libc.Xstrtol(tls, p, bp, 0)) if *(*uintptr)(unsafe.Pointer(bp)) == p { goto error } endOfBase = *(*uintptr)(unsafe.Pointer(bp)) } XTkTextMakeCharIndex(tls, (*TTkSharedText)(unsafe.Pointer(sharedPtr)).Ftree, textPtr, lineIndex, charIndex, indexPtr) canCache = int32(1) goto gotBase } p = (*TTcl_DString)(unsafe.Pointer(bp + 72)).Fstring1 for { if !(libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(p))) != 0) { break } v3 = libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(p))) v4 = libc.BoolInt32(v3 == int32(' ') || libc.Uint32FromInt32(v3)-uint32('\t') < uint32(5)) goto _5 _5: ; if v4 != 0 || libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(p))) == int32('+') || libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(p))) == int32('-') { break } goto _2 _2: ; p++ } endOfBase = p if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(string1))) == int32('.') { /* * See if the base position is the name of an embedded window. */ c = *(*uint8)(unsafe.Pointer(endOfBase)) *(*uint8)(unsafe.Pointer(endOfBase)) = uint8(0) result = XTkTextWindowIndex(tls, textPtr, (*TTcl_DString)(unsafe.Pointer(bp+72)).Fstring1, indexPtr) *(*uint8)(unsafe.Pointer(endOfBase)) = c if result == TCL_OK { goto gotBase } } if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(string1))) == int32('e') && libc.Xstrncmp(tls, string1, __ccgo_ts+8126, libc.Uint64FromInt64(int64(endOfBase)-int64((*TTcl_DString)(unsafe.Pointer(bp+72)).Fstring1))) == 0 { /* * Base position is end of text. */ XTkTextMakeByteIndex(tls, (*TTkSharedText)(unsafe.Pointer(sharedPtr)).Ftree, textPtr, XTkBTreeNumLines(tls, (*TTkSharedText)(unsafe.Pointer(sharedPtr)).Ftree, textPtr), 0, indexPtr) canCache = int32(1) goto gotBase } else { /* * See if the base position is the name of a mark. */ c = *(*uint8)(unsafe.Pointer(endOfBase)) *(*uint8)(unsafe.Pointer(endOfBase)) = uint8(0) result = XTkTextMarkNameToIndex(tls, textPtr, (*TTcl_DString)(unsafe.Pointer(bp+72)).Fstring1, indexPtr) *(*uint8)(unsafe.Pointer(endOfBase)) = c if result == TCL_OK { goto gotBase } /* * See if the base position is the name of an embedded image. */ c = *(*uint8)(unsafe.Pointer(endOfBase)) *(*uint8)(unsafe.Pointer(endOfBase)) = uint8(0) result = XTkTextImageIndex(tls, textPtr, (*TTcl_DString)(unsafe.Pointer(bp+72)).Fstring1, indexPtr) *(*uint8)(unsafe.Pointer(endOfBase)) = c if result == TCL_OK { goto gotBase } } goto error /* *------------------------------------------------------------------- * Stage 3: process zero or more modifiers. Each modifier is either a * keyword like "wordend" or "linestart", or it has the form "op count * units" where op is + or -, count is a number, and units is "chars" or * "lines". *------------------------------------------------------------------- */ goto gotBase gotBase: ; cp = endOfBase for int32(1) != 0 { for { v6 = libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(cp))) v7 = libc.BoolInt32(v6 == int32(' ') || libc.Uint32FromInt32(v6)-uint32('\t') < uint32(5)) goto _8 _8: if !(v7 != 0) { break } cp++ } if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(cp))) == 0 { break } if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(cp))) == int32('+') || libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(cp))) == int32('-') { cp = _ForwBack(tls, textPtr, cp, indexPtr) } else { cp = _StartEnd(tls, textPtr, cp, indexPtr) } if cp == libc.UintptrFromInt32(0) { goto error } } libtcl9_0.XTcl_DStringFree(tls, bp+72) goto done done: ; if canCachePtr != libc.UintptrFromInt32(0) { *(*int32)(unsafe.Pointer(canCachePtr)) = canCache } if (*TTkTextIndex)(unsafe.Pointer(indexPtr)).FlinePtr == libc.UintptrFromInt32(0) { libtcl9_0.XTcl_Panic(tls, __ccgo_ts+47900, 0) } XTkTextIndexAdjustToStartEnd(tls, textPtr, indexPtr, 0) return TCL_OK goto error error: ; libtcl9_0.XTcl_DStringFree(tls, bp+72) libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+47918, libc.VaList(bp+376, string1))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+376, __ccgo_ts+179, __ccgo_ts+16417, __ccgo_ts+22591, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) } /* *--------------------------------------------------------------------------- * * TkTextIndexAdjustToStartEnd -- * * Adjust indexPtr to the -startline/-endline range, or just check * if indexPtr is out of this range. * * Results: * The return value is a standard Tcl return result. If check is true, * return TCL_ERROR if indexPtr is outside the -startline/-endline * range (indexPtr is not modified). * If check is false, adjust indexPtr to -startline/-endline. * * Side effects: * None. * *--------------------------------------------------------------------------- */ func XTkTextIndexAdjustToStartEnd(tls *libc.TLS, textPtr uintptr, indexPtr uintptr, check int32) (r int32) { bp := tls.Alloc(32) defer tls.Free(32) /* 1 means only check indexPtr against * the -startline/-endline range * 0 means adjust to this range */ var bound int32 var _ /* indexBound at bp+0 */ TTkTextIndex _ = bound if !(textPtr != 0) { return TCL_OK } if (*TTkText)(unsafe.Pointer(textPtr)).Fstart != libc.UintptrFromInt32(0) { bound = XTkBTreeLinesTo(tls, libc.UintptrFromInt32(0), (*TTkText)(unsafe.Pointer(textPtr)).Fstart) XTkTextMakeByteIndex(tls, (*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).Ftree, libc.UintptrFromInt32(0), bound, 0, bp) if XTkTextIndexCmp(tls, indexPtr, bp) < 0 { if check != 0 { return int32(TCL_ERROR) } XTkTextMakeByteIndex(tls, (*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).Ftree, libc.UintptrFromInt32(0), bound, 0, indexPtr) } } if (*TTkText)(unsafe.Pointer(textPtr)).Fend != libc.UintptrFromInt32(0) { bound = XTkBTreeLinesTo(tls, libc.UintptrFromInt32(0), (*TTkText)(unsafe.Pointer(textPtr)).Fend) XTkTextMakeByteIndex(tls, (*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).Ftree, libc.UintptrFromInt32(0), bound, 0, bp) if XTkTextIndexCmp(tls, indexPtr, bp) > 0 { if check != 0 { return int32(TCL_ERROR) } XTkTextMakeByteIndex(tls, (*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).Ftree, libc.UintptrFromInt32(0), bound, 0, indexPtr) } } return TCL_OK } /* *--------------------------------------------------------------------------- * * TkTextPrintIndex -- * * This function generates a string description of an index, suitable for * reading in again later. * * Results: * The characters pointed to by string are modified. Returns the number * of characters in the string. * * Side effects: * None. * *--------------------------------------------------------------------------- */ func XTkTextPrintIndex(tls *libc.TLS, textPtr uintptr, indexPtr uintptr, string1 uintptr) (r TTcl_Size) { bp := tls.Alloc(32) defer tls.Free(32) /* Place to store the position. Must have at * least TK_POS_CHARS characters. */ var charIndex, numBytes TTcl_Size var linePtr, segPtr uintptr _, _, _, _ = charIndex, linePtr, numBytes, segPtr numBytes = (*TTkTextIndex)(unsafe.Pointer(indexPtr)).FbyteIndex charIndex = 0 linePtr = (*TTkTextIndex)(unsafe.Pointer(indexPtr)).FlinePtr segPtr = (*TTkTextLine)(unsafe.Pointer(linePtr)).FsegPtr for { if segPtr == libc.UintptrFromInt32(0) { /* * Two logical lines merged into one display line through eliding * of a newline. */ linePtr = XTkBTreeNextLine(tls, libc.UintptrFromInt32(0), linePtr) segPtr = (*TTkTextLine)(unsafe.Pointer(linePtr)).FsegPtr } if numBytes <= (*TTkTextSegment)(unsafe.Pointer(segPtr)).Fsize { break } if (*TTkTextSegment)(unsafe.Pointer(segPtr)).FtypePtr == uintptr(unsafe.Pointer(&XtkTextCharType)) { charIndex += libtcl9_0.XTcl_NumUtfChars(tls, segPtr+24, (*TTkTextSegment)(unsafe.Pointer(segPtr)).Fsize) } else { charIndex += (*TTkTextSegment)(unsafe.Pointer(segPtr)).Fsize } numBytes -= (*TTkTextSegment)(unsafe.Pointer(segPtr)).Fsize goto _1 _1: ; segPtr = (*TTkTextSegment)(unsafe.Pointer(segPtr)).FnextPtr } if (*TTkTextSegment)(unsafe.Pointer(segPtr)).FtypePtr == uintptr(unsafe.Pointer(&XtkTextCharType)) { charIndex += libtcl9_0.XTcl_NumUtfChars(tls, segPtr+24, numBytes) } else { charIndex += numBytes } return int64(libc.X__builtin_snprintf(tls, string1, uint64(TK_POS_CHARS), __ccgo_ts+47938, libc.VaList(bp+8, XTkBTreeLinesTo(tls, textPtr, (*TTkTextIndex)(unsafe.Pointer(indexPtr)).FlinePtr)+int32(1), charIndex))) } /* *--------------------------------------------------------------------------- * * TkTextIndexCmp -- * * Compare two indices to see which one is earlier in the text. * * Results: * The return value is 0 if index1Ptr and index2Ptr refer to the same * position in the file, -1 if index1Ptr refers to an earlier position * than index2Ptr, and 1 otherwise. * * Side effects: * None. * *--------------------------------------------------------------------------- */ func XTkTextIndexCmp(tls *libc.TLS, index1Ptr uintptr, index2Ptr uintptr) (r int32) { /* Second index. */ var line1, line2 int32 _, _ = line1, line2 if (*TTkTextIndex)(unsafe.Pointer(index1Ptr)).FlinePtr == (*TTkTextIndex)(unsafe.Pointer(index2Ptr)).FlinePtr { if (*TTkTextIndex)(unsafe.Pointer(index1Ptr)).FbyteIndex < (*TTkTextIndex)(unsafe.Pointer(index2Ptr)).FbyteIndex { return -int32(1) } else { if (*TTkTextIndex)(unsafe.Pointer(index1Ptr)).FbyteIndex > (*TTkTextIndex)(unsafe.Pointer(index2Ptr)).FbyteIndex { return int32(1) } else { return 0 } } } /* * Assumption here that it is ok for comparisons to reflect the full * B-tree and not just the portion that is available to any client. This * should be true because the only indexPtr's we should be given are ones * which are valid for the current client. */ line1 = XTkBTreeLinesTo(tls, libc.UintptrFromInt32(0), (*TTkTextIndex)(unsafe.Pointer(index1Ptr)).FlinePtr) line2 = XTkBTreeLinesTo(tls, libc.UintptrFromInt32(0), (*TTkTextIndex)(unsafe.Pointer(index2Ptr)).FlinePtr) if line1 < line2 { return -int32(1) } if line1 > line2 { return int32(1) } return 0 } /* *--------------------------------------------------------------------------- * * ForwBack -- * * This function handles +/- modifiers for indices to adjust the index * forwards or backwards. * * Results: * If the modifier in string is successfully parsed then the return value * is the address of the first character after the modifier, and * *indexPtr is updated to reflect the modifier. If there is a syntax * error in the modifier then NULL is returned. * * Side effects: * None. * *--------------------------------------------------------------------------- */ func _ForwBack(tls *libc.TLS, textPtr uintptr, string1 uintptr, indexPtr uintptr) (r uintptr) { bp := tls.Alloc(48) defer tls.Free(48) /* Index to update as specified in string. */ var count, forward, lineIndex, modifier, v1, v15, v16, v18, v19, v2, v22, v23, v4, v5, v7, v8 int32 var length Tsize_t var p, units uintptr var type1, type11 TTkTextCountType var v10, v12, v14, v21 bool var v11, v13 uint64 var _ /* end at bp+0 */ uintptr var _ /* indexPtr2 at bp+16 */ TTkTextIndex var _ /* xOffset at bp+8 */ int32 _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = count, forward, length, lineIndex, modifier, p, type1, type11, units, v1, v10, v11, v12, v13, v14, v15, v16, v18, v19, v2, v21, v22, v23, v4, v5, v7, v8 /* * Get the count (how many units forward or backward). */ p = string1 + uintptr(1) for { v1 = libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(p))) v2 = libc.BoolInt32(v1 == int32(' ') || libc.Uint32FromInt32(v1)-uint32('\t') < uint32(5)) goto _3 _3: if !(v2 != 0) { break } p++ } count = int32(libc.Xstrtol(tls, p, bp, 0)) if *(*uintptr)(unsafe.Pointer(bp)) == p { return libc.UintptrFromInt32(0) } p = *(*uintptr)(unsafe.Pointer(bp)) for { v4 = libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(p))) v5 = libc.BoolInt32(v4 == int32(' ') || libc.Uint32FromInt32(v4)-uint32('\t') < uint32(5)) goto _6 _6: if !(v5 != 0) { break } p++ } /* * Find the end of this modifier (next space or + or - character), then * check if there is a textual 'display' or 'any' modifier. These * modifiers can be their own word (in which case they can be abbreviated) * or they can follow on to the actual unit in a single word (in which * case no abbreviation is allowed). So, 'display lines', 'd lines', * 'displaylin' are all ok, but 'dline' is not. */ units = p for { if v10 = libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(p))) != int32('\000'); v10 { v7 = libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(p))) v8 = libc.BoolInt32(v7 == int32(' ') || libc.Uint32FromInt32(v7)-uint32('\t') < uint32(5)) goto _9 _9: } if !(v10 && !(v8 != 0) && libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(p))) != int32('+') && libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(p))) != int32('-')) { break } p++ } length = libc.Uint64FromInt64(int64(p) - int64(units)) if v12 = libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(units))) == int32('d'); v12 { if length > uint64(7) { v11 = uint64(7) } else { v11 = length } } if v12 && libc.Xstrncmp(tls, units, __ccgo_ts+41488, v11) == 0 { modifier = int32(TKINDEX_DISPLAY) if length > uint64(7) { p -= uintptr(length - libc.Uint64FromInt32(7)) } } else { if v14 = libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(units))) == int32('a'); v14 { if length > uint64(3) { v13 = uint64(3) } else { v13 = length } } if v14 && libc.Xstrncmp(tls, units, __ccgo_ts+47945, v13) == 0 { modifier = int32(TKINDEX_ANY) if length > uint64(3) { p -= uintptr(length - libc.Uint64FromInt32(3)) } } else { modifier = TKINDEX_NONE } } /* * If we had a modifier, which we interpreted ok, so now forward to the * actual units. */ if modifier != TKINDEX_NONE { for { v15 = libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(p))) v16 = libc.BoolInt32(v15 == int32(' ') || libc.Uint32FromInt32(v15)-uint32('\t') < uint32(5)) goto _17 _17: if !(v16 != 0) { break } p++ } units = p for { if v21 = libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(p))) != int32('\000'); v21 { v18 = libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(p))) v19 = libc.BoolInt32(v18 == int32(' ') || libc.Uint32FromInt32(v18)-uint32('\t') < uint32(5)) goto _20 _20: } if !(v21 && !(v19 != 0) && libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(p))) != int32('+') && libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(p))) != int32('-')) { break } p++ } length = libc.Uint64FromInt64(int64(p) - int64(units)) } /* * Finally parse the units. */ if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(units))) == int32('c') && libc.Xstrncmp(tls, units, __ccgo_ts+47949, length) == 0 { if modifier == TKINDEX_NONE { type1 = int32(COUNT_INDICES) } else { if modifier == int32(TKINDEX_ANY) { type1 = COUNT_CHARS } else { type1 = libc.Int32FromInt32(COUNT_CHARS) | libc.Int32FromInt32(COUNT_DISPLAY) } } if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(string1))) == int32('+') { XTkTextIndexForwChars(tls, textPtr, indexPtr, count, indexPtr, type1) } else { XTkTextIndexBackChars(tls, textPtr, indexPtr, count, indexPtr, type1) } } else { if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(units))) == int32('i') && libc.Xstrncmp(tls, units, __ccgo_ts+47955, length) == 0 { if modifier == int32(TKINDEX_DISPLAY) { type11 = libc.Int32FromInt32(COUNT_INDICES) | libc.Int32FromInt32(COUNT_DISPLAY) } else { type11 = int32(COUNT_INDICES) } if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(string1))) == int32('+') { XTkTextIndexForwChars(tls, textPtr, indexPtr, count, indexPtr, type11) } else { XTkTextIndexBackChars(tls, textPtr, indexPtr, count, indexPtr, type11) } } else { if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(units))) == int32('l') && libc.Xstrncmp(tls, units, __ccgo_ts+47963, length) == 0 { if modifier == int32(TKINDEX_DISPLAY) { if XTkTextIsElided(tls, textPtr, indexPtr, libc.UintptrFromInt32(0)) != 0 { /* * Go forward to the first non-elided index. */ XTkTextIndexForwChars(tls, textPtr, indexPtr, 0, indexPtr, libc.Int32FromInt32(COUNT_INDICES)|libc.Int32FromInt32(COUNT_DISPLAY)) } /* * Unlike the Forw/BackChars code, the display line code is * sensitive to whether we are genuinely going forwards or * backwards. So, we need to determine that. This is important in * the case where we have "+ -3 displaylines", for example. */ if libc.BoolInt32(count < 0)^libc.BoolInt32(libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(string1))) == int32('-')) != 0 { forward = 0 } else { forward = int32(1) } count = libc.Xabs(tls, count) if count == 0 { return p } if forward != 0 { XTkTextFindDisplayLineEnd(tls, textPtr, indexPtr, int32(1), bp+8) for { v22 = count count-- if !(v22 > 0) { break } /* * Go to the end of the line, then forward one char/byte * to get to the beginning of the next line. */ XTkTextFindDisplayLineEnd(tls, textPtr, indexPtr, int32(1), libc.UintptrFromInt32(0)) XTkTextIndexForwChars(tls, textPtr, indexPtr, int32(1), indexPtr, libc.Int32FromInt32(COUNT_INDICES)|libc.Int32FromInt32(COUNT_DISPLAY)) } } else { XTkTextFindDisplayLineEnd(tls, textPtr, indexPtr, 0, bp+8) for { v23 = count count-- if !(v23 > 0) { break } /* * Go to the beginning of the line, then backward one * char/byte to get to the end of the previous line. */ XTkTextFindDisplayLineEnd(tls, textPtr, indexPtr, 0, libc.UintptrFromInt32(0)) XTkTextIndexBackChars(tls, textPtr, indexPtr, int32(1), bp+16, libc.Int32FromInt32(COUNT_INDICES)|libc.Int32FromInt32(COUNT_DISPLAY)) /* * If we couldn't go to the previous line, then we wanted to go before the start of the text: arrange for returning the first index of the first display line. */ if !(XTkTextIndexCmp(tls, indexPtr, bp+16) != 0) { *(*int32)(unsafe.Pointer(bp + 8)) = 0 break } *(*TTkTextIndex)(unsafe.Pointer(indexPtr)) = *(*TTkTextIndex)(unsafe.Pointer(bp + 16)) } } XTkTextFindDisplayLineEnd(tls, textPtr, indexPtr, 0, libc.UintptrFromInt32(0)) /* * This call assumes indexPtr is the beginning of a display line * and moves it to the 'xOffset' position of that line, which is * just what we want. */ XTkTextIndexOfX(tls, textPtr, *(*int32)(unsafe.Pointer(bp + 8)), indexPtr) } else { lineIndex = XTkBTreeLinesTo(tls, textPtr, (*TTkTextIndex)(unsafe.Pointer(indexPtr)).FlinePtr) if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(string1))) == int32('+') { lineIndex += count } else { lineIndex -= count /* * The check below retains the character position, even if the * line runs off the start of the file. Without it, the * character position will get reset to 0 by TkTextMakeIndex. */ if lineIndex < 0 { lineIndex = 0 } } /* * This doesn't work quite right if using a proportional font or * UTF-8 characters with varying numbers of bytes, or if there are * embedded windows, images, etc. The cursor will bop around, * keeping a constant number of bytes (not characters) from the * left edge (but making sure not to split any UTF-8 characters), * regardless of the x-position the index corresponds to. The * proper way to do this is to get the x-position of the index and * then pick the character at the same x-position in the new line. */ XTkTextMakeByteIndex(tls, (*TTkTextIndex)(unsafe.Pointer(indexPtr)).Ftree, textPtr, lineIndex, (*TTkTextIndex)(unsafe.Pointer(indexPtr)).FbyteIndex, indexPtr) } } else { return libc.UintptrFromInt32(0) } } } return p } /* *--------------------------------------------------------------------------- * * TkTextIndexForwBytes -- * * Given an index for a text widget, this function creates a new index * that points "count" bytes ahead of the source index. * * Results: * *dstPtr is modified to refer to the character "count" bytes after * srcPtr, or to the last character in the TkText if there aren't "count" * bytes left. * * In this latter case, the function returns '1' to indicate that not all * of 'byteCount' could be used. * * Side effects: * None. * *--------------------------------------------------------------------------- */ func XTkTextIndexForwBytes(tls *libc.TLS, textPtr uintptr, srcPtr uintptr, byteCount TTcl_Size, dstPtr uintptr) (r int32) { /* Destination index: gets modified. */ var lineLength int32 var linePtr, segPtr uintptr _, _, _ = lineLength, linePtr, segPtr if byteCount < 0 { XTkTextIndexBackBytes(tls, textPtr, srcPtr, -byteCount, dstPtr) return 0 } *(*TTkTextIndex)(unsafe.Pointer(dstPtr)) = *(*TTkTextIndex)(unsafe.Pointer(srcPtr)) *(*TTcl_Size)(unsafe.Pointer(dstPtr + 16)) += byteCount for int32(1) != 0 { /* * Compute the length of the current line. */ lineLength = 0 segPtr = (*TTkTextLine)(unsafe.Pointer((*TTkTextIndex)(unsafe.Pointer(dstPtr)).FlinePtr)).FsegPtr for { if !(segPtr != libc.UintptrFromInt32(0)) { break } lineLength = int32(int64(lineLength) + (*TTkTextSegment)(unsafe.Pointer(segPtr)).Fsize) goto _1 _1: ; segPtr = (*TTkTextSegment)(unsafe.Pointer(segPtr)).FnextPtr } /* * If the new index is in the same line then we're done. Otherwise go * on to the next line. */ if (*TTkTextIndex)(unsafe.Pointer(dstPtr)).FbyteIndex < int64(lineLength) { return 0 } *(*TTcl_Size)(unsafe.Pointer(dstPtr + 16)) -= int64(lineLength) linePtr = XTkBTreeNextLine(tls, textPtr, (*TTkTextIndex)(unsafe.Pointer(dstPtr)).FlinePtr) if linePtr == libc.UintptrFromInt32(0) { (*TTkTextIndex)(unsafe.Pointer(dstPtr)).FbyteIndex = int64(lineLength - int32(1)) return int32(1) } (*TTkTextIndex)(unsafe.Pointer(dstPtr)).FlinePtr = linePtr } return r } /* *--------------------------------------------------------------------------- * * TkTextIndexForwChars -- * * Given an index for a text widget, this function creates a new index * that points "count" items of type given by "type" ahead of the source * index. "count" can be zero, which is useful in the case where one * wishes to move forward by display (non-elided) chars or indices or one * wishes to move forward by chars, skipping any intervening indices. In * this case dstPtr will point to the first acceptable index which is * encountered. * * Results: * *dstPtr is modified to refer to the character "count" items after * srcPtr, or to the last character in the TkText if there aren't * sufficient items left in the widget. * * Side effects: * None. * *--------------------------------------------------------------------------- */ func XTkTextIndexForwChars(tls *libc.TLS, textPtr uintptr, srcPtr uintptr, charCount int32, dstPtr uintptr, type1 TTkTextCountType) { bp := tls.Alloc(16) defer tls.Free(16) /* The type of item to count */ var checkElided, elide int32 var end, infoPtr, linePtr, p, segPtr, start, tagPtr, v3, p5 uintptr var v2 TTcl_Size var _ /* byteOffset at bp+0 */ TTcl_Size var _ /* ch at bp+8 */ int32 _, _, _, _, _, _, _, _, _, _, _, _ = checkElided, elide, end, infoPtr, linePtr, p, segPtr, start, tagPtr, v2, v3, p5 infoPtr = libc.UintptrFromInt32(0) elide = 0 checkElided = type1 & int32(COUNT_DISPLAY) if charCount < 0 { XTkTextIndexBackChars(tls, textPtr, srcPtr, -charCount, dstPtr, type1) return } if checkElided != 0 { infoPtr = libtcl9_0.XTcl_Alloc(tls, uint64(12056)) elide = XTkTextIsElided(tls, textPtr, srcPtr, infoPtr) } *(*TTkTextIndex)(unsafe.Pointer(dstPtr)) = *(*TTkTextIndex)(unsafe.Pointer(srcPtr)) /* * Find seg that contains src byteIndex. Move forward specified number of * chars. */ if checkElided != 0 { /* * In this case we have already calculated the information we need, so * no need to use TkTextIndexToSeg() */ segPtr = (*TTkTextElideInfo)(unsafe.Pointer(infoPtr)).FsegPtr *(*TTcl_Size)(unsafe.Pointer(bp)) = (*TTkTextIndex)(unsafe.Pointer(dstPtr)).FbyteIndex - int64((*TTkTextElideInfo)(unsafe.Pointer(infoPtr)).FsegOffset) } else { segPtr = XTkTextIndexToSeg(tls, dstPtr, bp) } for int32(1) != 0 { /* * Go through each segment in line looking for specified character * index. */ for { if !(segPtr != libc.UintptrFromInt32(0)) { break } /* * If we do need to pay attention to the visibility of * characters/indices, check that first. If the current segment * isn't visible, then we simply continue the loop. */ if checkElided != 0 && ((*TTkTextSegment)(unsafe.Pointer(segPtr)).FtypePtr == uintptr(unsafe.Pointer(&XtkTextToggleOffType)) || (*TTkTextSegment)(unsafe.Pointer(segPtr)).FtypePtr == uintptr(unsafe.Pointer(&XtkTextToggleOnType))) { tagPtr = (*(*TTkTextToggle)(unsafe.Pointer(&(*TTkTextSegment)(unsafe.Pointer(segPtr)).Fbody))).FtagPtr /* * The elide state only changes if this tag is either the * current highest priority tag (and is therefore being * toggled off), or it's a new tag with higher priority. */ if (*TTkTextTag)(unsafe.Pointer(tagPtr)).Felide >= 0 { *(*int32)(unsafe.Pointer((*TTkTextElideInfo)(unsafe.Pointer(infoPtr)).FtagCnts + uintptr((*TTkTextTag)(unsafe.Pointer(tagPtr)).Fpriority)*4))++ if *(*int32)(unsafe.Pointer((*TTkTextElideInfo)(unsafe.Pointer(infoPtr)).FtagCnts + uintptr((*TTkTextTag)(unsafe.Pointer(tagPtr)).Fpriority)*4))&int32(1) != 0 { *(*uintptr)(unsafe.Pointer((*TTkTextElideInfo)(unsafe.Pointer(infoPtr)).FtagPtrs + uintptr((*TTkTextTag)(unsafe.Pointer(tagPtr)).Fpriority)*8)) = tagPtr } if (*TTkTextTag)(unsafe.Pointer(tagPtr)).Fpriority >= (*TTkTextElideInfo)(unsafe.Pointer(infoPtr)).FelidePriority { if (*TTkTextSegment)(unsafe.Pointer(segPtr)).FtypePtr == uintptr(unsafe.Pointer(&XtkTextToggleOffType)) { /* * If it is being toggled off, and it has an elide * string, it must actually be the current highest * priority tag, so this check is redundant: */ if (*TTkTextTag)(unsafe.Pointer(tagPtr)).Fpriority != (*TTkTextElideInfo)(unsafe.Pointer(infoPtr)).FelidePriority { libtcl9_0.XTcl_Panic(tls, __ccgo_ts+46912, 0) } /* * Find previous elide tag, if any (if not then * elide will be zero, of course). */ elide = 0 for { v3 = infoPtr + 16 *(*TTcl_Size)(unsafe.Pointer(v3))-- v2 = *(*TTcl_Size)(unsafe.Pointer(v3)) if !(v2 > 0) { break } if *(*int32)(unsafe.Pointer((*TTkTextElideInfo)(unsafe.Pointer(infoPtr)).FtagCnts + uintptr((*TTkTextElideInfo)(unsafe.Pointer(infoPtr)).FelidePriority)*4))&int32(1) != 0 { elide = libc.BoolInt32((*TTkTextTag)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer((*TTkTextElideInfo)(unsafe.Pointer(infoPtr)).FtagPtrs + uintptr((*TTkTextElideInfo)(unsafe.Pointer(infoPtr)).FelidePriority)*8)))).Felide > 0) break } } } else { elide = libc.BoolInt32((*TTkTextTag)(unsafe.Pointer(tagPtr)).Felide > 0) (*TTkTextElideInfo)(unsafe.Pointer(infoPtr)).FelidePriority = (*TTkTextTag)(unsafe.Pointer(tagPtr)).Fpriority } } } } if !(elide != 0) { if (*TTkTextSegment)(unsafe.Pointer(segPtr)).FtypePtr == uintptr(unsafe.Pointer(&XtkTextCharType)) { start = segPtr + 24 + uintptr(*(*TTcl_Size)(unsafe.Pointer(bp))) end = segPtr + 24 + uintptr((*TTkTextSegment)(unsafe.Pointer(segPtr)).Fsize) p = start for { if !(p < end) { break } if charCount == 0 { *(*TTcl_Size)(unsafe.Pointer(dstPtr + 16)) += int64(p) - int64(start) goto forwardCharDone } charCount-- goto _4 _4: ; p += uintptr(libtcl9_0.XTcl_UtfToUniChar(tls, p, bp+8)) } } else { if type1&int32(COUNT_INDICES) != 0 { if int64(charCount)+*(*TTcl_Size)(unsafe.Pointer(bp)) < (*TTkTextSegment)(unsafe.Pointer(segPtr)).Fsize { *(*TTcl_Size)(unsafe.Pointer(dstPtr + 16)) += int64(charCount) goto forwardCharDone } charCount = int32(int64(charCount) - ((*TTkTextSegment)(unsafe.Pointer(segPtr)).Fsize - *(*TTcl_Size)(unsafe.Pointer(bp)))) } } } *(*TTcl_Size)(unsafe.Pointer(dstPtr + 16)) += (*TTkTextSegment)(unsafe.Pointer(segPtr)).Fsize - *(*TTcl_Size)(unsafe.Pointer(bp)) *(*TTcl_Size)(unsafe.Pointer(bp)) = 0 goto _1 _1: ; segPtr = (*TTkTextSegment)(unsafe.Pointer(segPtr)).FnextPtr } /* * Go to the next line. If we are at the end of the text item, back up * one byte (for the terminal '\n' character) and return that index. */ linePtr = XTkBTreeNextLine(tls, textPtr, (*TTkTextIndex)(unsafe.Pointer(dstPtr)).FlinePtr) if linePtr == libc.UintptrFromInt32(0) { p5 = dstPtr + 16 *(*TTcl_Size)(unsafe.Pointer(p5)) = TTcl_Size(uint64(*(*TTcl_Size)(unsafe.Pointer(p5))) - libc.Uint64FromInt64(1)) goto forwardCharDone } (*TTkTextIndex)(unsafe.Pointer(dstPtr)).FlinePtr = linePtr (*TTkTextIndex)(unsafe.Pointer(dstPtr)).FbyteIndex = 0 segPtr = (*TTkTextLine)(unsafe.Pointer((*TTkTextIndex)(unsafe.Pointer(dstPtr)).FlinePtr)).FsegPtr } goto forwardCharDone forwardCharDone: ; if infoPtr != libc.UintptrFromInt32(0) { XTkTextFreeElideInfo(tls, infoPtr) libtcl9_0.XTcl_Free(tls, infoPtr) } } /* *--------------------------------------------------------------------------- * * TkTextIndexCountBytes -- * * Given a pair of indices in a text widget, this function counts how * many bytes are between the two indices. The two indices do not need * to be ordered. * * Results: * The number of bytes in the given range. * * Side effects: * None. * *--------------------------------------------------------------------------- */ func XTkTextIndexCountBytes(tls *libc.TLS, textPtr uintptr, indexPtr1 uintptr, indexPtr2 uintptr) (r int32) { /* Index describing second location. */ var compare int32 _ = compare compare = XTkTextIndexCmp(tls, indexPtr1, indexPtr2) if compare == 0 { return 0 } else { if compare > 0 { return _IndexCountBytesOrdered(tls, textPtr, indexPtr2, indexPtr1) } else { return _IndexCountBytesOrdered(tls, textPtr, indexPtr1, indexPtr2) } } return r } func _IndexCountBytesOrdered(tls *libc.TLS, textPtr uintptr, indexPtr1 uintptr, indexPtr2 uintptr) (r int32) { bp := tls.Alloc(16) defer tls.Free(16) /* Index describing location of last character * at which to stop the count. */ var byteCount TTcl_Size var linePtr, segPtr, segPtr1 uintptr var _ /* offset at bp+0 */ TTcl_Size _, _, _, _ = byteCount, linePtr, segPtr, segPtr1 if (*TTkTextIndex)(unsafe.Pointer(indexPtr1)).FlinePtr == (*TTkTextIndex)(unsafe.Pointer(indexPtr2)).FlinePtr { return int32((*TTkTextIndex)(unsafe.Pointer(indexPtr2)).FbyteIndex - (*TTkTextIndex)(unsafe.Pointer(indexPtr1)).FbyteIndex) } /* * indexPtr2 is on a line strictly after the line containing indexPtr1. * Add up: * bytes between indexPtr1 and end of its line * bytes in lines strictly between indexPtr1 and indexPtr2 * bytes between start of the indexPtr2 line and indexPtr2 */ segPtr1 = XTkTextIndexToSeg(tls, indexPtr1, bp) byteCount = -*(*TTcl_Size)(unsafe.Pointer(bp)) segPtr = segPtr1 for { if !(segPtr != libc.UintptrFromInt32(0)) { break } byteCount += (*TTkTextSegment)(unsafe.Pointer(segPtr)).Fsize goto _1 _1: ; segPtr = (*TTkTextSegment)(unsafe.Pointer(segPtr)).FnextPtr } linePtr = XTkBTreeNextLine(tls, textPtr, (*TTkTextIndex)(unsafe.Pointer(indexPtr1)).FlinePtr) for linePtr != (*TTkTextIndex)(unsafe.Pointer(indexPtr2)).FlinePtr { segPtr = (*TTkTextLine)(unsafe.Pointer(linePtr)).FsegPtr for { if !(segPtr != libc.UintptrFromInt32(0)) { break } byteCount += (*TTkTextSegment)(unsafe.Pointer(segPtr)).Fsize goto _2 _2: ; segPtr = (*TTkTextSegment)(unsafe.Pointer(segPtr)).FnextPtr } linePtr = XTkBTreeNextLine(tls, textPtr, linePtr) if linePtr == libc.UintptrFromInt32(0) { libtcl9_0.XTcl_Panic(tls, __ccgo_ts+47969, 0) } } byteCount += (*TTkTextIndex)(unsafe.Pointer(indexPtr2)).FbyteIndex return int32(byteCount) } /* *--------------------------------------------------------------------------- * * TkTextIndexCount -- * * Given an ordered pair of indices in a text widget, this function * counts how many characters (not bytes) are between the two indices. * * It is illegal to call this function with unordered indices. * * Note that 'textPtr' is only used if we need to check for elided * attributes, i.e. if type is COUNT_DISPLAY_INDICES or * COUNT_DISPLAY_CHARS. * * Results: * The number of characters in the given range, which meet the * appropriate 'type' attributes. * * Side effects: * None. * *--------------------------------------------------------------------------- */ func XTkTextIndexCount(tls *libc.TLS, textPtr uintptr, indexPtr1 uintptr, indexPtr2 uintptr, type1 TTkTextCountType) (r int32) { bp := tls.Alloc(16) defer tls.Free(16) /* The kind of indices to count. */ var byteLen, byteLen1, count, i, v2 TTcl_Size var checkElided, elide int32 var infoPtr, linePtr1, seg2Ptr, segPtr, str, tagPtr, v3 uintptr var _ /* byteOffset at bp+0 */ TTcl_Size var _ /* maxBytes at bp+8 */ TTcl_Size _, _, _, _, _, _, _, _, _, _, _, _, _, _ = byteLen, byteLen1, checkElided, count, elide, i, infoPtr, linePtr1, seg2Ptr, segPtr, str, tagPtr, v2, v3 seg2Ptr = libc.UintptrFromInt32(0) infoPtr = libc.UintptrFromInt32(0) count = 0 elide = 0 checkElided = type1 & int32(COUNT_DISPLAY) /* * Find seg that contains src index, and remember how many bytes not to * count in the given segment. */ segPtr = XTkTextIndexToSeg(tls, indexPtr1, bp) linePtr1 = (*TTkTextIndex)(unsafe.Pointer(indexPtr1)).FlinePtr seg2Ptr = XTkTextIndexToSeg(tls, indexPtr2, bp+8) if checkElided != 0 { infoPtr = libtcl9_0.XTcl_Alloc(tls, uint64(12056)) elide = XTkTextIsElided(tls, textPtr, indexPtr1, infoPtr) } for int32(1) != 0 { /* * Go through each segment in line adding up the number of characters. */ for { if !(segPtr != libc.UintptrFromInt32(0)) { break } /* * If we do need to pay attention to the visibility of * characters/indices, check that first. If the current segment * isn't visible, then we simply continue the loop. */ if checkElided != 0 { if (*TTkTextSegment)(unsafe.Pointer(segPtr)).FtypePtr == uintptr(unsafe.Pointer(&XtkTextToggleOffType)) || (*TTkTextSegment)(unsafe.Pointer(segPtr)).FtypePtr == uintptr(unsafe.Pointer(&XtkTextToggleOnType)) { tagPtr = (*(*TTkTextToggle)(unsafe.Pointer(&(*TTkTextSegment)(unsafe.Pointer(segPtr)).Fbody))).FtagPtr /* * The elide state only changes if this tag is either the * current highest priority tag (and is therefore being * toggled off), or it's a new tag with higher priority. */ if (*TTkTextTag)(unsafe.Pointer(tagPtr)).Felide >= 0 { *(*int32)(unsafe.Pointer((*TTkTextElideInfo)(unsafe.Pointer(infoPtr)).FtagCnts + uintptr((*TTkTextTag)(unsafe.Pointer(tagPtr)).Fpriority)*4))++ if *(*int32)(unsafe.Pointer((*TTkTextElideInfo)(unsafe.Pointer(infoPtr)).FtagCnts + uintptr((*TTkTextTag)(unsafe.Pointer(tagPtr)).Fpriority)*4))&int32(1) != 0 { *(*uintptr)(unsafe.Pointer((*TTkTextElideInfo)(unsafe.Pointer(infoPtr)).FtagPtrs + uintptr((*TTkTextTag)(unsafe.Pointer(tagPtr)).Fpriority)*8)) = tagPtr } if (*TTkTextTag)(unsafe.Pointer(tagPtr)).Fpriority >= (*TTkTextElideInfo)(unsafe.Pointer(infoPtr)).FelidePriority { if (*TTkTextSegment)(unsafe.Pointer(segPtr)).FtypePtr == uintptr(unsafe.Pointer(&XtkTextToggleOffType)) { /* * If it is being toggled off, and it has an * elide string, it must actually be the * current highest priority tag, so this check * is redundant: */ if (*TTkTextTag)(unsafe.Pointer(tagPtr)).Fpriority != (*TTkTextElideInfo)(unsafe.Pointer(infoPtr)).FelidePriority { libtcl9_0.XTcl_Panic(tls, __ccgo_ts+46912, 0) } /* * Find previous elide tag, if any (if not * then elide will be zero, of course). */ elide = 0 for { v3 = infoPtr + 16 *(*TTcl_Size)(unsafe.Pointer(v3))-- v2 = *(*TTcl_Size)(unsafe.Pointer(v3)) if !(v2 > 0) { break } if *(*int32)(unsafe.Pointer((*TTkTextElideInfo)(unsafe.Pointer(infoPtr)).FtagCnts + uintptr((*TTkTextElideInfo)(unsafe.Pointer(infoPtr)).FelidePriority)*4))&int32(1) != 0 { elide = libc.BoolInt32((*TTkTextTag)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer((*TTkTextElideInfo)(unsafe.Pointer(infoPtr)).FtagPtrs + uintptr((*TTkTextElideInfo)(unsafe.Pointer(infoPtr)).FelidePriority)*8)))).Felide > 0) break } } } else { elide = libc.BoolInt32((*TTkTextTag)(unsafe.Pointer(tagPtr)).Felide > 0) (*TTkTextElideInfo)(unsafe.Pointer(infoPtr)).FelidePriority = (*TTkTextTag)(unsafe.Pointer(tagPtr)).Fpriority } } } } if elide != 0 { if segPtr == seg2Ptr { goto countDone } *(*TTcl_Size)(unsafe.Pointer(bp)) = 0 goto _1 } } if (*TTkTextSegment)(unsafe.Pointer(segPtr)).FtypePtr == uintptr(unsafe.Pointer(&XtkTextCharType)) { byteLen = (*TTkTextSegment)(unsafe.Pointer(segPtr)).Fsize - *(*TTcl_Size)(unsafe.Pointer(bp)) str = segPtr + 24 + uintptr(*(*TTcl_Size)(unsafe.Pointer(bp))) if segPtr == seg2Ptr { if byteLen+*(*TTcl_Size)(unsafe.Pointer(bp)) > *(*TTcl_Size)(unsafe.Pointer(bp + 8)) { byteLen = *(*TTcl_Size)(unsafe.Pointer(bp + 8)) - *(*TTcl_Size)(unsafe.Pointer(bp)) } } i = byteLen /* * This is a speed sensitive function, so run specially over * the string to count continuous ascii characters before * resorting to the Tcl_NumUtfChars call. This is a long form * of: * * stringPtr->numChars = * Tcl_NumUtfChars(objPtr->bytes, objPtr->length); */ for i != 0 && libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(str))) < int32(0xC0) { i-- str++ } count += byteLen - i if i != 0 { count += libtcl9_0.XTcl_NumUtfChars(tls, segPtr+24+uintptr(*(*TTcl_Size)(unsafe.Pointer(bp)))+uintptr(byteLen-i), i) } } else { if type1&int32(COUNT_INDICES) != 0 { byteLen1 = (*TTkTextSegment)(unsafe.Pointer(segPtr)).Fsize - *(*TTcl_Size)(unsafe.Pointer(bp)) if segPtr == seg2Ptr { if byteLen1+*(*TTcl_Size)(unsafe.Pointer(bp)) > *(*TTcl_Size)(unsafe.Pointer(bp + 8)) { byteLen1 = *(*TTcl_Size)(unsafe.Pointer(bp + 8)) - *(*TTcl_Size)(unsafe.Pointer(bp)) } } count += byteLen1 } } if segPtr == seg2Ptr { goto countDone } *(*TTcl_Size)(unsafe.Pointer(bp)) = 0 goto _1 _1: ; segPtr = (*TTkTextSegment)(unsafe.Pointer(segPtr)).FnextPtr } /* * Go to the next line. If we are at the end of the text item, back up * one byte (for the terminal '\n' character) and return that index. */ linePtr1 = XTkBTreeNextLine(tls, textPtr, linePtr1) if linePtr1 == libc.UintptrFromInt32(0) { libtcl9_0.XTcl_Panic(tls, __ccgo_ts+48013, 0) } segPtr = (*TTkTextLine)(unsafe.Pointer(linePtr1)).FsegPtr } goto countDone countDone: ; if infoPtr != libc.UintptrFromInt32(0) { XTkTextFreeElideInfo(tls, infoPtr) libtcl9_0.XTcl_Free(tls, infoPtr) } return int32(count) } /* *--------------------------------------------------------------------------- * * TkTextIndexBackBytes -- * * Given an index for a text widget, this function creates a new index * that points "count" bytes earlier than the source index. * * Results: * *dstPtr is modified to refer to the character "count" bytes before * srcPtr, or to the first character in the TkText if there aren't * "count" bytes earlier than srcPtr. * * Returns 1 if we couldn't use all of 'byteCount' because we have run * into the beginning or end of the text, and zero otherwise. * * Side effects: * None. * *--------------------------------------------------------------------------- */ func XTkTextIndexBackBytes(tls *libc.TLS, textPtr uintptr, srcPtr uintptr, byteCount TTcl_Size, dstPtr uintptr) (r int32) { /* Destination index: gets modified. */ var lineIndex int32 var segPtr uintptr _, _ = lineIndex, segPtr if byteCount < 0 { return XTkTextIndexForwBytes(tls, textPtr, srcPtr, -byteCount, dstPtr) } *(*TTkTextIndex)(unsafe.Pointer(dstPtr)) = *(*TTkTextIndex)(unsafe.Pointer(srcPtr)) *(*TTcl_Size)(unsafe.Pointer(dstPtr + 16)) -= byteCount lineIndex = -int32(1) for (*TTkTextIndex)(unsafe.Pointer(dstPtr)).FbyteIndex < 0 { /* * Move back one line in the text. If we run off the beginning of the * file then just return the first character in the text. */ if lineIndex < 0 { lineIndex = XTkBTreeLinesTo(tls, textPtr, (*TTkTextIndex)(unsafe.Pointer(dstPtr)).FlinePtr) } if lineIndex == 0 { (*TTkTextIndex)(unsafe.Pointer(dstPtr)).FbyteIndex = 0 return int32(1) } lineIndex-- (*TTkTextIndex)(unsafe.Pointer(dstPtr)).FlinePtr = XTkBTreeFindLine(tls, (*TTkTextIndex)(unsafe.Pointer(dstPtr)).Ftree, textPtr, lineIndex) /* * Compute the length of the line and add that to dstPtr->charIndex. */ segPtr = (*TTkTextLine)(unsafe.Pointer((*TTkTextIndex)(unsafe.Pointer(dstPtr)).FlinePtr)).FsegPtr for { if !(segPtr != libc.UintptrFromInt32(0)) { break } *(*TTcl_Size)(unsafe.Pointer(dstPtr + 16)) += (*TTkTextSegment)(unsafe.Pointer(segPtr)).Fsize goto _1 _1: ; segPtr = (*TTkTextSegment)(unsafe.Pointer(segPtr)).FnextPtr } } return 0 } /* *--------------------------------------------------------------------------- * * TkTextIndexBackChars -- * * Given an index for a text widget, this function creates a new index * that points "count" items of type given by "type" earlier than the * source index. "count" can be zero, which is useful in the case where * one wishes to move backward by display (non-elided) chars or indices * or one wishes to move backward by chars, skipping any intervening * indices. In this case the returned index *dstPtr will point just * _after_ the first acceptable index which is encountered. * * Results: * *dstPtr is modified to refer to the character "count" items before * srcPtr, or to the first index in the window if there aren't sufficient * items earlier than srcPtr. * * Side effects: * None. * *--------------------------------------------------------------------------- */ func XTkTextIndexBackChars(tls *libc.TLS, textPtr uintptr, srcPtr uintptr, charCount int32, dstPtr uintptr, type1 TTkTextCountType) { /* The type of item to count */ var checkElided, elide, lineIndex, segSize int32 var end, infoPtr, linePtr, oldPtr, p, segPtr, start, tagPtr, v3 uintptr var v2 TTcl_Size _, _, _, _, _, _, _, _, _, _, _, _, _, _ = checkElided, elide, end, infoPtr, lineIndex, linePtr, oldPtr, p, segPtr, segSize, start, tagPtr, v2, v3 infoPtr = libc.UintptrFromInt32(0) elide = 0 checkElided = type1 & int32(COUNT_DISPLAY) if charCount < 0 { XTkTextIndexForwChars(tls, textPtr, srcPtr, -charCount, dstPtr, type1) return } if checkElided != 0 { infoPtr = libtcl9_0.XTcl_Alloc(tls, uint64(12056)) elide = XTkTextIsElided(tls, textPtr, srcPtr, infoPtr) } *(*TTkTextIndex)(unsafe.Pointer(dstPtr)) = *(*TTkTextIndex)(unsafe.Pointer(srcPtr)) /* * Find offset within seg that contains byteIndex. Move backward specified * number of chars. */ lineIndex = -int32(1) segSize = int32((*TTkTextIndex)(unsafe.Pointer(dstPtr)).FbyteIndex) if checkElided != 0 { segPtr = (*TTkTextElideInfo)(unsafe.Pointer(infoPtr)).FsegPtr segSize -= (*TTkTextElideInfo)(unsafe.Pointer(infoPtr)).FsegOffset } else { linePtr = (*TTkTextIndex)(unsafe.Pointer(dstPtr)).FlinePtr segPtr = (*TTkTextLine)(unsafe.Pointer(linePtr)).FsegPtr for { if segPtr == libc.UintptrFromInt32(0) { /* * Two logical lines merged into one display line through * eliding of a newline. */ linePtr = XTkBTreeNextLine(tls, libc.UintptrFromInt32(0), linePtr) segPtr = (*TTkTextLine)(unsafe.Pointer(linePtr)).FsegPtr } if segSize <= int32((*TTkTextSegment)(unsafe.Pointer(segPtr)).Fsize) { break } segSize = int32(int64(segSize) - (*TTkTextSegment)(unsafe.Pointer(segPtr)).Fsize) goto _1 _1: ; segPtr = (*TTkTextSegment)(unsafe.Pointer(segPtr)).FnextPtr } } /* * Now segPtr points to the segment containing the starting index. */ for int32(1) != 0 { /* * If we do need to pay attention to the visibility of * characters/indices, check that first. If the current segment isn't * visible, then we simply continue the loop. */ if checkElided != 0 && ((*TTkTextSegment)(unsafe.Pointer(segPtr)).FtypePtr == uintptr(unsafe.Pointer(&XtkTextToggleOffType)) || (*TTkTextSegment)(unsafe.Pointer(segPtr)).FtypePtr == uintptr(unsafe.Pointer(&XtkTextToggleOnType))) { tagPtr = (*(*TTkTextToggle)(unsafe.Pointer(&(*TTkTextSegment)(unsafe.Pointer(segPtr)).Fbody))).FtagPtr /* * The elide state only changes if this tag is either the current * highest priority tag (and is therefore being toggled off), or * it's a new tag with higher priority. */ if (*TTkTextTag)(unsafe.Pointer(tagPtr)).Felide >= 0 { *(*int32)(unsafe.Pointer((*TTkTextElideInfo)(unsafe.Pointer(infoPtr)).FtagCnts + uintptr((*TTkTextTag)(unsafe.Pointer(tagPtr)).Fpriority)*4))++ if *(*int32)(unsafe.Pointer((*TTkTextElideInfo)(unsafe.Pointer(infoPtr)).FtagCnts + uintptr((*TTkTextTag)(unsafe.Pointer(tagPtr)).Fpriority)*4))&int32(1) != 0 { *(*uintptr)(unsafe.Pointer((*TTkTextElideInfo)(unsafe.Pointer(infoPtr)).FtagPtrs + uintptr((*TTkTextTag)(unsafe.Pointer(tagPtr)).Fpriority)*8)) = tagPtr } if (*TTkTextTag)(unsafe.Pointer(tagPtr)).Fpriority >= (*TTkTextElideInfo)(unsafe.Pointer(infoPtr)).FelidePriority { if (*TTkTextSegment)(unsafe.Pointer(segPtr)).FtypePtr == uintptr(unsafe.Pointer(&XtkTextToggleOnType)) { /* * If it is being toggled on, and it has an elide * string, it must actually be the current highest * priority tag, so this check is redundant: */ if (*TTkTextTag)(unsafe.Pointer(tagPtr)).Fpriority != (*TTkTextElideInfo)(unsafe.Pointer(infoPtr)).FelidePriority { libtcl9_0.XTcl_Panic(tls, __ccgo_ts+48065, 0) } /* * Find previous elide tag, if any (if not then elide * will be zero, of course). */ elide = 0 for { v3 = infoPtr + 16 *(*TTcl_Size)(unsafe.Pointer(v3))-- v2 = *(*TTcl_Size)(unsafe.Pointer(v3)) if !(v2 > 0) { break } if *(*int32)(unsafe.Pointer((*TTkTextElideInfo)(unsafe.Pointer(infoPtr)).FtagCnts + uintptr((*TTkTextElideInfo)(unsafe.Pointer(infoPtr)).FelidePriority)*4))&int32(1) != 0 { elide = libc.BoolInt32((*TTkTextTag)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer((*TTkTextElideInfo)(unsafe.Pointer(infoPtr)).FtagPtrs + uintptr((*TTkTextElideInfo)(unsafe.Pointer(infoPtr)).FelidePriority)*8)))).Felide > 0) break } } } else { elide = libc.BoolInt32((*TTkTextTag)(unsafe.Pointer(tagPtr)).Felide > 0) (*TTkTextElideInfo)(unsafe.Pointer(infoPtr)).FelidePriority = (*TTkTextTag)(unsafe.Pointer(tagPtr)).Fpriority } } } } if !(elide != 0) { if (*TTkTextSegment)(unsafe.Pointer(segPtr)).FtypePtr == uintptr(unsafe.Pointer(&XtkTextCharType)) { start = segPtr + 24 end = segPtr + 24 + uintptr(segSize) p = end for { if charCount == 0 { *(*TTcl_Size)(unsafe.Pointer(dstPtr + 16)) -= int64(end) - int64(p) goto backwardCharDone } if p == start { break } if libc.Bool(uint64(4) == uint64(2)) && libc.Uint32FromInt32(libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(p)))-libc.Int32FromInt32(0xF0)) <= uint32(5) { charCount-- /* Characters > U+FFFF count as 2 here */ } if charCount != 0 { charCount-- } goto _4 _4: ; p = libtcl9_0.XTcl_UtfPrev(tls, p, start) } } else { if type1&int32(COUNT_INDICES) != 0 { if charCount <= segSize { *(*TTcl_Size)(unsafe.Pointer(dstPtr + 16)) -= int64(charCount) goto backwardCharDone } charCount -= segSize } } } *(*TTcl_Size)(unsafe.Pointer(dstPtr + 16)) -= int64(segSize) /* * Move back into previous segment. */ oldPtr = segPtr segPtr = (*TTkTextLine)(unsafe.Pointer((*TTkTextIndex)(unsafe.Pointer(dstPtr)).FlinePtr)).FsegPtr if segPtr != oldPtr { for { if !((*TTkTextSegment)(unsafe.Pointer(segPtr)).FnextPtr != oldPtr) { break } /* Empty body. */ goto _5 _5: ; segPtr = (*TTkTextSegment)(unsafe.Pointer(segPtr)).FnextPtr } segSize = int32((*TTkTextSegment)(unsafe.Pointer(segPtr)).Fsize) continue } /* * Move back to previous line. */ if lineIndex < 0 { lineIndex = XTkBTreeLinesTo(tls, textPtr, (*TTkTextIndex)(unsafe.Pointer(dstPtr)).FlinePtr) } if lineIndex == 0 { (*TTkTextIndex)(unsafe.Pointer(dstPtr)).FbyteIndex = 0 goto backwardCharDone } lineIndex-- (*TTkTextIndex)(unsafe.Pointer(dstPtr)).FlinePtr = XTkBTreeFindLine(tls, (*TTkTextIndex)(unsafe.Pointer(dstPtr)).Ftree, textPtr, lineIndex) /* * Compute the length of the line and add that to dstPtr->byteIndex. */ oldPtr = (*TTkTextLine)(unsafe.Pointer((*TTkTextIndex)(unsafe.Pointer(dstPtr)).FlinePtr)).FsegPtr segPtr = oldPtr for { if !(segPtr != libc.UintptrFromInt32(0)) { break } *(*TTcl_Size)(unsafe.Pointer(dstPtr + 16)) += (*TTkTextSegment)(unsafe.Pointer(segPtr)).Fsize oldPtr = segPtr goto _6 _6: ; segPtr = (*TTkTextSegment)(unsafe.Pointer(segPtr)).FnextPtr } segPtr = oldPtr segSize = int32((*TTkTextSegment)(unsafe.Pointer(segPtr)).Fsize) } goto backwardCharDone backwardCharDone: ; if infoPtr != libc.UintptrFromInt32(0) { XTkTextFreeElideInfo(tls, infoPtr) libtcl9_0.XTcl_Free(tls, infoPtr) } } /* *---------------------------------------------------------------------- * * StartEnd -- * * This function handles modifiers like "wordstart" and "lineend" to * adjust indices forwards or backwards. * * Results: * If the modifier is successfully parsed then the return value is the * address of the first character after the modifier, and *indexPtr is * updated to reflect the modifier. If there is a syntax error in the * modifier then NULL is returned. * * Side effects: * None. * *---------------------------------------------------------------------- */ func _StartEnd(tls *libc.TLS, textPtr uintptr, string1 uintptr, indexPtr uintptr) (r uintptr) { bp := tls.Alloc(32) defer tls.Free(32) /* Index to modify based on string. */ var chSize, chSize1, firstChar, firstChar1, modifier, v10, v6, v7, v9 int32 var length Tsize_t var p, segPtr, p14 uintptr var v12, v3, v5 bool var v2, v4 uint64 var _ /* ch at bp+24 */ int32 var _ /* ch at bp+8 */ int32 var _ /* offset at bp+0 */ TTcl_Size var _ /* offset at bp+16 */ TTcl_Size _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = chSize, chSize1, firstChar, firstChar1, length, modifier, p, segPtr, v10, v12, v2, v3, v4, v5, v6, v7, v9, p14 /* * Find the end of the modifier word. */ p = string1 for { if !(libc.Xisalnum(tls, libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(p)))) != 0) { break } /* Empty loop body. */ goto _1 _1: ; p++ } length = libc.Uint64FromInt64(int64(p) - int64(string1)) if v3 = libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(string1))) == int32('d'); v3 { if length > uint64(7) { v2 = uint64(7) } else { v2 = length } } if v3 && libc.Xstrncmp(tls, string1, __ccgo_ts+41488, v2) == 0 { modifier = int32(TKINDEX_DISPLAY) if length > uint64(7) { p -= uintptr(length - libc.Uint64FromInt32(7)) } } else { if v5 = libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(string1))) == int32('a'); v5 { if length > uint64(3) { v4 = uint64(3) } else { v4 = length } } if v5 && libc.Xstrncmp(tls, string1, __ccgo_ts+47945, v4) == 0 { modifier = int32(TKINDEX_ANY) if length > uint64(3) { p -= uintptr(length - libc.Uint64FromInt32(3)) } } else { modifier = TKINDEX_NONE } } /* * If we had a modifier, which we interpreted ok, so now forward to the * actual units. */ if modifier != TKINDEX_NONE { for { v6 = libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(p))) v7 = libc.BoolInt32(v6 == int32(' ') || libc.Uint32FromInt32(v6)-uint32('\t') < uint32(5)) goto _8 _8: if !(v7 != 0) { break } p++ } string1 = p for { if v12 = libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(p))) != int32('\000'); v12 { v9 = libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(p))) v10 = libc.BoolInt32(v9 == int32(' ') || libc.Uint32FromInt32(v9)-uint32('\t') < uint32(5)) goto _11 _11: } if !(v12 && !(v10 != 0) && libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(p))) != int32('+') && libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(p))) != int32('-')) { break } p++ } length = libc.Uint64FromInt64(int64(p) - int64(string1)) } if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(string1))) == int32('l') && libc.Xstrncmp(tls, string1, __ccgo_ts+48099, length) == 0 && length >= uint64(5) { if modifier == int32(TKINDEX_DISPLAY) { XTkTextFindDisplayLineEnd(tls, textPtr, indexPtr, int32(1), libc.UintptrFromInt32(0)) } else { (*TTkTextIndex)(unsafe.Pointer(indexPtr)).FbyteIndex = 0 segPtr = (*TTkTextLine)(unsafe.Pointer((*TTkTextIndex)(unsafe.Pointer(indexPtr)).FlinePtr)).FsegPtr for { if !(segPtr != libc.UintptrFromInt32(0)) { break } *(*TTcl_Size)(unsafe.Pointer(indexPtr + 16)) += (*TTkTextSegment)(unsafe.Pointer(segPtr)).Fsize goto _13 _13: ; segPtr = (*TTkTextSegment)(unsafe.Pointer(segPtr)).FnextPtr } /* * We know '\n' is encoded with a single byte index. */ p14 = indexPtr + 16 *(*TTcl_Size)(unsafe.Pointer(p14)) = TTcl_Size(uint64(*(*TTcl_Size)(unsafe.Pointer(p14))) - libc.Uint64FromInt64(1)) } } else { if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(string1))) == int32('l') && libc.Xstrncmp(tls, string1, __ccgo_ts+48107, length) == 0 && length >= uint64(5) { if modifier == int32(TKINDEX_DISPLAY) { XTkTextFindDisplayLineEnd(tls, textPtr, indexPtr, 0, libc.UintptrFromInt32(0)) } else { (*TTkTextIndex)(unsafe.Pointer(indexPtr)).FbyteIndex = 0 } } else { if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(string1))) == int32('w') && libc.Xstrncmp(tls, string1, __ccgo_ts+48117, length) == 0 && length >= uint64(5) { firstChar = int32(1) /* * If the current character isn't part of a word then just move * forward one character. Otherwise move forward until finding a * character that isn't part of a word and stop there. */ if modifier == int32(TKINDEX_DISPLAY) { XTkTextIndexForwChars(tls, textPtr, indexPtr, 0, indexPtr, libc.Int32FromInt32(COUNT_INDICES)|libc.Int32FromInt32(COUNT_DISPLAY)) } segPtr = XTkTextIndexToSeg(tls, indexPtr, bp) for int32(1) != 0 { chSize = int32(1) if (*TTkTextSegment)(unsafe.Pointer(segPtr)).FtypePtr == uintptr(unsafe.Pointer(&XtkTextCharType)) { chSize = int32(libtcl9_0.XTcl_UtfToUniChar(tls, segPtr+24+uintptr(*(*TTcl_Size)(unsafe.Pointer(bp))), bp+8)) if !(libtcl9_0.XTcl_UniCharIsWordChar(tls, *(*int32)(unsafe.Pointer(bp + 8))) != 0) { break } firstChar = 0 } *(*TTcl_Size)(unsafe.Pointer(bp)) += int64(chSize) *(*TTcl_Size)(unsafe.Pointer(indexPtr + 16)) += int64(chSize) if *(*TTcl_Size)(unsafe.Pointer(bp)) >= (*TTkTextSegment)(unsafe.Pointer(segPtr)).Fsize { segPtr = XTkTextIndexToSeg(tls, indexPtr, bp) } } if firstChar != 0 { if modifier == int32(TKINDEX_DISPLAY) { XTkTextIndexForwChars(tls, textPtr, indexPtr, int32(1), indexPtr, libc.Int32FromInt32(COUNT_INDICES)|libc.Int32FromInt32(COUNT_DISPLAY)) } else { XTkTextIndexForwChars(tls, libc.UintptrFromInt32(0), indexPtr, int32(1), indexPtr, int32(COUNT_INDICES)) } } } else { if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(string1))) == int32('w') && libc.Xstrncmp(tls, string1, __ccgo_ts+48125, length) == 0 && length >= uint64(5) { firstChar1 = int32(1) if modifier == int32(TKINDEX_DISPLAY) { XTkTextIndexForwChars(tls, textPtr, indexPtr, 0, indexPtr, libc.Int32FromInt32(COUNT_INDICES)|libc.Int32FromInt32(COUNT_DISPLAY)) } /* * Starting with the current character, look for one that's not part * of a word and keep moving backward until you find one. Then if the * character found wasn't the first one, move forward again one * position. */ segPtr = XTkTextIndexToSeg(tls, indexPtr, bp+16) for int32(1) != 0 { chSize1 = int32(1) if (*TTkTextSegment)(unsafe.Pointer(segPtr)).FtypePtr == uintptr(unsafe.Pointer(&XtkTextCharType)) { libtcl9_0.XTcl_UtfToUniChar(tls, segPtr+24+uintptr(*(*TTcl_Size)(unsafe.Pointer(bp + 16))), bp+24) if !(libtcl9_0.XTcl_UniCharIsWordChar(tls, *(*int32)(unsafe.Pointer(bp + 24))) != 0) { break } if *(*TTcl_Size)(unsafe.Pointer(bp + 16))+int64(1) > int64(1) { chSize1 = int32(int64(segPtr+24+uintptr(*(*TTcl_Size)(unsafe.Pointer(bp + 16)))) - int64(libtcl9_0.XTcl_UtfPrev(tls, segPtr+24+uintptr(*(*TTcl_Size)(unsafe.Pointer(bp + 16))), segPtr+24))) } firstChar1 = 0 } if *(*TTcl_Size)(unsafe.Pointer(bp + 16)) == 0 { if (*TTkTextIndex)(unsafe.Pointer(indexPtr)).FbyteIndex == 0 { goto done } if modifier == int32(TKINDEX_DISPLAY) { XTkTextIndexBackChars(tls, textPtr, indexPtr, int32(1), indexPtr, libc.Int32FromInt32(COUNT_INDICES)|libc.Int32FromInt32(COUNT_DISPLAY)) } else { XTkTextIndexBackChars(tls, libc.UintptrFromInt32(0), indexPtr, int32(1), indexPtr, int32(COUNT_INDICES)) } } else { *(*TTcl_Size)(unsafe.Pointer(indexPtr + 16)) -= int64(chSize1) } *(*TTcl_Size)(unsafe.Pointer(bp + 16)) -= int64(chSize1) if *(*TTcl_Size)(unsafe.Pointer(bp + 16)) < 0 { segPtr = XTkTextIndexToSeg(tls, indexPtr, bp+16) } } if !(firstChar1 != 0) { if modifier == int32(TKINDEX_DISPLAY) { XTkTextIndexForwChars(tls, textPtr, indexPtr, int32(1), indexPtr, libc.Int32FromInt32(COUNT_INDICES)|libc.Int32FromInt32(COUNT_DISPLAY)) } else { XTkTextIndexForwChars(tls, libc.UintptrFromInt32(0), indexPtr, int32(1), indexPtr, int32(COUNT_INDICES)) } } } else { return libc.UintptrFromInt32(0) } } } } goto done done: ; return p return r } func init() { p := unsafe.Pointer(&XtkTextRightMarkType) *(*uintptr)(unsafe.Add(p, 24)) = __ccgo_fp(_MarkDeleteProc) *(*uintptr)(unsafe.Add(p, 32)) = __ccgo_fp(_MarkCleanupProc) *(*uintptr)(unsafe.Add(p, 48)) = __ccgo_fp(_MarkLayoutProc) *(*uintptr)(unsafe.Add(p, 56)) = __ccgo_fp(_MarkCheckProc) } func init() { p := unsafe.Pointer(&XtkTextLeftMarkType) *(*uintptr)(unsafe.Add(p, 24)) = __ccgo_fp(_MarkDeleteProc) *(*uintptr)(unsafe.Add(p, 32)) = __ccgo_fp(_MarkCleanupProc) *(*uintptr)(unsafe.Add(p, 48)) = __ccgo_fp(_MarkLayoutProc) *(*uintptr)(unsafe.Add(p, 56)) = __ccgo_fp(_MarkCheckProc) } /* *-------------------------------------------------------------- * * TkTextMarkCmd -- * * This function is invoked to process the "mark" options of the widget * command for text widgets. See the user documentation for details on * what it does. * * Results: * A standard Tcl result. * * Side effects: * See the user documentation. * *-------------------------------------------------------------- */ func XTkTextMarkCmd(tls *libc.TLS, textPtr uintptr, interp uintptr, objc TTcl_Size, objv uintptr) (r int32) { bp := tls.Alloc(128) defer tls.Free(128) /* Argument objects. Someone else has already * parsed this command enough to know that * objv[1] is "mark". */ var c uint8 var hPtr, markPtr, newTypePtr, resultObj, str, typeStr, v2 uintptr var i TTcl_Size var _ /* index at bp+24 */ TTkTextIndex var _ /* length at bp+64 */ TTcl_Size var _ /* optionIndex at bp+56 */ int32 var _ /* search at bp+0 */ TTcl_HashSearch _, _, _, _, _, _, _, _, _ = c, hPtr, i, markPtr, newTypePtr, resultObj, str, typeStr, v2 if objc+int64(1) < int64(4) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(2), objv, __ccgo_ts+4953) return int32(TCL_ERROR) } if libtcl9_0.XTcl_GetIndexFromObjStruct(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), uintptr(unsafe.Pointer(&_markOptionStrings)), libc.Int64FromUint64(libc.Uint64FromInt64(8)), __ccgo_ts+48155, libc.Int32FromInt32(0)|libc.Int32FromUint64(libc.Uint64FromInt64(4)< int64(5) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(3), objv, __ccgo_ts+48167) return int32(TCL_ERROR) } str = libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 3*8)), bp+64) if *(*TTcl_Size)(unsafe.Pointer(bp + 64)) == int64(6) && !(libc.Xstrcmp(tls, str, __ccgo_ts+22158) != 0) { markPtr = (*TTkText)(unsafe.Pointer(textPtr)).FinsertMarkPtr } else { if *(*TTcl_Size)(unsafe.Pointer(bp + 64)) == int64(7) && !(libc.Xstrcmp(tls, str, __ccgo_ts+3279) != 0) { markPtr = (*TTkText)(unsafe.Pointer(textPtr)).FcurrentMarkPtr } else { hPtr = (*(*func(*libc.TLS, uintptr, uintptr) uintptr)(unsafe.Pointer(&struct{ uintptr }{(*TTcl_HashTable)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr + 128)).FfindProc})))(tls, (*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr+128, str) if hPtr == libc.UintptrFromInt32(0) { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+48186, libc.VaList(bp+80, str))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+80, __ccgo_ts+179, __ccgo_ts+3058, __ccgo_ts+48214, str, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) } markPtr = (*TTcl_HashEntry)(unsafe.Pointer(hPtr)).FclientData } } if objc == int64(4) { if (*TTkTextSegment)(unsafe.Pointer(markPtr)).FtypePtr == uintptr(unsafe.Pointer(&XtkTextRightMarkType)) { typeStr = __ccgo_ts + 10971 } else { typeStr = __ccgo_ts + 10966 } libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewStringObj(tls, typeStr, int64(-libc.Int32FromInt32(1)))) return TCL_OK } str = libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 4*8)), bp+64) c = *(*uint8)(unsafe.Pointer(str)) if libc.Int32FromUint8(c) == int32('l') && libc.Xstrncmp(tls, str, __ccgo_ts+10966, libc.Uint64FromInt64(*(*TTcl_Size)(unsafe.Pointer(bp + 64)))) == 0 { newTypePtr = uintptr(unsafe.Pointer(&XtkTextLeftMarkType)) } else { if libc.Int32FromUint8(c) == int32('r') && libc.Xstrncmp(tls, str, __ccgo_ts+10971, libc.Uint64FromInt64(*(*TTcl_Size)(unsafe.Pointer(bp + 64)))) == 0 { newTypePtr = uintptr(unsafe.Pointer(&XtkTextRightMarkType)) } else { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+48224, libc.VaList(bp+80, str))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+80, __ccgo_ts+179, __ccgo_ts+182, __ccgo_ts+48269, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) } } XTkTextMarkSegToIndex(tls, textPtr, markPtr, bp+24) XTkBTreeUnlinkSegment(tls, markPtr, (*(*TTkTextMark)(unsafe.Pointer(&(*TTkTextSegment)(unsafe.Pointer(markPtr)).Fbody))).FlinePtr) (*TTkTextSegment)(unsafe.Pointer(markPtr)).FtypePtr = newTypePtr XTkBTreeLinkSegment(tls, markPtr, bp+24) case 1: if objc != int64(3) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(3), objv, libc.UintptrFromInt32(0)) return int32(TCL_ERROR) } resultObj = libtcl9_0.XTcl_NewObj(tls) libtcl9_0.XTcl_ListObjAppendElement(tls, libc.UintptrFromInt32(0), resultObj, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+22158, int64(-libc.Int32FromInt32(1)))) libtcl9_0.XTcl_ListObjAppendElement(tls, libc.UintptrFromInt32(0), resultObj, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+3279, int64(-libc.Int32FromInt32(1)))) hPtr = libtcl9_0.XTcl_FirstHashEntry(tls, (*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr+128, bp) for { if !(hPtr != libc.UintptrFromInt32(0)) { break } if (*TTcl_HashTable)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr+128)).FkeyType == int32(TCL_ONE_WORD_KEYS) || (*TTcl_HashTable)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr+128)).FkeyType == -int32(1) { v2 = *(*uintptr)(unsafe.Pointer(hPtr + 32)) } else { v2 = hPtr + 32 } libtcl9_0.XTcl_ListObjAppendElement(tls, libc.UintptrFromInt32(0), resultObj, libtcl9_0.XTcl_NewStringObj(tls, v2, int64(-int32(1)))) goto _1 _1: ; hPtr = libtcl9_0.XTcl_NextHashEntry(tls, bp) } libtcl9_0.XTcl_SetObjResult(tls, interp, resultObj) case 2: if objc != int64(4) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(3), objv, __ccgo_ts+22152) return int32(TCL_ERROR) } return _MarkFindNext(tls, interp, textPtr, *(*uintptr)(unsafe.Pointer(objv + 3*8))) case 3: if objc != int64(4) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(3), objv, __ccgo_ts+22152) return int32(TCL_ERROR) } return _MarkFindPrev(tls, interp, textPtr, *(*uintptr)(unsafe.Pointer(objv + 3*8))) case 4: if objc != int64(5) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(3), objv, __ccgo_ts+48282) return int32(TCL_ERROR) } if XTkTextGetObjIndex(tls, interp, textPtr, *(*uintptr)(unsafe.Pointer(objv + 4*8)), bp+24) != TCL_OK { return int32(TCL_ERROR) } XTkTextSetMark(tls, textPtr, libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 3*8)), libc.UintptrFromInt32(0)), bp+24) return TCL_OK case 5: i = int64(3) for { if !(i < objc) { break } hPtr = (*(*func(*libc.TLS, uintptr, uintptr) uintptr)(unsafe.Pointer(&struct{ uintptr }{(*TTcl_HashTable)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr + 128)).FfindProc})))(tls, (*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr+128, libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(i)*8)), libc.UintptrFromInt32(0))) if hPtr != libc.UintptrFromInt32(0) { markPtr = (*TTcl_HashEntry)(unsafe.Pointer(hPtr)).FclientData /* * Special case not needed with peer widgets. */ if markPtr == (*TTkText)(unsafe.Pointer(textPtr)).FinsertMarkPtr || markPtr == (*TTkText)(unsafe.Pointer(textPtr)).FcurrentMarkPtr { goto _3 } XTkBTreeUnlinkSegment(tls, markPtr, (*(*TTkTextMark)(unsafe.Pointer(&(*TTkTextSegment)(unsafe.Pointer(markPtr)).Fbody))).FlinePtr) libtcl9_0.XTcl_DeleteHashEntry(tls, hPtr) libtcl9_0.XTcl_Free(tls, markPtr) } goto _3 _3: ; i++ } break } return TCL_OK } var _markOptionStrings = [7]uintptr{ 0: __ccgo_ts + 43697, 1: __ccgo_ts + 10036, 2: __ccgo_ts + 48135, 3: __ccgo_ts + 48140, 4: __ccgo_ts + 11726, 5: __ccgo_ts + 48149, 6: libc.UintptrFromInt32(0), } /* *---------------------------------------------------------------------- * * TkTextSetMark -- * * Set a mark to a particular position, creating a new mark if one * doesn't already exist. * * Results: * The return value is a pointer to the mark that was just set. * * Side effects: * A new mark is created, or an existing mark is moved. * *---------------------------------------------------------------------- */ func XTkTextSetMark(tls *libc.TLS, textPtr uintptr, name uintptr, indexPtr uintptr) (r uintptr) { bp := tls.Alloc(144) defer tls.Free(144) /* Where to set mark. */ var hPtr, markPtr uintptr var nblines, widgetSpecific, v1, v2 int32 var _ /* index at bp+40 */ TTkTextIndex var _ /* index2 at bp+104 */ TTkTextIndex var _ /* index2 at bp+72 */ TTkTextIndex var _ /* insertIndex at bp+0 */ TTkTextIndex var _ /* isNew at bp+32 */ int32 _, _, _, _, _, _ = hPtr, markPtr, nblines, widgetSpecific, v1, v2 hPtr = libc.UintptrFromInt32(0) if !(libc.Xstrcmp(tls, name, __ccgo_ts+22158) != 0) { widgetSpecific = int32(1) markPtr = (*TTkText)(unsafe.Pointer(textPtr)).FinsertMarkPtr if markPtr == libc.UintptrFromInt32(0) { v1 = int32(1) } else { v1 = 0 } *(*int32)(unsafe.Pointer(bp + 32)) = v1 } else { if !(libc.Xstrcmp(tls, name, __ccgo_ts+3279) != 0) { widgetSpecific = int32(2) markPtr = (*TTkText)(unsafe.Pointer(textPtr)).FcurrentMarkPtr if markPtr == libc.UintptrFromInt32(0) { v2 = int32(1) } else { v2 = 0 } *(*int32)(unsafe.Pointer(bp + 32)) = v2 } else { widgetSpecific = 0 hPtr = (*(*func(*libc.TLS, uintptr, uintptr, uintptr) uintptr)(unsafe.Pointer(&struct{ uintptr }{(*TTcl_HashTable)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr + 128)).FcreateProc})))(tls, (*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr+128, name, bp+32) markPtr = (*TTcl_HashEntry)(unsafe.Pointer(hPtr)).FclientData } } if !(*(*int32)(unsafe.Pointer(bp + 32)) != 0) { /* * If this is the insertion point that's being moved, be sure to force * a display update at the old position. Also, don't let the insertion * cursor be after the final newline of the file. */ if markPtr == (*TTkText)(unsafe.Pointer(textPtr)).FinsertMarkPtr { XTkTextMarkSegToIndex(tls, textPtr, (*TTkText)(unsafe.Pointer(textPtr)).FinsertMarkPtr, bp+40) XTkTextIndexForwChars(tls, libc.UintptrFromInt32(0), bp+40, int32(1), bp+72, int32(COUNT_INDICES)) /* * While we wish to redisplay, no heights have changed, so no need * to call TkTextInvalidateLineMetrics. */ XTkTextChanged(tls, libc.UintptrFromInt32(0), textPtr, bp+40, bp+72) /* * The number of lines in the widget is zero if and only if it is * a partial peer with -startline == -endline, i.e. an empty * peer. In this case the mark shall be set exactly at the given * index, and not one character backwards (bug 3487407). */ nblines = XTkBTreeNumLines(tls, (*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).Ftree, textPtr) if XTkBTreeLinesTo(tls, textPtr, (*TTkTextIndex)(unsafe.Pointer(indexPtr)).FlinePtr) == nblines && nblines > 0 { XTkTextIndexBackChars(tls, libc.UintptrFromInt32(0), indexPtr, int32(1), bp, int32(COUNT_INDICES)) indexPtr = bp } } XTkBTreeUnlinkSegment(tls, markPtr, (*(*TTkTextMark)(unsafe.Pointer(&(*TTkTextSegment)(unsafe.Pointer(markPtr)).Fbody))).FlinePtr) } else { markPtr = libtcl9_0.XTcl_Alloc(tls, uint64(libc.UintptrFromInt32(0)+24)+libc.Uint64FromInt64(24)) (*TTkTextSegment)(unsafe.Pointer(markPtr)).FtypePtr = uintptr(unsafe.Pointer(&XtkTextRightMarkType)) (*TTkTextSegment)(unsafe.Pointer(markPtr)).Fsize = 0 (*(*TTkTextMark)(unsafe.Pointer(&(*TTkTextSegment)(unsafe.Pointer(markPtr)).Fbody))).FtextPtr = textPtr (*(*TTkTextMark)(unsafe.Pointer(&(*TTkTextSegment)(unsafe.Pointer(markPtr)).Fbody))).FlinePtr = (*TTkTextIndex)(unsafe.Pointer(indexPtr)).FlinePtr (*(*TTkTextMark)(unsafe.Pointer(&(*TTkTextSegment)(unsafe.Pointer(markPtr)).Fbody))).FhPtr = hPtr if widgetSpecific == 0 { (*TTcl_HashEntry)(unsafe.Pointer(hPtr)).FclientData = markPtr } else { if widgetSpecific == int32(1) { (*TTkText)(unsafe.Pointer(textPtr)).FinsertMarkPtr = markPtr } else { (*TTkText)(unsafe.Pointer(textPtr)).FcurrentMarkPtr = markPtr } } } XTkBTreeLinkSegment(tls, markPtr, indexPtr) /* * If the mark is the insertion cursor, then update the screen at the * mark's new location. */ if markPtr == (*TTkText)(unsafe.Pointer(textPtr)).FinsertMarkPtr { XTkTextIndexForwChars(tls, libc.UintptrFromInt32(0), indexPtr, int32(1), bp+104, int32(COUNT_INDICES)) /* * While we wish to redisplay, no heights have changed, so no need to * call TkTextInvalidateLineMetrics */ XTkTextChanged(tls, libc.UintptrFromInt32(0), textPtr, indexPtr, bp+104) } return markPtr } /* *-------------------------------------------------------------- * * TkTextMarkSegToIndex -- * * Given a segment that is a mark, create an index that refers to the * next text character (or other text segment with non-zero size) after * the mark. * * Results: * *IndexPtr is filled in with index information. * * Side effects: * None. * *-------------------------------------------------------------- */ func XTkTextMarkSegToIndex(tls *libc.TLS, textPtr uintptr, markPtr uintptr, indexPtr uintptr) { /* Index information gets stored here. */ var segPtr uintptr _ = segPtr (*TTkTextIndex)(unsafe.Pointer(indexPtr)).Ftree = (*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).Ftree (*TTkTextIndex)(unsafe.Pointer(indexPtr)).FlinePtr = (*(*TTkTextMark)(unsafe.Pointer(&(*TTkTextSegment)(unsafe.Pointer(markPtr)).Fbody))).FlinePtr (*TTkTextIndex)(unsafe.Pointer(indexPtr)).FbyteIndex = 0 segPtr = (*TTkTextLine)(unsafe.Pointer((*TTkTextIndex)(unsafe.Pointer(indexPtr)).FlinePtr)).FsegPtr for { if !(segPtr != markPtr) { break } *(*TTcl_Size)(unsafe.Pointer(indexPtr + 16)) += (*TTkTextSegment)(unsafe.Pointer(segPtr)).Fsize goto _1 _1: ; segPtr = (*TTkTextSegment)(unsafe.Pointer(segPtr)).FnextPtr } } /* *-------------------------------------------------------------- * * TkTextMarkNameToIndex -- * * Given the name of a mark, return an index corresponding to the mark * name. * * Results: * The return value is TCL_OK if "name" exists as a mark in the text * widget and is located within its -startline/-endline range. In this * case *indexPtr is filled in with the next segment who is after the * mark whose size is non-zero. TCL_ERROR is returned if the mark * doesn't exist in the text widget, or if it is out of its -startline/ * -endline range. In this latter case *indexPtr still contains valid * information, in particular TkTextMarkNameToIndex called with the * "insert" or "current" mark name may return TCL_ERROR, but *indexPtr * contains the correct index of this mark before -startline or after * -endline. * * Side effects: * None. * *-------------------------------------------------------------- */ func XTkTextMarkNameToIndex(tls *libc.TLS, textPtr uintptr, name uintptr, indexPtr uintptr) (r int32) { /* Index information gets stored here. */ var hPtr, segPtr uintptr _, _ = hPtr, segPtr if textPtr == libc.UintptrFromInt32(0) { return int32(TCL_ERROR) } if !(libc.Xstrcmp(tls, name, __ccgo_ts+22158) != 0) { segPtr = (*TTkText)(unsafe.Pointer(textPtr)).FinsertMarkPtr } else { if !(libc.Xstrcmp(tls, name, __ccgo_ts+3279) != 0) { segPtr = (*TTkText)(unsafe.Pointer(textPtr)).FcurrentMarkPtr } else { hPtr = (*(*func(*libc.TLS, uintptr, uintptr) uintptr)(unsafe.Pointer(&struct{ uintptr }{(*TTcl_HashTable)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr + 128)).FfindProc})))(tls, (*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr+128, name) if hPtr == libc.UintptrFromInt32(0) { return int32(TCL_ERROR) } segPtr = (*TTcl_HashEntry)(unsafe.Pointer(hPtr)).FclientData } } XTkTextMarkSegToIndex(tls, textPtr, segPtr, indexPtr) /* * If indexPtr refers to somewhere outside the -startline/-endline * range limits of the widget, error out since the mark indeed is not * reachable from this text widget (it may be reachable from a peer) * (bug 1630271). */ if XTkTextIndexAdjustToStartEnd(tls, textPtr, indexPtr, int32(1)) == int32(TCL_ERROR) { return int32(TCL_ERROR) } return TCL_OK } /* *-------------------------------------------------------------- * * MarkDeleteProc -- * * This function is invoked by the text B-tree code whenever a mark lies * in a range of characters being deleted. * * Results: * Returns 1 to indicate that deletion has been rejected. * * Side effects: * None (even if the whole tree is being deleted we don't free up the * mark; it will be done elsewhere). * *-------------------------------------------------------------- */ func _MarkDeleteProc(tls *libc.TLS, dummy491 uintptr, dummy492 uintptr, dummy493 int32) (r int32) { /* Non-zero means the entire tree is being * deleted, so everything must get cleaned * up. */ return int32(1) } /* *-------------------------------------------------------------- * * MarkCleanupProc -- * * This function is invoked by the B-tree code whenever a mark segment is * moved from one line to another. * * Results: * None. * * Side effects: * The linePtr field of the segment gets updated. * *-------------------------------------------------------------- */ func _MarkCleanupProc(tls *libc.TLS, markPtr uintptr, linePtr uintptr) (r uintptr) { /* Line that now contains segment. */ (*(*TTkTextMark)(unsafe.Pointer(&(*TTkTextSegment)(unsafe.Pointer(markPtr)).Fbody))).FlinePtr = linePtr return markPtr } /* *-------------------------------------------------------------- * * MarkLayoutProc -- * * This function is the "layoutProc" for mark segments. * * Results: * If the mark isn't the insertion cursor then the return value is -1 to * indicate that this segment shouldn't be displayed. If the mark is the * insertion character then 1 is returned and the chunkPtr structure is * filled in. * * Side effects: * None, except for filling in chunkPtr. * *-------------------------------------------------------------- */ func _MarkLayoutProc(tls *libc.TLS, textPtr uintptr, dummy548 uintptr, segPtr uintptr, dummy550 TTcl_Size, dummy552 int32, dummy554 TTcl_Size, dummy556 int32, dummy558 TTkWrapMode, chunkPtr uintptr) (r int32) { /* Structure to fill in with information about * this chunk. The x field has already been * set by the caller. */ if segPtr != (*TTkText)(unsafe.Pointer(textPtr)).FinsertMarkPtr { return -int32(1) } (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FdisplayProc = __ccgo_fp(XTkTextInsertDisplayProc) (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FundisplayProc = __ccgo_fp(_InsertUndisplayProc) (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FmeasureProc = libc.UintptrFromInt32(0) (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FbboxProc = libc.UintptrFromInt32(0) (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FnumBytes = 0 (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FminAscent = 0 (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FminDescent = 0 (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FminHeight = 0 (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).Fwidth = 0 /* * Note: can't break a line after the insertion cursor: this prevents the * insertion cursor from being stranded at the end of a line. */ (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FbreakIndex = int64(-int32(1)) (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FclientData = textPtr return int32(1) } /* *-------------------------------------------------------------- * * TkTextInsertDisplayProc -- * * This function is called to display the insertion cursor. * * Results: * None. * * Side effects: * Graphics are drawn. * *-------------------------------------------------------------- */ func XTkTextInsertDisplayProc(tls *libc.TLS, textPtr uintptr, dummy607 uintptr, x int32, y int32, height int32, dummy614 int32, dummy615 uintptr, dst TDrawable, screenY int32) { bp := tls.Alloc(64) defer tls.Free(64) /* Y-coordinate in text window that * corresponds to y. */ var borderPtr uintptr var halfWidth, rightSideWidth int32 var _ /* charWidth at bp+56 */ int32 var _ /* ih at bp+52 */ int32 var _ /* index at bp+0 */ TTkTextIndex var _ /* insertBorderWidth at bp+36 */ int32 var _ /* insertWidth at bp+32 */ int32 var _ /* iw at bp+48 */ int32 var _ /* ix at bp+40 */ int32 var _ /* iy at bp+44 */ int32 _, _, _ = borderPtr, halfWidth, rightSideWidth *(*int32)(unsafe.Pointer(bp + 40)) = 0 *(*int32)(unsafe.Pointer(bp + 44)) = 0 *(*int32)(unsafe.Pointer(bp + 48)) = 0 *(*int32)(unsafe.Pointer(bp + 52)) = 0 *(*int32)(unsafe.Pointer(bp + 56)) = 0 XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), (*TTkText)(unsafe.Pointer(textPtr)).Ftkwin, (*TTkText)(unsafe.Pointer(textPtr)).FinsertWidthObj, bp+32) XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), (*TTkText)(unsafe.Pointer(textPtr)).Ftkwin, (*TTkText)(unsafe.Pointer(textPtr)).FinsertBorderWidthObj, bp+36) halfWidth = *(*int32)(unsafe.Pointer(bp + 32)) / int32(2) if (*TTkText)(unsafe.Pointer(textPtr)).FinsertCursorType != 0 { XTkTextMarkSegToIndex(tls, textPtr, (*TTkText)(unsafe.Pointer(textPtr)).FinsertMarkPtr, bp) XTkTextIndexBbox(tls, textPtr, bp, bp+40, bp+44, bp+48, bp+52, bp+56) rightSideWidth = *(*int32)(unsafe.Pointer(bp + 56)) + halfWidth } else { rightSideWidth = halfWidth } if x+rightSideWidth < 0 { /* * The insertion cursor is off-screen. Indicate caret at 0,0 and * return. */ XTk_SetCaretPos(tls, (*TTkText)(unsafe.Pointer(textPtr)).Ftkwin, 0, 0, height) return } XTk_SetCaretPos(tls, (*TTkText)(unsafe.Pointer(textPtr)).Ftkwin, x-halfWidth, screenY, height) /* * As a special hack to keep the cursor visible on mono displays (or * anywhere else that the selection and insertion cursors have the same * color) write the default background in the cursor area (instead of * nothing) when the cursor isn't on. Otherwise the selection might hide * the cursor. */ if (*TTkText)(unsafe.Pointer(textPtr)).Fflags&int32(GOT_FOCUS8) != 0 { if (*TTkText)(unsafe.Pointer(textPtr)).Fflags&int32(INSERT_ON) != 0 { XTk_Fill3DRectangle(tls, (*TTkText)(unsafe.Pointer(textPtr)).Ftkwin, dst, (*TTkText)(unsafe.Pointer(textPtr)).FinsertBorder, x-halfWidth, y, *(*int32)(unsafe.Pointer(bp + 56))+*(*int32)(unsafe.Pointer(bp + 32)), height, *(*int32)(unsafe.Pointer(bp + 36)), int32(TK_RELIEF_RAISED)) } else { if (*TTkText)(unsafe.Pointer(textPtr)).FselBorder == (*TTkText)(unsafe.Pointer(textPtr)).FinsertBorder { XTk_Fill3DRectangle(tls, (*TTkText)(unsafe.Pointer(textPtr)).Ftkwin, dst, (*TTkText)(unsafe.Pointer(textPtr)).Fborder, x-halfWidth, y, *(*int32)(unsafe.Pointer(bp + 56))+*(*int32)(unsafe.Pointer(bp + 32)), height, 0, TK_RELIEF_FLAT) } } } else { if (*TTkText)(unsafe.Pointer(textPtr)).FinsertUnfocussed == int32(TK_TEXT_INSERT_NOFOCUS_HOLLOW) { if *(*int32)(unsafe.Pointer(bp + 36)) > 0 { XTk_Draw3DRectangle(tls, (*TTkText)(unsafe.Pointer(textPtr)).Ftkwin, dst, (*TTkText)(unsafe.Pointer(textPtr)).FinsertBorder, x-halfWidth, y, *(*int32)(unsafe.Pointer(bp + 56))+*(*int32)(unsafe.Pointer(bp + 32)), height, *(*int32)(unsafe.Pointer(bp + 36)), int32(TK_RELIEF_RAISED)) } else { /* * Hack to work around the fact that a "solid" border always * paints in black. */ borderPtr = (*TTkText)(unsafe.Pointer(textPtr)).FinsertBorder libx11.XXDrawRectangle(tls, (*TTk_FakeWin)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).Ftkwin)).Fdisplay, dst, (*TTkBorder)(unsafe.Pointer(borderPtr)).FbgGC, x-halfWidth, y, libc.Uint32FromInt32(*(*int32)(unsafe.Pointer(bp + 56))+*(*int32)(unsafe.Pointer(bp + 32))-int32(1)), libc.Uint32FromInt32(height-int32(1))) } } else { if (*TTkText)(unsafe.Pointer(textPtr)).FinsertUnfocussed == int32(TK_TEXT_INSERT_NOFOCUS_SOLID) { XTk_Fill3DRectangle(tls, (*TTkText)(unsafe.Pointer(textPtr)).Ftkwin, dst, (*TTkText)(unsafe.Pointer(textPtr)).FinsertBorder, x-halfWidth, y, *(*int32)(unsafe.Pointer(bp + 56))+*(*int32)(unsafe.Pointer(bp + 32)), height, *(*int32)(unsafe.Pointer(bp + 36)), int32(TK_RELIEF_RAISED)) } } } } /* *-------------------------------------------------------------- * * InsertUndisplayProc -- * * This function is called when the insertion cursor is no longer at a * visible point on the display. It does nothing right now. * * Results: * None. * * Side effects: * None. * *-------------------------------------------------------------- */ func _InsertUndisplayProc(tls *libc.TLS, dummy714 uintptr, dummy715 uintptr) { /* Chunk that is about to be freed. */ return } /* *-------------------------------------------------------------- * * MarkCheckProc -- * * This function is invoked by the B-tree code to perform consistency * checks on mark segments. * * Results: * None. * * Side effects: * The function panics if it detects anything wrong with * the mark. * *-------------------------------------------------------------- */ func _MarkCheckProc(tls *libc.TLS, markPtr uintptr, linePtr uintptr) { bp := tls.Alloc(32) defer tls.Free(32) /* Line containing segment. */ var hPtr uintptr var _ /* search at bp+0 */ TTcl_HashSearch _ = hPtr if (*(*TTkTextMark)(unsafe.Pointer(&(*TTkTextSegment)(unsafe.Pointer(markPtr)).Fbody))).FlinePtr != linePtr { libtcl9_0.XTcl_Panic(tls, __ccgo_ts+48297, 0) } /* * These two marks are not in the hash table */ if (*TTkText1)(unsafe.Pointer((*(*TTkTextMark)(unsafe.Pointer(&(*TTkTextSegment)(unsafe.Pointer(markPtr)).Fbody))).FtextPtr)).FinsertMarkPtr == markPtr { return } if (*TTkText1)(unsafe.Pointer((*(*TTkTextMark)(unsafe.Pointer(&(*TTkTextSegment)(unsafe.Pointer(markPtr)).Fbody))).FtextPtr)).FcurrentMarkPtr == markPtr { return } /* * Make sure that the mark is still present in the text's mark hash table. */ hPtr = libtcl9_0.XTcl_FirstHashEntry(tls, (*TTkText1)(unsafe.Pointer((*(*TTkTextMark)(unsafe.Pointer(&(*TTkTextSegment)(unsafe.Pointer(markPtr)).Fbody))).FtextPtr)).FsharedTextPtr+128, bp) for { if !(hPtr != (*(*TTkTextMark)(unsafe.Pointer(&(*TTkTextSegment)(unsafe.Pointer(markPtr)).Fbody))).FhPtr) { break } if hPtr == libc.UintptrFromInt32(0) { libtcl9_0.XTcl_Panic(tls, __ccgo_ts+48345, 0) } goto _1 _1: ; hPtr = libtcl9_0.XTcl_NextHashEntry(tls, bp) } } /* *-------------------------------------------------------------- * * MarkFindNext -- * * This function searches forward for the next mark. * * Results: * A standard Tcl result, which is a mark name or an empty string. * * Side effects: * None. * *-------------------------------------------------------------- */ func _MarkFindNext(tls *libc.TLS, interp uintptr, textPtr uintptr, obj uintptr) (r int32) { bp := tls.Alloc(32) defer tls.Free(32) /* The starting index or mark name */ var hPtr, markName, segPtr, string1 uintptr var offset int32 var _ /* index at bp+0 */ TTkTextIndex _, _, _, _, _ = hPtr, markName, offset, segPtr, string1 string1 = libtcl9_0.XTcl_GetStringFromObj(tls, obj, libc.UintptrFromInt32(0)) if !(libc.Xstrcmp(tls, string1, __ccgo_ts+22158) != 0) { segPtr = (*TTkText)(unsafe.Pointer(textPtr)).FinsertMarkPtr XTkTextMarkSegToIndex(tls, textPtr, segPtr, bp) segPtr = (*TTkTextSegment)(unsafe.Pointer(segPtr)).FnextPtr } else { if !(libc.Xstrcmp(tls, string1, __ccgo_ts+3279) != 0) { segPtr = (*TTkText)(unsafe.Pointer(textPtr)).FcurrentMarkPtr XTkTextMarkSegToIndex(tls, textPtr, segPtr, bp) segPtr = (*TTkTextSegment)(unsafe.Pointer(segPtr)).FnextPtr } else { hPtr = (*(*func(*libc.TLS, uintptr, uintptr) uintptr)(unsafe.Pointer(&struct{ uintptr }{(*TTcl_HashTable)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr + 128)).FfindProc})))(tls, (*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr+128, string1) if hPtr != libc.UintptrFromInt32(0) { /* * If given a mark name, return the next mark in the list of * segments, even if it happens to be at the same character * position. */ segPtr = (*TTcl_HashEntry)(unsafe.Pointer(hPtr)).FclientData XTkTextMarkSegToIndex(tls, textPtr, segPtr, bp) segPtr = (*TTkTextSegment)(unsafe.Pointer(segPtr)).FnextPtr } else { /* * For non-mark name indices we want to return any marks that are * right at the index. */ if XTkTextGetObjIndex(tls, interp, textPtr, obj, bp) != TCL_OK { return int32(TCL_ERROR) } offset = 0 segPtr = (*TTkTextLine)(unsafe.Pointer((*(*TTkTextIndex)(unsafe.Pointer(bp))).FlinePtr)).FsegPtr for { if !(segPtr != libc.UintptrFromInt32(0) && int64(offset) < (*(*TTkTextIndex)(unsafe.Pointer(bp))).FbyteIndex) { break } /* Empty loop body */ goto _1 _1: ; offset = int32(int64(offset) + (*TTkTextSegment)(unsafe.Pointer(segPtr)).Fsize) segPtr = (*TTkTextSegment)(unsafe.Pointer(segPtr)).FnextPtr } } } } for int32(1) != 0 { /* * segPtr points at the first possible candidate, or NULL if we ran * off the end of the line. */ for { if !(segPtr != libc.UintptrFromInt32(0)) { break } if (*TTkTextSegment)(unsafe.Pointer(segPtr)).FtypePtr == uintptr(unsafe.Pointer(&XtkTextRightMarkType)) || (*TTkTextSegment)(unsafe.Pointer(segPtr)).FtypePtr == uintptr(unsafe.Pointer(&XtkTextLeftMarkType)) { markName = _GetMarkName(tls, textPtr, segPtr) if markName != libc.UintptrFromInt32(0) { libtcl9_0.XTcl_SetObjResult(tls, interp, markName) return TCL_OK } } goto _2 _2: ; segPtr = (*TTkTextSegment)(unsafe.Pointer(segPtr)).FnextPtr } (*(*TTkTextIndex)(unsafe.Pointer(bp))).FlinePtr = XTkBTreeNextLine(tls, textPtr, (*(*TTkTextIndex)(unsafe.Pointer(bp))).FlinePtr) if (*(*TTkTextIndex)(unsafe.Pointer(bp))).FlinePtr == libc.UintptrFromInt32(0) { return TCL_OK } (*(*TTkTextIndex)(unsafe.Pointer(bp))).FbyteIndex = 0 segPtr = (*TTkTextLine)(unsafe.Pointer((*(*TTkTextIndex)(unsafe.Pointer(bp))).FlinePtr)).FsegPtr } return r } /* *-------------------------------------------------------------- * * MarkFindPrev -- * * This function searches backwards for the previous mark. * * Results: * A standard Tcl result, which is a mark name or an empty string. * * Side effects: * None. * *-------------------------------------------------------------- */ func _MarkFindPrev(tls *libc.TLS, interp uintptr, textPtr uintptr, obj uintptr) (r int32) { bp := tls.Alloc(32) defer tls.Free(32) /* The starting index or mark name */ var hPtr, markName, prevPtr, seg2Ptr, segPtr, string1 uintptr var offset int32 var _ /* index at bp+0 */ TTkTextIndex _, _, _, _, _, _, _ = hPtr, markName, offset, prevPtr, seg2Ptr, segPtr, string1 string1 = libtcl9_0.XTcl_GetStringFromObj(tls, obj, libc.UintptrFromInt32(0)) if !(libc.Xstrcmp(tls, string1, __ccgo_ts+22158) != 0) { segPtr = (*TTkText)(unsafe.Pointer(textPtr)).FinsertMarkPtr XTkTextMarkSegToIndex(tls, textPtr, segPtr, bp) } else { if !(libc.Xstrcmp(tls, string1, __ccgo_ts+3279) != 0) { segPtr = (*TTkText)(unsafe.Pointer(textPtr)).FcurrentMarkPtr XTkTextMarkSegToIndex(tls, textPtr, segPtr, bp) } else { hPtr = (*(*func(*libc.TLS, uintptr, uintptr) uintptr)(unsafe.Pointer(&struct{ uintptr }{(*TTcl_HashTable)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr + 128)).FfindProc})))(tls, (*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr+128, string1) if hPtr != libc.UintptrFromInt32(0) { /* * If given a mark name, return the previous mark in the list of * segments, even if it happens to be at the same character * position. */ segPtr = (*TTcl_HashEntry)(unsafe.Pointer(hPtr)).FclientData XTkTextMarkSegToIndex(tls, textPtr, segPtr, bp) } else { /* * For non-mark name indices we do not return any marks that are * right at the index. */ if XTkTextGetObjIndex(tls, interp, textPtr, obj, bp) != TCL_OK { return int32(TCL_ERROR) } offset = 0 segPtr = (*TTkTextLine)(unsafe.Pointer((*(*TTkTextIndex)(unsafe.Pointer(bp))).FlinePtr)).FsegPtr for { if !(segPtr != libc.UintptrFromInt32(0) && int64(offset) < (*(*TTkTextIndex)(unsafe.Pointer(bp))).FbyteIndex) { break } /* Empty loop body */ goto _1 _1: ; offset = int32(int64(offset) + (*TTkTextSegment)(unsafe.Pointer(segPtr)).Fsize) segPtr = (*TTkTextSegment)(unsafe.Pointer(segPtr)).FnextPtr } } } } for int32(1) != 0 { /* * segPtr points just past the first possible candidate, or at the * beginning of the line. */ prevPtr = libc.UintptrFromInt32(0) seg2Ptr = (*TTkTextLine)(unsafe.Pointer((*(*TTkTextIndex)(unsafe.Pointer(bp))).FlinePtr)).FsegPtr for { if !(seg2Ptr != libc.UintptrFromInt32(0) && seg2Ptr != segPtr) { break } if (*TTkTextSegment)(unsafe.Pointer(seg2Ptr)).FtypePtr == uintptr(unsafe.Pointer(&XtkTextRightMarkType)) || (*TTkTextSegment)(unsafe.Pointer(seg2Ptr)).FtypePtr == uintptr(unsafe.Pointer(&XtkTextLeftMarkType)) { if (*(*TTkTextMark)(unsafe.Pointer(&(*TTkTextSegment)(unsafe.Pointer(seg2Ptr)).Fbody))).FhPtr == libc.UintptrFromInt32(0) { if seg2Ptr != (*TTkText)(unsafe.Pointer(textPtr)).FcurrentMarkPtr && seg2Ptr != (*TTkText)(unsafe.Pointer(textPtr)).FinsertMarkPtr { /* * This is an insert or current mark from a * peer of textPtr. */ goto _2 } } prevPtr = seg2Ptr } goto _2 _2: ; seg2Ptr = (*TTkTextSegment)(unsafe.Pointer(seg2Ptr)).FnextPtr } if prevPtr != libc.UintptrFromInt32(0) { markName = _GetMarkName(tls, textPtr, prevPtr) if markName != libc.UintptrFromInt32(0) { libtcl9_0.XTcl_SetObjResult(tls, interp, markName) return TCL_OK } } (*(*TTkTextIndex)(unsafe.Pointer(bp))).FlinePtr = XTkBTreePreviousLine(tls, textPtr, (*(*TTkTextIndex)(unsafe.Pointer(bp))).FlinePtr) if (*(*TTkTextIndex)(unsafe.Pointer(bp))).FlinePtr == libc.UintptrFromInt32(0) { return TCL_OK } segPtr = libc.UintptrFromInt32(0) } return r } /* * ------------------------------------------------------------------------ * * GetMarkName -- * Returns the name of the mark that is the given text segment, or NULL * if it is unnamed (i.e., a widget-specific mark that isn't "current" or * "insert"). * * ------------------------------------------------------------------------ */ func _GetMarkName(tls *libc.TLS, textPtr uintptr, segPtr uintptr) (r uintptr) { var markName, v1 uintptr _, _ = markName, v1 if segPtr == (*TTkText)(unsafe.Pointer(textPtr)).FcurrentMarkPtr { markName = __ccgo_ts + 3279 } else { if segPtr == (*TTkText)(unsafe.Pointer(textPtr)).FinsertMarkPtr { markName = __ccgo_ts + 22158 } else { if (*(*TTkTextMark)(unsafe.Pointer(&(*TTkTextSegment)(unsafe.Pointer(segPtr)).Fbody))).FhPtr == libc.UintptrFromInt32(0) { /* * Ignore widget-specific marks for the other widgets. This is either * an insert or a current mark (markPtr->body.mark.hPtr actually * receives NULL for these marks in TkTextSetMark). The insert and * current marks for textPtr having already been tested above, the * current segment is an insert or current mark from a peer of * textPtr, which we don't want to return. */ return libc.UintptrFromInt32(0) } else { if (*TTcl_HashTable)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr+128)).FkeyType == int32(TCL_ONE_WORD_KEYS) || (*TTcl_HashTable)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr+128)).FkeyType == -int32(1) { v1 = *(*uintptr)(unsafe.Pointer((*(*TTkTextMark)(unsafe.Pointer(&(*TTkTextSegment)(unsafe.Pointer(segPtr)).Fbody))).FhPtr + 32)) } else { v1 = (*(*TTkTextMark)(unsafe.Pointer(&(*TTkTextSegment)(unsafe.Pointer(segPtr)).Fbody))).FhPtr + 32 } markName = v1 } } } return libtcl9_0.XTcl_NewStringObj(tls, markName, int64(-int32(1))) } const NUM_BIND_TAGS = 10 /* * Local Variables: * mode: c * c-basic-offset: 4 * fill-column: 78 * End: */ /* * default.h -- * * This file defines the defaults for all options for all of * the Tk widgets. * * Copyright © 1991-1994 The Regents of the University of California. * Copyright © 1994 Sun Microsystems, Inc. * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. */ /* * tkUnixDefault.h -- * * This file defines the defaults for all options for all of * the Tk widgets. * * Copyright © 1991-1994 The Regents of the University of California. * Copyright © 1994-1997 Sun Microsystems, Inc. * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. */ /* * The definitions below provide symbolic names for the default colors. * NORMAL_BG - Normal background color. * ACTIVE_BG - Background color when widget is active. * SELECT_BG - Background color for selected text. * TROUGH - Background color for troughs in scales and scrollbars. * INDICATOR - Color for indicator when button is selected. * DISABLED - Foreground color when widget is disabled. * PLACEHOLDER_FG - Foreground color for placeholder text. */ /* * Defaults for labels, buttons, checkbuttons, and radiobuttons: */ /* * Defaults for canvases: */ /* * Defaults for entries: */ /* * Defaults for frames: */ /* * Defaults for labelframes: */ /* * Defaults for listboxes: */ /* * Defaults for individual entries of menus: */ /* * Defaults for menus overall: */ /* * Defaults for menubuttons: */ /* * Defaults for messages: */ /* * Defaults for panedwindows */ /* * Defaults for panedwindow panes */ /* * Defaults for scales: */ /* * Defaults for scrollbars: */ /* * Defaults for texts: */ /* * Defaults for canvas text: */ /* * Defaults for canvas items * (arcs, bitmaps, lines, polygons, rectangles, and ovals): */ /* * Defaults for toplevels (most of the defaults for frames also apply * to toplevels): */ /* * Defaults for busy windows: */ var _tagOptionSpecs = [28]TTk_OptionSpec{ 0: { Ftype1: int32(TK_OPTION_BORDER), FoptionName: __ccgo_ts + 19898, FobjOffset: int64(-libc.Int32FromInt32(1)), FinternalOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 40)), Fflags: int32(TCL_NULL_OK), }, 1: { Ftype1: int32(TK_OPTION_BITMAP), FoptionName: __ccgo_ts + 48399, FobjOffset: int64(-libc.Int32FromInt32(1)), FinternalOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 64)), Fflags: int32(TCL_NULL_OK), }, 2: { Ftype1: int32(TK_OPTION_PIXELS), FoptionName: __ccgo_ts + 2814, FobjOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 48)), FinternalOffset: int64(-libc.Int32FromInt32(1)), Fflags: int32(TCL_NULL_OK), }, 3: { FoptionName: __ccgo_ts + 43785, FobjOffset: int64(-libc.Int32FromInt32(1)), FinternalOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 268)), Fflags: int32(TCL_NULL_OK), }, 4: { Ftype1: int32(TK_OPTION_BITMAP), FoptionName: __ccgo_ts + 48410, FobjOffset: int64(-libc.Int32FromInt32(1)), FinternalOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 88)), Fflags: int32(TCL_NULL_OK), }, 5: { Ftype1: int32(TK_OPTION_FONT), FoptionName: __ccgo_ts + 20097, FobjOffset: int64(-libc.Int32FromInt32(1)), FinternalOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 80)), Fflags: int32(TCL_NULL_OK), }, 6: { Ftype1: int32(TK_OPTION_COLOR), FoptionName: __ccgo_ts + 20085, FobjOffset: int64(-libc.Int32FromInt32(1)), FinternalOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 72)), Fflags: int32(TCL_NULL_OK), }, 7: { Ftype1: int32(TK_OPTION_JUSTIFY), FoptionName: __ccgo_ts + 20307, FobjOffset: int64(-libc.Int32FromInt32(1)), FinternalOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 96)), Fflags: int32(TCL_NULL_OK), }, 8: { Ftype1: int32(TK_OPTION_PIXELS), FoptionName: __ccgo_ts + 48421, FobjOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 104)), FinternalOffset: int64(-libc.Int32FromInt32(1)), Fflags: int32(TCL_NULL_OK), }, 9: { Ftype1: int32(TK_OPTION_PIXELS), FoptionName: __ccgo_ts + 48431, FobjOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 120)), FinternalOffset: int64(-libc.Int32FromInt32(1)), Fflags: int32(TCL_NULL_OK), }, 10: { Ftype1: int32(TK_OPTION_BORDER), FoptionName: __ccgo_ts + 48441, FobjOffset: int64(-libc.Int32FromInt32(1)), FinternalOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 136)), Fflags: int32(TCL_NULL_OK), }, 11: { Ftype1: int32(TK_OPTION_PIXELS), FoptionName: __ccgo_ts + 26544, FobjOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 144)), FinternalOffset: int64(-libc.Int32FromInt32(1)), Fflags: int32(TCL_NULL_OK), }, 12: { FoptionName: __ccgo_ts + 9518, FobjOffset: int64(-libc.Int32FromInt32(1)), FinternalOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 156)), Fflags: int32(TCL_NULL_OK), }, 13: { Ftype1: int32(TK_OPTION_COLOR), FoptionName: __ccgo_ts + 48455, FobjOffset: int64(-libc.Int32FromInt32(1)), FinternalOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 160)), Fflags: int32(TCL_NULL_OK), }, 14: { Ftype1: int32(TK_OPTION_RELIEF), FoptionName: __ccgo_ts + 20346, FobjOffset: int64(-libc.Int32FromInt32(1)), FinternalOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 56)), Fflags: int32(TCL_NULL_OK), }, 15: { Ftype1: int32(TK_OPTION_PIXELS), FoptionName: __ccgo_ts + 48469, FobjOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 168)), FinternalOffset: int64(-libc.Int32FromInt32(1)), Fflags: int32(TCL_NULL_OK), }, 16: { Ftype1: int32(TK_OPTION_BORDER), FoptionName: __ccgo_ts + 48478, FobjOffset: int64(-libc.Int32FromInt32(1)), FinternalOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 184)), Fflags: int32(TCL_NULL_OK), }, 17: { Ftype1: int32(TK_OPTION_BORDER), FoptionName: __ccgo_ts + 21638, FobjOffset: int64(-libc.Int32FromInt32(1)), FinternalOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 192)), Fflags: int32(TCL_NULL_OK), }, 18: { Ftype1: int32(TK_OPTION_COLOR), FoptionName: __ccgo_ts + 21718, FobjOffset: int64(-libc.Int32FromInt32(1)), FinternalOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 200)), Fflags: int32(TCL_NULL_OK), }, 19: { Ftype1: int32(TK_OPTION_PIXELS), FoptionName: __ccgo_ts + 42753, FobjOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 208)), FinternalOffset: int64(-libc.Int32FromInt32(1)), Fflags: int32(TCL_NULL_OK), }, 20: { Ftype1: int32(TK_OPTION_PIXELS), FoptionName: __ccgo_ts + 42780, FobjOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 216)), FinternalOffset: int64(-libc.Int32FromInt32(1)), Fflags: int32(TCL_NULL_OK), }, 21: { Ftype1: int32(TK_OPTION_PIXELS), FoptionName: __ccgo_ts + 42799, FobjOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 224)), FinternalOffset: int64(-libc.Int32FromInt32(1)), Fflags: int32(TCL_NULL_OK), }, 22: { Ftype1: int32(TK_OPTION_STRING), FoptionName: __ccgo_ts + 42829, FobjOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 232)), FinternalOffset: int64(-libc.Int32FromInt32(1)), Fflags: int32(TCL_NULL_OK), }, 23: { Ftype1: int32(TK_OPTION_STRING_TABLE), FoptionName: __ccgo_ts + 42845, FobjOffset: int64(-libc.Int32FromInt32(1)), FinternalOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 248)), Fflags: libc.Int32FromInt32(TCL_NULL_OK) | libc.Int32FromUint64(libc.Uint64FromInt64(4)&(libc.Uint64FromInt64(4)-libc.Uint64FromInt32(1)))< 0 { /* * Indices are potentially obsolete after adding or removing * elided character ranges, especially indices having "display" * or "any" submodifier, therefore increase the epoch. */ (*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).FstateEpoch++ } i = int64(4) for { if !(i < objc) { break } if XTkTextGetObjIndex(tls, interp, textPtr, *(*uintptr)(unsafe.Pointer(objv + uintptr(i)*8)), bp+8) != TCL_OK { return int32(TCL_ERROR) } if objc > i+int64(1) { if XTkTextGetObjIndex(tls, interp, textPtr, *(*uintptr)(unsafe.Pointer(objv + uintptr(i+int64(1))*8)), bp+40) != TCL_OK { return int32(TCL_ERROR) } if XTkTextIndexCmp(tls, bp+8, bp+40) >= 0 { return TCL_OK } } else { *(*TTkTextIndex)(unsafe.Pointer(bp + 40)) = *(*TTkTextIndex)(unsafe.Pointer(bp + 8)) XTkTextIndexForwChars(tls, libc.UintptrFromInt32(0), bp+40, int32(1), bp+40, int32(COUNT_INDICES)) } if (*TTkTextTag)(unsafe.Pointer(tagPtr)).FaffectsDisplay != 0 { XTkTextRedrawTag(tls, (*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr, libc.UintptrFromInt32(0), bp+8, bp+40, tagPtr, libc.BoolInt32(!(addTag != 0))) } else { /* * Still need to trigger enter/leave events on tags that have * changed. */ XTkTextEventuallyRepick(tls, textPtr) } if XTkBTreeTag(tls, bp+8, bp+40, tagPtr, addTag) != 0 { /* * If the tag is "sel", and we actually adjusted something * then grab the selection if we're supposed to export it and * don't already have it. * * Also, invalidate partially-completed selection retrievals. * We only need to check whether the tag is "sel" for this * textPtr (not for other peer widget's "sel" tags) because we * cannot reach this code path with a different widget's "sel" * tag. */ if tagPtr == (*TTkText)(unsafe.Pointer(textPtr)).FselTagPtr { /* * Send an event that the selection changed. This is * equivalent to: * event generate $textWidget <> */ XTkTextSelectionEvent(tls, textPtr) if addTag != 0 && (*TTkText)(unsafe.Pointer(textPtr)).FexportSelection != 0 && !(libtcl9_0.XTcl_IsSafe(tls, (*TTkText)(unsafe.Pointer(textPtr)).Finterp) != 0) && !((*TTkText)(unsafe.Pointer(textPtr)).Fflags&libc.Int32FromInt32(GOT_SELECTION1) != 0) { XTk_OwnSelection(tls, (*TTkText)(unsafe.Pointer(textPtr)).Ftkwin, libc.Uint64FromInt32(1), __ccgo_fp(XTkTextLostSelection), textPtr) *(*int32)(unsafe.Pointer(textPtr + 672)) |= int32(GOT_SELECTION1) } (*TTkText)(unsafe.Pointer(textPtr)).FabortSelections = int32(1) } } goto _14 _14: ; i += int64(2) } goto _13 _3: ; if objc < int64(4) || objc > int64(6) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(3), objv, __ccgo_ts+48585) return int32(TCL_ERROR) } tagPtr = XTkTextCreateTag(tls, textPtr, libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 3*8)), libc.UintptrFromInt32(0)), libc.UintptrFromInt32(0)) /* * Make a binding table if the widget doesn't already have one. */ if (*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).FbindingTable == libc.UintptrFromInt32(0) { (*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).FbindingTable = XTk_CreateBindingTable(tls, interp) } if objc == int64(6) { append1 = 0 fifth = libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 5*8)), libc.UintptrFromInt32(0)) if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(fifth))) == 0 { return XTk_DeleteBinding(tls, interp, (*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).FbindingTable, (*TTkTextTag)(unsafe.Pointer(tagPtr)).Fname, libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 4*8)), libc.UintptrFromInt32(0))) } if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(fifth))) == int32('+') { fifth++ append1 = int32(1) } mask = XTk_CreateBinding(tls, interp, (*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).FbindingTable, (*TTkTextTag)(unsafe.Pointer(tagPtr)).Fname, libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 4*8)), libc.UintptrFromInt32(0)), fifth, append1) if mask == uint64(0) { return int32(TCL_ERROR) } if mask & ^libc.Uint64FromInt64(libc.Int64FromInt64(1)<= 0 { /* * Indices are potentially obsolete after changing -elide, * especially those computed with "display" or "any" * submodifier, therefore increase the epoch. */ (*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).FstateEpoch++ } /* * If the "sel" tag was changed, be sure to mirror information * from the tag back into the text widget record. NOTE: we don't * have to free up information in the widget record before * overwriting it, because it was mirrored in the tag and hence * freed when the tag field was overwritten. */ if tagPtr == (*TTkText)(unsafe.Pointer(textPtr)).FselTagPtr { if (*TTkTextTag)(unsafe.Pointer(tagPtr)).FselBorder == libc.UintptrFromInt32(0) { (*TTkText)(unsafe.Pointer(textPtr)).FselBorder = (*TTkTextTag)(unsafe.Pointer(tagPtr)).Fborder } else { (*TTkText)(unsafe.Pointer(textPtr)).FselBorder = (*TTkTextTag)(unsafe.Pointer(tagPtr)).FselBorder } (*TTkText)(unsafe.Pointer(textPtr)).FselBorderWidthObj = (*TTkTextTag)(unsafe.Pointer(tagPtr)).FborderWidthObj if (*TTkTextTag)(unsafe.Pointer(tagPtr)).FselFgColor == libc.UintptrFromInt32(0) { (*TTkText)(unsafe.Pointer(textPtr)).FselFgColorPtr = (*TTkTextTag)(unsafe.Pointer(tagPtr)).FfgColor } else { (*TTkText)(unsafe.Pointer(textPtr)).FselFgColorPtr = (*TTkTextTag)(unsafe.Pointer(tagPtr)).FselFgColor } } (*TTkTextTag)(unsafe.Pointer(tagPtr)).FaffectsDisplay = 0 (*TTkTextTag)(unsafe.Pointer(tagPtr)).FaffectsDisplayGeometry = 0 if (*TTkTextTag)(unsafe.Pointer(tagPtr)).Felide >= 0 || (*TTkTextTag)(unsafe.Pointer(tagPtr)).Ftkfont != libc.UintptrFromInt32(0) || (*TTkTextTag)(unsafe.Pointer(tagPtr)).Fjustify != int32(TK_JUSTIFY_NULL) || (*TTkTextTag)(unsafe.Pointer(tagPtr)).FlMargin1Obj != libc.UintptrFromInt32(0) || (*TTkTextTag)(unsafe.Pointer(tagPtr)).FlMargin2Obj != libc.UintptrFromInt32(0) || (*TTkTextTag)(unsafe.Pointer(tagPtr)).FoffsetObj != libc.UintptrFromInt32(0) || (*TTkTextTag)(unsafe.Pointer(tagPtr)).FrMarginObj != libc.UintptrFromInt32(0) || (*TTkTextTag)(unsafe.Pointer(tagPtr)).Fspacing1Obj != libc.UintptrFromInt32(0) || (*TTkTextTag)(unsafe.Pointer(tagPtr)).Fspacing2Obj != libc.UintptrFromInt32(0) || (*TTkTextTag)(unsafe.Pointer(tagPtr)).Fspacing3Obj != libc.UintptrFromInt32(0) || (*TTkTextTag)(unsafe.Pointer(tagPtr)).FtabStringPtr != libc.UintptrFromInt32(0) || (*TTkTextTag)(unsafe.Pointer(tagPtr)).FtabStyle == int32(TK_TEXT_TABSTYLE_TABULAR) || (*TTkTextTag)(unsafe.Pointer(tagPtr)).FtabStyle == int32(TK_TEXT_TABSTYLE_WORDPROCESSOR) || (*TTkTextTag)(unsafe.Pointer(tagPtr)).FwrapMode == int32(TEXT_WRAPMODE_CHAR) || (*TTkTextTag)(unsafe.Pointer(tagPtr)).FwrapMode == int32(TEXT_WRAPMODE_NONE) || (*TTkTextTag)(unsafe.Pointer(tagPtr)).FwrapMode == int32(TEXT_WRAPMODE_WORD) { (*TTkTextTag)(unsafe.Pointer(tagPtr)).FaffectsDisplay = int32(1) (*TTkTextTag)(unsafe.Pointer(tagPtr)).FaffectsDisplayGeometry = int32(1) } if (*TTkTextTag)(unsafe.Pointer(tagPtr)).Fborder != libc.UintptrFromInt32(0) || (*TTkTextTag)(unsafe.Pointer(tagPtr)).FselBorder != libc.UintptrFromInt32(0) || (*TTkTextTag)(unsafe.Pointer(tagPtr)).Frelief != -int32(1) || (*TTkTextTag)(unsafe.Pointer(tagPtr)).FbgStipple != uint64(0) || (*TTkTextTag)(unsafe.Pointer(tagPtr)).FfgColor != libc.UintptrFromInt32(0) || (*TTkTextTag)(unsafe.Pointer(tagPtr)).FselFgColor != libc.UintptrFromInt32(0) || (*TTkTextTag)(unsafe.Pointer(tagPtr)).FfgStipple != uint64(0) || (*TTkTextTag)(unsafe.Pointer(tagPtr)).Foverstrike >= 0 || (*TTkTextTag)(unsafe.Pointer(tagPtr)).FoverstrikeColor != libc.UintptrFromInt32(0) || (*TTkTextTag)(unsafe.Pointer(tagPtr)).Funderline >= 0 || (*TTkTextTag)(unsafe.Pointer(tagPtr)).FunderlineColor != libc.UintptrFromInt32(0) || (*TTkTextTag)(unsafe.Pointer(tagPtr)).FlMarginColor != libc.UintptrFromInt32(0) || (*TTkTextTag)(unsafe.Pointer(tagPtr)).FrMarginColor != libc.UintptrFromInt32(0) { (*TTkTextTag)(unsafe.Pointer(tagPtr)).FaffectsDisplay = int32(1) } if !(*(*int32)(unsafe.Pointer(bp + 72)) != 0) { /* * This line is not necessary if this is a new tag, since it * can't possibly have been applied to anything yet. */ /* * VMD: If this is the 'sel' tag, then we don't need to call * this for all peers, unless we actually want to synchronize * sel-style changes across the peers. */ XTkTextRedrawTag(tls, (*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr, libc.UintptrFromInt32(0), libc.UintptrFromInt32(0), libc.UintptrFromInt32(0), tagPtr, int32(1)) } return TCL_OK } goto _13 _6: ; if objc < int64(4) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(3), objv, __ccgo_ts+48681) return int32(TCL_ERROR) } i = int64(3) for { if !(i < objc) { break } hPtr = (*(*func(*libc.TLS, uintptr, uintptr) uintptr)(unsafe.Pointer(&struct{ uintptr }{(*TTcl_HashTable)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr + 16)).FfindProc})))(tls, (*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr+16, libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(i)*8)), libc.UintptrFromInt32(0))) if hPtr == libc.UintptrFromInt32(0) { /* * Either this tag doesn't exist or it's the 'sel' tag (which * is not in the hash table). Either way we don't want to * delete it. */ goto _24 } tagPtr = (*TTcl_HashEntry)(unsafe.Pointer(hPtr)).FclientData if tagPtr == (*TTkText)(unsafe.Pointer(textPtr)).FselTagPtr { goto _24 } if (*TTkTextTag)(unsafe.Pointer(tagPtr)).FaffectsDisplay != 0 { XTkTextRedrawTag(tls, (*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr, libc.UintptrFromInt32(0), libc.UintptrFromInt32(0), libc.UintptrFromInt32(0), tagPtr, int32(1)) } XTkTextDeleteTag(tls, textPtr, tagPtr) libtcl9_0.XTcl_DeleteHashEntry(tls, hPtr) goto _24 _24: ; i++ } goto _13 _7: ; if objc != int64(4) && objc != int64(5) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(3), objv, __ccgo_ts+48703) return int32(TCL_ERROR) } tagPtr = _FindTag(tls, interp, textPtr, *(*uintptr)(unsafe.Pointer(objv + 3*8))) if tagPtr == libc.UintptrFromInt32(0) { return int32(TCL_ERROR) } if objc == int64(5) { tagPtr2 = _FindTag(tls, interp, textPtr, *(*uintptr)(unsafe.Pointer(objv + 4*8))) if tagPtr2 == libc.UintptrFromInt32(0) { return int32(TCL_ERROR) } if (*TTkTextTag)(unsafe.Pointer(tagPtr)).Fpriority < (*TTkTextTag)(unsafe.Pointer(tagPtr2)).Fpriority { prio = int32((*TTkTextTag)(unsafe.Pointer(tagPtr2)).Fpriority - int64(1)) } else { prio = int32((*TTkTextTag)(unsafe.Pointer(tagPtr2)).Fpriority) } } else { prio = 0 } _ChangeTagPriority(tls, textPtr, tagPtr, prio) /* * If this is the 'sel' tag, then we don't actually need to call this * for all peers. */ XTkTextRedrawTag(tls, (*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr, libc.UintptrFromInt32(0), libc.UintptrFromInt32(0), libc.UintptrFromInt32(0), tagPtr, int32(1)) goto _13 _8: ; if objc != int64(3) && objc != int64(4) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(3), objv, __ccgo_ts+48723) return int32(TCL_ERROR) } if objc == int64(3) { arrayPtr = libtcl9_0.XTcl_Alloc(tls, libc.Uint64FromInt64((*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).FnumTags)*uint64(8)) i = 0 hPtr1 = libtcl9_0.XTcl_FirstHashEntry(tls, (*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr+16, bp+104) for { if !(hPtr1 != libc.UintptrFromInt32(0)) { break } *(*uintptr)(unsafe.Pointer(arrayPtr + uintptr(i)*8)) = (*TTcl_HashEntry)(unsafe.Pointer(hPtr1)).FclientData goto _25 _25: ; i++ hPtr1 = libtcl9_0.XTcl_NextHashEntry(tls, bp+104) } /* * The 'sel' tag is not in the hash table. */ *(*uintptr)(unsafe.Pointer(arrayPtr + uintptr(i)*8)) = (*TTkText)(unsafe.Pointer(textPtr)).FselTagPtr i++ v26 = i *(*TTcl_Size)(unsafe.Pointer(bp + 96)) = v26 } else { if XTkTextGetObjIndex(tls, interp, textPtr, *(*uintptr)(unsafe.Pointer(objv + 3*8)), bp+8) != TCL_OK { return int32(TCL_ERROR) } arrayPtr = XTkBTreeGetTags(tls, bp+8, textPtr, bp+96) if arrayPtr == libc.UintptrFromInt32(0) { return TCL_OK } } _SortTags(tls, int32(*(*TTcl_Size)(unsafe.Pointer(bp + 96))), arrayPtr) listObj = libtcl9_0.XTcl_NewListObj(tls, 0, libc.UintptrFromInt32(0)) i = 0 for { if !(i < *(*TTcl_Size)(unsafe.Pointer(bp + 96))) { break } tagPtr = *(*uintptr)(unsafe.Pointer(arrayPtr + uintptr(i)*8)) libtcl9_0.XTcl_ListObjAppendElement(tls, interp, listObj, libtcl9_0.XTcl_NewStringObj(tls, (*TTkTextTag)(unsafe.Pointer(tagPtr)).Fname, int64(-int32(1)))) goto _27 _27: ; i++ } libtcl9_0.XTcl_SetObjResult(tls, interp, listObj) libtcl9_0.XTcl_Free(tls, arrayPtr) goto _13 _9: ; if objc != int64(5) && objc != int64(6) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(3), objv, __ccgo_ts+48731) return int32(TCL_ERROR) } tagPtr = _FindTag(tls, libc.UintptrFromInt32(0), textPtr, *(*uintptr)(unsafe.Pointer(objv + 3*8))) if tagPtr == libc.UintptrFromInt32(0) { return TCL_OK } if XTkTextGetObjIndex(tls, interp, textPtr, *(*uintptr)(unsafe.Pointer(objv + 4*8)), bp+8) != TCL_OK { return int32(TCL_ERROR) } XTkTextMakeByteIndex(tls, (*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).Ftree, textPtr, XTkBTreeNumLines(tls, (*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).Ftree, textPtr), 0, bp+128) if objc == int64(5) { *(*TTkTextIndex)(unsafe.Pointer(bp + 40)) = *(*TTkTextIndex)(unsafe.Pointer(bp + 128)) } else { if XTkTextGetObjIndex(tls, interp, textPtr, *(*uintptr)(unsafe.Pointer(objv + 5*8)), bp+40) != TCL_OK { return int32(TCL_ERROR) } } /* * The search below is a bit tricky. Rather than use the B-tree * facilities to stop the search at index2, let it search up until the * end of the file but check for a position past index2 ourselves. * The reason for doing it this way is that we only care whether the * *start* of the range is before index2; once we find the start, we * don't want TkBTreeNextTag to abort the search because the end of * the range is after index2. */ XTkBTreeStartSearch(tls, bp+8, bp+128, tagPtr, bp+160) if XTkBTreeCharTagged(tls, bp+8, tagPtr) != 0 { /* * The first character is tagged. See if there is an on-toggle * just before the character. If not, then skip to the end of this * tagged range. */ segPtr = (*TTkTextLine)(unsafe.Pointer((*(*TTkTextIndex)(unsafe.Pointer(bp + 8))).FlinePtr)).FsegPtr offset = int32((*(*TTkTextIndex)(unsafe.Pointer(bp + 8))).FbyteIndex) for { if !(offset >= 0) { break } if offset == 0 && (*TTkTextSegment)(unsafe.Pointer(segPtr)).FtypePtr == uintptr(unsafe.Pointer(&XtkTextToggleOnType)) && (*(*TTkTextToggle)(unsafe.Pointer(&(*TTkTextSegment)(unsafe.Pointer(segPtr)).Fbody))).FtagPtr == tagPtr { goto gotStart } goto _28 _28: ; offset = int32(int64(offset) - (*TTkTextSegment)(unsafe.Pointer(segPtr)).Fsize) segPtr = (*TTkTextSegment)(unsafe.Pointer(segPtr)).FnextPtr } if !(XTkBTreeNextTag(tls, bp+160) != 0) { return TCL_OK } } /* * Find the start of the tagged range. */ if !(XTkBTreeNextTag(tls, bp+160) != 0) { return TCL_OK } goto gotStart gotStart: ; if XTkTextIndexCmp(tls, bp+160, bp+40) >= 0 { return TCL_OK } resultObj = libtcl9_0.XTcl_NewObj(tls) XTkTextPrintIndex(tls, textPtr, bp+160, bp+232) libtcl9_0.XTcl_ListObjAppendElement(tls, libc.UintptrFromInt32(0), resultObj, libtcl9_0.XTcl_NewStringObj(tls, bp+232, int64(-libc.Int32FromInt32(1)))) XTkBTreeNextTag(tls, bp+160) XTkTextPrintIndex(tls, textPtr, bp+160, bp+232) libtcl9_0.XTcl_ListObjAppendElement(tls, libc.UintptrFromInt32(0), resultObj, libtcl9_0.XTcl_NewStringObj(tls, bp+232, int64(-libc.Int32FromInt32(1)))) libtcl9_0.XTcl_SetObjResult(tls, interp, resultObj) goto _13 _10: ; if objc != int64(5) && objc != int64(6) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(3), objv, __ccgo_ts+48731) return int32(TCL_ERROR) } tagPtr = _FindTag(tls, libc.UintptrFromInt32(0), textPtr, *(*uintptr)(unsafe.Pointer(objv + 3*8))) if tagPtr == libc.UintptrFromInt32(0) { return TCL_OK } if XTkTextGetObjIndex(tls, interp, textPtr, *(*uintptr)(unsafe.Pointer(objv + 4*8)), bp+8) != TCL_OK { return int32(TCL_ERROR) } if objc == int64(5) { XTkTextMakeByteIndex(tls, (*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).Ftree, textPtr, 0, 0, bp+40) } else { if XTkTextGetObjIndex(tls, interp, textPtr, *(*uintptr)(unsafe.Pointer(objv + 5*8)), bp+40) != TCL_OK { return int32(TCL_ERROR) } } /* * The search below is a bit weird. The previous toggle can be either * an on or off toggle. If it is an on toggle, then we need to turn * around and search forward for the end toggle. Otherwise we keep * searching backwards. */ XTkBTreeStartSearchBack(tls, bp+8, bp+40, tagPtr, bp+296) if !(XTkBTreePrevTag(tls, bp+296) != 0) { /* * Special case, there may be a tag off toggle at index1, and a * tag on toggle before the start of a partial peer widget. In * this case we missed it. */ if (*TTkText)(unsafe.Pointer(textPtr)).Fstart != libc.UintptrFromInt32(0) && (*TTkText)(unsafe.Pointer(textPtr)).Fstart == (*(*TTkTextIndex)(unsafe.Pointer(bp + 40))).FlinePtr && (*(*TTkTextIndex)(unsafe.Pointer(bp + 40))).FbyteIndex == 0 && XTkBTreeCharTagged(tls, bp+40, tagPtr) != 0 && XTkTextIndexCmp(tls, bp+40, bp+8) < 0 { /* * The first character is tagged, so just add the range from * the first char to the start of the range. */ XTkTextPrintIndex(tls, textPtr, bp+40, bp+368) XTkTextPrintIndex(tls, textPtr, bp+8, bp+398) goto gotPrevIndexPair } return TCL_OK } if (*TTkTextSegment)(unsafe.Pointer((*(*TTkTextSearch)(unsafe.Pointer(bp + 296))).FsegPtr)).FtypePtr == uintptr(unsafe.Pointer(&XtkTextToggleOnType)) { XTkTextPrintIndex(tls, textPtr, bp+296, bp+368) if (*TTkText)(unsafe.Pointer(textPtr)).Fstart != libc.UintptrFromInt32(0) { (*(*TTkTextIndex)(unsafe.Pointer(bp + 432))).FlinePtr = (*TTkText)(unsafe.Pointer(textPtr)).Fstart (*(*TTkTextIndex)(unsafe.Pointer(bp + 432))).FbyteIndex = 0 (*(*TTkTextIndex)(unsafe.Pointer(bp + 432))).FtextPtr = libc.UintptrFromInt32(0) if XTkTextIndexCmp(tls, bp+296, bp+432) < 0 { if XTkTextIndexCmp(tls, bp+432, bp+8) >= 0 { /* * But now the new first index is actually too far * along in the text, so nothing is returned. */ return TCL_OK } XTkTextPrintIndex(tls, textPtr, bp+432, bp+368) } } XTkTextMakeByteIndex(tls, (*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).Ftree, textPtr, XTkBTreeNumLines(tls, (*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).Ftree, textPtr), 0, bp+264) XTkBTreeStartSearch(tls, bp+296, bp+264, tagPtr, bp+296) XTkBTreeNextTag(tls, bp+296) XTkTextPrintIndex(tls, textPtr, bp+296, bp+398) } else { XTkTextPrintIndex(tls, textPtr, bp+296, bp+398) XTkBTreePrevTag(tls, bp+296) XTkTextPrintIndex(tls, textPtr, bp+296, bp+368) if XTkTextIndexCmp(tls, bp+296, bp+40) < 0 { if (*TTkText)(unsafe.Pointer(textPtr)).Fstart != libc.UintptrFromInt32(0) && (*(*TTkTextIndex)(unsafe.Pointer(bp + 40))).FlinePtr == (*TTkText)(unsafe.Pointer(textPtr)).Fstart && (*(*TTkTextIndex)(unsafe.Pointer(bp + 40))).FbyteIndex == 0 { /* It's ok */ XTkTextPrintIndex(tls, textPtr, bp+40, bp+368) } else { return TCL_OK } } } goto gotPrevIndexPair gotPrevIndexPair: ; resultObj1 = libtcl9_0.XTcl_NewObj(tls) libtcl9_0.XTcl_ListObjAppendElement(tls, libc.UintptrFromInt32(0), resultObj1, libtcl9_0.XTcl_NewStringObj(tls, bp+368, int64(-libc.Int32FromInt32(1)))) libtcl9_0.XTcl_ListObjAppendElement(tls, libc.UintptrFromInt32(0), resultObj1, libtcl9_0.XTcl_NewStringObj(tls, bp+398, int64(-libc.Int32FromInt32(1)))) libtcl9_0.XTcl_SetObjResult(tls, interp, resultObj1) goto _13 _11: ; if objc != int64(4) && objc != int64(5) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(3), objv, __ccgo_ts+48755) return int32(TCL_ERROR) } tagPtr = _FindTag(tls, interp, textPtr, *(*uintptr)(unsafe.Pointer(objv + 3*8))) if tagPtr == libc.UintptrFromInt32(0) { return int32(TCL_ERROR) } if objc == int64(5) { tagPtr21 = _FindTag(tls, interp, textPtr, *(*uintptr)(unsafe.Pointer(objv + 4*8))) if tagPtr21 == libc.UintptrFromInt32(0) { return int32(TCL_ERROR) } if (*TTkTextTag)(unsafe.Pointer(tagPtr)).Fpriority <= (*TTkTextTag)(unsafe.Pointer(tagPtr21)).Fpriority { prio1 = int32((*TTkTextTag)(unsafe.Pointer(tagPtr21)).Fpriority) } else { prio1 = int32((*TTkTextTag)(unsafe.Pointer(tagPtr21)).Fpriority + int64(1)) } } else { prio1 = int32((*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).FnumTags - int64(1)) } _ChangeTagPriority(tls, textPtr, tagPtr, prio1) /* * If this is the 'sel' tag, then we don't actually need to call this * for all peers. */ XTkTextRedrawTag(tls, (*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr, libc.UintptrFromInt32(0), libc.UintptrFromInt32(0), libc.UintptrFromInt32(0), tagPtr, int32(1)) goto _13 _12: ; listObj1 = libtcl9_0.XTcl_NewListObj(tls, 0, libc.UintptrFromInt32(0)) count = 0 if objc != int64(4) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(3), objv, __ccgo_ts+48775) return int32(TCL_ERROR) } tagPtr = _FindTag(tls, libc.UintptrFromInt32(0), textPtr, *(*uintptr)(unsafe.Pointer(objv + 3*8))) if tagPtr == libc.UintptrFromInt32(0) { return TCL_OK } XTkTextMakeByteIndex(tls, (*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).Ftree, textPtr, 0, 0, bp+464) XTkTextMakeByteIndex(tls, (*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).Ftree, textPtr, XTkBTreeNumLines(tls, (*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).Ftree, textPtr), 0, bp+496) XTkBTreeStartSearch(tls, bp+464, bp+496, tagPtr, bp+528) if XTkBTreeCharTagged(tls, bp+464, tagPtr) != 0 { libtcl9_0.XTcl_ListObjAppendElement(tls, libc.UintptrFromInt32(0), listObj1, XTkTextNewIndexObj(tls, textPtr, bp+464)) count++ } for XTkBTreeNextTag(tls, bp+528) != 0 { libtcl9_0.XTcl_ListObjAppendElement(tls, libc.UintptrFromInt32(0), listObj1, XTkTextNewIndexObj(tls, textPtr, bp+528)) count++ } if count%int32(2) == int32(1) { /* * If a text widget uses '-end', it won't necessarily run to the * end of the B-tree, and therefore the tag range might not be * closed. In this case we add the end of the range. */ libtcl9_0.XTcl_ListObjAppendElement(tls, libc.UintptrFromInt32(0), listObj1, XTkTextNewIndexObj(tls, textPtr, bp+496)) } libtcl9_0.XTcl_SetObjResult(tls, interp, listObj1) goto _13 _13: ; return TCL_OK } var _tagOptionStrings = [13]uintptr{ 0: __ccgo_ts + 2651, 1: __ccgo_ts + 17761, 2: __ccgo_ts + 4735, 3: __ccgo_ts + 4740, 4: __ccgo_ts + 2655, 5: __ccgo_ts + 17816, 6: __ccgo_ts + 10036, 7: __ccgo_ts + 48505, 8: __ccgo_ts + 48515, 9: __ccgo_ts + 17822, 10: __ccgo_ts + 48525, 11: __ccgo_ts + 12143, 12: libc.UintptrFromInt32(0), } /* *---------------------------------------------------------------------- * * TkTextCreateTag -- * * Find the record describing a tag within a given text widget, creating * a new record if one doesn't already exist. * * Results: * The return value is a pointer to the TkTextTag record for tagName. * * Side effects: * A new tag record is created if there isn't one already defined for * tagName. * *---------------------------------------------------------------------- */ func XTkTextCreateTag(tls *libc.TLS, textPtr uintptr, tagName uintptr, newTag uintptr) (r uintptr) { bp := tls.Alloc(16) defer tls.Free(16) /* If non-NULL, then return 1 if new, or 0 if * already exists. */ var hPtr, name, tagPtr, v1 uintptr var _ /* isNew at bp+0 */ int32 _, _, _, _ = hPtr, name, tagPtr, v1 hPtr = libc.UintptrFromInt32(0) if !(libc.Xstrcmp(tls, tagName, __ccgo_ts+42892) != 0) { if (*TTkText)(unsafe.Pointer(textPtr)).FselTagPtr != libc.UintptrFromInt32(0) { if newTag != libc.UintptrFromInt32(0) { *(*int32)(unsafe.Pointer(newTag)) = 0 } return (*TTkText)(unsafe.Pointer(textPtr)).FselTagPtr } if newTag != libc.UintptrFromInt32(0) { *(*int32)(unsafe.Pointer(newTag)) = int32(1) } name = __ccgo_ts + 42892 } else { hPtr = (*(*func(*libc.TLS, uintptr, uintptr, uintptr) uintptr)(unsafe.Pointer(&struct{ uintptr }{(*TTcl_HashTable)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr + 16)).FcreateProc})))(tls, (*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr+16, tagName, bp) if newTag != libc.UintptrFromInt32(0) { *(*int32)(unsafe.Pointer(newTag)) = *(*int32)(unsafe.Pointer(bp)) } if !(*(*int32)(unsafe.Pointer(bp)) != 0) { return (*TTcl_HashEntry)(unsafe.Pointer(hPtr)).FclientData } if (*TTcl_HashTable)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr+16)).FkeyType == int32(TCL_ONE_WORD_KEYS) || (*TTcl_HashTable)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr+16)).FkeyType == -int32(1) { v1 = *(*uintptr)(unsafe.Pointer(hPtr + 32)) } else { v1 = hPtr + 32 } name = v1 } /* * No existing entry. Create a new one, initialize it, and add a pointer * to it to the hash table entry. */ tagPtr = libtcl9_0.XTcl_Alloc(tls, uint64(296)) (*TTkTextTag)(unsafe.Pointer(tagPtr)).Fname = name (*TTkTextTag)(unsafe.Pointer(tagPtr)).FtextPtr = libc.UintptrFromInt32(0) (*TTkTextTag)(unsafe.Pointer(tagPtr)).FtoggleCount = 0 (*TTkTextTag)(unsafe.Pointer(tagPtr)).FtagRootPtr = libc.UintptrFromInt32(0) (*TTkTextTag)(unsafe.Pointer(tagPtr)).Fpriority = (*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).FnumTags (*TTkTextTag)(unsafe.Pointer(tagPtr)).Fborder = libc.UintptrFromInt32(0) (*TTkTextTag)(unsafe.Pointer(tagPtr)).FborderWidthObj = libc.UintptrFromInt32(0) (*TTkTextTag)(unsafe.Pointer(tagPtr)).Frelief = -int32(1) (*TTkTextTag)(unsafe.Pointer(tagPtr)).FbgStipple = uint64(0) (*TTkTextTag)(unsafe.Pointer(tagPtr)).FfgColor = libc.UintptrFromInt32(0) (*TTkTextTag)(unsafe.Pointer(tagPtr)).Ftkfont = libc.UintptrFromInt32(0) (*TTkTextTag)(unsafe.Pointer(tagPtr)).FfgStipple = uint64(0) (*TTkTextTag)(unsafe.Pointer(tagPtr)).Fjustify = int32(TK_JUSTIFY_NULL) (*TTkTextTag)(unsafe.Pointer(tagPtr)).FlMargin1Obj = libc.UintptrFromInt32(0) (*TTkTextTag)(unsafe.Pointer(tagPtr)).FlMargin1 = 0 (*TTkTextTag)(unsafe.Pointer(tagPtr)).FlMargin2Obj = libc.UintptrFromInt32(0) (*TTkTextTag)(unsafe.Pointer(tagPtr)).FlMargin2 = 0 (*TTkTextTag)(unsafe.Pointer(tagPtr)).FlMarginColor = libc.UintptrFromInt32(0) (*TTkTextTag)(unsafe.Pointer(tagPtr)).FoffsetObj = libc.UintptrFromInt32(0) (*TTkTextTag)(unsafe.Pointer(tagPtr)).Foffset = 0 (*TTkTextTag)(unsafe.Pointer(tagPtr)).Foverstrike = -int32(1) (*TTkTextTag)(unsafe.Pointer(tagPtr)).FoverstrikeColor = libc.UintptrFromInt32(0) (*TTkTextTag)(unsafe.Pointer(tagPtr)).FrMarginObj = libc.UintptrFromInt32(0) (*TTkTextTag)(unsafe.Pointer(tagPtr)).FrMargin = 0 (*TTkTextTag)(unsafe.Pointer(tagPtr)).FrMarginColor = libc.UintptrFromInt32(0) (*TTkTextTag)(unsafe.Pointer(tagPtr)).FselBorder = libc.UintptrFromInt32(0) (*TTkTextTag)(unsafe.Pointer(tagPtr)).FselFgColor = libc.UintptrFromInt32(0) (*TTkTextTag)(unsafe.Pointer(tagPtr)).Fspacing1Obj = libc.UintptrFromInt32(0) (*TTkTextTag)(unsafe.Pointer(tagPtr)).Fspacing2Obj = libc.UintptrFromInt32(0) (*TTkTextTag)(unsafe.Pointer(tagPtr)).Fspacing3Obj = libc.UintptrFromInt32(0) (*TTkTextTag)(unsafe.Pointer(tagPtr)).FtabStringPtr = libc.UintptrFromInt32(0) (*TTkTextTag)(unsafe.Pointer(tagPtr)).FtabArrayPtr = libc.UintptrFromInt32(0) (*TTkTextTag)(unsafe.Pointer(tagPtr)).FtabStyle = int32(TK_TEXT_TABSTYLE_NULL) (*TTkTextTag)(unsafe.Pointer(tagPtr)).Funderline = -int32(1) (*TTkTextTag)(unsafe.Pointer(tagPtr)).FunderlineColor = libc.UintptrFromInt32(0) (*TTkTextTag)(unsafe.Pointer(tagPtr)).Felide = -int32(1) (*TTkTextTag)(unsafe.Pointer(tagPtr)).FwrapMode = int32(TEXT_WRAPMODE_NULL) (*TTkTextTag)(unsafe.Pointer(tagPtr)).FaffectsDisplay = 0 (*TTkTextTag)(unsafe.Pointer(tagPtr)).FaffectsDisplayGeometry = 0 (*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).FnumTags++ if !(libc.Xstrcmp(tls, tagName, __ccgo_ts+42892) != 0) { (*TTkTextTag)(unsafe.Pointer(tagPtr)).FtextPtr = textPtr (*TTkText)(unsafe.Pointer(textPtr)).FrefCount++ } else { (*TTcl_HashEntry)(unsafe.Pointer(hPtr)).FclientData = tagPtr } (*TTkTextTag)(unsafe.Pointer(tagPtr)).FoptionTable = XTk_CreateOptionTable(tls, (*TTkText)(unsafe.Pointer(textPtr)).Finterp, uintptr(unsafe.Pointer(&_tagOptionSpecs))) return tagPtr } /* *---------------------------------------------------------------------- * * FindTag -- * * See if tag is defined for a given widget. * * Results: * If tagName is defined in textPtr, a pointer to its TkTextTag structure * is returned. Otherwise NULL is returned and an error message is * recorded in the interp's result unless interp is NULL. * * Side effects: * None. * *---------------------------------------------------------------------- */ func _FindTag(tls *libc.TLS, interp uintptr, textPtr uintptr, tagName uintptr) (r uintptr) { bp := tls.Alloc(64) defer tls.Free(64) /* Name of desired tag. */ var hPtr, str uintptr var _ /* len at bp+0 */ TTcl_Size _, _ = hPtr, str str = libtcl9_0.XTcl_GetStringFromObj(tls, tagName, bp) if *(*TTcl_Size)(unsafe.Pointer(bp)) == int64(3) && !(libc.Xstrcmp(tls, str, __ccgo_ts+42892) != 0) { return (*TTkText)(unsafe.Pointer(textPtr)).FselTagPtr } hPtr = (*(*func(*libc.TLS, uintptr, uintptr) uintptr)(unsafe.Pointer(&struct{ uintptr }{(*TTcl_HashTable)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr + 16)).FfindProc})))(tls, (*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr+16, libtcl9_0.XTcl_GetStringFromObj(tls, tagName, libc.UintptrFromInt32(0))) if hPtr != libc.UintptrFromInt32(0) { return (*TTcl_HashEntry)(unsafe.Pointer(hPtr)).FclientData } if interp != libc.UintptrFromInt32(0) { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+48783, libc.VaList(bp+16, libtcl9_0.XTcl_GetStringFromObj(tls, tagName, libc.UintptrFromInt32(0))))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+16, __ccgo_ts+179, __ccgo_ts+3058, __ccgo_ts+48821, libtcl9_0.XTcl_GetStringFromObj(tls, tagName, libc.UintptrFromInt32(0)), libc.UintptrFromInt32(0))) } return libc.UintptrFromInt32(0) } /* *---------------------------------------------------------------------- * * TkTextDeleteTag -- * * This function is called to carry out most actions associated with the * 'tag delete' sub-command. It will remove all evidence of the tag from * the B-tree, and then call TkTextFreeTag to clean up the tag structure * itself. * * The only actions this doesn't carry out it to check if the deletion of * the tag requires something to be re-displayed, and to remove the tag * from the tagTable (hash table) if that is necessary (i.e. if it's not * the 'sel' tag). It is expected that the caller carry out both of these * actions. * * Results: * None. * * Side effects: * Memory and other resources are freed, the B-tree is manipulated. * *---------------------------------------------------------------------- */ func XTkTextDeleteTag(tls *libc.TLS, textPtr uintptr, tagPtr uintptr) { bp := tls.Alloc(64) defer tls.Free(64) /* Tag being deleted. */ var _ /* first at bp+0 */ TTkTextIndex var _ /* last at bp+32 */ TTkTextIndex XTkTextMakeByteIndex(tls, (*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).Ftree, textPtr, 0, 0, bp) XTkTextMakeByteIndex(tls, (*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).Ftree, textPtr, XTkBTreeNumLines(tls, (*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).Ftree, textPtr), 0, bp+32) XTkBTreeTag(tls, bp, bp+32, tagPtr, 0) if tagPtr == (*TTkText)(unsafe.Pointer(textPtr)).FselTagPtr { /* * Send an event that the selection changed. This is equivalent to: * event generate $textWidget <> */ XTkTextSelectionEvent(tls, textPtr) } else { /* * Since all peer widgets have an independent "sel" tag, we * don't want removal of one sel tag to remove bindings which * are still valid in other peer widgets. */ if (*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).FbindingTable != libc.UintptrFromInt32(0) { XTk_DeleteAllBindings(tls, (*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).FbindingTable, (*TTkTextTag)(unsafe.Pointer(tagPtr)).Fname) } } /* * Update the tag priorities to reflect the deletion of this tag. */ _ChangeTagPriority(tls, textPtr, tagPtr, int32((*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).FnumTags-int64(1))) *(*TTcl_Size)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr + 120)) -= int64(1) XTkTextFreeTag(tls, textPtr, tagPtr) } /* *---------------------------------------------------------------------- * * TkTextFreeTag -- * * This function is called when a tag is deleted to free up the memory * and other resources associated with the tag. * * Results: * None. * * Side effects: * Memory and other resources are freed. * *---------------------------------------------------------------------- */ func XTkTextFreeTag(tls *libc.TLS, textPtr uintptr, tagPtr uintptr) { /* Tag being deleted. */ var i int32 var v3 TTcl_Size var v4 uintptr _, _, _ = i, v3, v4 /* * Let Tk do most of the hard work for us. */ XTk_FreeConfigOptions(tls, tagPtr, (*TTkTextTag)(unsafe.Pointer(tagPtr)).FoptionTable, (*TTkText)(unsafe.Pointer(textPtr)).Ftkwin) /* * This associated information is managed by us. */ if (*TTkTextTag)(unsafe.Pointer(tagPtr)).FtabArrayPtr != libc.UintptrFromInt32(0) { libtcl9_0.XTcl_Free(tls, (*TTkTextTag)(unsafe.Pointer(tagPtr)).FtabArrayPtr) } /* * Make sure this tag isn't referenced from the 'current' tag array. */ i = 0 for { if !(i < (*TTkText)(unsafe.Pointer(textPtr)).FnumCurTags) { break } if *(*uintptr)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FcurTagArrayPtr + uintptr(i)*8)) == tagPtr { for { if !(i < (*TTkText)(unsafe.Pointer(textPtr)).FnumCurTags-int32(1)) { break } *(*uintptr)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FcurTagArrayPtr + uintptr(i)*8)) = *(*uintptr)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FcurTagArrayPtr + uintptr(i+int32(1))*8)) goto _2 _2: ; i++ } *(*uintptr)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FcurTagArrayPtr + uintptr((*TTkText)(unsafe.Pointer(textPtr)).FnumCurTags-int32(1))*8)) = libc.UintptrFromInt32(0) (*TTkText)(unsafe.Pointer(textPtr)).FnumCurTags-- break } goto _1 _1: ; i++ } /* * If this tag is widget-specific (peer widgets) then clean up the * refCount it holds. */ if (*TTkTextTag)(unsafe.Pointer(tagPtr)).FtextPtr != libc.UintptrFromInt32(0) { if textPtr != (*TTkTextTag)(unsafe.Pointer(tagPtr)).FtextPtr { libtcl9_0.XTcl_Panic(tls, __ccgo_ts+48830, 0) } v4 = textPtr + 688 v3 = *(*TTcl_Size)(unsafe.Pointer(v4)) *(*TTcl_Size)(unsafe.Pointer(v4))-- if v3 <= int64(1) { libtcl9_0.XTcl_Free(tls, textPtr) } (*TTkTextTag)(unsafe.Pointer(tagPtr)).FtextPtr = libc.UintptrFromInt32(0) } /* * Finally free the tag's memory. */ libtcl9_0.XTcl_Free(tls, tagPtr) } /* *---------------------------------------------------------------------- * * SortTags -- * * This function sorts an array of tag pointers in increasing order of * priority, optimizing for the common case where the array is small. * * Results: * None. * * Side effects: * None. * *---------------------------------------------------------------------- */ func _SortTags(tls *libc.TLS, numTags int32, tagArrayPtr uintptr) { /* Pointer to array of pointers. */ var i, j, prio int32 var maxPtrPtr, tagPtrPtr, tmp, v2 uintptr _, _, _, _, _, _, _ = i, j, maxPtrPtr, prio, tagPtrPtr, tmp, v2 if numTags < int32(2) { return } if numTags < int32(20) { i = numTags - int32(1) for { if !(i > 0) { break } v2 = tagArrayPtr tagPtrPtr = v2 maxPtrPtr = v2 prio = int32((*TTkTextTag)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(tagPtrPtr)))).Fpriority) j = i tagPtrPtr += 8 for { if !(j > 0) { break } if (*TTkTextTag)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(tagPtrPtr)))).Fpriority < int64(prio) { prio = int32((*TTkTextTag)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(tagPtrPtr)))).Fpriority) maxPtrPtr = tagPtrPtr } goto _3 _3: ; j-- tagPtrPtr += 8 } tmp = *(*uintptr)(unsafe.Pointer(maxPtrPtr)) *(*uintptr)(unsafe.Pointer(maxPtrPtr)) = *(*uintptr)(unsafe.Pointer(tagArrayPtr)) *(*uintptr)(unsafe.Pointer(tagArrayPtr)) = tmp goto _1 _1: ; i-- tagArrayPtr += 8 } } else { libc.Xqsort(tls, tagArrayPtr, uint64(libc.Uint32FromInt32(numTags)), uint64(8), __ccgo_fp(_TagSortProc)) } } /* *---------------------------------------------------------------------- * * TagSortProc -- * * This function is called by qsort() when sorting an array of tags in * priority order. * * Results: * The return value is -1 if the first argument should be before the * second element (i.e. it has lower priority), 0 if it's equivalent * (this should never happen!), and 1 if it should be after the second * element. * * Side effects: * None. * *---------------------------------------------------------------------- */ func _TagSortProc(tls *libc.TLS, first uintptr, second uintptr) (r int32) { /* Elements to be compared. */ var tagPtr1, tagPtr2 uintptr _, _ = tagPtr1, tagPtr2 tagPtr1 = *(*uintptr)(unsafe.Pointer(first)) tagPtr2 = *(*uintptr)(unsafe.Pointer(second)) return int32((*TTkTextTag)(unsafe.Pointer(tagPtr1)).Fpriority - (*TTkTextTag)(unsafe.Pointer(tagPtr2)).Fpriority) } /* *---------------------------------------------------------------------- * * ChangeTagPriority -- * * This function changes the priority of a tag by modifying its priority * and the priorities of other tags that are affected by the change. * * Results: * None. * * Side effects: * Priorities may be changed for some or all of the tags in textPtr. The * tags will be arranged so that there is exactly one tag at each * priority level between 0 and textPtr->sharedTextPtr->numTags-1, with * tagPtr at priority "prio". * *---------------------------------------------------------------------- */ func _ChangeTagPriority(tls *libc.TLS, textPtr uintptr, tagPtr uintptr, prio int32) { bp := tls.Alloc(32) defer tls.Free(32) /* New priority for tag. */ var delta, high, low int32 var hPtr, tagPtr2 uintptr var _ /* search at bp+0 */ TTcl_HashSearch _, _, _, _, _ = delta, hPtr, high, low, tagPtr2 if prio < 0 { prio = 0 } if int64(prio) >= (*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).FnumTags { prio = int32((*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).FnumTags - int64(1)) } if int64(prio) == (*TTkTextTag)(unsafe.Pointer(tagPtr)).Fpriority { return } if int64(prio) < (*TTkTextTag)(unsafe.Pointer(tagPtr)).Fpriority { low = prio high = int32((*TTkTextTag)(unsafe.Pointer(tagPtr)).Fpriority - int64(1)) delta = int32(1) } else { low = int32((*TTkTextTag)(unsafe.Pointer(tagPtr)).Fpriority + int64(1)) high = prio delta = -int32(1) } /* * Adjust first the 'sel' tag, then all others from the hash table */ if (*TTkTextTag)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FselTagPtr)).Fpriority >= int64(low) && (*TTkTextTag)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FselTagPtr)).Fpriority <= int64(high) { *(*TTcl_Size)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FselTagPtr + 16)) += int64(delta) } hPtr = libtcl9_0.XTcl_FirstHashEntry(tls, (*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr+16, bp) for { if !(hPtr != libc.UintptrFromInt32(0)) { break } tagPtr2 = (*TTcl_HashEntry)(unsafe.Pointer(hPtr)).FclientData if (*TTkTextTag)(unsafe.Pointer(tagPtr2)).Fpriority >= int64(low) && (*TTkTextTag)(unsafe.Pointer(tagPtr2)).Fpriority <= int64(high) { *(*TTcl_Size)(unsafe.Pointer(tagPtr2 + 16)) += int64(delta) } goto _1 _1: ; hPtr = libtcl9_0.XTcl_NextHashEntry(tls, bp) } (*TTkTextTag)(unsafe.Pointer(tagPtr)).Fpriority = int64(prio) } /* *-------------------------------------------------------------- * * TkTextBindProc -- * * This function is invoked by the Tk dispatcher to handle events * associated with bindings on items. * * Results: * None. * * Side effects: * Depends on the command invoked as part of the binding (if there was * any). * *-------------------------------------------------------------- */ func XTkTextBindProc(tls *libc.TLS, clientData uintptr, eventPtr uintptr) { bp := tls.Alloc(48) defer tls.Free(48) /* Pointer to X event that just happened. */ var mask uint64 var oldState uint32 var repick int32 var tagArrayPtr, textPtr, v3, p1 uintptr var v2 TTcl_Size var _ /* index at bp+0 */ TTkTextIndex var _ /* numTags at bp+32 */ TTcl_Size _, _, _, _, _, _, _, _ = mask, oldState, repick, tagArrayPtr, textPtr, v2, v3, p1 textPtr = clientData repick = 0 (*TTkText)(unsafe.Pointer(textPtr)).FrefCount++ /* * This code simulates grabs for mouse buttons by keeping track of whether * a button is pressed and refusing to pick a new current character while * a button is pressed. */ if (*TXEvent)(unsafe.Pointer(eventPtr)).Ftype1 == int32(ButtonPress) { *(*int32)(unsafe.Pointer(textPtr + 672)) |= int32(BUTTON_DOWN) } else { if (*TXEvent)(unsafe.Pointer(eventPtr)).Ftype1 == int32(ButtonRelease) { mask = uint64(XTk_GetButtonMask(tls, (*(*TXButtonEvent)(unsafe.Pointer(eventPtr))).Fbutton)) if uint64((*(*TXButtonEvent)(unsafe.Pointer(eventPtr))).Fstate&libc.Uint32FromInt32(libc.Int32FromInt32(1)< 0 { /* * The mouse is inside the text widget, the 'current' mark was updated. */ _TagBindEvent(tls, textPtr, eventPtr, (*TTkText)(unsafe.Pointer(textPtr)).FnumCurTags, (*TTkText)(unsafe.Pointer(textPtr)).FcurTagArrayPtr) } else { if (*TXEvent)(unsafe.Pointer(eventPtr)).Ftype1 == int32(KeyPress) || (*TXEvent)(unsafe.Pointer(eventPtr)).Ftype1 == int32(KeyRelease) { XTkTextMarkNameToIndex(tls, textPtr, __ccgo_ts+22158, bp) tagArrayPtr = XTkBTreeGetTags(tls, bp, textPtr, bp+32) _SortTags(tls, int32(*(*TTcl_Size)(unsafe.Pointer(bp + 32))), tagArrayPtr) _TagBindEvent(tls, textPtr, eventPtr, int32(*(*TTcl_Size)(unsafe.Pointer(bp + 32))), tagArrayPtr) } } } if repick != 0 { oldState = (*(*TXButtonEvent)(unsafe.Pointer(eventPtr))).Fstate p1 = eventPtr + 80 *(*uint32)(unsafe.Pointer(p1)) = uint32(uint64(*(*uint32)(unsafe.Pointer(p1))) & ^libc.Uint64FromInt32(libc.Int32FromInt32(1)< 0 { size = libc.Uint64FromInt64(*(*TTcl_Size)(unsafe.Pointer(bp + 40))) * uint64(8) copyArrayPtr = libtcl9_0.XTcl_Alloc(tls, size) libc.Xmemcpy(tls, copyArrayPtr, newArrayPtr, size) i = 0 for { if !(i < (*TTkText)(unsafe.Pointer(textPtr)).FnumCurTags) { break } j = 0 for { if !(j < *(*TTcl_Size)(unsafe.Pointer(bp + 40))) { break } if *(*uintptr)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FcurTagArrayPtr + uintptr(i)*8)) == *(*uintptr)(unsafe.Pointer(copyArrayPtr + uintptr(j)*8)) { *(*uintptr)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FcurTagArrayPtr + uintptr(i)*8)) = libc.UintptrFromInt32(0) *(*uintptr)(unsafe.Pointer(copyArrayPtr + uintptr(j)*8)) = libc.UintptrFromInt32(0) break } goto _2 _2: ; j++ } goto _1 _1: ; i++ } } /* * Invoke the binding system with a LeaveNotify event for all of the tags * that have gone away. We have to be careful here, because it's possible * that the binding could do something (like calling tkwait) that * eventually modifies textPtr->curTagArrayPtr. To avoid problems in * situations like this, update curTagArrayPtr to its new value before * invoking any bindings, and don't use it any more here. */ numOldTags = (*TTkText)(unsafe.Pointer(textPtr)).FnumCurTags (*TTkText)(unsafe.Pointer(textPtr)).FnumCurTags = int32(*(*TTcl_Size)(unsafe.Pointer(bp + 40))) oldArrayPtr = (*TTkText)(unsafe.Pointer(textPtr)).FcurTagArrayPtr (*TTkText)(unsafe.Pointer(textPtr)).FcurTagArrayPtr = newArrayPtr if numOldTags != 0 { if (*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).FbindingTable != libc.UintptrFromInt32(0) && (*TTkText)(unsafe.Pointer(textPtr)).Ftkwin != libc.UintptrFromInt32(0) && !((*TTkText)(unsafe.Pointer(textPtr)).Fflags&libc.Int32FromInt32(DESTROYED) != 0) { *(*TXEvent)(unsafe.Pointer(bp + 48)) = (*TTkText)(unsafe.Pointer(textPtr)).FpickEvent (*(*TXEvent)(unsafe.Pointer(bp + 48))).Ftype1 = int32(LeaveNotify) /* * Behaviour before ticket #47d4f29159: * Always use a detail of NotifyAncestor. Besides being * consistent, this avoids problems where the binding code will * discard NotifyInferior events. * * Behaviour after ticket #47d4f29159: * The binding mechanism doesn't discard events with detail field * NotifyInferior anymore. It would be best to base the detail * field on the ancestry relationship between the old and new * tags. For the time being, retain the choice from before * ticket #47d4f29159, which doesn't harm. */ (*(*TXCrossingEvent)(unsafe.Pointer(&*(*TXEvent)(unsafe.Pointer(bp + 48))))).Fdetail = NotifyAncestor _TagBindEvent(tls, textPtr, bp+48, numOldTags, oldArrayPtr) } libtcl9_0.XTcl_Free(tls, oldArrayPtr) } /* * Reset the "current" mark (be careful to recompute its location, since * it might have changed during an event binding). Then invoke the binding * system with an EnterNotify event for all of the tags that have just * appeared. */ XTkTextPixelIndex(tls, textPtr, (*(*TXCrossingEvent)(unsafe.Pointer(&(*TTkText)(unsafe.Pointer(textPtr)).FpickEvent))).Fx, (*(*TXCrossingEvent)(unsafe.Pointer(&(*TTkText)(unsafe.Pointer(textPtr)).FpickEvent))).Fy, bp, bp+32) XTkTextSetMark(tls, textPtr, __ccgo_ts+3279, bp) if *(*TTcl_Size)(unsafe.Pointer(bp + 40)) != 0 { if (*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).FbindingTable != libc.UintptrFromInt32(0) && (*TTkText)(unsafe.Pointer(textPtr)).Ftkwin != libc.UintptrFromInt32(0) && !((*TTkText)(unsafe.Pointer(textPtr)).Fflags&libc.Int32FromInt32(DESTROYED) != 0) && !(*(*int32)(unsafe.Pointer(bp + 32)) != 0) { *(*TXEvent)(unsafe.Pointer(bp + 48)) = (*TTkText)(unsafe.Pointer(textPtr)).FpickEvent (*(*TXEvent)(unsafe.Pointer(bp + 48))).Ftype1 = int32(EnterNotify) (*(*TXCrossingEvent)(unsafe.Pointer(&*(*TXEvent)(unsafe.Pointer(bp + 48))))).Fdetail = NotifyAncestor _TagBindEvent(tls, textPtr, bp+48, int32(*(*TTcl_Size)(unsafe.Pointer(bp + 40))), copyArrayPtr) } libtcl9_0.XTcl_Free(tls, copyArrayPtr) } } /* *-------------------------------------------------------------- * * TagBindEvent -- * * Trigger given events for all tags that match the relevant bindings. * To handle the "sel" tag correctly in all peer widgets, we must use the * name of the tags as the binding table element. * * Results: * None. * * Side effects: * Almost anything can be triggered by tag bindings, including deletion * of the text widget. * *-------------------------------------------------------------- */ func _TagBindEvent(tls *libc.TLS, textPtr uintptr, eventPtr uintptr, numTags int32, tagArrayPtr uintptr) { bp := tls.Alloc(80) defer tls.Free(80) /* Array of relevant tags. */ var i int32 var nameArrPtr, tagPtr uintptr var _ /* nameArray at bp+0 */ [10]uintptr _, _, _ = i, nameArrPtr, tagPtr /* * Try to avoid allocation unless there are lots of tags. */ if numTags > int32(NUM_BIND_TAGS) { nameArrPtr = libtcl9_0.XTcl_Alloc(tls, libc.Uint64FromInt32(numTags)*uint64(8)) } else { nameArrPtr = bp } /* * We use tag names as keys in the hash table. We do this instead of using * the actual tagPtr objects because we want one "sel" tag binding for all * peer widgets, despite the fact that each has its own tagPtr object. */ i = 0 for { if !(i < numTags) { break } tagPtr = *(*uintptr)(unsafe.Pointer(tagArrayPtr + uintptr(i)*8)) if tagPtr != libc.UintptrFromInt32(0) { *(*uintptr)(unsafe.Pointer(nameArrPtr + uintptr(i)*8)) = (*TTkTextTag)(unsafe.Pointer(tagPtr)).Fname } else { /* * Tag has been deleted elsewhere, and therefore nulled out in * this array. Tk_BindEvent is clever enough to cope with NULLs * being thrown at it. */ *(*uintptr)(unsafe.Pointer(nameArrPtr + uintptr(i)*8)) = libc.UintptrFromInt32(0) } goto _1 _1: ; i++ } XTk_BindEvent(tls, (*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).FbindingTable, eventPtr, (*TTkText)(unsafe.Pointer(textPtr)).Ftkwin, int64(numTags), nameArrPtr) if numTags > int32(NUM_BIND_TAGS) { libtcl9_0.XTcl_Free(tls, nameArrPtr) } } var _textGeomType = TTk_GeomMgr{ Fname: __ccgo_ts + 17996, } func init() { p := unsafe.Pointer(&_textGeomType) *(*uintptr)(unsafe.Add(p, 8)) = __ccgo_fp(_EmbWinRequestProc) *(*uintptr)(unsafe.Add(p, 16)) = __ccgo_fp(_EmbWinLostContentProc) } func init() { p := unsafe.Pointer(&XtkTextEmbWindowType) *(*uintptr)(unsafe.Add(p, 24)) = __ccgo_fp(_EmbWinDeleteProc) *(*uintptr)(unsafe.Add(p, 32)) = __ccgo_fp(_EmbWinCleanupProc) *(*uintptr)(unsafe.Add(p, 48)) = __ccgo_fp(_EmbWinLayoutProc) *(*uintptr)(unsafe.Add(p, 56)) = __ccgo_fp(_EmbWinCheckProc) } /* * Definitions for alignment values: */ var _alignStrings1 = [5]uintptr{ 0: __ccgo_ts + 47514, 1: __ccgo_ts + 15099, 2: __ccgo_ts + 10959, 3: __ccgo_ts + 15106, 4: libc.UintptrFromInt32(0), } /* * Information used for parsing window configuration options: */ var _optionSpecs10 = [7]TTk_OptionSpec{ 0: { Ftype1: int32(TK_OPTION_STRING_TABLE), FoptionName: __ccgo_ts + 47523, FdefValue: __ccgo_ts + 10959, FobjOffset: int64(-libc.Int32FromInt32(1)), FinternalOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 48)), FclientData: uintptr(unsafe.Pointer(&_alignStrings1)), }, 1: { Ftype1: int32(TK_OPTION_STRING), FoptionName: __ccgo_ts + 48866, FobjOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 24)), FinternalOffset: int64(-libc.Int32FromInt32(1)), Fflags: int32(TCL_NULL_OK), }, 2: { Ftype1: int32(TK_OPTION_PIXELS), FoptionName: __ccgo_ts + 12320, FdefValue: __ccgo_ts + 10533, FobjOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 32)), FinternalOffset: int64(-libc.Int32FromInt32(1)), }, 3: { Ftype1: int32(TK_OPTION_PIXELS), FoptionName: __ccgo_ts + 12326, FdefValue: __ccgo_ts + 10533, FobjOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 40)), FinternalOffset: int64(-libc.Int32FromInt32(1)), }, 4: { FoptionName: __ccgo_ts + 25403, FdefValue: __ccgo_ts + 10533, FobjOffset: int64(-libc.Int32FromInt32(1)), FinternalOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 52)), }, 5: { Ftype1: int32(TK_OPTION_WINDOW), FoptionName: __ccgo_ts + 2994, FobjOffset: int64(-libc.Int32FromInt32(1)), FinternalOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 8)), Fflags: int32(TCL_NULL_OK), }, 6: { Ftype1: int32(TK_OPTION_END), }, } /* *-------------------------------------------------------------- * * TkTextWindowCmd -- * * This function implements the "window" widget command for text widgets. * See the user documentation for details on what it does. * * Results: * A standard Tcl result or error. * * Side effects: * See the user documentation. * *-------------------------------------------------------------- */ func XTkTextWindowCmd(tls *libc.TLS, textPtr uintptr, interp uintptr, objc TTcl_Size, objv uintptr) (r int32) { bp := tls.Alloc(208) defer tls.Free(208) /* Argument objects. Someone else has already * parsed this command enough to know that * objv[1] is "window". */ var client, client1, client2, ewPtr, hPtr, objPtr, objPtr1, resultObj, v1, v2, v4 uintptr var lineIndex, res int32 var _ /* index at bp+40 */ TTkTextIndex var _ /* index at bp+72 */ TTkTextIndex var _ /* index at bp+8 */ TTkTextIndex var _ /* index2 at bp+104 */ TTkTextIndex var _ /* optionIndex at bp+0 */ int32 var _ /* search at bp+136 */ TTcl_HashSearch _, _, _, _, _, _, _, _, _, _, _, _, _ = client, client1, client2, ewPtr, hPtr, lineIndex, objPtr, objPtr1, res, resultObj, v1, v2, v4 if objc < int64(3) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(2), objv, __ccgo_ts+4953) return int32(TCL_ERROR) } if libtcl9_0.XTcl_GetIndexFromObjStruct(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), uintptr(unsafe.Pointer(&_windOptionStrings)), libc.Int64FromUint64(libc.Uint64FromInt64(8)), __ccgo_ts+4821, libc.Int32FromInt32(0)|libc.Int32FromUint64(libc.Uint64FromInt64(4)<body.ew.tkwin == NULL means the embedded window is already * destroyed. The ewPtr segment is no longer linked, TkTextSegToOffset * cannot find it within the line pointed by ewPtr->body.ew.linePtr. */ if (*(*TTkTextEmbWindow)(unsafe.Pointer(&(*TTkTextSegment)(unsafe.Pointer(ewPtr)).Fbody))).Ftkwin != 0 { v1 = XTkTextSegToOffset(tls, ewPtr, (*(*TTkTextEmbWindow)(unsafe.Pointer(&(*TTkTextSegment)(unsafe.Pointer(ewPtr)).Fbody))).FlinePtr) } else { v1 = 0 } (*(*TTkTextIndex)(unsafe.Pointer(bp))).FbyteIndex = v1 XTkTextChanged(tls, (*(*TTkTextEmbWindow)(unsafe.Pointer(&(*TTkTextSegment)(unsafe.Pointer(ewPtr)).Fbody))).FsharedTextPtr, libc.UintptrFromInt32(0), bp, bp) XTkTextInvalidateLineMetrics(tls, (*(*TTkTextEmbWindow)(unsafe.Pointer(&(*TTkTextSegment)(unsafe.Pointer(ewPtr)).Fbody))).FsharedTextPtr, libc.UintptrFromInt32(0), (*(*TTkTextIndex)(unsafe.Pointer(bp))).FlinePtr, 0, int32(TK_TEXT_INVALIDATE_ONLY)) } /* *-------------------------------------------------------------- * * EmbWinLostContentProc -- * * This function is invoked by the Tk geometry manager when a content * window managed by a text widget is claimed away by another geometry * manager. * * Results: * None. * * Side effects: * The window is disassociated from the window segment, and the portion * of the text is redisplayed. * *-------------------------------------------------------------- */ func _EmbWinLostContentProc(tls *libc.TLS, clientData uintptr, tkwin TTk_Window) { bp := tls.Alloc(32) defer tls.Free(32) /* Window that was claimed away by another * geometry manager. */ var client, ewPtr, hPtr, loop uintptr var _ /* index at bp+0 */ TTkTextIndex _, _, _, _ = client, ewPtr, hPtr, loop client = clientData ewPtr = (*TTkTextEmbWindowClient)(unsafe.Pointer(client)).Fparent XTk_DeleteEventHandler(tls, (*TTkTextEmbWindowClient)(unsafe.Pointer(client)).Ftkwin, libc.Uint64FromInt64(libc.Int64FromInt64(1)< maxX-(*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).Fx && !(noCharsYet != 0) && (*TTkText)(unsafe.Pointer(textPtr)).FwrapMode != int32(TEXT_WRAPMODE_NONE) { return 0 } /* * Fill in the chunk structure. */ (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FdisplayProc = __ccgo_fp(XTkTextEmbWinDisplayProc) (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FundisplayProc = __ccgo_fp(_EmbWinUndisplayProc) (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FmeasureProc = libc.UintptrFromInt32(0) (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FbboxProc = __ccgo_fp(_EmbWinBboxProc) (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FnumBytes = int64(1) if (*(*TTkTextEmbWindow)(unsafe.Pointer(&(*TTkTextSegment)(unsafe.Pointer(ewPtr)).Fbody))).Falign == int32(TK_ALIGN_BASELINE) { (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FminAscent = height - *(*int32)(unsafe.Pointer(bp + 4)) (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FminDescent = *(*int32)(unsafe.Pointer(bp + 4)) (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FminHeight = 0 } else { (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FminAscent = 0 (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FminDescent = 0 (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FminHeight = height } (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).Fwidth = width (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FbreakIndex = int64(-int32(1)) (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FbreakIndex = int64(1) (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FclientData = ewPtr if client != libc.UintptrFromInt32(0) { *(*int32)(unsafe.Pointer(client + 16)) += int32(1) } return int32(1) } /* *-------------------------------------------------------------- * * EmbWinCheckProc -- * * This function is invoked by the B-tree code to perform consistency * checks on embedded windows. * * Results: * None. * * Side effects: * The function panics if it detects anything wrong with the embedded * window. * *-------------------------------------------------------------- */ func _EmbWinCheckProc(tls *libc.TLS, ewPtr uintptr, dummy1055 uintptr) { bp := tls.Alloc(16) defer tls.Free(16) /* Line containing segment. */ if (*TTkTextSegment)(unsafe.Pointer(ewPtr)).FnextPtr == libc.UintptrFromInt32(0) { libtcl9_0.XTcl_Panic(tls, __ccgo_ts+49006, 0) } if (*TTkTextSegment)(unsafe.Pointer(ewPtr)).Fsize != int64(1) { libtcl9_0.XTcl_Panic(tls, __ccgo_ts+49063, libc.VaList(bp+8, (*TTkTextSegment)(unsafe.Pointer(ewPtr)).Fsize)) } } /* *-------------------------------------------------------------- * * TkTextEmbWinDisplayProc -- * * This function is invoked by the text displaying code when it is time * to actually draw an embedded window chunk on the screen. * * Results: * None. * * Side effects: * The embedded window gets moved to the correct location and mapped onto * the screen. * *-------------------------------------------------------------- */ func XTkTextEmbWinDisplayProc(tls *libc.TLS, textPtr uintptr, chunkPtr uintptr, x int32, dummy1090 int32, lineHeight int32, baseline int32, dummy1095 uintptr, dummy1096 TDrawable, screenY int32) { bp := tls.Alloc(16) defer tls.Free(16) /* Y-coordinate in text window that * corresponds to y. */ var client, ewPtr uintptr var tkwin TTk_Window var windowX int32 var _ /* height at bp+12 */ int32 var _ /* lineX at bp+0 */ int32 var _ /* width at bp+8 */ int32 var _ /* windowY at bp+4 */ int32 _, _, _, _ = client, ewPtr, tkwin, windowX ewPtr = (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FclientData client = _EmbWinGetClient(tls, textPtr, ewPtr) if client == libc.UintptrFromInt32(0) { return } tkwin = (*TTkTextEmbWindowClient)(unsafe.Pointer(client)).Ftkwin if tkwin == libc.UintptrFromInt32(0) { return } if x+(*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).Fwidth <= 0 { /* * The window is off-screen; just unmap it. */ if (*TTkText)(unsafe.Pointer(textPtr)).Ftkwin != (*TTk_FakeWin)(unsafe.Pointer(tkwin)).FparentPtr { XTk_UnmaintainGeometry(tls, tkwin, (*TTkText)(unsafe.Pointer(textPtr)).Ftkwin) } else { XTk_UnmapWindow(tls, tkwin) } return } /* * Compute the window's location and size in the text widget, taking into * account the align and stretch values for the window. */ _EmbWinBboxProc(tls, textPtr, chunkPtr, 0, screenY, lineHeight, baseline, bp, bp+4, bp+8, bp+12) windowX = *(*int32)(unsafe.Pointer(bp)) - (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).Fx + x /* * Mark the window as displayed so that it won't get unmapped. * This needs to be done before the next instruction block because * Tk_MaintainGeometry/Tk_MapWindow will run event handlers, in * particular for the event, and if the bound script deletes * the embedded window its clients will get freed. */ (*TTkTextEmbWindowClient)(unsafe.Pointer(client)).Fdisplayed = int32(1) if (*TTkText)(unsafe.Pointer(textPtr)).Ftkwin == (*TTk_FakeWin)(unsafe.Pointer(tkwin)).FparentPtr { if windowX != (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fchanges.Fx || *(*int32)(unsafe.Pointer(bp + 4)) != (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fchanges.Fy || (*TTk_FakeWin)(unsafe.Pointer(tkwin)).FreqWidth != (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fchanges.Fwidth || *(*int32)(unsafe.Pointer(bp + 12)) != (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fchanges.Fheight { XTk_MoveResizeWindow(tls, tkwin, windowX, *(*int32)(unsafe.Pointer(bp + 4)), *(*int32)(unsafe.Pointer(bp + 8)), *(*int32)(unsafe.Pointer(bp + 12))) } XTk_MapWindow(tls, tkwin) } else { XTk_MaintainGeometry(tls, tkwin, (*TTkText)(unsafe.Pointer(textPtr)).Ftkwin, windowX, *(*int32)(unsafe.Pointer(bp + 4)), *(*int32)(unsafe.Pointer(bp + 8)), *(*int32)(unsafe.Pointer(bp + 12))) } } /* *-------------------------------------------------------------- * * EmbWinUndisplayProc -- * * This function is called when the chunk for an embedded window is no * longer going to be displayed. It arranges for the window associated * with the chunk to be unmapped. * * Results: * None. * * Side effects: * The window is scheduled for unmapping. * *-------------------------------------------------------------- */ func _EmbWinUndisplayProc(tls *libc.TLS, textPtr uintptr, chunkPtr uintptr) { /* Chunk that is about to be freed. */ var client, ewPtr uintptr _, _ = client, ewPtr ewPtr = (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FclientData client = _EmbWinGetClient(tls, textPtr, ewPtr) if client == libc.UintptrFromInt32(0) { return } (*TTkTextEmbWindowClient)(unsafe.Pointer(client)).FchunkCount-- if (*TTkTextEmbWindowClient)(unsafe.Pointer(client)).FchunkCount == 0 { /* * Don't unmap the window immediately, since there's a good chance * that it will immediately be redisplayed, perhaps even in the same * place. Instead, schedule the window to be unmapped later; the call * to EmbWinDelayedUnmap will be cancelled in the likely event that * the unmap becomes unnecessary. */ (*TTkTextEmbWindowClient)(unsafe.Pointer(client)).Fdisplayed = 0 libtcl9_0.XTcl_DoWhenIdle(tls, __ccgo_fp(_EmbWinDelayedUnmap), client) } } /* *-------------------------------------------------------------- * * EmbWinBboxProc -- * * This function is called to compute the bounding box of the area * occupied by an embedded window. * * Results: * There is no return value. *xPtr and *yPtr are filled in with the * coordinates of the upper left corner of the window, and *widthPtr and * *heightPtr are filled in with the dimensions of the window in pixels. * Note: not all of the returned bbox is necessarily visible on the * screen (the rightmost part might be off-screen to the right, and the * bottommost part might be off-screen to the bottom). * * Side effects: * None. * *-------------------------------------------------------------- */ func _EmbWinBboxProc(tls *libc.TLS, textPtr uintptr, chunkPtr uintptr, dummy1231 TTcl_Size, y int32, lineHeight int32, baseline int32, xPtr uintptr, yPtr uintptr, widthPtr uintptr, heightPtr uintptr) { bp := tls.Alloc(16) defer tls.Free(16) /* Gets filled in with height of window, in * pixels. */ var client, ewPtr uintptr var tkwin TTk_Window var _ /* padX at bp+0 */ int32 var _ /* padY at bp+4 */ int32 _, _, _ = client, ewPtr, tkwin ewPtr = (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).FclientData client = _EmbWinGetClient(tls, textPtr, ewPtr) *(*int32)(unsafe.Pointer(bp)) = 0 *(*int32)(unsafe.Pointer(bp + 4)) = 0 if client == libc.UintptrFromInt32(0) { tkwin = libc.UintptrFromInt32(0) } else { tkwin = (*TTkTextEmbWindowClient)(unsafe.Pointer(client)).Ftkwin } if tkwin != libc.UintptrFromInt32(0) { *(*int32)(unsafe.Pointer(widthPtr)) = (*TTk_FakeWin)(unsafe.Pointer(tkwin)).FreqWidth *(*int32)(unsafe.Pointer(heightPtr)) = (*TTk_FakeWin)(unsafe.Pointer(tkwin)).FreqHeight } else { *(*int32)(unsafe.Pointer(widthPtr)) = 0 *(*int32)(unsafe.Pointer(heightPtr)) = 0 } if (*(*TTkTextEmbWindow)(unsafe.Pointer(&(*TTkTextSegment)(unsafe.Pointer(ewPtr)).Fbody))).FpadXObj != 0 { XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), (*TTkText)(unsafe.Pointer(textPtr)).Ftkwin, (*(*TTkTextEmbWindow)(unsafe.Pointer(&(*TTkTextSegment)(unsafe.Pointer(ewPtr)).Fbody))).FpadXObj, bp) } if (*(*TTkTextEmbWindow)(unsafe.Pointer(&(*TTkTextSegment)(unsafe.Pointer(ewPtr)).Fbody))).FpadYObj != 0 { XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), (*TTkText)(unsafe.Pointer(textPtr)).Ftkwin, (*(*TTkTextEmbWindow)(unsafe.Pointer(&(*TTkTextSegment)(unsafe.Pointer(ewPtr)).Fbody))).FpadYObj, bp+4) } *(*int32)(unsafe.Pointer(xPtr)) = (*TTkTextDispChunk)(unsafe.Pointer(chunkPtr)).Fx + *(*int32)(unsafe.Pointer(bp)) if (*(*TTkTextEmbWindow)(unsafe.Pointer(&(*TTkTextSegment)(unsafe.Pointer(ewPtr)).Fbody))).Fstretch != 0 { if (*(*TTkTextEmbWindow)(unsafe.Pointer(&(*TTkTextSegment)(unsafe.Pointer(ewPtr)).Fbody))).Falign == int32(TK_ALIGN_BASELINE) { *(*int32)(unsafe.Pointer(heightPtr)) = baseline - *(*int32)(unsafe.Pointer(bp + 4)) } else { *(*int32)(unsafe.Pointer(heightPtr)) = lineHeight - int32(2)**(*int32)(unsafe.Pointer(bp + 4)) } } switch (*(*TTkTextEmbWindow)(unsafe.Pointer(&(*TTkTextSegment)(unsafe.Pointer(ewPtr)).Fbody))).Falign { case int32(TK_ALIGN_BOTTOM): *(*int32)(unsafe.Pointer(yPtr)) = y + (lineHeight - *(*int32)(unsafe.Pointer(heightPtr)) - *(*int32)(unsafe.Pointer(bp + 4))) case int32(TK_ALIGN_CENTER): *(*int32)(unsafe.Pointer(yPtr)) = y + (lineHeight-*(*int32)(unsafe.Pointer(heightPtr)))/int32(2) case int32(TK_ALIGN_TOP): *(*int32)(unsafe.Pointer(yPtr)) = y + *(*int32)(unsafe.Pointer(bp + 4)) case int32(TK_ALIGN_BASELINE): *(*int32)(unsafe.Pointer(yPtr)) = y + (baseline - *(*int32)(unsafe.Pointer(heightPtr))) break } } /* *-------------------------------------------------------------- * * EmbWinDelayedUnmap -- * * This function is an idle handler that does the actual work of * unmapping an embedded window. See the comment in EmbWinUndisplayProc * for details. * * Results: * None. * * Side effects: * The window gets unmapped, unless its chunk reference count has become * non-zero again. * *-------------------------------------------------------------- */ func _EmbWinDelayedUnmap(tls *libc.TLS, clientData uintptr) { /* Token for the window to be unmapped. */ var client uintptr _ = client client = clientData if !((*TTkTextEmbWindowClient)(unsafe.Pointer(client)).Fdisplayed != 0) && (*TTkTextEmbWindowClient)(unsafe.Pointer(client)).Ftkwin != libc.UintptrFromInt32(0) { if (*TTkText1)(unsafe.Pointer((*TTkTextEmbWindowClient)(unsafe.Pointer(client)).FtextPtr)).Ftkwin != (*TTk_FakeWin)(unsafe.Pointer((*TTkTextEmbWindowClient)(unsafe.Pointer(client)).Ftkwin)).FparentPtr { XTk_UnmaintainGeometry(tls, (*TTkTextEmbWindowClient)(unsafe.Pointer(client)).Ftkwin, (*TTkText1)(unsafe.Pointer((*TTkTextEmbWindowClient)(unsafe.Pointer(client)).FtextPtr)).Ftkwin) } else { XTk_UnmapWindow(tls, (*TTkTextEmbWindowClient)(unsafe.Pointer(client)).Ftkwin) } } } /* *-------------------------------------------------------------- * * TkTextWindowIndex -- * * Given the name of an embedded window within a text widget, returns an * index corresponding to the window's position in the text. * * Results: * The return value is TCL_OK if there is an embedded window by the given * name in the text widget, TCL_ERROR otherwise. If the window exists, * *indexPtr is filled in with its index. * * Side effects: * None. * *-------------------------------------------------------------- */ func XTkTextWindowIndex(tls *libc.TLS, textPtr uintptr, name uintptr, indexPtr uintptr) (r int32) { /* Index information gets stored here. */ var ewPtr, hPtr uintptr _, _ = ewPtr, hPtr if textPtr == libc.UintptrFromInt32(0) { return int32(TCL_ERROR) } hPtr = (*(*func(*libc.TLS, uintptr, uintptr) uintptr)(unsafe.Pointer(&struct{ uintptr }{(*TTcl_HashTable)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr + 232)).FfindProc})))(tls, (*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr+232, name) if hPtr == libc.UintptrFromInt32(0) { return int32(TCL_ERROR) } ewPtr = (*TTcl_HashEntry)(unsafe.Pointer(hPtr)).FclientData (*TTkTextIndex)(unsafe.Pointer(indexPtr)).Ftree = (*TTkSharedText)(unsafe.Pointer((*TTkText)(unsafe.Pointer(textPtr)).FsharedTextPtr)).Ftree (*TTkTextIndex)(unsafe.Pointer(indexPtr)).FlinePtr = (*(*TTkTextEmbWindow)(unsafe.Pointer(&(*TTkTextSegment)(unsafe.Pointer(ewPtr)).Fbody))).FlinePtr (*TTkTextIndex)(unsafe.Pointer(indexPtr)).FbyteIndex = XTkTextSegToOffset(tls, ewPtr, (*TTkTextIndex)(unsafe.Pointer(indexPtr)).FlinePtr) /* * If indexPtr refers to somewhere outside the -startline/-endline * range limits of the widget, error out since the window indeed is not * reachable from this text widget (it may be reachable from a peer). */ if XTkTextIndexAdjustToStartEnd(tls, textPtr, indexPtr, int32(1)) == int32(TCL_ERROR) { return int32(TCL_ERROR) } return TCL_OK } /* *-------------------------------------------------------------- * * EmbWinGetClient -- * * Given a text widget and a segment which contains an embedded window, * find the text-widget specific information about the embedded window, * if any. * * This function performs a completely linear lookup for a matching data * structure. If we envisage using this code with dozens of peer widgets, * then performance could become an issue and a more sophisticated lookup * mechanism might be desirable. * * Results: * NULL if no widget-specific info exists, otherwise the structure is * returned. * * Side effects: * None. * *-------------------------------------------------------------- */ func _EmbWinGetClient(tls *libc.TLS, textPtr uintptr, ewPtr uintptr) (r uintptr) { /* Segment containing embedded window. */ var client uintptr _ = client client = (*(*TTkTextEmbWindow)(unsafe.Pointer(&(*TTkTextSegment)(unsafe.Pointer(ewPtr)).Fbody))).Fclients for client != libc.UintptrFromInt32(0) { if (*TTkTextEmbWindowClient)(unsafe.Pointer(client)).FtextPtr == textPtr { return client } client = (*TTkTextEmbWindowClient)(unsafe.Pointer(client)).Fnext } return libc.UintptrFromInt32(0) } const Tk_MacOSXGetNSViewForDrawable = 0 const XParseColor = 0 type TTkPlatStubs = struct { Fmagic int32 Fhooks uintptr } /* * Remove macro that might interfere with the definition below. */ func _doNothing(tls *libc.TLS) (r int32) { /* dummy implementation, no need to do anything */ return 0 } /* * Make sure that extensions which call XParseColor through the stub * table, call TkParseColor instead. [Bug 3486474] */ /* * WARNING: The contents of this file is automatically generated by the * tools/genStubs.tcl script. Any modifications to the function declarations * below should be made in the generic/tk.decls script. */ /* * The rest of this file shouldn't warn about deprecated functions; they're * there because we intend them to be so and know that this file is OK to * touch those fields. */ /* !BEGIN!: Do not edit below this line. */ var _tkIntStubs = TTkIntStubs{ Fmagic: libc.Int32FromUint32(0xFCA3BACB) + libc.Int32FromInt64(8), } func init() { p := unsafe.Pointer(&_tkIntStubs) *(*uintptr)(unsafe.Add(p, 16)) = __ccgo_fp(XTkAllocWindow) *(*uintptr)(unsafe.Add(p, 24)) = __ccgo_fp(XTkBezierPoints) *(*uintptr)(unsafe.Add(p, 32)) = __ccgo_fp(XTkBezierScreenPoints) *(*uintptr)(unsafe.Add(p, 48)) = __ccgo_fp(XTkBindEventProc) *(*uintptr)(unsafe.Add(p, 56)) = __ccgo_fp(XTkBindFree) *(*uintptr)(unsafe.Add(p, 64)) = __ccgo_fp(XTkBindInit) *(*uintptr)(unsafe.Add(p, 72)) = __ccgo_fp(XTkChangeEventWindow) *(*uintptr)(unsafe.Add(p, 80)) = __ccgo_fp(XTkClipInit) *(*uintptr)(unsafe.Add(p, 88)) = __ccgo_fp(XTkComputeAnchor) *(*uintptr)(unsafe.Add(p, 112)) = __ccgo_fp(XTkCreateCursorFromData) *(*uintptr)(unsafe.Add(p, 120)) = __ccgo_fp(XTkCreateFrame) *(*uintptr)(unsafe.Add(p, 128)) = __ccgo_fp(XTkCreateMainWindow) *(*uintptr)(unsafe.Add(p, 136)) = __ccgo_fp(XTkCurrentTime) *(*uintptr)(unsafe.Add(p, 144)) = __ccgo_fp(XTkDeleteAllImages) *(*uintptr)(unsafe.Add(p, 152)) = __ccgo_fp(XTkDoConfigureNotify) *(*uintptr)(unsafe.Add(p, 160)) = __ccgo_fp(XTkDrawInsetFocusHighlight) *(*uintptr)(unsafe.Add(p, 168)) = __ccgo_fp(XTkEventDeadWindow) *(*uintptr)(unsafe.Add(p, 176)) = __ccgo_fp(XTkFillPolygon) *(*uintptr)(unsafe.Add(p, 184)) = __ccgo_fp(XTkFindStateNum) *(*uintptr)(unsafe.Add(p, 192)) = __ccgo_fp(XTkFindStateString) *(*uintptr)(unsafe.Add(p, 200)) = __ccgo_fp(XTkFocusDeadWindow) *(*uintptr)(unsafe.Add(p, 208)) = __ccgo_fp(XTkFocusFilterEvent) *(*uintptr)(unsafe.Add(p, 216)) = __ccgo_fp(XTkFocusKeyEvent) *(*uintptr)(unsafe.Add(p, 224)) = __ccgo_fp(XTkFontPkgInit) *(*uintptr)(unsafe.Add(p, 232)) = __ccgo_fp(XTkFontPkgFree) *(*uintptr)(unsafe.Add(p, 240)) = __ccgo_fp(XTkFreeBindingTags) *(*uintptr)(unsafe.Add(p, 248)) = __ccgo_fp(XTkpFreeCursor) *(*uintptr)(unsafe.Add(p, 256)) = __ccgo_fp(XTkGetBitmapData) *(*uintptr)(unsafe.Add(p, 264)) = __ccgo_fp(XTkGetButtPoints) *(*uintptr)(unsafe.Add(p, 272)) = __ccgo_fp(XTkGetCursorByName) *(*uintptr)(unsafe.Add(p, 280)) = __ccgo_fp(XTkGetDefaultScreenName) *(*uintptr)(unsafe.Add(p, 288)) = __ccgo_fp(XTkGetDisplay) *(*uintptr)(unsafe.Add(p, 296)) = __ccgo_fp(XTkGetDisplayOf) *(*uintptr)(unsafe.Add(p, 304)) = __ccgo_fp(XTkGetFocusWin) *(*uintptr)(unsafe.Add(p, 312)) = __ccgo_fp(XTkGetInterpNames) *(*uintptr)(unsafe.Add(p, 320)) = __ccgo_fp(XTkGetMiterPoints) *(*uintptr)(unsafe.Add(p, 328)) = __ccgo_fp(XTkGetPointerCoords) *(*uintptr)(unsafe.Add(p, 336)) = __ccgo_fp(XTkGetServerInfo) *(*uintptr)(unsafe.Add(p, 344)) = __ccgo_fp(XTkGrabDeadWindow) *(*uintptr)(unsafe.Add(p, 352)) = __ccgo_fp(XTkGrabState) *(*uintptr)(unsafe.Add(p, 360)) = __ccgo_fp(XTkIncludePoint) *(*uintptr)(unsafe.Add(p, 368)) = __ccgo_fp(XTkInOutEvents) *(*uintptr)(unsafe.Add(p, 376)) = __ccgo_fp(XTkInstallFrameMenu) *(*uintptr)(unsafe.Add(p, 384)) = __ccgo_fp(XTkKeysymToString) *(*uintptr)(unsafe.Add(p, 392)) = __ccgo_fp(XTkLineToArea) *(*uintptr)(unsafe.Add(p, 400)) = __ccgo_fp(XTkLineToPoint) *(*uintptr)(unsafe.Add(p, 408)) = __ccgo_fp(XTkMakeBezierCurve) *(*uintptr)(unsafe.Add(p, 416)) = __ccgo_fp(XTkMakeBezierPostscript) *(*uintptr)(unsafe.Add(p, 424)) = __ccgo_fp(XTkOptionClassChanged) *(*uintptr)(unsafe.Add(p, 432)) = __ccgo_fp(XTkOptionDeadWindow) *(*uintptr)(unsafe.Add(p, 440)) = __ccgo_fp(XTkOvalToArea) *(*uintptr)(unsafe.Add(p, 448)) = __ccgo_fp(XTkOvalToPoint) *(*uintptr)(unsafe.Add(p, 456)) = __ccgo_fp(XTkpChangeFocus) *(*uintptr)(unsafe.Add(p, 464)) = __ccgo_fp(XTkpCloseDisplay) *(*uintptr)(unsafe.Add(p, 472)) = __ccgo_fp(XTkpClaimFocus) *(*uintptr)(unsafe.Add(p, 480)) = __ccgo_fp(XTkpDisplayWarning) *(*uintptr)(unsafe.Add(p, 488)) = __ccgo_fp(XTkpGetAppName) *(*uintptr)(unsafe.Add(p, 504)) = __ccgo_fp(XTkpGetWrapperWindow) *(*uintptr)(unsafe.Add(p, 512)) = __ccgo_fp(XTkpInit) *(*uintptr)(unsafe.Add(p, 520)) = __ccgo_fp(XTkpInitializeMenuBindings) *(*uintptr)(unsafe.Add(p, 536)) = __ccgo_fp(XTkpMakeMenuWindow) *(*uintptr)(unsafe.Add(p, 552)) = __ccgo_fp(XTkpMenuNotifyToplevelCreate) *(*uintptr)(unsafe.Add(p, 560)) = __ccgo_fp(XTkpOpenDisplay) *(*uintptr)(unsafe.Add(p, 568)) = __ccgo_fp(XTkPointerEvent) *(*uintptr)(unsafe.Add(p, 576)) = __ccgo_fp(XTkPolygonToArea) *(*uintptr)(unsafe.Add(p, 584)) = __ccgo_fp(XTkPolygonToPoint) *(*uintptr)(unsafe.Add(p, 592)) = __ccgo_fp(XTkPositionInTree) *(*uintptr)(unsafe.Add(p, 600)) = __ccgo_fp(XTkpRedirectKeyEvent) *(*uintptr)(unsafe.Add(p, 632)) = __ccgo_fp(XTkQueueEventForAllChildren) *(*uintptr)(unsafe.Add(p, 640)) = __ccgo_fp(XTkReadBitmapFile) *(*uintptr)(unsafe.Add(p, 648)) = __ccgo_fp(XTkScrollWindow) *(*uintptr)(unsafe.Add(p, 656)) = __ccgo_fp(XTkSelDeadWindow) *(*uintptr)(unsafe.Add(p, 664)) = __ccgo_fp(XTkSelEventProc) *(*uintptr)(unsafe.Add(p, 672)) = __ccgo_fp(XTkSelInit) *(*uintptr)(unsafe.Add(p, 680)) = __ccgo_fp(XTkSelPropProc) *(*uintptr)(unsafe.Add(p, 704)) = __ccgo_fp(XTkStringToKeysym) *(*uintptr)(unsafe.Add(p, 712)) = __ccgo_fp(XTkThickPolyLineToArea) *(*uintptr)(unsafe.Add(p, 720)) = __ccgo_fp(XTkWmAddToColormapWindows) *(*uintptr)(unsafe.Add(p, 728)) = __ccgo_fp(XTkWmDeadWindow) *(*uintptr)(unsafe.Add(p, 736)) = __ccgo_fp(XTkWmFocusToplevel) *(*uintptr)(unsafe.Add(p, 744)) = __ccgo_fp(XTkWmMapWindow) *(*uintptr)(unsafe.Add(p, 752)) = __ccgo_fp(XTkWmNewWindow) *(*uintptr)(unsafe.Add(p, 760)) = __ccgo_fp(XTkWmProtocolEventProc) *(*uintptr)(unsafe.Add(p, 768)) = __ccgo_fp(XTkWmRemoveFromColormapWindows) *(*uintptr)(unsafe.Add(p, 776)) = __ccgo_fp(XTkWmRestackToplevel) *(*uintptr)(unsafe.Add(p, 784)) = __ccgo_fp(XTkWmSetClass) *(*uintptr)(unsafe.Add(p, 792)) = __ccgo_fp(XTkWmUnmapWindow) *(*uintptr)(unsafe.Add(p, 800)) = __ccgo_fp(XTkDebugBitmap) *(*uintptr)(unsafe.Add(p, 808)) = __ccgo_fp(XTkDebugBorder) *(*uintptr)(unsafe.Add(p, 816)) = __ccgo_fp(XTkDebugCursor) *(*uintptr)(unsafe.Add(p, 824)) = __ccgo_fp(XTkDebugColor) *(*uintptr)(unsafe.Add(p, 832)) = __ccgo_fp(XTkDebugConfig) *(*uintptr)(unsafe.Add(p, 840)) = __ccgo_fp(XTkDebugFont) *(*uintptr)(unsafe.Add(p, 848)) = __ccgo_fp(XTkFindStateNumObj) *(*uintptr)(unsafe.Add(p, 856)) = __ccgo_fp(XTkGetBitmapPredefTable) *(*uintptr)(unsafe.Add(p, 864)) = __ccgo_fp(XTkGetDisplayList) *(*uintptr)(unsafe.Add(p, 872)) = __ccgo_fp(XTkGetMainInfoList) *(*uintptr)(unsafe.Add(p, 880)) = __ccgo_fp(XTkGetWindowFromObj) *(*uintptr)(unsafe.Add(p, 888)) = __ccgo_fp(XTkpGetString) *(*uintptr)(unsafe.Add(p, 896)) = __ccgo_fp(XTkpGetSubFonts) *(*uintptr)(unsafe.Add(p, 912)) = __ccgo_fp(XTkpMenuThreadInit) *(*uintptr)(unsafe.Add(p, 920)) = __ccgo_fp(libx11.XXClipBox) *(*uintptr)(unsafe.Add(p, 928)) = __ccgo_fp(libx11.XXCreateRegion) *(*uintptr)(unsafe.Add(p, 936)) = __ccgo_fp(libx11.XXDestroyRegion) *(*uintptr)(unsafe.Add(p, 944)) = __ccgo_fp(libx11.XXIntersectRegion) *(*uintptr)(unsafe.Add(p, 952)) = __ccgo_fp(libx11.XXRectInRegion) *(*uintptr)(unsafe.Add(p, 960)) = __ccgo_fp(libx11.XXSetRegion) *(*uintptr)(unsafe.Add(p, 968)) = __ccgo_fp(libx11.XXUnionRectWithRegion) *(*uintptr)(unsafe.Add(p, 984)) = __ccgo_fp(_doNothing) *(*uintptr)(unsafe.Add(p, 992)) = __ccgo_fp(_doNothing) *(*uintptr)(unsafe.Add(p, 1008)) = __ccgo_fp(_doNothing) *(*uintptr)(unsafe.Add(p, 1104)) = __ccgo_fp(XTkSetFocusWin) *(*uintptr)(unsafe.Add(p, 1112)) = __ccgo_fp(XTkpSetKeycodeAndState) *(*uintptr)(unsafe.Add(p, 1120)) = __ccgo_fp(XTkpGetKeySym) *(*uintptr)(unsafe.Add(p, 1128)) = __ccgo_fp(XTkpInitKeymapInfo) *(*uintptr)(unsafe.Add(p, 1136)) = __ccgo_fp(XTkPhotoGetValidRegion) *(*uintptr)(unsafe.Add(p, 1144)) = __ccgo_fp(XTkWmStackorderToplevel) *(*uintptr)(unsafe.Add(p, 1152)) = __ccgo_fp(XTkFocusFree) *(*uintptr)(unsafe.Add(p, 1160)) = __ccgo_fp(XTkClipCleanup) *(*uintptr)(unsafe.Add(p, 1168)) = __ccgo_fp(XTkGCCleanup) *(*uintptr)(unsafe.Add(p, 1176)) = __ccgo_fp(libx11.XXSubtractRegion) *(*uintptr)(unsafe.Add(p, 1184)) = __ccgo_fp(XTkStylePkgInit) *(*uintptr)(unsafe.Add(p, 1192)) = __ccgo_fp(XTkStylePkgFree) *(*uintptr)(unsafe.Add(p, 1200)) = __ccgo_fp(XTkToplevelWindowForCommand) *(*uintptr)(unsafe.Add(p, 1208)) = __ccgo_fp(XTkGetOptionSpec) *(*uintptr)(unsafe.Add(p, 1216)) = __ccgo_fp(XTkMakeRawCurve) *(*uintptr)(unsafe.Add(p, 1224)) = __ccgo_fp(XTkMakeRawCurvePostscript) *(*uintptr)(unsafe.Add(p, 1232)) = __ccgo_fp(XTkpDrawFrame) *(*uintptr)(unsafe.Add(p, 1240)) = __ccgo_fp(XTkCreateThreadExitHandler) *(*uintptr)(unsafe.Add(p, 1248)) = __ccgo_fp(XTkDeleteThreadExitHandler) *(*uintptr)(unsafe.Add(p, 1264)) = __ccgo_fp(XTkpTestembedCmd) *(*uintptr)(unsafe.Add(p, 1272)) = __ccgo_fp(XTkpTesttextCmd) *(*uintptr)(unsafe.Add(p, 1280)) = __ccgo_fp(XTkSelGetSelection) *(*uintptr)(unsafe.Add(p, 1288)) = __ccgo_fp(XTkTextGetIndex) *(*uintptr)(unsafe.Add(p, 1296)) = __ccgo_fp(XTkTextIndexBackBytes) *(*uintptr)(unsafe.Add(p, 1304)) = __ccgo_fp(XTkTextIndexForwBytes) *(*uintptr)(unsafe.Add(p, 1312)) = __ccgo_fp(XTkTextMakeByteIndex) *(*uintptr)(unsafe.Add(p, 1320)) = __ccgo_fp(XTkTextPrintIndex) *(*uintptr)(unsafe.Add(p, 1328)) = __ccgo_fp(XTkTextSetMark) *(*uintptr)(unsafe.Add(p, 1336)) = __ccgo_fp(XTkTextXviewCmd) *(*uintptr)(unsafe.Add(p, 1344)) = __ccgo_fp(XTkTextChanged) *(*uintptr)(unsafe.Add(p, 1352)) = __ccgo_fp(XTkBTreeNumLines) *(*uintptr)(unsafe.Add(p, 1360)) = __ccgo_fp(XTkTextInsertDisplayProc) *(*uintptr)(unsafe.Add(p, 1368)) = __ccgo_fp(XTkStateParseProc) *(*uintptr)(unsafe.Add(p, 1376)) = __ccgo_fp(XTkStatePrintProc) *(*uintptr)(unsafe.Add(p, 1384)) = __ccgo_fp(XTkCanvasDashParseProc) *(*uintptr)(unsafe.Add(p, 1392)) = __ccgo_fp(XTkCanvasDashPrintProc) *(*uintptr)(unsafe.Add(p, 1400)) = __ccgo_fp(XTkOffsetParseProc) *(*uintptr)(unsafe.Add(p, 1408)) = __ccgo_fp(XTkOffsetPrintProc) *(*uintptr)(unsafe.Add(p, 1416)) = __ccgo_fp(XTkPixelParseProc) *(*uintptr)(unsafe.Add(p, 1424)) = __ccgo_fp(XTkPixelPrintProc) *(*uintptr)(unsafe.Add(p, 1432)) = __ccgo_fp(XTkOrientParseProc) *(*uintptr)(unsafe.Add(p, 1440)) = __ccgo_fp(XTkOrientPrintProc) *(*uintptr)(unsafe.Add(p, 1448)) = __ccgo_fp(XTkSmoothParseProc) *(*uintptr)(unsafe.Add(p, 1456)) = __ccgo_fp(XTkSmoothPrintProc) *(*uintptr)(unsafe.Add(p, 1464)) = __ccgo_fp(XTkDrawAngledTextLayout) *(*uintptr)(unsafe.Add(p, 1472)) = __ccgo_fp(XTkUnderlineAngledTextLayout) *(*uintptr)(unsafe.Add(p, 1480)) = __ccgo_fp(XTkIntersectAngledTextLayout) *(*uintptr)(unsafe.Add(p, 1488)) = __ccgo_fp(XTkDrawAngledChars) *(*uintptr)(unsafe.Add(p, 1496)) = __ccgo_fp(_doNothing) *(*uintptr)(unsafe.Add(p, 1504)) = __ccgo_fp(_doNothing) *(*uintptr)(unsafe.Add(p, 1512)) = __ccgo_fp(XTkDebugPhotoStringMatchDef) } var _tkIntPlatStubs = TTkIntPlatStubs{ Fmagic: libc.Int32FromUint32(0xFCA3BACB) + libc.Int32FromInt64(8), } func init() { p := unsafe.Pointer(&_tkIntPlatStubs) *(*uintptr)(unsafe.Add(p, 16)) = __ccgo_fp(XTkCreateXEventSource) *(*uintptr)(unsafe.Add(p, 32)) = __ccgo_fp(XTkGenerateActivateEvents) *(*uintptr)(unsafe.Add(p, 64)) = __ccgo_fp(XTkpScanWindowId) *(*uintptr)(unsafe.Add(p, 88)) = __ccgo_fp(XTkpWmSetState) *(*uintptr)(unsafe.Add(p, 320)) = __ccgo_fp(XTkpCmapStressed) *(*uintptr)(unsafe.Add(p, 328)) = __ccgo_fp(XTkpSync) *(*uintptr)(unsafe.Add(p, 336)) = __ccgo_fp(XTkUnixContainerId) *(*uintptr)(unsafe.Add(p, 344)) = __ccgo_fp(XTkUnixDoOneXEvent) *(*uintptr)(unsafe.Add(p, 352)) = __ccgo_fp(XTkUnixSetMenubar) *(*uintptr)(unsafe.Add(p, 360)) = __ccgo_fp(XTkWmCleanup) *(*uintptr)(unsafe.Add(p, 368)) = __ccgo_fp(XTkSendCleanup) *(*uintptr)(unsafe.Add(p, 376)) = __ccgo_fp(XTkpTestsendCmd) } var _tkIntXlibStubs = TTkIntXlibStubs{ Fmagic: libc.Int32FromUint32(0xFCA3BACB) + libc.Int32FromInt64(8), } var _tkPlatStubs = TTkPlatStubs{ Fmagic: libc.Int32FromUint32(0xFCA3BACB) + libc.Int32FromInt64(8), } var _tkStubHooks = TTkStubHooks{ FtkPlatStubs: uintptr(unsafe.Pointer(&_tkPlatStubs)), FtkIntStubs: uintptr(unsafe.Pointer(&_tkIntStubs)), FtkIntPlatStubs: uintptr(unsafe.Pointer(&_tkIntPlatStubs)), FtkIntXlibStubs: uintptr(unsafe.Pointer(&_tkIntXlibStubs)), } func init() { p := unsafe.Pointer(&XtkStubs) *(*uintptr)(unsafe.Add(p, 16)) = __ccgo_fp(XTk_MainLoop) *(*uintptr)(unsafe.Add(p, 24)) = __ccgo_fp(XTk_3DBorderColor) *(*uintptr)(unsafe.Add(p, 32)) = __ccgo_fp(XTk_3DBorderGC) *(*uintptr)(unsafe.Add(p, 40)) = __ccgo_fp(XTk_3DHorizontalBevel) *(*uintptr)(unsafe.Add(p, 48)) = __ccgo_fp(XTk_3DVerticalBevel) *(*uintptr)(unsafe.Add(p, 56)) = __ccgo_fp(XTk_AddOption) *(*uintptr)(unsafe.Add(p, 64)) = __ccgo_fp(XTk_BindEvent) *(*uintptr)(unsafe.Add(p, 72)) = __ccgo_fp(XTk_CanvasDrawableCoords) *(*uintptr)(unsafe.Add(p, 80)) = __ccgo_fp(XTk_CanvasEventuallyRedraw) *(*uintptr)(unsafe.Add(p, 88)) = __ccgo_fp(XTk_CanvasGetCoord) *(*uintptr)(unsafe.Add(p, 96)) = __ccgo_fp(XTk_CanvasGetTextInfo) *(*uintptr)(unsafe.Add(p, 104)) = __ccgo_fp(XTk_CanvasPsBitmap) *(*uintptr)(unsafe.Add(p, 112)) = __ccgo_fp(XTk_CanvasPsColor) *(*uintptr)(unsafe.Add(p, 120)) = __ccgo_fp(XTk_CanvasPsFont) *(*uintptr)(unsafe.Add(p, 128)) = __ccgo_fp(XTk_CanvasPsPath) *(*uintptr)(unsafe.Add(p, 136)) = __ccgo_fp(XTk_CanvasPsStipple) *(*uintptr)(unsafe.Add(p, 144)) = __ccgo_fp(XTk_CanvasPsY) *(*uintptr)(unsafe.Add(p, 152)) = __ccgo_fp(XTk_CanvasSetStippleOrigin) *(*uintptr)(unsafe.Add(p, 160)) = __ccgo_fp(XTk_CanvasTagsParseProc) *(*uintptr)(unsafe.Add(p, 168)) = __ccgo_fp(XTk_CanvasTagsPrintProc) *(*uintptr)(unsafe.Add(p, 176)) = __ccgo_fp(XTk_CanvasTkwin) *(*uintptr)(unsafe.Add(p, 184)) = __ccgo_fp(XTk_CanvasWindowCoords) *(*uintptr)(unsafe.Add(p, 192)) = __ccgo_fp(XTk_ChangeWindowAttributes) *(*uintptr)(unsafe.Add(p, 200)) = __ccgo_fp(XTk_CharBbox) *(*uintptr)(unsafe.Add(p, 208)) = __ccgo_fp(XTk_ClearSelection) *(*uintptr)(unsafe.Add(p, 216)) = __ccgo_fp(XTk_ClipboardAppend) *(*uintptr)(unsafe.Add(p, 224)) = __ccgo_fp(XTk_ClipboardClear) *(*uintptr)(unsafe.Add(p, 232)) = __ccgo_fp(XTk_ConfigureInfo) *(*uintptr)(unsafe.Add(p, 240)) = __ccgo_fp(XTk_ConfigureValue) *(*uintptr)(unsafe.Add(p, 248)) = __ccgo_fp(XTk_ConfigureWidget) *(*uintptr)(unsafe.Add(p, 256)) = __ccgo_fp(XTk_ConfigureWindow) *(*uintptr)(unsafe.Add(p, 264)) = __ccgo_fp(XTk_ComputeTextLayout) *(*uintptr)(unsafe.Add(p, 272)) = __ccgo_fp(XTk_CoordsToWindow) *(*uintptr)(unsafe.Add(p, 280)) = __ccgo_fp(XTk_CreateBinding) *(*uintptr)(unsafe.Add(p, 288)) = __ccgo_fp(XTk_CreateBindingTable) *(*uintptr)(unsafe.Add(p, 296)) = __ccgo_fp(XTk_CreateErrorHandler) *(*uintptr)(unsafe.Add(p, 304)) = __ccgo_fp(XTk_CreateEventHandler) *(*uintptr)(unsafe.Add(p, 312)) = __ccgo_fp(XTk_CreateGenericHandler) *(*uintptr)(unsafe.Add(p, 320)) = __ccgo_fp(XTk_CreateImageType) *(*uintptr)(unsafe.Add(p, 328)) = __ccgo_fp(XTk_CreateItemType) *(*uintptr)(unsafe.Add(p, 336)) = __ccgo_fp(XTk_CreatePhotoImageFormat) *(*uintptr)(unsafe.Add(p, 344)) = __ccgo_fp(XTk_CreateSelHandler) *(*uintptr)(unsafe.Add(p, 352)) = __ccgo_fp(XTk_CreateWindow) *(*uintptr)(unsafe.Add(p, 360)) = __ccgo_fp(XTk_CreateWindowFromPath) *(*uintptr)(unsafe.Add(p, 368)) = __ccgo_fp(XTk_DefineBitmap) *(*uintptr)(unsafe.Add(p, 376)) = __ccgo_fp(XTk_DefineCursor) *(*uintptr)(unsafe.Add(p, 384)) = __ccgo_fp(XTk_DeleteAllBindings) *(*uintptr)(unsafe.Add(p, 392)) = __ccgo_fp(XTk_DeleteBinding) *(*uintptr)(unsafe.Add(p, 400)) = __ccgo_fp(XTk_DeleteBindingTable) *(*uintptr)(unsafe.Add(p, 408)) = __ccgo_fp(XTk_DeleteErrorHandler) *(*uintptr)(unsafe.Add(p, 416)) = __ccgo_fp(XTk_DeleteEventHandler) *(*uintptr)(unsafe.Add(p, 424)) = __ccgo_fp(XTk_DeleteGenericHandler) *(*uintptr)(unsafe.Add(p, 432)) = __ccgo_fp(XTk_DeleteImage) *(*uintptr)(unsafe.Add(p, 440)) = __ccgo_fp(XTk_DeleteSelHandler) *(*uintptr)(unsafe.Add(p, 448)) = __ccgo_fp(XTk_DestroyWindow) *(*uintptr)(unsafe.Add(p, 456)) = __ccgo_fp(XTk_DisplayName) *(*uintptr)(unsafe.Add(p, 464)) = __ccgo_fp(XTk_DistanceToTextLayout) *(*uintptr)(unsafe.Add(p, 472)) = __ccgo_fp(XTk_Draw3DPolygon) *(*uintptr)(unsafe.Add(p, 480)) = __ccgo_fp(XTk_Draw3DRectangle) *(*uintptr)(unsafe.Add(p, 488)) = __ccgo_fp(XTk_DrawChars) *(*uintptr)(unsafe.Add(p, 496)) = __ccgo_fp(XTk_DrawFocusHighlight) *(*uintptr)(unsafe.Add(p, 504)) = __ccgo_fp(XTk_DrawTextLayout) *(*uintptr)(unsafe.Add(p, 512)) = __ccgo_fp(XTk_Fill3DPolygon) *(*uintptr)(unsafe.Add(p, 520)) = __ccgo_fp(XTk_Fill3DRectangle) *(*uintptr)(unsafe.Add(p, 528)) = __ccgo_fp(XTk_FindPhoto) *(*uintptr)(unsafe.Add(p, 536)) = __ccgo_fp(XTk_FontId) *(*uintptr)(unsafe.Add(p, 544)) = __ccgo_fp(XTk_Free3DBorder) *(*uintptr)(unsafe.Add(p, 552)) = __ccgo_fp(XTk_FreeBitmap) *(*uintptr)(unsafe.Add(p, 560)) = __ccgo_fp(XTk_FreeColor) *(*uintptr)(unsafe.Add(p, 568)) = __ccgo_fp(XTk_FreeColormap) *(*uintptr)(unsafe.Add(p, 576)) = __ccgo_fp(XTk_FreeCursor) *(*uintptr)(unsafe.Add(p, 584)) = __ccgo_fp(XTk_FreeFont) *(*uintptr)(unsafe.Add(p, 592)) = __ccgo_fp(XTk_FreeGC) *(*uintptr)(unsafe.Add(p, 600)) = __ccgo_fp(XTk_FreeImage) *(*uintptr)(unsafe.Add(p, 608)) = __ccgo_fp(XTk_FreeOptions) *(*uintptr)(unsafe.Add(p, 616)) = __ccgo_fp(XTk_FreePixmap) *(*uintptr)(unsafe.Add(p, 624)) = __ccgo_fp(XTk_FreeTextLayout) *(*uintptr)(unsafe.Add(p, 640)) = __ccgo_fp(XTk_GCForColor) *(*uintptr)(unsafe.Add(p, 648)) = __ccgo_fp(XTk_GeometryRequest) *(*uintptr)(unsafe.Add(p, 656)) = __ccgo_fp(XTk_Get3DBorder) *(*uintptr)(unsafe.Add(p, 664)) = __ccgo_fp(XTk_GetAllBindings) *(*uintptr)(unsafe.Add(p, 672)) = __ccgo_fp(XTk_GetAnchor) *(*uintptr)(unsafe.Add(p, 680)) = __ccgo_fp(XTk_GetAtomName) *(*uintptr)(unsafe.Add(p, 688)) = __ccgo_fp(XTk_GetBinding) *(*uintptr)(unsafe.Add(p, 696)) = __ccgo_fp(XTk_GetBitmap) *(*uintptr)(unsafe.Add(p, 704)) = __ccgo_fp(XTk_GetBitmapFromData) *(*uintptr)(unsafe.Add(p, 712)) = __ccgo_fp(XTk_GetCapStyle) *(*uintptr)(unsafe.Add(p, 720)) = __ccgo_fp(XTk_GetColor) *(*uintptr)(unsafe.Add(p, 728)) = __ccgo_fp(XTk_GetColorByValue) *(*uintptr)(unsafe.Add(p, 736)) = __ccgo_fp(XTk_GetColormap) *(*uintptr)(unsafe.Add(p, 744)) = __ccgo_fp(XTk_GetCursor) *(*uintptr)(unsafe.Add(p, 752)) = __ccgo_fp(XTk_GetCursorFromData) *(*uintptr)(unsafe.Add(p, 760)) = __ccgo_fp(XTk_GetFont) *(*uintptr)(unsafe.Add(p, 768)) = __ccgo_fp(XTk_GetFontFromObj) *(*uintptr)(unsafe.Add(p, 776)) = __ccgo_fp(XTk_GetFontMetrics) *(*uintptr)(unsafe.Add(p, 784)) = __ccgo_fp(XTk_GetGC) *(*uintptr)(unsafe.Add(p, 792)) = __ccgo_fp(XTk_GetImage) *(*uintptr)(unsafe.Add(p, 800)) = __ccgo_fp(XTk_GetImageModelData) *(*uintptr)(unsafe.Add(p, 808)) = __ccgo_fp(XTk_GetItemTypes) *(*uintptr)(unsafe.Add(p, 816)) = __ccgo_fp(XTk_GetJoinStyle) *(*uintptr)(unsafe.Add(p, 824)) = __ccgo_fp(XTk_GetJustify) *(*uintptr)(unsafe.Add(p, 832)) = __ccgo_fp(XTk_GetNumMainWindows) *(*uintptr)(unsafe.Add(p, 840)) = __ccgo_fp(XTk_GetOption) *(*uintptr)(unsafe.Add(p, 848)) = __ccgo_fp(XTk_GetPixels) *(*uintptr)(unsafe.Add(p, 856)) = __ccgo_fp(XTk_GetPixmap) *(*uintptr)(unsafe.Add(p, 864)) = __ccgo_fp(XTk_GetRelief) *(*uintptr)(unsafe.Add(p, 872)) = __ccgo_fp(XTk_GetRootCoords) *(*uintptr)(unsafe.Add(p, 880)) = __ccgo_fp(XTk_GetScrollInfo) *(*uintptr)(unsafe.Add(p, 888)) = __ccgo_fp(XTk_GetScreenMM) *(*uintptr)(unsafe.Add(p, 896)) = __ccgo_fp(XTk_GetSelection) *(*uintptr)(unsafe.Add(p, 904)) = __ccgo_fp(XTk_GetUid) *(*uintptr)(unsafe.Add(p, 912)) = __ccgo_fp(XTk_GetVisual) *(*uintptr)(unsafe.Add(p, 920)) = __ccgo_fp(XTk_GetVRootGeometry) *(*uintptr)(unsafe.Add(p, 928)) = __ccgo_fp(XTk_Grab) *(*uintptr)(unsafe.Add(p, 936)) = __ccgo_fp(XTk_HandleEvent) *(*uintptr)(unsafe.Add(p, 944)) = __ccgo_fp(XTk_IdToWindow) *(*uintptr)(unsafe.Add(p, 952)) = __ccgo_fp(XTk_ImageChanged) *(*uintptr)(unsafe.Add(p, 968)) = __ccgo_fp(XTk_InternAtom) *(*uintptr)(unsafe.Add(p, 976)) = __ccgo_fp(XTk_IntersectTextLayout) *(*uintptr)(unsafe.Add(p, 984)) = __ccgo_fp(XTk_MaintainGeometry) *(*uintptr)(unsafe.Add(p, 992)) = __ccgo_fp(XTk_MainWindow) *(*uintptr)(unsafe.Add(p, 1000)) = __ccgo_fp(XTk_MakeWindowExist) *(*uintptr)(unsafe.Add(p, 1008)) = __ccgo_fp(XTk_ManageGeometry) *(*uintptr)(unsafe.Add(p, 1016)) = __ccgo_fp(XTk_MapWindow) *(*uintptr)(unsafe.Add(p, 1024)) = __ccgo_fp(XTk_MeasureChars) *(*uintptr)(unsafe.Add(p, 1032)) = __ccgo_fp(XTk_MoveResizeWindow) *(*uintptr)(unsafe.Add(p, 1040)) = __ccgo_fp(XTk_MoveWindow) *(*uintptr)(unsafe.Add(p, 1048)) = __ccgo_fp(XTk_MoveToplevelWindow) *(*uintptr)(unsafe.Add(p, 1056)) = __ccgo_fp(XTk_NameOf3DBorder) *(*uintptr)(unsafe.Add(p, 1064)) = __ccgo_fp(XTk_NameOfAnchor) *(*uintptr)(unsafe.Add(p, 1072)) = __ccgo_fp(XTk_NameOfBitmap) *(*uintptr)(unsafe.Add(p, 1080)) = __ccgo_fp(XTk_NameOfCapStyle) *(*uintptr)(unsafe.Add(p, 1088)) = __ccgo_fp(XTk_NameOfColor) *(*uintptr)(unsafe.Add(p, 1096)) = __ccgo_fp(XTk_NameOfCursor) *(*uintptr)(unsafe.Add(p, 1104)) = __ccgo_fp(XTk_NameOfFont) *(*uintptr)(unsafe.Add(p, 1112)) = __ccgo_fp(XTk_NameOfImage) *(*uintptr)(unsafe.Add(p, 1120)) = __ccgo_fp(XTk_NameOfJoinStyle) *(*uintptr)(unsafe.Add(p, 1128)) = __ccgo_fp(XTk_NameOfJustify) *(*uintptr)(unsafe.Add(p, 1136)) = __ccgo_fp(XTk_NameOfRelief) *(*uintptr)(unsafe.Add(p, 1144)) = __ccgo_fp(XTk_NameToWindow) *(*uintptr)(unsafe.Add(p, 1152)) = __ccgo_fp(XTk_OwnSelection) *(*uintptr)(unsafe.Add(p, 1160)) = __ccgo_fp(XTk_ParseArgv) *(*uintptr)(unsafe.Add(p, 1184)) = __ccgo_fp(XTk_PhotoGetImage) *(*uintptr)(unsafe.Add(p, 1192)) = __ccgo_fp(XTk_PhotoBlank) *(*uintptr)(unsafe.Add(p, 1208)) = __ccgo_fp(XTk_PhotoGetSize) *(*uintptr)(unsafe.Add(p, 1224)) = __ccgo_fp(XTk_PointToChar) *(*uintptr)(unsafe.Add(p, 1232)) = __ccgo_fp(XTk_PostscriptFontName) *(*uintptr)(unsafe.Add(p, 1240)) = __ccgo_fp(XTk_PreserveColormap) *(*uintptr)(unsafe.Add(p, 1248)) = __ccgo_fp(XTk_QueueWindowEvent) *(*uintptr)(unsafe.Add(p, 1256)) = __ccgo_fp(XTk_RedrawImage) *(*uintptr)(unsafe.Add(p, 1264)) = __ccgo_fp(XTk_ResizeWindow) *(*uintptr)(unsafe.Add(p, 1272)) = __ccgo_fp(XTk_RestackWindow) *(*uintptr)(unsafe.Add(p, 1280)) = __ccgo_fp(XTk_RestrictEvents) *(*uintptr)(unsafe.Add(p, 1296)) = __ccgo_fp(XTk_SetAppName) *(*uintptr)(unsafe.Add(p, 1304)) = __ccgo_fp(XTk_SetBackgroundFromBorder) *(*uintptr)(unsafe.Add(p, 1312)) = __ccgo_fp(XTk_SetClass) *(*uintptr)(unsafe.Add(p, 1320)) = __ccgo_fp(XTk_SetGrid) *(*uintptr)(unsafe.Add(p, 1328)) = __ccgo_fp(XTk_SetInternalBorder) *(*uintptr)(unsafe.Add(p, 1336)) = __ccgo_fp(XTk_SetWindowBackground) *(*uintptr)(unsafe.Add(p, 1344)) = __ccgo_fp(XTk_SetWindowBackgroundPixmap) *(*uintptr)(unsafe.Add(p, 1352)) = __ccgo_fp(XTk_SetWindowBorder) *(*uintptr)(unsafe.Add(p, 1360)) = __ccgo_fp(XTk_SetWindowBorderWidth) *(*uintptr)(unsafe.Add(p, 1368)) = __ccgo_fp(XTk_SetWindowBorderPixmap) *(*uintptr)(unsafe.Add(p, 1376)) = __ccgo_fp(XTk_SetWindowColormap) *(*uintptr)(unsafe.Add(p, 1384)) = __ccgo_fp(XTk_SetWindowVisual) *(*uintptr)(unsafe.Add(p, 1392)) = __ccgo_fp(XTk_SizeOfBitmap) *(*uintptr)(unsafe.Add(p, 1400)) = __ccgo_fp(XTk_SizeOfImage) *(*uintptr)(unsafe.Add(p, 1408)) = __ccgo_fp(XTk_StrictMotif) *(*uintptr)(unsafe.Add(p, 1416)) = __ccgo_fp(XTk_TextLayoutToPostscript) *(*uintptr)(unsafe.Add(p, 1424)) = __ccgo_fp(XTk_TextWidth) *(*uintptr)(unsafe.Add(p, 1432)) = __ccgo_fp(XTk_UndefineCursor) *(*uintptr)(unsafe.Add(p, 1440)) = __ccgo_fp(XTk_UnderlineChars) *(*uintptr)(unsafe.Add(p, 1448)) = __ccgo_fp(XTk_UnderlineTextLayout) *(*uintptr)(unsafe.Add(p, 1456)) = __ccgo_fp(XTk_Ungrab) *(*uintptr)(unsafe.Add(p, 1464)) = __ccgo_fp(XTk_UnmaintainGeometry) *(*uintptr)(unsafe.Add(p, 1472)) = __ccgo_fp(XTk_UnmapWindow) *(*uintptr)(unsafe.Add(p, 1480)) = __ccgo_fp(XTk_UnsetGrid) *(*uintptr)(unsafe.Add(p, 1488)) = __ccgo_fp(XTk_UpdatePointer) *(*uintptr)(unsafe.Add(p, 1496)) = __ccgo_fp(XTk_AllocBitmapFromObj) *(*uintptr)(unsafe.Add(p, 1504)) = __ccgo_fp(XTk_Alloc3DBorderFromObj) *(*uintptr)(unsafe.Add(p, 1512)) = __ccgo_fp(XTk_AllocColorFromObj) *(*uintptr)(unsafe.Add(p, 1520)) = __ccgo_fp(XTk_AllocCursorFromObj) *(*uintptr)(unsafe.Add(p, 1528)) = __ccgo_fp(XTk_AllocFontFromObj) *(*uintptr)(unsafe.Add(p, 1536)) = __ccgo_fp(XTk_CreateOptionTable) *(*uintptr)(unsafe.Add(p, 1544)) = __ccgo_fp(XTk_DeleteOptionTable) *(*uintptr)(unsafe.Add(p, 1552)) = __ccgo_fp(XTk_Free3DBorderFromObj) *(*uintptr)(unsafe.Add(p, 1560)) = __ccgo_fp(XTk_FreeBitmapFromObj) *(*uintptr)(unsafe.Add(p, 1568)) = __ccgo_fp(XTk_FreeColorFromObj) *(*uintptr)(unsafe.Add(p, 1576)) = __ccgo_fp(XTk_FreeConfigOptions) *(*uintptr)(unsafe.Add(p, 1584)) = __ccgo_fp(XTk_FreeSavedOptions) *(*uintptr)(unsafe.Add(p, 1592)) = __ccgo_fp(XTk_FreeCursorFromObj) *(*uintptr)(unsafe.Add(p, 1600)) = __ccgo_fp(XTk_FreeFontFromObj) *(*uintptr)(unsafe.Add(p, 1608)) = __ccgo_fp(XTk_Get3DBorderFromObj) *(*uintptr)(unsafe.Add(p, 1616)) = __ccgo_fp(XTk_GetAnchorFromObj) *(*uintptr)(unsafe.Add(p, 1624)) = __ccgo_fp(XTk_GetBitmapFromObj) *(*uintptr)(unsafe.Add(p, 1632)) = __ccgo_fp(XTk_GetColorFromObj) *(*uintptr)(unsafe.Add(p, 1640)) = __ccgo_fp(XTk_GetCursorFromObj) *(*uintptr)(unsafe.Add(p, 1648)) = __ccgo_fp(XTk_GetOptionInfo) *(*uintptr)(unsafe.Add(p, 1656)) = __ccgo_fp(XTk_GetOptionValue) *(*uintptr)(unsafe.Add(p, 1664)) = __ccgo_fp(XTk_GetJustifyFromObj) *(*uintptr)(unsafe.Add(p, 1672)) = __ccgo_fp(XTk_GetMMFromObj) *(*uintptr)(unsafe.Add(p, 1680)) = __ccgo_fp(XTk_GetPixelsFromObj) *(*uintptr)(unsafe.Add(p, 1688)) = __ccgo_fp(XTk_GetReliefFromObj) *(*uintptr)(unsafe.Add(p, 1696)) = __ccgo_fp(XTk_GetScrollInfoObj) *(*uintptr)(unsafe.Add(p, 1704)) = __ccgo_fp(XTk_InitOptions) *(*uintptr)(unsafe.Add(p, 1720)) = __ccgo_fp(XTk_RestoreSavedOptions) *(*uintptr)(unsafe.Add(p, 1728)) = __ccgo_fp(XTk_SetOptions) *(*uintptr)(unsafe.Add(p, 1736)) = __ccgo_fp(XTk_InitConsoleChannels) *(*uintptr)(unsafe.Add(p, 1752)) = __ccgo_fp(XTk_CreateSmoothMethod) *(*uintptr)(unsafe.Add(p, 1776)) = __ccgo_fp(XTk_GetDash) *(*uintptr)(unsafe.Add(p, 1784)) = __ccgo_fp(XTk_CreateOutline) *(*uintptr)(unsafe.Add(p, 1792)) = __ccgo_fp(XTk_DeleteOutline) *(*uintptr)(unsafe.Add(p, 1800)) = __ccgo_fp(XTk_ConfigOutlineGC) *(*uintptr)(unsafe.Add(p, 1808)) = __ccgo_fp(XTk_ChangeOutlineGC) *(*uintptr)(unsafe.Add(p, 1816)) = __ccgo_fp(XTk_ResetOutlineGC) *(*uintptr)(unsafe.Add(p, 1824)) = __ccgo_fp(XTk_CanvasPsOutline) *(*uintptr)(unsafe.Add(p, 1832)) = __ccgo_fp(XTk_SetTSOrigin) *(*uintptr)(unsafe.Add(p, 1840)) = __ccgo_fp(XTk_CanvasGetCoordFromObj) *(*uintptr)(unsafe.Add(p, 1848)) = __ccgo_fp(XTk_CanvasSetOffset) *(*uintptr)(unsafe.Add(p, 1856)) = __ccgo_fp(XTk_DitherPhoto) *(*uintptr)(unsafe.Add(p, 1864)) = __ccgo_fp(XTk_PostscriptBitmap) *(*uintptr)(unsafe.Add(p, 1872)) = __ccgo_fp(XTk_PostscriptColor) *(*uintptr)(unsafe.Add(p, 1880)) = __ccgo_fp(XTk_PostscriptFont) *(*uintptr)(unsafe.Add(p, 1888)) = __ccgo_fp(XTk_PostscriptImage) *(*uintptr)(unsafe.Add(p, 1896)) = __ccgo_fp(XTk_PostscriptPath) *(*uintptr)(unsafe.Add(p, 1904)) = __ccgo_fp(XTk_PostscriptStipple) *(*uintptr)(unsafe.Add(p, 1912)) = __ccgo_fp(XTk_PostscriptY) *(*uintptr)(unsafe.Add(p, 1920)) = __ccgo_fp(XTk_PostscriptPhoto) *(*uintptr)(unsafe.Add(p, 1928)) = __ccgo_fp(XTk_CreateClientMessageHandler) *(*uintptr)(unsafe.Add(p, 1936)) = __ccgo_fp(XTk_DeleteClientMessageHandler) *(*uintptr)(unsafe.Add(p, 1944)) = __ccgo_fp(XTk_CreateAnonymousWindow) *(*uintptr)(unsafe.Add(p, 1952)) = __ccgo_fp(XTk_SetClassProcs) *(*uintptr)(unsafe.Add(p, 1960)) = __ccgo_fp(XTk_SetInternalBorderEx) *(*uintptr)(unsafe.Add(p, 1968)) = __ccgo_fp(XTk_SetMinimumRequestSize) *(*uintptr)(unsafe.Add(p, 1976)) = __ccgo_fp(XTk_SetCaretPos) *(*uintptr)(unsafe.Add(p, 2000)) = __ccgo_fp(XTk_CollapseMotionEvents) *(*uintptr)(unsafe.Add(p, 2008)) = __ccgo_fp(XTk_RegisterStyleEngine) *(*uintptr)(unsafe.Add(p, 2016)) = __ccgo_fp(XTk_GetStyleEngine) *(*uintptr)(unsafe.Add(p, 2024)) = __ccgo_fp(XTk_RegisterStyledElement) *(*uintptr)(unsafe.Add(p, 2032)) = __ccgo_fp(XTk_GetElementId) *(*uintptr)(unsafe.Add(p, 2040)) = __ccgo_fp(XTk_CreateStyle) *(*uintptr)(unsafe.Add(p, 2048)) = __ccgo_fp(XTk_GetStyle) *(*uintptr)(unsafe.Add(p, 2056)) = __ccgo_fp(XTk_FreeStyle) *(*uintptr)(unsafe.Add(p, 2064)) = __ccgo_fp(XTk_NameOfStyle) *(*uintptr)(unsafe.Add(p, 2072)) = __ccgo_fp(XTk_AllocStyleFromObj) *(*uintptr)(unsafe.Add(p, 2096)) = __ccgo_fp(XTk_GetStyledElement) *(*uintptr)(unsafe.Add(p, 2104)) = __ccgo_fp(XTk_GetElementSize) *(*uintptr)(unsafe.Add(p, 2112)) = __ccgo_fp(XTk_GetElementBox) *(*uintptr)(unsafe.Add(p, 2120)) = __ccgo_fp(XTk_GetElementBorderWidth) *(*uintptr)(unsafe.Add(p, 2128)) = __ccgo_fp(XTk_DrawElement) *(*uintptr)(unsafe.Add(p, 2136)) = __ccgo_fp(XTk_PhotoExpand) *(*uintptr)(unsafe.Add(p, 2144)) = __ccgo_fp(XTk_PhotoPutBlock) *(*uintptr)(unsafe.Add(p, 2152)) = __ccgo_fp(XTk_PhotoPutZoomedBlock) *(*uintptr)(unsafe.Add(p, 2160)) = __ccgo_fp(XTk_PhotoSetSize) *(*uintptr)(unsafe.Add(p, 2168)) = __ccgo_fp(XTk_GetUserInactiveTime) *(*uintptr)(unsafe.Add(p, 2176)) = __ccgo_fp(XTk_ResetUserInactiveTime) *(*uintptr)(unsafe.Add(p, 2184)) = __ccgo_fp(XTk_Interp) *(*uintptr)(unsafe.Add(p, 2208)) = __ccgo_fp(XTk_AlwaysShowSelection) *(*uintptr)(unsafe.Add(p, 2216)) = __ccgo_fp(XTk_GetButtonMask) *(*uintptr)(unsafe.Add(p, 2224)) = __ccgo_fp(XTk_GetDoublePixelsFromObj) *(*uintptr)(unsafe.Add(p, 2232)) = __ccgo_fp(XTk_NewWindowObj) *(*uintptr)(unsafe.Add(p, 2240)) = __ccgo_fp(XTk_SendVirtualEvent) *(*uintptr)(unsafe.Add(p, 2248)) = __ccgo_fp(XTk_FontGetDescription) *(*uintptr)(unsafe.Add(p, 2256)) = __ccgo_fp(XTk_CreatePhotoImageFormatVersion3) *(*uintptr)(unsafe.Add(p, 2264)) = __ccgo_fp(XTk_DrawHighlightBorder) *(*uintptr)(unsafe.Add(p, 2272)) = __ccgo_fp(XTk_SetMainMenubar) *(*uintptr)(unsafe.Add(p, 2280)) = __ccgo_fp(XTk_SetWindowMenubar) *(*uintptr)(unsafe.Add(p, 2296)) = __ccgo_fp(XTk_GetSystemDefault) *(*uintptr)(unsafe.Add(p, 2304)) = __ccgo_fp(XTk_UseWindow) *(*uintptr)(unsafe.Add(p, 2312)) = __ccgo_fp(XTk_MakeContainer) *(*uintptr)(unsafe.Add(p, 2320)) = __ccgo_fp(XTk_GetOtherWindow) *(*uintptr)(unsafe.Add(p, 2328)) = __ccgo_fp(XTk_Get3DBorderColors) *(*uintptr)(unsafe.Add(p, 2336)) = __ccgo_fp(XTk_MakeWindow) *(*uintptr)(unsafe.Add(p, 2344)) = __ccgo_fp(XTk_UnderlineCharsInContext) *(*uintptr)(unsafe.Add(p, 2352)) = __ccgo_fp(XTk_DrawCharsInContext) *(*uintptr)(unsafe.Add(p, 2360)) = __ccgo_fp(XTk_MeasureCharsInContext) } const CURSOR_ON2 = 32 const CursorEventMask = 2228224 const DEFAULT_BACKGROUND = "#d9d9d9" const DEFAULT_FONT = "TkDefaultFont" const DEFAULT_FOREGROUND = "black" const DEF_CURSOR_OFF_TIME = 300 const DEF_CURSOR_ON_TIME = 600 const GEOMETRY_CHANGED = 4 const READONLY_OPTION = 1 const REDISPLAY_PENDING = 2 const STYLE_CHANGED = 2 const TK_OPTION_ANY = 0 const TTKAPI = "MODULE_SCOPE" const TTK_BORDER = 512 const TTK_EXPAND = 256 const TTK_FILL_BOTH = 15 const TTK_FILL_X = 3 const TTK_FILL_Y = 12 const TTK_PACK_BOTTOM = 128 const TTK_PACK_LEFT = 16 const TTK_PACK_RIGHT = 32 const TTK_PACK_TOP = 64 const TTK_PATCH_LEVEL = "TK_PATCH_LEVEL" const TTK_STATE_ACTIVE = 1 const TTK_STATE_ALTERNATE = 64 const TTK_STATE_BACKGROUND = 32 const TTK_STATE_DISABLED = 2 const TTK_STATE_FIRST = 262144 const TTK_STATE_FOCUS = 4 const TTK_STATE_HOVER = 512 const TTK_STATE_INVALID = 128 const TTK_STATE_LAST = 524288 const TTK_STATE_LEAF = 131072 const TTK_STATE_OPEN = 65536 const TTK_STATE_PRESSED = 8 const TTK_STATE_READONLY = 256 const TTK_STATE_SELECTED = 16 const TTK_STATE_USER1 = 32768 const TTK_STATE_USER2 = 16384 const TTK_STATE_USER3 = 8192 const TTK_STATE_USER4 = 4096 const TTK_STATE_USER5 = 2048 const TTK_STATE_USER6 = 1024 const TTK_STICK_E = 2 const TTK_STICK_N = 4 const TTK_STICK_S = 8 const TTK_STICK_W = 1 const TTK_STUBS_EPOCH = 0 const TTK_STUBS_REVISION = 31 const TTK_UNIT = 1024 const TTK_VERSION = "TK_VERSION" const WIDGET_DESTROYED = 1 const WIDGET_USER_FLAG = 256 const _TTK_CHILDREN = 4096 const _TTK_LAYOUT = 16384 const _TTK_LAYOUT_END = 8192 const _TTK_MASK_PACK = 240 const _TTK_MASK_STICK = 15 type TTtk_State = uint32 type TTtk_StateSpec = struct { Fonbits uint32 Foffbits uint32 } type TTtk_StateMap = uintptr type TTtk_StateTable = struct { Findex int32 FonBits uint32 FoffBits uint32 } type TTtk_Padding = struct { Fleft int16 Ftop int16 Fright int16 Fbottom int16 } type TTtk_Box = struct { Fx int32 Fy int32 Fwidth int32 Fheight int32 } type TTtk_Side = int32 const TTK_SIDE_LEFT = 0 const TTK_SIDE_TOP = 1 const TTK_SIDE_RIGHT = 2 const TTK_SIDE_BOTTOM = 3 type TTtk_Sticky = uint32 type TTtk_PositionSpec = uint32 type TTtk_Theme = uintptr type TTtk_Layout = uintptr type TTtk_Element = uintptr type TTtk_Style = uintptr type TTKStyleVersion2 = int32 const TK_STYLE_VERSION_2 = 2 type TTtk_ElementOptionSpec = struct { FoptionName uintptr Ftype1 TTk_OptionType Foffset TTcl_Size FdefaultValue uintptr } type TTtk_ElementSpec = struct { Fversion TTKStyleVersion2 FelementSize Tsize_t Foptions uintptr Fsize uintptr Fdraw uintptr } type TTtk_ElementFactory = uintptr type TNullElement = struct { Funused uintptr } type TTTKLayoutInstruction = struct { FelementName uintptr Fopcode uint32 } type TTtk_LayoutSpec = uintptr type TTtk_ResourceCache = uintptr type TTtk_ButtonDefaultState = int32 const TTK_BUTTON_DEFAULT_ACTIVE = 0 const TTK_BUTTON_DEFAULT_DISABLED = 1 const TTK_BUTTON_DEFAULT_NORMAL = 2 type TTtk_Compound = int32 const TTK_COMPOUND_NONE = 0 const TTK_COMPOUND_TEXT = 1 const TTK_COMPOUND_IMAGE = 2 const TTK_COMPOUND_CENTER = 3 const TTK_COMPOUND_TOP = 4 const TTK_COMPOUND_BOTTOM = 5 const TTK_COMPOUND_LEFT = 6 const TTK_COMPOUND_RIGHT = 7 type TTtk_Orient = int32 const TTK_ORIENT_HORIZONTAL = 0 const TTK_ORIENT_VERTICAL = 1 type TTtk_Ensemble = struct { Fname uintptr Fcommand uintptr Fensemble uintptr } type TTtkEnsemble = TTtk_Ensemble type TTtkStubs = struct { Fmagic int32 Fepoch int32 Frevision int32 Fhooks uintptr Fttk_GetTheme uintptr Fttk_GetDefaultTheme uintptr Fttk_GetCurrentTheme uintptr Fttk_CreateTheme uintptr Fttk_RegisterCleanup uintptr Fttk_RegisterElementSpec uintptr Fttk_RegisterElement uintptr Fttk_RegisterElementFactory uintptr Fttk_RegisterLayout uintptr Freserved9 uintptr Fttk_GetStateSpecFromObj uintptr Fttk_NewStateSpecObj uintptr Fttk_GetStateMapFromObj uintptr Fttk_StateMapLookup uintptr Fttk_StateTableLookup uintptr Freserved15 uintptr Freserved16 uintptr Freserved17 uintptr Freserved18 uintptr Freserved19 uintptr Fttk_GetPaddingFromObj uintptr Fttk_GetBorderFromObj uintptr Fttk_GetStickyFromObj uintptr Fttk_MakePadding uintptr Fttk_UniformPadding uintptr Fttk_AddPadding uintptr Fttk_RelievePadding uintptr Fttk_MakeBox uintptr Fttk_BoxContains uintptr Fttk_PackBox uintptr Fttk_StickBox uintptr Fttk_AnchorBox uintptr Fttk_PadBox uintptr Fttk_ExpandBox uintptr Fttk_PlaceBox uintptr Fttk_NewBoxObj uintptr Freserved36 uintptr Freserved37 uintptr Freserved38 uintptr Freserved39 uintptr Fttk_GetOrientFromObj uintptr } type TArrowDirection = int32 const ARROW_UP = 0 const ARROW_DOWN = 1 const ARROW_LEFT = 2 const ARROW_RIGHT = 3 type TTtk_LayoutTemplate = uintptr type TWidgetSpec = struct { FclassName uintptr FrecordSize Tsize_t FoptionSpecs uintptr Fcommands uintptr FinitializeProc uintptr FcleanupProc uintptr FconfigureProc uintptr FpostConfigureProc uintptr FgetLayoutProc uintptr FsizeProc uintptr FlayoutProc uintptr FdisplayProc uintptr } type TWidgetSpec_ = TWidgetSpec type TWidgetCore = struct { Ftkwin TTk_Window Finterp uintptr FwidgetSpec uintptr FwidgetCmd TTcl_Command FoptionTable TTk_OptionTable Flayout TTtk_Layout FtakeFocusPtr uintptr FcursorObj uintptr FstyleObj uintptr FclassObj uintptr Fstate TTtk_State Fflags uint32 } type TTtk_TraceProc = uintptr type TScrollable = struct { Ffirst int32 Flast int32 Ftotal int32 FscrollCmdObj uintptr } type TScrollHandle = uintptr type TTtk_Tag = uintptr type TTtk_TagTable = uintptr type TTtk_TagSet = uintptr type TTtkTagSet = struct { Ftags uintptr FnTags TTcl_Size } /* * Platform-specific initialization. */ // C documentation // // /* Interp-specific data for tracking cursors: // */ type TCursorManager = struct { Fowner uintptr Ftimer TTcl_TimerToken FonTime int32 FoffTime int32 } // C documentation // // /* CursorManagerDeleteProc -- // * InterpDeleteProc for cursor manager. // */ func _CursorManagerDeleteProc(tls *libc.TLS, clientData uintptr, dummy37 uintptr) { var cm uintptr _ = cm cm = clientData if (*TCursorManager)(unsafe.Pointer(cm)).Ftimer != 0 { libtcl9_0.XTcl_DeleteTimerHandler(tls, (*TCursorManager)(unsafe.Pointer(cm)).Ftimer) } libtcl9_0.XTcl_Free(tls, clientData) } // C documentation // // /* GetCursorManager -- // * Look up and create if necessary the interp's cursor manager. // */ func _GetCursorManager(tls *libc.TLS, interp uintptr) (r uintptr) { bp := tls.Alloc(16) defer tls.Free(16) var cm uintptr var value TTk_Uid var window TTk_Window var _ /* intValue at bp+0 */ int32 _, _, _ = cm, value, window cm = libtcl9_0.XTcl_GetAssocData(tls, interp, _cm_key, uintptr(0)) if !(cm != 0) { cm = libtcl9_0.XTcl_Alloc(tls, uint64(24)) (*TCursorManager)(unsafe.Pointer(cm)).Ftimer = uintptr(0) (*TCursorManager)(unsafe.Pointer(cm)).Fowner = uintptr(0) (*TCursorManager)(unsafe.Pointer(cm)).FonTime = int32(DEF_CURSOR_ON_TIME) (*TCursorManager)(unsafe.Pointer(cm)).FoffTime = int32(DEF_CURSOR_OFF_TIME) /* Override on and off default times with values obtained from * the option database (if such values are specified). */ window = XTk_MainWindow(tls, interp) if window != 0 { value = XTk_GetOption(tls, window, __ccgo_ts+21351, __ccgo_ts+21364) if value != 0 { if libtcl9_0.XTcl_GetInt(tls, interp, value, bp) == TCL_OK { (*TCursorManager)(unsafe.Pointer(cm)).FonTime = *(*int32)(unsafe.Pointer(bp)) } } value = XTk_GetOption(tls, window, __ccgo_ts+21311, __ccgo_ts+21325) if value != 0 { if libtcl9_0.XTcl_GetInt(tls, interp, value, bp) == TCL_OK { (*TCursorManager)(unsafe.Pointer(cm)).FoffTime = *(*int32)(unsafe.Pointer(bp)) } } } libtcl9_0.XTcl_SetAssocData(tls, interp, _cm_key, __ccgo_fp(_CursorManagerDeleteProc), cm) } return cm } var _cm_key = __ccgo_ts + 49109 // C documentation // // /* CursorBlinkProc -- // * Timer handler to blink the insert cursor on and off. // */ func _CursorBlinkProc(tls *libc.TLS, clientData uintptr) { var blinkTime int32 var cm uintptr _, _ = blinkTime, cm cm = clientData if (*TWidgetCore)(unsafe.Pointer((*TCursorManager)(unsafe.Pointer(cm)).Fowner)).Fflags&uint32(CURSOR_ON2) != 0 { *(*uint32)(unsafe.Pointer((*TCursorManager)(unsafe.Pointer(cm)).Fowner + 84)) &= libc.Uint32FromInt32(^libc.Int32FromInt32(CURSOR_ON2)) blinkTime = (*TCursorManager)(unsafe.Pointer(cm)).FoffTime } else { *(*uint32)(unsafe.Pointer((*TCursorManager)(unsafe.Pointer(cm)).Fowner + 84)) |= uint32(CURSOR_ON2) blinkTime = (*TCursorManager)(unsafe.Pointer(cm)).FonTime } (*TCursorManager)(unsafe.Pointer(cm)).Ftimer = libtcl9_0.XTcl_CreateTimerHandler(tls, blinkTime, __ccgo_fp(_CursorBlinkProc), clientData) XTtkRedisplayWidget(tls, (*TCursorManager)(unsafe.Pointer(cm)).Fowner) } // C documentation // // /* LoseCursor -- // * Turn cursor off, disable blink timer. // */ func _LoseCursor(tls *libc.TLS, cm uintptr, corePtr uintptr) { if (*TWidgetCore)(unsafe.Pointer(corePtr)).Fflags&uint32(CURSOR_ON2) != 0 { *(*uint32)(unsafe.Pointer(corePtr + 84)) &= libc.Uint32FromInt32(^libc.Int32FromInt32(CURSOR_ON2)) XTtkRedisplayWidget(tls, corePtr) } if (*TCursorManager)(unsafe.Pointer(cm)).Fowner == corePtr { (*TCursorManager)(unsafe.Pointer(cm)).Fowner = libc.UintptrFromInt32(0) } if (*TCursorManager)(unsafe.Pointer(cm)).Ftimer != 0 { libtcl9_0.XTcl_DeleteTimerHandler(tls, (*TCursorManager)(unsafe.Pointer(cm)).Ftimer) (*TCursorManager)(unsafe.Pointer(cm)).Ftimer = uintptr(0) } } // C documentation // // /* ClaimCursor -- // * Claim ownership of the insert cursor and blink on. // */ func _ClaimCursor(tls *libc.TLS, cm uintptr, corePtr uintptr) { if (*TCursorManager)(unsafe.Pointer(cm)).Fowner == corePtr { return } if (*TCursorManager)(unsafe.Pointer(cm)).Fowner != 0 { _LoseCursor(tls, cm, (*TCursorManager)(unsafe.Pointer(cm)).Fowner) } *(*uint32)(unsafe.Pointer(corePtr + 84)) |= uint32(CURSOR_ON2) XTtkRedisplayWidget(tls, corePtr) (*TCursorManager)(unsafe.Pointer(cm)).Fowner = corePtr (*TCursorManager)(unsafe.Pointer(cm)).Ftimer = libtcl9_0.XTcl_CreateTimerHandler(tls, (*TCursorManager)(unsafe.Pointer(cm)).FonTime, __ccgo_fp(_CursorBlinkProc), cm) } /* * CursorEventProc -- * Event handler for FocusIn and FocusOut events; * claim/lose ownership of the insert cursor when the widget * acquires/loses keyboard focus. */ func _CursorEventProc(tls *libc.TLS, clientData uintptr, eventPtr uintptr) { var cm, corePtr uintptr _, _ = cm, corePtr corePtr = clientData cm = _GetCursorManager(tls, (*TWidgetCore)(unsafe.Pointer(corePtr)).Finterp) switch (*TXEvent)(unsafe.Pointer(eventPtr)).Ftype1 { case int32(DestroyNotify): if (*TCursorManager)(unsafe.Pointer(cm)).Fowner == corePtr { _LoseCursor(tls, cm, corePtr) } XTk_DeleteEventHandler(tls, (*TWidgetCore)(unsafe.Pointer(corePtr)).Ftkwin, libc.Uint64FromInt64(libc.Int64FromInt64(1)<= 0 { (*TCursorManager)(unsafe.Pointer(cm)).FonTime = onTime } } func XTtkSetBlinkCursorOffTime(tls *libc.TLS, interp uintptr, offTime int32) { var cm uintptr _ = cm cm = _GetCursorManager(tls, interp) if offTime >= 0 { (*TCursorManager)(unsafe.Pointer(cm)).FoffTime = offTime } } // C documentation // // /* // * TtkSetBlinkCursorTimes -- // * Set cursor blink on and off times from the "." style defaults // * -insertontime and -insertofftime - For instance to set cursor // * blinking off: // * ttk::style configure . -insertofftime 0 // */ func XTtkSetBlinkCursorTimes(tls *libc.TLS, interp uintptr) { bp := tls.Alloc(16) defer tls.Free(16) var result uintptr var style TTtk_Style var theme TTtk_Theme var _ /* timeInterval at bp+0 */ int32 _, _, _ = result, style, theme style = libc.UintptrFromInt32(0) theme = XTtk_GetCurrentTheme(tls, interp) style = XTtk_GetStyle(tls, theme, __ccgo_ts+18591) result = XTtk_StyleDefault(tls, style, __ccgo_ts+21337) if result != 0 { libtcl9_0.XTcl_GetIntFromObj(tls, interp, result, bp) XTtkSetBlinkCursorOnTime(tls, interp, *(*int32)(unsafe.Pointer(bp))) } result = XTtk_StyleDefault(tls, style, __ccgo_ts+21296) if result != 0 { libtcl9_0.XTcl_GetIntFromObj(tls, interp, result, bp) XTtkSetBlinkCursorOffTime(tls, interp, *(*int32)(unsafe.Pointer(bp))) } } // C documentation // // /* // * TtkBlinkCursor (main routine) -- // * Arrange to blink the cursor on and off whenever the // * widget has focus. // */ func XTtkBlinkCursor(tls *libc.TLS, corePtr uintptr) { XTk_CreateEventHandler(tls, (*TWidgetCore)(unsafe.Pointer(corePtr)).Ftkwin, libc.Uint64FromInt64(libc.Int64FromInt64(1)< int64(2) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(1), objv, __ccgo_ts+20930) return int32(TCL_ERROR) } if (*TButton)(unsafe.Pointer(buttonPtr)).Fcore.Fstate&libc.Uint32FromInt32(libc.Int32FromInt32(1)< int64(2) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(1), objv, __ccgo_ts+20930) return int32(TCL_ERROR) } if (*TWidgetCore)(unsafe.Pointer(corePtr)).Fstate&libc.Uint32FromInt32(libc.Int32FromInt32(1)< int64(2) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(1), objv, __ccgo_ts+20930) return int32(TCL_ERROR) } if (*TWidgetCore)(unsafe.Pointer(corePtr)).Fstate&libc.Uint32FromInt32(libc.Int32FromInt32(1)<>: -borderwidth is only partially supported: * in this theme, borders are always exactly 2 pixels thick. * With -borderwidth 0, border is not drawn at all; * otherwise a 2-pixel border is used. For -borderwidth > 2, * the excess is used as padding. */ func _BorderElementSize(tls *libc.TLS, dummy132 uintptr, elementRecord uintptr, tkwin TTk_Window, dummy135 uintptr, dummy136 uintptr, paddingPtr uintptr) { bp := tls.Alloc(16) defer tls.Free(16) var border uintptr var _ /* borderWidth at bp+0 */ int32 _ = border border = elementRecord *(*int32)(unsafe.Pointer(bp)) = int32(2) XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), tkwin, (*TBorderElement)(unsafe.Pointer(border)).FborderWidthObj, bp) if *(*int32)(unsafe.Pointer(bp)) == int32(1) { *(*int32)(unsafe.Pointer(bp))++ } *(*TTtk_Padding)(unsafe.Pointer(paddingPtr)) = XTtk_UniformPadding(tls, int16(*(*int32)(unsafe.Pointer(bp)))) } func _BorderElementDraw(tls *libc.TLS, dummy148 uintptr, elementRecord uintptr, tkwin TTk_Window, d TDrawable, b TTtk_Box, dummy153 TTtk_State) { bp := tls.Alloc(16) defer tls.Free(16) var border, lower, outer, upper, v1, v2, v3, v4 uintptr var _ /* borderWidth at bp+4 */ int32 var _ /* relief at bp+0 */ int32 _, _, _, _, _, _, _, _ = border, lower, outer, upper, v1, v2, v3, v4 border = elementRecord *(*int32)(unsafe.Pointer(bp)) = TK_RELIEF_FLAT *(*int32)(unsafe.Pointer(bp + 4)) = int32(2) outer = uintptr(0) upper = uintptr(0) lower = uintptr(0) XTk_GetReliefFromObj(tls, libc.UintptrFromInt32(0), (*TBorderElement)(unsafe.Pointer(border)).FreliefObj, bp) XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), tkwin, (*TBorderElement)(unsafe.Pointer(border)).FborderWidthObj, bp+4) if *(*int32)(unsafe.Pointer(bp + 4)) == 0 { return } switch *(*int32)(unsafe.Pointer(bp)) { case int32(TK_RELIEF_GROOVE): fallthrough case int32(TK_RELIEF_RIDGE): fallthrough case int32(TK_RELIEF_RAISED): outer = (*TBorderElement)(unsafe.Pointer(border)).FborderColorObj upper = (*TBorderElement)(unsafe.Pointer(border)).FlightColorObj lower = (*TBorderElement)(unsafe.Pointer(border)).FdarkColorObj case int32(TK_RELIEF_SUNKEN): outer = (*TBorderElement)(unsafe.Pointer(border)).FborderColorObj upper = (*TBorderElement)(unsafe.Pointer(border)).FdarkColorObj lower = (*TBorderElement)(unsafe.Pointer(border)).FlightColorObj case TK_RELIEF_FLAT: v2 = libc.UintptrFromInt32(0) lower = v2 v1 = v2 upper = v1 outer = v1 case int32(TK_RELIEF_SOLID): v4 = (*TBorderElement)(unsafe.Pointer(border)).FborderColorObj lower = v4 v3 = v4 upper = v3 outer = v3 break } _DrawSmoothBorder(tls, tkwin, d, b, outer, upper, lower) } var _BorderElementSpec = TTtk_ElementSpec{ Fversion: int32(TK_STYLE_VERSION_2), FelementSize: uint64(40), Foptions: uintptr(unsafe.Pointer(&_BorderElementOptions)), } func init() { p := unsafe.Pointer(&_BorderElementSpec) *(*uintptr)(unsafe.Add(p, 24)) = __ccgo_fp(_BorderElementSize) *(*uintptr)(unsafe.Add(p, 32)) = __ccgo_fp(_BorderElementDraw) } /*------------------------------------------------------------------------ * +++ Field element. */ type TFieldElement = struct { FborderColorObj uintptr FlightColorObj uintptr FbackgroundObj uintptr } var _FieldElementOptions = [4]TTtk_ElementOptionSpec{ 0: { FoptionName: __ccgo_ts + 49726, Ftype1: int32(TK_OPTION_COLOR), FdefaultValue: __ccgo_ts + 49739, }, 1: { FoptionName: __ccgo_ts + 49747, Ftype1: int32(TK_OPTION_COLOR), Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 8)), FdefaultValue: __ccgo_ts + 19883, }, 2: { FoptionName: __ccgo_ts + 49778, Ftype1: int32(TK_OPTION_BORDER), Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 16)), FdefaultValue: __ccgo_ts + 39093, }, 3: {}, } func _FieldElementSize(tls *libc.TLS, dummy218 uintptr, dummy219 uintptr, dummy220 TTk_Window, dummy221 uintptr, dummy222 uintptr, paddingPtr uintptr) { *(*TTtk_Padding)(unsafe.Pointer(paddingPtr)) = XTtk_UniformPadding(tls, int16(2)) } func _FieldElementDraw(tls *libc.TLS, dummy229 uintptr, elementRecord uintptr, tkwin TTk_Window, d TDrawable, b TTtk_Box, dummy234 TTtk_State) { var bg TTk_3DBorder var f TTtk_Box var field, inner, outer uintptr _, _, _, _, _ = bg, f, field, inner, outer field = elementRecord bg = XTk_Get3DBorderFromObj(tls, tkwin, (*TFieldElement)(unsafe.Pointer(field)).FbackgroundObj) f = XTtk_PadBox(tls, b, XTtk_UniformPadding(tls, int16(2))) outer = (*TFieldElement)(unsafe.Pointer(field)).FborderColorObj inner = (*TFieldElement)(unsafe.Pointer(field)).FlightColorObj _DrawSmoothBorder(tls, tkwin, d, b, outer, inner, inner) XTk_Fill3DRectangle(tls, tkwin, d, bg, f.Fx, f.Fy, f.Fwidth, f.Fheight, 0, int32(TK_RELIEF_SUNKEN)) } var _FieldElementSpec = TTtk_ElementSpec{ Fversion: int32(TK_STYLE_VERSION_2), FelementSize: uint64(24), Foptions: uintptr(unsafe.Pointer(&_FieldElementOptions)), } func init() { p := unsafe.Pointer(&_FieldElementSpec) *(*uintptr)(unsafe.Add(p, 24)) = __ccgo_fp(_FieldElementSize) *(*uintptr)(unsafe.Add(p, 32)) = __ccgo_fp(_FieldElementDraw) } // C documentation // // /* // * Modified field element for comboboxes: // * Right edge is expanded to overlap the dropdown button. // */ func _ComboboxFieldElementDraw(tls *libc.TLS, clientData uintptr, elementRecord uintptr, tkwin TTk_Window, d TDrawable, b TTtk_Box, state TTtk_State) { var field uintptr var gc TGC _, _ = field, gc field = elementRecord gc = _Ttk_GCForColor(tls, tkwin, (*TFieldElement)(unsafe.Pointer(field)).FborderColorObj, d) b.Fwidth++ _FieldElementDraw(tls, clientData, elementRecord, tkwin, d, b, state) libx11.XXDrawLine(tls, (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fdisplay, d, gc, b.Fx+b.Fwidth-int32(1), b.Fy, b.Fx+b.Fwidth-int32(1), b.Fy+b.Fheight-int32(1)+WIN32_XDRAWLINE_HACK) } var _ComboboxFieldElementSpec = TTtk_ElementSpec{ Fversion: int32(TK_STYLE_VERSION_2), FelementSize: uint64(24), Foptions: uintptr(unsafe.Pointer(&_FieldElementOptions)), } func init() { p := unsafe.Pointer(&_ComboboxFieldElementSpec) *(*uintptr)(unsafe.Add(p, 24)) = __ccgo_fp(_FieldElementSize) *(*uintptr)(unsafe.Add(p, 32)) = __ccgo_fp(_ComboboxFieldElementDraw) } /*------------------------------------------------------------------------ * +++ Indicator elements for check and radio buttons. */ // C documentation // // /* // * Indicator image descriptor: // */ type TIndicatorSpec = struct { Fwidth int32 Fheight int32 FoffDataPtr uintptr FonDataPtr uintptr } var _checkbtnOffData = [264]uint8{' ', ' ', ' ', ' ', '<', 's', 'v', 'g', ' ', 'w', 'i', 'd', 't', 'h', '=', '\'', '1', '6', '\'', ' ', 'h', 'e', 'i', 'g', 'h', 't', '=', '\'', '1', '6', '\'', ' ', 'v', 'e', 'r', 's', 'i', 'o', 'n', '=', '\'', '1', '.', '1', '\'', ' ', 'x', 'm', 'l', 'n', 's', '=', '\'', 'h', 't', 't', 'p', ':', '/', '/', 'w', 'w', 'w', '.', 'w', '3', '.', 'o', 'r', 'g', '/', '2', '0', '0', '0', '/', 's', 'v', 'g', '\'', '>', 10, ' ', ' ', ' ', ' ', ' ', '<', 'p', 'a', 't', 'h', ' ', 'd', '=', '\'', 'm', '0', ' ', '0', 'v', '1', '6', 'h', '1', 'v', '-', '1', '5', 'h', '1', '5', 'v', '-', '1', 'z', '\'', ' ', 'f', 'i', 'l', 'l', '=', '\'', '#', '9', 'e', '9', 'a', '9', '1', '\'', '/', '>', 10, ' ', ' ', ' ', ' ', ' ', '<', 'p', 'a', 't', 'h', ' ', 'd', '=', '\'', 'm', '1', '5', ' ', '1', 'v', '1', '4', 'h', '-', '1', '4', 'v', '1', 'h', '1', '5', 'v', '-', '1', '5', 'z', '\'', ' ', 'f', 'i', 'l', 'l', '=', '\'', '#', 'c', 'f', 'c', 'd', 'c', '8', '\'', '/', '>', 10, ' ', ' ', ' ', ' ', ' ', '<', 'r', 'e', 'c', 't', ' ', 'x', '=', '\'', '1', '\'', ' ', 'y', '=', '\'', '1', '\'', ' ', 'w', 'i', 'd', 't', 'h', '=', '\'', '1', '4', '\'', ' ', 'h', 'e', 'i', 'g', 'h', 't', '=', '\'', '1', '4', '\'', ' ', 'f', 'i', 'l', 'l', '=', '\'', '#', 'f', 'f', 'f', 'f', 'f', 'f', '\'', '/', '>', 10, ' ', ' ', ' ', ' ', '<', '/', 's', 'v', 'g', '>'} var _checkbtnOnData = [367]uint8{' ', ' ', ' ', ' ', '<', 's', 'v', 'g', ' ', 'w', 'i', 'd', 't', 'h', '=', '\'', '1', '6', '\'', ' ', 'h', 'e', 'i', 'g', 'h', 't', '=', '\'', '1', '6', '\'', ' ', 'v', 'e', 'r', 's', 'i', 'o', 'n', '=', '\'', '1', '.', '1', '\'', ' ', 'x', 'm', 'l', 'n', 's', '=', '\'', 'h', 't', 't', 'p', ':', '/', '/', 'w', 'w', 'w', '.', 'w', '3', '.', 'o', 'r', 'g', '/', '2', '0', '0', '0', '/', 's', 'v', 'g', '\'', '>', 10, ' ', ' ', ' ', ' ', ' ', '<', 'p', 'a', 't', 'h', ' ', 'd', '=', '\'', 'm', '0', ' ', '0', 'v', '1', '6', 'h', '1', 'v', '-', '1', '5', 'h', '1', '5', 'v', '-', '1', 'z', '\'', ' ', 'f', 'i', 'l', 'l', '=', '\'', '#', '9', 'e', '9', 'a', '9', '1', '\'', '/', '>', 10, ' ', ' ', ' ', ' ', ' ', '<', 'p', 'a', 't', 'h', ' ', 'd', '=', '\'', 'm', '1', '5', ' ', '1', 'v', '1', '4', 'h', '-', '1', '4', 'v', '1', 'h', '1', '5', 'v', '-', '1', '5', 'z', '\'', ' ', 'f', 'i', 'l', 'l', '=', '\'', '#', 'c', 'f', 'c', 'd', 'c', '8', '\'', '/', '>', 10, ' ', ' ', ' ', ' ', ' ', '<', 'r', 'e', 'c', 't', ' ', 'x', '=', '\'', '1', '\'', ' ', 'y', '=', '\'', '1', '\'', ' ', 'w', 'i', 'd', 't', 'h', '=', '\'', '1', '4', '\'', ' ', 'h', 'e', 'i', 'g', 'h', 't', '=', '\'', '1', '4', '\'', ' ', 'f', 'i', 'l', 'l', '=', '\'', '#', 'f', 'f', 'f', 'f', 'f', 'f', '\'', '/', '>', 10, ' ', ' ', ' ', ' ', ' ', '<', 'p', 'a', 't', 'h', ' ', 'd', '=', '\'', 'm', '5', ' ', '5', ' ', '6', ' ', '6', 'm', '0', '-', '6', '-', '6', ' ', '6', '\'', ' ', 'f', 'i', 'l', 'l', '=', '\'', 'n', 'o', 'n', 'e', '\'', ' ', 's', 't', 'r', 'o', 'k', 'e', '=', '\'', '#', '0', '0', '0', '0', '0', '0', '\'', ' ', 's', 't', 'r', 'o', 'k', 'e', '-', 'l', 'i', 'n', 'e', 'c', 'a', 'p', '=', '\'', 'r', 'o', 'u', 'n', 'd', '\'', ' ', 's', 't', 'r', 'o', 'k', 'e', '-', 'w', 'i', 'd', 't', 'h', '=', '\'', '2', '\'', '/', '>', 10, ' ', ' ', ' ', ' ', '<', '/', 's', 'v', 'g', '>'} var _checkbutton_spec = TIndicatorSpec{ Fwidth: int32(16), Fheight: int32(16), FoffDataPtr: uintptr(unsafe.Pointer(&_checkbtnOffData)), FonDataPtr: uintptr(unsafe.Pointer(&_checkbtnOnData)), } var _radiobtnOffData = [453]uint8{' ', ' ', ' ', ' ', '<', 's', 'v', 'g', ' ', 'w', 'i', 'd', 't', 'h', '=', '\'', '1', '6', '\'', ' ', 'h', 'e', 'i', 'g', 'h', 't', '=', '\'', '1', '6', '\'', ' ', 'v', 'e', 'r', 's', 'i', 'o', 'n', '=', '\'', '1', '.', '1', '\'', ' ', 'x', 'm', 'l', 'n', 's', '=', '\'', 'h', 't', 't', 'p', ':', '/', '/', 'w', 'w', 'w', '.', 'w', '3', '.', 'o', 'r', 'g', '/', '2', '0', '0', '0', '/', 's', 'v', 'g', '\'', '>', 10, ' ', ' ', ' ', ' ', ' ', '<', 'd', 'e', 'f', 's', '>', 10, ' ', ' ', ' ', ' ', ' ', ' ', '<', 'l', 'i', 'n', 'e', 'a', 'r', 'G', 'r', 'a', 'd', 'i', 'e', 'n', 't', ' ', 'i', 'd', '=', '\'', 'l', 'i', 'n', 'e', 'a', 'r', 'G', 'r', 'a', 'd', 'i', 'e', 'n', 't', '\'', ' ', 'x', '1', '=', '\'', '5', '\'', ' ', 'y', '1', '=', '\'', '5', '\'', ' ', 'x', '2', '=', '\'', '1', '1', '\'', ' ', 'y', '2', '=', '\'', '1', '1', '\'', ' ', 'g', 'r', 'a', 'd', 'i', 'e', 'n', 't', 'U', 'n', 'i', 't', 's', '=', '\'', 'u', 's', 'e', 'r', 'S', 'p', 'a', 'c', 'e', 'O', 'n', 'U', 's', 'e', '\'', '>', 10, ' ', ' ', ' ', ' ', ' ', ' ', ' ', '<', 's', 't', 'o', 'p', ' ', 's', 't', 'o', 'p', '-', 'c', 'o', 'l', 'o', 'r', '=', '\'', '#', '9', 'e', '9', 'a', '9', '1', '\'', ' ', 'o', 'f', 'f', 's', 'e', 't', '=', '\'', '0', '\'', '/', '>', 10, ' ', ' ', ' ', ' ', ' ', ' ', ' ', '<', 's', 't', 'o', 'p', ' ', 's', 't', 'o', 'p', '-', 'c', 'o', 'l', 'o', 'r', '=', '\'', '#', 'c', 'f', 'c', 'd', 'c', '8', '\'', ' ', 'o', 'f', 'f', 's', 'e', 't', '=', '\'', '1', '\'', '/', '>', 10, ' ', ' ', ' ', ' ', ' ', ' ', '<', '/', 'l', 'i', 'n', 'e', 'a', 'r', 'G', 'r', 'a', 'd', 'i', 'e', 'n', 't', '>', 10, ' ', ' ', ' ', ' ', ' ', '<', '/', 'd', 'e', 'f', 's', '>', 10, ' ', ' ', ' ', ' ', ' ', '<', 'c', 'i', 'r', 'c', 'l', 'e', ' ', 'c', 'x', '=', '\'', '8', '\'', ' ', 'c', 'y', '=', '\'', '8', '\'', ' ', 'r', '=', '\'', '8', '\'', ' ', 'f', 'i', 'l', 'l', '=', '\'', 'u', 'r', 'l', '(', '#', 'l', 'i', 'n', 'e', 'a', 'r', 'G', 'r', 'a', 'd', 'i', 'e', 'n', 't', ')', '\'', '/', '>', 10, ' ', ' ', ' ', ' ', ' ', '<', 'c', 'i', 'r', 'c', 'l', 'e', ' ', 'c', 'x', '=', '\'', '8', '\'', ' ', 'c', 'y', '=', '\'', '8', '\'', ' ', 'r', '=', '\'', '7', '\'', ' ', 'f', 'i', 'l', 'l', '=', '\'', '#', 'f', 'f', 'f', 'f', 'f', 'f', '\'', '/', '>', 10, ' ', ' ', ' ', ' ', '<', '/', 's', 'v', 'g', '>'} var _radiobtnOnData = [503]uint8{' ', ' ', ' ', ' ', '<', 's', 'v', 'g', ' ', 'w', 'i', 'd', 't', 'h', '=', '\'', '1', '6', '\'', ' ', 'h', 'e', 'i', 'g', 'h', 't', '=', '\'', '1', '6', '\'', ' ', 'v', 'e', 'r', 's', 'i', 'o', 'n', '=', '\'', '1', '.', '1', '\'', ' ', 'x', 'm', 'l', 'n', 's', '=', '\'', 'h', 't', 't', 'p', ':', '/', '/', 'w', 'w', 'w', '.', 'w', '3', '.', 'o', 'r', 'g', '/', '2', '0', '0', '0', '/', 's', 'v', 'g', '\'', '>', 10, ' ', ' ', ' ', ' ', ' ', '<', 'd', 'e', 'f', 's', '>', 10, ' ', ' ', ' ', ' ', ' ', ' ', '<', 'l', 'i', 'n', 'e', 'a', 'r', 'G', 'r', 'a', 'd', 'i', 'e', 'n', 't', ' ', 'i', 'd', '=', '\'', 'l', 'i', 'n', 'e', 'a', 'r', 'G', 'r', 'a', 'd', 'i', 'e', 'n', 't', '\'', ' ', 'x', '1', '=', '\'', '5', '\'', ' ', 'y', '1', '=', '\'', '5', '\'', ' ', 'x', '2', '=', '\'', '1', '1', '\'', ' ', 'y', '2', '=', '\'', '1', '1', '\'', ' ', 'g', 'r', 'a', 'd', 'i', 'e', 'n', 't', 'U', 'n', 'i', 't', 's', '=', '\'', 'u', 's', 'e', 'r', 'S', 'p', 'a', 'c', 'e', 'O', 'n', 'U', 's', 'e', '\'', '>', 10, ' ', ' ', ' ', ' ', ' ', ' ', ' ', '<', 's', 't', 'o', 'p', ' ', 's', 't', 'o', 'p', '-', 'c', 'o', 'l', 'o', 'r', '=', '\'', '#', '9', 'e', '9', 'a', '9', '1', '\'', ' ', 'o', 'f', 'f', 's', 'e', 't', '=', '\'', '0', '\'', '/', '>', 10, ' ', ' ', ' ', ' ', ' ', ' ', ' ', '<', 's', 't', 'o', 'p', ' ', 's', 't', 'o', 'p', '-', 'c', 'o', 'l', 'o', 'r', '=', '\'', '#', 'c', 'f', 'c', 'd', 'c', '8', '\'', ' ', 'o', 'f', 'f', 's', 'e', 't', '=', '\'', '1', '\'', '/', '>', 10, ' ', ' ', ' ', ' ', ' ', ' ', '<', '/', 'l', 'i', 'n', 'e', 'a', 'r', 'G', 'r', 'a', 'd', 'i', 'e', 'n', 't', '>', 10, ' ', ' ', ' ', ' ', ' ', '<', '/', 'd', 'e', 'f', 's', '>', 10, ' ', ' ', ' ', ' ', ' ', '<', 'c', 'i', 'r', 'c', 'l', 'e', ' ', 'c', 'x', '=', '\'', '8', '\'', ' ', 'c', 'y', '=', '\'', '8', '\'', ' ', 'r', '=', '\'', '8', '\'', ' ', 'f', 'i', 'l', 'l', '=', '\'', 'u', 'r', 'l', '(', '#', 'l', 'i', 'n', 'e', 'a', 'r', 'G', 'r', 'a', 'd', 'i', 'e', 'n', 't', ')', '\'', '/', '>', 10, ' ', ' ', ' ', ' ', ' ', '<', 'c', 'i', 'r', 'c', 'l', 'e', ' ', 'c', 'x', '=', '\'', '8', '\'', ' ', 'c', 'y', '=', '\'', '8', '\'', ' ', 'r', '=', '\'', '7', '\'', ' ', 'f', 'i', 'l', 'l', '=', '\'', '#', 'f', 'f', 'f', 'f', 'f', 'f', '\'', '/', '>', 10, ' ', ' ', ' ', ' ', ' ', '<', 'c', 'i', 'r', 'c', 'l', 'e', ' ', 'c', 'x', '=', '\'', '8', '\'', ' ', 'c', 'y', '=', '\'', '8', '\'', ' ', 'r', '=', '\'', '4', '\'', ' ', 'f', 'i', 'l', 'l', '=', '\'', '#', '0', '0', '0', '0', '0', '0', '\'', '/', '>', 10, ' ', ' ', ' ', ' ', '<', '/', 's', 'v', 'g', '>'} var _radiobutton_spec = TIndicatorSpec{ Fwidth: int32(16), Fheight: int32(16), FoffDataPtr: uintptr(unsafe.Pointer(&_radiobtnOffData)), FonDataPtr: uintptr(unsafe.Pointer(&_radiobtnOnData)), } type TIndicatorElement = struct { FmarginObj uintptr FbackgroundObj uintptr FforegroundObj uintptr FupperColorObj uintptr FlowerColorObj uintptr } var _IndicatorElementOptions = [6]TTtk_ElementOptionSpec{ 0: { FoptionName: __ccgo_ts + 49795, Ftype1: int32(TK_OPTION_STRING), FdefaultValue: __ccgo_ts + 14538, }, 1: { FoptionName: __ccgo_ts + 49812, Ftype1: int32(TK_OPTION_COLOR), Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 8)), FdefaultValue: __ccgo_ts + 39093, }, 2: { FoptionName: __ccgo_ts + 49833, Ftype1: int32(TK_OPTION_COLOR), Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 16)), FdefaultValue: __ccgo_ts + 39099, }, 3: { FoptionName: __ccgo_ts + 49854, Ftype1: int32(TK_OPTION_COLOR), Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 24)), FdefaultValue: __ccgo_ts + 49739, }, 4: { FoptionName: __ccgo_ts + 49872, Ftype1: int32(TK_OPTION_COLOR), Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 32)), FdefaultValue: __ccgo_ts + 49770, }, 5: {}, } func _IndicatorElementSize(tls *libc.TLS, clientData uintptr, elementRecord uintptr, tkwin TTk_Window, widthPtr uintptr, heightPtr uintptr, dummy373 uintptr) { bp := tls.Alloc(16) defer tls.Free(16) var indicator, spec uintptr var scalingLevel float64 var _ /* margins at bp+0 */ TTtk_Padding _, _, _ = indicator, scalingLevel, spec spec = clientData indicator = elementRecord scalingLevel = XTkScalingLevel(tls, tkwin) XTtk_GetPaddingFromObj(tls, libc.UintptrFromInt32(0), tkwin, (*TIndicatorElement)(unsafe.Pointer(indicator)).FmarginObj, bp) *(*int32)(unsafe.Pointer(widthPtr)) = int32(float64(float64((*TIndicatorSpec)(unsafe.Pointer(spec)).Fwidth)*scalingLevel) + float64(int32((*(*TTtk_Padding)(unsafe.Pointer(bp))).Fleft)+int32((*(*TTtk_Padding)(unsafe.Pointer(bp))).Fright))) *(*int32)(unsafe.Pointer(heightPtr)) = int32(float64(float64((*TIndicatorSpec)(unsafe.Pointer(spec)).Fheight)*scalingLevel) + float64(int32((*(*TTtk_Padding)(unsafe.Pointer(bp))).Ftop)+int32((*(*TTtk_Padding)(unsafe.Pointer(bp))).Fbottom))) } func _ColorToStr(tls *libc.TLS, colorPtr uintptr, colorStr uintptr) { bp := tls.Alloc(32) defer tls.Free(32) /* in the format "RRGGBB" */ libc.X__builtin_snprintf(tls, colorStr, uint64(7), __ccgo_ts+49890, libc.VaList(bp+8, libc.Int32FromUint16((*TXColor)(unsafe.Pointer(colorPtr)).Fred)>>int32(8), libc.Int32FromUint16((*TXColor)(unsafe.Pointer(colorPtr)).Fgreen)>>int32(8), libc.Int32FromUint16((*TXColor)(unsafe.Pointer(colorPtr)).Fblue)>>int32(8))) } func _ImageChanged(tls *libc.TLS, dummy393 uintptr, dummy394 int32, dummy395 int32, dummy396 int32, dummy397 int32, dummy398 int32, dummy399 int32) { } func _IndicatorElementDraw(tls *libc.TLS, clientData uintptr, elementRecord uintptr, tkwin TTk_Window, d TDrawable, b TTtk_Box, state TTtk_State) { bp := tls.Alloc(160) defer tls.Free(160) var bgColorPtr, cmdFmt, fgColorPtr, indicator, interp, lowerBdColorPtr, script, spec, svgDataCopy, svgDataPtr, upperBdColorPtr, v1, v2 uintptr var code, height, width int32 var img TTk_Image var scalingLevel float64 var scriptSize, svgDataLen Tsize_t var selected uint32 var _ /* bgColorStr at bp+28 */ [7]uint8 var _ /* fgColorStr at bp+35 */ [7]uint8 var _ /* imgName at bp+42 */ [60]uint8 var _ /* lowerBdColorStr at bp+21 */ [7]uint8 var _ /* padding at bp+0 */ TTtk_Padding var _ /* upperBdColorStr at bp+14 */ [7]uint8 _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = bgColorPtr, cmdFmt, code, fgColorPtr, height, img, indicator, interp, lowerBdColorPtr, scalingLevel, script, scriptSize, selected, spec, svgDataCopy, svgDataLen, svgDataPtr, upperBdColorPtr, width, v1, v2 indicator = elementRecord spec = clientData scalingLevel = XTkScalingLevel(tls, tkwin) width = int32(float64((*TIndicatorSpec)(unsafe.Pointer(spec)).Fwidth) * scalingLevel) height = int32(float64((*TIndicatorSpec)(unsafe.Pointer(spec)).Fheight) * scalingLevel) selected = state & libc.Uint32FromInt32(libc.Int32FromInt32(1)< int32(4) && b.Fheight > int32(4) { _DrawSmoothBorder(tls, tkwin, d, b, (*TScrollbarElement)(unsafe.Pointer(sb)).FborderColorObj, (*TScrollbarElement)(unsafe.Pointer(sb)).FlightColorObj, (*TScrollbarElement)(unsafe.Pointer(sb)).FdarkColorObj) libx11.XXFillRectangle(tls, (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fdisplay, d, _BackgroundGC(tls, tkwin, (*TScrollbarElement)(unsafe.Pointer(sb)).FbackgroundObj), b.Fx+int32(2), b.Fy+int32(2), libc.Uint32FromInt32(b.Fwidth-int32(4)), libc.Uint32FromInt32(b.Fheight-int32(4))) } } var _PbarElementSpec = TTtk_ElementSpec{ Fversion: int32(TK_STYLE_VERSION_2), FelementSize: uint64(80), Foptions: uintptr(unsafe.Pointer(&_ScrollbarElementOptions)), } func init() { p := unsafe.Pointer(&_PbarElementSpec) *(*uintptr)(unsafe.Add(p, 24)) = __ccgo_fp(_PbarElementSize) *(*uintptr)(unsafe.Add(p, 32)) = __ccgo_fp(_PbarElementDraw) } // C documentation // // /*------------------------------------------------------------------------ // * +++ Scrollbar arrows. // */ func _ArrowElementSize(tls *libc.TLS, clientData uintptr, elementRecord uintptr, tkwin TTk_Window, widthPtr uintptr, heightPtr uintptr, dummy845 uintptr) { bp := tls.Alloc(16) defer tls.Free(16) var direction TArrowDirection var padding TTtk_Padding var sb uintptr var scalingLevel float64 var _ /* size at bp+0 */ int32 _, _, _, _ = direction, padding, sb, scalingLevel sb = elementRecord direction = int32(int64(clientData)) scalingLevel = XTkScalingLevel(tls, tkwin) padding = XTtk_UniformPadding(tls, int16(libc.X__builtin_round(tls, float64(libc.Float64FromInt32(3)*scalingLevel)))) *(*int32)(unsafe.Pointer(bp)) = int32(SCROLLBAR_THICKNESS) XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), tkwin, (*TScrollbarElement)(unsafe.Pointer(sb)).FarrowSizeObj, bp) *(*int32)(unsafe.Pointer(bp)) -= int32(padding.Fleft) + int32(padding.Fright) XTtkArrowSize(tls, *(*int32)(unsafe.Pointer(bp))/int32(2), direction, widthPtr, heightPtr) *(*int32)(unsafe.Pointer(widthPtr)) += int32(padding.Fleft) + int32(padding.Fright) *(*int32)(unsafe.Pointer(heightPtr)) += int32(padding.Ftop) + int32(padding.Fbottom) if *(*int32)(unsafe.Pointer(widthPtr)) < *(*int32)(unsafe.Pointer(heightPtr)) { *(*int32)(unsafe.Pointer(widthPtr)) = *(*int32)(unsafe.Pointer(heightPtr)) } else { *(*int32)(unsafe.Pointer(heightPtr)) = *(*int32)(unsafe.Pointer(widthPtr)) } } func _ArrowElementDraw(tls *libc.TLS, clientData uintptr, elementRecord uintptr, tkwin TTk_Window, d TDrawable, b TTtk_Box, dummy868 TTtk_State) { bp := tls.Alloc(16) defer tls.Free(16) var direction TArrowDirection var gc TGC var padding TTtk_Padding var sb uintptr var scalingLevel float64 var _ /* cx at bp+0 */ int32 var _ /* cy at bp+4 */ int32 _, _, _, _, _ = direction, gc, padding, sb, scalingLevel sb = elementRecord direction = int32(int64(clientData)) scalingLevel = XTkScalingLevel(tls, tkwin) padding = XTtk_UniformPadding(tls, int16(libc.X__builtin_round(tls, float64(libc.Float64FromInt32(3)*scalingLevel)))) gc = _Ttk_GCForColor(tls, tkwin, (*TScrollbarElement)(unsafe.Pointer(sb)).FarrowColorObj, d) _DrawSmoothBorder(tls, tkwin, d, b, (*TScrollbarElement)(unsafe.Pointer(sb)).FborderColorObj, (*TScrollbarElement)(unsafe.Pointer(sb)).FlightColorObj, (*TScrollbarElement)(unsafe.Pointer(sb)).FdarkColorObj) libx11.XXFillRectangle(tls, (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fdisplay, d, _BackgroundGC(tls, tkwin, (*TScrollbarElement)(unsafe.Pointer(sb)).FbackgroundObj), b.Fx+int32(2), b.Fy+int32(2), libc.Uint32FromInt32(b.Fwidth-int32(4)), libc.Uint32FromInt32(b.Fheight-int32(4))) b = XTtk_PadBox(tls, b, padding) switch direction { case int32(ARROW_UP): fallthrough case int32(ARROW_DOWN): XTtkArrowSize(tls, b.Fwidth/int32(2), direction, bp, bp+4) if (b.Fheight-*(*int32)(unsafe.Pointer(bp + 4)))%int32(2) == int32(1) { *(*int32)(unsafe.Pointer(bp + 4))++ } case int32(ARROW_LEFT): fallthrough case int32(ARROW_RIGHT): XTtkArrowSize(tls, b.Fheight/int32(2), direction, bp, bp+4) if (b.Fwidth-*(*int32)(unsafe.Pointer(bp)))%int32(2) == int32(1) { *(*int32)(unsafe.Pointer(bp))++ } break } b = XTtk_AnchorBox(tls, b, *(*int32)(unsafe.Pointer(bp)), *(*int32)(unsafe.Pointer(bp + 4)), int32(TK_ANCHOR_CENTER)) XTtkFillArrow(tls, (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fdisplay, d, gc, b, direction) } var _ArrowElementSpec = TTtk_ElementSpec{ Fversion: int32(TK_STYLE_VERSION_2), FelementSize: uint64(80), Foptions: uintptr(unsafe.Pointer(&_ScrollbarElementOptions)), } func init() { p := unsafe.Pointer(&_ArrowElementSpec) *(*uintptr)(unsafe.Add(p, 24)) = __ccgo_fp(_ArrowElementSize) *(*uintptr)(unsafe.Add(p, 32)) = __ccgo_fp(_ArrowElementDraw) } // C documentation // // /* // * Modified arrow element for spinboxes: // * The width and height are different. // */ func _SpinboxArrowElementSize(tls *libc.TLS, clientData uintptr, elementRecord uintptr, tkwin TTk_Window, widthPtr uintptr, heightPtr uintptr, dummy923 uintptr) { bp := tls.Alloc(16) defer tls.Free(16) var direction TArrowDirection var padding TTtk_Padding var sb uintptr var scalingLevel float64 var _ /* size at bp+0 */ int32 _, _, _, _ = direction, padding, sb, scalingLevel sb = elementRecord direction = int32(int64(clientData)) scalingLevel = XTkScalingLevel(tls, tkwin) padding = XTtk_UniformPadding(tls, int16(libc.X__builtin_round(tls, float64(libc.Float64FromInt32(3)*scalingLevel)))) *(*int32)(unsafe.Pointer(bp)) = int32(10) XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), tkwin, (*TScrollbarElement)(unsafe.Pointer(sb)).FarrowSizeObj, bp) *(*int32)(unsafe.Pointer(bp)) -= int32(padding.Fleft) + int32(padding.Fright) XTtkArrowSize(tls, *(*int32)(unsafe.Pointer(bp))/int32(2), direction, widthPtr, heightPtr) *(*int32)(unsafe.Pointer(widthPtr)) += int32(padding.Fleft) + int32(padding.Fright) *(*int32)(unsafe.Pointer(heightPtr)) += int32(padding.Ftop) + int32(padding.Fbottom) } var _SpinboxArrowElementSpec = TTtk_ElementSpec{ Fversion: int32(TK_STYLE_VERSION_2), FelementSize: uint64(80), Foptions: uintptr(unsafe.Pointer(&_ScrollbarElementOptions)), } func init() { p := unsafe.Pointer(&_SpinboxArrowElementSpec) *(*uintptr)(unsafe.Add(p, 24)) = __ccgo_fp(_SpinboxArrowElementSize) *(*uintptr)(unsafe.Add(p, 32)) = __ccgo_fp(_ArrowElementDraw) } /*------------------------------------------------------------------------ * +++ Notebook elements. * * Note: Tabs, except for the rightmost, overlap the neighbor to * their right by one pixel. */ type TNotebookElement = struct { FbackgroundObj uintptr FborderColorObj uintptr FlightColorObj uintptr FdarkColorObj uintptr } var _NotebookElementOptions = [5]TTtk_ElementOptionSpec{ 0: { FoptionName: __ccgo_ts + 19898, Ftype1: int32(TK_OPTION_BORDER), FdefaultValue: __ccgo_ts + 50053, }, 1: { FoptionName: __ccgo_ts + 49726, Ftype1: int32(TK_OPTION_COLOR), Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 8)), FdefaultValue: __ccgo_ts + 49739, }, 2: { FoptionName: __ccgo_ts + 49747, Ftype1: int32(TK_OPTION_COLOR), Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 16)), FdefaultValue: __ccgo_ts + 19883, }, 3: { FoptionName: __ccgo_ts + 49759, Ftype1: int32(TK_OPTION_COLOR), Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 24)), FdefaultValue: __ccgo_ts + 49770, }, 4: {}, } func _TabElementSize(tls *libc.TLS, dummy973 uintptr, dummy974 uintptr, tkwin TTk_Window, dummy976 uintptr, dummy977 uintptr, paddingPtr uintptr) { var borderWidth int32 var mainInfoPtr uintptr var nbTabsStickBit TTtk_PositionSpec _, _, _ = borderWidth, mainInfoPtr, nbTabsStickBit nbTabsStickBit = libc.Uint32FromInt32(libc.Int32FromInt32(TTK_STICK_S)) mainInfoPtr = (*TTkWindow)(unsafe.Pointer(tkwin)).FmainPtr borderWidth = int32(2) if mainInfoPtr != libc.UintptrFromInt32(0) { nbTabsStickBit = (*TTkMainInfo)(unsafe.Pointer(mainInfoPtr)).FttkNbTabsStickBit } *(*TTtk_Padding)(unsafe.Pointer(paddingPtr)) = XTtk_UniformPadding(tls, int16(borderWidth)) switch nbTabsStickBit { default: fallthrough case libc.Uint32FromInt32(libc.Int32FromInt32(TTK_STICK_S)): (*TTtk_Padding)(unsafe.Pointer(paddingPtr)).Fbottom = 0 case libc.Uint32FromInt32(libc.Int32FromInt32(TTK_STICK_N)): (*TTtk_Padding)(unsafe.Pointer(paddingPtr)).Ftop = 0 case libc.Uint32FromInt32(libc.Int32FromInt32(TTK_STICK_E)): (*TTtk_Padding)(unsafe.Pointer(paddingPtr)).Fright = 0 case libc.Uint32FromInt32(libc.Int32FromInt32(TTK_STICK_W)): (*TTtk_Padding)(unsafe.Pointer(paddingPtr)).Fleft = 0 break } } func _TabElementDraw(tls *libc.TLS, dummy1007 uintptr, elementRecord uintptr, tkwin TTk_Window, d TDrawable, b TTtk_Box, state TTtk_State) { var border TTk_3DBorder var borderWidth, delta, w, x1, x2, y1, y2 int32 var display, mainInfoPtr, tab uintptr var gc TGC var nbTabsStickBit TTtk_PositionSpec _, _, _, _, _, _, _, _, _, _, _, _, _ = border, borderWidth, delta, display, gc, mainInfoPtr, nbTabsStickBit, tab, w, x1, x2, y1, y2 nbTabsStickBit = libc.Uint32FromInt32(libc.Int32FromInt32(TTK_STICK_S)) mainInfoPtr = (*TTkWindow)(unsafe.Pointer(tkwin)).FmainPtr borderWidth = int32(2) delta = 0 tab = elementRecord border = XTk_Get3DBorderFromObj(tls, tkwin, (*TNotebookElement)(unsafe.Pointer(tab)).FbackgroundObj) display = (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fdisplay w = WIN32_XDRAWLINE_HACK if mainInfoPtr != libc.UintptrFromInt32(0) { nbTabsStickBit = (*TTkMainInfo)(unsafe.Pointer(mainInfoPtr)).FttkNbTabsStickBit } if state&libc.Uint32FromInt32(libc.Int32FromInt32(1)< 0 { XTtk_GetButtonDefaultStateFromObj(tls, libc.UintptrFromInt32(0), (*THighlightElement)(unsafe.Pointer(hl)).FdefaultStateObj, bp+4) gc = XTk_GCForColor(tls, highlightColor, d) if *(*TTtk_ButtonDefaultState)(unsafe.Pointer(bp + 4)) == int32(TTK_BUTTON_DEFAULT_NORMAL) { XTkDrawInsetFocusHighlight(tls, tkwin, gc, *(*int32)(unsafe.Pointer(bp)), d, int32(libc.X__builtin_round(tls, float64(libc.Float64FromInt32(5)*XTkScalingLevel(tls, tkwin))))) } else { XTk_DrawFocusHighlight(tls, tkwin, gc, *(*int32)(unsafe.Pointer(bp)), d) } } } var _HighlightElementSpec = TTtk_ElementSpec{ Fversion: int32(TK_STYLE_VERSION_2), FelementSize: uint64(24), Foptions: uintptr(unsafe.Pointer(&_HighlightElementOptions)), } func init() { p := unsafe.Pointer(&_HighlightElementSpec) *(*uintptr)(unsafe.Add(p, 24)) = __ccgo_fp(_HighlightElementSize) *(*uintptr)(unsafe.Add(p, 32)) = __ccgo_fp(_HighlightElementDraw) } /*------------------------------------------------------------------------ * +++ Button Border element: * * The Motif-style button border on X11 consists of (from outside-in): * * + focus indicator (controlled by -highlightcolor and -highlightthickness), * + default ring (if -default active; blank if -default normal) * + shaded border (controlled by -background, -borderwidth, and -relief) */ type TButtonBorderElement = struct { FborderObj uintptr FborderWidthObj uintptr FreliefObj uintptr FdefaultStateObj uintptr } var _ButtonBorderElementOptions = [5]TTtk_ElementOptionSpec{ 0: { FoptionName: __ccgo_ts + 19898, Ftype1: int32(TK_OPTION_BORDER), FdefaultValue: __ccgo_ts + 19921, }, 1: { FoptionName: __ccgo_ts + 2814, Ftype1: int32(TK_OPTION_PIXELS), Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 8)), FdefaultValue: __ccgo_ts + 21412, }, 2: { FoptionName: __ccgo_ts + 20346, Ftype1: int32(TK_OPTION_RELIEF), Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 16)), FdefaultValue: __ccgo_ts, }, 3: { FoptionName: __ccgo_ts + 16738, Ftype1: int32(TK_OPTION_STRING), Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 24)), FdefaultValue: __ccgo_ts + 16715, }, 4: {}, } func _ButtonBorderElementSize(tls *libc.TLS, dummy117 uintptr, elementRecord uintptr, tkwin TTk_Window, dummy120 uintptr, dummy121 uintptr, paddingPtr uintptr) { bp := tls.Alloc(16) defer tls.Free(16) var bd uintptr var _ /* borderWidth at bp+4 */ int32 var _ /* defaultState at bp+0 */ TTtk_ButtonDefaultState _ = bd bd = elementRecord *(*TTtk_ButtonDefaultState)(unsafe.Pointer(bp)) = int32(TTK_BUTTON_DEFAULT_DISABLED) *(*int32)(unsafe.Pointer(bp + 4)) = 0 XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), tkwin, (*TButtonBorderElement)(unsafe.Pointer(bd)).FborderWidthObj, bp+4) XTtk_GetButtonDefaultStateFromObj(tls, libc.UintptrFromInt32(0), (*TButtonBorderElement)(unsafe.Pointer(bd)).FdefaultStateObj, bp) if *(*TTtk_ButtonDefaultState)(unsafe.Pointer(bp)) != int32(TTK_BUTTON_DEFAULT_DISABLED) { *(*int32)(unsafe.Pointer(bp + 4)) = int32(float64(*(*int32)(unsafe.Pointer(bp + 4))) + libc.X__builtin_round(tls, float64(libc.Float64FromInt32(5)*XTkScalingLevel(tls, tkwin)))) } *(*TTtk_Padding)(unsafe.Pointer(paddingPtr)) = XTtk_UniformPadding(tls, int16(*(*int32)(unsafe.Pointer(bp + 4)))) } // C documentation // // /* // * (@@@ Note: ButtonBorderElement still still still buggy: // * padding for default ring is drawn in the wrong color // * when the button is active.) // */ func _ButtonBorderElementDraw(tls *libc.TLS, dummy143 uintptr, elementRecord uintptr, tkwin TTk_Window, d TDrawable, b TTtk_Box, dummy148 TTtk_State) { bp := tls.Alloc(16) defer tls.Free(16) var bd uintptr var border TTk_3DBorder var inset int32 var _ /* borderWidth at bp+0 */ int32 var _ /* defaultState at bp+8 */ TTtk_ButtonDefaultState var _ /* relief at bp+4 */ int32 _, _, _ = bd, border, inset bd = elementRecord border = libc.UintptrFromInt32(0) *(*int32)(unsafe.Pointer(bp)) = int32(1) *(*int32)(unsafe.Pointer(bp + 4)) = TK_RELIEF_FLAT *(*TTtk_ButtonDefaultState)(unsafe.Pointer(bp + 8)) = int32(TTK_BUTTON_DEFAULT_DISABLED) inset = 0 /* * Get option values. */ border = XTk_Get3DBorderFromObj(tls, tkwin, (*TButtonBorderElement)(unsafe.Pointer(bd)).FborderObj) XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), tkwin, (*TButtonBorderElement)(unsafe.Pointer(bd)).FborderWidthObj, bp) XTk_GetReliefFromObj(tls, libc.UintptrFromInt32(0), (*TButtonBorderElement)(unsafe.Pointer(bd)).FreliefObj, bp+4) XTtk_GetButtonDefaultStateFromObj(tls, libc.UintptrFromInt32(0), (*TButtonBorderElement)(unsafe.Pointer(bd)).FdefaultStateObj, bp+8) /* * Default ring: */ switch *(*TTtk_ButtonDefaultState)(unsafe.Pointer(bp + 8)) { case int32(TTK_BUTTON_DEFAULT_DISABLED): case int32(TTK_BUTTON_DEFAULT_NORMAL): inset = int32(float64(inset) + libc.X__builtin_round(tls, float64(libc.Float64FromInt32(5)*XTkScalingLevel(tls, tkwin)))) case int32(TTK_BUTTON_DEFAULT_ACTIVE): XTk_Draw3DRectangle(tls, tkwin, d, border, b.Fx+inset, b.Fy+inset, b.Fwidth-int32(2)*inset, b.Fheight-int32(2)*inset, int32(2), TK_RELIEF_FLAT) inset += int32(2) XTk_Draw3DRectangle(tls, tkwin, d, border, b.Fx+inset, b.Fy+inset, b.Fwidth-int32(2)*inset, b.Fheight-int32(2)*inset, int32(1), int32(TK_RELIEF_SUNKEN)) inset++ XTk_Draw3DRectangle(tls, tkwin, d, border, b.Fx+inset, b.Fy+inset, b.Fwidth-int32(2)*inset, b.Fheight-int32(2)*inset, int32(2), TK_RELIEF_FLAT) inset += int32(2) break } /* * 3-D border: */ if border != 0 && *(*int32)(unsafe.Pointer(bp)) > 0 { XTk_Draw3DRectangle(tls, tkwin, d, border, b.Fx+inset, b.Fy+inset, b.Fwidth-int32(2)*inset, b.Fheight-int32(2)*inset, *(*int32)(unsafe.Pointer(bp)), *(*int32)(unsafe.Pointer(bp + 4))) } } var _ButtonBorderElementSpec = TTtk_ElementSpec{ Fversion: int32(TK_STYLE_VERSION_2), FelementSize: uint64(32), Foptions: uintptr(unsafe.Pointer(&_ButtonBorderElementOptions)), } func init() { p := unsafe.Pointer(&_ButtonBorderElementSpec) *(*uintptr)(unsafe.Add(p, 24)) = __ccgo_fp(_ButtonBorderElementSize) *(*uintptr)(unsafe.Add(p, 32)) = __ccgo_fp(_ButtonBorderElementDraw) } /*---------------------------------------------------------------------- * +++ Indicator element. * * Draws the on/off indicator for checkbuttons and radiobuttons. * * Draws a 3-D square (or diamond), raised if off, sunken if on. * * This is actually a regression from Tk 8.5 back to the ugly old Motif * style; use the "alt", "clam", or "default" theme" for newer, nicer * versions. */ type TIndicatorElement1 = struct { FbackgroundObj uintptr FreliefObj uintptr FcolorObj uintptr FsizeObj uintptr FmarginObj uintptr FborderWidthObj uintptr } var _IndicatorElementOptions1 = [7]TTtk_ElementOptionSpec{ 0: { FoptionName: __ccgo_ts + 19898, Ftype1: int32(TK_OPTION_BORDER), FdefaultValue: __ccgo_ts + 19921, }, 1: { FoptionName: __ccgo_ts + 50394, Ftype1: int32(TK_OPTION_BORDER), Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 16)), FdefaultValue: __ccgo_ts + 19921, }, 2: { FoptionName: __ccgo_ts + 50410, Ftype1: int32(TK_OPTION_RELIEF), Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 8)), FdefaultValue: __ccgo_ts + 12, }, 3: { FoptionName: __ccgo_ts + 50427, Ftype1: int32(TK_OPTION_PIXELS), Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 24)), FdefaultValue: __ccgo_ts + 50442, }, 4: { FoptionName: __ccgo_ts + 49795, Ftype1: int32(TK_OPTION_STRING), Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 32)), FdefaultValue: __ccgo_ts + 50445, }, 5: { FoptionName: __ccgo_ts + 2814, Ftype1: int32(TK_OPTION_PIXELS), Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 40)), FdefaultValue: __ccgo_ts + 21412, }, 6: {}, } // C documentation // // /* // * Checkbutton indicators: 3-D square. // */ func _SquareIndicatorElementSize(tls *libc.TLS, dummy250 uintptr, elementRecord uintptr, tkwin TTk_Window, widthPtr uintptr, heightPtr uintptr, dummy255 uintptr) { bp := tls.Alloc(16) defer tls.Free(16) var indicator uintptr var _ /* diameter at bp+8 */ int32 var _ /* margins at bp+0 */ TTtk_Padding _ = indicator indicator = elementRecord *(*int32)(unsafe.Pointer(bp + 8)) = 0 XTtk_GetPaddingFromObj(tls, libc.UintptrFromInt32(0), tkwin, (*TIndicatorElement1)(unsafe.Pointer(indicator)).FmarginObj, bp) XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), tkwin, (*TIndicatorElement1)(unsafe.Pointer(indicator)).FsizeObj, bp+8) *(*int32)(unsafe.Pointer(widthPtr)) = *(*int32)(unsafe.Pointer(bp + 8)) + (int32((*(*TTtk_Padding)(unsafe.Pointer(bp))).Fleft) + int32((*(*TTtk_Padding)(unsafe.Pointer(bp))).Fright)) *(*int32)(unsafe.Pointer(heightPtr)) = *(*int32)(unsafe.Pointer(bp + 8)) + (int32((*(*TTtk_Padding)(unsafe.Pointer(bp))).Ftop) + int32((*(*TTtk_Padding)(unsafe.Pointer(bp))).Fbottom)) } func _SquareIndicatorElementDraw(tls *libc.TLS, dummy268 uintptr, elementRecord uintptr, tkwin TTk_Window, d TDrawable, b TTtk_Box, dummy273 TTtk_State) { bp := tls.Alloc(32) defer tls.Free(32) var border, interior TTk_3DBorder var diameter, v1 int32 var indicator uintptr var _ /* borderWidth at bp+16 */ int32 var _ /* padding at bp+8 */ TTtk_Padding var _ /* relief at bp+0 */ int32 _, _, _, _, _ = border, diameter, indicator, interior, v1 indicator = elementRecord border = uintptr(0) interior = uintptr(0) *(*int32)(unsafe.Pointer(bp)) = int32(TK_RELIEF_RAISED) *(*int32)(unsafe.Pointer(bp + 16)) = int32(2) interior = XTk_Get3DBorderFromObj(tls, tkwin, (*TIndicatorElement1)(unsafe.Pointer(indicator)).FcolorObj) border = XTk_Get3DBorderFromObj(tls, tkwin, (*TIndicatorElement1)(unsafe.Pointer(indicator)).FbackgroundObj) XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), tkwin, (*TIndicatorElement1)(unsafe.Pointer(indicator)).FborderWidthObj, bp+16) XTk_GetReliefFromObj(tls, libc.UintptrFromInt32(0), (*TIndicatorElement1)(unsafe.Pointer(indicator)).FreliefObj, bp) XTtk_GetPaddingFromObj(tls, libc.UintptrFromInt32(0), tkwin, (*TIndicatorElement1)(unsafe.Pointer(indicator)).FmarginObj, bp+8) b = XTtk_PadBox(tls, b, *(*TTtk_Padding)(unsafe.Pointer(bp + 8))) if b.Fwidth < b.Fheight { v1 = b.Fwidth } else { v1 = b.Fheight } diameter = v1 XTk_Fill3DRectangle(tls, tkwin, d, interior, b.Fx, b.Fy, diameter, diameter, *(*int32)(unsafe.Pointer(bp + 16)), TK_RELIEF_FLAT) XTk_Draw3DRectangle(tls, tkwin, d, border, b.Fx, b.Fy, diameter, diameter, *(*int32)(unsafe.Pointer(bp + 16)), *(*int32)(unsafe.Pointer(bp))) } // C documentation // // /* // * Radiobutton indicators: 3-D diamond. // */ func _DiamondIndicatorElementSize(tls *libc.TLS, dummy301 uintptr, elementRecord uintptr, tkwin TTk_Window, widthPtr uintptr, heightPtr uintptr, dummy306 uintptr) { bp := tls.Alloc(16) defer tls.Free(16) var indicator uintptr var _ /* diameter at bp+8 */ int32 var _ /* margins at bp+0 */ TTtk_Padding _ = indicator indicator = elementRecord *(*int32)(unsafe.Pointer(bp + 8)) = 0 XTtk_GetPaddingFromObj(tls, libc.UintptrFromInt32(0), tkwin, (*TIndicatorElement1)(unsafe.Pointer(indicator)).FmarginObj, bp) XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), tkwin, (*TIndicatorElement1)(unsafe.Pointer(indicator)).FsizeObj, bp+8) *(*int32)(unsafe.Pointer(widthPtr)) = *(*int32)(unsafe.Pointer(bp + 8)) + int32(3) + (int32((*(*TTtk_Padding)(unsafe.Pointer(bp))).Fleft) + int32((*(*TTtk_Padding)(unsafe.Pointer(bp))).Fright)) *(*int32)(unsafe.Pointer(heightPtr)) = *(*int32)(unsafe.Pointer(bp + 8)) + int32(3) + (int32((*(*TTtk_Padding)(unsafe.Pointer(bp))).Ftop) + int32((*(*TTtk_Padding)(unsafe.Pointer(bp))).Fbottom)) } func _DiamondIndicatorElementDraw(tls *libc.TLS, dummy319 uintptr, elementRecord uintptr, tkwin TTk_Window, d TDrawable, b TTtk_Box, dummy324 TTtk_State) { bp := tls.Alloc(32) defer tls.Free(32) var border, interior TTk_3DBorder var diameter, radius, v1 int32 var indicator uintptr var _ /* borderWidth at bp+0 */ int32 var _ /* padding at bp+24 */ TTtk_Padding var _ /* points at bp+8 */ [4]TXPoint var _ /* relief at bp+4 */ int32 _, _, _, _, _, _ = border, diameter, indicator, interior, radius, v1 indicator = elementRecord border = uintptr(0) interior = uintptr(0) *(*int32)(unsafe.Pointer(bp)) = int32(2) *(*int32)(unsafe.Pointer(bp + 4)) = int32(TK_RELIEF_RAISED) interior = XTk_Get3DBorderFromObj(tls, tkwin, (*TIndicatorElement1)(unsafe.Pointer(indicator)).FcolorObj) border = XTk_Get3DBorderFromObj(tls, tkwin, (*TIndicatorElement1)(unsafe.Pointer(indicator)).FbackgroundObj) XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), tkwin, (*TIndicatorElement1)(unsafe.Pointer(indicator)).FborderWidthObj, bp) XTk_GetReliefFromObj(tls, libc.UintptrFromInt32(0), (*TIndicatorElement1)(unsafe.Pointer(indicator)).FreliefObj, bp+4) XTtk_GetPaddingFromObj(tls, libc.UintptrFromInt32(0), tkwin, (*TIndicatorElement1)(unsafe.Pointer(indicator)).FmarginObj, bp+24) b = XTtk_PadBox(tls, b, *(*TTtk_Padding)(unsafe.Pointer(bp + 24))) if b.Fwidth < b.Fheight { v1 = b.Fwidth } else { v1 = b.Fheight } diameter = v1 radius = diameter / int32(2) (*(*[4]TXPoint)(unsafe.Pointer(bp + 8)))[0].Fx = int16(b.Fx) (*(*[4]TXPoint)(unsafe.Pointer(bp + 8)))[0].Fy = int16(b.Fy + radius) (*(*[4]TXPoint)(unsafe.Pointer(bp + 8)))[int32(1)].Fx = int16(b.Fx + radius) (*(*[4]TXPoint)(unsafe.Pointer(bp + 8)))[int32(1)].Fy = int16(b.Fy + int32(2)*radius) (*(*[4]TXPoint)(unsafe.Pointer(bp + 8)))[int32(2)].Fx = int16(b.Fx + int32(2)*radius) (*(*[4]TXPoint)(unsafe.Pointer(bp + 8)))[int32(2)].Fy = int16(b.Fy + radius) (*(*[4]TXPoint)(unsafe.Pointer(bp + 8)))[int32(3)].Fx = int16(b.Fx + radius) (*(*[4]TXPoint)(unsafe.Pointer(bp + 8)))[int32(3)].Fy = int16(b.Fy) XTk_Fill3DPolygon(tls, tkwin, d, interior, bp+8, int64(4), *(*int32)(unsafe.Pointer(bp)), TK_RELIEF_FLAT) XTk_Draw3DPolygon(tls, tkwin, d, border, bp+8, int64(4), *(*int32)(unsafe.Pointer(bp)), *(*int32)(unsafe.Pointer(bp + 4))) } var _CheckbuttonIndicatorElementSpec = TTtk_ElementSpec{ Fversion: int32(TK_STYLE_VERSION_2), FelementSize: uint64(48), Foptions: uintptr(unsafe.Pointer(&_IndicatorElementOptions1)), } func init() { p := unsafe.Pointer(&_CheckbuttonIndicatorElementSpec) *(*uintptr)(unsafe.Add(p, 24)) = __ccgo_fp(_SquareIndicatorElementSize) *(*uintptr)(unsafe.Add(p, 32)) = __ccgo_fp(_SquareIndicatorElementDraw) } var _RadiobuttonIndicatorElementSpec = TTtk_ElementSpec{ Fversion: int32(TK_STYLE_VERSION_2), FelementSize: uint64(48), Foptions: uintptr(unsafe.Pointer(&_IndicatorElementOptions1)), } func init() { p := unsafe.Pointer(&_RadiobuttonIndicatorElementSpec) *(*uintptr)(unsafe.Add(p, 24)) = __ccgo_fp(_DiamondIndicatorElementSize) *(*uintptr)(unsafe.Add(p, 32)) = __ccgo_fp(_DiamondIndicatorElementDraw) } /*---------------------------------------------------------------------- * +++ Menubutton indicators. * * These aren't functional like radio/check indicators, * they're just affordability indicators. * * Standard Tk sets the indicator size to 4.0 mm by 1.7 mm. * I have no idea where these numbers came from. */ type TMenuIndicatorElement = struct { FbackgroundObj uintptr FwidthObj uintptr FheightObj uintptr FborderWidthObj uintptr FreliefObj uintptr FmarginObj uintptr } var _MenuIndicatorElementOptions = [7]TTtk_ElementOptionSpec{ 0: { FoptionName: __ccgo_ts + 19898, Ftype1: int32(TK_OPTION_BORDER), FdefaultValue: __ccgo_ts + 19921, }, 1: { FoptionName: __ccgo_ts + 50453, Ftype1: int32(TK_OPTION_PIXELS), Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 8)), FdefaultValue: __ccgo_ts + 50469, }, 2: { FoptionName: __ccgo_ts + 50474, Ftype1: int32(TK_OPTION_PIXELS), Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 16)), FdefaultValue: __ccgo_ts + 50491, }, 3: { FoptionName: __ccgo_ts + 50496, Ftype1: int32(TK_OPTION_PIXELS), Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 24)), FdefaultValue: __ccgo_ts + 21412, }, 4: { FoptionName: __ccgo_ts + 50410, Ftype1: int32(TK_OPTION_RELIEF), Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 32)), FdefaultValue: __ccgo_ts + 12, }, 5: { FoptionName: __ccgo_ts + 49795, Ftype1: int32(TK_OPTION_STRING), Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 40)), FdefaultValue: __ccgo_ts + 50518, }, 6: {}, } func _MenuIndicatorElementSize(tls *libc.TLS, dummy410 uintptr, elementRecord uintptr, tkwin TTk_Window, widthPtr uintptr, heightPtr uintptr, dummy415 uintptr) { bp := tls.Alloc(16) defer tls.Free(16) var mi uintptr var _ /* margins at bp+0 */ TTtk_Padding _ = mi mi = elementRecord XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), tkwin, (*TMenuIndicatorElement)(unsafe.Pointer(mi)).FwidthObj, widthPtr) XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), tkwin, (*TMenuIndicatorElement)(unsafe.Pointer(mi)).FheightObj, heightPtr) XTtk_GetPaddingFromObj(tls, libc.UintptrFromInt32(0), tkwin, (*TMenuIndicatorElement)(unsafe.Pointer(mi)).FmarginObj, bp) *(*int32)(unsafe.Pointer(widthPtr)) += int32((*(*TTtk_Padding)(unsafe.Pointer(bp))).Fleft) + int32((*(*TTtk_Padding)(unsafe.Pointer(bp))).Fright) *(*int32)(unsafe.Pointer(heightPtr)) += int32((*(*TTtk_Padding)(unsafe.Pointer(bp))).Ftop) + int32((*(*TTtk_Padding)(unsafe.Pointer(bp))).Fbottom) } func _MenuIndicatorElementDraw(tls *libc.TLS, dummy428 uintptr, elementRecord uintptr, tkwin TTk_Window, d TDrawable, b TTtk_Box, dummy433 TTtk_State) { bp := tls.Alloc(16) defer tls.Free(16) var border TTk_3DBorder var mi uintptr var _ /* borderWidth at bp+8 */ int32 var _ /* margins at bp+0 */ TTtk_Padding _, _ = border, mi mi = elementRecord border = XTk_Get3DBorderFromObj(tls, tkwin, (*TMenuIndicatorElement)(unsafe.Pointer(mi)).FbackgroundObj) *(*int32)(unsafe.Pointer(bp + 8)) = int32(2) XTtk_GetPaddingFromObj(tls, libc.UintptrFromInt32(0), tkwin, (*TMenuIndicatorElement)(unsafe.Pointer(mi)).FmarginObj, bp) b = XTtk_PadBox(tls, b, *(*TTtk_Padding)(unsafe.Pointer(bp))) XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), tkwin, (*TMenuIndicatorElement)(unsafe.Pointer(mi)).FborderWidthObj, bp+8) XTk_Fill3DRectangle(tls, tkwin, d, border, b.Fx, b.Fy, b.Fwidth, b.Fheight, *(*int32)(unsafe.Pointer(bp + 8)), int32(TK_RELIEF_RAISED)) } var _MenuIndicatorElementSpec = TTtk_ElementSpec{ Fversion: int32(TK_STYLE_VERSION_2), FelementSize: uint64(48), Foptions: uintptr(unsafe.Pointer(&_MenuIndicatorElementOptions)), } func init() { p := unsafe.Pointer(&_MenuIndicatorElementSpec) *(*uintptr)(unsafe.Add(p, 24)) = __ccgo_fp(_MenuIndicatorElementSize) *(*uintptr)(unsafe.Add(p, 32)) = __ccgo_fp(_MenuIndicatorElementDraw) } /*---------------------------------------------------------------------- * +++ Arrow element(s). * * Draws a 3-D shaded triangle. * clientData is an enum ArrowDirection pointer. */ type TArrowElement = struct { FsizeObj uintptr FborderObj uintptr FborderWidthObj uintptr FreliefObj uintptr } var _ArrowElementOptions = [5]TTtk_ElementOptionSpec{ 0: { FoptionName: __ccgo_ts + 50081, Ftype1: int32(TK_OPTION_PIXELS), FdefaultValue: __ccgo_ts + 26163, }, 1: { FoptionName: __ccgo_ts + 19898, Ftype1: int32(TK_OPTION_BORDER), Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 8)), FdefaultValue: __ccgo_ts + 19921, }, 2: { FoptionName: __ccgo_ts + 2814, Ftype1: int32(TK_OPTION_PIXELS), Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 16)), FdefaultValue: __ccgo_ts + 21412, }, 3: { FoptionName: __ccgo_ts + 20346, Ftype1: int32(TK_OPTION_RELIEF), Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 24)), FdefaultValue: __ccgo_ts + 12, }, 4: {}, } func _ArrowElementSize1(tls *libc.TLS, dummy483 uintptr, elementRecord uintptr, tkwin TTk_Window, widthPtr uintptr, heightPtr uintptr, dummy488 uintptr) { bp := tls.Alloc(16) defer tls.Free(16) var arrow uintptr var v1 int32 var _ /* size at bp+0 */ int32 _, _ = arrow, v1 arrow = elementRecord *(*int32)(unsafe.Pointer(bp)) = int32(12) XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), tkwin, (*TArrowElement)(unsafe.Pointer(arrow)).FsizeObj, bp) v1 = *(*int32)(unsafe.Pointer(bp)) *(*int32)(unsafe.Pointer(heightPtr)) = v1 *(*int32)(unsafe.Pointer(widthPtr)) = v1 } func _ArrowElementDraw1(tls *libc.TLS, clientData uintptr, elementRecord uintptr, tkwin TTk_Window, d TDrawable, b TTtk_Box, dummy500 TTtk_State) { bp := tls.Alloc(32) defer tls.Free(32) var arrow uintptr var border TTk_3DBorder var direction TArrowDirection var size, v1 int32 var _ /* borderWidth at bp+0 */ int32 var _ /* points at bp+8 */ [3]TXPoint var _ /* relief at bp+4 */ int32 _, _, _, _, _ = arrow, border, direction, size, v1 direction = int32(int64(clientData)) arrow = elementRecord border = XTk_Get3DBorderFromObj(tls, tkwin, (*TArrowElement)(unsafe.Pointer(arrow)).FborderObj) *(*int32)(unsafe.Pointer(bp)) = int32(2) *(*int32)(unsafe.Pointer(bp + 4)) = int32(TK_RELIEF_RAISED) if b.Fwidth < b.Fheight { v1 = b.Fwidth } else { v1 = b.Fheight } size = v1 XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), tkwin, (*TArrowElement)(unsafe.Pointer(arrow)).FborderWidthObj, bp) XTk_GetReliefFromObj(tls, libc.UintptrFromInt32(0), (*TArrowElement)(unsafe.Pointer(arrow)).FreliefObj, bp+4) /* * @@@ There are off-by-one pixel errors in the way these are drawn; * @@@ need to take a look at Tk_Fill3DPolygon and X11 to find the * @@@ exact rules. */ switch direction { case int32(ARROW_UP): (*(*[3]TXPoint)(unsafe.Pointer(bp + 8)))[int32(2)].Fx = int16(b.Fx) (*(*[3]TXPoint)(unsafe.Pointer(bp + 8)))[int32(2)].Fy = int16(b.Fy + size) (*(*[3]TXPoint)(unsafe.Pointer(bp + 8)))[int32(1)].Fx = int16(b.Fx + size/int32(2)) (*(*[3]TXPoint)(unsafe.Pointer(bp + 8)))[int32(1)].Fy = int16(b.Fy) (*(*[3]TXPoint)(unsafe.Pointer(bp + 8)))[0].Fx = int16(b.Fx + size) (*(*[3]TXPoint)(unsafe.Pointer(bp + 8)))[0].Fy = int16(b.Fy + size) case int32(ARROW_DOWN): (*(*[3]TXPoint)(unsafe.Pointer(bp + 8)))[0].Fx = int16(b.Fx) (*(*[3]TXPoint)(unsafe.Pointer(bp + 8)))[0].Fy = int16(b.Fy) (*(*[3]TXPoint)(unsafe.Pointer(bp + 8)))[int32(1)].Fx = int16(b.Fx + size/int32(2)) (*(*[3]TXPoint)(unsafe.Pointer(bp + 8)))[int32(1)].Fy = int16(b.Fy + size) (*(*[3]TXPoint)(unsafe.Pointer(bp + 8)))[int32(2)].Fx = int16(b.Fx + size) (*(*[3]TXPoint)(unsafe.Pointer(bp + 8)))[int32(2)].Fy = int16(b.Fy) case int32(ARROW_LEFT): (*(*[3]TXPoint)(unsafe.Pointer(bp + 8)))[0].Fx = int16(b.Fx) (*(*[3]TXPoint)(unsafe.Pointer(bp + 8)))[0].Fy = int16(b.Fy + size/int32(2)) (*(*[3]TXPoint)(unsafe.Pointer(bp + 8)))[int32(1)].Fx = int16(b.Fx + size) (*(*[3]TXPoint)(unsafe.Pointer(bp + 8)))[int32(1)].Fy = int16(b.Fy + size) (*(*[3]TXPoint)(unsafe.Pointer(bp + 8)))[int32(2)].Fx = int16(b.Fx + size) (*(*[3]TXPoint)(unsafe.Pointer(bp + 8)))[int32(2)].Fy = int16(b.Fy) case int32(ARROW_RIGHT): (*(*[3]TXPoint)(unsafe.Pointer(bp + 8)))[0].Fx = int16(b.Fx + size) (*(*[3]TXPoint)(unsafe.Pointer(bp + 8)))[0].Fy = int16(b.Fy + size/int32(2)) (*(*[3]TXPoint)(unsafe.Pointer(bp + 8)))[int32(1)].Fx = int16(b.Fx) (*(*[3]TXPoint)(unsafe.Pointer(bp + 8)))[int32(1)].Fy = int16(b.Fy) (*(*[3]TXPoint)(unsafe.Pointer(bp + 8)))[int32(2)].Fx = int16(b.Fx) (*(*[3]TXPoint)(unsafe.Pointer(bp + 8)))[int32(2)].Fy = int16(b.Fy + size) break } XTk_Fill3DPolygon(tls, tkwin, d, border, bp+8, int64(3), *(*int32)(unsafe.Pointer(bp)), *(*int32)(unsafe.Pointer(bp + 4))) } var _ArrowElementSpec1 = TTtk_ElementSpec{ Fversion: int32(TK_STYLE_VERSION_2), FelementSize: uint64(32), Foptions: uintptr(unsafe.Pointer(&_ArrowElementOptions)), } func init() { p := unsafe.Pointer(&_ArrowElementSpec1) *(*uintptr)(unsafe.Add(p, 24)) = __ccgo_fp(_ArrowElementSize1) *(*uintptr)(unsafe.Add(p, 32)) = __ccgo_fp(_ArrowElementDraw1) } /*------------------------------------------------------------------------ * +++ Slider element. * * This is the moving part of the scale widget. Drawn as a raised box. */ type TSliderElement = struct { ForientObj uintptr FlengthObj uintptr FthicknessObj uintptr FreliefObj uintptr FborderObj uintptr FborderWidthObj uintptr } var _SliderElementOptions = [7]TTtk_ElementOptionSpec{ 0: { FoptionName: __ccgo_ts + 26009, Ftype1: int32(TK_OPTION_PIXELS), Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 8)), FdefaultValue: __ccgo_ts + 26049, }, 1: { FoptionName: __ccgo_ts + 50522, Ftype1: int32(TK_OPTION_PIXELS), Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 16)), FdefaultValue: __ccgo_ts + 26163, }, 2: { FoptionName: __ccgo_ts + 26052, Ftype1: int32(TK_OPTION_RELIEF), Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 24)), FdefaultValue: __ccgo_ts + 12, }, 3: { FoptionName: __ccgo_ts + 50539, Ftype1: int32(TK_OPTION_PIXELS), Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 40)), FdefaultValue: __ccgo_ts + 21412, }, 4: { FoptionName: __ccgo_ts + 19898, Ftype1: int32(TK_OPTION_BORDER), Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 32)), FdefaultValue: __ccgo_ts + 19921, }, 5: { FoptionName: __ccgo_ts + 25111, Ftype1: int32(TK_OPTION_STRING), FdefaultValue: __ccgo_ts + 16826, }, 6: {}, } func _SliderElementSize1(tls *libc.TLS, dummy586 uintptr, elementRecord uintptr, tkwin TTk_Window, widthPtr uintptr, heightPtr uintptr, dummy591 uintptr) { bp := tls.Alloc(16) defer tls.Free(16) var slider uintptr var _ /* length at bp+4 */ int32 var _ /* orient at bp+0 */ TTtk_Orient var _ /* thickness at bp+8 */ int32 _ = slider slider = elementRecord XTtk_GetOrientFromObj(tls, libc.UintptrFromInt32(0), (*TSliderElement)(unsafe.Pointer(slider)).ForientObj, bp) XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), tkwin, (*TSliderElement)(unsafe.Pointer(slider)).FlengthObj, bp+4) XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), tkwin, (*TSliderElement)(unsafe.Pointer(slider)).FthicknessObj, bp+8) switch *(*TTtk_Orient)(unsafe.Pointer(bp)) { case int32(TTK_ORIENT_VERTICAL): *(*int32)(unsafe.Pointer(widthPtr)) = *(*int32)(unsafe.Pointer(bp + 8)) *(*int32)(unsafe.Pointer(heightPtr)) = *(*int32)(unsafe.Pointer(bp + 4)) case int32(TTK_ORIENT_HORIZONTAL): *(*int32)(unsafe.Pointer(widthPtr)) = *(*int32)(unsafe.Pointer(bp + 4)) *(*int32)(unsafe.Pointer(heightPtr)) = *(*int32)(unsafe.Pointer(bp + 8)) break } } func _SliderElementDraw(tls *libc.TLS, dummy615 uintptr, elementRecord uintptr, tkwin TTk_Window, d TDrawable, b TTtk_Box, dummy620 TTtk_State) { bp := tls.Alloc(16) defer tls.Free(16) var border TTk_3DBorder var slider uintptr var _ /* borderWidth at bp+4 */ int32 var _ /* orient at bp+8 */ TTtk_Orient var _ /* relief at bp+0 */ int32 _, _ = border, slider slider = elementRecord border = libc.UintptrFromInt32(0) *(*int32)(unsafe.Pointer(bp)) = int32(TK_RELIEF_RAISED) *(*int32)(unsafe.Pointer(bp + 4)) = int32(2) border = XTk_Get3DBorderFromObj(tls, tkwin, (*TSliderElement)(unsafe.Pointer(slider)).FborderObj) XTk_GetReliefFromObj(tls, libc.UintptrFromInt32(0), (*TSliderElement)(unsafe.Pointer(slider)).FreliefObj, bp) XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), tkwin, (*TSliderElement)(unsafe.Pointer(slider)).FborderWidthObj, bp+4) XTtk_GetOrientFromObj(tls, libc.UintptrFromInt32(0), (*TSliderElement)(unsafe.Pointer(slider)).ForientObj, bp+8) XTk_Fill3DRectangle(tls, tkwin, d, border, b.Fx, b.Fy, b.Fwidth, b.Fheight, *(*int32)(unsafe.Pointer(bp + 4)), *(*int32)(unsafe.Pointer(bp))) if *(*int32)(unsafe.Pointer(bp)) != TK_RELIEF_FLAT { if *(*TTtk_Orient)(unsafe.Pointer(bp + 8)) == int32(TTK_ORIENT_HORIZONTAL) { if b.Fwidth > int32(4) { b.Fx += b.Fwidth / int32(2) libx11.XXDrawLine(tls, (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fdisplay, d, XTk_3DBorderGC(tls, tkwin, border, int32(TK_3D_DARK_GC)), b.Fx-int32(1), b.Fy+*(*int32)(unsafe.Pointer(bp + 4)), b.Fx-int32(1), b.Fy+b.Fheight-*(*int32)(unsafe.Pointer(bp + 4))) libx11.XXDrawLine(tls, (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fdisplay, d, XTk_3DBorderGC(tls, tkwin, border, int32(TK_3D_LIGHT_GC)), b.Fx, b.Fy+*(*int32)(unsafe.Pointer(bp + 4)), b.Fx, b.Fy+b.Fheight-*(*int32)(unsafe.Pointer(bp + 4))) } } else { if b.Fheight > int32(4) { b.Fy += b.Fheight / int32(2) libx11.XXDrawLine(tls, (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fdisplay, d, XTk_3DBorderGC(tls, tkwin, border, int32(TK_3D_DARK_GC)), b.Fx+*(*int32)(unsafe.Pointer(bp + 4)), b.Fy-int32(1), b.Fx+b.Fwidth-*(*int32)(unsafe.Pointer(bp + 4)), b.Fy-int32(1)) libx11.XXDrawLine(tls, (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fdisplay, d, XTk_3DBorderGC(tls, tkwin, border, int32(TK_3D_LIGHT_GC)), b.Fx+*(*int32)(unsafe.Pointer(bp + 4)), b.Fy, b.Fx+b.Fwidth-*(*int32)(unsafe.Pointer(bp + 4)), b.Fy) } } } } var _SliderElementSpec1 = TTtk_ElementSpec{ Fversion: int32(TK_STYLE_VERSION_2), FelementSize: uint64(48), Foptions: uintptr(unsafe.Pointer(&_SliderElementOptions)), } func init() { p := unsafe.Pointer(&_SliderElementSpec1) *(*uintptr)(unsafe.Add(p, 24)) = __ccgo_fp(_SliderElementSize1) *(*uintptr)(unsafe.Add(p, 32)) = __ccgo_fp(_SliderElementDraw) } /*------------------------------------------------------------------------ * +++ Sash element (for ttk::panedwindow) * * NOTES: * * panedwindows with -orient horizontal use vertical sashes, and vice versa. * * Interpretation of -sashrelief 'groove' and 'ridge' are * swapped wrt. the core panedwindow, which (I think) has them backwards. * * Default -sashrelief is sunken; the core panedwindow has default * -sashrelief raised, but that looks wrong to me. */ type TSashElement = struct { FborderObj uintptr FsashReliefObj uintptr FsashThicknessObj uintptr FsashPadObj uintptr FhandleSizeObj uintptr FhandlePadObj uintptr } var _SashOptions = [7]TTtk_ElementOptionSpec{ 0: { FoptionName: __ccgo_ts + 19898, Ftype1: int32(TK_OPTION_BORDER), FdefaultValue: __ccgo_ts + 19921, }, 1: { FoptionName: __ccgo_ts + 25307, Ftype1: int32(TK_OPTION_RELIEF), Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 8)), FdefaultValue: __ccgo_ts + 31, }, 2: { FoptionName: __ccgo_ts + 50558, Ftype1: int32(TK_OPTION_PIXELS), Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 16)), FdefaultValue: __ccgo_ts + 50573, }, 3: { FoptionName: __ccgo_ts + 25282, Ftype1: int32(TK_OPTION_PIXELS), Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 24)), FdefaultValue: __ccgo_ts + 21412, }, 4: { FoptionName: __ccgo_ts + 25037, Ftype1: int32(TK_OPTION_PIXELS), Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 32)), FdefaultValue: __ccgo_ts + 25035, }, 5: { FoptionName: __ccgo_ts + 25004, Ftype1: int32(TK_OPTION_PIXELS), Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 40)), FdefaultValue: __ccgo_ts + 25035, }, 6: {}, } func _SashElementSize(tls *libc.TLS, clientData uintptr, elementRecord uintptr, tkwin TTk_Window, widthPtr uintptr, heightPtr uintptr, dummy711 uintptr) { bp := tls.Alloc(16) defer tls.Free(16) var orient TTtk_Orient var sash uintptr var _ /* handleSize at bp+8 */ int32 var _ /* sashPad at bp+0 */ int32 var _ /* sashThickness at bp+4 */ int32 _, _ = orient, sash sash = elementRecord *(*int32)(unsafe.Pointer(bp)) = int32(2) *(*int32)(unsafe.Pointer(bp + 4)) = int32(6) *(*int32)(unsafe.Pointer(bp + 8)) = int32(8) orient = int32(int64(clientData)) XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), tkwin, (*TSashElement)(unsafe.Pointer(sash)).FsashThicknessObj, bp+4) XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), tkwin, (*TSashElement)(unsafe.Pointer(sash)).FhandleSizeObj, bp+8) XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), tkwin, (*TSashElement)(unsafe.Pointer(sash)).FsashPadObj, bp) if *(*int32)(unsafe.Pointer(bp + 4)) < *(*int32)(unsafe.Pointer(bp + 8))+int32(2)**(*int32)(unsafe.Pointer(bp)) { *(*int32)(unsafe.Pointer(bp + 4)) = *(*int32)(unsafe.Pointer(bp + 8)) + int32(2)**(*int32)(unsafe.Pointer(bp)) } if orient == int32(TTK_ORIENT_HORIZONTAL) { *(*int32)(unsafe.Pointer(heightPtr)) = *(*int32)(unsafe.Pointer(bp + 4)) } else { *(*int32)(unsafe.Pointer(widthPtr)) = *(*int32)(unsafe.Pointer(bp + 4)) } } func _SashElementDraw(tls *libc.TLS, clientData uintptr, elementRecord uintptr, tkwin TTk_Window, d TDrawable, b TTtk_Box, dummy733 TTtk_State) { bp := tls.Alloc(16) defer tls.Free(16) var border TTk_3DBorder var gc1, gc2, v1, v2 TGC var hb TTtk_Box var orient TTtk_Orient var sash uintptr var x, y int32 var _ /* handlePad at bp+8 */ int32 var _ /* handleSize at bp+4 */ int32 var _ /* relief at bp+0 */ int32 _, _, _, _, _, _, _, _, _, _ = border, gc1, gc2, hb, orient, sash, x, y, v1, v2 sash = elementRecord border = XTk_Get3DBorderFromObj(tls, tkwin, (*TSashElement)(unsafe.Pointer(sash)).FborderObj) *(*int32)(unsafe.Pointer(bp)) = int32(TK_RELIEF_RAISED) *(*int32)(unsafe.Pointer(bp + 4)) = int32(8) *(*int32)(unsafe.Pointer(bp + 8)) = int32(8) orient = int32(int64(clientData)) XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), tkwin, (*TSashElement)(unsafe.Pointer(sash)).FhandleSizeObj, bp+4) XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), tkwin, (*TSashElement)(unsafe.Pointer(sash)).FhandlePadObj, bp+8) XTk_GetReliefFromObj(tls, libc.UintptrFromInt32(0), (*TSashElement)(unsafe.Pointer(sash)).FsashReliefObj, bp) switch *(*int32)(unsafe.Pointer(bp)) { case int32(TK_RELIEF_RAISED): fallthrough case int32(TK_RELIEF_RIDGE): gc1 = XTk_3DBorderGC(tls, tkwin, border, int32(TK_3D_LIGHT_GC)) gc2 = XTk_3DBorderGC(tls, tkwin, border, int32(TK_3D_DARK_GC)) case int32(TK_RELIEF_SUNKEN): fallthrough case int32(TK_RELIEF_GROOVE): gc1 = XTk_3DBorderGC(tls, tkwin, border, int32(TK_3D_DARK_GC)) gc2 = XTk_3DBorderGC(tls, tkwin, border, int32(TK_3D_LIGHT_GC)) case int32(TK_RELIEF_SOLID): v1 = XTk_3DBorderGC(tls, tkwin, border, int32(TK_3D_DARK_GC)) gc2 = v1 gc1 = v1 case TK_RELIEF_FLAT: fallthrough default: v2 = XTk_3DBorderGC(tls, tkwin, border, int32(TK_3D_FLAT_GC)) gc2 = v2 gc1 = v2 break } /* Draw sash line: */ if orient == int32(TTK_ORIENT_HORIZONTAL) { y = b.Fy + b.Fheight/int32(2) - int32(1) libx11.XXDrawLine(tls, (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fdisplay, d, gc1, b.Fx, y, b.Fx+b.Fwidth, y) y++ libx11.XXDrawLine(tls, (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fdisplay, d, gc2, b.Fx, y, b.Fx+b.Fwidth, y) } else { x = b.Fx + b.Fwidth/int32(2) - int32(1) libx11.XXDrawLine(tls, (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fdisplay, d, gc1, x, b.Fy, x, b.Fy+b.Fheight) x++ libx11.XXDrawLine(tls, (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fdisplay, d, gc2, x, b.Fy, x, b.Fy+b.Fheight) } /* Draw handle: */ if *(*int32)(unsafe.Pointer(bp + 4)) >= 0 { if orient == int32(TTK_ORIENT_HORIZONTAL) { hb = XTtk_StickBox(tls, b, *(*int32)(unsafe.Pointer(bp + 4)), *(*int32)(unsafe.Pointer(bp + 4)), libc.Uint32FromInt32(libc.Int32FromInt32(TTK_STICK_W))) hb.Fx += *(*int32)(unsafe.Pointer(bp + 8)) } else { hb = XTtk_StickBox(tls, b, *(*int32)(unsafe.Pointer(bp + 4)), *(*int32)(unsafe.Pointer(bp + 4)), libc.Uint32FromInt32(libc.Int32FromInt32(TTK_STICK_N))) hb.Fy += *(*int32)(unsafe.Pointer(bp + 8)) } XTk_Fill3DRectangle(tls, tkwin, d, border, hb.Fx, hb.Fy, hb.Fwidth, hb.Fheight, int32(1), int32(TK_RELIEF_RAISED)) } } var _SashElementSpec = TTtk_ElementSpec{ Fversion: int32(TK_STYLE_VERSION_2), FelementSize: uint64(48), Foptions: uintptr(unsafe.Pointer(&_SashOptions)), } func init() { p := unsafe.Pointer(&_SashElementSpec) *(*uintptr)(unsafe.Add(p, 24)) = __ccgo_fp(_SashElementSize) *(*uintptr)(unsafe.Add(p, 32)) = __ccgo_fp(_SashElementDraw) } /*------------------------------------------------------------------------ * +++ Widget layouts. */ var _LayoutTable1 = [95]TTTKLayoutInstruction{ 0: { FelementName: __ccgo_ts + 49256, Fopcode: libc.Uint32FromInt32(libc.Int32FromInt32(_TTK_CHILDREN) | libc.Int32FromInt32(_TTK_LAYOUT)), }, 1: { FelementName: __ccgo_ts + 50575, Fopcode: libc.Uint32FromInt32(libc.Int32FromInt32(TTK_FILL_BOTH) | libc.Int32FromInt32(_TTK_CHILDREN)), }, 2: { FelementName: __ccgo_ts + 49264, Fopcode: libc.Uint32FromInt32(libc.Int32FromInt32(TTK_FILL_BOTH) | libc.Int32FromInt32(TTK_BORDER) | libc.Int32FromInt32(_TTK_CHILDREN)), }, 3: { FelementName: __ccgo_ts + 49291, Fopcode: libc.Uint32FromInt32(libc.Int32FromInt32(TTK_FILL_BOTH) | libc.Int32FromInt32(_TTK_CHILDREN)), }, 4: { FelementName: __ccgo_ts + 49306, Fopcode: libc.Uint32FromInt32(libc.Int32FromInt32(TTK_FILL_BOTH)), }, 5: { Fopcode: libc.Uint32FromInt32(libc.Int32FromInt32(_TTK_LAYOUT_END)), }, 6: { Fopcode: libc.Uint32FromInt32(libc.Int32FromInt32(_TTK_LAYOUT_END)), }, 7: { Fopcode: libc.Uint32FromInt32(libc.Int32FromInt32(_TTK_LAYOUT_END)), }, 8: { Fopcode: libc.Uint32FromInt32(libc.Int32FromInt32(_TTK_LAYOUT_END)), }, 9: { FelementName: __ccgo_ts + 49336, Fopcode: libc.Uint32FromInt32(libc.Int32FromInt32(_TTK_CHILDREN) | libc.Int32FromInt32(_TTK_LAYOUT)), }, 10: { FelementName: __ccgo_ts + 50592, Fopcode: libc.Uint32FromInt32(libc.Int32FromInt32(TTK_FILL_BOTH) | libc.Int32FromInt32(_TTK_CHILDREN)), }, 11: { FelementName: __ccgo_ts + 50614, Fopcode: libc.Uint32FromInt32(libc.Int32FromInt32(TTK_FILL_BOTH) | libc.Int32FromInt32(_TTK_CHILDREN)), }, 12: { FelementName: __ccgo_ts + 49349, Fopcode: libc.Uint32FromInt32(libc.Int32FromInt32(TTK_FILL_BOTH) | libc.Int32FromInt32(_TTK_CHILDREN)), }, 13: { FelementName: __ccgo_ts + 49369, Fopcode: libc.Uint32FromInt32(libc.Int32FromInt32(TTK_PACK_LEFT)), }, 14: { FelementName: __ccgo_ts + 49409, Fopcode: libc.Uint32FromInt32(libc.Int32FromInt32(TTK_PACK_LEFT) | libc.Int32FromInt32(TTK_FILL_BOTH)), }, 15: { Fopcode: libc.Uint32FromInt32(libc.Int32FromInt32(_TTK_LAYOUT_END)), }, 16: { Fopcode: libc.Uint32FromInt32(libc.Int32FromInt32(_TTK_LAYOUT_END)), }, 17: { Fopcode: libc.Uint32FromInt32(libc.Int32FromInt32(_TTK_LAYOUT_END)), }, 18: { Fopcode: libc.Uint32FromInt32(libc.Int32FromInt32(_TTK_LAYOUT_END)), }, 19: { FelementName: __ccgo_ts + 49444, Fopcode: libc.Uint32FromInt32(libc.Int32FromInt32(_TTK_CHILDREN) | libc.Int32FromInt32(_TTK_LAYOUT)), }, 20: { FelementName: __ccgo_ts + 50633, Fopcode: libc.Uint32FromInt32(libc.Int32FromInt32(TTK_FILL_BOTH) | libc.Int32FromInt32(_TTK_CHILDREN)), }, 21: { FelementName: __ccgo_ts + 50655, Fopcode: libc.Uint32FromInt32(libc.Int32FromInt32(TTK_FILL_BOTH) | libc.Int32FromInt32(_TTK_CHILDREN)), }, 22: { FelementName: __ccgo_ts + 49457, Fopcode: libc.Uint32FromInt32(libc.Int32FromInt32(TTK_FILL_BOTH) | libc.Int32FromInt32(_TTK_CHILDREN)), }, 23: { FelementName: __ccgo_ts + 49477, Fopcode: libc.Uint32FromInt32(libc.Int32FromInt32(TTK_PACK_LEFT)), }, 24: { FelementName: __ccgo_ts + 49517, Fopcode: libc.Uint32FromInt32(libc.Int32FromInt32(TTK_PACK_LEFT) | libc.Int32FromInt32(TTK_FILL_BOTH)), }, 25: { Fopcode: libc.Uint32FromInt32(libc.Int32FromInt32(_TTK_LAYOUT_END)), }, 26: { Fopcode: libc.Uint32FromInt32(libc.Int32FromInt32(_TTK_LAYOUT_END)), }, 27: { Fopcode: libc.Uint32FromInt32(libc.Int32FromInt32(_TTK_LAYOUT_END)), }, 28: { Fopcode: libc.Uint32FromInt32(libc.Int32FromInt32(_TTK_LAYOUT_END)), }, 29: { FelementName: __ccgo_ts + 49535, Fopcode: libc.Uint32FromInt32(libc.Int32FromInt32(_TTK_CHILDREN) | libc.Int32FromInt32(_TTK_LAYOUT)), }, 30: { FelementName: __ccgo_ts + 50674, Fopcode: libc.Uint32FromInt32(libc.Int32FromInt32(TTK_FILL_BOTH) | libc.Int32FromInt32(_TTK_CHILDREN)), }, 31: { FelementName: __ccgo_ts + 49547, Fopcode: libc.Uint32FromInt32(libc.Int32FromInt32(TTK_FILL_BOTH) | libc.Int32FromInt32(_TTK_CHILDREN)), }, 32: { FelementName: __ccgo_ts + 49582, Fopcode: libc.Uint32FromInt32(libc.Int32FromInt32(TTK_PACK_RIGHT)), }, 33: { FelementName: __ccgo_ts + 49603, Fopcode: libc.Uint32FromInt32(libc.Int32FromInt32(TTK_FILL_X) | libc.Int32FromInt32(_TTK_CHILDREN)), }, 34: { FelementName: __ccgo_ts + 49622, }, 35: { Fopcode: libc.Uint32FromInt32(libc.Int32FromInt32(_TTK_LAYOUT_END)), }, 36: { Fopcode: libc.Uint32FromInt32(libc.Int32FromInt32(_TTK_LAYOUT_END)), }, 37: { Fopcode: libc.Uint32FromInt32(libc.Int32FromInt32(_TTK_LAYOUT_END)), }, 38: { Fopcode: libc.Uint32FromInt32(libc.Int32FromInt32(_TTK_LAYOUT_END)), }, 39: { FelementName: __ccgo_ts + 50695, Fopcode: libc.Uint32FromInt32(libc.Int32FromInt32(_TTK_CHILDREN) | libc.Int32FromInt32(_TTK_LAYOUT)), }, 40: { FelementName: __ccgo_ts + 50702, Fopcode: libc.Uint32FromInt32(libc.Int32FromInt32(TTK_FILL_BOTH) | libc.Int32FromInt32(_TTK_CHILDREN)), }, 41: { FelementName: __ccgo_ts + 50718, Fopcode: libc.Uint32FromInt32(libc.Int32FromInt32(TTK_FILL_BOTH) | libc.Int32FromInt32(TTK_BORDER) | libc.Int32FromInt32(_TTK_CHILDREN)), }, 42: { FelementName: __ccgo_ts + 50730, Fopcode: libc.Uint32FromInt32(libc.Int32FromInt32(TTK_FILL_BOTH) | libc.Int32FromInt32(_TTK_CHILDREN)), }, 43: { FelementName: __ccgo_ts + 50744, Fopcode: libc.Uint32FromInt32(libc.Int32FromInt32(TTK_FILL_BOTH)), }, 44: { Fopcode: libc.Uint32FromInt32(libc.Int32FromInt32(_TTK_LAYOUT_END)), }, 45: { Fopcode: libc.Uint32FromInt32(libc.Int32FromInt32(_TTK_LAYOUT_END)), }, 46: { Fopcode: libc.Uint32FromInt32(libc.Int32FromInt32(_TTK_LAYOUT_END)), }, 47: { Fopcode: libc.Uint32FromInt32(libc.Int32FromInt32(_TTK_LAYOUT_END)), }, 48: { FelementName: __ccgo_ts + 50095, Fopcode: libc.Uint32FromInt32(libc.Int32FromInt32(_TTK_CHILDREN) | libc.Int32FromInt32(_TTK_LAYOUT)), }, 49: { FelementName: __ccgo_ts + 50759, Fopcode: libc.Uint32FromInt32(libc.Int32FromInt32(TTK_FILL_BOTH) | libc.Int32FromInt32(_TTK_CHILDREN)), }, 50: { FelementName: __ccgo_ts + 50124, Fopcode: libc.Uint32FromInt32(libc.Int32FromInt32(TTK_FILL_BOTH) | libc.Int32FromInt32(_TTK_CHILDREN)), }, 51: { FelementName: __ccgo_ts + 50105, Fopcode: libc.Uint32FromInt32(libc.Int32FromInt32(TTK_PACK_RIGHT) | libc.Int32FromInt32(TTK_FILL_Y)), }, 52: { FelementName: __ccgo_ts + 50139, Fopcode: libc.Uint32FromInt32(libc.Int32FromInt32(TTK_FILL_BOTH) | libc.Int32FromInt32(_TTK_CHILDREN)), }, 53: { FelementName: __ccgo_ts + 50156, Fopcode: libc.Uint32FromInt32(libc.Int32FromInt32(TTK_FILL_BOTH)), }, 54: { Fopcode: libc.Uint32FromInt32(libc.Int32FromInt32(_TTK_LAYOUT_END)), }, 55: { Fopcode: libc.Uint32FromInt32(libc.Int32FromInt32(_TTK_LAYOUT_END)), }, 56: { Fopcode: libc.Uint32FromInt32(libc.Int32FromInt32(_TTK_LAYOUT_END)), }, 57: { Fopcode: libc.Uint32FromInt32(libc.Int32FromInt32(_TTK_LAYOUT_END)), }, 58: { FelementName: __ccgo_ts + 50778, Fopcode: libc.Uint32FromInt32(libc.Int32FromInt32(_TTK_CHILDREN) | libc.Int32FromInt32(_TTK_LAYOUT)), }, 59: { FelementName: __ccgo_ts + 50787, Fopcode: libc.Uint32FromInt32(libc.Int32FromInt32(TTK_FILL_BOTH) | libc.Int32FromInt32(_TTK_CHILDREN)), }, 60: { FelementName: __ccgo_ts + 50805, Fopcode: libc.Uint32FromInt32(libc.Int32FromInt32(TTK_FILL_BOTH) | libc.Int32FromInt32(TTK_FILL_X) | libc.Int32FromInt32(_TTK_CHILDREN)), }, 61: { FelementName: __ccgo_ts + 50819, Fopcode: libc.Uint32FromInt32(libc.Int32FromInt32(TTK_PACK_RIGHT) | libc.Int32FromInt32(_TTK_CHILDREN)), }, 62: { FelementName: __ccgo_ts + 50280, Fopcode: libc.Uint32FromInt32(libc.Int32FromInt32(TTK_PACK_TOP) | libc.Int32FromInt32(TTK_STICK_E)), }, 63: { FelementName: __ccgo_ts + 50306, Fopcode: libc.Uint32FromInt32(libc.Int32FromInt32(TTK_PACK_BOTTOM) | libc.Int32FromInt32(TTK_STICK_E)), }, 64: { Fopcode: libc.Uint32FromInt32(libc.Int32FromInt32(_TTK_LAYOUT_END)), }, 65: { FelementName: __ccgo_ts + 50824, Fopcode: libc.Uint32FromInt32(libc.Int32FromInt32(TTK_FILL_BOTH) | libc.Int32FromInt32(_TTK_CHILDREN)), }, 66: { FelementName: __ccgo_ts + 50840, Fopcode: libc.Uint32FromInt32(libc.Int32FromInt32(TTK_FILL_BOTH)), }, 67: { Fopcode: libc.Uint32FromInt32(libc.Int32FromInt32(_TTK_LAYOUT_END)), }, 68: { Fopcode: libc.Uint32FromInt32(libc.Int32FromInt32(_TTK_LAYOUT_END)), }, 69: { Fopcode: libc.Uint32FromInt32(libc.Int32FromInt32(_TTK_LAYOUT_END)), }, 70: { Fopcode: libc.Uint32FromInt32(libc.Int32FromInt32(_TTK_LAYOUT_END)), }, 71: { FelementName: __ccgo_ts + 50857, Fopcode: libc.Uint32FromInt32(libc.Int32FromInt32(_TTK_CHILDREN) | libc.Int32FromInt32(_TTK_LAYOUT)), }, 72: { FelementName: __ccgo_ts + 50873, Fopcode: libc.Uint32FromInt32(libc.Int32FromInt32(TTK_FILL_BOTH) | libc.Int32FromInt32(_TTK_CHILDREN)), }, 73: { FelementName: __ccgo_ts + 50898, Fopcode: libc.Uint32FromInt32(libc.Int32FromInt32(TTK_FILL_BOTH) | libc.Int32FromInt32(_TTK_CHILDREN)), }, 74: { FelementName: __ccgo_ts + 50920, Fopcode: libc.Uint32FromInt32(libc.Int32FromInt32(TTK_PACK_TOP)), }, 75: { Fopcode: libc.Uint32FromInt32(libc.Int32FromInt32(_TTK_LAYOUT_END)), }, 76: { Fopcode: libc.Uint32FromInt32(libc.Int32FromInt32(_TTK_LAYOUT_END)), }, 77: { Fopcode: libc.Uint32FromInt32(libc.Int32FromInt32(_TTK_LAYOUT_END)), }, 78: { FelementName: __ccgo_ts + 50942, Fopcode: libc.Uint32FromInt32(libc.Int32FromInt32(_TTK_CHILDREN) | libc.Int32FromInt32(_TTK_LAYOUT)), }, 79: { FelementName: __ccgo_ts + 50960, Fopcode: libc.Uint32FromInt32(libc.Int32FromInt32(TTK_FILL_BOTH) | libc.Int32FromInt32(_TTK_CHILDREN)), }, 80: { FelementName: __ccgo_ts + 50987, Fopcode: libc.Uint32FromInt32(libc.Int32FromInt32(TTK_FILL_BOTH) | libc.Int32FromInt32(_TTK_CHILDREN)), }, 81: { FelementName: __ccgo_ts + 51011, Fopcode: libc.Uint32FromInt32(libc.Int32FromInt32(TTK_PACK_LEFT)), }, 82: { Fopcode: libc.Uint32FromInt32(libc.Int32FromInt32(_TTK_LAYOUT_END)), }, 83: { Fopcode: libc.Uint32FromInt32(libc.Int32FromInt32(_TTK_LAYOUT_END)), }, 84: { Fopcode: libc.Uint32FromInt32(libc.Int32FromInt32(_TTK_LAYOUT_END)), }, 85: { FelementName: __ccgo_ts + 51035, Fopcode: libc.Uint32FromInt32(libc.Int32FromInt32(_TTK_CHILDREN) | libc.Int32FromInt32(_TTK_LAYOUT)), }, 86: { FelementName: __ccgo_ts + 51044, Fopcode: libc.Uint32FromInt32(libc.Int32FromInt32(TTK_FILL_BOTH) | libc.Int32FromInt32(_TTK_CHILDREN)), }, 87: { FelementName: __ccgo_ts + 51063, Fopcode: libc.Uint32FromInt32(libc.Int32FromInt32(TTK_FILL_BOTH) | libc.Int32FromInt32(TTK_BORDER) | libc.Int32FromInt32(_TTK_CHILDREN)), }, 88: { FelementName: __ccgo_ts + 51078, Fopcode: libc.Uint32FromInt32(libc.Int32FromInt32(TTK_FILL_BOTH) | libc.Int32FromInt32(_TTK_CHILDREN)), }, 89: { FelementName: __ccgo_ts + 51095, Fopcode: libc.Uint32FromInt32(libc.Int32FromInt32(TTK_FILL_BOTH)), }, 90: { Fopcode: libc.Uint32FromInt32(libc.Int32FromInt32(_TTK_LAYOUT_END)), }, 91: { Fopcode: libc.Uint32FromInt32(libc.Int32FromInt32(_TTK_LAYOUT_END)), }, 92: { Fopcode: libc.Uint32FromInt32(libc.Int32FromInt32(_TTK_LAYOUT_END)), }, 93: { Fopcode: libc.Uint32FromInt32(libc.Int32FromInt32(_TTK_LAYOUT_END)), }, 94: { Fopcode: libc.Uint32FromInt32(libc.Int32FromInt32(_TTK_LAYOUT) | libc.Int32FromInt32(_TTK_LAYOUT_END)), }, } /*------------------------------------------------------------------------ * TtkClassicTheme_Init -- * Install classic theme. */ func XTtkClassicTheme_Init(tls *libc.TLS, interp uintptr) (r int32) { var theme TTtk_Theme _ = theme theme = XTtk_CreateTheme(tls, interp, __ccgo_ts+51113, libc.UintptrFromInt32(0)) if !(theme != 0) { return int32(TCL_ERROR) } /* * Register elements: */ XTtk_RegisterElement(tls, interp, theme, __ccgo_ts+51121, uintptr(unsafe.Pointer(&_HighlightElementSpec)), libc.UintptrFromInt32(0)) XTtk_RegisterElement(tls, interp, theme, __ccgo_ts+49264, uintptr(unsafe.Pointer(&_ButtonBorderElementSpec)), libc.UintptrFromInt32(0)) XTtk_RegisterElement(tls, interp, theme, __ccgo_ts+49369, uintptr(unsafe.Pointer(&_CheckbuttonIndicatorElementSpec)), libc.UintptrFromInt32(0)) XTtk_RegisterElement(tls, interp, theme, __ccgo_ts+49477, uintptr(unsafe.Pointer(&_RadiobuttonIndicatorElementSpec)), libc.UintptrFromInt32(0)) XTtk_RegisterElement(tls, interp, theme, __ccgo_ts+49582, uintptr(unsafe.Pointer(&_MenuIndicatorElementSpec)), libc.UintptrFromInt32(0)) XTtk_RegisterElement(tls, interp, theme, __ccgo_ts+50272, uintptr(unsafe.Pointer(&_ArrowElementSpec1)), uintptr(int64(int32(ARROW_UP)))) XTtk_RegisterElement(tls, interp, theme, __ccgo_ts+50296, uintptr(unsafe.Pointer(&_ArrowElementSpec1)), uintptr(int64(int32(ARROW_DOWN)))) XTtk_RegisterElement(tls, interp, theme, __ccgo_ts+50324, uintptr(unsafe.Pointer(&_ArrowElementSpec1)), uintptr(int64(int32(ARROW_LEFT)))) XTtk_RegisterElement(tls, interp, theme, __ccgo_ts+50334, uintptr(unsafe.Pointer(&_ArrowElementSpec1)), uintptr(int64(int32(ARROW_RIGHT)))) XTtk_RegisterElement(tls, interp, theme, __ccgo_ts+24278, uintptr(unsafe.Pointer(&_ArrowElementSpec1)), uintptr(int64(int32(ARROW_UP)))) XTtk_RegisterElement(tls, interp, theme, __ccgo_ts+26225, uintptr(unsafe.Pointer(&_SliderElementSpec1)), libc.UintptrFromInt32(0)) XTtk_RegisterElement(tls, interp, theme, __ccgo_ts+51131, uintptr(unsafe.Pointer(&_SashElementSpec)), uintptr(int64(int32(TTK_ORIENT_HORIZONTAL)))) XTtk_RegisterElement(tls, interp, theme, __ccgo_ts+51137, uintptr(unsafe.Pointer(&_SashElementSpec)), uintptr(int64(int32(TTK_ORIENT_VERTICAL)))) /* * Register layouts: */ XTtk_RegisterLayouts(tls, theme, uintptr(unsafe.Pointer(&_LayoutTable1))) libtcl9_0.XTcl_PkgProvideEx(tls, interp, __ccgo_ts+51143, __ccgo_ts+18729, libc.UintptrFromInt32(0)) return TCL_OK } const BORDERWIDTH = 2 const MENUBUTTON_ARROW_SIZE = 5 const MIN_THUMB_SIZE = 8 const SCROLLBAR_WIDTH = 14 /* *---------------------------------------------------------------------- * * Helper routines for border drawing: * * NOTE: MSUE specifies a slightly different arrangement * for button borders than for other elements; "shadowColors" * is for button borders. * * Please excuse the gross misspelling "LITE" for "LIGHT", * but it makes things line up nicer. */ type BorderColor = int32 const FLAT = 1 const LITE = 2 const DARK = 3 const BRDR = 4 // C documentation // // /* top-left outer, top-left inner, bottom-right inner, bottom-right outer */ var _shadowColors = [6][4]BorderColor{ 0: { 0: int32(FLAT), 1: int32(FLAT), 2: int32(FLAT), 3: int32(FLAT), }, 1: { 0: int32(DARK), 1: int32(LITE), 2: int32(DARK), 3: int32(LITE), }, 2: { 0: int32(LITE), 1: int32(FLAT), 2: int32(DARK), 3: int32(BRDR), }, 3: { 0: int32(LITE), 1: int32(DARK), 2: int32(LITE), 3: int32(DARK), }, 4: { 0: int32(BRDR), 1: int32(BRDR), 2: int32(BRDR), 3: int32(BRDR), }, 5: { 0: int32(BRDR), 1: int32(DARK), 2: int32(FLAT), 3: int32(LITE), }, } // C documentation // // /* top-left, bottom-right */ var _thinShadowColors = [6][4]BorderColor{ 0: { 0: int32(FLAT), 1: int32(FLAT), }, 1: { 0: int32(DARK), 1: int32(LITE), }, 2: { 0: int32(LITE), 1: int32(DARK), }, 3: { 0: int32(LITE), 1: int32(DARK), }, 4: { 0: int32(BRDR), 1: int32(BRDR), }, 5: { 0: int32(DARK), 1: int32(LITE), }, } func _DrawCorner(tls *libc.TLS, tkwin TTk_Window, d TDrawable, border TTk_3DBorder, borderGC TGC, x int32, y int32, width int32, height int32, corner int32, color BorderColor) { bp := tls.Alloc(16) defer tls.Free(16) var gc TGC var _ /* points at bp+0 */ [3]TXPoint _ = gc width-- height-- (*(*[3]TXPoint)(unsafe.Pointer(bp)))[0].Fx = int16(x) (*(*[3]TXPoint)(unsafe.Pointer(bp)))[0].Fy = int16(y + height) (*(*[3]TXPoint)(unsafe.Pointer(bp)))[int32(1)].Fx = int16(x + width*corner) (*(*[3]TXPoint)(unsafe.Pointer(bp)))[int32(1)].Fy = int16(y + height*corner) (*(*[3]TXPoint)(unsafe.Pointer(bp)))[int32(2)].Fx = int16(x + width) (*(*[3]TXPoint)(unsafe.Pointer(bp)))[int32(2)].Fy = int16(y) if color == int32(BRDR) { gc = borderGC } else { gc = XTk_3DBorderGC(tls, tkwin, border, color) } libx11.XXDrawLines(tls, (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fdisplay, d, gc, bp, int32(3), CoordModeOrigin) } func _DrawBorder(tls *libc.TLS, tkwin TTk_Window, d TDrawable, border TTk_3DBorder, borderColor uintptr, b TTtk_Box, borderWidth int32, relief int32) { var borderGC TGC _ = borderGC borderGC = XTk_GCForColor(tls, borderColor, d) switch borderWidth { case int32(2): /* "thick" border */ _DrawCorner(tls, tkwin, d, border, borderGC, b.Fx, b.Fy, b.Fwidth, b.Fheight, 0, *(*BorderColor)(unsafe.Pointer(uintptr(unsafe.Pointer(&_shadowColors)) + uintptr(relief)*16))) _DrawCorner(tls, tkwin, d, border, borderGC, b.Fx+int32(1), b.Fy+int32(1), b.Fwidth-int32(2), b.Fheight-int32(2), 0, *(*BorderColor)(unsafe.Pointer(uintptr(unsafe.Pointer(&_shadowColors)) + uintptr(relief)*16 + 1*4))) _DrawCorner(tls, tkwin, d, border, borderGC, b.Fx+int32(1), b.Fy+int32(1), b.Fwidth-int32(2), b.Fheight-int32(2), int32(1), *(*BorderColor)(unsafe.Pointer(uintptr(unsafe.Pointer(&_shadowColors)) + uintptr(relief)*16 + 2*4))) _DrawCorner(tls, tkwin, d, border, borderGC, b.Fx, b.Fy, b.Fwidth, b.Fheight, int32(1), *(*BorderColor)(unsafe.Pointer(uintptr(unsafe.Pointer(&_shadowColors)) + uintptr(relief)*16 + 3*4))) case int32(1): /* "thin" border */ _DrawCorner(tls, tkwin, d, border, borderGC, b.Fx, b.Fy, b.Fwidth, b.Fheight, 0, *(*BorderColor)(unsafe.Pointer(uintptr(unsafe.Pointer(&_thinShadowColors)) + uintptr(relief)*16))) _DrawCorner(tls, tkwin, d, border, borderGC, b.Fx, b.Fy, b.Fwidth, b.Fheight, int32(1), *(*BorderColor)(unsafe.Pointer(uintptr(unsafe.Pointer(&_thinShadowColors)) + uintptr(relief)*16 + 1*4))) case 0: /* no border -- do nothing */ default: /* Fall back to Motif-style borders: */ XTk_Draw3DRectangle(tls, tkwin, d, border, b.Fx, b.Fy, b.Fwidth, b.Fheight, borderWidth, relief) break } } // C documentation // // /* Alternate shadow colors for entry fields: // * NOTE: FLAT color is normally white, and the LITE color is a darker shade. // */ func _DrawFieldBorder(tls *libc.TLS, tkwin TTk_Window, d TDrawable, border TTk_3DBorder, borderColor uintptr, b TTtk_Box) { var borderGC TGC _ = borderGC borderGC = XTk_GCForColor(tls, borderColor, d) _DrawCorner(tls, tkwin, d, border, borderGC, b.Fx, b.Fy, b.Fwidth, b.Fheight, 0, int32(DARK)) _DrawCorner(tls, tkwin, d, border, borderGC, b.Fx+int32(1), b.Fy+int32(1), b.Fwidth-int32(2), b.Fheight-int32(2), 0, int32(BRDR)) _DrawCorner(tls, tkwin, d, border, borderGC, b.Fx+int32(1), b.Fy+int32(1), b.Fwidth-int32(2), b.Fheight-int32(2), int32(1), int32(LITE)) _DrawCorner(tls, tkwin, d, border, borderGC, b.Fx, b.Fy, b.Fwidth, b.Fheight, int32(1), int32(FLAT)) return } // C documentation // // /* // * ArrowPoints -- // * Compute points of arrow polygon. // */ func _ArrowPoints(tls *libc.TLS, b TTtk_Box, direction TArrowDirection, points uintptr) { var cx, cy, h int32 _, _, _ = cx, cy, h switch direction { case int32(ARROW_UP): h = (b.Fwidth - int32(1)) / int32(2) cx = b.Fx + h cy = b.Fy if b.Fheight <= h { h = b.Fheight - int32(1) } (*(*TXPoint)(unsafe.Pointer(points))).Fx = int16(cx) (*(*TXPoint)(unsafe.Pointer(points))).Fy = int16(cy) (*(*TXPoint)(unsafe.Pointer(points + 1*4))).Fx = int16(cx - h) (*(*TXPoint)(unsafe.Pointer(points + 1*4))).Fy = int16(cy + h) (*(*TXPoint)(unsafe.Pointer(points + 2*4))).Fx = int16(cx + h) (*(*TXPoint)(unsafe.Pointer(points + 2*4))).Fy = int16(cy + h) case int32(ARROW_DOWN): h = (b.Fwidth - int32(1)) / int32(2) cx = b.Fx + h cy = b.Fy + b.Fheight - int32(1) if b.Fheight <= h { h = b.Fheight - int32(1) } (*(*TXPoint)(unsafe.Pointer(points))).Fx = int16(cx) (*(*TXPoint)(unsafe.Pointer(points))).Fy = int16(cy) (*(*TXPoint)(unsafe.Pointer(points + 1*4))).Fx = int16(cx - h) (*(*TXPoint)(unsafe.Pointer(points + 1*4))).Fy = int16(cy - h) (*(*TXPoint)(unsafe.Pointer(points + 2*4))).Fx = int16(cx + h) (*(*TXPoint)(unsafe.Pointer(points + 2*4))).Fy = int16(cy - h) case int32(ARROW_LEFT): h = (b.Fheight - int32(1)) / int32(2) cx = b.Fx cy = b.Fy + h if b.Fwidth <= h { h = b.Fwidth - int32(1) } (*(*TXPoint)(unsafe.Pointer(points))).Fx = int16(cx) (*(*TXPoint)(unsafe.Pointer(points))).Fy = int16(cy) (*(*TXPoint)(unsafe.Pointer(points + 1*4))).Fx = int16(cx + h) (*(*TXPoint)(unsafe.Pointer(points + 1*4))).Fy = int16(cy - h) (*(*TXPoint)(unsafe.Pointer(points + 2*4))).Fx = int16(cx + h) (*(*TXPoint)(unsafe.Pointer(points + 2*4))).Fy = int16(cy + h) case int32(ARROW_RIGHT): h = (b.Fheight - int32(1)) / int32(2) cx = b.Fx + b.Fwidth - int32(1) cy = b.Fy + h if b.Fwidth <= h { h = b.Fwidth - int32(1) } (*(*TXPoint)(unsafe.Pointer(points))).Fx = int16(cx) (*(*TXPoint)(unsafe.Pointer(points))).Fy = int16(cy) (*(*TXPoint)(unsafe.Pointer(points + 1*4))).Fx = int16(cx - h) (*(*TXPoint)(unsafe.Pointer(points + 1*4))).Fy = int16(cy - h) (*(*TXPoint)(unsafe.Pointer(points + 2*4))).Fx = int16(cx - h) (*(*TXPoint)(unsafe.Pointer(points + 2*4))).Fy = int16(cy + h) break } (*(*TXPoint)(unsafe.Pointer(points + 3*4))).Fx = (*(*TXPoint)(unsafe.Pointer(points))).Fx (*(*TXPoint)(unsafe.Pointer(points + 3*4))).Fy = (*(*TXPoint)(unsafe.Pointer(points))).Fy } // C documentation // // /*public*/ func XTtkArrowSize(tls *libc.TLS, h int32, direction TArrowDirection, widthPtr uintptr, heightPtr uintptr) { switch direction { case int32(ARROW_UP): fallthrough case int32(ARROW_DOWN): *(*int32)(unsafe.Pointer(widthPtr)) = int32(2)*h + int32(1) *(*int32)(unsafe.Pointer(heightPtr)) = h + int32(1) case int32(ARROW_LEFT): fallthrough case int32(ARROW_RIGHT): *(*int32)(unsafe.Pointer(widthPtr)) = h + int32(1) *(*int32)(unsafe.Pointer(heightPtr)) = int32(2)*h + int32(1) } } // C documentation // // /* // * TtkDrawArrow, TtkFillArrow -- // * Draw an arrow in the indicated direction inside the specified box. // */ // /*public*/ func XTtkFillArrow(tls *libc.TLS, display uintptr, d TDrawable, gc TGC, b TTtk_Box, direction TArrowDirection) { bp := tls.Alloc(16) defer tls.Free(16) var _ /* points at bp+0 */ [4]TXPoint _ArrowPoints(tls, b, direction, bp) libx11.XXFillPolygon(tls, display, d, gc, bp, int32(3), int32(Convex), CoordModeOrigin) libx11.XXDrawLines(tls, display, d, gc, bp, int32(4), CoordModeOrigin) /* Work around bug [77527326e5] - ttk artifacts on Ubuntu */ libx11.XXDrawPoint(tls, display, d, gc, int32((*(*[4]TXPoint)(unsafe.Pointer(bp)))[int32(2)].Fx), int32((*(*[4]TXPoint)(unsafe.Pointer(bp)))[int32(2)].Fy)) } // C documentation // // /*public*/ func XTtkDrawArrow(tls *libc.TLS, display uintptr, d TDrawable, gc TGC, b TTtk_Box, direction TArrowDirection) { bp := tls.Alloc(16) defer tls.Free(16) var _ /* points at bp+0 */ [4]TXPoint _ArrowPoints(tls, b, direction, bp) libx11.XXDrawLines(tls, display, d, gc, bp, int32(4), CoordModeOrigin) /* Work around bug [77527326e5] - ttk artifacts on Ubuntu */ libx11.XXDrawPoint(tls, display, d, gc, int32((*(*[4]TXPoint)(unsafe.Pointer(bp)))[int32(2)].Fx), int32((*(*[4]TXPoint)(unsafe.Pointer(bp)))[int32(2)].Fy)) } /* *---------------------------------------------------------------------- * +++ Border element implementation. * * This border consists of (from outside-in): * * + a 1-pixel thick default indicator (defaultable widgets only) * + 1- or 2- pixel shaded border (controlled by -background and -relief) * + 1 pixel padding (???) */ type TBorderElement1 = struct { FborderObj uintptr FborderColorObj uintptr FborderWidthObj uintptr FreliefObj uintptr FdefaultStateObj uintptr } var _BorderElementOptions1 = [6]TTtk_ElementOptionSpec{ 0: { FoptionName: __ccgo_ts + 19898, Ftype1: int32(TK_OPTION_BORDER), FdefaultValue: __ccgo_ts + 19921, }, 1: { FoptionName: __ccgo_ts + 49726, Ftype1: int32(TK_OPTION_COLOR), Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 8)), FdefaultValue: __ccgo_ts + 39099, }, 2: { FoptionName: __ccgo_ts + 16738, Ftype1: int32(TK_OPTION_STRING), Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 32)), FdefaultValue: __ccgo_ts + 16715, }, 3: { FoptionName: __ccgo_ts + 2814, Ftype1: int32(TK_OPTION_PIXELS), Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 16)), FdefaultValue: __ccgo_ts + 21412, }, 4: { FoptionName: __ccgo_ts + 20346, Ftype1: int32(TK_OPTION_RELIEF), Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 24)), FdefaultValue: __ccgo_ts, }, 5: {}, } func _BorderElementSize1(tls *libc.TLS, dummy260 uintptr, elementRecord uintptr, tkwin TTk_Window, dummy263 uintptr, dummy264 uintptr, paddingPtr uintptr) { bp := tls.Alloc(16) defer tls.Free(16) var bd uintptr var _ /* borderWidth at bp+0 */ int32 var _ /* defaultState at bp+4 */ TTtk_ButtonDefaultState _ = bd bd = elementRecord *(*int32)(unsafe.Pointer(bp)) = 0 *(*TTtk_ButtonDefaultState)(unsafe.Pointer(bp + 4)) = int32(TTK_BUTTON_DEFAULT_DISABLED) XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), tkwin, (*TBorderElement1)(unsafe.Pointer(bd)).FborderWidthObj, bp) XTtk_GetButtonDefaultStateFromObj(tls, libc.UintptrFromInt32(0), (*TBorderElement1)(unsafe.Pointer(bd)).FdefaultStateObj, bp+4) if *(*TTtk_ButtonDefaultState)(unsafe.Pointer(bp + 4)) != int32(TTK_BUTTON_DEFAULT_DISABLED) { *(*int32)(unsafe.Pointer(bp))++ } *(*TTtk_Padding)(unsafe.Pointer(paddingPtr)) = XTtk_UniformPadding(tls, int16(*(*int32)(unsafe.Pointer(bp)))) } func _BorderElementDraw1(tls *libc.TLS, dummy282 uintptr, elementRecord uintptr, tkwin TTk_Window, d TDrawable, b TTtk_Box, dummy287 TTtk_State) { bp := tls.Alloc(16) defer tls.Free(16) var bd, borderColor uintptr var border TTk_3DBorder var gc TGC var _ /* borderWidth at bp+0 */ int32 var _ /* defaultState at bp+8 */ TTtk_ButtonDefaultState var _ /* relief at bp+4 */ int32 _, _, _, _ = bd, border, borderColor, gc bd = elementRecord border = XTk_Get3DBorderFromObj(tls, tkwin, (*TBorderElement1)(unsafe.Pointer(bd)).FborderObj) borderColor = XTk_GetColorFromObj(tls, tkwin, (*TBorderElement1)(unsafe.Pointer(bd)).FborderColorObj) *(*int32)(unsafe.Pointer(bp)) = int32(2) *(*int32)(unsafe.Pointer(bp + 4)) = TK_RELIEF_FLAT *(*TTtk_ButtonDefaultState)(unsafe.Pointer(bp + 8)) = int32(TTK_BUTTON_DEFAULT_DISABLED) /* * Get option values. */ XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), tkwin, (*TBorderElement1)(unsafe.Pointer(bd)).FborderWidthObj, bp) XTk_GetReliefFromObj(tls, libc.UintptrFromInt32(0), (*TBorderElement1)(unsafe.Pointer(bd)).FreliefObj, bp+4) XTtk_GetButtonDefaultStateFromObj(tls, libc.UintptrFromInt32(0), (*TBorderElement1)(unsafe.Pointer(bd)).FdefaultStateObj, bp+8) if *(*TTtk_ButtonDefaultState)(unsafe.Pointer(bp + 8)) == int32(TTK_BUTTON_DEFAULT_ACTIVE) { gc = XTk_GCForColor(tls, borderColor, d) libx11.XXDrawRectangle(tls, (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fdisplay, d, gc, b.Fx, b.Fy, libc.Uint32FromInt32(b.Fwidth-int32(1)), libc.Uint32FromInt32(b.Fheight-int32(1))) } if *(*TTtk_ButtonDefaultState)(unsafe.Pointer(bp + 8)) != int32(TTK_BUTTON_DEFAULT_DISABLED) { /* Space for default ring: */ b = XTtk_PadBox(tls, b, XTtk_UniformPadding(tls, int16(1))) } _DrawBorder(tls, tkwin, d, border, borderColor, b, *(*int32)(unsafe.Pointer(bp)), *(*int32)(unsafe.Pointer(bp + 4))) } var _BorderElementSpec1 = TTtk_ElementSpec{ Fversion: int32(TK_STYLE_VERSION_2), FelementSize: uint64(40), Foptions: uintptr(unsafe.Pointer(&_BorderElementOptions1)), } func init() { p := unsafe.Pointer(&_BorderElementSpec1) *(*uintptr)(unsafe.Add(p, 24)) = __ccgo_fp(_BorderElementSize1) *(*uintptr)(unsafe.Add(p, 32)) = __ccgo_fp(_BorderElementDraw1) } // C documentation // // /*---------------------------------------------------------------------- // * +++ Field element: // * Used for editable fields. // */ type TFieldElement1 = struct { FborderObj uintptr FborderColorObj uintptr FfocusWidthObj uintptr FfocusColorObj uintptr } var _FieldElementOptions1 = [5]TTtk_ElementOptionSpec{ 0: { FoptionName: __ccgo_ts + 49778, Ftype1: int32(TK_OPTION_BORDER), FdefaultValue: __ccgo_ts + 39093, }, 1: { FoptionName: __ccgo_ts + 49726, Ftype1: int32(TK_OPTION_COLOR), Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 8)), FdefaultValue: __ccgo_ts + 39099, }, 2: { FoptionName: __ccgo_ts + 51163, Ftype1: int32(TK_OPTION_PIXELS), Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 16)), FdefaultValue: __ccgo_ts + 21412, }, 3: { FoptionName: __ccgo_ts + 51175, Ftype1: int32(TK_OPTION_COLOR), Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 24)), FdefaultValue: __ccgo_ts + 51187, }, 4: {}, } func _FieldElementSize1(tls *libc.TLS, dummy348 uintptr, dummy349 uintptr, dummy350 TTk_Window, dummy351 uintptr, dummy352 uintptr, paddingPtr uintptr) { *(*TTtk_Padding)(unsafe.Pointer(paddingPtr)) = XTtk_UniformPadding(tls, int16(2)) } func _FieldElementDraw1(tls *libc.TLS, dummy359 uintptr, elementRecord uintptr, tkwin TTk_Window, d TDrawable, b TTtk_Box, state TTtk_State) { bp := tls.Alloc(16) defer tls.Free(16) var bgGC, focusGC TGC var border TTk_3DBorder var borderColor, disp, field, focusColor uintptr var w, x1, x2, y1, y2 int32 var _ /* focusWidth at bp+0 */ int32 _, _, _, _, _, _, _, _, _, _, _, _ = bgGC, border, borderColor, disp, field, focusColor, focusGC, w, x1, x2, y1, y2 field = elementRecord border = XTk_Get3DBorderFromObj(tls, tkwin, (*TFieldElement1)(unsafe.Pointer(field)).FborderObj) borderColor = XTk_GetColorFromObj(tls, tkwin, (*TFieldElement1)(unsafe.Pointer(field)).FborderColorObj) *(*int32)(unsafe.Pointer(bp)) = int32(2) XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), tkwin, (*TFieldElement1)(unsafe.Pointer(field)).FfocusWidthObj, bp) if *(*int32)(unsafe.Pointer(bp)) > 0 && state&libc.Uint32FromInt32(libc.Int32FromInt32(1)< int32(1) { x1 = b.Fx x2 = b.Fx + b.Fwidth - int32(1) y1 = b.Fy y2 = b.Fy + b.Fheight - int32(1) w = WIN32_XDRAWLINE_HACK /* * Draw the outer rounded rectangle */ libx11.XXDrawLine(tls, disp, d, focusGC, x1+int32(1), y1, x2-int32(1)+w, y1) /* N */ libx11.XXDrawLine(tls, disp, d, focusGC, x1+int32(1), y2, x2-int32(1)+w, y2) /* S */ libx11.XXDrawLine(tls, disp, d, focusGC, x1, y1+int32(1), x1, y2-int32(1)+w) /* W */ libx11.XXDrawLine(tls, disp, d, focusGC, x2, y1+int32(1), x2, y2-int32(1)+w) /* E */ /* * Draw the inner rectangle */ b.Fx += int32(1) b.Fy += int32(1) b.Fwidth -= int32(2) b.Fheight -= int32(2) libx11.XXDrawRectangle(tls, disp, d, focusGC, b.Fx, b.Fy, libc.Uint32FromInt32(b.Fwidth-int32(1)), libc.Uint32FromInt32(b.Fheight-int32(1))) /* * Fill the inner rectangle */ bgGC = XTk_3DBorderGC(tls, tkwin, border, int32(TK_3D_FLAT_GC)) libx11.XXFillRectangle(tls, disp, d, bgGC, b.Fx+int32(1), b.Fy+int32(1), libc.Uint32FromInt32(b.Fwidth-int32(2)), libc.Uint32FromInt32(b.Fheight-int32(2))) } else { /* * Draw the field element as usual */ XTk_Fill3DRectangle(tls, tkwin, d, border, b.Fx, b.Fy, b.Fwidth, b.Fheight, 0, int32(TK_RELIEF_SUNKEN)) _DrawFieldBorder(tls, tkwin, d, border, borderColor, b) /* * Change the color of the border's outermost pixels */ libx11.XXDrawRectangle(tls, disp, d, focusGC, b.Fx, b.Fy, libc.Uint32FromInt32(b.Fwidth-int32(1)), libc.Uint32FromInt32(b.Fheight-int32(1))) } } else { XTk_Fill3DRectangle(tls, tkwin, d, border, b.Fx, b.Fy, b.Fwidth, b.Fheight, 0, int32(TK_RELIEF_SUNKEN)) _DrawFieldBorder(tls, tkwin, d, border, borderColor, b) } } var _FieldElementSpec1 = TTtk_ElementSpec{ Fversion: int32(TK_STYLE_VERSION_2), FelementSize: uint64(32), Foptions: uintptr(unsafe.Pointer(&_FieldElementOptions1)), } func init() { p := unsafe.Pointer(&_FieldElementSpec1) *(*uintptr)(unsafe.Add(p, 24)) = __ccgo_fp(_FieldElementSize1) *(*uintptr)(unsafe.Add(p, 32)) = __ccgo_fp(_FieldElementDraw1) } var _checkbtnOffData1 = [372]uint8{' ', ' ', ' ', ' ', '<', 's', 'v', 'g', ' ', 'w', 'i', 'd', 't', 'h', '=', '\'', '1', '6', '\'', ' ', 'h', 'e', 'i', 'g', 'h', 't', '=', '\'', '1', '6', '\'', ' ', 'v', 'e', 'r', 's', 'i', 'o', 'n', '=', '\'', '1', '.', '1', '\'', ' ', 'x', 'm', 'l', 'n', 's', '=', '\'', 'h', 't', 't', 'p', ':', '/', '/', 'w', 'w', 'w', '.', 'w', '3', '.', 'o', 'r', 'g', '/', '2', '0', '0', '0', '/', 's', 'v', 'g', '\'', '>', 10, ' ', ' ', ' ', ' ', ' ', '<', 'p', 'a', 't', 'h', ' ', 'd', '=', '\'', 'm', '0', ' ', '0', 'v', '1', '5', 'h', '1', 'v', '-', '1', '4', 'h', '1', '4', 'v', '-', '1', 'z', '\'', ' ', 'f', 'i', 'l', 'l', '=', '\'', '#', '8', '8', '8', '8', '8', '8', '\'', '/', '>', 10, ' ', ' ', ' ', ' ', ' ', '<', 'p', 'a', 't', 'h', ' ', 'd', '=', '\'', 'm', '1', ' ', '1', 'v', '1', '3', 'h', '1', 'v', '-', '1', '2', 'h', '1', '2', 'v', '-', '1', 'z', '\'', ' ', 'f', 'i', 'l', 'l', '=', '\'', '#', '4', '1', '4', '1', '4', '1', '\'', '/', '>', 10, ' ', ' ', ' ', ' ', ' ', '<', 'p', 'a', 't', 'h', ' ', 'd', '=', '\'', 'm', '1', '4', ' ', '1', 'v', '1', '3', 'h', '-', '1', '3', 'v', '1', 'h', '1', '4', 'v', '-', '1', '4', 'z', '\'', ' ', 'f', 'i', 'l', 'l', '=', '\'', '#', 'd', '9', 'd', '9', 'd', '9', '\'', '/', '>', 10, ' ', ' ', ' ', ' ', ' ', '<', 'p', 'a', 't', 'h', ' ', 'd', '=', '\'', 'm', '1', '5', ' ', '0', 'v', '1', '5', 'h', '-', '1', '5', 'v', '1', 'h', '1', '6', 'v', '-', '1', '6', 'z', '\'', ' ', 'f', 'i', 'l', 'l', '=', '\'', '#', 'e', 'e', 'e', 'e', 'e', 'e', '\'', '/', '>', 10, ' ', ' ', ' ', ' ', ' ', '<', 'r', 'e', 'c', 't', ' ', 'x', '=', '\'', '2', '\'', ' ', 'y', '=', '\'', '2', '\'', ' ', 'w', 'i', 'd', 't', 'h', '=', '\'', '1', '2', '\'', ' ', 'h', 'e', 'i', 'g', 'h', 't', '=', '\'', '1', '2', '\'', ' ', 'f', 'i', 'l', 'l', '=', '\'', '#', 'f', 'f', 'f', 'f', 'f', 'f', '\'', '/', '>', 10, ' ', ' ', ' ', ' ', '<', '/', 's', 'v', 'g', '>'} var _checkbtnOnData1 = [497]uint8{' ', ' ', ' ', ' ', '<', 's', 'v', 'g', ' ', 'w', 'i', 'd', 't', 'h', '=', '\'', '1', '6', '\'', ' ', 'h', 'e', 'i', 'g', 'h', 't', '=', '\'', '1', '6', '\'', ' ', 'v', 'e', 'r', 's', 'i', 'o', 'n', '=', '\'', '1', '.', '1', '\'', ' ', 'x', 'm', 'l', 'n', 's', '=', '\'', 'h', 't', 't', 'p', ':', '/', '/', 'w', 'w', 'w', '.', 'w', '3', '.', 'o', 'r', 'g', '/', '2', '0', '0', '0', '/', 's', 'v', 'g', '\'', '>', 10, ' ', ' ', ' ', ' ', ' ', '<', 'p', 'a', 't', 'h', ' ', 'd', '=', '\'', 'm', '0', ' ', '0', 'v', '1', '5', 'h', '1', 'v', '-', '1', '4', 'h', '1', '4', 'v', '-', '1', 'z', '\'', ' ', 'f', 'i', 'l', 'l', '=', '\'', '#', '8', '8', '8', '8', '8', '8', '\'', '/', '>', 10, ' ', ' ', ' ', ' ', ' ', '<', 'p', 'a', 't', 'h', ' ', 'd', '=', '\'', 'm', '1', ' ', '1', 'v', '1', '3', 'h', '1', 'v', '-', '1', '2', 'h', '1', '2', 'v', '-', '1', 'z', '\'', ' ', 'f', 'i', 'l', 'l', '=', '\'', '#', '4', '1', '4', '1', '4', '1', '\'', '/', '>', 10, ' ', ' ', ' ', ' ', ' ', '<', 'p', 'a', 't', 'h', ' ', 'd', '=', '\'', 'm', '1', '4', ' ', '1', 'v', '1', '3', 'h', '-', '1', '3', 'v', '1', 'h', '1', '4', 'v', '-', '1', '4', 'z', '\'', ' ', 'f', 'i', 'l', 'l', '=', '\'', '#', 'd', '9', 'd', '9', 'd', '9', '\'', '/', '>', 10, ' ', ' ', ' ', ' ', ' ', '<', 'p', 'a', 't', 'h', ' ', 'd', '=', '\'', 'm', '1', '5', ' ', '0', 'v', '1', '5', 'h', '-', '1', '5', 'v', '1', 'h', '1', '6', 'v', '-', '1', '6', 'z', '\'', ' ', 'f', 'i', 'l', 'l', '=', '\'', '#', 'e', 'e', 'e', 'e', 'e', 'e', '\'', '/', '>', 10, ' ', ' ', ' ', ' ', ' ', '<', 'r', 'e', 'c', 't', ' ', 'x', '=', '\'', '2', '\'', ' ', 'y', '=', '\'', '2', '\'', ' ', 'w', 'i', 'd', 't', 'h', '=', '\'', '1', '2', '\'', ' ', 'h', 'e', 'i', 'g', 'h', 't', '=', '\'', '1', '2', '\'', ' ', 'f', 'i', 'l', 'l', '=', '\'', '#', 'f', 'f', 'f', 'f', 'f', 'f', '\'', '/', '>', 10, ' ', ' ', ' ', ' ', ' ', '<', 'p', 'a', 't', 'h', ' ', 'd', '=', '\'', 'm', '4', '.', '5', ' ', '8', ' ', '3', ' ', '3', ' ', '4', '-', '6', '\'', ' ', 'f', 'i', 'l', 'l', '=', '\'', 'n', 'o', 'n', 'e', '\'', ' ', 's', 't', 'r', 'o', 'k', 'e', '=', '\'', '#', '0', '0', '0', '0', '0', '0', '\'', ' ', 's', 't', 'r', 'o', 'k', 'e', '-', 'l', 'i', 'n', 'e', 'c', 'a', 'p', '=', '\'', 'r', 'o', 'u', 'n', 'd', '\'', ' ', 's', 't', 'r', 'o', 'k', 'e', '-', 'l', 'i', 'n', 'e', 'j', 'o', 'i', 'n', '=', '\'', 'r', 'o', 'u', 'n', 'd', '\'', ' ', 's', 't', 'r', 'o', 'k', 'e', '-', 'w', 'i', 'd', 't', 'h', '=', '\'', '2', '\'', '/', '>', 10, ' ', ' ', ' ', ' ', '<', '/', 's', 'v', 'g', '>'} var _checkbutton_spec1 = TIndicatorSpec{ Fwidth: int32(16), Fheight: int32(16), FoffDataPtr: uintptr(unsafe.Pointer(&_checkbtnOffData1)), FonDataPtr: uintptr(unsafe.Pointer(&_checkbtnOnData1)), } var _radiobtnOffData1 = [758]uint8{' ', ' ', ' ', ' ', '<', 's', 'v', 'g', ' ', 'w', 'i', 'd', 't', 'h', '=', '\'', '1', '6', '\'', ' ', 'h', 'e', 'i', 'g', 'h', 't', '=', '\'', '1', '6', '\'', ' ', 'v', 'e', 'r', 's', 'i', 'o', 'n', '=', '\'', '1', '.', '1', '\'', ' ', 'x', 'm', 'l', 'n', 's', '=', '\'', 'h', 't', 't', 'p', ':', '/', '/', 'w', 'w', 'w', '.', 'w', '3', '.', 'o', 'r', 'g', '/', '2', '0', '0', '0', '/', 's', 'v', 'g', '\'', '>', 10, ' ', ' ', ' ', ' ', ' ', '<', 'd', 'e', 'f', 's', '>', 10, ' ', ' ', ' ', ' ', ' ', ' ', '<', 'l', 'i', 'n', 'e', 'a', 'r', 'G', 'r', 'a', 'd', 'i', 'e', 'n', 't', ' ', 'i', 'd', '=', '\'', 'l', 'i', 'n', 'e', 'a', 'r', 'G', 'r', 'a', 'd', 'i', 'e', 'n', 't', 'O', 'u', 't', 'e', 'r', '\'', ' ', 'x', '1', '=', '\'', '5', '\'', ' ', 'y', '1', '=', '\'', '5', '\'', ' ', 'x', '2', '=', '\'', '1', '1', '\'', ' ', 'y', '2', '=', '\'', '1', '1', '\'', ' ', 'g', 'r', 'a', 'd', 'i', 'e', 'n', 't', 'U', 'n', 'i', 't', 's', '=', '\'', 'u', 's', 'e', 'r', 'S', 'p', 'a', 'c', 'e', 'O', 'n', 'U', 's', 'e', '\'', '>', 10, ' ', ' ', ' ', ' ', ' ', ' ', ' ', '<', 's', 't', 'o', 'p', ' ', 's', 't', 'o', 'p', '-', 'c', 'o', 'l', 'o', 'r', '=', '\'', '#', '8', '8', '8', '8', '8', '8', '\'', ' ', 'o', 'f', 'f', 's', 'e', 't', '=', '\'', '0', '\'', '/', '>', 10, ' ', ' ', ' ', ' ', ' ', ' ', ' ', '<', 's', 't', 'o', 'p', ' ', 's', 't', 'o', 'p', '-', 'c', 'o', 'l', 'o', 'r', '=', '\'', '#', 'e', 'e', 'e', 'e', 'e', 'e', '\'', ' ', 'o', 'f', 'f', 's', 'e', 't', '=', '\'', '1', '\'', '/', '>', 10, ' ', ' ', ' ', ' ', ' ', ' ', '<', '/', 'l', 'i', 'n', 'e', 'a', 'r', 'G', 'r', 'a', 'd', 'i', 'e', 'n', 't', '>', 10, ' ', ' ', ' ', ' ', ' ', ' ', '<', 'l', 'i', 'n', 'e', 'a', 'r', 'G', 'r', 'a', 'd', 'i', 'e', 'n', 't', ' ', 'i', 'd', '=', '\'', 'l', 'i', 'n', 'e', 'a', 'r', 'G', 'r', 'a', 'd', 'i', 'e', 'n', 't', 'I', 'n', 'n', 'e', 'r', '\'', ' ', 'x', '1', '=', '\'', '5', '\'', ' ', 'y', '1', '=', '\'', '5', '\'', ' ', 'x', '2', '=', '\'', '1', '1', '\'', ' ', 'y', '2', '=', '\'', '1', '1', '\'', ' ', 'g', 'r', 'a', 'd', 'i', 'e', 'n', 't', 'U', 'n', 'i', 't', 's', '=', '\'', 'u', 's', 'e', 'r', 'S', 'p', 'a', 'c', 'e', 'O', 'n', 'U', 's', 'e', '\'', '>', 10, ' ', ' ', ' ', ' ', ' ', ' ', ' ', '<', 's', 't', 'o', 'p', ' ', 's', 't', 'o', 'p', '-', 'c', 'o', 'l', 'o', 'r', '=', '\'', '#', '4', '1', '4', '1', '4', '1', '\'', ' ', 'o', 'f', 'f', 's', 'e', 't', '=', '\'', '0', '\'', '/', '>', 10, ' ', ' ', ' ', ' ', ' ', ' ', ' ', '<', 's', 't', 'o', 'p', ' ', 's', 't', 'o', 'p', '-', 'c', 'o', 'l', 'o', 'r', '=', '\'', '#', 'd', '9', 'd', '9', 'd', '9', '\'', ' ', 'o', 'f', 'f', 's', 'e', 't', '=', '\'', '1', '\'', '/', '>', 10, ' ', ' ', ' ', ' ', ' ', ' ', '<', '/', 'l', 'i', 'n', 'e', 'a', 'r', 'G', 'r', 'a', 'd', 'i', 'e', 'n', 't', '>', 10, ' ', ' ', ' ', ' ', ' ', '<', '/', 'd', 'e', 'f', 's', '>', 10, ' ', ' ', ' ', ' ', ' ', '<', 'c', 'i', 'r', 'c', 'l', 'e', ' ', 'c', 'x', '=', '\'', '8', '\'', ' ', 'c', 'y', '=', '\'', '8', '\'', ' ', 'r', '=', '\'', '8', '\'', ' ', 'f', 'i', 'l', 'l', '=', '\'', 'u', 'r', 'l', '(', '#', 'l', 'i', 'n', 'e', 'a', 'r', 'G', 'r', 'a', 'd', 'i', 'e', 'n', 't', 'O', 'u', 't', 'e', 'r', ')', '\'', '/', '>', 10, ' ', ' ', ' ', ' ', ' ', '<', 'c', 'i', 'r', 'c', 'l', 'e', ' ', 'c', 'x', '=', '\'', '8', '\'', ' ', 'c', 'y', '=', '\'', '8', '\'', ' ', 'r', '=', '\'', '7', '\'', ' ', 'f', 'i', 'l', 'l', '=', '\'', 'u', 'r', 'l', '(', '#', 'l', 'i', 'n', 'e', 'a', 'r', 'G', 'r', 'a', 'd', 'i', 'e', 'n', 't', 'I', 'n', 'n', 'e', 'r', ')', '\'', '/', '>', 10, ' ', ' ', ' ', ' ', ' ', '<', 'c', 'i', 'r', 'c', 'l', 'e', ' ', 'c', 'x', '=', '\'', '8', '\'', ' ', 'c', 'y', '=', '\'', '8', '\'', ' ', 'r', '=', '\'', '6', '\'', ' ', 'f', 'i', 'l', 'l', '=', '\'', '#', 'f', 'f', 'f', 'f', 'f', 'f', '\'', '/', '>', 10, ' ', ' ', ' ', ' ', '<', '/', 's', 'v', 'g', '>'} var _radiobtnOnData1 = [808]uint8{' ', ' ', ' ', ' ', '<', 's', 'v', 'g', ' ', 'w', 'i', 'd', 't', 'h', '=', '\'', '1', '6', '\'', ' ', 'h', 'e', 'i', 'g', 'h', 't', '=', '\'', '1', '6', '\'', ' ', 'v', 'e', 'r', 's', 'i', 'o', 'n', '=', '\'', '1', '.', '1', '\'', ' ', 'x', 'm', 'l', 'n', 's', '=', '\'', 'h', 't', 't', 'p', ':', '/', '/', 'w', 'w', 'w', '.', 'w', '3', '.', 'o', 'r', 'g', '/', '2', '0', '0', '0', '/', 's', 'v', 'g', '\'', '>', 10, ' ', ' ', ' ', ' ', ' ', '<', 'd', 'e', 'f', 's', '>', 10, ' ', ' ', ' ', ' ', ' ', ' ', '<', 'l', 'i', 'n', 'e', 'a', 'r', 'G', 'r', 'a', 'd', 'i', 'e', 'n', 't', ' ', 'i', 'd', '=', '\'', 'l', 'i', 'n', 'e', 'a', 'r', 'G', 'r', 'a', 'd', 'i', 'e', 'n', 't', 'O', 'u', 't', 'e', 'r', '\'', ' ', 'x', '1', '=', '\'', '5', '\'', ' ', 'y', '1', '=', '\'', '5', '\'', ' ', 'x', '2', '=', '\'', '1', '1', '\'', ' ', 'y', '2', '=', '\'', '1', '1', '\'', ' ', 'g', 'r', 'a', 'd', 'i', 'e', 'n', 't', 'U', 'n', 'i', 't', 's', '=', '\'', 'u', 's', 'e', 'r', 'S', 'p', 'a', 'c', 'e', 'O', 'n', 'U', 's', 'e', '\'', '>', 10, ' ', ' ', ' ', ' ', ' ', ' ', ' ', '<', 's', 't', 'o', 'p', ' ', 's', 't', 'o', 'p', '-', 'c', 'o', 'l', 'o', 'r', '=', '\'', '#', '8', '8', '8', '8', '8', '8', '\'', ' ', 'o', 'f', 'f', 's', 'e', 't', '=', '\'', '0', '\'', '/', '>', 10, ' ', ' ', ' ', ' ', ' ', ' ', ' ', '<', 's', 't', 'o', 'p', ' ', 's', 't', 'o', 'p', '-', 'c', 'o', 'l', 'o', 'r', '=', '\'', '#', 'e', 'e', 'e', 'e', 'e', 'e', '\'', ' ', 'o', 'f', 'f', 's', 'e', 't', '=', '\'', '1', '\'', '/', '>', 10, ' ', ' ', ' ', ' ', ' ', ' ', '<', '/', 'l', 'i', 'n', 'e', 'a', 'r', 'G', 'r', 'a', 'd', 'i', 'e', 'n', 't', '>', 10, ' ', ' ', ' ', ' ', ' ', ' ', '<', 'l', 'i', 'n', 'e', 'a', 'r', 'G', 'r', 'a', 'd', 'i', 'e', 'n', 't', ' ', 'i', 'd', '=', '\'', 'l', 'i', 'n', 'e', 'a', 'r', 'G', 'r', 'a', 'd', 'i', 'e', 'n', 't', 'I', 'n', 'n', 'e', 'r', '\'', ' ', 'x', '1', '=', '\'', '5', '\'', ' ', 'y', '1', '=', '\'', '5', '\'', ' ', 'x', '2', '=', '\'', '1', '1', '\'', ' ', 'y', '2', '=', '\'', '1', '1', '\'', ' ', 'g', 'r', 'a', 'd', 'i', 'e', 'n', 't', 'U', 'n', 'i', 't', 's', '=', '\'', 'u', 's', 'e', 'r', 'S', 'p', 'a', 'c', 'e', 'O', 'n', 'U', 's', 'e', '\'', '>', 10, ' ', ' ', ' ', ' ', ' ', ' ', ' ', '<', 's', 't', 'o', 'p', ' ', 's', 't', 'o', 'p', '-', 'c', 'o', 'l', 'o', 'r', '=', '\'', '#', '4', '1', '4', '1', '4', '1', '\'', ' ', 'o', 'f', 'f', 's', 'e', 't', '=', '\'', '0', '\'', '/', '>', 10, ' ', ' ', ' ', ' ', ' ', ' ', ' ', '<', 's', 't', 'o', 'p', ' ', 's', 't', 'o', 'p', '-', 'c', 'o', 'l', 'o', 'r', '=', '\'', '#', 'd', '9', 'd', '9', 'd', '9', '\'', ' ', 'o', 'f', 'f', 's', 'e', 't', '=', '\'', '1', '\'', '/', '>', 10, ' ', ' ', ' ', ' ', ' ', ' ', '<', '/', 'l', 'i', 'n', 'e', 'a', 'r', 'G', 'r', 'a', 'd', 'i', 'e', 'n', 't', '>', 10, ' ', ' ', ' ', ' ', ' ', '<', '/', 'd', 'e', 'f', 's', '>', 10, ' ', ' ', ' ', ' ', ' ', '<', 'c', 'i', 'r', 'c', 'l', 'e', ' ', 'c', 'x', '=', '\'', '8', '\'', ' ', 'c', 'y', '=', '\'', '8', '\'', ' ', 'r', '=', '\'', '8', '\'', ' ', 'f', 'i', 'l', 'l', '=', '\'', 'u', 'r', 'l', '(', '#', 'l', 'i', 'n', 'e', 'a', 'r', 'G', 'r', 'a', 'd', 'i', 'e', 'n', 't', 'O', 'u', 't', 'e', 'r', ')', '\'', '/', '>', 10, ' ', ' ', ' ', ' ', ' ', '<', 'c', 'i', 'r', 'c', 'l', 'e', ' ', 'c', 'x', '=', '\'', '8', '\'', ' ', 'c', 'y', '=', '\'', '8', '\'', ' ', 'r', '=', '\'', '7', '\'', ' ', 'f', 'i', 'l', 'l', '=', '\'', 'u', 'r', 'l', '(', '#', 'l', 'i', 'n', 'e', 'a', 'r', 'G', 'r', 'a', 'd', 'i', 'e', 'n', 't', 'I', 'n', 'n', 'e', 'r', ')', '\'', '/', '>', 10, ' ', ' ', ' ', ' ', ' ', '<', 'c', 'i', 'r', 'c', 'l', 'e', ' ', 'c', 'x', '=', '\'', '8', '\'', ' ', 'c', 'y', '=', '\'', '8', '\'', ' ', 'r', '=', '\'', '6', '\'', ' ', 'f', 'i', 'l', 'l', '=', '\'', '#', 'f', 'f', 'f', 'f', 'f', 'f', '\'', '/', '>', 10, ' ', ' ', ' ', ' ', ' ', '<', 'c', 'i', 'r', 'c', 'l', 'e', ' ', 'c', 'x', '=', '\'', '8', '\'', ' ', 'c', 'y', '=', '\'', '8', '\'', ' ', 'r', '=', '\'', '3', '\'', ' ', 'f', 'i', 'l', 'l', '=', '\'', '#', '0', '0', '0', '0', '0', '0', '\'', '/', '>', 10, ' ', ' ', ' ', ' ', '<', '/', 's', 'v', 'g', '>'} var _radiobutton_spec1 = TIndicatorSpec{ Fwidth: int32(16), Fheight: int32(16), FoffDataPtr: uintptr(unsafe.Pointer(&_radiobtnOffData1)), FonDataPtr: uintptr(unsafe.Pointer(&_radiobtnOnData1)), } type TIndicatorElement2 = struct { FbackgroundObj uintptr FforegroundObj uintptr FcolorObj uintptr FlightColorObj uintptr FshadeColorObj uintptr FborderColorObj uintptr FmarginObj uintptr } var _IndicatorElementOptions2 = [8]TTtk_ElementOptionSpec{ 0: { FoptionName: __ccgo_ts + 19898, Ftype1: int32(TK_OPTION_COLOR), FdefaultValue: __ccgo_ts + 19921, }, 1: { FoptionName: __ccgo_ts + 20085, Ftype1: int32(TK_OPTION_COLOR), Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 8)), FdefaultValue: __ccgo_ts + 39099, }, 2: { FoptionName: __ccgo_ts + 50394, Ftype1: int32(TK_OPTION_COLOR), Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 16)), FdefaultValue: __ccgo_ts + 51195, }, 3: { FoptionName: __ccgo_ts + 49747, Ftype1: int32(TK_OPTION_COLOR), Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 24)), FdefaultValue: __ccgo_ts + 51203, }, 4: { FoptionName: __ccgo_ts + 51211, Ftype1: int32(TK_OPTION_COLOR), Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 32)), FdefaultValue: __ccgo_ts + 51223, }, 5: { FoptionName: __ccgo_ts + 49726, Ftype1: int32(TK_OPTION_COLOR), Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 40)), FdefaultValue: __ccgo_ts + 39099, }, 6: { FoptionName: __ccgo_ts + 49795, Ftype1: int32(TK_OPTION_STRING), Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 48)), FdefaultValue: __ccgo_ts + 50445, }, 7: {}, } func _IndicatorElementSize1(tls *libc.TLS, clientData uintptr, elementRecord uintptr, tkwin TTk_Window, widthPtr uintptr, heightPtr uintptr, dummy538 uintptr) { bp := tls.Alloc(16) defer tls.Free(16) var indicator, spec uintptr var scalingLevel float64 var _ /* margins at bp+0 */ TTtk_Padding _, _, _ = indicator, scalingLevel, spec spec = clientData indicator = elementRecord scalingLevel = XTkScalingLevel(tls, tkwin) XTtk_GetPaddingFromObj(tls, libc.UintptrFromInt32(0), tkwin, (*TIndicatorElement2)(unsafe.Pointer(indicator)).FmarginObj, bp) *(*int32)(unsafe.Pointer(widthPtr)) = int32(float64(float64((*TIndicatorSpec)(unsafe.Pointer(spec)).Fwidth)*scalingLevel) + float64(int32((*(*TTtk_Padding)(unsafe.Pointer(bp))).Fleft)+int32((*(*TTtk_Padding)(unsafe.Pointer(bp))).Fright))) *(*int32)(unsafe.Pointer(heightPtr)) = int32(float64(float64((*TIndicatorSpec)(unsafe.Pointer(spec)).Fheight)*scalingLevel) + float64(int32((*(*TTtk_Padding)(unsafe.Pointer(bp))).Ftop)+int32((*(*TTtk_Padding)(unsafe.Pointer(bp))).Fbottom))) } func _ColorToStr1(tls *libc.TLS, colorPtr uintptr, colorStr uintptr) { bp := tls.Alloc(32) defer tls.Free(32) /* in the format "RRGGBB" */ libc.X__builtin_snprintf(tls, colorStr, uint64(7), __ccgo_ts+49890, libc.VaList(bp+8, libc.Int32FromUint16((*TXColor)(unsafe.Pointer(colorPtr)).Fred)>>int32(8), libc.Int32FromUint16((*TXColor)(unsafe.Pointer(colorPtr)).Fgreen)>>int32(8), libc.Int32FromUint16((*TXColor)(unsafe.Pointer(colorPtr)).Fblue)>>int32(8))) } func _ImageChanged1(tls *libc.TLS, dummy558 uintptr, dummy559 int32, dummy560 int32, dummy561 int32, dummy562 int32, dummy563 int32, dummy564 int32) { } func _IndicatorElementDraw1(tls *libc.TLS, clientData uintptr, elementRecord uintptr, tkwin TTk_Window, d TDrawable, b TTtk_Box, state TTtk_State) { bp := tls.Alloc(192) defer tls.Free(192) var bgColorPtr, borderColorPtr, cmdFmt, fgColorPtr, highlightColorPtr, indicator, indicatorColorPtr, interp, script, shadeColorPtr, spec, svgDataCopy, svgDataPtr, v1, v2 uintptr var code, height, width int32 var img TTk_Image var scalingLevel float64 var scriptSize, svgDataLen Tsize_t var selected uint32 var _ /* bgColorStr at bp+14 */ [7]uint8 var _ /* borderColorStr at bp+42 */ [7]uint8 var _ /* fgColorStr at bp+21 */ [7]uint8 var _ /* imgName at bp+49 */ [70]uint8 var _ /* indicatorColorStr at bp+28 */ [7]uint8 var _ /* padding at bp+0 */ TTtk_Padding var _ /* shadeColorStr at bp+35 */ [7]uint8 _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = bgColorPtr, borderColorPtr, cmdFmt, code, fgColorPtr, height, highlightColorPtr, img, indicator, indicatorColorPtr, interp, scalingLevel, script, scriptSize, selected, shadeColorPtr, spec, svgDataCopy, svgDataLen, svgDataPtr, width, v1, v2 indicator = elementRecord spec = clientData scalingLevel = XTkScalingLevel(tls, tkwin) width = int32(float64((*TIndicatorSpec)(unsafe.Pointer(spec)).Fwidth) * scalingLevel) height = int32(float64((*TIndicatorSpec)(unsafe.Pointer(spec)).Fheight) * scalingLevel) selected = state & libc.Uint32FromInt32(libc.Int32FromInt32(1)< 0 && *(*int32)(unsafe.Pointer(bp + 4)) != TK_RELIEF_FLAT { XTk_Draw3DRectangle(tls, tkwin, d, border, b.Fx, b.Fy, b.Fwidth, b.Fheight, *(*int32)(unsafe.Pointer(bp)), *(*int32)(unsafe.Pointer(bp + 4))) } } var _BorderElementSpec2 = TTtk_ElementSpec{ Fversion: int32(TK_STYLE_VERSION_2), FelementSize: uint64(24), Foptions: uintptr(unsafe.Pointer(&_BorderElementOptions2)), } func init() { p := unsafe.Pointer(&_BorderElementSpec2) *(*uintptr)(unsafe.Add(p, 24)) = __ccgo_fp(_BorderElementSize2) *(*uintptr)(unsafe.Add(p, 32)) = __ccgo_fp(_BorderElementDraw2) } // C documentation // // /*---------------------------------------------------------------------- // * +++ Field element. // * Used for editable fields. // */ type TFieldElement2 = struct { FborderObj uintptr FborderWidthObj uintptr FfocusWidthObj uintptr FfocusColorObj uintptr } var _FieldElementOptions2 = [5]TTtk_ElementOptionSpec{ 0: { FoptionName: __ccgo_ts + 49778, Ftype1: int32(TK_OPTION_BORDER), FdefaultValue: __ccgo_ts + 39093, }, 1: { FoptionName: __ccgo_ts + 2814, Ftype1: int32(TK_OPTION_PIXELS), Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 8)), FdefaultValue: __ccgo_ts + 21412, }, 2: { FoptionName: __ccgo_ts + 51163, Ftype1: int32(TK_OPTION_PIXELS), Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 16)), FdefaultValue: __ccgo_ts + 21412, }, 3: { FoptionName: __ccgo_ts + 51175, Ftype1: int32(TK_OPTION_COLOR), Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 24)), FdefaultValue: __ccgo_ts + 51187, }, 4: {}, } func _FieldElementSize2(tls *libc.TLS, dummy212 uintptr, elementRecord uintptr, tkwin TTk_Window, dummy215 uintptr, dummy216 uintptr, paddingPtr uintptr) { bp := tls.Alloc(16) defer tls.Free(16) var field uintptr var _ /* borderWidth at bp+0 */ int32 var _ /* focusWidth at bp+4 */ int32 _ = field field = elementRecord *(*int32)(unsafe.Pointer(bp)) = int32(2) *(*int32)(unsafe.Pointer(bp + 4)) = int32(2) XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), tkwin, (*TFieldElement2)(unsafe.Pointer(field)).FborderWidthObj, bp) XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), tkwin, (*TFieldElement2)(unsafe.Pointer(field)).FfocusWidthObj, bp+4) if *(*int32)(unsafe.Pointer(bp + 4)) > 0 && *(*int32)(unsafe.Pointer(bp)) < int32(2) { *(*int32)(unsafe.Pointer(bp)) += *(*int32)(unsafe.Pointer(bp + 4)) - *(*int32)(unsafe.Pointer(bp)) } *(*TTtk_Padding)(unsafe.Pointer(paddingPtr)) = XTtk_UniformPadding(tls, int16(*(*int32)(unsafe.Pointer(bp)))) } func _FieldElementDraw2(tls *libc.TLS, dummy231 uintptr, elementRecord uintptr, tkwin TTk_Window, d TDrawable, b TTtk_Box, state TTtk_State) { bp := tls.Alloc(16) defer tls.Free(16) var bgGC, focusGC TGC var border TTk_3DBorder var disp, field, focusColor uintptr var w, x1, x2, y1, y2 int32 var _ /* borderWidth at bp+4 */ int32 var _ /* borderWidth at bp+8 */ int32 var _ /* focusWidth at bp+0 */ int32 _, _, _, _, _, _, _, _, _, _, _ = bgGC, border, disp, field, focusColor, focusGC, w, x1, x2, y1, y2 field = elementRecord border = XTk_Get3DBorderFromObj(tls, tkwin, (*TFieldElement2)(unsafe.Pointer(field)).FborderObj) *(*int32)(unsafe.Pointer(bp)) = int32(2) XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), tkwin, (*TFieldElement2)(unsafe.Pointer(field)).FfocusWidthObj, bp) if *(*int32)(unsafe.Pointer(bp)) > 0 && state&libc.Uint32FromInt32(libc.Int32FromInt32(1)< int32(1) { x1 = b.Fx x2 = b.Fx + b.Fwidth - int32(1) y1 = b.Fy y2 = b.Fy + b.Fheight - int32(1) w = WIN32_XDRAWLINE_HACK /* * Draw the outer rounded rectangle */ libx11.XXDrawLine(tls, disp, d, focusGC, x1+int32(1), y1, x2-int32(1)+w, y1) /* N */ libx11.XXDrawLine(tls, disp, d, focusGC, x1+int32(1), y2, x2-int32(1)+w, y2) /* S */ libx11.XXDrawLine(tls, disp, d, focusGC, x1, y1+int32(1), x1, y2-int32(1)+w) /* W */ libx11.XXDrawLine(tls, disp, d, focusGC, x2, y1+int32(1), x2, y2-int32(1)+w) /* E */ /* * Draw the inner rectangle */ b.Fx += int32(1) b.Fy += int32(1) b.Fwidth -= int32(2) b.Fheight -= int32(2) libx11.XXDrawRectangle(tls, disp, d, focusGC, b.Fx, b.Fy, libc.Uint32FromInt32(b.Fwidth-int32(1)), libc.Uint32FromInt32(b.Fheight-int32(1))) /* * Fill the inner rectangle */ bgGC = XTk_3DBorderGC(tls, tkwin, border, int32(TK_3D_FLAT_GC)) libx11.XXFillRectangle(tls, disp, d, bgGC, b.Fx+int32(1), b.Fy+int32(1), libc.Uint32FromInt32(b.Fwidth-int32(2)), libc.Uint32FromInt32(b.Fheight-int32(2))) } else { /* * Draw the field element as usual */ *(*int32)(unsafe.Pointer(bp + 4)) = int32(2) XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), tkwin, (*TFieldElement2)(unsafe.Pointer(field)).FborderWidthObj, bp+4) XTk_Fill3DRectangle(tls, tkwin, d, border, b.Fx, b.Fy, b.Fwidth, b.Fheight, *(*int32)(unsafe.Pointer(bp + 4)), int32(TK_RELIEF_SUNKEN)) /* * Change the color of the border's outermost pixels */ libx11.XXDrawRectangle(tls, disp, d, focusGC, b.Fx, b.Fy, libc.Uint32FromInt32(b.Fwidth-int32(1)), libc.Uint32FromInt32(b.Fheight-int32(1))) } } else { *(*int32)(unsafe.Pointer(bp + 8)) = int32(2) XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), tkwin, (*TFieldElement2)(unsafe.Pointer(field)).FborderWidthObj, bp+8) XTk_Fill3DRectangle(tls, tkwin, d, border, b.Fx, b.Fy, b.Fwidth, b.Fheight, *(*int32)(unsafe.Pointer(bp + 8)), int32(TK_RELIEF_SUNKEN)) } } var _FieldElementSpec2 = TTtk_ElementSpec{ Fversion: int32(TK_STYLE_VERSION_2), FelementSize: uint64(32), Foptions: uintptr(unsafe.Pointer(&_FieldElementOptions2)), } func init() { p := unsafe.Pointer(&_FieldElementSpec2) *(*uintptr)(unsafe.Add(p, 24)) = __ccgo_fp(_FieldElementSize2) *(*uintptr)(unsafe.Add(p, 32)) = __ccgo_fp(_FieldElementDraw2) } /* *---------------------------------------------------------------------- * +++ Padding element. * * This element has no visual representation, only geometry. * It adds a (possibly non-uniform) internal border. * In addition, if "-shiftrelief" is specified, * adds additional pixels to shift child elements "in" or "out" * depending on the -relief. */ type TPaddingElement = struct { FpaddingObj uintptr FreliefObj uintptr FshiftreliefObj uintptr } var _PaddingElementOptions = [4]TTtk_ElementOptionSpec{ 0: { FoptionName: __ccgo_ts + 49128, Ftype1: int32(TK_OPTION_STRING), FdefaultValue: __ccgo_ts + 10533, }, 1: { FoptionName: __ccgo_ts + 20346, Ftype1: int32(TK_OPTION_RELIEF), Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 8)), FdefaultValue: __ccgo_ts, }, 2: { FoptionName: __ccgo_ts + 51379, Ftype1: int32(TK_OPTION_PIXELS), Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 16)), FdefaultValue: __ccgo_ts + 10533, }, 3: {}, } func _PaddingElementSize(tls *libc.TLS, dummy330 uintptr, elementRecord uintptr, tkwin TTk_Window, dummy333 uintptr, dummy334 uintptr, paddingPtr uintptr) { bp := tls.Alloc(16) defer tls.Free(16) var padding uintptr var _ /* pad at bp+8 */ TTtk_Padding var _ /* relief at bp+4 */ int32 var _ /* shiftRelief at bp+0 */ int32 _ = padding padding = elementRecord *(*int32)(unsafe.Pointer(bp)) = 0 *(*int32)(unsafe.Pointer(bp + 4)) = TK_RELIEF_FLAT XTk_GetReliefFromObj(tls, libc.UintptrFromInt32(0), (*TPaddingElement)(unsafe.Pointer(padding)).FreliefObj, bp+4) XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), tkwin, (*TPaddingElement)(unsafe.Pointer(padding)).FshiftreliefObj, bp) XTtk_GetPaddingFromObj(tls, libc.UintptrFromInt32(0), tkwin, (*TPaddingElement)(unsafe.Pointer(padding)).FpaddingObj, bp+8) *(*TTtk_Padding)(unsafe.Pointer(paddingPtr)) = XTtk_RelievePadding(tls, *(*TTtk_Padding)(unsafe.Pointer(bp + 8)), *(*int32)(unsafe.Pointer(bp + 4)), *(*int32)(unsafe.Pointer(bp))) } var _PaddingElementSpec = TTtk_ElementSpec{ Fversion: int32(TK_STYLE_VERSION_2), FelementSize: uint64(24), Foptions: uintptr(unsafe.Pointer(&_PaddingElementOptions)), } func init() { p := unsafe.Pointer(&_PaddingElementSpec) *(*uintptr)(unsafe.Add(p, 24)) = __ccgo_fp(_PaddingElementSize) *(*uintptr)(unsafe.Add(p, 32)) = __ccgo_fp(XTtkNullElementDraw) } // C documentation // // /*---------------------------------------------------------------------- // * +++ Focus ring element. // * Draws a dashed focus ring, if the widget has keyboard focus. // */ type TFocusElement = struct { FfocusColorObj uintptr FfocusThicknessObj uintptr FfocusSolidObj uintptr } // C documentation // // /* // * DrawFocusRing -- // * Draw a dotted rectangle to indicate focus. // */ func _DrawFocusRing(tls *libc.TLS, tkwin TTk_Window, d TDrawable, colorObj uintptr, thickness int32, solid int32, b TTtk_Box) { bp := tls.Alloc(160) defer tls.Free(160) var color, disp uintptr var gc TGC var _ /* gcValues at bp+0 */ TXGCValues var _ /* rects at bp+128 */ [4]TXRectangle _, _, _ = color, disp, gc color = XTk_GetColorFromObj(tls, tkwin, colorObj) disp = (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fdisplay if thickness < int32(1) && solid != 0 { thickness = int32(1) } (*(*TXGCValues)(unsafe.Pointer(bp))).Fforeground = (*TXColor)(unsafe.Pointer(color)).Fpixel gc = XTk_GetGC(tls, tkwin, libc.Uint64FromInt64(libc.Int64FromInt64(1)<', 10, ' ', ' ', ' ', ' ', ' ', '<', 'r', 'e', 'c', 't', ' ', 'x', '=', '\'', '.', '5', '\'', ' ', 'y', '=', '\'', '.', '5', '\'', ' ', 'w', 'i', 'd', 't', 'h', '=', '\'', '1', '5', '\'', ' ', 'h', 'e', 'i', 'g', 'h', 't', '=', '\'', '1', '5', '\'', ' ', 'r', 'x', '=', '\'', '3', '.', '5', '\'', ' ', 'f', 'i', 'l', 'l', '=', '\'', '#', 'f', 'f', 'f', 'f', 'f', 'f', '\'', ' ', 's', 't', 'r', 'o', 'k', 'e', '=', '\'', '#', '8', '8', '8', '8', '8', '8', '\'', '/', '>', 10, ' ', ' ', ' ', ' ', '<', '/', 's', 'v', 'g', '>'} var _checkbtnOnData2 = [288]uint8{' ', ' ', ' ', ' ', '<', 's', 'v', 'g', ' ', 'w', 'i', 'd', 't', 'h', '=', '\'', '1', '6', '\'', ' ', 'h', 'e', 'i', 'g', 'h', 't', '=', '\'', '1', '6', '\'', ' ', 'v', 'e', 'r', 's', 'i', 'o', 'n', '=', '\'', '1', '.', '1', '\'', ' ', 'x', 'm', 'l', 'n', 's', '=', '\'', 'h', 't', 't', 'p', ':', '/', '/', 'w', 'w', 'w', '.', 'w', '3', '.', 'o', 'r', 'g', '/', '2', '0', '0', '0', '/', 's', 'v', 'g', '\'', '>', 10, ' ', ' ', ' ', ' ', ' ', '<', 'r', 'e', 'c', 't', ' ', 'x', '=', '\'', '0', '\'', ' ', 'y', '=', '\'', '0', '\'', ' ', 'w', 'i', 'd', 't', 'h', '=', '\'', '1', '6', '\'', ' ', 'h', 'e', 'i', 'g', 'h', 't', '=', '\'', '1', '6', '\'', ' ', 'f', 'i', 'l', 'l', '=', '\'', '#', '4', 'a', '6', '9', '8', '4', '\'', ' ', 'r', 'x', '=', '\'', '4', '\'', '/', '>', 10, ' ', ' ', ' ', ' ', ' ', '<', 'p', 'a', 't', 'h', ' ', 'd', '=', '\'', 'm', '4', '.', '5', ' ', '8', ' ', '3', ' ', '3', ' ', '4', '-', '6', '\'', ' ', 'f', 'i', 'l', 'l', '=', '\'', 'n', 'o', 'n', 'e', '\'', ' ', 's', 't', 'r', 'o', 'k', 'e', '=', '\'', '#', 'f', 'f', 'f', 'f', 'f', 'f', '\'', ' ', 's', 't', 'r', 'o', 'k', 'e', '-', 'l', 'i', 'n', 'e', 'c', 'a', 'p', '=', '\'', 'r', 'o', 'u', 'n', 'd', '\'', ' ', 's', 't', 'r', 'o', 'k', 'e', '-', 'l', 'i', 'n', 'e', 'j', 'o', 'i', 'n', '=', '\'', 'r', 'o', 'u', 'n', 'd', '\'', ' ', 's', 't', 'r', 'o', 'k', 'e', '-', 'w', 'i', 'd', 't', 'h', '=', '\'', '2', '\'', '/', '>', 10, ' ', ' ', ' ', ' ', '<', '/', 's', 'v', 'g', '>'} var _checkbtnTriData = [233]uint8{' ', ' ', ' ', ' ', '<', 's', 'v', 'g', ' ', 'w', 'i', 'd', 't', 'h', '=', '\'', '1', '6', '\'', ' ', 'h', 'e', 'i', 'g', 'h', 't', '=', '\'', '1', '6', '\'', ' ', 'v', 'e', 'r', 's', 'i', 'o', 'n', '=', '\'', '1', '.', '1', '\'', ' ', 'x', 'm', 'l', 'n', 's', '=', '\'', 'h', 't', 't', 'p', ':', '/', '/', 'w', 'w', 'w', '.', 'w', '3', '.', 'o', 'r', 'g', '/', '2', '0', '0', '0', '/', 's', 'v', 'g', '\'', '>', 10, ' ', ' ', ' ', ' ', ' ', '<', 'r', 'e', 'c', 't', ' ', 'x', '=', '\'', '0', '\'', ' ', 'y', '=', '\'', '0', '\'', ' ', 'w', 'i', 'd', 't', 'h', '=', '\'', '1', '6', '\'', ' ', 'h', 'e', 'i', 'g', 'h', 't', '=', '\'', '1', '6', '\'', ' ', 'f', 'i', 'l', 'l', '=', '\'', '#', '4', 'a', '6', '9', '8', '4', '\'', ' ', 'r', 'x', '=', '\'', '4', '\'', '/', '>', 10, ' ', ' ', ' ', ' ', ' ', '<', 'p', 'a', 't', 'h', ' ', 'd', '=', '\'', 'm', '4', ' ', '8', 'h', '8', '\'', ' ', 'f', 'i', 'l', 'l', '=', '\'', 'n', 'o', 'n', 'e', '\'', ' ', 's', 't', 'r', 'o', 'k', 'e', '=', '\'', '#', 'f', 'f', 'f', 'f', 'f', 'f', '\'', ' ', 's', 't', 'r', 'o', 'k', 'e', '-', 'w', 'i', 'd', 't', 'h', '=', '\'', '2', '\'', '/', '>', 10, ' ', ' ', ' ', ' ', '<', '/', 's', 'v', 'g', '>'} var _checkbutton_spec2 = TIndicatorSpec1{ Fwidth: int32(16), Fheight: int32(16), FoffDataPtr: uintptr(unsafe.Pointer(&_checkbtnOffData2)), FonDataPtr: uintptr(unsafe.Pointer(&_checkbtnOnData2)), FtriDataPtr: uintptr(unsafe.Pointer(&_checkbtnTriData)), } var _radiobtnOffData2 = [162]uint8{' ', ' ', ' ', ' ', '<', 's', 'v', 'g', ' ', 'w', 'i', 'd', 't', 'h', '=', '\'', '1', '6', '\'', ' ', 'h', 'e', 'i', 'g', 'h', 't', '=', '\'', '1', '6', '\'', ' ', 'v', 'e', 'r', 's', 'i', 'o', 'n', '=', '\'', '1', '.', '1', '\'', ' ', 'x', 'm', 'l', 'n', 's', '=', '\'', 'h', 't', 't', 'p', ':', '/', '/', 'w', 'w', 'w', '.', 'w', '3', '.', 'o', 'r', 'g', '/', '2', '0', '0', '0', '/', 's', 'v', 'g', '\'', '>', 10, ' ', ' ', ' ', ' ', ' ', '<', 'c', 'i', 'r', 'c', 'l', 'e', ' ', 'c', 'x', '=', '\'', '8', '\'', ' ', 'c', 'y', '=', '\'', '8', '\'', ' ', 'r', '=', '\'', '7', '.', '5', '\'', ' ', 'f', 'i', 'l', 'l', '=', '\'', '#', 'f', 'f', 'f', 'f', 'f', 'f', '\'', ' ', 's', 't', 'r', 'o', 'k', 'e', '=', '\'', '#', '8', '8', '8', '8', '8', '8', '\'', '/', '>', 10, ' ', ' ', ' ', ' ', '<', '/', 's', 'v', 'g', '>'} var _radiobtnOnData2 = [193]uint8{' ', ' ', ' ', ' ', '<', 's', 'v', 'g', ' ', 'w', 'i', 'd', 't', 'h', '=', '\'', '1', '6', '\'', ' ', 'h', 'e', 'i', 'g', 'h', 't', '=', '\'', '1', '6', '\'', ' ', 'v', 'e', 'r', 's', 'i', 'o', 'n', '=', '\'', '1', '.', '1', '\'', ' ', 'x', 'm', 'l', 'n', 's', '=', '\'', 'h', 't', 't', 'p', ':', '/', '/', 'w', 'w', 'w', '.', 'w', '3', '.', 'o', 'r', 'g', '/', '2', '0', '0', '0', '/', 's', 'v', 'g', '\'', '>', 10, ' ', ' ', ' ', ' ', ' ', '<', 'c', 'i', 'r', 'c', 'l', 'e', ' ', 'c', 'x', '=', '\'', '8', '\'', ' ', 'c', 'y', '=', '\'', '8', '\'', ' ', 'r', '=', '\'', '8', '\'', ' ', 'f', 'i', 'l', 'l', '=', '\'', '#', '4', 'a', '6', '9', '8', '4', '\'', '/', '>', 10, ' ', ' ', ' ', ' ', ' ', '<', 'c', 'i', 'r', 'c', 'l', 'e', ' ', 'c', 'x', '=', '\'', '8', '\'', ' ', 'c', 'y', '=', '\'', '8', '\'', ' ', 'r', '=', '\'', '3', '\'', ' ', 'f', 'i', 'l', 'l', '=', '\'', '#', 'f', 'f', 'f', 'f', 'f', 'f', '\'', '/', '>', 10, ' ', ' ', ' ', ' ', '<', '/', 's', 'v', 'g', '>'} var _radiobtnTriData = [213]uint8{' ', ' ', ' ', ' ', '<', 's', 'v', 'g', ' ', 'w', 'i', 'd', 't', 'h', '=', '\'', '1', '6', '\'', ' ', 'h', 'e', 'i', 'g', 'h', 't', '=', '\'', '1', '6', '\'', ' ', 'v', 'e', 'r', 's', 'i', 'o', 'n', '=', '\'', '1', '.', '1', '\'', ' ', 'x', 'm', 'l', 'n', 's', '=', '\'', 'h', 't', 't', 'p', ':', '/', '/', 'w', 'w', 'w', '.', 'w', '3', '.', 'o', 'r', 'g', '/', '2', '0', '0', '0', '/', 's', 'v', 'g', '\'', '>', 10, ' ', ' ', ' ', ' ', ' ', '<', 'c', 'i', 'r', 'c', 'l', 'e', ' ', 'c', 'x', '=', '\'', '8', '\'', ' ', 'c', 'y', '=', '\'', '8', '\'', ' ', 'r', '=', '\'', '8', '\'', ' ', 'f', 'i', 'l', 'l', '=', '\'', '#', '4', 'a', '6', '9', '8', '4', '\'', '/', '>', 10, ' ', ' ', ' ', ' ', ' ', '<', 'p', 'a', 't', 'h', ' ', 'd', '=', '\'', 'm', '4', ' ', '8', 'h', '8', '\'', ' ', 'f', 'i', 'l', 'l', '=', '\'', 'n', 'o', 'n', 'e', '\'', ' ', 's', 't', 'r', 'o', 'k', 'e', '=', '\'', '#', 'f', 'f', 'f', 'f', 'f', 'f', '\'', ' ', 's', 't', 'r', 'o', 'k', 'e', '-', 'w', 'i', 'd', 't', 'h', '=', '\'', '2', '\'', '/', '>', 10, ' ', ' ', ' ', ' ', '<', '/', 's', 'v', 'g', '>'} var _radiobutton_spec2 = TIndicatorSpec1{ Fwidth: int32(16), Fheight: int32(16), FoffDataPtr: uintptr(unsafe.Pointer(&_radiobtnOffData2)), FonDataPtr: uintptr(unsafe.Pointer(&_radiobtnOnData2)), FtriDataPtr: uintptr(unsafe.Pointer(&_radiobtnTriData)), } type TIndicatorElement3 = struct { FbackgroundObj uintptr FforegroundObj uintptr FborderColorObj uintptr FmarginObj uintptr } // C documentation // // /* // * Note that the -indicatorbackground and -indicatorforeground options below // * have the same default value "#ffffff", but the -indicatorforeground option // * will only be used for the alternate and selected states, in which the // * -indicatorbackground option will have a different value (e.g., "#4a6984"). // */ var _IndicatorElementOptions3 = [5]TTtk_ElementOptionSpec{ 0: { FoptionName: __ccgo_ts + 49812, Ftype1: int32(TK_OPTION_COLOR), FdefaultValue: __ccgo_ts + 19883, }, 1: { FoptionName: __ccgo_ts + 49833, Ftype1: int32(TK_OPTION_COLOR), Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 8)), FdefaultValue: __ccgo_ts + 19883, }, 2: { FoptionName: __ccgo_ts + 49726, Ftype1: int32(TK_OPTION_COLOR), Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 16)), FdefaultValue: __ccgo_ts + 51223, }, 3: { FoptionName: __ccgo_ts + 49795, Ftype1: int32(TK_OPTION_STRING), Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 24)), FdefaultValue: __ccgo_ts + 50445, }, 4: {}, } func _IndicatorElementSize2(tls *libc.TLS, clientData uintptr, elementRecord uintptr, tkwin TTk_Window, widthPtr uintptr, heightPtr uintptr, dummy726 uintptr) { bp := tls.Alloc(16) defer tls.Free(16) var indicator, spec uintptr var scalingLevel float64 var _ /* margins at bp+0 */ TTtk_Padding _, _, _ = indicator, scalingLevel, spec spec = clientData indicator = elementRecord scalingLevel = XTkScalingLevel(tls, tkwin) XTtk_GetPaddingFromObj(tls, libc.UintptrFromInt32(0), tkwin, (*TIndicatorElement3)(unsafe.Pointer(indicator)).FmarginObj, bp) *(*int32)(unsafe.Pointer(widthPtr)) = int32(float64(float64((*TIndicatorSpec1)(unsafe.Pointer(spec)).Fwidth)*scalingLevel) + float64(int32((*(*TTtk_Padding)(unsafe.Pointer(bp))).Fleft)+int32((*(*TTtk_Padding)(unsafe.Pointer(bp))).Fright))) *(*int32)(unsafe.Pointer(heightPtr)) = int32(float64(float64((*TIndicatorSpec1)(unsafe.Pointer(spec)).Fheight)*scalingLevel) + float64(int32((*(*TTtk_Padding)(unsafe.Pointer(bp))).Ftop)+int32((*(*TTtk_Padding)(unsafe.Pointer(bp))).Fbottom))) } func _ColorToStr2(tls *libc.TLS, colorPtr uintptr, colorStr uintptr) { bp := tls.Alloc(32) defer tls.Free(32) /* in the format "RRGGBB" */ libc.X__builtin_snprintf(tls, colorStr, uint64(7), __ccgo_ts+49890, libc.VaList(bp+8, libc.Int32FromUint16((*TXColor)(unsafe.Pointer(colorPtr)).Fred)>>int32(8), libc.Int32FromUint16((*TXColor)(unsafe.Pointer(colorPtr)).Fgreen)>>int32(8), libc.Int32FromUint16((*TXColor)(unsafe.Pointer(colorPtr)).Fblue)>>int32(8))) } func _ImageChanged2(tls *libc.TLS, dummy746 uintptr, dummy747 int32, dummy748 int32, dummy749 int32, dummy750 int32, dummy751 int32, dummy752 int32) { } func _IndicatorElementDraw2(tls *libc.TLS, clientData uintptr, elementRecord uintptr, tkwin TTk_Window, d TDrawable, b TTtk_Box, state TTtk_State) { bp := tls.Alloc(160) defer tls.Free(160) var bgColorPtr, borderColorPtr, cmdFmt, fgColorPtr, indicator, interp, script, spec, svgDataCopy, svgDataPtr, v3, v4, v5, v6 uintptr var code, height, width, v1, v2 int32 var img TTk_Image var scalingLevel float64 var scriptSize, svgDataLen Tsize_t var selected, tristate uint32 var _ /* bgColorStr at bp+14 */ [7]uint8 var _ /* borderColorStr at bp+28 */ [7]uint8 var _ /* fgColorStr at bp+21 */ [7]uint8 var _ /* imgName at bp+35 */ [60]uint8 var _ /* padding at bp+0 */ TTtk_Padding _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = bgColorPtr, borderColorPtr, cmdFmt, code, fgColorPtr, height, img, indicator, interp, scalingLevel, script, scriptSize, selected, spec, svgDataCopy, svgDataLen, svgDataPtr, tristate, width, v1, v2, v3, v4, v5, v6 indicator = elementRecord spec = clientData scalingLevel = XTkScalingLevel(tls, tkwin) width = int32(float64((*TIndicatorSpec1)(unsafe.Pointer(spec)).Fwidth) * scalingLevel) height = int32(float64((*TIndicatorSpec1)(unsafe.Pointer(spec)).Fheight) * scalingLevel) selected = state & libc.Uint32FromInt32(libc.Int32FromInt32(1)< 0 && *(*int32)(unsafe.Pointer(bp + 4)) < b.Fheight && *(*int32)(unsafe.Pointer(bp + 4)) < b.Fwidth { if *(*TTtk_Orient)(unsafe.Pointer(bp + 12)) == int32(TTK_ORIENT_HORIZONTAL) { b.Fy += (b.Fheight - *(*int32)(unsafe.Pointer(bp + 4))) / int32(2) b.Fheight = *(*int32)(unsafe.Pointer(bp + 4)) } else { b.Fx += (b.Fwidth - *(*int32)(unsafe.Pointer(bp + 4))) / int32(2) b.Fwidth = *(*int32)(unsafe.Pointer(bp + 4)) } /* * Save the data of the trough's inner box for later */ if mainInfoPtr != libc.UintptrFromInt32(0) { (*TTkMainInfo)(unsafe.Pointer(mainInfoPtr)).FtroughInnerX = b.Fx + *(*int32)(unsafe.Pointer(bp)) (*TTkMainInfo)(unsafe.Pointer(mainInfoPtr)).FtroughInnerY = b.Fy + *(*int32)(unsafe.Pointer(bp)) (*TTkMainInfo)(unsafe.Pointer(mainInfoPtr)).FtroughInnerWidth = b.Fwidth - int32(2)**(*int32)(unsafe.Pointer(bp)) (*TTkMainInfo)(unsafe.Pointer(mainInfoPtr)).FtroughInnerHeight = b.Fheight - int32(2)**(*int32)(unsafe.Pointer(bp)) } } XTk_Fill3DRectangle(tls, tkwin, d, border, b.Fx, b.Fy, b.Fwidth, b.Fheight, *(*int32)(unsafe.Pointer(bp)), *(*int32)(unsafe.Pointer(bp + 8))) } var _TroughElementSpec1 = TTtk_ElementSpec{ Fversion: int32(TK_STYLE_VERSION_2), FelementSize: uint64(40), Foptions: uintptr(unsafe.Pointer(&_TroughElementOptions)), } func init() { p := unsafe.Pointer(&_TroughElementSpec1) *(*uintptr)(unsafe.Add(p, 24)) = __ccgo_fp(_TroughElementSize) *(*uintptr)(unsafe.Add(p, 32)) = __ccgo_fp(_TroughElementDraw1) } /* *---------------------------------------------------------------------- * +++ Thumb element. * * Used in scrollbars. */ type TThumbElement1 = struct { ForientObj uintptr FthicknessObj uintptr FreliefObj uintptr FborderObj uintptr FborderWidthObj uintptr } var _ThumbElementOptions1 = [6]TTtk_ElementOptionSpec{ 0: { FoptionName: __ccgo_ts + 25111, Ftype1: int32(TK_OPTION_STRING), FdefaultValue: __ccgo_ts + 16826, }, 1: { FoptionName: __ccgo_ts + 2987, Ftype1: int32(TK_OPTION_PIXELS), Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 8)), FdefaultValue: __ccgo_ts + 26163, }, 2: { FoptionName: __ccgo_ts + 20346, Ftype1: int32(TK_OPTION_RELIEF), Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 16)), FdefaultValue: __ccgo_ts + 12, }, 3: { FoptionName: __ccgo_ts + 19898, Ftype1: int32(TK_OPTION_BORDER), Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 24)), FdefaultValue: __ccgo_ts + 19921, }, 4: { FoptionName: __ccgo_ts + 2814, Ftype1: int32(TK_OPTION_PIXELS), Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 32)), FdefaultValue: __ccgo_ts + 21412, }, 5: {}, } func _ThumbElementSize2(tls *libc.TLS, dummy1302 uintptr, elementRecord uintptr, tkwin TTk_Window, widthPtr uintptr, heightPtr uintptr, dummy1305 uintptr) { bp := tls.Alloc(16) defer tls.Free(16) var thumb uintptr var _ /* orient at bp+0 */ TTtk_Orient var _ /* thickness at bp+4 */ int32 _ = thumb thumb = elementRecord XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), tkwin, (*TThumbElement1)(unsafe.Pointer(thumb)).FthicknessObj, bp+4) XTtk_GetOrientFromObj(tls, libc.UintptrFromInt32(0), (*TThumbElement1)(unsafe.Pointer(thumb)).ForientObj, bp) if *(*TTtk_Orient)(unsafe.Pointer(bp)) == int32(TTK_ORIENT_VERTICAL) { *(*int32)(unsafe.Pointer(widthPtr)) = *(*int32)(unsafe.Pointer(bp + 4)) *(*int32)(unsafe.Pointer(heightPtr)) = int32(MIN_THUMB_SIZE1) } else { *(*int32)(unsafe.Pointer(widthPtr)) = int32(MIN_THUMB_SIZE1) *(*int32)(unsafe.Pointer(heightPtr)) = *(*int32)(unsafe.Pointer(bp + 4)) } } func _ThumbElementDraw2(tls *libc.TLS, dummy1324 uintptr, elementRecord uintptr, tkwin TTk_Window, d TDrawable, b TTtk_Box, dummy1327 TTtk_State) { bp := tls.Alloc(16) defer tls.Free(16) var border TTk_3DBorder var thumb uintptr var _ /* borderWidth at bp+0 */ int32 var _ /* relief at bp+4 */ int32 _, _ = border, thumb thumb = elementRecord border = XTk_Get3DBorderFromObj(tls, tkwin, (*TThumbElement1)(unsafe.Pointer(thumb)).FborderObj) *(*int32)(unsafe.Pointer(bp)) = int32(2) *(*int32)(unsafe.Pointer(bp + 4)) = int32(TK_RELIEF_RAISED) XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), tkwin, (*TThumbElement1)(unsafe.Pointer(thumb)).FborderWidthObj, bp) XTk_GetReliefFromObj(tls, libc.UintptrFromInt32(0), (*TThumbElement1)(unsafe.Pointer(thumb)).FreliefObj, bp+4) XTk_Fill3DRectangle(tls, tkwin, d, border, b.Fx, b.Fy, b.Fwidth, b.Fheight, *(*int32)(unsafe.Pointer(bp)), *(*int32)(unsafe.Pointer(bp + 4))) } var _ThumbElementSpec2 = TTtk_ElementSpec{ Fversion: int32(TK_STYLE_VERSION_2), FelementSize: uint64(40), Foptions: uintptr(unsafe.Pointer(&_ThumbElementOptions1)), } func init() { p := unsafe.Pointer(&_ThumbElementSpec2) *(*uintptr)(unsafe.Add(p, 24)) = __ccgo_fp(_ThumbElementSize2) *(*uintptr)(unsafe.Add(p, 32)) = __ccgo_fp(_ThumbElementDraw2) } /* *---------------------------------------------------------------------- * +++ Slider element. * * This is the moving part of the scale widget. Drawn as a filled circle. */ var _sliderData = [212]uint8{' ', ' ', ' ', ' ', '<', 's', 'v', 'g', ' ', 'w', 'i', 'd', 't', 'h', '=', '\'', '1', '6', '\'', ' ', 'h', 'e', 'i', 'g', 'h', 't', '=', '\'', '1', '6', '\'', ' ', 'v', 'e', 'r', 's', 'i', 'o', 'n', '=', '\'', '1', '.', '1', '\'', ' ', 'x', 'm', 'l', 'n', 's', '=', '\'', 'h', 't', 't', 'p', ':', '/', '/', 'w', 'w', 'w', '.', 'w', '3', '.', 'o', 'r', 'g', '/', '2', '0', '0', '0', '/', 's', 'v', 'g', '\'', '>', 10, ' ', ' ', ' ', ' ', ' ', '<', 'c', 'i', 'r', 'c', 'l', 'e', ' ', 'c', 'x', '=', '\'', '8', '\'', ' ', 'c', 'y', '=', '\'', '8', '\'', ' ', 'r', '=', '\'', '7', '.', '5', '\'', ' ', 'f', 'i', 'l', 'l', '=', '\'', '#', 'f', 'f', 'f', 'f', 'f', 'f', '\'', ' ', 's', 't', 'r', 'o', 'k', 'e', '=', '\'', '#', 'c', '3', 'c', '3', 'c', '3', '\'', '/', '>', 10, ' ', ' ', ' ', ' ', ' ', '<', 'c', 'i', 'r', 'c', 'l', 'e', ' ', 'c', 'x', '=', '\'', '8', '\'', ' ', 'c', 'y', '=', '\'', '8', '\'', ' ', 'r', '=', '\'', '4', '\'', ' ', 'f', 'i', 'l', 'l', '=', '\'', '#', '4', 'a', '6', '9', '8', '4', '\'', '/', '>', 10, ' ', ' ', ' ', ' ', '<', '/', 's', 'v', 'g', '>'} type TSliderElement2 = struct { FinnerColorObj uintptr FouterColorObj uintptr FborderColorObj uintptr ForientObj uintptr } var _SliderElementOptions2 = [5]TTtk_ElementOptionSpec{ 0: { FoptionName: __ccgo_ts + 51545, Ftype1: int32(TK_OPTION_COLOR), FdefaultValue: __ccgo_ts + 51187, }, 1: { FoptionName: __ccgo_ts + 51557, Ftype1: int32(TK_OPTION_COLOR), Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 8)), FdefaultValue: __ccgo_ts + 19883, }, 2: { FoptionName: __ccgo_ts + 49726, Ftype1: int32(TK_OPTION_COLOR), Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 16)), FdefaultValue: __ccgo_ts + 21673, }, 3: { FoptionName: __ccgo_ts + 25111, Ftype1: int32(TK_OPTION_STRING), Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 24)), FdefaultValue: __ccgo_ts + 16826, }, 4: {}, } func _SliderElementSize3(tls *libc.TLS, dummy1382 uintptr, dummy1383 uintptr, tkwin TTk_Window, widthPtr uintptr, heightPtr uintptr, dummy1386 uintptr) { var scalingLevel float64 var v1 int32 _, _ = scalingLevel, v1 scalingLevel = XTkScalingLevel(tls, tkwin) v1 = int32(libc.Float64FromInt32(SLIDER_DIM) * scalingLevel) *(*int32)(unsafe.Pointer(heightPtr)) = v1 *(*int32)(unsafe.Pointer(widthPtr)) = v1 } func _SliderElementDraw2(tls *libc.TLS, dummy1393 uintptr, elementRecord uintptr, tkwin TTk_Window, d TDrawable, b TTtk_Box, dummy1396 TTtk_State) { bp := tls.Alloc(128) defer tls.Free(128) var borderColor, borderColorPtr, cmdFmt, disp, innerColor, innerColorPtr, interp, mainInfoPtr, outerColor, outerColorPtr, script, slider, svgDataCopy, svgDataPtr uintptr var code, dim int32 var gc TGC var img TTk_Image var scalingLevel float64 var scriptSize, svgDataLen Tsize_t var _ /* borderColorStr at bp+21 */ [7]uint8 var _ /* imgName at bp+28 */ [50]uint8 var _ /* innerColorStr at bp+7 */ [7]uint8 var _ /* orient at bp+0 */ TTtk_Orient var _ /* outerColorStr at bp+14 */ [7]uint8 _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = borderColor, borderColorPtr, cmdFmt, code, dim, disp, gc, img, innerColor, innerColorPtr, interp, mainInfoPtr, outerColor, outerColorPtr, scalingLevel, script, scriptSize, slider, svgDataCopy, svgDataLen, svgDataPtr scalingLevel = XTkScalingLevel(tls, tkwin) dim = int32(libc.Float64FromInt32(SLIDER_DIM) * scalingLevel) mainInfoPtr = (*TTkWindow)(unsafe.Pointer(tkwin)).FmainPtr slider = elementRecord disp = (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fdisplay innerColor = XTk_GetColorFromObj(tls, tkwin, (*TSliderElement2)(unsafe.Pointer(slider)).FinnerColorObj) outerColor = XTk_GetColorFromObj(tls, tkwin, (*TSliderElement2)(unsafe.Pointer(slider)).FouterColorObj) borderColor = XTk_GetColorFromObj(tls, tkwin, (*TSliderElement2)(unsafe.Pointer(slider)).FborderColorObj) gc = XTk_GCForColor(tls, innerColor, d) interp = XTk_Interp(tls, tkwin) svgDataPtr = uintptr(unsafe.Pointer(&_sliderData)) /* * Sanity check */ if b.Fx < 0 || b.Fy < 0 || (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fchanges.Fwidth < b.Fx+dim || (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fchanges.Fheight < b.Fy+dim { /* Oops! Not enough room to display the image. * Don't draw anything. */ return } /* * Fill the thin trough area preceding the * slider's center with the inner color */ if mainInfoPtr != libc.UintptrFromInt32(0) { XTtk_GetOrientFromObj(tls, libc.UintptrFromInt32(0), (*TSliderElement2)(unsafe.Pointer(slider)).ForientObj, bp) switch *(*TTtk_Orient)(unsafe.Pointer(bp)) { case int32(TTK_ORIENT_HORIZONTAL): libx11.XXFillRectangle(tls, disp, d, gc, (*TTkMainInfo)(unsafe.Pointer(mainInfoPtr)).FtroughInnerX, (*TTkMainInfo)(unsafe.Pointer(mainInfoPtr)).FtroughInnerY, libc.Uint32FromInt32(b.Fx+dim/int32(2)-int32(1)), libc.Uint32FromInt32((*TTkMainInfo)(unsafe.Pointer(mainInfoPtr)).FtroughInnerHeight)) case int32(TTK_ORIENT_VERTICAL): libx11.XXFillRectangle(tls, disp, d, gc, (*TTkMainInfo)(unsafe.Pointer(mainInfoPtr)).FtroughInnerX, (*TTkMainInfo)(unsafe.Pointer(mainInfoPtr)).FtroughInnerY, libc.Uint32FromInt32((*TTkMainInfo)(unsafe.Pointer(mainInfoPtr)).FtroughInnerWidth), libc.Uint32FromInt32(b.Fy+dim/int32(2)-int32(1))) break } } /* * Construct the color strings innerColorStr, * outerColorStr, and borderColorStr */ _ColorToStr2(tls, innerColor, bp+7) _ColorToStr2(tls, outerColor, bp+14) _ColorToStr2(tls, borderColor, bp+21) /* * Check whether there is an SVG image of this size for these color strings */ libc.X__builtin_snprintf(tls, bp+28, uint64(50), __ccgo_ts+51569, libc.VaList(bp+88, dim, bp+7, bp+14, bp+21)) img = XTk_GetImage(tls, interp, tkwin, bp+28, __ccgo_fp(_ImageChanged2), libc.UintptrFromInt32(0)) if img == libc.UintptrFromInt32(0) { /* * Copy the string pointed to by svgDataPtr to * a newly allocated memory area svgDataCopy */ svgDataLen = libc.Xstrlen(tls, svgDataPtr) svgDataCopy = libtcl9_0.XTcl_AttemptAlloc(tls, svgDataLen+uint64(1)) if svgDataCopy == libc.UintptrFromInt32(0) { return } libc.Xmemcpy(tls, svgDataCopy, svgDataPtr, svgDataLen) *(*uint8)(unsafe.Pointer(svgDataCopy + uintptr(svgDataLen))) = uint8('\000') /* * Update the colors within svgDataCopy */ innerColorPtr = libc.Xstrstr(tls, svgDataCopy, __ccgo_ts+51475) outerColorPtr = libc.Xstrstr(tls, svgDataCopy, __ccgo_ts+49969) borderColorPtr = libc.Xstrstr(tls, svgDataCopy, __ccgo_ts+51608) libc.Xmemcpy(tls, innerColorPtr, bp+7, uint64(6)) libc.Xmemcpy(tls, outerColorPtr, bp+14, uint64(6)) libc.Xmemcpy(tls, borderColorPtr, bp+21, uint64(6)) /* * Create an SVG photo image from svgDataCopy */ cmdFmt = __ccgo_ts + 49983 scriptSize = libc.Xstrlen(tls, cmdFmt) + libc.Xstrlen(tls, bp+28) + svgDataLen script = libtcl9_0.XTcl_AttemptAlloc(tls, scriptSize) if script == libc.UintptrFromInt32(0) { libtcl9_0.XTcl_Free(tls, svgDataCopy) return } libc.X__builtin_snprintf(tls, script, scriptSize, cmdFmt, libc.VaList(bp+88, bp+28, svgDataCopy)) libtcl9_0.XTcl_Free(tls, svgDataCopy) code = libtcl9_0.XTcl_EvalEx(tls, interp, script, int64(-int32(1)), int32(TCL_EVAL_GLOBAL)) libtcl9_0.XTcl_Free(tls, script) if code != TCL_OK { libtcl9_0.XTcl_BackgroundException(tls, interp, code) return } img = XTk_GetImage(tls, interp, tkwin, bp+28, __ccgo_fp(_ImageChanged2), libc.UintptrFromInt32(0)) } /* * Display the image */ XTk_RedrawImage(tls, img, 0, 0, dim, dim, d, b.Fx, b.Fy) XTk_FreeImage(tls, img) } var _SliderElementSpec3 = TTtk_ElementSpec{ Fversion: int32(TK_STYLE_VERSION_2), FelementSize: uint64(32), Foptions: uintptr(unsafe.Pointer(&_SliderElementOptions2)), } func init() { p := unsafe.Pointer(&_SliderElementSpec3) *(*uintptr)(unsafe.Add(p, 24)) = __ccgo_fp(_SliderElementSize3) *(*uintptr)(unsafe.Add(p, 32)) = __ccgo_fp(_SliderElementDraw2) } /*------------------------------------------------------------------------ * +++ Progress bar element: * Draws the moving part of the progress bar. * * -thickness specifies the size along the short axis of the bar. * -length specifies the default size along the long axis; * the bar will be this long in indeterminate mode. */ type TPbarElement = struct { ForientObj uintptr FthicknessObj uintptr FlengthObj uintptr FreliefObj uintptr FborderObj uintptr FborderWidthObj uintptr } var _PbarElementOptions = [7]TTtk_ElementOptionSpec{ 0: { FoptionName: __ccgo_ts + 25111, Ftype1: int32(TK_OPTION_STRING), FdefaultValue: __ccgo_ts + 16826, }, 1: { FoptionName: __ccgo_ts + 51615, Ftype1: int32(TK_OPTION_PIXELS), Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 8)), FdefaultValue: __ccgo_ts + 26163, }, 2: { FoptionName: __ccgo_ts + 51626, Ftype1: int32(TK_OPTION_PIXELS), Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 16)), FdefaultValue: __ccgo_ts + 26049, }, 3: { FoptionName: __ccgo_ts + 51635, Ftype1: int32(TK_OPTION_RELIEF), Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 24)), FdefaultValue: __ccgo_ts + 12, }, 4: { FoptionName: __ccgo_ts + 2814, Ftype1: int32(TK_OPTION_PIXELS), Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 40)), FdefaultValue: __ccgo_ts + 21412, }, 5: { FoptionName: __ccgo_ts + 19898, Ftype1: int32(TK_OPTION_BORDER), Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 32)), FdefaultValue: __ccgo_ts + 19921, }, 6: {}, } func _PbarElementSize1(tls *libc.TLS, dummy1573 uintptr, elementRecord uintptr, tkwin TTk_Window, widthPtr uintptr, heightPtr uintptr, dummy1576 uintptr) { bp := tls.Alloc(16) defer tls.Free(16) var pbar uintptr var _ /* borderWidth at bp+12 */ int32 var _ /* length at bp+8 */ int32 var _ /* orient at bp+0 */ TTtk_Orient var _ /* thickness at bp+4 */ int32 _ = pbar pbar = elementRecord *(*int32)(unsafe.Pointer(bp + 4)) = int32(15) *(*int32)(unsafe.Pointer(bp + 8)) = int32(30) *(*int32)(unsafe.Pointer(bp + 12)) = int32(2) XTtk_GetOrientFromObj(tls, libc.UintptrFromInt32(0), (*TPbarElement)(unsafe.Pointer(pbar)).ForientObj, bp) XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), tkwin, (*TPbarElement)(unsafe.Pointer(pbar)).FthicknessObj, bp+4) XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), tkwin, (*TPbarElement)(unsafe.Pointer(pbar)).FlengthObj, bp+8) XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), tkwin, (*TPbarElement)(unsafe.Pointer(pbar)).FborderWidthObj, bp+12) switch *(*TTtk_Orient)(unsafe.Pointer(bp)) { case int32(TTK_ORIENT_HORIZONTAL): *(*int32)(unsafe.Pointer(widthPtr)) = *(*int32)(unsafe.Pointer(bp + 8)) + int32(2)**(*int32)(unsafe.Pointer(bp + 12)) *(*int32)(unsafe.Pointer(heightPtr)) = *(*int32)(unsafe.Pointer(bp + 4)) + int32(2)**(*int32)(unsafe.Pointer(bp + 12)) case int32(TTK_ORIENT_VERTICAL): *(*int32)(unsafe.Pointer(widthPtr)) = *(*int32)(unsafe.Pointer(bp + 4)) + int32(2)**(*int32)(unsafe.Pointer(bp + 12)) *(*int32)(unsafe.Pointer(heightPtr)) = *(*int32)(unsafe.Pointer(bp + 8)) + int32(2)**(*int32)(unsafe.Pointer(bp + 12)) break } } func _PbarElementDraw1(tls *libc.TLS, dummy1600 uintptr, elementRecord uintptr, tkwin TTk_Window, d TDrawable, b TTtk_Box, dummy1603 TTtk_State) { bp := tls.Alloc(16) defer tls.Free(16) var border TTk_3DBorder var pbar uintptr var _ /* borderWidth at bp+4 */ int32 var _ /* relief at bp+0 */ int32 _, _ = border, pbar pbar = elementRecord border = XTk_Get3DBorderFromObj(tls, tkwin, (*TPbarElement)(unsafe.Pointer(pbar)).FborderObj) *(*int32)(unsafe.Pointer(bp)) = int32(TK_RELIEF_RAISED) *(*int32)(unsafe.Pointer(bp + 4)) = int32(2) XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), tkwin, (*TPbarElement)(unsafe.Pointer(pbar)).FborderWidthObj, bp+4) XTk_GetReliefFromObj(tls, libc.UintptrFromInt32(0), (*TPbarElement)(unsafe.Pointer(pbar)).FreliefObj, bp) XTk_Fill3DRectangle(tls, tkwin, d, border, b.Fx, b.Fy, b.Fwidth, b.Fheight, *(*int32)(unsafe.Pointer(bp + 4)), *(*int32)(unsafe.Pointer(bp))) } var _PbarElementSpec1 = TTtk_ElementSpec{ Fversion: int32(TK_STYLE_VERSION_2), FelementSize: uint64(48), Foptions: uintptr(unsafe.Pointer(&_PbarElementOptions)), } func init() { p := unsafe.Pointer(&_PbarElementSpec1) *(*uintptr)(unsafe.Add(p, 24)) = __ccgo_fp(_PbarElementSize1) *(*uintptr)(unsafe.Add(p, 32)) = __ccgo_fp(_PbarElementDraw1) } /*------------------------------------------------------------------------ * +++ Notebook tabs and client area. */ type TTabElement = struct { FborderWidthObj uintptr FbackgroundObj uintptr FhighlightObj uintptr FhighlightColorObj uintptr } var _TabElementOptions = [5]TTtk_ElementOptionSpec{ 0: { FoptionName: __ccgo_ts + 2814, Ftype1: int32(TK_OPTION_PIXELS), FdefaultValue: __ccgo_ts + 14538, }, 1: { FoptionName: __ccgo_ts + 19898, Ftype1: int32(TK_OPTION_BORDER), Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 8)), FdefaultValue: __ccgo_ts + 19921, }, 2: { FoptionName: __ccgo_ts + 51647, Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 16)), FdefaultValue: __ccgo_ts + 10533, }, 3: { FoptionName: __ccgo_ts + 20190, Ftype1: int32(TK_OPTION_COLOR), Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 24)), FdefaultValue: __ccgo_ts + 51187, }, 4: {}, } func _TabElementSize1(tls *libc.TLS, dummy1649 uintptr, elementRecord uintptr, tkwin TTk_Window, dummy1651 uintptr, dummy1652 uintptr, paddingPtr uintptr) { bp := tls.Alloc(16) defer tls.Free(16) var mainInfoPtr, tab uintptr var nbTabsStickBit TTtk_PositionSpec var _ /* borderWidth at bp+0 */ int32 _, _, _ = mainInfoPtr, nbTabsStickBit, tab tab = elementRecord *(*int32)(unsafe.Pointer(bp)) = int32(1) nbTabsStickBit = libc.Uint32FromInt32(libc.Int32FromInt32(TTK_STICK_S)) mainInfoPtr = (*TTkWindow)(unsafe.Pointer(tkwin)).FmainPtr XTk_GetPixelsFromObj(tls, uintptr(0), tkwin, (*TTabElement)(unsafe.Pointer(tab)).FborderWidthObj, bp) *(*TTtk_Padding)(unsafe.Pointer(paddingPtr)) = XTtk_UniformPadding(tls, int16(*(*int32)(unsafe.Pointer(bp)))) if mainInfoPtr != libc.UintptrFromInt32(0) { nbTabsStickBit = (*TTkMainInfo)(unsafe.Pointer(mainInfoPtr)).FttkNbTabsStickBit } switch nbTabsStickBit { default: fallthrough case libc.Uint32FromInt32(libc.Int32FromInt32(TTK_STICK_S)): (*TTtk_Padding)(unsafe.Pointer(paddingPtr)).Fbottom = 0 case libc.Uint32FromInt32(libc.Int32FromInt32(TTK_STICK_N)): (*TTtk_Padding)(unsafe.Pointer(paddingPtr)).Ftop = 0 case libc.Uint32FromInt32(libc.Int32FromInt32(TTK_STICK_E)): (*TTtk_Padding)(unsafe.Pointer(paddingPtr)).Fright = 0 case libc.Uint32FromInt32(libc.Int32FromInt32(TTK_STICK_W)): (*TTtk_Padding)(unsafe.Pointer(paddingPtr)).Fleft = 0 break } } func _TabElementDraw1(tls *libc.TLS, dummy1685 uintptr, elementRecord uintptr, tkwin TTk_Window, d TDrawable, b TTtk_Box, state TTtk_State) { bp := tls.Alloc(32) defer tls.Free(32) var border TTk_3DBorder var cut, v5 int32 var disp, hlColor, mainInfoPtr, tab, p1, p2, p3, p4 uintptr var nbTabsStickBit TTtk_PositionSpec var scalingLevel float64 var _ /* borderWidth at bp+28 */ int32 var _ /* highlight at bp+0 */ int32 var _ /* pts at bp+4 */ [6]TXPoint _, _, _, _, _, _, _, _, _, _, _, _, _ = border, cut, disp, hlColor, mainInfoPtr, nbTabsStickBit, scalingLevel, tab, v5, p1, p2, p3, p4 nbTabsStickBit = libc.Uint32FromInt32(libc.Int32FromInt32(TTK_STICK_S)) mainInfoPtr = (*TTkWindow)(unsafe.Pointer(tkwin)).FmainPtr tab = elementRecord border = XTk_Get3DBorderFromObj(tls, tkwin, (*TTabElement)(unsafe.Pointer(tab)).FbackgroundObj) *(*int32)(unsafe.Pointer(bp)) = 0 hlColor = libc.UintptrFromInt32(0) scalingLevel = XTkScalingLevel(tls, tkwin) cut = int32(libc.X__builtin_round(tls, float64(libc.Float64FromInt32(2)*scalingLevel))) disp = (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fdisplay *(*int32)(unsafe.Pointer(bp + 28)) = int32(1) if mainInfoPtr != libc.UintptrFromInt32(0) { nbTabsStickBit = (*TTkMainInfo)(unsafe.Pointer(mainInfoPtr)).FttkNbTabsStickBit } if state&libc.Uint32FromInt32(libc.Int32FromInt32(1)< maxBytes { /* @@@POSSIBLE BUG: Can transfer partial UTF-8 sequences. Is this OK? */ byteCount = maxBytes } libc.Xmemcpy(tls, buffer, selStart+uintptr(offset), libc.Uint64FromInt64(byteCount)) *(*uint8)(unsafe.Pointer(buffer + uintptr(byteCount))) = uint8('\000') return byteCount } // C documentation // // /* EntryLostSelection -- // * Tk_LostSelProc for Entry widgets; called when an entry // * loses ownership of the selection. // */ func _EntryLostSelection1(tls *libc.TLS, clientData uintptr) { var entryPtr uintptr var v1 TTcl_Size _, _ = entryPtr, v1 entryPtr = clientData (*TEntry1)(unsafe.Pointer(entryPtr)).Fcore.Fflags &= libc.Uint32FromInt32(^(libc.Int32FromInt32(WIDGET_USER_FLAG) << libc.Int32FromInt32(1))) v1 = int64(-libc.Int32FromInt32(1)) (*TEntry1)(unsafe.Pointer(entryPtr)).Fentry.FselectLast = v1 (*TEntry1)(unsafe.Pointer(entryPtr)).Fentry.FselectFirst = v1 XTtkRedisplayWidget(tls, entryPtr) } // C documentation // // /* EntryOwnSelection -- // * Assert ownership of the PRIMARY selection, // * if -exportselection set and selection is present and interp is unsafe. // */ func _EntryOwnSelection(tls *libc.TLS, entryPtr uintptr) { if (*TEntry1)(unsafe.Pointer(entryPtr)).Fentry.FexportSelection != 0 && !(libtcl9_0.XTcl_IsSafe(tls, (*TEntry1)(unsafe.Pointer(entryPtr)).Fcore.Finterp) != 0) && !((*TEntry1)(unsafe.Pointer(entryPtr)).Fcore.Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(WIDGET_USER_FLAG)< 0) // * or deletion (nChars < 0) at specified index. // */ func _AdjustIndex(tls *libc.TLS, i0 int32, index int32, nChars int32) (r int32) { if i0 >= index { i0 += nChars if i0 < index { /* index was inside deleted range */ i0 = index } } return i0 } // C documentation // // /* AdjustIndices -- // * Adjust all internal entry indexes to account for change. // * Note that insertPos, and selectFirst have "right gravity", // * while leftIndex (=xscroll.first) and selectLast have "left gravity". // */ func _AdjustIndices(tls *libc.TLS, entryPtr uintptr, index int32, nChars int32) { var e uintptr var g int32 var v1 TTcl_Size _, _, _ = e, g, v1 e = entryPtr + 88 g = libc.BoolInt32(nChars > 0) /* left gravity adjustment */ (*TEntryPart)(unsafe.Pointer(e)).FinsertPos = int64(_AdjustIndex(tls, int32((*TEntryPart)(unsafe.Pointer(e)).FinsertPos), index, nChars)) (*TEntryPart)(unsafe.Pointer(e)).FselectFirst = int64(_AdjustIndex(tls, int32((*TEntryPart)(unsafe.Pointer(e)).FselectFirst), index, nChars)) (*TEntryPart)(unsafe.Pointer(e)).FselectLast = int64(_AdjustIndex(tls, int32((*TEntryPart)(unsafe.Pointer(e)).FselectLast), index+g, nChars)) (*TEntryPart)(unsafe.Pointer(e)).Fxscroll.Ffirst = _AdjustIndex(tls, (*TEntryPart)(unsafe.Pointer(e)).Fxscroll.Ffirst, index+g, nChars) if (*TEntryPart)(unsafe.Pointer(e)).FselectLast <= (*TEntryPart)(unsafe.Pointer(e)).FselectFirst { v1 = int64(-libc.Int32FromInt32(1)) (*TEntryPart)(unsafe.Pointer(e)).FselectLast = v1 (*TEntryPart)(unsafe.Pointer(e)).FselectFirst = v1 } } // C documentation // // /* EntryStoreValue -- // * Replace the contents of a text entry with a given value, // * recompute dependent resources, and schedule a redisplay. // * // * See also: EntrySetValue(). // */ func _EntryStoreValue(tls *libc.TLS, entryPtr uintptr, value uintptr) { var numBytes Tsize_t var numChars TTcl_Size var v1 uintptr _, _, _ = numBytes, numChars, v1 numBytes = libc.Xstrlen(tls, value) numChars = libtcl9_0.XTcl_NumUtfChars(tls, value, libc.Int64FromUint64(numBytes)) if (*TEntry1)(unsafe.Pointer(entryPtr)).Fcore.Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(WIDGET_USER_FLAG)< (*TEntry1)(unsafe.Pointer(entryPtr)).Fentry.FnumChars { count = (*TEntry1)(unsafe.Pointer(entryPtr)).Fentry.FnumChars - index } if count <= 0 { return TCL_OK } byteIndex = libc.Uint64FromInt64(int64(libtcl9_0.XTcl_UtfAtIndex(tls, string1, index)) - int64(string1)) byteCount = libc.Uint64FromInt64(int64(libtcl9_0.XTcl_UtfAtIndex(tls, string1+uintptr(byteIndex), count)) - int64(string1+uintptr(byteIndex))) newByteCount = libc.Uint64FromInt64((*TEntry1)(unsafe.Pointer(entryPtr)).Fentry.FnumBytes+int64(1)) - byteCount newBytes = libtcl9_0.XTcl_Alloc(tls, newByteCount) libc.Xmemcpy(tls, newBytes, string1, byteIndex) libc.Xstrcpy(tls, newBytes+uintptr(byteIndex), string1+uintptr(byteIndex)+uintptr(byteCount)) code = _EntryValidateChange1(tls, entryPtr, newBytes, index, count, int32(VALIDATE_DELETE1)) if code == TCL_OK { _AdjustIndices(tls, entryPtr, int32(index), int32(-count)) code = _EntrySetValue1(tls, entryPtr, newBytes) } else { if code == int32(TCL_BREAK) { code = TCL_OK } } libtcl9_0.XTcl_Free(tls, newBytes) return code } /*------------------------------------------------------------------------ * +++ Event handler. */ // C documentation // // /* EntryEventProc -- // * Extra event handling for entry widgets: // * Triggers validation on FocusIn and FocusOut events. // */ func _EntryEventProc1(tls *libc.TLS, clientData uintptr, eventPtr uintptr) { var entryPtr uintptr _ = entryPtr entryPtr = clientData libtcl9_0.XTcl_Preserve(tls, clientData) switch (*TXEvent)(unsafe.Pointer(eventPtr)).Ftype1 { case int32(DestroyNotify): XTk_DeleteEventHandler(tls, (*TEntry1)(unsafe.Pointer(entryPtr)).Fcore.Ftkwin, libc.Uint64FromInt64(libc.Int64FromInt64(1)<= 0 && !(libtcl9_0.XTcl_IsSafe(tls, (*TEntry1)(unsafe.Pointer(entryPtr)).Fcore.Finterp) != 0) { _EntryOwnSelection(tls, entryPtr) } /* Handle -state compatibility option: */ if mask&int32(STATE_CHANGED) != 0 { XTtkCheckStateOption(tls, entryPtr, (*TEntry1)(unsafe.Pointer(entryPtr)).Fentry.FstateObj) } /* Force scrollbar update if needed: */ if mask&int32(SCROLLCMD_CHANGED) != 0 { XTtkScrollbarUpdateRequired(tls, (*TEntry1)(unsafe.Pointer(entryPtr)).Fentry.FxscrollHandle) } /* Recompute the displayString, in case showChar changed: */ if (*TEntry1)(unsafe.Pointer(entryPtr)).Fentry.FdisplayString != (*TEntry1)(unsafe.Pointer(entryPtr)).Fentry.Fstring1 { libtcl9_0.XTcl_Free(tls, (*TEntry1)(unsafe.Pointer(entryPtr)).Fentry.FdisplayString) } if (*TEntry1)(unsafe.Pointer(entryPtr)).Fentry.FshowCharObj != 0 { v1 = _EntryDisplayString(tls, libtcl9_0.XTcl_GetStringFromObj(tls, (*TEntry1)(unsafe.Pointer(entryPtr)).Fentry.FshowCharObj, libc.UintptrFromInt32(0)), int32((*TEntry1)(unsafe.Pointer(entryPtr)).Fentry.FnumChars)) } else { v1 = (*TEntry1)(unsafe.Pointer(entryPtr)).Fentry.Fstring1 } (*TEntry1)(unsafe.Pointer(entryPtr)).Fentry.FdisplayString = v1 /* Update textLayout: */ _EntryUpdateTextLayout(tls, entryPtr) return TCL_OK } // C documentation // // /* EntryPostConfigure -- // * Post-configuration hook for entry widgets. // */ func _EntryPostConfigure(tls *libc.TLS, dummy1078 uintptr, recordPtr uintptr, mask int32) (r int32) { var entryPtr uintptr var status int32 _, _ = entryPtr, status entryPtr = recordPtr status = TCL_OK if mask&int32(TEXTVAR_CHANGED) != 0 && (*TEntry1)(unsafe.Pointer(entryPtr)).Fentry.FtextVariableTrace != libc.UintptrFromInt32(0) { status = XTtk_FireTrace(tls, (*TEntry1)(unsafe.Pointer(entryPtr)).Fentry.FtextVariableTrace) } return status } /*------------------------------------------------------------------------ * +++ Layout and display. */ // C documentation // // /* EntryCharPosition -- // * Return the X coordinate of the specified character index. // * Precondition: textLayout and layoutX up-to-date. // */ func _EntryCharPosition(tls *libc.TLS, entryPtr uintptr, index TTcl_Size) (r int32) { bp := tls.Alloc(16) defer tls.Free(16) var _ /* xPos at bp+0 */ int32 XTk_CharBbox(tls, (*TEntry1)(unsafe.Pointer(entryPtr)).Fentry.FtextLayout, index, bp, libc.UintptrFromInt32(0), libc.UintptrFromInt32(0), libc.UintptrFromInt32(0)) return *(*int32)(unsafe.Pointer(bp)) + (*TEntry1)(unsafe.Pointer(entryPtr)).Fentry.FlayoutX } // C documentation // // /* EntryDoLayout -- // * Layout hook for entry widgets. // * // * Determine position of textLayout based on xscroll.first, justify, // * and display area. // * // * Recalculates layoutX, layoutY, and rightIndex, // * and updates xscroll accordingly. // * May adjust xscroll.first to ensure the maximum #characters are onscreen. // */ func _EntryDoLayout(tls *libc.TLS, recordPtr uintptr) { bp := tls.Alloc(16) defer tls.Free(16) var corePtr, entryPtr uintptr var extraSpace, leftIndex, maxLeftIndex, overflow, rightIndex int32 var textLayout TTk_TextLayout var textarea TTtk_Box var _ /* leftX at bp+0 */ int32 _, _, _, _, _, _, _, _, _ = corePtr, entryPtr, extraSpace, leftIndex, maxLeftIndex, overflow, rightIndex, textLayout, textarea entryPtr = recordPtr corePtr = entryPtr textLayout = (*TEntry1)(unsafe.Pointer(entryPtr)).Fentry.FtextLayout leftIndex = (*TEntry1)(unsafe.Pointer(entryPtr)).Fentry.Fxscroll.Ffirst XTtk_PlaceLayout(tls, (*TWidgetCore)(unsafe.Pointer(corePtr)).Flayout, (*TWidgetCore)(unsafe.Pointer(corePtr)).Fstate, XTtk_MakeBox(tls, 0, 0, (*TTk_FakeWin)(unsafe.Pointer((*TWidgetCore)(unsafe.Pointer(corePtr)).Ftkwin)).Fchanges.Fwidth, (*TTk_FakeWin)(unsafe.Pointer((*TWidgetCore)(unsafe.Pointer(corePtr)).Ftkwin)).Fchanges.Fheight)) textarea = XTtk_ClientRegion(tls, (*TWidgetCore)(unsafe.Pointer(corePtr)).Flayout, __ccgo_ts+51847) /* Center the text vertically within the available parcel: */ (*TEntry1)(unsafe.Pointer(entryPtr)).Fentry.FlayoutY = textarea.Fy + (textarea.Fheight-(*TEntry1)(unsafe.Pointer(entryPtr)).Fentry.FlayoutHeight)/int32(2) /* Recompute where the leftmost character on the display will * be drawn (layoutX) and adjust leftIndex if necessary. */ if (*TEntry1)(unsafe.Pointer(entryPtr)).Fentry.FlayoutWidth <= textarea.Fwidth { /* Everything fits. Set leftIndex to zero (no need to scroll), * and compute layoutX based on -justify. */ extraSpace = textarea.Fwidth - (*TEntry1)(unsafe.Pointer(entryPtr)).Fentry.FlayoutWidth leftIndex = 0 rightIndex = int32((*TEntry1)(unsafe.Pointer(entryPtr)).Fentry.FnumChars) (*TEntry1)(unsafe.Pointer(entryPtr)).Fentry.FlayoutX = textarea.Fx if (*TEntry1)(unsafe.Pointer(entryPtr)).Fentry.Fjustify == int32(TK_JUSTIFY_RIGHT) { (*TEntry1)(unsafe.Pointer(entryPtr)).Fentry.FlayoutX += extraSpace } else { if (*TEntry1)(unsafe.Pointer(entryPtr)).Fentry.Fjustify == int32(TK_JUSTIFY_CENTER) { (*TEntry1)(unsafe.Pointer(entryPtr)).Fentry.FlayoutX += extraSpace / int32(2) } } } else { /* The whole string doesn't fit in the window. * Limit leftIndex to leave at most one character's worth * of empty space on the right. */ overflow = (*TEntry1)(unsafe.Pointer(entryPtr)).Fentry.FlayoutWidth - textarea.Fwidth maxLeftIndex = int32(1) + XTk_PointToChar(tls, textLayout, overflow, 0) if leftIndex > maxLeftIndex { leftIndex = maxLeftIndex } /* Compute layoutX and rightIndex. * rightIndex is set to one past the last fully-visible character. */ XTk_CharBbox(tls, textLayout, int64(leftIndex), bp, libc.UintptrFromInt32(0), libc.UintptrFromInt32(0), libc.UintptrFromInt32(0)) rightIndex = XTk_PointToChar(tls, textLayout, *(*int32)(unsafe.Pointer(bp))+textarea.Fwidth, 0) (*TEntry1)(unsafe.Pointer(entryPtr)).Fentry.FlayoutX = textarea.Fx - *(*int32)(unsafe.Pointer(bp)) } XTtkScrolled(tls, (*TEntry1)(unsafe.Pointer(entryPtr)).Fentry.FxscrollHandle, leftIndex, rightIndex, int32((*TEntry1)(unsafe.Pointer(entryPtr)).Fentry.FnumChars)) } // C documentation // // /* EntryGetGC -- Helper routine. // * Get a GC using the specified foreground color and the entry's font. // * Result must be freed with Tk_FreeGC(). // */ func _EntryGetGC(tls *libc.TLS, entryPtr uintptr, colorObj uintptr, clip TRegion) (r TGC) { bp := tls.Alloc(128) defer tls.Free(128) var colorPtr, v1 uintptr var font TTk_Font var gc TGC var mask uint64 var tkwin TTk_Window var v2 bool var _ /* gcValues at bp+0 */ TXGCValues _, _, _, _, _, _, _ = colorPtr, font, gc, mask, tkwin, v1, v2 tkwin = (*TEntry1)(unsafe.Pointer(entryPtr)).Fcore.Ftkwin font = XTk_GetFontFromObj(tls, tkwin, (*TEntry1)(unsafe.Pointer(entryPtr)).Fentry.FfontObj) mask = 0 (*(*TXGCValues)(unsafe.Pointer(bp))).Fline_width = int32(1) mask |= libc.Uint64FromInt64(libc.Int64FromInt64(1) << libc.Int32FromInt32(4)) (*(*TXGCValues)(unsafe.Pointer(bp))).Ffont = XTk_FontId(tls, font) mask |= libc.Uint64FromInt64(libc.Int64FromInt64(1) << libc.Int32FromInt32(14)) if v2 = colorObj != uintptr(0); v2 { v1 = XTk_GetColorFromObj(tls, tkwin, colorObj) colorPtr = v1 } if v2 && v1 != uintptr(0) { (*(*TXGCValues)(unsafe.Pointer(bp))).Fforeground = (*TXColor)(unsafe.Pointer(colorPtr)).Fpixel mask |= libc.Uint64FromInt64(libc.Int64FromInt64(1) << libc.Int32FromInt32(2)) } gc = XTk_GetGC(tls, (*TEntry1)(unsafe.Pointer(entryPtr)).Fcore.Ftkwin, mask, bp) if clip != libc.UintptrFromInt32(0) { libx11.XXSetRegion(tls, (*TTk_FakeWin)(unsafe.Pointer((*TEntry1)(unsafe.Pointer(entryPtr)).Fcore.Ftkwin)).Fdisplay, gc, clip) } return gc } // C documentation // // /* EntryDisplay -- // * Redraws the contents of an entry window. // */ func _EntryDisplay(tls *libc.TLS, clientData uintptr, d TDrawable) { bp := tls.Alloc(96) defer tls.Free(96) var clipRegion TRegion var cursorHeight, cursorX, cursorY, selEndX, selStartX, selWidth, showCursor, showSelection, textareaEnd int32 var entryPtr, foregroundObj uintptr var field, textarea TTtk_Box var gc TGC var leftIndex, selFirst, selLast TTcl_Size var selBorder TTk_3DBorder var tkwin TTk_Window var _ /* borderWidth at bp+80 */ int32 var _ /* cursorWidth at bp+84 */ int32 var _ /* es at bp+8 */ TEntryStyleData var _ /* rect at bp+72 */ TXRectangle var _ /* rightIndex at bp+0 */ TTcl_Size _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = clipRegion, cursorHeight, cursorX, cursorY, entryPtr, field, foregroundObj, gc, leftIndex, selBorder, selEndX, selFirst, selLast, selStartX, selWidth, showCursor, showSelection, textarea, textareaEnd, tkwin entryPtr = clientData tkwin = (*TEntry1)(unsafe.Pointer(entryPtr)).Fcore.Ftkwin leftIndex = int64((*TEntry1)(unsafe.Pointer(entryPtr)).Fentry.Fxscroll.Ffirst) *(*TTcl_Size)(unsafe.Pointer(bp)) = int64((*TEntry1)(unsafe.Pointer(entryPtr)).Fentry.Fxscroll.Flast + int32(1)) selFirst = (*TEntry1)(unsafe.Pointer(entryPtr)).Fentry.FselectFirst selLast = (*TEntry1)(unsafe.Pointer(entryPtr)).Fentry.FselectLast _EntryInitStyleData(tls, entryPtr, bp+8) textarea = XTtk_ClientRegion(tls, (*TEntry1)(unsafe.Pointer(entryPtr)).Fcore.Flayout, __ccgo_ts+51847) showCursor = libc.BoolInt32((*TEntry1)(unsafe.Pointer(entryPtr)).Fcore.Fflags&uint32(CURSOR_ON2) != 0 && _EntryEditable(tls, entryPtr) != 0 && (*TEntry1)(unsafe.Pointer(entryPtr)).Fentry.FinsertPos >= leftIndex && (*TEntry1)(unsafe.Pointer(entryPtr)).Fentry.FinsertPos <= *(*TTcl_Size)(unsafe.Pointer(bp))) showSelection = libc.BoolInt32(!((*TEntry1)(unsafe.Pointer(entryPtr)).Fcore.Fstate&libc.Uint32FromInt32(libc.Int32FromInt32(1)<= 0 && selLast > leftIndex && selFirst <= *(*TTcl_Size)(unsafe.Pointer(bp))) /* Adjust selection range to keep in display bounds. */ if showSelection != 0 { if selFirst < leftIndex { selFirst = leftIndex } if selLast > *(*TTcl_Size)(unsafe.Pointer(bp)) { selLast = *(*TTcl_Size)(unsafe.Pointer(bp)) } } /* Draw widget background & border */ XTtk_DrawLayout(tls, (*TEntry1)(unsafe.Pointer(entryPtr)).Fcore.Flayout, (*TEntry1)(unsafe.Pointer(entryPtr)).Fcore.Fstate, d) /* Draw selection background */ if showSelection != 0 && (*(*TEntryStyleData)(unsafe.Pointer(bp + 8))).FselBorderObj != 0 { selBorder = XTk_Get3DBorderFromObj(tls, tkwin, (*(*TEntryStyleData)(unsafe.Pointer(bp + 8))).FselBorderObj) selStartX = _EntryCharPosition(tls, entryPtr, selFirst) selEndX = _EntryCharPosition(tls, entryPtr, selLast) *(*int32)(unsafe.Pointer(bp + 80)) = 0 XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), tkwin, (*(*TEntryStyleData)(unsafe.Pointer(bp + 8))).FselBorderWidthObj, bp+80) if selBorder != 0 { textareaEnd = textarea.Fx + textarea.Fwidth if selEndX > textareaEnd { selEndX = textareaEnd } selWidth = selEndX - selStartX + int32(2)**(*int32)(unsafe.Pointer(bp + 80)) if selWidth > 0 { XTk_Fill3DRectangle(tls, tkwin, d, selBorder, selStartX-*(*int32)(unsafe.Pointer(bp + 80)), (*TEntry1)(unsafe.Pointer(entryPtr)).Fentry.FlayoutY-*(*int32)(unsafe.Pointer(bp + 80)), selWidth, (*TEntry1)(unsafe.Pointer(entryPtr)).Fentry.FlayoutHeight+int32(2)**(*int32)(unsafe.Pointer(bp + 80)), *(*int32)(unsafe.Pointer(bp + 80)), int32(TK_RELIEF_RAISED)) } } } /* Initialize the clip region. Note that Xft does _not_ derive its * clipping area from the GC, so we have to supply that by other means. */ (*(*TXRectangle)(unsafe.Pointer(bp + 72))).Fx = int16(textarea.Fx) (*(*TXRectangle)(unsafe.Pointer(bp + 72))).Fy = int16(textarea.Fy) (*(*TXRectangle)(unsafe.Pointer(bp + 72))).Fwidth = libc.Uint16FromInt32(textarea.Fwidth) (*(*TXRectangle)(unsafe.Pointer(bp + 72))).Fheight = libc.Uint16FromInt32(textarea.Fheight) clipRegion = libx11.XXCreateRegion(tls) libx11.XXUnionRectWithRegion(tls, bp+72, clipRegion, clipRegion) /* Draw cursor: */ if showCursor != 0 { field = XTtk_ClientRegion(tls, (*TEntry1)(unsafe.Pointer(entryPtr)).Fcore.Flayout, __ccgo_ts+50253) cursorX = _EntryCharPosition(tls, entryPtr, (*TEntry1)(unsafe.Pointer(entryPtr)).Fentry.FinsertPos) cursorY = (*TEntry1)(unsafe.Pointer(entryPtr)).Fentry.FlayoutY cursorHeight = (*TEntry1)(unsafe.Pointer(entryPtr)).Fentry.FlayoutHeight *(*int32)(unsafe.Pointer(bp + 84)) = int32(1) XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), tkwin, (*(*TEntryStyleData)(unsafe.Pointer(bp + 8))).FinsertWidthObj, bp+84) if *(*int32)(unsafe.Pointer(bp + 84)) <= 0 { *(*int32)(unsafe.Pointer(bp + 84)) = int32(1) } /* @@@ should: maybe: SetCaretPos even when blinked off */ XTk_SetCaretPos(tls, tkwin, cursorX, cursorY, cursorHeight) cursorX -= *(*int32)(unsafe.Pointer(bp + 84)) / int32(2) if cursorX < field.Fx { cursorX = field.Fx } else { if cursorX+*(*int32)(unsafe.Pointer(bp + 84)) > field.Fx+field.Fwidth { cursorX = field.Fx + field.Fwidth - *(*int32)(unsafe.Pointer(bp + 84)) } } gc = _EntryGetGC(tls, entryPtr, (*(*TEntryStyleData)(unsafe.Pointer(bp + 8))).FinsertColorObj, libc.UintptrFromInt32(0)) libx11.XXFillRectangle(tls, (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fdisplay, d, gc, cursorX, cursorY, libc.Uint32FromInt32(*(*int32)(unsafe.Pointer(bp + 84))), libc.Uint32FromInt32(cursorHeight)) XTk_FreeGC(tls, (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fdisplay, gc) } /* Draw the text: */ if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer((*TEntry1)(unsafe.Pointer(entryPtr)).Fentry.FdisplayString))) == int32('\000') && (*TEntry1)(unsafe.Pointer(entryPtr)).Fentry.FplaceholderObj != libc.UintptrFromInt32(0) { /* No text displayed, but -placeholder is given */ if libtcl9_0.XTcl_GetCharLength(tls, (*(*TEntryStyleData)(unsafe.Pointer(bp + 8))).FplaceholderForegroundObj) > 0 { foregroundObj = (*(*TEntryStyleData)(unsafe.Pointer(bp + 8))).FplaceholderForegroundObj } else { foregroundObj = (*(*TEntryStyleData)(unsafe.Pointer(bp + 8))).FforegroundObj } /* Use placeholder text width */ leftIndex = 0 libtcl9_0.XTcl_GetStringFromObj(tls, (*TEntry1)(unsafe.Pointer(entryPtr)).Fentry.FplaceholderObj, bp) } else { foregroundObj = (*(*TEntryStyleData)(unsafe.Pointer(bp + 8))).FforegroundObj } gc = _EntryGetGC(tls, entryPtr, foregroundObj, clipRegion) if showSelection != 0 { /* Draw the selected and unselected portions separately. */ if leftIndex < selFirst { XTk_DrawTextLayout(tls, (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fdisplay, d, gc, (*TEntry1)(unsafe.Pointer(entryPtr)).Fentry.FtextLayout, (*TEntry1)(unsafe.Pointer(entryPtr)).Fentry.FlayoutX, (*TEntry1)(unsafe.Pointer(entryPtr)).Fentry.FlayoutY, leftIndex, selFirst) } if selLast < *(*TTcl_Size)(unsafe.Pointer(bp)) { XTk_DrawTextLayout(tls, (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fdisplay, d, gc, (*TEntry1)(unsafe.Pointer(entryPtr)).Fentry.FtextLayout, (*TEntry1)(unsafe.Pointer(entryPtr)).Fentry.FlayoutX, (*TEntry1)(unsafe.Pointer(entryPtr)).Fentry.FlayoutY, selLast, *(*TTcl_Size)(unsafe.Pointer(bp))) } libx11.XXSetClipMask(tls, (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fdisplay, gc, uint64(0)) XTk_FreeGC(tls, (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fdisplay, gc) /* Draw the selected portion in the -selectforeground color: */ gc = _EntryGetGC(tls, entryPtr, (*(*TEntryStyleData)(unsafe.Pointer(bp + 8))).FselForegroundObj, clipRegion) XTk_DrawTextLayout(tls, (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fdisplay, d, gc, (*TEntry1)(unsafe.Pointer(entryPtr)).Fentry.FtextLayout, (*TEntry1)(unsafe.Pointer(entryPtr)).Fentry.FlayoutX, (*TEntry1)(unsafe.Pointer(entryPtr)).Fentry.FlayoutY, selFirst, selLast) libx11.XXSetClipMask(tls, (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fdisplay, gc, uint64(0)) XTk_FreeGC(tls, (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fdisplay, gc) } else { /* Draw the entire visible text */ XTk_DrawTextLayout(tls, (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fdisplay, d, gc, (*TEntry1)(unsafe.Pointer(entryPtr)).Fentry.FtextLayout, (*TEntry1)(unsafe.Pointer(entryPtr)).Fentry.FlayoutX, (*TEntry1)(unsafe.Pointer(entryPtr)).Fentry.FlayoutY, leftIndex, *(*TTcl_Size)(unsafe.Pointer(bp))) libx11.XXSetClipMask(tls, (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fdisplay, gc, uint64(0)) XTk_FreeGC(tls, (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fdisplay, gc) } /* Drop the region. Note that we have to manually remove the reference to * it from the Xft guts (if they're being used). */ libx11.XXDestroyRegion(tls, clipRegion) } /*------------------------------------------------------------------------ * +++ Widget commands. */ // C documentation // // /* EntryIndex -- // * Parse an index into an entry and return either its value // * or an error. // * // * Results: // * A standard Tcl result. If all went well, then *indexPtr is // * filled in with the character index (into entryPtr) corresponding to // * string. The index value is guaranteed to lie between 0 and // * the number of characters in the string, inclusive. If an // * error occurs then an error message is left in the interp's result. // */ func _EntryIndex(tls *libc.TLS, interp uintptr, entryPtr uintptr, indexObj uintptr, indexPtr uintptr) (r int32) { bp := tls.Alloc(64) defer tls.Free(64) /* Return value */ var maxWidth, roundUp int32 var string1 uintptr var _ /* idx at bp+8 */ TTcl_Size var _ /* length at bp+0 */ TTcl_Size var _ /* x at bp+16 */ int32 _, _, _ = maxWidth, roundUp, string1 if TCL_OK == XTkGetIntForIndex(tls, indexObj, (*TEntry1)(unsafe.Pointer(entryPtr)).Fentry.FnumChars-int64(1), int32(1), bp+8) { if *(*TTcl_Size)(unsafe.Pointer(bp + 8)) < 0 { *(*TTcl_Size)(unsafe.Pointer(bp + 8)) = 0 } else { if *(*TTcl_Size)(unsafe.Pointer(bp + 8)) > (*TEntry1)(unsafe.Pointer(entryPtr)).Fentry.FnumChars { *(*TTcl_Size)(unsafe.Pointer(bp + 8)) = (*TEntry1)(unsafe.Pointer(entryPtr)).Fentry.FnumChars } } *(*TTcl_Size)(unsafe.Pointer(indexPtr)) = *(*TTcl_Size)(unsafe.Pointer(bp + 8)) return TCL_OK } string1 = libtcl9_0.XTcl_GetStringFromObj(tls, indexObj, bp) if libc.Xstrncmp(tls, string1, __ccgo_ts+22158, libc.Uint64FromInt64(*(*TTcl_Size)(unsafe.Pointer(bp)))) == 0 { *(*TTcl_Size)(unsafe.Pointer(indexPtr)) = (*TEntry1)(unsafe.Pointer(entryPtr)).Fentry.FinsertPos } else { if libc.Xstrncmp(tls, string1, __ccgo_ts+10966, libc.Uint64FromInt64(*(*TTcl_Size)(unsafe.Pointer(bp)))) == 0 { /* for debugging */ *(*TTcl_Size)(unsafe.Pointer(indexPtr)) = int64((*TEntry1)(unsafe.Pointer(entryPtr)).Fentry.Fxscroll.Ffirst) } else { if libc.Xstrncmp(tls, string1, __ccgo_ts+10971, libc.Uint64FromInt64(*(*TTcl_Size)(unsafe.Pointer(bp)))) == 0 { /* for debugging */ *(*TTcl_Size)(unsafe.Pointer(indexPtr)) = int64((*TEntry1)(unsafe.Pointer(entryPtr)).Fentry.Fxscroll.Flast) } else { if libc.Xstrncmp(tls, string1, __ccgo_ts+51856, uint64(4)) == 0 { if (*TEntry1)(unsafe.Pointer(entryPtr)).Fentry.FselectFirst < 0 { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+22506, libc.VaList(bp+32, (*TTk_FakeWin)(unsafe.Pointer((*TEntry1)(unsafe.Pointer(entryPtr)).Fcore.Ftkwin)).FpathName))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+32, __ccgo_ts+51861, __ccgo_ts+22535, __ccgo_ts+22541, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) } if libc.Xstrncmp(tls, string1, __ccgo_ts+22554, libc.Uint64FromInt64(*(*TTcl_Size)(unsafe.Pointer(bp)))) == 0 { *(*TTcl_Size)(unsafe.Pointer(indexPtr)) = (*TEntry1)(unsafe.Pointer(entryPtr)).Fentry.FselectFirst } else { if libc.Xstrncmp(tls, string1, __ccgo_ts+22564, libc.Uint64FromInt64(*(*TTcl_Size)(unsafe.Pointer(bp)))) == 0 { *(*TTcl_Size)(unsafe.Pointer(indexPtr)) = (*TEntry1)(unsafe.Pointer(entryPtr)).Fentry.FselectLast } else { goto badIndex } } } else { if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(string1))) == int32('@') { roundUp = 0 maxWidth = (*TTk_FakeWin)(unsafe.Pointer((*TEntry1)(unsafe.Pointer(entryPtr)).Fcore.Ftkwin)).Fchanges.Fwidth if libtcl9_0.XTcl_GetInt(tls, interp, string1+uintptr(1), bp+16) != TCL_OK { goto badIndex } if *(*int32)(unsafe.Pointer(bp + 16)) > maxWidth { *(*int32)(unsafe.Pointer(bp + 16)) = maxWidth roundUp = int32(1) } *(*TTcl_Size)(unsafe.Pointer(indexPtr)) = int64(XTk_PointToChar(tls, (*TEntry1)(unsafe.Pointer(entryPtr)).Fentry.FtextLayout, *(*int32)(unsafe.Pointer(bp + 16))-(*TEntry1)(unsafe.Pointer(entryPtr)).Fentry.FlayoutX, 0)) XTtkUpdateScrollInfo(tls, (*TEntry1)(unsafe.Pointer(entryPtr)).Fentry.FxscrollHandle) if *(*TTcl_Size)(unsafe.Pointer(indexPtr)) < int64((*TEntry1)(unsafe.Pointer(entryPtr)).Fentry.Fxscroll.Ffirst) { *(*TTcl_Size)(unsafe.Pointer(indexPtr)) = int64((*TEntry1)(unsafe.Pointer(entryPtr)).Fentry.Fxscroll.Ffirst) } /* * Special trick: if the x-position was off-screen to the right, * round the index up to refer to the character just after the * last visible one on the screen. This is needed to enable the * last character to be selected, for example. */ if roundUp != 0 && *(*TTcl_Size)(unsafe.Pointer(indexPtr)) < (*TEntry1)(unsafe.Pointer(entryPtr)).Fentry.FnumChars { *(*TTcl_Size)(unsafe.Pointer(indexPtr)) += int64(1) } } else { goto badIndex } } } } } return TCL_OK goto badIndex badIndex: ; libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+51865, libc.VaList(bp+32, string1))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+32, __ccgo_ts+51861, __ccgo_ts+22535, __ccgo_ts+5789, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) } // C documentation // // /* $entry bbox $index -- // * Return the bounding box of the character at the specified index. // */ func _EntryBBoxCommand(tls *libc.TLS, recordPtr uintptr, interp uintptr, objc TTcl_Size, objv uintptr) (r int32) { bp := tls.Alloc(32) defer tls.Free(32) var entryPtr uintptr var _ /* b at bp+0 */ TTtk_Box var _ /* index at bp+16 */ TTcl_Size _ = entryPtr entryPtr = recordPtr if objc != int64(3) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(2), objv, __ccgo_ts+22152) return int32(TCL_ERROR) } if _EntryIndex(tls, interp, entryPtr, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+16) != TCL_OK { return int32(TCL_ERROR) } if *(*TTcl_Size)(unsafe.Pointer(bp + 16)) == (*TEntry1)(unsafe.Pointer(entryPtr)).Fentry.FnumChars && *(*TTcl_Size)(unsafe.Pointer(bp + 16)) > 0 { *(*TTcl_Size)(unsafe.Pointer(bp + 16))-- } XTk_CharBbox(tls, (*TEntry1)(unsafe.Pointer(entryPtr)).Fentry.FtextLayout, *(*TTcl_Size)(unsafe.Pointer(bp + 16)), bp, bp+4, bp+8, bp+12) (*(*TTtk_Box)(unsafe.Pointer(bp))).Fx += (*TEntry1)(unsafe.Pointer(entryPtr)).Fentry.FlayoutX (*(*TTtk_Box)(unsafe.Pointer(bp))).Fy += (*TEntry1)(unsafe.Pointer(entryPtr)).Fentry.FlayoutY libtcl9_0.XTcl_SetObjResult(tls, interp, XTtk_NewBoxObj(tls, *(*TTtk_Box)(unsafe.Pointer(bp)))) return TCL_OK } // C documentation // // /* $entry delete $from ?$to? -- // * Delete the characters in the range [$from,$to). // * $to defaults to $from+1 if not specified. // */ func _EntryDeleteCommand(tls *libc.TLS, recordPtr uintptr, interp uintptr, objc TTcl_Size, objv uintptr) (r int32) { bp := tls.Alloc(16) defer tls.Free(16) var entryPtr uintptr var _ /* first at bp+0 */ TTcl_Size var _ /* last at bp+8 */ TTcl_Size _ = entryPtr entryPtr = recordPtr if objc < int64(3) || objc > int64(4) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(2), objv, __ccgo_ts+22240) return int32(TCL_ERROR) } if _EntryIndex(tls, interp, entryPtr, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp) != TCL_OK { return int32(TCL_ERROR) } if objc == int64(3) { *(*TTcl_Size)(unsafe.Pointer(bp + 8)) = *(*TTcl_Size)(unsafe.Pointer(bp)) + int64(1) } else { if _EntryIndex(tls, interp, entryPtr, *(*uintptr)(unsafe.Pointer(objv + 3*8)), bp+8) != TCL_OK { return int32(TCL_ERROR) } } if *(*TTcl_Size)(unsafe.Pointer(bp + 8)) >= *(*TTcl_Size)(unsafe.Pointer(bp)) && _EntryEditable(tls, entryPtr) != 0 { return _DeleteChars1(tls, entryPtr, *(*TTcl_Size)(unsafe.Pointer(bp)), *(*TTcl_Size)(unsafe.Pointer(bp + 8))-*(*TTcl_Size)(unsafe.Pointer(bp))) } return TCL_OK } // C documentation // // /* $entry get -- // * Return the current value of the entry widget. // */ func _EntryGetCommand(tls *libc.TLS, recordPtr uintptr, interp uintptr, objc TTcl_Size, objv uintptr) (r int32) { var entryPtr uintptr _ = entryPtr entryPtr = recordPtr if objc != int64(2) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(2), objv, libc.UintptrFromInt32(0)) return int32(TCL_ERROR) } libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewStringObj(tls, (*TEntry1)(unsafe.Pointer(entryPtr)).Fentry.Fstring1, int64(-int32(1)))) return TCL_OK } // C documentation // // /* $entry icursor $index -- // * Set the insert cursor position. // */ func _EntryICursorCommand(tls *libc.TLS, recordPtr uintptr, interp uintptr, objc TTcl_Size, objv uintptr) (r int32) { var entryPtr uintptr _ = entryPtr entryPtr = recordPtr if objc != int64(3) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(2), objv, __ccgo_ts+22263) return int32(TCL_ERROR) } if _EntryIndex(tls, interp, entryPtr, *(*uintptr)(unsafe.Pointer(objv + 2*8)), entryPtr+88+24) != TCL_OK { return int32(TCL_ERROR) } XTtkRedisplayWidget(tls, entryPtr) return TCL_OK } // C documentation // // /* $entry index $index -- // * Return numeric value (0..numChars) of the specified index. // */ func _EntryIndexCommand(tls *libc.TLS, recordPtr uintptr, interp uintptr, objc TTcl_Size, objv uintptr) (r int32) { bp := tls.Alloc(16) defer tls.Free(16) var entryPtr, v1 uintptr var _ /* index at bp+0 */ TTcl_Size _, _ = entryPtr, v1 entryPtr = recordPtr if objc != int64(3) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(2), objv, __ccgo_ts+22267) return int32(TCL_ERROR) } if _EntryIndex(tls, interp, entryPtr, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp) != TCL_OK { return int32(TCL_ERROR) } if *(*TTcl_Size)(unsafe.Pointer(bp)) == int64(-libc.Int32FromInt32(1)) { v1 = libtcl9_0.XTcl_NewObj(tls) } else { v1 = libtcl9_0.XTcl_NewWideIntObj(tls, *(*TTcl_Size)(unsafe.Pointer(bp))) } libtcl9_0.XTcl_SetObjResult(tls, interp, v1) return TCL_OK } // C documentation // // /* $entry insert $index $text -- // * Insert $text after position $index. // * Silent no-op if the entry is disabled or read-only. // */ func _EntryInsertCommand(tls *libc.TLS, recordPtr uintptr, interp uintptr, objc TTcl_Size, objv uintptr) (r int32) { bp := tls.Alloc(16) defer tls.Free(16) var entryPtr uintptr var _ /* index at bp+0 */ TTcl_Size _ = entryPtr entryPtr = recordPtr if objc != int64(4) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(2), objv, __ccgo_ts+22274) return int32(TCL_ERROR) } if _EntryIndex(tls, interp, entryPtr, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp) != TCL_OK { return int32(TCL_ERROR) } if _EntryEditable(tls, entryPtr) != 0 { return _InsertChars2(tls, entryPtr, *(*TTcl_Size)(unsafe.Pointer(bp)), *(*uintptr)(unsafe.Pointer(objv + 3*8))) } return TCL_OK } // C documentation // // /* $entry selection clear -- // * Clear selection. // */ func _EntrySelectionClearCommand(tls *libc.TLS, recordPtr uintptr, interp uintptr, objc TTcl_Size, objv uintptr) (r int32) { var entryPtr uintptr var v1 TTcl_Size _, _ = entryPtr, v1 entryPtr = recordPtr if objc != int64(3) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(3), objv, libc.UintptrFromInt32(0)) return int32(TCL_ERROR) } v1 = int64(-libc.Int32FromInt32(1)) (*TEntry1)(unsafe.Pointer(entryPtr)).Fentry.FselectLast = v1 (*TEntry1)(unsafe.Pointer(entryPtr)).Fentry.FselectFirst = v1 XTtkRedisplayWidget(tls, entryPtr) return TCL_OK } // C documentation // // /* $entry selection present -- // * Returns 1 if any characters are selected, 0 otherwise. // */ func _EntrySelectionPresentCommand(tls *libc.TLS, recordPtr uintptr, interp uintptr, objc TTcl_Size, objv uintptr) (r int32) { var entryPtr uintptr _ = entryPtr entryPtr = recordPtr if objc != int64(3) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(3), objv, libc.UintptrFromInt32(0)) return int32(TCL_ERROR) } libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewWideIntObj(tls, libc.BoolInt64(libc.BoolInt32((*TEntry1)(unsafe.Pointer(entryPtr)).Fentry.FselectFirst >= 0) != 0))) return TCL_OK } // C documentation // // /* $entry selection range $start $end -- // * Explicitly set the selection range. // */ func _EntrySelectionRangeCommand(tls *libc.TLS, recordPtr uintptr, interp uintptr, objc TTcl_Size, objv uintptr) (r int32) { bp := tls.Alloc(16) defer tls.Free(16) var entryPtr uintptr var v1 TTcl_Size var _ /* end at bp+8 */ TTcl_Size var _ /* start at bp+0 */ TTcl_Size _, _ = entryPtr, v1 entryPtr = recordPtr if objc != int64(5) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(3), objv, __ccgo_ts+22395) return int32(TCL_ERROR) } if _EntryIndex(tls, interp, entryPtr, *(*uintptr)(unsafe.Pointer(objv + 3*8)), bp) != TCL_OK || _EntryIndex(tls, interp, entryPtr, *(*uintptr)(unsafe.Pointer(objv + 4*8)), bp+8) != TCL_OK { return int32(TCL_ERROR) } if (*TEntry1)(unsafe.Pointer(entryPtr)).Fcore.Fstate&libc.Uint32FromInt32(libc.Int32FromInt32(1)<= *(*TTcl_Size)(unsafe.Pointer(bp + 8)) { v1 = int64(-libc.Int32FromInt32(1)) (*TEntry1)(unsafe.Pointer(entryPtr)).Fentry.FselectLast = v1 (*TEntry1)(unsafe.Pointer(entryPtr)).Fentry.FselectFirst = v1 } else { (*TEntry1)(unsafe.Pointer(entryPtr)).Fentry.FselectFirst = *(*TTcl_Size)(unsafe.Pointer(bp)) (*TEntry1)(unsafe.Pointer(entryPtr)).Fentry.FselectLast = *(*TTcl_Size)(unsafe.Pointer(bp + 8)) _EntryOwnSelection(tls, entryPtr) } XTtkRedisplayWidget(tls, entryPtr) return TCL_OK } var _EntrySelectionCommands = [4]TTtk_Ensemble{ 0: { Fname: __ccgo_ts + 4943, }, 1: { Fname: __ccgo_ts + 22183, }, 2: { Fname: __ccgo_ts + 22191, }, 3: {}, } func init() { p := unsafe.Pointer(&_EntrySelectionCommands) *(*uintptr)(unsafe.Add(p, 8)) = __ccgo_fp(_EntrySelectionClearCommand) *(*uintptr)(unsafe.Add(p, 32)) = __ccgo_fp(_EntrySelectionPresentCommand) *(*uintptr)(unsafe.Add(p, 56)) = __ccgo_fp(_EntrySelectionRangeCommand) } // C documentation // // /* $entry set $value // * Sets the value of an entry widget. // */ func _EntrySetCommand(tls *libc.TLS, recordPtr uintptr, interp uintptr, objc TTcl_Size, objv uintptr) (r int32) { var entryPtr uintptr _ = entryPtr entryPtr = recordPtr if objc != int64(3) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(2), objv, __ccgo_ts+20903) return int32(TCL_ERROR) } _EntrySetValue1(tls, entryPtr, libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8)), libc.UintptrFromInt32(0))) return TCL_OK } // C documentation // // /* $entry validate -- // * Trigger forced validation. Returns 1/0 if validation succeeds/fails // * or error status from -validatecommand / -invalidcommand. // */ func _EntryValidateCommand(tls *libc.TLS, recordPtr uintptr, interp uintptr, objc TTcl_Size, objv uintptr) (r int32) { var code int32 var entryPtr uintptr _, _ = code, entryPtr entryPtr = recordPtr if objc != int64(2) { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(2), objv, libc.UintptrFromInt32(0)) return int32(TCL_ERROR) } code = _EntryRevalidate(tls, interp, entryPtr, int32(VALIDATE_FORCED1)) if code == int32(TCL_ERROR) { return code } libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewWideIntObj(tls, libc.BoolInt64(libc.BoolInt32(code == TCL_OK) != 0))) return TCL_OK } // C documentation // // /* $entry xview -- horizontal scrolling interface // */ func _EntryXViewCommand(tls *libc.TLS, recordPtr uintptr, interp uintptr, objc TTcl_Size, objv uintptr) (r int32) { bp := tls.Alloc(16) defer tls.Free(16) var entryPtr uintptr var _ /* newFirst at bp+0 */ TTcl_Size _ = entryPtr entryPtr = recordPtr if objc == int64(3) { if _EntryIndex(tls, interp, entryPtr, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp) != TCL_OK { return int32(TCL_ERROR) } XTtkScrollTo(tls, (*TEntry1)(unsafe.Pointer(entryPtr)).Fentry.FxscrollHandle, int32(*(*TTcl_Size)(unsafe.Pointer(bp))), int32(1)) return TCL_OK } return XTtkScrollviewCommand(tls, interp, objc, objv, (*TEntry1)(unsafe.Pointer(entryPtr)).Fentry.FxscrollHandle) } var _EntryCommands = [16]TTtk_Ensemble{ 0: { Fname: __ccgo_ts + 12095, }, 1: { Fname: __ccgo_ts + 4735, }, 2: { Fname: __ccgo_ts + 4740, }, 3: { Fname: __ccgo_ts + 2655, }, 4: { Fname: __ccgo_ts + 4949, }, 5: { Fname: __ccgo_ts + 22144, }, 6: { Fname: __ccgo_ts + 22197, }, 7: { Fname: __ccgo_ts + 22152, }, 8: { Fname: __ccgo_ts + 22158, }, 9: { Fname: __ccgo_ts + 49187, }, 10: { Fname: __ccgo_ts + 17828, Fensemble: uintptr(unsafe.Pointer(&_EntrySelectionCommands)), }, 11: { Fname: __ccgo_ts + 16747, }, 12: { Fname: __ccgo_ts + 16580, }, 13: { Fname: __ccgo_ts + 21774, }, 14: { Fname: __ccgo_ts + 22170, }, 15: {}, } func init() { p := unsafe.Pointer(&_EntryCommands) *(*uintptr)(unsafe.Add(p, 8)) = __ccgo_fp(_EntryBBoxCommand) *(*uintptr)(unsafe.Add(p, 32)) = __ccgo_fp(XTtkWidgetCgetCommand) *(*uintptr)(unsafe.Add(p, 56)) = __ccgo_fp(XTtkWidgetConfigureCommand) *(*uintptr)(unsafe.Add(p, 80)) = __ccgo_fp(_EntryDeleteCommand) *(*uintptr)(unsafe.Add(p, 104)) = __ccgo_fp(_EntryGetCommand) *(*uintptr)(unsafe.Add(p, 128)) = __ccgo_fp(_EntryICursorCommand) *(*uintptr)(unsafe.Add(p, 152)) = __ccgo_fp(XTtkWidgetIdentifyCommand) *(*uintptr)(unsafe.Add(p, 176)) = __ccgo_fp(_EntryIndexCommand) *(*uintptr)(unsafe.Add(p, 200)) = __ccgo_fp(_EntryInsertCommand) *(*uintptr)(unsafe.Add(p, 224)) = __ccgo_fp(XTtkWidgetInstateCommand) *(*uintptr)(unsafe.Add(p, 272)) = __ccgo_fp(XTtkWidgetStateCommand) *(*uintptr)(unsafe.Add(p, 296)) = __ccgo_fp(XTtkWidgetStyleCommand) *(*uintptr)(unsafe.Add(p, 320)) = __ccgo_fp(_EntryValidateCommand) *(*uintptr)(unsafe.Add(p, 344)) = __ccgo_fp(_EntryXViewCommand) } /*------------------------------------------------------------------------ * +++ Entry widget definition. */ var _EntryWidgetSpec = TWidgetSpec{ FclassName: __ccgo_ts + 50695, FrecordSize: uint64(416), FoptionSpecs: uintptr(unsafe.Pointer(&_EntryOptionSpecs)), Fcommands: uintptr(unsafe.Pointer(&_EntryCommands)), } func init() { p := unsafe.Pointer(&_EntryWidgetSpec) *(*uintptr)(unsafe.Add(p, 32)) = __ccgo_fp(_EntryInitialize) *(*uintptr)(unsafe.Add(p, 40)) = __ccgo_fp(_EntryCleanup) *(*uintptr)(unsafe.Add(p, 48)) = __ccgo_fp(_EntryConfigure) *(*uintptr)(unsafe.Add(p, 56)) = __ccgo_fp(_EntryPostConfigure) *(*uintptr)(unsafe.Add(p, 64)) = __ccgo_fp(XTtkWidgetGetLayout) *(*uintptr)(unsafe.Add(p, 72)) = __ccgo_fp(XTtkWidgetSize) *(*uintptr)(unsafe.Add(p, 80)) = __ccgo_fp(_EntryDoLayout) *(*uintptr)(unsafe.Add(p, 88)) = __ccgo_fp(_EntryDisplay) } /*------------------------------------------------------------------------ * +++ Combobox widget record. */ type TComboboxPart = struct { FpostCommandObj uintptr FvaluesObj uintptr FheightObj uintptr FcurrentIndex TTcl_Size } type TCombobox = struct { Fcore TWidgetCore Fentry TEntryPart Fcombobox TComboboxPart } var _ComboboxOptionSpecs = [4]TTk_OptionSpec{ 0: { Ftype1: int32(TK_OPTION_STRING), FoptionName: __ccgo_ts + 2870, FdbName: __ccgo_ts + 6172, FdbClass: __ccgo_ts + 20122, FdefValue: __ccgo_ts + 23502, FobjOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 416 + 16)), FinternalOffset: int64(-libc.Int32FromInt32(1)), }, 1: { Ftype1: int32(TK_OPTION_STRING), FoptionName: __ccgo_ts + 24295, FdbName: __ccgo_ts + 24308, FdbClass: __ccgo_ts + 51886, FdefValue: __ccgo_ts + 195, FobjOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 416)), FinternalOffset: int64(-libc.Int32FromInt32(1)), }, 2: { Ftype1: int32(TK_OPTION_STRING), FoptionName: __ccgo_ts + 22106, FdbName: __ccgo_ts + 22114, FdbClass: __ccgo_ts + 22121, FdefValue: __ccgo_ts + 195, FobjOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 416 + 8)), FinternalOffset: int64(-libc.Int32FromInt32(1)), }, 3: { Ftype1: int32(TK_OPTION_END), FobjOffset: int64(-libc.Int32FromInt32(1)), FinternalOffset: int64(-libc.Int32FromInt32(1)), FclientData: uintptr(unsafe.Pointer(&_EntryOptionSpecs)), }, } // C documentation // // /* ComboboxInitialize -- // * Initialization hook for combobox widgets. // */ func _ComboboxInitialize(tls *libc.TLS, interp uintptr, recordPtr uintptr) { var cb uintptr _ = cb cb = recordPtr (*TCombobox)(unsafe.Pointer(cb)).Fcombobox.FcurrentIndex = int64(-libc.Int32FromInt32(1)) XTtkTrackElementState(tls, cb) _EntryInitialize(tls, interp, recordPtr) } // C documentation // // /* ComboboxConfigure -- // * Configuration hook for combobox widgets. // */ func _ComboboxConfigure(tls *libc.TLS, interp uintptr, recordPtr uintptr, mask int32) (r int32) { bp := tls.Alloc(16) defer tls.Free(16) var cbPtr uintptr var _ /* unused at bp+0 */ TTcl_Size _ = cbPtr cbPtr = recordPtr /* Make sure -values is a valid list: */ if libtcl9_0.XTcl_ListObjLength(tls, interp, (*TCombobox)(unsafe.Pointer(cbPtr)).Fcombobox.FvaluesObj, bp) != TCL_OK { return int32(TCL_ERROR) } return _EntryConfigure(tls, interp, recordPtr, mask) } // C documentation // // /* $cb current ?newIndex? -- get or set current index. // * Setting the current index updates the combobox value, // * but the value and -values may be changed independently // * of the index. Instead of trying to keep currentIndex // * in sync at all times, [$cb current] double-checks // */ func _ComboboxCurrentCommand(tls *libc.TLS, recordPtr uintptr, interp uintptr, objc TTcl_Size, objv uintptr) (r int32) { bp := tls.Alloc(64) defer tls.Free(64) var cbPtr, currentValue, v2 uintptr var currentIndex TTcl_Size var _ /* idx at bp+16 */ TTcl_Size var _ /* nValues at bp+0 */ TTcl_Size var _ /* values at bp+8 */ uintptr _, _, _, _ = cbPtr, currentIndex, currentValue, v2 cbPtr = recordPtr currentIndex = (*TCombobox)(unsafe.Pointer(cbPtr)).Fcombobox.FcurrentIndex currentValue = (*TCombobox)(unsafe.Pointer(cbPtr)).Fentry.Fstring1 libtcl9_0.XTcl_ListObjGetElements(tls, interp, (*TCombobox)(unsafe.Pointer(cbPtr)).Fcombobox.FvaluesObj, bp, bp+8) if objc == int64(2) { /* Check if currentIndex still valid: */ if currentIndex < 0 || currentIndex >= *(*TTcl_Size)(unsafe.Pointer(bp)) || libc.Xstrcmp(tls, currentValue, libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 8)) + uintptr(currentIndex)*8)), libc.UintptrFromInt32(0))) != 0 { /* Not valid. Check current value against each element in -values: */ currentIndex = 0 for { if !(currentIndex < *(*TTcl_Size)(unsafe.Pointer(bp))) { break } if !(libc.Xstrcmp(tls, currentValue, libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 8)) + uintptr(currentIndex)*8)), libc.UintptrFromInt32(0))) != 0) { break } goto _1 _1: ; currentIndex++ } if currentIndex >= *(*TTcl_Size)(unsafe.Pointer(bp)) { /* Not found */ currentIndex = int64(-libc.Int32FromInt32(1)) } } (*TCombobox)(unsafe.Pointer(cbPtr)).Fcombobox.FcurrentIndex = currentIndex if currentIndex == int64(-libc.Int32FromInt32(1)) { v2 = libtcl9_0.XTcl_NewObj(tls) } else { v2 = libtcl9_0.XTcl_NewWideIntObj(tls, currentIndex) } libtcl9_0.XTcl_SetObjResult(tls, interp, v2) return TCL_OK } else { if objc == int64(3) { if TCL_OK == XTkGetIntForIndex(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8)), *(*TTcl_Size)(unsafe.Pointer(bp))-int64(1), 0, bp+16) { if *(*TTcl_Size)(unsafe.Pointer(bp + 16)) < 0 || *(*TTcl_Size)(unsafe.Pointer(bp + 16)) >= *(*TTcl_Size)(unsafe.Pointer(bp)) { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+51898, libc.VaList(bp+32, libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8)), libc.UintptrFromInt32(0))))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+32, __ccgo_ts+51861, __ccgo_ts+51922, __ccgo_ts+51931, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) } currentIndex = *(*TTcl_Size)(unsafe.Pointer(bp + 16)) } else { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+29867, libc.VaList(bp+32, libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8)), libc.UintptrFromInt32(0))))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+32, __ccgo_ts+51861, __ccgo_ts+51922, __ccgo_ts+51941, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) } (*TCombobox)(unsafe.Pointer(cbPtr)).Fcombobox.FcurrentIndex = currentIndex return _EntrySetValue1(tls, recordPtr, libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 8)) + uintptr(currentIndex)*8)), libc.UintptrFromInt32(0))) } else { libtcl9_0.XTcl_WrongNumArgs(tls, interp, int64(2), objv, __ccgo_ts+51951) return int32(TCL_ERROR) } } return TCL_OK } // C documentation // // /*------------------------------------------------------------------------ // * +++ Combobox widget definition. // */ var _ComboboxCommands = [18]TTtk_Ensemble{ 0: { Fname: __ccgo_ts + 12095, }, 1: { Fname: __ccgo_ts + 4735, }, 2: { Fname: __ccgo_ts + 4740, }, 3: { Fname: __ccgo_ts + 3279, }, 4: { Fname: __ccgo_ts + 2655, }, 5: { Fname: __ccgo_ts + 4949, }, 6: { Fname: __ccgo_ts + 22144, }, 7: { Fname: __ccgo_ts + 22197, }, 8: { Fname: __ccgo_ts + 22152, }, 9: { Fname: __ccgo_ts + 22158, }, 10: { Fname: __ccgo_ts + 49187, }, 11: { Fname: __ccgo_ts + 17828, Fensemble: uintptr(unsafe.Pointer(&_EntrySelectionCommands)), }, 12: { Fname: __ccgo_ts + 11726, }, 13: { Fname: __ccgo_ts + 16747, }, 14: { Fname: __ccgo_ts + 16580, }, 15: { Fname: __ccgo_ts + 21774, }, 16: { Fname: __ccgo_ts + 22170, }, 17: {}, } func init() { p := unsafe.Pointer(&_ComboboxCommands) *(*uintptr)(unsafe.Add(p, 8)) = __ccgo_fp(_EntryBBoxCommand) *(*uintptr)(unsafe.Add(p, 32)) = __ccgo_fp(XTtkWidgetCgetCommand) *(*uintptr)(unsafe.Add(p, 56)) = __ccgo_fp(XTtkWidgetConfigureCommand) *(*uintptr)(unsafe.Add(p, 80)) = __ccgo_fp(_ComboboxCurrentCommand) *(*uintptr)(unsafe.Add(p, 104)) = __ccgo_fp(_EntryDeleteCommand) *(*uintptr)(unsafe.Add(p, 128)) = __ccgo_fp(_EntryGetCommand) *(*uintptr)(unsafe.Add(p, 152)) = __ccgo_fp(_EntryICursorCommand) *(*uintptr)(unsafe.Add(p, 176)) = __ccgo_fp(XTtkWidgetIdentifyCommand) *(*uintptr)(unsafe.Add(p, 200)) = __ccgo_fp(_EntryIndexCommand) *(*uintptr)(unsafe.Add(p, 224)) = __ccgo_fp(_EntryInsertCommand) *(*uintptr)(unsafe.Add(p, 248)) = __ccgo_fp(XTtkWidgetInstateCommand) *(*uintptr)(unsafe.Add(p, 296)) = __ccgo_fp(_EntrySetCommand) *(*uintptr)(unsafe.Add(p, 320)) = __ccgo_fp(XTtkWidgetStateCommand) *(*uintptr)(unsafe.Add(p, 344)) = __ccgo_fp(XTtkWidgetStyleCommand) *(*uintptr)(unsafe.Add(p, 368)) = __ccgo_fp(_EntryValidateCommand) *(*uintptr)(unsafe.Add(p, 392)) = __ccgo_fp(_EntryXViewCommand) } var _ComboboxWidgetSpec = TWidgetSpec{ FclassName: __ccgo_ts + 50095, FrecordSize: uint64(448), FoptionSpecs: uintptr(unsafe.Pointer(&_ComboboxOptionSpecs)), Fcommands: uintptr(unsafe.Pointer(&_ComboboxCommands)), } func init() { p := unsafe.Pointer(&_ComboboxWidgetSpec) *(*uintptr)(unsafe.Add(p, 32)) = __ccgo_fp(_ComboboxInitialize) *(*uintptr)(unsafe.Add(p, 40)) = __ccgo_fp(_EntryCleanup) *(*uintptr)(unsafe.Add(p, 48)) = __ccgo_fp(_ComboboxConfigure) *(*uintptr)(unsafe.Add(p, 56)) = __ccgo_fp(_EntryPostConfigure) *(*uintptr)(unsafe.Add(p, 64)) = __ccgo_fp(XTtkWidgetGetLayout) *(*uintptr)(unsafe.Add(p, 72)) = __ccgo_fp(XTtkWidgetSize) *(*uintptr)(unsafe.Add(p, 80)) = __ccgo_fp(_EntryDoLayout) *(*uintptr)(unsafe.Add(p, 88)) = __ccgo_fp(_EntryDisplay) } /*------------------------------------------------------------------------ * +++ Spinbox widget. */ type TSpinboxPart = struct { FvaluesObj uintptr FfromObj uintptr FtoObj uintptr FincrementObj uintptr FformatObj uintptr FwrapObj uintptr FcommandObj uintptr } type TSpinbox1 = struct { Fcore TWidgetCore Fentry TEntryPart Fspinbox TSpinboxPart } var _SpinboxOptionSpecs = [8]TTk_OptionSpec{ 0: { Ftype1: int32(TK_OPTION_STRING), FoptionName: __ccgo_ts + 22106, FdbName: __ccgo_ts + 22114, FdbClass: __ccgo_ts + 22121, FdefValue: __ccgo_ts + 195, FobjOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 416)), FinternalOffset: int64(-libc.Int32FromInt32(1)), }, 1: { Ftype1: int32(TK_OPTION_DOUBLE), FoptionName: __ccgo_ts + 22037, FdbName: __ccgo_ts + 22043, FdbClass: __ccgo_ts + 22048, FdefValue: __ccgo_ts + 14146, FobjOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 416 + 8)), FinternalOffset: int64(-libc.Int32FromInt32(1)), }, 2: { Ftype1: int32(TK_OPTION_DOUBLE), FoptionName: __ccgo_ts + 22096, FdbName: __ccgo_ts + 22100, FdbClass: __ccgo_ts + 22103, FdefValue: __ccgo_ts + 14146, FobjOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 416 + 16)), FinternalOffset: int64(-libc.Int32FromInt32(1)), }, 3: { Ftype1: int32(TK_OPTION_DOUBLE), FoptionName: __ccgo_ts + 22053, FdbName: __ccgo_ts + 22064, FdbClass: __ccgo_ts + 22074, FdefValue: __ccgo_ts + 22084, FobjOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 416 + 24)), FinternalOffset: int64(-libc.Int32FromInt32(1)), }, 4: { Ftype1: int32(TK_OPTION_STRING), FoptionName: __ccgo_ts + 4981, FdbName: __ccgo_ts + 22023, FdbClass: __ccgo_ts + 22030, FdefValue: __ccgo_ts + 195, FobjOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 416 + 32)), FinternalOffset: int64(-libc.Int32FromInt32(1)), }, 5: { Ftype1: int32(TK_OPTION_STRING), FoptionName: __ccgo_ts + 16356, FdbName: __ccgo_ts + 20495, FdbClass: __ccgo_ts + 1659, FdefValue: __ccgo_ts + 195, FobjOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 416 + 48)), FinternalOffset: int64(-libc.Int32FromInt32(1)), }, 6: { FoptionName: __ccgo_ts + 22128, FdbName: __ccgo_ts + 22134, FdbClass: __ccgo_ts + 22139, FdefValue: __ccgo_ts + 10533, FobjOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 416 + 40)), FinternalOffset: int64(-libc.Int32FromInt32(1)), }, 7: { Ftype1: int32(TK_OPTION_END), FobjOffset: int64(-libc.Int32FromInt32(1)), FinternalOffset: int64(-libc.Int32FromInt32(1)), FclientData: uintptr(unsafe.Pointer(&_EntryOptionSpecs)), }, } // C documentation // // /* SpinboxInitialize -- // * Initialization hook for spinbox widgets. // */ func _SpinboxInitialize(tls *libc.TLS, interp uintptr, recordPtr uintptr) { var sb uintptr _ = sb sb = recordPtr XTtkTrackElementState(tls, sb) _EntryInitialize(tls, interp, recordPtr) } // C documentation // // /* SpinboxConfigure -- // * Configuration hook for spinbox widgets. // */ func _SpinboxConfigure(tls *libc.TLS, interp uintptr, recordPtr uintptr, mask int32) (r int32) { bp := tls.Alloc(16) defer tls.Free(16) var sb uintptr var _ /* unused at bp+0 */ TTcl_Size _ = sb sb = recordPtr /* Make sure -values is a valid list: */ if libtcl9_0.XTcl_ListObjLength(tls, interp, (*TSpinbox1)(unsafe.Pointer(sb)).Fspinbox.FvaluesObj, bp) != TCL_OK { return int32(TCL_ERROR) } return _EntryConfigure(tls, interp, recordPtr, mask) } var _SpinboxCommands = [17]TTtk_Ensemble{ 0: { Fname: __ccgo_ts + 12095, }, 1: { Fname: __ccgo_ts + 4735, }, 2: { Fname: __ccgo_ts + 4740, }, 3: { Fname: __ccgo_ts + 2655, }, 4: { Fname: __ccgo_ts + 4949, }, 5: { Fname: __ccgo_ts + 22144, }, 6: { Fname: __ccgo_ts + 22197, }, 7: { Fname: __ccgo_ts + 22152, }, 8: { Fname: __ccgo_ts + 22158, }, 9: { Fname: __ccgo_ts + 49187, }, 10: { Fname: __ccgo_ts + 17828, Fensemble: uintptr(unsafe.Pointer(&_EntrySelectionCommands)), }, 11: { Fname: __ccgo_ts + 11726, }, 12: { Fname: __ccgo_ts + 16747, }, 13: { Fname: __ccgo_ts + 16580, }, 14: { Fname: __ccgo_ts + 21774, }, 15: { Fname: __ccgo_ts + 22170, }, 16: {}, } func init() { p := unsafe.Pointer(&_SpinboxCommands) *(*uintptr)(unsafe.Add(p, 8)) = __ccgo_fp(_EntryBBoxCommand) *(*uintptr)(unsafe.Add(p, 32)) = __ccgo_fp(XTtkWidgetCgetCommand) *(*uintptr)(unsafe.Add(p, 56)) = __ccgo_fp(XTtkWidgetConfigureCommand) *(*uintptr)(unsafe.Add(p, 80)) = __ccgo_fp(_EntryDeleteCommand) *(*uintptr)(unsafe.Add(p, 104)) = __ccgo_fp(_EntryGetCommand) *(*uintptr)(unsafe.Add(p, 128)) = __ccgo_fp(_EntryICursorCommand) *(*uintptr)(unsafe.Add(p, 152)) = __ccgo_fp(XTtkWidgetIdentifyCommand) *(*uintptr)(unsafe.Add(p, 176)) = __ccgo_fp(_EntryIndexCommand) *(*uintptr)(unsafe.Add(p, 200)) = __ccgo_fp(_EntryInsertCommand) *(*uintptr)(unsafe.Add(p, 224)) = __ccgo_fp(XTtkWidgetInstateCommand) *(*uintptr)(unsafe.Add(p, 272)) = __ccgo_fp(_EntrySetCommand) *(*uintptr)(unsafe.Add(p, 296)) = __ccgo_fp(XTtkWidgetStateCommand) *(*uintptr)(unsafe.Add(p, 320)) = __ccgo_fp(XTtkWidgetStyleCommand) *(*uintptr)(unsafe.Add(p, 344)) = __ccgo_fp(_EntryValidateCommand) *(*uintptr)(unsafe.Add(p, 368)) = __ccgo_fp(_EntryXViewCommand) } var _SpinboxWidgetSpec = TWidgetSpec{ FclassName: __ccgo_ts + 50778, FrecordSize: uint64(472), FoptionSpecs: uintptr(unsafe.Pointer(&_SpinboxOptionSpecs)), Fcommands: uintptr(unsafe.Pointer(&_SpinboxCommands)), } func init() { p := unsafe.Pointer(&_SpinboxWidgetSpec) *(*uintptr)(unsafe.Add(p, 32)) = __ccgo_fp(_SpinboxInitialize) *(*uintptr)(unsafe.Add(p, 40)) = __ccgo_fp(_EntryCleanup) *(*uintptr)(unsafe.Add(p, 48)) = __ccgo_fp(_SpinboxConfigure) *(*uintptr)(unsafe.Add(p, 56)) = __ccgo_fp(_EntryPostConfigure) *(*uintptr)(unsafe.Add(p, 64)) = __ccgo_fp(XTtkWidgetGetLayout) *(*uintptr)(unsafe.Add(p, 72)) = __ccgo_fp(XTtkWidgetSize) *(*uintptr)(unsafe.Add(p, 80)) = __ccgo_fp(_EntryDoLayout) *(*uintptr)(unsafe.Add(p, 88)) = __ccgo_fp(_EntryDisplay) } /*------------------------------------------------------------------------ * +++ Textarea element. * * Text display area for Entry widgets. * Just computes requested size; display is handled by the widget itself. */ type TTextareaElement = struct { FfontObj uintptr FwidthObj uintptr } var _TextareaElementOptions = [3]TTtk_ElementOptionSpec{ 0: { FoptionName: __ccgo_ts + 20097, Ftype1: int32(TK_OPTION_FONT), FdefaultValue: __ccgo_ts + 21213, }, 1: { FoptionName: __ccgo_ts + 2987, Ftype1: int32(TK_OPTION_INT), Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 8)), FdefaultValue: __ccgo_ts + 21847, }, 2: {}, } func _TextareaElementSize(tls *libc.TLS, dummy2091 uintptr, elementRecord uintptr, tkwin TTk_Window, widthPtr uintptr, heightPtr uintptr, dummy2096 uintptr) { bp := tls.Alloc(16) defer tls.Free(16) var avgWidth int32 var font TTk_Font var textarea uintptr var _ /* fm at bp+0 */ TTk_FontMetrics var _ /* prefWidth at bp+12 */ int32 _, _, _ = avgWidth, font, textarea textarea = elementRecord font = XTk_GetFontFromObj(tls, tkwin, (*TTextareaElement)(unsafe.Pointer(textarea)).FfontObj) avgWidth = XTk_TextWidth(tls, font, __ccgo_ts+10533, int64(1)) *(*int32)(unsafe.Pointer(bp + 12)) = int32(1) XTk_GetFontMetrics(tls, font, bp) libtcl9_0.XTcl_GetIntFromObj(tls, libc.UintptrFromInt32(0), (*TTextareaElement)(unsafe.Pointer(textarea)).FwidthObj, bp+12) if *(*int32)(unsafe.Pointer(bp + 12)) <= 0 { *(*int32)(unsafe.Pointer(bp + 12)) = int32(1) } *(*int32)(unsafe.Pointer(heightPtr)) = (*(*TTk_FontMetrics)(unsafe.Pointer(bp))).Flinespace *(*int32)(unsafe.Pointer(widthPtr)) = *(*int32)(unsafe.Pointer(bp + 12)) * avgWidth } var _TextareaElementSpec = TTtk_ElementSpec{ Fversion: int32(TK_STYLE_VERSION_2), FelementSize: uint64(16), Foptions: uintptr(unsafe.Pointer(&_TextareaElementOptions)), } func init() { p := unsafe.Pointer(&_TextareaElementSpec) *(*uintptr)(unsafe.Add(p, 24)) = __ccgo_fp(_TextareaElementSize) *(*uintptr)(unsafe.Add(p, 32)) = __ccgo_fp(XTtkNullElementDraw) } /*------------------------------------------------------------------------ * +++ Widget layouts. */ var _EntryLayout = [6]TTTKLayoutInstruction{ 0: { FelementName: __ccgo_ts + 50718, Fopcode: libc.Uint32FromInt32(libc.Int32FromInt32(TTK_FILL_BOTH) | libc.Int32FromInt32(TTK_BORDER) | libc.Int32FromInt32(_TTK_CHILDREN)), }, 1: { FelementName: __ccgo_ts + 50730, Fopcode: libc.Uint32FromInt32(libc.Int32FromInt32(TTK_FILL_BOTH) | libc.Int32FromInt32(_TTK_CHILDREN)), }, 2: { FelementName: __ccgo_ts + 50744, Fopcode: libc.Uint32FromInt32(libc.Int32FromInt32(TTK_FILL_BOTH)), }, 3: { Fopcode: libc.Uint32FromInt32(libc.Int32FromInt32(_TTK_LAYOUT_END)), }, 4: { Fopcode: libc.Uint32FromInt32(libc.Int32FromInt32(_TTK_LAYOUT_END)), }, 5: { Fopcode: libc.Uint32FromInt32(libc.Int32FromInt32(_TTK_LAYOUT_END)), }, } var _ComboboxLayout = [7]TTTKLayoutInstruction{ 0: { FelementName: __ccgo_ts + 50124, Fopcode: libc.Uint32FromInt32(libc.Int32FromInt32(TTK_FILL_BOTH) | libc.Int32FromInt32(_TTK_CHILDREN)), }, 1: { FelementName: __ccgo_ts + 50105, Fopcode: libc.Uint32FromInt32(libc.Int32FromInt32(TTK_PACK_RIGHT) | libc.Int32FromInt32(TTK_FILL_Y)), }, 2: { FelementName: __ccgo_ts + 50139, Fopcode: libc.Uint32FromInt32(libc.Int32FromInt32(TTK_FILL_BOTH) | libc.Int32FromInt32(_TTK_CHILDREN)), }, 3: { FelementName: __ccgo_ts + 50156, Fopcode: libc.Uint32FromInt32(libc.Int32FromInt32(TTK_FILL_BOTH)), }, 4: { Fopcode: libc.Uint32FromInt32(libc.Int32FromInt32(_TTK_LAYOUT_END)), }, 5: { Fopcode: libc.Uint32FromInt32(libc.Int32FromInt32(_TTK_LAYOUT_END)), }, 6: { Fopcode: libc.Uint32FromInt32(libc.Int32FromInt32(_TTK_LAYOUT_END)), }, } var _SpinboxLayout = [10]TTTKLayoutInstruction{ 0: { FelementName: __ccgo_ts + 50805, Fopcode: libc.Uint32FromInt32(libc.Int32FromInt32(TTK_PACK_TOP) | libc.Int32FromInt32(TTK_FILL_X) | libc.Int32FromInt32(_TTK_CHILDREN)), }, 1: { FelementName: __ccgo_ts + 50819, Fopcode: libc.Uint32FromInt32(libc.Int32FromInt32(TTK_PACK_RIGHT) | libc.Int32FromInt32(_TTK_CHILDREN)), }, 2: { FelementName: __ccgo_ts + 50280, Fopcode: libc.Uint32FromInt32(libc.Int32FromInt32(TTK_PACK_TOP) | libc.Int32FromInt32(TTK_STICK_E)), }, 3: { FelementName: __ccgo_ts + 50306, Fopcode: libc.Uint32FromInt32(libc.Int32FromInt32(TTK_PACK_BOTTOM) | libc.Int32FromInt32(TTK_STICK_E)), }, 4: { Fopcode: libc.Uint32FromInt32(libc.Int32FromInt32(_TTK_LAYOUT_END)), }, 5: { FelementName: __ccgo_ts + 50824, Fopcode: libc.Uint32FromInt32(libc.Int32FromInt32(TTK_FILL_BOTH) | libc.Int32FromInt32(_TTK_CHILDREN)), }, 6: { FelementName: __ccgo_ts + 50840, Fopcode: libc.Uint32FromInt32(libc.Int32FromInt32(TTK_FILL_BOTH)), }, 7: { Fopcode: libc.Uint32FromInt32(libc.Int32FromInt32(_TTK_LAYOUT_END)), }, 8: { Fopcode: libc.Uint32FromInt32(libc.Int32FromInt32(_TTK_LAYOUT_END)), }, 9: { Fopcode: libc.Uint32FromInt32(libc.Int32FromInt32(_TTK_LAYOUT_END)), }, } /*------------------------------------------------------------------------ * +++ Initialization. */ func XTtkEntry_Init(tls *libc.TLS, interp uintptr) { var themePtr TTtk_Theme _ = themePtr themePtr = XTtk_GetDefaultTheme(tls, interp) XTtk_RegisterElement(tls, interp, themePtr, __ccgo_ts+51847, uintptr(unsafe.Pointer(&_TextareaElementSpec)), uintptr(0)) XTtk_RegisterLayout(tls, themePtr, __ccgo_ts+50695, uintptr(unsafe.Pointer(&_EntryLayout))) XTtk_RegisterLayout(tls, themePtr, __ccgo_ts+50095, uintptr(unsafe.Pointer(&_ComboboxLayout))) XTtk_RegisterLayout(tls, themePtr, __ccgo_ts+50778, uintptr(unsafe.Pointer(&_SpinboxLayout))) libtcl9_0.XTcl_CreateObjCommand2(tls, interp, __ccgo_ts+51962, __ccgo_fp(XTtkWidgetConstructorObjCmd), uintptr(unsafe.Pointer(&_EntryWidgetSpec)), libc.UintptrFromInt32(0)) libtcl9_0.XTcl_CreateObjCommand2(tls, interp, __ccgo_ts+51973, __ccgo_fp(XTtkWidgetConstructorObjCmd), uintptr(unsafe.Pointer(&_ComboboxWidgetSpec)), libc.UintptrFromInt32(0)) libtcl9_0.XTcl_CreateObjCommand2(tls, interp, __ccgo_ts+51987, __ccgo_fp(XTtkWidgetConstructorObjCmd), uintptr(unsafe.Pointer(&_SpinboxWidgetSpec)), libc.UintptrFromInt32(0)) } const DEFAULT_BORDERWIDTH1 = 2 const DEFAULT_LABELINSET = 8 const LABELWIDGET_CHANGED = 256 const Ttk_ForgetSlave = 0 const Ttk_GetSlaveIndexFromObj = 0 const Ttk_InsertSlave = 0 const Ttk_LostSlaveProc = 0 const Ttk_NumberSlaves = 0 const Ttk_PlaceSlave = 0 const Ttk_ReorderSlave = 0 const Ttk_SlaveData = 0 const Ttk_SlaveIndex = 0 const Ttk_SlaveWindow = 0 const Ttk_UnmapSlave = 0 type TTtk_ManagerSpec = struct { FtkGeomMgr TTk_GeomMgr FRequestedSize uintptr FPlaceContent uintptr FContentRequest uintptr FContentRemoved uintptr } /* Returns: 1 if container can manage content; 0 otherwise leaving error msg */ /* ====================================================================== * +++ Frame widget: */ type TFramePart = struct { FborderWidthObj uintptr FpaddingObj uintptr FreliefObj uintptr FwidthObj uintptr FheightObj uintptr } type TFrame1 = struct { Fcore TWidgetCore Fframe TFramePart } var _FrameOptionSpecs = [7]TTk_OptionSpec{ 0: { Ftype1: int32(TK_OPTION_PIXELS), FoptionName: __ccgo_ts + 2814, FdbName: __ccgo_ts + 19952, FdbClass: __ccgo_ts + 19964, FobjOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 88)), FinternalOffset: int64(-libc.Int32FromInt32(1)), Fflags: int32(TCL_NULL_OK), FtypeMask: int32(GEOMETRY_CHANGED), }, 1: { Ftype1: int32(TK_OPTION_STRING), FoptionName: __ccgo_ts + 49128, FdbName: __ccgo_ts + 49137, FdbClass: __ccgo_ts + 20337, FobjOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 88 + 8)), FinternalOffset: int64(-libc.Int32FromInt32(1)), Fflags: int32(TCL_NULL_OK), FtypeMask: int32(GEOMETRY_CHANGED), }, 2: { Ftype1: int32(TK_OPTION_RELIEF), FoptionName: __ccgo_ts + 20346, FdbName: __ccgo_ts + 82, FdbClass: __ccgo_ts + 20354, FobjOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 88 + 16)), FinternalOffset: int64(-libc.Int32FromInt32(1)), Fflags: int32(TCL_NULL_OK), }, 3: { Ftype1: int32(TK_OPTION_PIXELS), FoptionName: __ccgo_ts + 2987, FdbName: __ccgo_ts + 6446, FdbClass: __ccgo_ts + 20455, FdefValue: __ccgo_ts + 10533, FobjOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 88 + 24)), FinternalOffset: int64(-libc.Int32FromInt32(1)), FtypeMask: int32(GEOMETRY_CHANGED), }, 4: { Ftype1: int32(TK_OPTION_PIXELS), FoptionName: __ccgo_ts + 2870, FdbName: __ccgo_ts + 6172, FdbClass: __ccgo_ts + 20122, FdefValue: __ccgo_ts + 10533, FobjOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 88 + 32)), FinternalOffset: int64(-libc.Int32FromInt32(1)), FtypeMask: int32(GEOMETRY_CHANGED), }, 5: { Ftype1: int32(TK_OPTION_STRING), FoptionName: __ccgo_ts + 20367, FdbName: __ccgo_ts + 20378, FdbClass: __ccgo_ts + 20388, FdefValue: __ccgo_ts + 195, FobjOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 48)), FinternalOffset: int64(-libc.Int32FromInt32(1)), }, 6: { Ftype1: int32(TK_OPTION_END), FobjOffset: int64(-libc.Int32FromInt32(1)), FinternalOffset: int64(-libc.Int32FromInt32(1)), FclientData: uintptr(unsafe.Pointer(&XttkCoreOptionSpecs)), }, } var _FrameCommands = [7]TTtk_Ensemble{ 0: { Fname: __ccgo_ts + 4735, }, 1: { Fname: __ccgo_ts + 4740, }, 2: { Fname: __ccgo_ts + 22197, }, 3: { Fname: __ccgo_ts + 49187, }, 4: { Fname: __ccgo_ts + 16747, }, 5: { Fname: __ccgo_ts + 16580, }, 6: {}, } func init() { p := unsafe.Pointer(&_FrameCommands) *(*uintptr)(unsafe.Add(p, 8)) = __ccgo_fp(XTtkWidgetCgetCommand) *(*uintptr)(unsafe.Add(p, 32)) = __ccgo_fp(XTtkWidgetConfigureCommand) *(*uintptr)(unsafe.Add(p, 56)) = __ccgo_fp(XTtkWidgetIdentifyCommand) *(*uintptr)(unsafe.Add(p, 80)) = __ccgo_fp(XTtkWidgetInstateCommand) *(*uintptr)(unsafe.Add(p, 104)) = __ccgo_fp(XTtkWidgetStateCommand) *(*uintptr)(unsafe.Add(p, 128)) = __ccgo_fp(XTtkWidgetStyleCommand) } // C documentation // // /* // * FrameMargins -- // * Compute internal margins for a frame widget. // * This includes the -borderWidth, plus any additional -padding. // */ func _FrameMargins(tls *libc.TLS, framePtr uintptr) (r TTtk_Padding) { bp := tls.Alloc(16) defer tls.Free(16) var _ /* border at bp+8 */ int32 var _ /* margins at bp+0 */ TTtk_Padding *(*TTtk_Padding)(unsafe.Pointer(bp)) = XTtk_UniformPadding(tls, 0) /* Check -padding: */ if (*TFrame1)(unsafe.Pointer(framePtr)).Fframe.FpaddingObj != 0 { XTtk_GetPaddingFromObj(tls, libc.UintptrFromInt32(0), (*TFrame1)(unsafe.Pointer(framePtr)).Fcore.Ftkwin, (*TFrame1)(unsafe.Pointer(framePtr)).Fframe.FpaddingObj, bp) } /* Add padding for border: */ if (*TFrame1)(unsafe.Pointer(framePtr)).Fframe.FborderWidthObj != 0 { *(*int32)(unsafe.Pointer(bp + 8)) = 0 XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), (*TFrame1)(unsafe.Pointer(framePtr)).Fcore.Ftkwin, (*TFrame1)(unsafe.Pointer(framePtr)).Fframe.FborderWidthObj, bp+8) *(*TTtk_Padding)(unsafe.Pointer(bp)) = XTtk_AddPadding(tls, *(*TTtk_Padding)(unsafe.Pointer(bp)), XTtk_UniformPadding(tls, int16(*(*int32)(unsafe.Pointer(bp + 8))))) } return *(*TTtk_Padding)(unsafe.Pointer(bp)) } // C documentation // // /* FrameSize procedure -- // * The frame doesn't request a size of its own by default, // * but it does have an internal border. See also <> // */ func _FrameSize(tls *libc.TLS, recordPtr uintptr, dummy94 uintptr, dummy95 uintptr) (r int32) { /* heightPtr */ var framePtr uintptr _ = framePtr framePtr = recordPtr XTk_SetInternalBorderEx(tls, (*TFrame1)(unsafe.Pointer(framePtr)).Fcore.Ftkwin, int32(_FrameMargins(tls, framePtr).Fleft), int32(_FrameMargins(tls, framePtr).Fright), int32(_FrameMargins(tls, framePtr).Ftop), int32(_FrameMargins(tls, framePtr).Fbottom)) return 0 } /* * FrameConfigure -- configure hook. * <> Usually the size of a frame is controlled by * a geometry manager (pack, grid); the -width and -height * options are only effective if geometry propagation is turned * off or if the [place] GM is used for child widgets. * * To avoid geometry blinking, we issue a geometry request * in the Configure hook instead of the Size hook, and only * if -width and/or -height is nonzero and one of them * or the other size-related options (-borderwidth, -padding) * has been changed. */ func _FrameConfigure(tls *libc.TLS, interp uintptr, recordPtr uintptr, mask int32) (r int32) { bp := tls.Alloc(16) defer tls.Free(16) var framePtr uintptr var _ /* height at bp+4 */ int32 var _ /* unused at bp+8 */ TTtk_Padding var _ /* width at bp+0 */ int32 _ = framePtr framePtr = recordPtr /* * Make sure -padding resource, if present, is correct: */ if (*TFrame1)(unsafe.Pointer(framePtr)).Fframe.FpaddingObj != 0 { if XTtk_GetPaddingFromObj(tls, interp, (*TFrame1)(unsafe.Pointer(framePtr)).Fcore.Ftkwin, (*TFrame1)(unsafe.Pointer(framePtr)).Fframe.FpaddingObj, bp+8) != TCL_OK { return int32(TCL_ERROR) } } /* See <> */ if TCL_OK != XTk_GetPixelsFromObj(tls, interp, (*TFrame1)(unsafe.Pointer(framePtr)).Fcore.Ftkwin, (*TFrame1)(unsafe.Pointer(framePtr)).Fframe.FwidthObj, bp) || TCL_OK != XTk_GetPixelsFromObj(tls, interp, (*TFrame1)(unsafe.Pointer(framePtr)).Fcore.Ftkwin, (*TFrame1)(unsafe.Pointer(framePtr)).Fframe.FheightObj, bp+4) { return int32(TCL_ERROR) } if (*(*int32)(unsafe.Pointer(bp)) > 0 || *(*int32)(unsafe.Pointer(bp + 4)) > 0) && mask&int32(GEOMETRY_CHANGED) != 0 { XTk_GeometryRequest(tls, (*TFrame1)(unsafe.Pointer(framePtr)).Fcore.Ftkwin, *(*int32)(unsafe.Pointer(bp)), *(*int32)(unsafe.Pointer(bp + 4))) } return XTtkCoreConfigure(tls, interp, recordPtr, mask) } var _FrameWidgetSpec = TWidgetSpec{ FclassName: __ccgo_ts + 52000, FrecordSize: uint64(128), FoptionSpecs: uintptr(unsafe.Pointer(&_FrameOptionSpecs)), Fcommands: uintptr(unsafe.Pointer(&_FrameCommands)), } func init() { p := unsafe.Pointer(&_FrameWidgetSpec) *(*uintptr)(unsafe.Add(p, 32)) = __ccgo_fp(XTtkNullInitialize) *(*uintptr)(unsafe.Add(p, 40)) = __ccgo_fp(XTtkNullCleanup) *(*uintptr)(unsafe.Add(p, 48)) = __ccgo_fp(_FrameConfigure) *(*uintptr)(unsafe.Add(p, 56)) = __ccgo_fp(XTtkNullPostConfigure) *(*uintptr)(unsafe.Add(p, 64)) = __ccgo_fp(XTtkWidgetGetLayout) *(*uintptr)(unsafe.Add(p, 72)) = __ccgo_fp(_FrameSize) *(*uintptr)(unsafe.Add(p, 80)) = __ccgo_fp(XTtkWidgetDoLayout) *(*uintptr)(unsafe.Add(p, 88)) = __ccgo_fp(XTtkWidgetDisplay) } var _FrameLayout = [2]TTTKLayoutInstruction{ 0: { FelementName: __ccgo_ts + 52007, Fopcode: libc.Uint32FromInt32(libc.Int32FromInt32(TTK_FILL_BOTH)), }, 1: { Fopcode: libc.Uint32FromInt32(libc.Int32FromInt32(_TTK_LAYOUT_END)), }, } /* ====================================================================== * +++ Labelframe widget: */ func XTtkGetLabelAnchorFromObj(tls *libc.TLS, interp uintptr, objPtr uintptr, anchorPtr uintptr) (r int32) { bp := tls.Alloc(48) defer tls.Free(48) var c, v2 uint8 var flags TTtk_PositionSpec var string1, v1, v3 uintptr _, _, _, _, _, _ = c, flags, string1, v1, v2, v3 string1 = libtcl9_0.XTcl_GetStringFromObj(tls, objPtr, libc.UintptrFromInt32(0)) v1 = string1 string1++ c = *(*uint8)(unsafe.Pointer(v1)) flags = uint32(0) /* First character determines side: */ switch libc.Int32FromUint8(c) { case int32('w'): flags = libc.Uint32FromInt32(libc.Int32FromInt32(TTK_PACK_LEFT)) case int32('e'): flags = libc.Uint32FromInt32(libc.Int32FromInt32(TTK_PACK_RIGHT)) case int32('n'): flags = libc.Uint32FromInt32(libc.Int32FromInt32(TTK_PACK_TOP)) case int32('s'): flags = libc.Uint32FromInt32(libc.Int32FromInt32(TTK_PACK_BOTTOM)) default: goto error } /* Remaining characters are as per -sticky: */ for { v3 = string1 string1++ v2 = *(*uint8)(unsafe.Pointer(v3)) c = v2 if !(libc.Int32FromUint8(v2) != int32('\000')) { break } switch libc.Int32FromUint8(c) { case int32('w'): flags |= libc.Uint32FromInt32(libc.Int32FromInt32(TTK_STICK_W)) case int32('e'): flags |= libc.Uint32FromInt32(libc.Int32FromInt32(TTK_STICK_E)) case int32('n'): flags |= libc.Uint32FromInt32(libc.Int32FromInt32(TTK_STICK_N)) case int32('s'): flags |= libc.Uint32FromInt32(libc.Int32FromInt32(TTK_STICK_S)) default: goto error } } *(*TTtk_PositionSpec)(unsafe.Pointer(anchorPtr)) = flags return TCL_OK goto error error: ; if interp != 0 { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+52020, libc.VaList(bp+8, libtcl9_0.XTcl_GetStringFromObj(tls, objPtr, libc.UintptrFromInt32(0))))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+8, __ccgo_ts+51861, __ccgo_ts+52054, __ccgo_ts+11040, libc.UintptrFromInt32(0))) } return int32(TCL_ERROR) } // C documentation // // /* LabelAnchorSide -- // * Returns the side corresponding to a LabelAnchor value. // */ func _LabelAnchorSide(tls *libc.TLS, flags TTtk_PositionSpec) (r TTtk_Side) { if flags&libc.Uint32FromInt32(libc.Int32FromInt32(TTK_PACK_LEFT)) != 0 { return int32(TTK_SIDE_LEFT) } else { if flags&libc.Uint32FromInt32(libc.Int32FromInt32(TTK_PACK_RIGHT)) != 0 { return int32(TTK_SIDE_RIGHT) } else { if flags&libc.Uint32FromInt32(libc.Int32FromInt32(TTK_PACK_TOP)) != 0 { return int32(TTK_SIDE_TOP) } else { if flags&libc.Uint32FromInt32(libc.Int32FromInt32(TTK_PACK_BOTTOM)) != 0 { return int32(TTK_SIDE_BOTTOM) } } } } /*NOTREACHED*/ return int32(TTK_SIDE_TOP) } // C documentation // // /* // * Labelframe widget record: // */ type TLabelframePart = struct { FlabelAnchorObj uintptr FtextObj uintptr FunderlineObj uintptr FlabelWidget TTk_Window Fmgr uintptr FlabelLayout TTtk_Layout FlabelParcel TTtk_Box } type TLabelframe1 = struct { Fcore TWidgetCore Fframe TFramePart Flabel TLabelframePart } var _LabelframeOptionSpecs = [5]TTk_OptionSpec{ 0: { Ftype1: int32(TK_OPTION_STRING), FoptionName: __ccgo_ts + 23115, FdbName: __ccgo_ts + 23128, FdbClass: __ccgo_ts + 23140, FdefValue: __ccgo_ts + 10956, FobjOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 128)), FinternalOffset: int64(-libc.Int32FromInt32(1)), FtypeMask: int32(GEOMETRY_CHANGED), }, 1: { Ftype1: int32(TK_OPTION_STRING), FoptionName: __ccgo_ts + 20398, FdbName: __ccgo_ts + 17996, FdbClass: __ccgo_ts + 20404, FdefValue: __ccgo_ts + 195, FobjOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 128 + 8)), FinternalOffset: int64(-libc.Int32FromInt32(1)), FtypeMask: int32(GEOMETRY_CHANGED), }, 2: { Ftype1: int32(TK_OPTION_INDEX), FoptionName: __ccgo_ts + 9507, FdbName: __ccgo_ts + 9388, FdbClass: __ccgo_ts + 20445, FobjOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 128 + 16)), FinternalOffset: int64(-libc.Int32FromInt32(1)), Fflags: int32(TCL_NULL_OK), }, 3: { Ftype1: int32(TK_OPTION_WINDOW), FoptionName: __ccgo_ts + 23152, FdbName: __ccgo_ts + 23165, FdbClass: __ccgo_ts + 23177, FobjOffset: int64(-libc.Int32FromInt32(1)), FinternalOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 128 + 24)), Fflags: int32(TCL_NULL_OK), FtypeMask: libc.Int32FromInt32(LABELWIDGET_CHANGED) | libc.Int32FromInt32(GEOMETRY_CHANGED), }, 4: { Ftype1: int32(TK_OPTION_END), FobjOffset: int64(-libc.Int32FromInt32(1)), FinternalOffset: int64(-libc.Int32FromInt32(1)), FclientData: uintptr(unsafe.Pointer(&_FrameOptionSpecs)), }, } // C documentation // // /* // * Labelframe style parameters: // */ type TLabelframeStyle = struct { FborderWidth int32 Fpadding TTtk_Padding FlabelAnchor TTtk_PositionSpec FlabelMargins TTtk_Padding FlabelOutside int32 } func _LabelframeStyleOptions(tls *libc.TLS, lf uintptr, style uintptr) { var layout TTtk_Layout var objPtr, v1, v2, v3, v4, v5 uintptr _, _, _, _, _, _, _ = layout, objPtr, v1, v2, v3, v4, v5 layout = (*TLabelframe1)(unsafe.Pointer(lf)).Fcore.Flayout (*TLabelframeStyle)(unsafe.Pointer(style)).FborderWidth = int32(DEFAULT_BORDERWIDTH1) (*TLabelframeStyle)(unsafe.Pointer(style)).Fpadding = XTtk_UniformPadding(tls, 0) (*TLabelframeStyle)(unsafe.Pointer(style)).FlabelAnchor = libc.Uint32FromInt32(libc.Int32FromInt32(TTK_PACK_TOP) | libc.Int32FromInt32(TTK_STICK_W)) (*TLabelframeStyle)(unsafe.Pointer(style)).FlabelOutside = 0 v1 = XTtk_QueryOption(tls, layout, __ccgo_ts+2814, uint32(0)) objPtr = v1 if v1 != libc.UintptrFromInt32(0) { XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), (*TLabelframe1)(unsafe.Pointer(lf)).Fcore.Ftkwin, objPtr, style) } v2 = XTtk_QueryOption(tls, layout, __ccgo_ts+49128, uint32(0)) objPtr = v2 if v2 != libc.UintptrFromInt32(0) { XTtk_GetPaddingFromObj(tls, libc.UintptrFromInt32(0), (*TLabelframe1)(unsafe.Pointer(lf)).Fcore.Ftkwin, objPtr, style+4) } v3 = XTtk_QueryOption(tls, layout, __ccgo_ts+23115, uint32(0)) objPtr = v3 if v3 != libc.UintptrFromInt32(0) { XTtkGetLabelAnchorFromObj(tls, libc.UintptrFromInt32(0), objPtr, style+12) } v4 = XTtk_QueryOption(tls, layout, __ccgo_ts+52060, uint32(0)) objPtr = v4 if v4 != libc.UintptrFromInt32(0) { XTtk_GetPaddingFromObj(tls, libc.UintptrFromInt32(0), (*TLabelframe1)(unsafe.Pointer(lf)).Fcore.Ftkwin, objPtr, style+16) } else { if (*TLabelframeStyle)(unsafe.Pointer(style)).FlabelAnchor&libc.Uint32FromInt32(libc.Int32FromInt32(TTK_PACK_TOP)|libc.Int32FromInt32(TTK_PACK_BOTTOM)) != 0 { (*TLabelframeStyle)(unsafe.Pointer(style)).FlabelMargins = XTtk_MakePadding(tls, int16(DEFAULT_LABELINSET), 0, int16(DEFAULT_LABELINSET), 0) } else { (*TLabelframeStyle)(unsafe.Pointer(style)).FlabelMargins = XTtk_MakePadding(tls, 0, int16(DEFAULT_LABELINSET), 0, int16(DEFAULT_LABELINSET)) } } v5 = XTtk_QueryOption(tls, layout, __ccgo_ts+52074, uint32(0)) objPtr = v5 if v5 != libc.UintptrFromInt32(0) { _ = libtcl9_0.XTcl_GetBoolFromObj(tls, libc.UintptrFromInt32(0), objPtr, (libc.Int32FromInt32(TCL_NULL_OK)-libc.Int32FromInt32(2))&libc.Int32FromInt64(4), style+24) } return } // C documentation // // /* LabelframeLabelSize -- // * Extract the requested width and height of the labelframe's label: // * taken from the label widget if specified, otherwise the text label. // */ func _LabelframeLabelSize(tls *libc.TLS, lframePtr uintptr, widthPtr uintptr, heightPtr uintptr) { var labelLayout TTtk_Layout var labelWidget TTk_Window var v1 int32 _, _, _ = labelLayout, labelWidget, v1 labelWidget = (*TLabelframe1)(unsafe.Pointer(lframePtr)).Flabel.FlabelWidget labelLayout = (*TLabelframe1)(unsafe.Pointer(lframePtr)).Flabel.FlabelLayout if labelWidget != 0 { *(*int32)(unsafe.Pointer(widthPtr)) = (*TTk_FakeWin)(unsafe.Pointer(labelWidget)).FreqWidth *(*int32)(unsafe.Pointer(heightPtr)) = (*TTk_FakeWin)(unsafe.Pointer(labelWidget)).FreqHeight } else { if labelLayout != 0 { XTtk_LayoutSize(tls, labelLayout, uint32(0), widthPtr, heightPtr) } else { v1 = libc.Int32FromInt32(0) *(*int32)(unsafe.Pointer(heightPtr)) = v1 *(*int32)(unsafe.Pointer(widthPtr)) = v1 } } } // C documentation // // /* // * LabelframeSize -- // * Like the frame, this doesn't request a size of its own // * but it does have internal padding and a minimum size. // */ func _LabelframeSize(tls *libc.TLS, recordPtr uintptr, dummy346 uintptr, dummy347 uintptr) (r int32) { bp := tls.Alloc(48) defer tls.Free(48) /* heightPtr */ var corePtr, lframePtr, p1, p2, p3, p4 uintptr var _ /* labelHeight at bp+40 */ int32 var _ /* labelWidth at bp+36 */ int32 var _ /* margins at bp+0 */ TTtk_Padding var _ /* style at bp+8 */ TLabelframeStyle _, _, _, _, _, _ = corePtr, lframePtr, p1, p2, p3, p4 lframePtr = recordPtr corePtr = lframePtr _LabelframeStyleOptions(tls, lframePtr, bp+8) /* Compute base margins (See also: FrameMargins) */ *(*TTtk_Padding)(unsafe.Pointer(bp)) = XTtk_AddPadding(tls, (*(*TLabelframeStyle)(unsafe.Pointer(bp + 8))).Fpadding, XTtk_UniformPadding(tls, int16((*(*TLabelframeStyle)(unsafe.Pointer(bp + 8))).FborderWidth))) /* Adjust margins based on label size and position: */ _LabelframeLabelSize(tls, lframePtr, bp+36, bp+40) *(*int32)(unsafe.Pointer(bp + 36)) += int32((*(*TLabelframeStyle)(unsafe.Pointer(bp + 8))).FlabelMargins.Fleft) + int32((*(*TLabelframeStyle)(unsafe.Pointer(bp + 8))).FlabelMargins.Fright) *(*int32)(unsafe.Pointer(bp + 40)) += int32((*(*TLabelframeStyle)(unsafe.Pointer(bp + 8))).FlabelMargins.Ftop) + int32((*(*TLabelframeStyle)(unsafe.Pointer(bp + 8))).FlabelMargins.Fbottom) switch _LabelAnchorSide(tls, (*(*TLabelframeStyle)(unsafe.Pointer(bp + 8))).FlabelAnchor) { case int32(TTK_SIDE_LEFT): p1 = bp *(*int16)(unsafe.Pointer(p1)) = int16(int32(*(*int16)(unsafe.Pointer(p1))) + *(*int32)(unsafe.Pointer(bp + 36))) case int32(TTK_SIDE_RIGHT): p2 = bp + 4 *(*int16)(unsafe.Pointer(p2)) = int16(int32(*(*int16)(unsafe.Pointer(p2))) + *(*int32)(unsafe.Pointer(bp + 36))) case int32(TTK_SIDE_TOP): p3 = bp + 2 *(*int16)(unsafe.Pointer(p3)) = int16(int32(*(*int16)(unsafe.Pointer(p3))) + *(*int32)(unsafe.Pointer(bp + 40))) case int32(TTK_SIDE_BOTTOM): p4 = bp + 6 *(*int16)(unsafe.Pointer(p4)) = int16(int32(*(*int16)(unsafe.Pointer(p4))) + *(*int32)(unsafe.Pointer(bp + 40))) break } XTk_SetInternalBorderEx(tls, (*TWidgetCore)(unsafe.Pointer(corePtr)).Ftkwin, int32((*(*TTtk_Padding)(unsafe.Pointer(bp))).Fleft), int32((*(*TTtk_Padding)(unsafe.Pointer(bp))).Fright), int32((*(*TTtk_Padding)(unsafe.Pointer(bp))).Ftop), int32((*(*TTtk_Padding)(unsafe.Pointer(bp))).Fbottom)) /* Request minimum size based on border width and label size: */ XTk_SetMinimumRequestSize(tls, (*TWidgetCore)(unsafe.Pointer(corePtr)).Ftkwin, *(*int32)(unsafe.Pointer(bp + 36))+int32(2)*(*(*TLabelframeStyle)(unsafe.Pointer(bp + 8))).FborderWidth, *(*int32)(unsafe.Pointer(bp + 40))+int32(2)*(*(*TLabelframeStyle)(unsafe.Pointer(bp + 8))).FborderWidth) return 0 } /* * LabelframeGetLayout -- * Getlayout widget hook. */ func _LabelframeGetLayout(tls *libc.TLS, interp uintptr, theme TTtk_Theme, recordPtr uintptr) (r TTtk_Layout) { var frameLayout, labelLayout TTtk_Layout var lf uintptr _, _, _ = frameLayout, labelLayout, lf lf = recordPtr frameLayout = XTtkWidgetGetLayout(tls, interp, theme, recordPtr) if !(frameLayout != 0) { return libc.UintptrFromInt32(0) } labelLayout = XTtk_CreateSublayout(tls, interp, theme, frameLayout, __ccgo_ts+52088, (*TLabelframe1)(unsafe.Pointer(lf)).Fcore.FoptionTable) if labelLayout != 0 { if (*TLabelframe1)(unsafe.Pointer(lf)).Flabel.FlabelLayout != 0 { XTtk_FreeLayout(tls, (*TLabelframe1)(unsafe.Pointer(lf)).Flabel.FlabelLayout) } XTtk_RebindSublayout(tls, labelLayout, recordPtr) (*TLabelframe1)(unsafe.Pointer(lf)).Flabel.FlabelLayout = labelLayout } return frameLayout } /* * LabelframeDoLayout -- * Labelframe layout hook. * * Side effects: Computes labelParcel. */ func _LabelframeDoLayout(tls *libc.TLS, recordPtr uintptr) { bp := tls.Alloc(64) defer tls.Free(64) var corePtr, lframePtr uintptr var labelParcel TTtk_Box var _ /* borderParcel at bp+36 */ TTtk_Box var _ /* lh at bp+4 */ int32 var _ /* lw at bp+0 */ int32 var _ /* style at bp+8 */ TLabelframeStyle _, _, _ = corePtr, labelParcel, lframePtr lframePtr = recordPtr corePtr = lframePtr *(*TTtk_Box)(unsafe.Pointer(bp + 36)) = XTtk_MakeBox(tls, 0, 0, (*TTk_FakeWin)(unsafe.Pointer((*TLabelframe1)(unsafe.Pointer(lframePtr)).Fcore.Ftkwin)).Fchanges.Fwidth, (*TTk_FakeWin)(unsafe.Pointer((*TLabelframe1)(unsafe.Pointer(lframePtr)).Fcore.Ftkwin)).Fchanges.Fheight) /* * Compute label parcel: */ _LabelframeStyleOptions(tls, lframePtr, bp+8) _LabelframeLabelSize(tls, lframePtr, bp, bp+4) *(*int32)(unsafe.Pointer(bp)) += int32((*(*TLabelframeStyle)(unsafe.Pointer(bp + 8))).FlabelMargins.Fleft) + int32((*(*TLabelframeStyle)(unsafe.Pointer(bp + 8))).FlabelMargins.Fright) *(*int32)(unsafe.Pointer(bp + 4)) += int32((*(*TLabelframeStyle)(unsafe.Pointer(bp + 8))).FlabelMargins.Ftop) + int32((*(*TLabelframeStyle)(unsafe.Pointer(bp + 8))).FlabelMargins.Fbottom) labelParcel = XTtk_PadBox(tls, XTtk_PositionBox(tls, bp+36, *(*int32)(unsafe.Pointer(bp)), *(*int32)(unsafe.Pointer(bp + 4)), (*(*TLabelframeStyle)(unsafe.Pointer(bp + 8))).FlabelAnchor), (*(*TLabelframeStyle)(unsafe.Pointer(bp + 8))).FlabelMargins) if !((*(*TLabelframeStyle)(unsafe.Pointer(bp + 8))).FlabelOutside != 0) { /* Move border edge so it's over label: */ switch _LabelAnchorSide(tls, (*(*TLabelframeStyle)(unsafe.Pointer(bp + 8))).FlabelAnchor) { case int32(TTK_SIDE_LEFT): (*(*TTtk_Box)(unsafe.Pointer(bp + 36))).Fx -= *(*int32)(unsafe.Pointer(bp)) / int32(2) /* FALLTHRU */ fallthrough case int32(TTK_SIDE_RIGHT): (*(*TTtk_Box)(unsafe.Pointer(bp + 36))).Fwidth += *(*int32)(unsafe.Pointer(bp)) / int32(2) case int32(TTK_SIDE_TOP): (*(*TTtk_Box)(unsafe.Pointer(bp + 36))).Fy -= *(*int32)(unsafe.Pointer(bp + 4)) / int32(2) /* FALLTHRU */ fallthrough case int32(TTK_SIDE_BOTTOM): (*(*TTtk_Box)(unsafe.Pointer(bp + 36))).Fheight += *(*int32)(unsafe.Pointer(bp + 4)) / int32(2) break } } /* * Place border and label: */ XTtk_PlaceLayout(tls, (*TWidgetCore)(unsafe.Pointer(corePtr)).Flayout, (*TWidgetCore)(unsafe.Pointer(corePtr)).Fstate, *(*TTtk_Box)(unsafe.Pointer(bp + 36))) if (*TLabelframe1)(unsafe.Pointer(lframePtr)).Flabel.FlabelLayout != 0 { XTtk_PlaceLayout(tls, (*TLabelframe1)(unsafe.Pointer(lframePtr)).Flabel.FlabelLayout, (*TWidgetCore)(unsafe.Pointer(corePtr)).Fstate, labelParcel) } /* labelWidget placed in LabelframePlaceContent GM hook */ (*TLabelframe1)(unsafe.Pointer(lframePtr)).Flabel.FlabelParcel = labelParcel } func _LabelframeDisplay(tls *libc.TLS, recordPtr uintptr, d TDrawable) { var lframePtr uintptr _ = lframePtr lframePtr = recordPtr XTtk_DrawLayout(tls, (*TLabelframe1)(unsafe.Pointer(lframePtr)).Fcore.Flayout, (*TLabelframe1)(unsafe.Pointer(lframePtr)).Fcore.Fstate, d) if (*TLabelframe1)(unsafe.Pointer(lframePtr)).Flabel.FlabelLayout != 0 { XTtk_DrawLayout(tls, (*TLabelframe1)(unsafe.Pointer(lframePtr)).Flabel.FlabelLayout, (*TLabelframe1)(unsafe.Pointer(lframePtr)).Fcore.Fstate, d) } } /* +++ Labelframe geometry manager hooks. */ // C documentation // // /* LabelframePlaceContent -- // * Sets the position and size of the labelwidget. // */ func _LabelframePlaceContent(tls *libc.TLS, recordPtr uintptr) { var b TTtk_Box var lframe uintptr _, _ = b, lframe lframe = recordPtr if XTtk_NumberContent(tls, (*TLabelframe1)(unsafe.Pointer(lframe)).Flabel.Fmgr) == int64(1) { _LabelframeDoLayout(tls, recordPtr) b = (*TLabelframe1)(unsafe.Pointer(lframe)).Flabel.FlabelParcel /* ASSERT: content #0 is lframe->label.labelWidget */ XTtk_PlaceContent(tls, (*TLabelframe1)(unsafe.Pointer(lframe)).Flabel.Fmgr, 0, b.Fx, b.Fy, b.Fwidth, b.Fheight) } } func _LabelRequest(tls *libc.TLS, dummy498 uintptr, dummy499 TTcl_Size, dummy500 int32, dummy501 int32) (r int32) { /* height */ return int32(1) } // C documentation // // /* LabelRemoved -- // * Unset the -labelwidget option. // * // * <>: // * This routine is also called when the widget voluntarily forgets // * the window in LabelframeConfigure. // */ func _LabelRemoved(tls *libc.TLS, managerData uintptr, dummy515 TTcl_Size) { /* index */ var lframe uintptr _ = lframe lframe = managerData (*TLabelframe1)(unsafe.Pointer(lframe)).Flabel.FlabelWidget = uintptr(0) } var _LabelframeManagerSpec = TTtk_ManagerSpec{ FtkGeomMgr: TTk_GeomMgr{ Fname: __ccgo_ts + 17905, }, } func init() { p := unsafe.Pointer(&_LabelframeManagerSpec) *(*uintptr)(unsafe.Add(p, 8)) = __ccgo_fp(XTtk_GeometryRequestProc) *(*uintptr)(unsafe.Add(p, 16)) = __ccgo_fp(XTtk_LostContentProc) *(*uintptr)(unsafe.Add(p, 24)) = __ccgo_fp(_LabelframeSize) *(*uintptr)(unsafe.Add(p, 32)) = __ccgo_fp(_LabelframePlaceContent) *(*uintptr)(unsafe.Add(p, 40)) = __ccgo_fp(_LabelRequest) *(*uintptr)(unsafe.Add(p, 48)) = __ccgo_fp(_LabelRemoved) } // C documentation // // /* LabelframeInitialize -- // * Initialization hook. // */ func _LabelframeInitialize(tls *libc.TLS, dummy534 uintptr, recordPtr uintptr) { var lframe uintptr _ = lframe lframe = recordPtr (*TLabelframe1)(unsafe.Pointer(lframe)).Flabel.Fmgr = XTtk_CreateManager(tls, uintptr(unsafe.Pointer(&_LabelframeManagerSpec)), lframe, (*TLabelframe1)(unsafe.Pointer(lframe)).Fcore.Ftkwin) (*TLabelframe1)(unsafe.Pointer(lframe)).Flabel.FlabelWidget = uintptr(0) (*TLabelframe1)(unsafe.Pointer(lframe)).Flabel.FlabelLayout = uintptr(0) (*TLabelframe1)(unsafe.Pointer(lframe)).Flabel.FlabelParcel = XTtk_MakeBox(tls, -int32(1), -int32(1), -int32(1), -int32(1)) } // C documentation // // /* LabelframeCleanup -- // * Cleanup hook. // */ func _LabelframeCleanup(tls *libc.TLS, recordPtr uintptr) { var lframe uintptr _ = lframe lframe = recordPtr XTtk_DeleteManager(tls, (*TLabelframe1)(unsafe.Pointer(lframe)).Flabel.Fmgr) if (*TLabelframe1)(unsafe.Pointer(lframe)).Flabel.FlabelLayout != 0 { XTtk_FreeLayout(tls, (*TLabelframe1)(unsafe.Pointer(lframe)).Flabel.FlabelLayout) } } // C documentation // // /* RaiseLabelWidget -- // * Raise the -labelwidget to ensure that the labelframe doesn't // * obscure it (if it's not a direct child), or bring it to // * the top of the stacking order (if it is). // */ func _RaiseLabelWidget(tls *libc.TLS, lframe uintptr) { var parent, sibling, w TTk_Window _, _, _ = parent, sibling, w parent = (*TTk_FakeWin)(unsafe.Pointer((*TLabelframe1)(unsafe.Pointer(lframe)).Flabel.FlabelWidget)).FparentPtr sibling = libc.UintptrFromInt32(0) w = (*TLabelframe1)(unsafe.Pointer(lframe)).Fcore.Ftkwin for w != 0 && w != parent { sibling = w w = (*TTk_FakeWin)(unsafe.Pointer(w)).FparentPtr } XTk_RestackWindow(tls, (*TLabelframe1)(unsafe.Pointer(lframe)).Flabel.FlabelWidget, Above, sibling) } // C documentation // // /* LabelframeConfigure -- // * Configuration hook. // */ func _LabelframeConfigure(tls *libc.TLS, interp uintptr, recordPtr uintptr, mask int32) (r int32) { bp := tls.Alloc(16) defer tls.Free(16) var labelWidget TTk_Window var lframePtr uintptr var _ /* unused at bp+0 */ TTtk_PositionSpec _, _ = labelWidget, lframePtr lframePtr = recordPtr labelWidget = (*TLabelframe1)(unsafe.Pointer(lframePtr)).Flabel.FlabelWidget /* Validate options: */ if mask&int32(LABELWIDGET_CHANGED) != 0 && labelWidget != libc.UintptrFromInt32(0) { if !(XTtk_Maintainable(tls, interp, labelWidget, (*TLabelframe1)(unsafe.Pointer(lframePtr)).Fcore.Ftkwin) != 0) { return int32(TCL_ERROR) } } if XTtkGetLabelAnchorFromObj(tls, interp, (*TLabelframe1)(unsafe.Pointer(lframePtr)).Flabel.FlabelAnchorObj, bp) != TCL_OK { return int32(TCL_ERROR) } /* Base class configuration: */ if _FrameConfigure(tls, interp, recordPtr, mask) != TCL_OK { return int32(TCL_ERROR) } /* Update -labelwidget changes, if any: */ if mask&int32(LABELWIDGET_CHANGED) != 0 { if XTtk_NumberContent(tls, (*TLabelframe1)(unsafe.Pointer(lframePtr)).Flabel.Fmgr) == int64(1) { XTtk_ForgetContent(tls, (*TLabelframe1)(unsafe.Pointer(lframePtr)).Flabel.Fmgr, 0) /* Restore labelWidget field (see <>) */ (*TLabelframe1)(unsafe.Pointer(lframePtr)).Flabel.FlabelWidget = labelWidget } if labelWidget != 0 { XTtk_InsertContent(tls, (*TLabelframe1)(unsafe.Pointer(lframePtr)).Flabel.Fmgr, 0, labelWidget, libc.UintptrFromInt32(0)) _RaiseLabelWidget(tls, lframePtr) } } if mask&int32(GEOMETRY_CHANGED) != 0 { XTtk_ManagerSizeChanged(tls, (*TLabelframe1)(unsafe.Pointer(lframePtr)).Flabel.Fmgr) XTtk_ManagerLayoutChanged(tls, (*TLabelframe1)(unsafe.Pointer(lframePtr)).Flabel.Fmgr) } return TCL_OK } var _LabelframeWidgetSpec = TWidgetSpec{ FclassName: __ccgo_ts + 52095, FrecordSize: uint64(192), FoptionSpecs: uintptr(unsafe.Pointer(&_LabelframeOptionSpecs)), Fcommands: uintptr(unsafe.Pointer(&_FrameCommands)), } func init() { p := unsafe.Pointer(&_LabelframeWidgetSpec) *(*uintptr)(unsafe.Add(p, 32)) = __ccgo_fp(_LabelframeInitialize) *(*uintptr)(unsafe.Add(p, 40)) = __ccgo_fp(_LabelframeCleanup) *(*uintptr)(unsafe.Add(p, 48)) = __ccgo_fp(_LabelframeConfigure) *(*uintptr)(unsafe.Add(p, 56)) = __ccgo_fp(XTtkNullPostConfigure) *(*uintptr)(unsafe.Add(p, 64)) = __ccgo_fp(_LabelframeGetLayout) *(*uintptr)(unsafe.Add(p, 72)) = __ccgo_fp(_LabelframeSize) *(*uintptr)(unsafe.Add(p, 80)) = __ccgo_fp(_LabelframeDoLayout) *(*uintptr)(unsafe.Add(p, 88)) = __ccgo_fp(_LabelframeDisplay) } var _LabelframeLayout = [2]TTTKLayoutInstruction{ 0: { FelementName: __ccgo_ts + 52107, Fopcode: libc.Uint32FromInt32(libc.Int32FromInt32(TTK_FILL_BOTH)), }, 1: { Fopcode: libc.Uint32FromInt32(libc.Int32FromInt32(_TTK_LAYOUT_END)), }, } var _LabelSublayout = [4]TTTKLayoutInstruction{ 0: { FelementName: __ccgo_ts + 52125, Fopcode: libc.Uint32FromInt32(libc.Int32FromInt32(TTK_FILL_BOTH) | libc.Int32FromInt32(_TTK_CHILDREN)), }, 1: { FelementName: __ccgo_ts + 52136, Fopcode: libc.Uint32FromInt32(libc.Int32FromInt32(TTK_FILL_BOTH)), }, 2: { Fopcode: libc.Uint32FromInt32(libc.Int32FromInt32(_TTK_LAYOUT_END)), }, 3: { Fopcode: libc.Uint32FromInt32(libc.Int32FromInt32(_TTK_LAYOUT_END)), }, } /* ====================================================================== * +++ Initialization. */ func XTtkFrame_Init(tls *libc.TLS, interp uintptr) { var theme TTtk_Theme _ = theme theme = XTtk_GetDefaultTheme(tls, interp) XTtk_RegisterLayout(tls, theme, __ccgo_ts+52000, uintptr(unsafe.Pointer(&_FrameLayout))) XTtk_RegisterLayout(tls, theme, __ccgo_ts+52095, uintptr(unsafe.Pointer(&_LabelframeLayout))) XTtk_RegisterLayout(tls, theme, __ccgo_ts+19745, uintptr(unsafe.Pointer(&_LabelSublayout))) libtcl9_0.XTcl_CreateObjCommand2(tls, interp, __ccgo_ts+52147, __ccgo_fp(XTtkWidgetConstructorObjCmd), uintptr(unsafe.Pointer(&_FrameWidgetSpec)), libc.UintptrFromInt32(0)) libtcl9_0.XTcl_CreateObjCommand2(tls, interp, __ccgo_ts+52158, __ccgo_fp(XTtkWidgetConstructorObjCmd), uintptr(unsafe.Pointer(&_LabelframeWidgetSpec)), libc.UintptrFromInt32(0)) } type TTtk_ImageSpec = struct { FbaseImage TTk_Image FmapCount int32 Fstates uintptr Fimages uintptr FimageChanged uintptr FimageChangedClientData uintptr } type TTtkImageSpec = TTtk_ImageSpec // C documentation // // /* NullImageChanged -- // * Do-nothing Tk_ImageChangedProc. // */ func _NullImageChanged1(tls *libc.TLS, dummy35 uintptr, dummy36 int32, dummy37 int32, dummy38 int32, dummy39 int32, dummy40 int32, dummy41 int32) { /* No-op */ } // C documentation // // /* ImageSpecImageChanged -- // * Image changes should trigger a repaint. // */ func _ImageSpecImageChanged(tls *libc.TLS, clientData uintptr, x int32, y int32, width int32, height int32, imageWidth int32, imageHeight int32) { var imageSpec uintptr _ = imageSpec imageSpec = clientData if (*TTtk_ImageSpec)(unsafe.Pointer(imageSpec)).FimageChanged != libc.UintptrFromInt32(0) { (*(*func(*libc.TLS, uintptr, int32, int32, int32, int32, int32, int32))(unsafe.Pointer(&struct{ uintptr }{(*TTtk_ImageSpec)(unsafe.Pointer(imageSpec)).FimageChanged})))(tls, (*TTtk_ImageSpec)(unsafe.Pointer(imageSpec)).FimageChangedClientData, x, y, width, height, imageWidth, imageHeight) } } // C documentation // // /* TtkGetImageSpec -- // * Constructs a Ttk_ImageSpec * from a Tcl_Obj *. // * Result must be released using TtkFreeImageSpec. // * // */ func XTtkGetImageSpec(tls *libc.TLS, interp uintptr, tkwin TTk_Window, objPtr uintptr) (r uintptr) { return XTtkGetImageSpecEx(tls, interp, tkwin, objPtr, libc.UintptrFromInt32(0), libc.UintptrFromInt32(0)) } // C documentation // // /* TtkGetImageSpecEx -- // * Constructs a Ttk_ImageSpec * from a Tcl_Obj *. // * Result must be released using TtkFreeImageSpec. // * imageChangedProc will be called when not NULL when // * the image changes to allow widgets to repaint. // */ func XTtkGetImageSpecEx(tls *libc.TLS, interp uintptr, tkwin TTk_Window, objPtr uintptr, imageChangedProc uintptr, imageChangedClientData uintptr) (r uintptr) { bp := tls.Alloc(64) defer tls.Free(64) var i, n int32 var imageName, imageSpec, stateSpec uintptr var _ /* objc at bp+0 */ TTcl_Size var _ /* objv at bp+8 */ uintptr var _ /* state at bp+16 */ TTtk_StateSpec _, _, _, _, _ = i, imageName, imageSpec, n, stateSpec imageSpec = uintptr(0) i = 0 n = 0 imageSpec = libtcl9_0.XTcl_Alloc(tls, uint64(48)) (*TTtk_ImageSpec)(unsafe.Pointer(imageSpec)).FbaseImage = uintptr(0) (*TTtk_ImageSpec)(unsafe.Pointer(imageSpec)).FmapCount = 0 (*TTtk_ImageSpec)(unsafe.Pointer(imageSpec)).Fstates = uintptr(0) (*TTtk_ImageSpec)(unsafe.Pointer(imageSpec)).Fimages = uintptr(0) (*TTtk_ImageSpec)(unsafe.Pointer(imageSpec)).FimageChanged = imageChangedProc (*TTtk_ImageSpec)(unsafe.Pointer(imageSpec)).FimageChangedClientData = imageChangedClientData if libtcl9_0.XTcl_ListObjGetElements(tls, interp, objPtr, bp, bp+8) != TCL_OK { goto error } if *(*TTcl_Size)(unsafe.Pointer(bp))%int64(2) != int64(1) { if interp != 0 { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+52174, int64(-int32(1)))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+32, __ccgo_ts+51861, __ccgo_ts+29667, __ccgo_ts+52233, libc.UintptrFromInt32(0))) } goto error } n = int32((*(*TTcl_Size)(unsafe.Pointer(bp)) - int64(1)) / int64(2)) (*TTtk_ImageSpec)(unsafe.Pointer(imageSpec)).Fstates = libtcl9_0.XTcl_Alloc(tls, libc.Uint64FromInt32(n)*uint64(8)) (*TTtk_ImageSpec)(unsafe.Pointer(imageSpec)).Fimages = libtcl9_0.XTcl_Alloc(tls, libc.Uint64FromInt32(n)*uint64(8)) /* Get base image: */ (*TTtk_ImageSpec)(unsafe.Pointer(imageSpec)).FbaseImage = XTk_GetImage(tls, interp, tkwin, libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 8)))), libc.UintptrFromInt32(0)), __ccgo_fp(_ImageSpecImageChanged), imageSpec) if !((*TTtk_ImageSpec)(unsafe.Pointer(imageSpec)).FbaseImage != 0) { goto error } /* Extract state and image specifications: */ i = 0 for { if !(i < n) { break } stateSpec = *(*uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 8)) + uintptr(int32(2)*i+int32(1))*8)) imageName = libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 8)) + uintptr(int32(2)*i+int32(2))*8)), libc.UintptrFromInt32(0)) if XTtk_GetStateSpecFromObj(tls, interp, stateSpec, bp+16) != TCL_OK { goto error } *(*TTtk_StateSpec)(unsafe.Pointer((*TTtk_ImageSpec)(unsafe.Pointer(imageSpec)).Fstates + uintptr(i)*8)) = *(*TTtk_StateSpec)(unsafe.Pointer(bp + 16)) *(*TTk_Image)(unsafe.Pointer((*TTtk_ImageSpec)(unsafe.Pointer(imageSpec)).Fimages + uintptr(i)*8)) = XTk_GetImage(tls, interp, tkwin, imageName, __ccgo_fp(_NullImageChanged1), libc.UintptrFromInt32(0)) if *(*TTk_Image)(unsafe.Pointer((*TTtk_ImageSpec)(unsafe.Pointer(imageSpec)).Fimages + uintptr(i)*8)) == libc.UintptrFromInt32(0) { goto error } (*TTtk_ImageSpec)(unsafe.Pointer(imageSpec)).FmapCount = i + int32(1) goto _1 _1: ; i++ } return imageSpec goto error error: ; XTtkFreeImageSpec(tls, imageSpec) return libc.UintptrFromInt32(0) } // C documentation // // /* TtkFreeImageSpec -- // * Dispose of an image specification. // */ func XTtkFreeImageSpec(tls *libc.TLS, imageSpec uintptr) { var i int32 _ = i i = 0 for { if !(i < (*TTtk_ImageSpec)(unsafe.Pointer(imageSpec)).FmapCount) { break } XTk_FreeImage(tls, *(*TTk_Image)(unsafe.Pointer((*TTtk_ImageSpec)(unsafe.Pointer(imageSpec)).Fimages + uintptr(i)*8))) goto _1 _1: ; i++ } if (*TTtk_ImageSpec)(unsafe.Pointer(imageSpec)).FbaseImage != 0 { XTk_FreeImage(tls, (*TTtk_ImageSpec)(unsafe.Pointer(imageSpec)).FbaseImage) } if (*TTtk_ImageSpec)(unsafe.Pointer(imageSpec)).Fstates != 0 { libtcl9_0.XTcl_Free(tls, (*TTtk_ImageSpec)(unsafe.Pointer(imageSpec)).Fstates) } if (*TTtk_ImageSpec)(unsafe.Pointer(imageSpec)).Fimages != 0 { libtcl9_0.XTcl_Free(tls, (*TTtk_ImageSpec)(unsafe.Pointer(imageSpec)).Fimages) } libtcl9_0.XTcl_Free(tls, imageSpec) } // C documentation // // /* TtkSelectImage -- // * Return a state-specific image from an ImageSpec // */ func XTtkSelectImage(tls *libc.TLS, imageSpec uintptr, dummy170 TTk_Window, state TTtk_State) (r TTk_Image) { var i int32 _ = i i = 0 for { if !(i < (*TTtk_ImageSpec)(unsafe.Pointer(imageSpec)).FmapCount) { break } if state&((*TTtk_StateSpec)(unsafe.Pointer((*TTtk_ImageSpec)(unsafe.Pointer(imageSpec)).Fstates+uintptr(i)*8)).Fonbits|(*TTtk_StateSpec)(unsafe.Pointer((*TTtk_ImageSpec)(unsafe.Pointer(imageSpec)).Fstates+uintptr(i)*8)).Foffbits) == (*TTtk_StateSpec)(unsafe.Pointer((*TTtk_ImageSpec)(unsafe.Pointer(imageSpec)).Fstates+uintptr(i)*8)).Fonbits { return *(*TTk_Image)(unsafe.Pointer((*TTtk_ImageSpec)(unsafe.Pointer(imageSpec)).Fimages + uintptr(i)*8)) } goto _1 _1: ; i++ } return (*TTtk_ImageSpec)(unsafe.Pointer(imageSpec)).FbaseImage } /*------------------------------------------------------------------------ * +++ Drawing utilities. */ // C documentation // // /* LPadding, CPadding, RPadding -- // * Split a box+padding pair into left, center, and right boxes. // */ func _LPadding(tls *libc.TLS, b TTtk_Box, p TTtk_Padding) (r TTtk_Box) { return XTtk_MakeBox(tls, b.Fx, b.Fy, int32(p.Fleft), b.Fheight) } func _CPadding(tls *libc.TLS, b TTtk_Box, p TTtk_Padding) (r TTtk_Box) { return XTtk_MakeBox(tls, b.Fx+int32(p.Fleft), b.Fy, b.Fwidth-int32(p.Fleft)-int32(p.Fright), b.Fheight) } func _RPadding(tls *libc.TLS, b TTtk_Box, p TTtk_Padding) (r TTtk_Box) { return XTtk_MakeBox(tls, b.Fx+b.Fwidth-int32(p.Fright), b.Fy, int32(p.Fright), b.Fheight) } // C documentation // // /* TPadding, MPadding, BPadding -- // * Split a box+padding pair into top, middle, and bottom parts. // */ func _TPadding(tls *libc.TLS, b TTtk_Box, p TTtk_Padding) (r TTtk_Box) { return XTtk_MakeBox(tls, b.Fx, b.Fy, b.Fwidth, int32(p.Ftop)) } func _MPadding(tls *libc.TLS, b TTtk_Box, p TTtk_Padding) (r TTtk_Box) { return XTtk_MakeBox(tls, b.Fx, b.Fy+int32(p.Ftop), b.Fwidth, b.Fheight-int32(p.Ftop)-int32(p.Fbottom)) } func _BPadding(tls *libc.TLS, b TTtk_Box, p TTtk_Padding) (r TTtk_Box) { return XTtk_MakeBox(tls, b.Fx, b.Fy+b.Fheight-int32(p.Fbottom), b.Fwidth, int32(p.Fbottom)) } // C documentation // // /* Ttk_Fill -- // * Fill the destination area of the drawable by replicating // * the source area of the image. // */ func _Ttk_Fill(tls *libc.TLS, dummy215 TTk_Window, d TDrawable, image TTk_Image, src TTtk_Box, dst TTtk_Box) { var ch, cw, db, dr, x, y, v2, v4 int32 _, _, _, _, _, _, _, _ = ch, cw, db, dr, x, y, v2, v4 dr = dst.Fx + dst.Fwidth db = dst.Fy + dst.Fheight if !(src.Fwidth != 0 && src.Fheight != 0 && dst.Fwidth != 0 && dst.Fheight != 0) { return } x = dst.Fx for { if !(x < dr) { break } if src.Fwidth < dr-x { v2 = src.Fwidth } else { v2 = dr - x } cw = v2 y = dst.Fy for { if !(y <= db) { break } if src.Fheight < db-y { v4 = src.Fheight } else { v4 = db - y } ch = v4 XTk_RedrawImage(tls, image, src.Fx, src.Fy, cw, ch, d, x, y) goto _3 _3: ; y += src.Fheight } goto _1 _1: ; x += src.Fwidth } } // C documentation // // /* Ttk_Stripe -- // * Fill a horizontal stripe of the destination drawable. // */ func _Ttk_Stripe(tls *libc.TLS, tkwin TTk_Window, d TDrawable, image TTk_Image, src TTtk_Box, dst TTtk_Box, p TTtk_Padding) { _Ttk_Fill(tls, tkwin, d, image, _LPadding(tls, src, p), _LPadding(tls, dst, p)) _Ttk_Fill(tls, tkwin, d, image, _CPadding(tls, src, p), _CPadding(tls, dst, p)) _Ttk_Fill(tls, tkwin, d, image, _RPadding(tls, src, p), _RPadding(tls, dst, p)) } // C documentation // // /* Ttk_Tile -- // * Fill successive horizontal stripes of the destination drawable. // */ func _Ttk_Tile(tls *libc.TLS, tkwin TTk_Window, d TDrawable, image TTk_Image, src TTtk_Box, dst TTtk_Box, p TTtk_Padding) { _Ttk_Stripe(tls, tkwin, d, image, _TPadding(tls, src, p), _TPadding(tls, dst, p), p) _Ttk_Stripe(tls, tkwin, d, image, _MPadding(tls, src, p), _MPadding(tls, dst, p), p) _Ttk_Stripe(tls, tkwin, d, image, _BPadding(tls, src, p), _BPadding(tls, dst, p), p) } /*------------------------------------------------------------------------ * +++ Image element definition. */ type TImageData = struct { FimageSpec uintptr FminWidth int32 FminHeight int32 Fsticky TTtk_Sticky Fborder TTtk_Padding Fpadding TTtk_Padding } func _FreeImageData(tls *libc.TLS, clientData uintptr) { var imageData uintptr _ = imageData imageData = clientData if (*TImageData)(unsafe.Pointer(imageData)).FimageSpec != 0 { XTtkFreeImageSpec(tls, (*TImageData)(unsafe.Pointer(imageData)).FimageSpec) } libtcl9_0.XTcl_Free(tls, clientData) } func _ImageElementSize(tls *libc.TLS, clientData uintptr, dummy291 uintptr, dummy292 TTk_Window, widthPtr uintptr, heightPtr uintptr, paddingPtr uintptr) { var image TTk_Image var imageData uintptr _, _ = image, imageData imageData = clientData image = (*TTtk_ImageSpec)(unsafe.Pointer((*TImageData)(unsafe.Pointer(imageData)).FimageSpec)).FbaseImage if image != 0 { XTk_SizeOfImage(tls, image, widthPtr, heightPtr) } if (*TImageData)(unsafe.Pointer(imageData)).FminWidth >= 0 { *(*int32)(unsafe.Pointer(widthPtr)) = (*TImageData)(unsafe.Pointer(imageData)).FminWidth } if (*TImageData)(unsafe.Pointer(imageData)).FminHeight >= 0 { *(*int32)(unsafe.Pointer(heightPtr)) = (*TImageData)(unsafe.Pointer(imageData)).FminHeight } *(*TTtk_Padding)(unsafe.Pointer(paddingPtr)) = (*TImageData)(unsafe.Pointer(imageData)).Fpadding } func _ImageElementDraw(tls *libc.TLS, clientData uintptr, dummy315 uintptr, tkwin TTk_Window, d TDrawable, b TTtk_Box, state TTtk_State) { bp := tls.Alloc(16) defer tls.Free(16) var dst, src TTtk_Box var image TTk_Image var imageData uintptr var _ /* imgHeight at bp+4 */ int32 var _ /* imgWidth at bp+0 */ int32 _, _, _, _ = dst, image, imageData, src imageData = clientData image = uintptr(0) image = XTtkSelectImage(tls, (*TImageData)(unsafe.Pointer(imageData)).FimageSpec, tkwin, state) if !(image != 0) { return } XTk_SizeOfImage(tls, image, bp, bp+4) src = XTtk_MakeBox(tls, 0, 0, *(*int32)(unsafe.Pointer(bp)), *(*int32)(unsafe.Pointer(bp + 4))) dst = XTtk_StickBox(tls, b, *(*int32)(unsafe.Pointer(bp)), *(*int32)(unsafe.Pointer(bp + 4)), (*TImageData)(unsafe.Pointer(imageData)).Fsticky) _Ttk_Tile(tls, tkwin, d, image, src, dst, (*TImageData)(unsafe.Pointer(imageData)).Fborder) } var _ImageElementSpec = TTtk_ElementSpec{ Fversion: int32(TK_STYLE_VERSION_2), FelementSize: uint64(8), Foptions: uintptr(unsafe.Pointer(&XTtkNullElementOptions)), } func init() { p := unsafe.Pointer(&_ImageElementSpec) *(*uintptr)(unsafe.Add(p, 24)) = __ccgo_fp(_ImageElementSize) *(*uintptr)(unsafe.Add(p, 32)) = __ccgo_fp(_ImageElementDraw) } // C documentation // // /*------------------------------------------------------------------------ // * +++ Image element factory. // */ func _Ttk_CreateImageElement(tls *libc.TLS, interp uintptr, dummy366 uintptr, theme TTtk_Theme, elementName uintptr, objc TTcl_Size, objv uintptr) (r int32) { bp := tls.Alloc(48) defer tls.Free(48) var i TTcl_Size var imageData, imageSpec uintptr var padding_specified, v1 int32 var v2 TTtk_Padding var _ /* option at bp+0 */ int32 _, _, _, _, _, _ = i, imageData, imageSpec, padding_specified, v1, v2 imageSpec = uintptr(0) imageData = uintptr(0) padding_specified = 0 if objc+int64(1) < int64(2) { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+52246, int64(-int32(1)))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+16, __ccgo_ts+51861, __ccgo_ts+29667, __ccgo_ts+52271, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) } imageSpec = XTtkGetImageSpec(tls, interp, XTk_MainWindow(tls, interp), *(*uintptr)(unsafe.Pointer(objv))) if !(imageSpec != 0) { return int32(TCL_ERROR) } imageData = libtcl9_0.XTcl_Alloc(tls, uint64(40)) (*TImageData)(unsafe.Pointer(imageData)).FimageSpec = imageSpec v1 = -libc.Int32FromInt32(1) (*TImageData)(unsafe.Pointer(imageData)).FminHeight = v1 (*TImageData)(unsafe.Pointer(imageData)).FminWidth = v1 (*TImageData)(unsafe.Pointer(imageData)).Fsticky = libc.Uint32FromInt32(libc.Int32FromInt32(TTK_FILL_BOTH)) v2 = XTtk_UniformPadding(tls, 0) (*TImageData)(unsafe.Pointer(imageData)).Fpadding = v2 (*TImageData)(unsafe.Pointer(imageData)).Fborder = v2 i = int64(1) for { if !(i < objc) { break } if i == objc-int64(1) { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+52276, libc.VaList(bp+16, libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(i)*8)), libc.UintptrFromInt32(0))))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+16, __ccgo_ts+51861, __ccgo_ts+29667, __ccgo_ts+182, libc.UintptrFromInt32(0))) goto error } if libtcl9_0.XTcl_GetIndexFromObjStruct(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(i)*8)), uintptr(unsafe.Pointer(&_optionStrings25)), libc.Int64FromUint64(libc.Uint64FromInt64(8)), __ccgo_ts+2689, libc.Int32FromInt32(0)|libc.Int32FromUint64(libc.Uint64FromInt64(4)<= 0. */ type TTextElement = struct { FtextObj uintptr FfontObj uintptr FforegroundObj uintptr FunderlineObj uintptr FwidthObj uintptr FanchorObj uintptr FjustifyObj uintptr FwrapLengthObj uintptr FembossedObj uintptr Ftkfont TTk_Font FtextLayout TTk_TextLayout Fwidth int32 Fheight int32 Fembossed int32 } // C documentation // // /* Text element options table. // * NB: Keep in sync with label element option table. // */ var _TextElementOptions = [10]TTtk_ElementOptionSpec{ 0: { FoptionName: __ccgo_ts + 20398, Ftype1: int32(TK_OPTION_STRING), FdefaultValue: __ccgo_ts + 195, }, 1: { FoptionName: __ccgo_ts + 20097, Ftype1: int32(TK_OPTION_FONT), Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 8)), FdefaultValue: __ccgo_ts + 20108, }, 2: { FoptionName: __ccgo_ts + 20085, Ftype1: int32(TK_OPTION_COLOR), Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 16)), FdefaultValue: __ccgo_ts + 39099, }, 3: { FoptionName: __ccgo_ts + 9507, Ftype1: int32(TK_OPTION_INDEX), Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 24)), }, 4: { FoptionName: __ccgo_ts + 2987, Ftype1: int32(TK_OPTION_INT), Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 32)), FdefaultValue: __ccgo_ts + 51542, }, 5: { FoptionName: __ccgo_ts + 15168, Ftype1: int32(TK_OPTION_ANCHOR), Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 40)), FdefaultValue: __ccgo_ts + 10954, }, 6: { FoptionName: __ccgo_ts + 20307, Ftype1: int32(TK_OPTION_JUSTIFY), Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 48)), FdefaultValue: __ccgo_ts + 10966, }, 7: { FoptionName: __ccgo_ts + 20461, Ftype1: int32(TK_OPTION_PIXELS), Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 56)), FdefaultValue: __ccgo_ts + 10533, }, 8: { FoptionName: __ccgo_ts + 52353, Ftype1: int32(TK_OPTION_INT), Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 64)), FdefaultValue: __ccgo_ts + 10533, }, 9: {}, } func _TextSetup(tls *libc.TLS, text uintptr, tkwin TTk_Window) (r int32) { bp := tls.Alloc(16) defer tls.Free(16) var string1 uintptr var _ /* justify at bp+0 */ TTk_Justify var _ /* wrapLength at bp+4 */ int32 _ = string1 string1 = libtcl9_0.XTcl_GetStringFromObj(tls, (*TTextElement)(unsafe.Pointer(text)).FtextObj, libc.UintptrFromInt32(0)) *(*TTk_Justify)(unsafe.Pointer(bp)) = int32(TK_JUSTIFY_LEFT) *(*int32)(unsafe.Pointer(bp + 4)) = 0 (*TTextElement)(unsafe.Pointer(text)).Ftkfont = XTk_GetFontFromObj(tls, tkwin, (*TTextElement)(unsafe.Pointer(text)).FfontObj) XTk_GetJustifyFromObj(tls, libc.UintptrFromInt32(0), (*TTextElement)(unsafe.Pointer(text)).FjustifyObj, bp) XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), tkwin, (*TTextElement)(unsafe.Pointer(text)).FwrapLengthObj, bp+4) _ = libtcl9_0.XTcl_GetBoolFromObj(tls, libc.UintptrFromInt32(0), (*TTextElement)(unsafe.Pointer(text)).FembossedObj, (libc.Int32FromInt32(TCL_NULL_OK)-libc.Int32FromInt32(2))&libc.Int32FromInt64(4), text+96) (*TTextElement)(unsafe.Pointer(text)).FtextLayout = XTk_ComputeTextLayout(tls, (*TTextElement)(unsafe.Pointer(text)).Ftkfont, string1, int64(-int32(1)), *(*int32)(unsafe.Pointer(bp + 4)), *(*TTk_Justify)(unsafe.Pointer(bp)), 0, text+88, text+92) return int32(1) } /* * TextReqWidth -- compute the requested width of a text element. * * If -width is positive, use that as the width * If -width is negative, use that as the minimum width * If not specified or empty, use the natural size of the text */ func _TextReqWidth(tls *libc.TLS, text uintptr) (r int32) { bp := tls.Alloc(16) defer tls.Free(16) var avgWidth, specWidth int32 var _ /* reqWidth at bp+0 */ int32 _, _ = avgWidth, specWidth if (*TTextElement)(unsafe.Pointer(text)).FwidthObj != 0 && libtcl9_0.XTcl_GetIntFromObj(tls, libc.UintptrFromInt32(0), (*TTextElement)(unsafe.Pointer(text)).FwidthObj, bp) == TCL_OK { avgWidth = XTk_TextWidth(tls, (*TTextElement)(unsafe.Pointer(text)).Ftkfont, __ccgo_ts+10533, int64(1)) if *(*int32)(unsafe.Pointer(bp)) <= 0 { specWidth = avgWidth * -*(*int32)(unsafe.Pointer(bp)) if specWidth > (*TTextElement)(unsafe.Pointer(text)).Fwidth { return specWidth } } else { return avgWidth * *(*int32)(unsafe.Pointer(bp)) } } return (*TTextElement)(unsafe.Pointer(text)).Fwidth } func _TextCleanup(tls *libc.TLS, text uintptr) { XTk_FreeTextLayout(tls, (*TTextElement)(unsafe.Pointer(text)).FtextLayout) } // C documentation // // /* // * TextDraw -- // * Draw a text element. // * Called by TextElementDraw() and LabelElementDraw(). // */ func _TextDraw(tls *libc.TLS, text uintptr, tkwin TTk_Window, d TDrawable, b TTtk_Box) { bp := tls.Alloc(160) defer tls.Free(160) var clipRegion TRegion var color uintptr var gc1, gc2 TGC var v1, v2 int32 var _ /* anchor at bp+136 */ TTk_Anchor var _ /* gcValues at bp+8 */ TXGCValues var _ /* rect at bp+144 */ TXRectangle var _ /* underline at bp+0 */ TTcl_Size _, _, _, _, _, _ = clipRegion, color, gc1, gc2, v1, v2 color = XTk_GetColorFromObj(tls, tkwin, (*TTextElement)(unsafe.Pointer(text)).FforegroundObj) *(*TTcl_Size)(unsafe.Pointer(bp)) = int64(-libc.Int32FromInt32(1) - libc.Int32FromInt32(0x7fffffff)) *(*TTk_Anchor)(unsafe.Pointer(bp + 136)) = int32(TK_ANCHOR_CENTER) clipRegion = libc.UintptrFromInt32(0) (*(*TXGCValues)(unsafe.Pointer(bp + 8))).Ffont = XTk_FontId(tls, (*TTextElement)(unsafe.Pointer(text)).Ftkfont) (*(*TXGCValues)(unsafe.Pointer(bp + 8))).Fforeground = (*TXColor)(unsafe.Pointer(color)).Fpixel gc1 = XTk_GetGC(tls, tkwin, libc.Uint64FromInt64(libc.Int64FromInt64(1)< int64(INT_MAX) { *(*TTcl_Size)(unsafe.Pointer(bp)) = int64(INT_MAX) } } if *(*TTcl_Size)(unsafe.Pointer(bp)) != int64(-libc.Int32FromInt32(1)-libc.Int32FromInt32(0x7fffffff)) { if (*TTextElement)(unsafe.Pointer(text)).Fembossed != 0 { XTk_UnderlineTextLayout(tls, (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fdisplay, d, gc2, (*TTextElement)(unsafe.Pointer(text)).FtextLayout, b.Fx+int32(1), b.Fy+int32(1), int32(*(*TTcl_Size)(unsafe.Pointer(bp)))) } XTk_UnderlineTextLayout(tls, (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fdisplay, d, gc1, (*TTextElement)(unsafe.Pointer(text)).FtextLayout, b.Fx, b.Fy, int32(*(*TTcl_Size)(unsafe.Pointer(bp)))) } } if clipRegion != libc.UintptrFromInt32(0) { libx11.XXSetClipMask(tls, (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fdisplay, gc1, uint64(0)) libx11.XXSetClipMask(tls, (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fdisplay, gc2, uint64(0)) libx11.XXDestroyRegion(tls, clipRegion) } XTk_FreeGC(tls, (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fdisplay, gc1) XTk_FreeGC(tls, (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fdisplay, gc2) } func _TextElementSize(tls *libc.TLS, dummy203 uintptr, elementRecord uintptr, tkwin TTk_Window, widthPtr uintptr, heightPtr uintptr, dummy208 uintptr) { var text uintptr _ = text text = elementRecord if !(_TextSetup(tls, text, tkwin) != 0) { return } *(*int32)(unsafe.Pointer(heightPtr)) = (*TTextElement)(unsafe.Pointer(text)).Fheight *(*int32)(unsafe.Pointer(widthPtr)) = _TextReqWidth(tls, text) _TextCleanup(tls, text) return } func _TextElementDraw(tls *libc.TLS, dummy224 uintptr, elementRecord uintptr, tkwin TTk_Window, d TDrawable, b TTtk_Box, dummy229 TTtk_State) { var text uintptr _ = text text = elementRecord if _TextSetup(tls, text, tkwin) != 0 { _TextDraw(tls, text, tkwin, d, b) _TextCleanup(tls, text) } } var _TextElementSpec = TTtk_ElementSpec{ Fversion: int32(TK_STYLE_VERSION_2), FelementSize: uint64(104), Foptions: uintptr(unsafe.Pointer(&_TextElementOptions)), } func init() { p := unsafe.Pointer(&_TextElementSpec) *(*uintptr)(unsafe.Add(p, 24)) = __ccgo_fp(_TextElementSize) *(*uintptr)(unsafe.Add(p, 32)) = __ccgo_fp(_TextElementDraw) } /*---------------------------------------------------------------------- * +++ cText (collapsing text) element. * * This element is the same as the Text element, except its dimensions * are 0,0 when the text to display is "". */ func _cTextSetup(tls *libc.TLS, text uintptr, tkwin TTk_Window) (r int32) { if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(libtcl9_0.XTcl_GetStringFromObj(tls, (*TTextElement)(unsafe.Pointer(text)).FtextObj, libc.UintptrFromInt32(0))))) == int32('\000') { return 0 } else { return _TextSetup(tls, text, tkwin) } return r } func _cTextElementSize(tls *libc.TLS, dummy264 uintptr, elementRecord uintptr, tkwin TTk_Window, widthPtr uintptr, heightPtr uintptr, dummy269 uintptr) { var text uintptr _ = text text = elementRecord if !(_cTextSetup(tls, text, tkwin) != 0) { return } *(*int32)(unsafe.Pointer(heightPtr)) = (*TTextElement)(unsafe.Pointer(text)).Fheight *(*int32)(unsafe.Pointer(widthPtr)) = _TextReqWidth(tls, text) _TextCleanup(tls, text) return } var _cTextElementSpec = TTtk_ElementSpec{ Fversion: int32(TK_STYLE_VERSION_2), FelementSize: uint64(104), Foptions: uintptr(unsafe.Pointer(&_TextElementOptions)), } func init() { p := unsafe.Pointer(&_cTextElementSpec) *(*uintptr)(unsafe.Add(p, 24)) = __ccgo_fp(_cTextElementSize) *(*uintptr)(unsafe.Add(p, 32)) = __ccgo_fp(_TextElementDraw) } /*---------------------------------------------------------------------- * +++ Image element. * Draws an image. */ type TImageElement = struct { FimageObj uintptr FstippleObj uintptr FbackgroundObj uintptr FimageSpec uintptr Ftkimg TTk_Image Fwidth int32 Fheight int32 } // C documentation // // /* ===> NB: Keep in sync with label element option table. <=== // */ var _ImageElementOptions = [4]TTtk_ElementOptionSpec{ 0: { FoptionName: __ccgo_ts + 20294, Ftype1: int32(TK_OPTION_STRING), FdefaultValue: __ccgo_ts + 195, }, 1: { FoptionName: __ccgo_ts + 28879, Ftype1: int32(TK_OPTION_STRING), Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 8)), FdefaultValue: __ccgo_ts + 4537, }, 2: { FoptionName: __ccgo_ts + 19898, Ftype1: int32(TK_OPTION_COLOR), Foffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 16)), FdefaultValue: __ccgo_ts + 19921, }, 3: {}, } /* * ImageSetup() -- * Look up the Tk_Image from the image element's imageObj resource. * Caller must release the image with ImageCleanup(). * * Returns: * 1 if successful, 0 if there was an error (unreported) * or the image resource was not specified. */ func _ImageSetup(tls *libc.TLS, image uintptr, tkwin TTk_Window, state TTtk_State) (r int32) { if !((*TImageElement)(unsafe.Pointer(image)).FimageObj != 0) { return 0 } (*TImageElement)(unsafe.Pointer(image)).FimageSpec = XTtkGetImageSpec(tls, libc.UintptrFromInt32(0), tkwin, (*TImageElement)(unsafe.Pointer(image)).FimageObj) if !((*TImageElement)(unsafe.Pointer(image)).FimageSpec != 0) { return 0 } (*TImageElement)(unsafe.Pointer(image)).Ftkimg = XTtkSelectImage(tls, (*TImageElement)(unsafe.Pointer(image)).FimageSpec, tkwin, state) if !((*TImageElement)(unsafe.Pointer(image)).Ftkimg != 0) { XTtkFreeImageSpec(tls, (*TImageElement)(unsafe.Pointer(image)).FimageSpec) return 0 } XTk_SizeOfImage(tls, (*TImageElement)(unsafe.Pointer(image)).Ftkimg, image+40, image+44) return int32(1) } func _ImageCleanup(tls *libc.TLS, image uintptr) { XTtkFreeImageSpec(tls, (*TImageElement)(unsafe.Pointer(image)).FimageSpec) } // C documentation // // /* // * StippleOver -- // * Draw a stipple over the image area, to make it look "grayed-out" // * when TTK_STATE_DISABLED is set. // */ func _StippleOver(tls *libc.TLS, image uintptr, tkwin TTk_Window, d TDrawable, x int32, y int32) { bp := tls.Alloc(128) defer tls.Free(128) var color uintptr var gc TGC var mask uint64 var stipple TPixmap var _ /* gcvalues at bp+0 */ TXGCValues _, _, _, _ = color, gc, mask, stipple stipple = XTk_AllocBitmapFromObj(tls, libc.UintptrFromInt32(0), tkwin, (*TImageElement)(unsafe.Pointer(image)).FstippleObj) color = XTk_GetColorFromObj(tls, tkwin, (*TImageElement)(unsafe.Pointer(image)).FbackgroundObj) if stipple != uint64(0) { mask = libc.Uint64FromInt64(libc.Int64FromInt64(1)< (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fchanges.Fwidth { width = (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fchanges.Fwidth - b.Fx } if b.Fy+height > (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fchanges.Fheight { height = (*TTk_FakeWin)(unsafe.Pointer(tkwin)).Fchanges.Fheight - b.Fy } if height <= 0 || width <= 0 { /* Completely clipped - bail out. */ return } XTk_RedrawImage(tls, (*TImageElement)(unsafe.Pointer(image)).Ftkimg, 0, 0, width, height, d, b.Fx, b.Fy) /* If we're disabled there's no state-specific 'disabled' image, * stipple the image. * @@@ Possibly: Don't do disabled-stippling at all; * @@@ it's ugly and out of fashion. * Do not stipple at all under Aqua, just draw the image: it shows up * as a white rectangle otherwise. */ if state&libc.Uint32FromInt32(libc.Int32FromInt32(1)<compound != IMAGE, then TextSetup() has been called * if c->compound != TEXT, then ImageSetup() has returned successfully * c->compound != COMPOUND_NONE. */ switch (*TLabelElement)(unsafe.Pointer(c)).Fcompound { case int32(TTK_COMPOUND_NONE): /* Can't happen */ case int32(TTK_COMPOUND_TEXT): (*TLabelElement)(unsafe.Pointer(c)).FtotalWidth = (*TLabelElement)(unsafe.Pointer(c)).Ftext.Fwidth (*TLabelElement)(unsafe.Pointer(c)).FtotalHeight = (*TLabelElement)(unsafe.Pointer(c)).Ftext.Fheight case int32(TTK_COMPOUND_IMAGE): (*TLabelElement)(unsafe.Pointer(c)).FtotalWidth = (*TLabelElement)(unsafe.Pointer(c)).Fimage.Fwidth (*TLabelElement)(unsafe.Pointer(c)).FtotalHeight = (*TLabelElement)(unsafe.Pointer(c)).Fimage.Fheight case int32(TTK_COMPOUND_CENTER): if (*TLabelElement)(unsafe.Pointer(c)).Fimage.Fwidth > (*TLabelElement)(unsafe.Pointer(c)).Ftext.Fwidth { v1 = (*TLabelElement)(unsafe.Pointer(c)).Fimage.Fwidth } else { v1 = (*TLabelElement)(unsafe.Pointer(c)).Ftext.Fwidth } (*TLabelElement)(unsafe.Pointer(c)).FtotalWidth = v1 if (*TLabelElement)(unsafe.Pointer(c)).Fimage.Fheight > (*TLabelElement)(unsafe.Pointer(c)).Ftext.Fheight { v2 = (*TLabelElement)(unsafe.Pointer(c)).Fimage.Fheight } else { v2 = (*TLabelElement)(unsafe.Pointer(c)).Ftext.Fheight } (*TLabelElement)(unsafe.Pointer(c)).FtotalHeight = v2 case int32(TTK_COMPOUND_TOP): fallthrough case int32(TTK_COMPOUND_BOTTOM): if (*TLabelElement)(unsafe.Pointer(c)).Fimage.Fwidth > (*TLabelElement)(unsafe.Pointer(c)).Ftext.Fwidth { v3 = (*TLabelElement)(unsafe.Pointer(c)).Fimage.Fwidth } else { v3 = (*TLabelElement)(unsafe.Pointer(c)).Ftext.Fwidth } (*TLabelElement)(unsafe.Pointer(c)).FtotalWidth = v3 (*TLabelElement)(unsafe.Pointer(c)).FtotalHeight = (*TLabelElement)(unsafe.Pointer(c)).Fimage.Fheight + (*TLabelElement)(unsafe.Pointer(c)).Ftext.Fheight + (*TLabelElement)(unsafe.Pointer(c)).Fspace case int32(TTK_COMPOUND_LEFT): fallthrough case int32(TTK_COMPOUND_RIGHT): (*TLabelElement)(unsafe.Pointer(c)).FtotalWidth = (*TLabelElement)(unsafe.Pointer(c)).Fimage.Fwidth + (*TLabelElement)(unsafe.Pointer(c)).Ftext.Fwidth + (*TLabelElement)(unsafe.Pointer(c)).Fspace if (*TLabelElement)(unsafe.Pointer(c)).Fimage.Fheight > (*TLabelElement)(unsafe.Pointer(c)).Ftext.Fheight { v4 = (*TLabelElement)(unsafe.Pointer(c)).Fimage.Fheight } else { v4 = (*TLabelElement)(unsafe.Pointer(c)).Ftext.Fheight } (*TLabelElement)(unsafe.Pointer(c)).FtotalHeight = v4 break } } func _LabelCleanup(tls *libc.TLS, c uintptr) { if (*TLabelElement)(unsafe.Pointer(c)).Fcompound != int32(TTK_COMPOUND_TEXT) { _ImageCleanup(tls, c+120) } if (*TLabelElement)(unsafe.Pointer(c)).Fcompound != int32(TTK_COMPOUND_IMAGE) { _TextCleanup(tls, c+16) } } func _LabelElementSize(tls *libc.TLS, dummy633 uintptr, elementRecord uintptr, tkwin TTk_Window, widthPtr uintptr, heightPtr uintptr, dummy638 uintptr) { var label uintptr var textReqWidth, v1 int32 _, _, _ = label, textReqWidth, v1 label = elementRecord textReqWidth = 0 _LabelSetup(tls, label, tkwin, uint32(0)) *(*int32)(unsafe.Pointer(heightPtr)) = (*TLabelElement)(unsafe.Pointer(label)).FtotalHeight /* Requested width based on -width option, not actual text width: */ if (*TLabelElement)(unsafe.Pointer(label)).Fcompound != int32(TTK_COMPOUND_IMAGE) { textReqWidth = _TextReqWidth(tls, label+16) } switch (*TLabelElement)(unsafe.Pointer(label)).Fcompound { case int32(TTK_COMPOUND_TEXT): *(*int32)(unsafe.Pointer(widthPtr)) = textReqWidth case int32(TTK_COMPOUND_IMAGE): *(*int32)(unsafe.Pointer(widthPtr)) = (*TLabelElement)(unsafe.Pointer(label)).Fimage.Fwidth case int32(TTK_COMPOUND_TOP): fallthrough case int32(TTK_COMPOUND_BOTTOM): fallthrough case int32(TTK_COMPOUND_CENTER): if (*TLabelElement)(unsafe.Pointer(label)).Fimage.Fwidth > textReqWidth { v1 = (*TLabelElement)(unsafe.Pointer(label)).Fimage.Fwidth } else { v1 = textReqWidth } *(*int32)(unsafe.Pointer(widthPtr)) = v1 case int32(TTK_COMPOUND_LEFT): fallthrough case int32(TTK_COMPOUND_RIGHT): *(*int32)(unsafe.Pointer(widthPtr)) = (*TLabelElement)(unsafe.Pointer(label)).Fimage.Fwidth + textReqWidth + (*TLabelElement)(unsafe.Pointer(label)).Fspace case int32(TTK_COMPOUND_NONE): break /* Can't happen */ } _LabelCleanup(tls, label) } // C documentation // // /* // * DrawCompound -- // * Helper routine for LabelElementDraw; // * Handles layout for -compound {left,right,top,bottom} // */ func _DrawCompound(tls *libc.TLS, l uintptr, _b TTtk_Box, tkwin TTk_Window, d TDrawable, state TTtk_State, imageSide TTtk_Side, textSide TTtk_Side) { bp := tls.Alloc(16) defer tls.Free(16) *(*TTtk_Box)(unsafe.Pointer(bp)) = _b var imageBox, textBox TTtk_Box _, _ = imageBox, textBox imageBox = XTtk_PlaceBox(tls, bp, (*TLabelElement)(unsafe.Pointer(l)).Fimage.Fwidth, (*TLabelElement)(unsafe.Pointer(l)).Fimage.Fheight, imageSide, uint32(0)) textBox = XTtk_PlaceBox(tls, bp, (*TLabelElement)(unsafe.Pointer(l)).Ftext.Fwidth, (*TLabelElement)(unsafe.Pointer(l)).Ftext.Fheight, textSide, uint32(0)) _ImageDraw(tls, l+120, tkwin, d, imageBox, state) _TextDraw(tls, l+16, tkwin, d, textBox) } func _LabelElementDraw(tls *libc.TLS, dummy694 uintptr, elementRecord uintptr, tkwin TTk_Window, d TDrawable, b TTtk_Box, state TTtk_State) { bp := tls.Alloc(16) defer tls.Free(16) var l uintptr var pb TTtk_Box var _ /* anchor at bp+0 */ TTk_Anchor _, _ = l, pb l = elementRecord *(*TTk_Anchor)(unsafe.Pointer(bp)) = int32(TK_ANCHOR_CENTER) _LabelSetup(tls, l, tkwin, state) /* * Adjust overall parcel based on -anchor: */ XTk_GetAnchorFromObj(tls, libc.UintptrFromInt32(0), (*TLabelElement)(unsafe.Pointer(l)).Ftext.FanchorObj, bp) b = XTtk_AnchorBox(tls, b, (*TLabelElement)(unsafe.Pointer(l)).FtotalWidth, (*TLabelElement)(unsafe.Pointer(l)).FtotalHeight, *(*TTk_Anchor)(unsafe.Pointer(bp))) /* * Draw text and/or image parts based on -compound: */ switch (*TLabelElement)(unsafe.Pointer(l)).Fcompound { case int32(TTK_COMPOUND_NONE): /* Can't happen */ case int32(TTK_COMPOUND_TEXT): _TextDraw(tls, l+16, tkwin, d, b) case int32(TTK_COMPOUND_IMAGE): _ImageDraw(tls, l+120, tkwin, d, b, state) case int32(TTK_COMPOUND_CENTER): pb = XTtk_AnchorBox(tls, b, (*TLabelElement)(unsafe.Pointer(l)).Fimage.Fwidth, (*TLabelElement)(unsafe.Pointer(l)).Fimage.Fheight, int32(TK_ANCHOR_CENTER)) _ImageDraw(tls, l+120, tkwin, d, pb, state) pb = XTtk_AnchorBox(tls, b, (*TLabelElement)(unsafe.Pointer(l)).Ftext.Fwidth, (*TLabelElement)(unsafe.Pointer(l)).Ftext.Fheight, int32(TK_ANCHOR_CENTER)) _TextDraw(tls, l+16, tkwin, d, pb) case int32(TTK_COMPOUND_TOP): _DrawCompound(tls, l, b, tkwin, d, state, int32(TTK_SIDE_TOP), int32(TTK_SIDE_BOTTOM)) case int32(TTK_COMPOUND_BOTTOM): _DrawCompound(tls, l, b, tkwin, d, state, int32(TTK_SIDE_BOTTOM), int32(TTK_SIDE_TOP)) case int32(TTK_COMPOUND_LEFT): _DrawCompound(tls, l, b, tkwin, d, state, int32(TTK_SIDE_LEFT), int32(TTK_SIDE_RIGHT)) case int32(TTK_COMPOUND_RIGHT): _DrawCompound(tls, l, b, tkwin, d, state, int32(TTK_SIDE_RIGHT), int32(TTK_SIDE_LEFT)) break } _LabelCleanup(tls, l) } var _LabelElementSpec = TTtk_ElementSpec{ Fversion: int32(TK_STYLE_VERSION_2), FelementSize: uint64(184), Foptions: uintptr(unsafe.Pointer(&_LabelElementOptions)), } func init() { p := unsafe.Pointer(&_LabelElementSpec) *(*uintptr)(unsafe.Add(p, 24)) = __ccgo_fp(_LabelElementSize) *(*uintptr)(unsafe.Add(p, 32)) = __ccgo_fp(_LabelElementDraw) } /*------------------------------------------------------------------------ * +++ Initialization. */ func XTtkLabel_Init(tls *libc.TLS, interp uintptr) { var theme TTtk_Theme _ = theme theme = XTtk_GetDefaultTheme(tls, interp) XTtk_RegisterElement(tls, interp, theme, __ccgo_ts+17996, uintptr(unsafe.Pointer(&_TextElementSpec)), libc.UintptrFromInt32(0)) XTtk_RegisterElement(tls, interp, theme, __ccgo_ts+52372, uintptr(unsafe.Pointer(&_cTextElementSpec)), libc.UintptrFromInt32(0)) XTtk_RegisterElement(tls, interp, theme, __ccgo_ts+17810, uintptr(unsafe.Pointer(&_ImageElementSpec1)), libc.UintptrFromInt32(0)) XTtk_RegisterElement(tls, interp, theme, __ccgo_ts+17899, uintptr(unsafe.Pointer(&_LabelElementSpec)), libc.UintptrFromInt32(0)) } const TK_OPTION_ANY4 = 0 type TTtk_Layout_ = struct { Fstyle TTtk_Style FrecordPtr uintptr FoptionTable TTk_OptionTable Ftkwin TTk_Window Froot uintptr } type TTtk_LayoutNode_ = struct { Fflags uint32 Feclass uintptr Fstate TTtk_State Fparcel TTtk_Box Fnext uintptr Fchild uintptr } type TTtk_TemplateNode = struct { Fname uintptr Fflags uint32 Fnext uintptr Fchild uintptr } type TTtk_TemplateNode_ = TTtk_TemplateNode /*------------------------------------------------------------------------ * +++ Ttk_Box and Ttk_Padding utilities: */ func XTtk_MakeBox(tls *libc.TLS, x int32, y int32, width int32, height int32) (r TTtk_Box) { var b TTtk_Box _ = b b.Fx = x b.Fy = y b.Fwidth = width b.Fheight = height return b } func XTtk_BoxContains(tls *libc.TLS, box TTtk_Box, x int32, y int32) (r int32) { return libc.BoolInt32(box.Fx <= x && x < box.Fx+box.Fwidth && box.Fy <= y && y < box.Fy+box.Fheight) } func XTtkBoxEqual(tls *libc.TLS, box1 TTtk_Box, box2 TTtk_Box) (r int32) { return libc.BoolInt32(box1.Fx == box2.Fx && box1.Fy == box2.Fy && box1.Fwidth == box2.Fwidth && box1.Fheight == box2.Fheight) } func XTtk_NewBoxObj(tls *libc.TLS, box TTtk_Box) (r uintptr) { bp := tls.Alloc(32) defer tls.Free(32) var _ /* result at bp+0 */ [4]uintptr (*(*[4]uintptr)(unsafe.Pointer(bp)))[0] = libtcl9_0.XTcl_NewWideIntObj(tls, int64(box.Fx)) (*(*[4]uintptr)(unsafe.Pointer(bp)))[int32(1)] = libtcl9_0.XTcl_NewWideIntObj(tls, int64(box.Fy)) (*(*[4]uintptr)(unsafe.Pointer(bp)))[int32(2)] = libtcl9_0.XTcl_NewWideIntObj(tls, int64(box.Fwidth)) (*(*[4]uintptr)(unsafe.Pointer(bp)))[int32(3)] = libtcl9_0.XTcl_NewWideIntObj(tls, int64(box.Fheight)) return libtcl9_0.XTcl_NewListObj(tls, int64(4), bp) } /* * packTop, packBottom, packLeft, packRight -- * Carve out a parcel of the specified height (resp width) * from the specified cavity. * * Returns: * The new parcel. * * Side effects: * Adjust the cavity. */ func _packTop(tls *libc.TLS, cavity uintptr, height int32) (r TTtk_Box) { var parcel TTtk_Box var v1 int32 _, _ = parcel, v1 if height < (*TTtk_Box)(unsafe.Pointer(cavity)).Fheight { v1 = height } else { v1 = (*TTtk_Box)(unsafe.Pointer(cavity)).Fheight } height = v1 parcel = XTtk_MakeBox(tls, (*TTtk_Box)(unsafe.Pointer(cavity)).Fx, (*TTtk_Box)(unsafe.Pointer(cavity)).Fy, (*TTtk_Box)(unsafe.Pointer(cavity)).Fwidth, height) *(*int32)(unsafe.Pointer(cavity + 4)) += height *(*int32)(unsafe.Pointer(cavity + 12)) -= height return parcel } func _packBottom(tls *libc.TLS, cavity uintptr, height int32) (r TTtk_Box) { var v1 int32 _ = v1 if height < (*TTtk_Box)(unsafe.Pointer(cavity)).Fheight { v1 = height } else { v1 = (*TTtk_Box)(unsafe.Pointer(cavity)).Fheight } height = v1 *(*int32)(unsafe.Pointer(cavity + 12)) -= height return XTtk_MakeBox(tls, (*TTtk_Box)(unsafe.Pointer(cavity)).Fx, (*TTtk_Box)(unsafe.Pointer(cavity)).Fy+(*TTtk_Box)(unsafe.Pointer(cavity)).Fheight, (*TTtk_Box)(unsafe.Pointer(cavity)).Fwidth, height) } func _packLeft(tls *libc.TLS, cavity uintptr, width int32) (r TTtk_Box) { var parcel TTtk_Box var v1 int32 _, _ = parcel, v1 if width < (*TTtk_Box)(unsafe.Pointer(cavity)).Fwidth { v1 = width } else { v1 = (*TTtk_Box)(unsafe.Pointer(cavity)).Fwidth } width = v1 parcel = XTtk_MakeBox(tls, (*TTtk_Box)(unsafe.Pointer(cavity)).Fx, (*TTtk_Box)(unsafe.Pointer(cavity)).Fy, width, (*TTtk_Box)(unsafe.Pointer(cavity)).Fheight) *(*int32)(unsafe.Pointer(cavity)) += width *(*int32)(unsafe.Pointer(cavity + 8)) -= width return parcel } func _packRight(tls *libc.TLS, cavity uintptr, width int32) (r TTtk_Box) { var v1 int32 _ = v1 if width < (*TTtk_Box)(unsafe.Pointer(cavity)).Fwidth { v1 = width } else { v1 = (*TTtk_Box)(unsafe.Pointer(cavity)).Fwidth } width = v1 *(*int32)(unsafe.Pointer(cavity + 8)) -= width return XTtk_MakeBox(tls, (*TTtk_Box)(unsafe.Pointer(cavity)).Fx+(*TTtk_Box)(unsafe.Pointer(cavity)).Fwidth, (*TTtk_Box)(unsafe.Pointer(cavity)).Fy, width, (*TTtk_Box)(unsafe.Pointer(cavity)).Fheight) } /* * Ttk_PackBox -- * Carve out a parcel of the specified size on the specified side * in the specified cavity. * * Returns: * The new parcel. * * Side effects: * Adjust the cavity. */ func XTtk_PackBox(tls *libc.TLS, cavity uintptr, width int32, height int32, side TTtk_Side) (r TTtk_Box) { switch side { default: fallthrough case int32(TTK_SIDE_TOP): return _packTop(tls, cavity, height) case int32(TTK_SIDE_BOTTOM): return _packBottom(tls, cavity, height) case int32(TTK_SIDE_LEFT): return _packLeft(tls, cavity, width) case int32(TTK_SIDE_RIGHT): return _packRight(tls, cavity, width) } return r } // C documentation // // /* // * Ttk_PadBox -- // * Shrink a box by the specified padding amount. // */ func XTtk_PadBox(tls *libc.TLS, b TTtk_Box, p TTtk_Padding) (r TTtk_Box) { b.Fx += int32(p.Fleft) b.Fy += int32(p.Ftop) b.Fwidth -= int32(p.Fleft) + int32(p.Fright) b.Fheight -= int32(p.Ftop) + int32(p.Fbottom) if b.Fwidth <= 0 { b.Fwidth = int32(1) } if b.Fheight <= 0 { b.Fheight = int32(1) } return b } // C documentation // // /* // * Ttk_ExpandBox -- // * Grow a box by the specified padding amount. // */ func XTtk_ExpandBox(tls *libc.TLS, b TTtk_Box, p TTtk_Padding) (r TTtk_Box) { b.Fx -= int32(p.Fleft) b.Fy -= int32(p.Ftop) b.Fwidth += int32(p.Fleft) + int32(p.Fright) b.Fheight += int32(p.Ftop) + int32(p.Fbottom) return b } // C documentation // // /* // * Ttk_StickBox -- // * Place a box of size w * h in the specified parcel, // * according to the specified sticky bits. // */ func XTtk_StickBox(tls *libc.TLS, parcel TTtk_Box, width int32, height int32, sticky uint32) (r TTtk_Box) { var dx, dy int32 _, _ = dx, dy if width > parcel.Fwidth { width = parcel.Fwidth } if height > parcel.Fheight { height = parcel.Fheight } dx = parcel.Fwidth - width dy = parcel.Fheight - height /* * X coordinate adjustment: */ switch sticky & libc.Uint32FromInt32(libc.Int32FromInt32(TTK_STICK_W)|libc.Int32FromInt32(TTK_STICK_E)) { case libc.Uint32FromInt32(libc.Int32FromInt32(TTK_STICK_W) | libc.Int32FromInt32(TTK_STICK_E)): /* no-op -- use entire parcel width */ case libc.Uint32FromInt32(libc.Int32FromInt32(TTK_STICK_W)): parcel.Fwidth = width case libc.Uint32FromInt32(libc.Int32FromInt32(TTK_STICK_E)): parcel.Fx += dx parcel.Fwidth = width default: parcel.Fx += dx / int32(2) parcel.Fwidth = width break } /* * Y coordinate adjustment: */ switch sticky & libc.Uint32FromInt32(libc.Int32FromInt32(TTK_STICK_N)|libc.Int32FromInt32(TTK_STICK_S)) { case libc.Uint32FromInt32(libc.Int32FromInt32(TTK_STICK_N) | libc.Int32FromInt32(TTK_STICK_S)): /* use entire parcel height */ case libc.Uint32FromInt32(libc.Int32FromInt32(TTK_STICK_N)): parcel.Fheight = height case libc.Uint32FromInt32(libc.Int32FromInt32(TTK_STICK_S)): parcel.Fy += dy parcel.Fheight = height default: parcel.Fy += dy / int32(2) parcel.Fheight = height break } return parcel } // C documentation // // /* // * AnchorToSticky -- // * Convert a Tk_Anchor enum to a TTK_STICKY bitmask. // */ func _AnchorToSticky(tls *libc.TLS, anchor TTk_Anchor) (r TTtk_Sticky) { switch anchor { case int32(TK_ANCHOR_N): return libc.Uint32FromInt32(libc.Int32FromInt32(TTK_STICK_N)) case int32(TK_ANCHOR_NE): return libc.Uint32FromInt32(libc.Int32FromInt32(TTK_STICK_N) | libc.Int32FromInt32(TTK_STICK_E)) case int32(TK_ANCHOR_E): return libc.Uint32FromInt32(libc.Int32FromInt32(TTK_STICK_E)) case int32(TK_ANCHOR_SE): return libc.Uint32FromInt32(libc.Int32FromInt32(TTK_STICK_S) | libc.Int32FromInt32(TTK_STICK_E)) case int32(TK_ANCHOR_S): return libc.Uint32FromInt32(libc.Int32FromInt32(TTK_STICK_S)) case int32(TK_ANCHOR_SW): return libc.Uint32FromInt32(libc.Int32FromInt32(TTK_STICK_S) | libc.Int32FromInt32(TTK_STICK_W)) case int32(TK_ANCHOR_W): return libc.Uint32FromInt32(libc.Int32FromInt32(TTK_STICK_W)) case int32(TK_ANCHOR_NW): return libc.Uint32FromInt32(libc.Int32FromInt32(TTK_STICK_N) | libc.Int32FromInt32(TTK_STICK_W)) default: return uint32(0) } return r } // C documentation // // /* // * Ttk_AnchorBox -- // * Place a box of size w * h in the specified parcel, // * according to the specified anchor. // */ func XTtk_AnchorBox(tls *libc.TLS, parcel TTtk_Box, width int32, height int32, anchor TTk_Anchor) (r TTtk_Box) { return XTtk_StickBox(tls, parcel, width, height, _AnchorToSticky(tls, anchor)) } // C documentation // // /* // * Ttk_PlaceBox -- // * Combine Ttk_PackBox() and Ttk_StickBox(). // */ func XTtk_PlaceBox(tls *libc.TLS, cavity uintptr, width int32, height int32, side TTtk_Side, sticky uint32) (r TTtk_Box) { return XTtk_StickBox(tls, XTtk_PackBox(tls, cavity, width, height, side), width, height, sticky) } /* * Ttk_PositionBox -- * Pack and stick a box according to PositionSpec flags. */ func XTtk_PositionBox(tls *libc.TLS, cavity uintptr, width int32, height int32, flags TTtk_PositionSpec) (r TTtk_Box) { var parcel TTtk_Box _ = parcel if flags&libc.Uint32FromInt32(libc.Int32FromInt32(TTK_EXPAND)) != 0 { parcel = *(*TTtk_Box)(unsafe.Pointer(cavity)) } else { if flags&libc.Uint32FromInt32(libc.Int32FromInt32(TTK_PACK_TOP)) != 0 { parcel = _packTop(tls, cavity, height) } else { if flags&libc.Uint32FromInt32(libc.Int32FromInt32(TTK_PACK_LEFT)) != 0 { parcel = _packLeft(tls, cavity, width) } else { if flags&libc.Uint32FromInt32(libc.Int32FromInt32(TTK_PACK_BOTTOM)) != 0 { parcel = _packBottom(tls, cavity, height) } else { if flags&libc.Uint32FromInt32(libc.Int32FromInt32(TTK_PACK_RIGHT)) != 0 { parcel = _packRight(tls, cavity, width) } else { parcel = *(*TTtk_Box)(unsafe.Pointer(cavity)) } } } } } return XTtk_StickBox(tls, parcel, width, height, flags) } // C documentation // // /* // * TTKInitPadding -- // * Common factor of Ttk_GetPaddingFromObj and Ttk_GetBorderFromObj. // * Initializes Ttk_Padding record, supplying default values // * for missing entries. // */ func _TTKInitPadding(tls *libc.TLS, padc int32, pixels uintptr, pad uintptr) { switch padc { case 0: *(*int32)(unsafe.Pointer(pixels)) = 0 /*FALLTHRU*/ fallthrough case int32(1): *(*int32)(unsafe.Pointer(pixels + 1*4)) = *(*int32)(unsafe.Pointer(pixels)) /*FALLTHRU*/ fallthrough case int32(2): *(*int32)(unsafe.Pointer(pixels + 2*4)) = *(*int32)(unsafe.Pointer(pixels)) /*FALLTHRU*/ fallthrough case int32(3): *(*int32)(unsafe.Pointer(pixels + 3*4)) = *(*int32)(unsafe.Pointer(pixels + 1*4)) /*FALLTHRU*/ } (*TTtk_Padding)(unsafe.Pointer(pad)).Fleft = int16(*(*int32)(unsafe.Pointer(pixels))) (*TTtk_Padding)(unsafe.Pointer(pad)).Ftop = int16(*(*int32)(unsafe.Pointer(pixels + 1*4))) (*TTtk_Padding)(unsafe.Pointer(pad)).Fright = int16(*(*int32)(unsafe.Pointer(pixels + 2*4))) (*TTtk_Padding)(unsafe.Pointer(pad)).Fbottom = int16(*(*int32)(unsafe.Pointer(pixels + 3*4))) } // C documentation // // /* // * Ttk_GetPaddingFromObj -- // * // * Extract a padding specification from a Tcl_Obj * scaled // * to work with a particular Tk_Window. // * // * The string representation of a Ttk_Padding is a list // * of one to four Tk_Pixel specifications, corresponding // * to the left, top, right, and bottom padding. // * // * If the 'bottom' (fourth) element is missing, it defaults to 'top'. // * If the 'right' (third) element is missing, it defaults to 'left'. // * If the 'top' (second) element is missing, it defaults to 'left'. // * // * The internal representation is a Tcl_ListObj containing // * one to four Tk_PixelObj objects. // * // * Returns: // * TCL_OK or TCL_ERROR. In the latter case an error message is // * left in 'interp' and '*paddingPtr' is set to all-zeros. // * Otherwise, *paddingPtr is filled in with the padding specification. // * // */ func XTtk_GetPaddingFromObj(tls *libc.TLS, interp uintptr, tkwin TTk_Window, objPtr uintptr, pad uintptr) (r int32) { bp := tls.Alloc(80) defer tls.Free(80) var i TTcl_Size var v2, v3, v4 int16 var _ /* padc at bp+8 */ TTcl_Size var _ /* padv at bp+0 */ uintptr var _ /* pixels at bp+16 */ [4]int32 _, _, _, _ = i, v2, v3, v4 if TCL_OK != libtcl9_0.XTcl_ListObjGetElements(tls, interp, objPtr, bp+8, bp) { goto error } if *(*TTcl_Size)(unsafe.Pointer(bp + 8)) > int64(4) { if interp != 0 { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+52378, int64(-int32(1)))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+40, __ccgo_ts+51861, __ccgo_ts+182, __ccgo_ts+14240, libc.UintptrFromInt32(0))) } goto error } i = 0 for { if !(i < *(*TTcl_Size)(unsafe.Pointer(bp + 8))) { break } if XTk_GetPixelsFromObj(tls, interp, tkwin, *(*uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp)) + uintptr(i)*8)), bp+16+uintptr(i)*4) != TCL_OK { goto error } goto _1 _1: ; i++ } _TTKInitPadding(tls, int32(*(*TTcl_Size)(unsafe.Pointer(bp + 8))), bp+16, pad) return TCL_OK goto error error: ; v4 = libc.Int16FromInt32(0) (*TTtk_Padding)(unsafe.Pointer(pad)).Fbottom = v4 v3 = v4 (*TTtk_Padding)(unsafe.Pointer(pad)).Fright = v3 v2 = v3 (*TTtk_Padding)(unsafe.Pointer(pad)).Ftop = v2 (*TTtk_Padding)(unsafe.Pointer(pad)).Fleft = v2 return int32(TCL_ERROR) } // C documentation // // /* Ttk_GetBorderFromObj -- // * Same as Ttk_GetPaddingFromObj, except padding is a list of integers // * instead of Tk_Pixel specifications. Does not require a Tk_Window // * parameter. // * // */ func XTtk_GetBorderFromObj(tls *libc.TLS, interp uintptr, objPtr uintptr, pad uintptr) (r int32) { bp := tls.Alloc(80) defer tls.Free(80) var i TTcl_Size var v2, v3, v4 int16 var _ /* padc at bp+8 */ TTcl_Size var _ /* padv at bp+0 */ uintptr var _ /* pixels at bp+16 */ [4]int32 _, _, _, _ = i, v2, v3, v4 if TCL_OK != libtcl9_0.XTcl_ListObjGetElements(tls, interp, objPtr, bp+8, bp) { goto error } if *(*TTcl_Size)(unsafe.Pointer(bp + 8)) > int64(4) { if interp != 0 { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+52378, int64(-int32(1)))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+40, __ccgo_ts+51861, __ccgo_ts+182, __ccgo_ts+52410, libc.UintptrFromInt32(0))) } goto error } i = 0 for { if !(i < *(*TTcl_Size)(unsafe.Pointer(bp + 8))) { break } if libtcl9_0.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp)) + uintptr(i)*8)), bp+16+uintptr(i)*4) != TCL_OK { goto error } goto _1 _1: ; i++ } _TTKInitPadding(tls, int32(*(*TTcl_Size)(unsafe.Pointer(bp + 8))), bp+16, pad) return TCL_OK goto error error: ; v4 = libc.Int16FromInt32(0) (*TTtk_Padding)(unsafe.Pointer(pad)).Fbottom = v4 v3 = v4 (*TTtk_Padding)(unsafe.Pointer(pad)).Fright = v3 v2 = v3 (*TTtk_Padding)(unsafe.Pointer(pad)).Ftop = v2 (*TTtk_Padding)(unsafe.Pointer(pad)).Fleft = v2 return int32(TCL_ERROR) } // C documentation // // /* // * Ttk_MakePadding -- // * Return an initialized Ttk_Padding structure. // */ func XTtk_MakePadding(tls *libc.TLS, left int16, top int16, right int16, bottom int16) (r TTtk_Padding) { var pad TTtk_Padding _ = pad pad.Fleft = left pad.Ftop = top pad.Fright = right pad.Fbottom = bottom return pad } // C documentation // // /* // * Ttk_UniformPadding -- // * Returns a uniform Ttk_Padding structure, with the same // * border width on all sides. // */ func XTtk_UniformPadding(tls *libc.TLS, borderWidth int16) (r TTtk_Padding) { var pad TTtk_Padding var v1, v2, v3 int16 _, _, _, _ = pad, v1, v2, v3 v3 = borderWidth pad.Fbottom = v3 v2 = v3 pad.Fright = v2 v1 = v2 pad.Ftop = v1 pad.Fleft = v1 return pad } // C documentation // // /* // * Ttk_AddPadding -- // * Combine two padding records. // */ func XTtk_AddPadding(tls *libc.TLS, _p1 TTtk_Padding, p2 TTtk_Padding) (r TTtk_Padding) { bp := tls.Alloc(16) defer tls.Free(16) *(*TTtk_Padding)(unsafe.Pointer(bp)) = _p1 var p1, p21, p3, p4 uintptr _, _, _, _ = p1, p21, p3, p4 p1 = bp *(*int16)(unsafe.Pointer(p1)) = int16(int32(*(*int16)(unsafe.Pointer(p1))) + int32(p2.Fleft)) p21 = bp + 2 *(*int16)(unsafe.Pointer(p21)) = int16(int32(*(*int16)(unsafe.Pointer(p21))) + int32(p2.Ftop)) p3 = bp + 4 *(*int16)(unsafe.Pointer(p3)) = int16(int32(*(*int16)(unsafe.Pointer(p3))) + int32(p2.Fright)) p4 = bp + 6 *(*int16)(unsafe.Pointer(p4)) = int16(int32(*(*int16)(unsafe.Pointer(p4))) + int32(p2.Fbottom)) return *(*TTtk_Padding)(unsafe.Pointer(bp)) } // C documentation // // /* Ttk_RelievePadding -- // * Add an extra n pixels of padding according to specified relief. // * This may be used in element geometry procedures to simulate // * a "pressed-in" look for pushbuttons. // */ func XTtk_RelievePadding(tls *libc.TLS, _padding TTtk_Padding, relief int32, n int32) (r TTtk_Padding) { bp := tls.Alloc(16) defer tls.Free(16) *(*TTtk_Padding)(unsafe.Pointer(bp)) = _padding var h1, h2 int32 var p1, p2, p3, p4, p5, p6, p7, p8 uintptr _, _, _, _, _, _, _, _, _, _ = h1, h2, p1, p2, p3, p4, p5, p6, p7, p8 switch relief { case int32(TK_RELIEF_RAISED): p1 = bp + 4 *(*int16)(unsafe.Pointer(p1)) = int16(int32(*(*int16)(unsafe.Pointer(p1))) + n) p2 = bp + 6 *(*int16)(unsafe.Pointer(p2)) = int16(int32(*(*int16)(unsafe.Pointer(p2))) + n) case int32(TK_RELIEF_SUNKEN): /* shift */ p3 = bp *(*int16)(unsafe.Pointer(p3)) = int16(int32(*(*int16)(unsafe.Pointer(p3))) + n) p4 = bp + 2 *(*int16)(unsafe.Pointer(p4)) = int16(int32(*(*int16)(unsafe.Pointer(p4))) + n) default: h1 = n / int32(2) h2 = h1 + n%int32(2) p5 = bp *(*int16)(unsafe.Pointer(p5)) = int16(int32(*(*int16)(unsafe.Pointer(p5))) + h1) p6 = bp + 2 *(*int16)(unsafe.Pointer(p6)) = int16(int32(*(*int16)(unsafe.Pointer(p6))) + h1) p7 = bp + 4 *(*int16)(unsafe.Pointer(p7)) = int16(int32(*(*int16)(unsafe.Pointer(p7))) + h2) p8 = bp + 6 *(*int16)(unsafe.Pointer(p8)) = int16(int32(*(*int16)(unsafe.Pointer(p8))) + h2) break } return *(*TTtk_Padding)(unsafe.Pointer(bp)) } // C documentation // // /* // * Ttk_GetStickyFromObj -- // * Returns a stickiness specification from the specified Tcl_Obj*, // * consisting of any combination of n, s, e, and w. // * // * Returns: TCL_OK if objPtr holds a valid stickiness specification, // * otherwise TCL_ERROR. interp is used for error reporting if non-NULL. // * // */ func XTtk_GetStickyFromObj(tls *libc.TLS, interp uintptr, objPtr uintptr, result uintptr) (r int32) { bp := tls.Alloc(48) defer tls.Free(48) var c, v1 uint8 var sticky TTtk_Sticky var string1, v2 uintptr _, _, _, _, _ = c, sticky, string1, v1, v2 string1 = libtcl9_0.XTcl_GetStringFromObj(tls, objPtr, libc.UintptrFromInt32(0)) sticky = uint32(0) for { v2 = string1 string1++ v1 = *(*uint8)(unsafe.Pointer(v2)) c = v1 if !(libc.Int32FromUint8(v1) != int32('\000')) { break } switch libc.Int32FromUint8(c) { case int32('w'): fallthrough case int32('W'): sticky |= libc.Uint32FromInt32(libc.Int32FromInt32(TTK_STICK_W)) case int32('e'): fallthrough case int32('E'): sticky |= libc.Uint32FromInt32(libc.Int32FromInt32(TTK_STICK_E)) case int32('n'): fallthrough case int32('N'): sticky |= libc.Uint32FromInt32(libc.Int32FromInt32(TTK_STICK_N)) case int32('s'): fallthrough case int32('S'): sticky |= libc.Uint32FromInt32(libc.Int32FromInt32(TTK_STICK_S)) default: if interp != 0 { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+52417, libc.VaList(bp+8, libtcl9_0.XTcl_GetStringFromObj(tls, objPtr, libc.UintptrFromInt32(0))))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+8, __ccgo_ts+51861, __ccgo_ts+182, __ccgo_ts+13542, libc.UintptrFromInt32(0))) } return int32(TCL_ERROR) } } *(*TTtk_Sticky)(unsafe.Pointer(result)) = sticky return TCL_OK } // C documentation // // /* Ttk_NewStickyObj -- // * Construct a new Tcl_Obj * containing a stickiness specification. // */ func XTtk_NewStickyObj(tls *libc.TLS, sticky TTtk_Sticky) (r uintptr) { bp := tls.Alloc(16) defer tls.Free(16) var p, v1, v2, v3, v4 uintptr var _ /* buf at bp+0 */ [5]uint8 _, _, _, _, _ = p, v1, v2, v3, v4 p = bp if sticky&libc.Uint32FromInt32(libc.Int32FromInt32(TTK_STICK_N)) != 0 { v1 = p p++ *(*uint8)(unsafe.Pointer(v1)) = uint8('n') } if sticky&libc.Uint32FromInt32(libc.Int32FromInt32(TTK_STICK_S)) != 0 { v2 = p p++ *(*uint8)(unsafe.Pointer(v2)) = uint8('s') } if sticky&libc.Uint32FromInt32(libc.Int32FromInt32(TTK_STICK_W)) != 0 { v3 = p p++ *(*uint8)(unsafe.Pointer(v3)) = uint8('w') } if sticky&libc.Uint32FromInt32(libc.Int32FromInt32(TTK_STICK_E)) != 0 { v4 = p p++ *(*uint8)(unsafe.Pointer(v4)) = uint8('e') } *(*uint8)(unsafe.Pointer(p)) = uint8('\000') return libtcl9_0.XTcl_NewStringObj(tls, bp, int64(p)-T__predefined_ptrdiff_t(bp)) } /*------------------------------------------------------------------------ * +++ Layout nodes. */ type TTtk_LayoutNode = struct { Fflags uint32 Feclass uintptr Fstate TTtk_State Fparcel TTtk_Box Fnext uintptr Fchild uintptr } func _Ttk_NewLayoutNode(tls *libc.TLS, flags uint32, elementClass uintptr) (r uintptr) { var node, v1 uintptr _, _ = node, v1 node = libtcl9_0.XTcl_Alloc(tls, uint64(56)) (*TTtk_LayoutNode)(unsafe.Pointer(node)).Fflags = flags (*TTtk_LayoutNode)(unsafe.Pointer(node)).Feclass = elementClass (*TTtk_LayoutNode)(unsafe.Pointer(node)).Fstate = 0 v1 = libc.UintptrFromInt32(0) (*TTtk_LayoutNode)(unsafe.Pointer(node)).Fchild = v1 (*TTtk_LayoutNode)(unsafe.Pointer(node)).Fnext = v1 (*TTtk_LayoutNode)(unsafe.Pointer(node)).Fparcel = XTtk_MakeBox(tls, 0, 0, 0, 0) return node } func _Ttk_FreeLayoutNode(tls *libc.TLS, node uintptr) { var next uintptr _ = next for node != 0 { next = (*TTtk_LayoutNode)(unsafe.Pointer(node)).Fnext _Ttk_FreeLayoutNode(tls, (*TTtk_LayoutNode)(unsafe.Pointer(node)).Fchild) libtcl9_0.XTcl_Free(tls, node) node = next } } func _Ttk_NewTemplateNode(tls *libc.TLS, name uintptr, flags uint32) (r uintptr) { var op, v1 uintptr _, _ = op, v1 op = libtcl9_0.XTcl_Alloc(tls, uint64(32)) (*TTtk_TemplateNode)(unsafe.Pointer(op)).Fname = libtcl9_0.XTcl_Alloc(tls, libc.Xstrlen(tls, name)+uint64(1)) libc.Xstrcpy(tls, (*TTtk_TemplateNode)(unsafe.Pointer(op)).Fname, name) (*TTtk_TemplateNode)(unsafe.Pointer(op)).Fflags = flags v1 = libc.UintptrFromInt32(0) (*TTtk_TemplateNode)(unsafe.Pointer(op)).Fchild = v1 (*TTtk_TemplateNode)(unsafe.Pointer(op)).Fnext = v1 return op } func XTtk_FreeLayoutTemplate(tls *libc.TLS, op TTtk_LayoutTemplate) { var next TTtk_LayoutTemplate _ = next for op != 0 { next = (*TTtk_TemplateNode_)(unsafe.Pointer(op)).Fnext XTtk_FreeLayoutTemplate(tls, (*TTtk_TemplateNode_)(unsafe.Pointer(op)).Fchild) libtcl9_0.XTcl_Free(tls, (*TTtk_TemplateNode_)(unsafe.Pointer(op)).Fname) libtcl9_0.XTcl_Free(tls, op) op = next } } // C documentation // // /* InstantiateLayout -- // * Create a layout tree from a template. // */ func _Ttk_InstantiateLayout(tls *libc.TLS, theme TTtk_Theme, op uintptr) (r uintptr) { var elementClass, node uintptr _, _ = elementClass, node elementClass = XTtk_GetElement(tls, theme, (*TTtk_TemplateNode)(unsafe.Pointer(op)).Fname) node = _Ttk_NewLayoutNode(tls, (*TTtk_TemplateNode)(unsafe.Pointer(op)).Fflags, elementClass) if (*TTtk_TemplateNode)(unsafe.Pointer(op)).Fnext != 0 { (*TTtk_LayoutNode)(unsafe.Pointer(node)).Fnext = _Ttk_InstantiateLayout(tls, theme, (*TTtk_TemplateNode)(unsafe.Pointer(op)).Fnext) } if (*TTtk_TemplateNode)(unsafe.Pointer(op)).Fchild != 0 { (*TTtk_LayoutNode)(unsafe.Pointer(node)).Fchild = _Ttk_InstantiateLayout(tls, theme, (*TTtk_TemplateNode)(unsafe.Pointer(op)).Fchild) } return node } /* * Ttk_ParseLayoutTemplate -- * Convert a Tcl list into a layout template. * * Syntax: * layoutSpec ::= { elementName ?-option value ...? }+ */ // C documentation // // /* NB: This must match bit definitions TTK_PACK_LEFT etc. */ var _packSideStrings = [5]uintptr{ 0: __ccgo_ts + 10966, 1: __ccgo_ts + 10971, 2: __ccgo_ts + 15106, 3: __ccgo_ts + 15099, 4: libc.UintptrFromInt32(0), } func XTtk_ParseLayoutTemplate(tls *libc.TLS, interp uintptr, objPtr uintptr) (r TTtk_LayoutTemplate) { bp := tls.Alloc(80) defer tls.Free(80) var childSpec, elementName, head, optName, tail, v2 uintptr var flags uint32 var i, v1 TTcl_Size var _ /* objc at bp+0 */ TTcl_Size var _ /* objv at bp+8 */ uintptr var _ /* option at bp+20 */ int32 var _ /* sticky at bp+16 */ uint32 var _ /* value at bp+24 */ int32 _, _, _, _, _, _, _, _, _ = childSpec, elementName, flags, head, i, optName, tail, v1, v2 i = 0 head = uintptr(0) tail = uintptr(0) if libtcl9_0.XTcl_ListObjGetElements(tls, interp, objPtr, bp, bp+8) != TCL_OK { return uintptr(0) } for i < *(*TTcl_Size)(unsafe.Pointer(bp)) { elementName = libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 8)) + uintptr(i)*8)), libc.UintptrFromInt32(0)) flags = uint32(0x0) *(*uint32)(unsafe.Pointer(bp + 16)) = libc.Uint32FromInt32(libc.Int32FromInt32(TTK_FILL_BOTH)) childSpec = uintptr(0) /* * Parse options: */ i++ for i < *(*TTcl_Size)(unsafe.Pointer(bp)) { optName = libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 8)) + uintptr(i)*8)), libc.UintptrFromInt32(0)) if libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(optName))) != int32('-') { break } if libtcl9_0.XTcl_GetIndexFromObjStruct(tls, interp, *(*uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 8)) + uintptr(i)*8)), uintptr(unsafe.Pointer(&_optStrings1)), libc.Int64FromUint64(libc.Uint64FromInt64(8)), __ccgo_ts+2689, libc.Int32FromInt32(0)|libc.Int32FromUint64(libc.Uint64FromInt64(4)<= *(*TTcl_Size)(unsafe.Pointer(bp)) { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+52462, libc.VaList(bp+40, libtcl9_0.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 8)) + uintptr(i-int64(1))*8)), libc.UintptrFromInt32(0))))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+40, __ccgo_ts+51861, __ccgo_ts+182, __ccgo_ts+52490, libc.UintptrFromInt32(0))) goto error } switch *(*int32)(unsafe.Pointer(bp + 20)) { case 0: /* <> */ if libtcl9_0.XTcl_GetIndexFromObjStruct(tls, interp, *(*uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 8)) + uintptr(i)*8)), uintptr(unsafe.Pointer(&_packSideStrings)), libc.Int64FromUint64(libc.Uint64FromInt64(8)), __ccgo_ts+15353, libc.Int32FromInt32(0)|libc.Int32FromUint64(libc.Uint64FromInt64(4)<> * @@@ NOTES: Ick. */ if flags&libc.Uint32FromInt32(libc.Int32FromInt32(TTK_EXPAND)) != 0 { libtcl9_0.XTcl_ListObjAppendElement(tls, libc.UintptrFromInt32(0), result, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+15176, int64(-int32(1)))) libtcl9_0.XTcl_ListObjAppendElement(tls, libc.UintptrFromInt32(0), result, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+14538, int64(-int32(1)))) } else { if flags&libc.Uint32FromInt32(libc.Int32FromInt32(_TTK_MASK_PACK)) != 0 { side = 0 sideFlags = flags & libc.Uint32FromInt32(libc.Int32FromInt32(_TTK_MASK_PACK)) for !(sideFlags&libc.Uint32FromInt32(libc.Int32FromInt32(TTK_PACK_LEFT)) != 0) { side++ sideFlags >>= uint32(1) } libtcl9_0.XTcl_ListObjAppendElement(tls, libc.UintptrFromInt32(0), result, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+15195, int64(-int32(1)))) libtcl9_0.XTcl_ListObjAppendElement(tls, libc.UintptrFromInt32(0), result, libtcl9_0.XTcl_NewStringObj(tls, _packSideStrings[side], int64(-int32(1)))) } } /* * In Ttk_ParseLayoutTemplate, default -sticky is "nsew", so always * include this even if no sticky bits are set. */ libtcl9_0.XTcl_ListObjAppendElement(tls, libc.UintptrFromInt32(0), result, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+12332, int64(-int32(1)))) libtcl9_0.XTcl_ListObjAppendElement(tls, libc.UintptrFromInt32(0), result, XTtk_NewStickyObj(tls, flags&libc.Uint32FromInt32(libc.Int32FromInt32(_TTK_MASK_STICK)))) /* @@@ Check again: are these necessary? Can't see any effect! */ if flags&libc.Uint32FromInt32(libc.Int32FromInt32(TTK_BORDER)) != 0 { libtcl9_0.XTcl_ListObjAppendElement(tls, libc.UintptrFromInt32(0), result, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+52238, int64(-int32(1)))) libtcl9_0.XTcl_ListObjAppendElement(tls, libc.UintptrFromInt32(0), result, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+14538, int64(-int32(1)))) } if flags&libc.Uint32FromInt32(libc.Int32FromInt32(TTK_UNIT)) != 0 { libtcl9_0.XTcl_ListObjAppendElement(tls, libc.UintptrFromInt32(0), result, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+52446, int64(-int32(1)))) libtcl9_0.XTcl_ListObjAppendElement(tls, libc.UintptrFromInt32(0), result, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+14538, int64(-int32(1)))) } if (*TTtk_TemplateNode)(unsafe.Pointer(node)).Fchild != 0 { libtcl9_0.XTcl_ListObjAppendElement(tls, libc.UintptrFromInt32(0), result, libtcl9_0.XTcl_NewStringObj(tls, __ccgo_ts+52452, int64(-int32(1)))) libtcl9_0.XTcl_ListObjAppendElement(tls, libc.UintptrFromInt32(0), result, XTtk_UnparseLayoutTemplate(tls, (*TTtk_TemplateNode)(unsafe.Pointer(node)).Fchild)) } node = (*TTtk_TemplateNode)(unsafe.Pointer(node)).Fnext } return result } func _TTKNewLayout(tls *libc.TLS, style TTtk_Style, recordPtr uintptr, optionTable TTk_OptionTable, tkwin TTk_Window, root uintptr) (r TTtk_Layout) { var layout TTtk_Layout _ = layout layout = libtcl9_0.XTcl_Alloc(tls, uint64(40)) (*TTtk_Layout_)(unsafe.Pointer(layout)).Fstyle = style (*TTtk_Layout_)(unsafe.Pointer(layout)).FrecordPtr = recordPtr (*TTtk_Layout_)(unsafe.Pointer(layout)).FoptionTable = optionTable (*TTtk_Layout_)(unsafe.Pointer(layout)).Ftkwin = tkwin (*TTtk_Layout_)(unsafe.Pointer(layout)).Froot = root return layout } func XTtk_FreeLayout(tls *libc.TLS, layout TTtk_Layout) { _Ttk_FreeLayoutNode(tls, (*TTtk_Layout_)(unsafe.Pointer(layout)).Froot) libtcl9_0.XTcl_Free(tls, layout) } // C documentation // // /* // * Ttk_CreateLayout -- // * Create a layout from the specified theme and style name. // * Returns: New layout, 0 on error. // * Leaves an error message in interp's result if there is an error. // */ func XTtk_CreateLayout(tls *libc.TLS, interp uintptr, themePtr TTtk_Theme, styleName uintptr, recordPtr uintptr, optionTable TTk_OptionTable, tkwin TTk_Window) (r TTtk_Layout) { bp := tls.Alloc(48) defer tls.Free(48) var bgelement, bgnode uintptr var layoutTemplate TTtk_LayoutTemplate var style TTtk_Style _, _, _, _ = bgelement, bgnode, layoutTemplate, style style = XTtk_GetStyle(tls, themePtr, styleName) layoutTemplate = XTtk_FindLayoutTemplate(tls, themePtr, styleName) bgelement = XTtk_GetElement(tls, themePtr, __ccgo_ts+19910) if !(layoutTemplate != 0) { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+52530, libc.VaList(bp+8, styleName))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+8, __ccgo_ts+51861, __ccgo_ts+3058, __ccgo_ts+52490, styleName, libc.UintptrFromInt32(0))) return uintptr(0) } bgnode = _Ttk_NewLayoutNode(tls, libc.Uint32FromInt32(libc.Int32FromInt32(TTK_FILL_BOTH)), bgelement) (*TTtk_LayoutNode)(unsafe.Pointer(bgnode)).Fnext = _Ttk_InstantiateLayout(tls, themePtr, layoutTemplate) return _TTKNewLayout(tls, style, recordPtr, optionTable, tkwin, bgnode) } // C documentation // // /* Ttk_CreateSublayout -- // * Creates a new sublayout. // * // * Sublayouts are used to draw subparts of a compound widget. // * They use the same Tk_Window, but a different option table // * and data record. // */ func XTtk_CreateSublayout(tls *libc.TLS, interp uintptr, themePtr TTtk_Theme, parentLayout TTtk_Layout, baseName uintptr, optionTable TTk_OptionTable) (r TTtk_Layout) { bp := tls.Alloc(272) defer tls.Free(272) var layoutTemplate TTtk_LayoutTemplate var style TTtk_Style var styleName uintptr var _ /* buf at bp+0 */ TTcl_DString _, _, _ = layoutTemplate, style, styleName libtcl9_0.XTcl_DStringInit(tls, bp) libtcl9_0.XTcl_DStringAppend(tls, bp, XTtk_StyleName(tls, (*TTtk_Layout_)(unsafe.Pointer(parentLayout)).Fstyle), int64(-libc.Int32FromInt32(1))) libtcl9_0.XTcl_DStringAppend(tls, bp, baseName, int64(-libc.Int32FromInt32(1))) styleName = (*TTcl_DString)(unsafe.Pointer(bp)).Fstring1 style = XTtk_GetStyle(tls, themePtr, styleName) layoutTemplate = XTtk_FindLayoutTemplate(tls, themePtr, styleName) if !(layoutTemplate != 0) { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+52530, libc.VaList(bp+232, styleName))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+232, __ccgo_ts+51861, __ccgo_ts+3058, __ccgo_ts+52490, styleName, libc.UintptrFromInt32(0))) return uintptr(0) } libtcl9_0.XTcl_DStringFree(tls, bp) return _TTKNewLayout(tls, style, uintptr(0), optionTable, (*TTtk_Layout_)(unsafe.Pointer(parentLayout)).Ftkwin, _Ttk_InstantiateLayout(tls, themePtr, layoutTemplate)) } // C documentation // // /* Ttk_RebindSublayout -- // * Bind sublayout to new data source. // */ func XTtk_RebindSublayout(tls *libc.TLS, layout TTtk_Layout, recordPtr uintptr) { (*TTtk_Layout_)(unsafe.Pointer(layout)).FrecordPtr = recordPtr } // C documentation // // /* // * Ttk_QueryOption -- // * Look up an option from a layout's associated option. // */ func XTtk_QueryOption(tls *libc.TLS, layout TTtk_Layout, optionName uintptr, state TTtk_State) (r uintptr) { return XTtk_QueryStyle(tls, (*TTtk_Layout_)(unsafe.Pointer(layout)).Fstyle, (*TTtk_Layout_)(unsafe.Pointer(layout)).FrecordPtr, (*TTtk_Layout_)(unsafe.Pointer(layout)).FoptionTable, optionName, state) } // C documentation // // /* // * Ttk_LayoutStyle -- // * Extract Ttk_Style from Ttk_Layout. // */ func XTtk_LayoutStyle(tls *libc.TLS, layout TTtk_Layout) (r TTtk_Style) { return (*TTtk_Layout_)(unsafe.Pointer(layout)).Fstyle } /* Forward */ func _Ttk_NodeSize(tls *libc.TLS, layout TTtk_Layout, node uintptr, state TTtk_State, widthPtr uintptr, heightPtr uintptr, paddingPtr uintptr) { bp := tls.Alloc(32) defer tls.Free(32) var v1, v2 int32 var _ /* elementHeight at bp+4 */ int32 var _ /* elementPadding at bp+16 */ TTtk_Padding var _ /* elementWidth at bp+0 */ int32 var _ /* subHeight at bp+12 */ int32 var _ /* subWidth at bp+8 */ int32 _, _ = v1, v2 XTtk_ElementSize(tls, (*TTtk_LayoutNode)(unsafe.Pointer(node)).Feclass, (*TTtk_Layout_)(unsafe.Pointer(layout)).Fstyle, (*TTtk_Layout_)(unsafe.Pointer(layout)).FrecordPtr, (*TTtk_Layout_)(unsafe.Pointer(layout)).FoptionTable, (*TTtk_Layout_)(unsafe.Pointer(layout)).Ftkwin, state|(*TTtk_LayoutNode)(unsafe.Pointer(node)).Fstate, bp, bp+4, bp+16) _Ttk_NodeListSize(tls, layout, (*TTtk_LayoutNode)(unsafe.Pointer(node)).Fchild, state, bp+8, bp+12) *(*int32)(unsafe.Pointer(bp + 8)) += int32((*(*TTtk_Padding)(unsafe.Pointer(bp + 16))).Fleft) + int32((*(*TTtk_Padding)(unsafe.Pointer(bp + 16))).Fright) *(*int32)(unsafe.Pointer(bp + 12)) += int32((*(*TTtk_Padding)(unsafe.Pointer(bp + 16))).Ftop) + int32((*(*TTtk_Padding)(unsafe.Pointer(bp + 16))).Fbottom) if *(*int32)(unsafe.Pointer(bp)) > *(*int32)(unsafe.Pointer(bp + 8)) { v1 = *(*int32)(unsafe.Pointer(bp)) } else { v1 = *(*int32)(unsafe.Pointer(bp + 8)) } *(*int32)(unsafe.Pointer(widthPtr)) = v1 if *(*int32)(unsafe.Pointer(bp + 4)) > *(*int32)(unsafe.Pointer(bp + 12)) { v2 = *(*int32)(unsafe.Pointer(bp + 4)) } else { v2 = *(*int32)(unsafe.Pointer(bp + 12)) } *(*int32)(unsafe.Pointer(heightPtr)) = v2 *(*TTtk_Padding)(unsafe.Pointer(paddingPtr)) = *(*TTtk_Padding)(unsafe.Pointer(bp + 16)) } func _Ttk_NodeListSize(tls *libc.TLS, layout TTtk_Layout, node uintptr, state TTtk_State, widthPtr uintptr, heightPtr uintptr) { bp := tls.Alloc(32) defer tls.Free(32) var v1, v2, v3 int32 var _ /* height at bp+4 */ int32 var _ /* restHeight at bp+12 */ int32 var _ /* restWidth at bp+8 */ int32 var _ /* unused at bp+16 */ TTtk_Padding var _ /* width at bp+0 */ int32 _, _, _ = v1, v2, v3 if !(node != 0) { v1 = libc.Int32FromInt32(0) *(*int32)(unsafe.Pointer(heightPtr)) = v1 *(*int32)(unsafe.Pointer(widthPtr)) = v1 } else { _Ttk_NodeSize(tls, layout, node, state, bp, bp+4, bp+16) _Ttk_NodeListSize(tls, layout, (*TTtk_LayoutNode)(unsafe.Pointer(node)).Fnext, state, bp+8, bp+12) if (*TTtk_LayoutNode)(unsafe.Pointer(node)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(TTK_PACK_LEFT)|libc.Int32FromInt32(TTK_PACK_RIGHT)) != 0 { *(*int32)(unsafe.Pointer(widthPtr)) = *(*int32)(unsafe.Pointer(bp)) + *(*int32)(unsafe.Pointer(bp + 8)) } else { if *(*int32)(unsafe.Pointer(bp)) > *(*int32)(unsafe.Pointer(bp + 8)) { v2 = *(*int32)(unsafe.Pointer(bp)) } else { v2 = *(*int32)(unsafe.Pointer(bp + 8)) } *(*int32)(unsafe.Pointer(widthPtr)) = v2 } if (*TTtk_LayoutNode)(unsafe.Pointer(node)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(TTK_PACK_TOP)|libc.Int32FromInt32(TTK_PACK_BOTTOM)) != 0 { *(*int32)(unsafe.Pointer(heightPtr)) = *(*int32)(unsafe.Pointer(bp + 4)) + *(*int32)(unsafe.Pointer(bp + 12)) } else { if *(*int32)(unsafe.Pointer(bp + 4)) > *(*int32)(unsafe.Pointer(bp + 12)) { v3 = *(*int32)(unsafe.Pointer(bp + 4)) } else { v3 = *(*int32)(unsafe.Pointer(bp + 12)) } *(*int32)(unsafe.Pointer(heightPtr)) = v3 } } } // C documentation // // /* // * Ttk_LayoutNodeInternalPadding -- // * Returns the internal padding of a layout node. // */ func XTtk_LayoutNodeInternalPadding(tls *libc.TLS, layout TTtk_Layout, node uintptr) (r TTtk_Padding) { bp := tls.Alloc(16) defer tls.Free(16) var _ /* padding at bp+8 */ TTtk_Padding var _ /* unused at bp+0 */ int32 XTtk_ElementSize(tls, (*TTtk_LayoutNode)(unsafe.Pointer(node)).Feclass, (*TTtk_Layout_)(unsafe.Pointer(layout)).Fstyle, (*TTtk_Layout_)(unsafe.Pointer(layout)).FrecordPtr, (*TTtk_Layout_)(unsafe.Pointer(layout)).FoptionTable, (*TTtk_Layout_)(unsafe.Pointer(layout)).Ftkwin, uint32(0), bp, bp, bp+8) return *(*TTtk_Padding)(unsafe.Pointer(bp + 8)) } // C documentation // // /* // * Ttk_LayoutNodeInternalParcel -- // * Returns the inner area of a specified layout node, // * based on current parcel and element's internal padding. // */ func XTtk_LayoutNodeInternalParcel(tls *libc.TLS, layout TTtk_Layout, node uintptr) (r TTtk_Box) { var padding TTtk_Padding _ = padding padding = XTtk_LayoutNodeInternalPadding(tls, layout, node) return XTtk_PadBox(tls, (*TTtk_LayoutNode)(unsafe.Pointer(node)).Fparcel, padding) } // C documentation // // /* Ttk_LayoutSize -- // * Compute requested size of a layout. // */ func XTtk_LayoutSize(tls *libc.TLS, layout TTtk_Layout, state TTtk_State, widthPtr uintptr, heightPtr uintptr) { _Ttk_NodeListSize(tls, layout, (*TTtk_Layout_)(unsafe.Pointer(layout)).Froot, state, widthPtr, heightPtr) } func XTtk_LayoutNodeReqSize(tls *libc.TLS, layout TTtk_Layout, node uintptr, widthPtr uintptr, heightPtr uintptr) { bp := tls.Alloc(16) defer tls.Free(16) var _ /* unused at bp+0 */ TTtk_Padding _Ttk_NodeSize(tls, layout, node, uint32(0), widthPtr, heightPtr, bp) } /*------------------------------------------------------------------------ * +++ Layout placement. */ // C documentation // // /* Ttk_PlaceNodeList -- // * Compute parcel for each node in a layout tree // * according to position specification and overall size. // */ func _Ttk_PlaceNodeList(tls *libc.TLS, layout TTtk_Layout, node uintptr, state TTtk_State, _cavity TTtk_Box) { bp := tls.Alloc(32) defer tls.Free(32) *(*TTtk_Box)(unsafe.Pointer(bp)) = _cavity var childBox TTtk_Box var _ /* height at bp+20 */ int32 var _ /* padding at bp+24 */ TTtk_Padding var _ /* width at bp+16 */ int32 _ = childBox for { if !(node != 0) { break } /* Compute node size: (@@@ cache this instead?) */ _Ttk_NodeSize(tls, layout, node, state, bp+16, bp+20, bp+24) /* Compute parcel: */ (*TTtk_LayoutNode)(unsafe.Pointer(node)).Fparcel = XTtk_PositionBox(tls, bp, *(*int32)(unsafe.Pointer(bp + 16)), *(*int32)(unsafe.Pointer(bp + 20)), (*TTtk_LayoutNode)(unsafe.Pointer(node)).Fflags) /* Place child nodes: */ if (*TTtk_LayoutNode)(unsafe.Pointer(node)).Fchild != 0 { childBox = XTtk_PadBox(tls, (*TTtk_LayoutNode)(unsafe.Pointer(node)).Fparcel, *(*TTtk_Padding)(unsafe.Pointer(bp + 24))) _Ttk_PlaceNodeList(tls, layout, (*TTtk_LayoutNode)(unsafe.Pointer(node)).Fchild, state, childBox) } goto _1 _1: ; node = (*TTtk_LayoutNode)(unsafe.Pointer(node)).Fnext } } func XTtk_PlaceLayout(tls *libc.TLS, layout TTtk_Layout, state TTtk_State, b TTtk_Box) { _Ttk_PlaceNodeList(tls, layout, (*TTtk_Layout_)(unsafe.Pointer(layout)).Froot, state, b) } /*------------------------------------------------------------------------ * +++ Layout drawing. */ // C documentation // // /* // * Ttk_DrawLayout -- // * Draw a layout tree. // */ func _Ttk_DrawNodeList(tls *libc.TLS, layout TTtk_Layout, state TTtk_State, node uintptr, d TDrawable) { var border, substate int32 _, _ = border, substate for { if !(node != 0) { break } border = libc.Int32FromUint32((*TTtk_LayoutNode)(unsafe.Pointer(node)).Fflags & libc.Uint32FromInt32(libc.Int32FromInt32(TTK_BORDER))) substate = libc.Int32FromUint32(state) if (*TTtk_LayoutNode)(unsafe.Pointer(node)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(TTK_UNIT)) != 0 { substate = int32(uint32(substate) | (*TTtk_LayoutNode)(unsafe.Pointer(node)).Fstate) } if (*TTtk_LayoutNode)(unsafe.Pointer(node)).Fchild != 0 && border != 0 { _Ttk_DrawNodeList(tls, layout, libc.Uint32FromInt32(substate), (*TTtk_LayoutNode)(unsafe.Pointer(node)).Fchild, d) } XTtk_DrawElement(tls, (*TTtk_LayoutNode)(unsafe.Pointer(node)).Feclass, (*TTtk_Layout_)(unsafe.Pointer(layout)).Fstyle, (*TTtk_Layout_)(unsafe.Pointer(layout)).FrecordPtr, (*TTtk_Layout_)(unsafe.Pointer(layout)).FoptionTable, (*TTtk_Layout_)(unsafe.Pointer(layout)).Ftkwin, d, (*TTtk_LayoutNode)(unsafe.Pointer(node)).Fparcel, state|(*TTtk_LayoutNode)(unsafe.Pointer(node)).Fstate) if (*TTtk_LayoutNode)(unsafe.Pointer(node)).Fchild != 0 && !(border != 0) { _Ttk_DrawNodeList(tls, layout, libc.Uint32FromInt32(substate), (*TTtk_LayoutNode)(unsafe.Pointer(node)).Fchild, d) } goto _1 _1: ; node = (*TTtk_LayoutNode)(unsafe.Pointer(node)).Fnext } } func XTtk_DrawLayout(tls *libc.TLS, layout TTtk_Layout, state TTtk_State, d TDrawable) { _Ttk_DrawNodeList(tls, layout, state, (*TTtk_Layout_)(unsafe.Pointer(layout)).Froot, d) } /*------------------------------------------------------------------------ * +++ Inquiry and modification. */ // C documentation // // /* // * Ttk_IdentifyElement -- // * Find the element at the specified x,y coordinate. // */ func _IdentifyNode(tls *libc.TLS, node TTtk_Element, x int32, y int32) (r TTtk_Element) { var childNode, closest TTtk_Element _, _ = childNode, closest closest = libc.UintptrFromInt32(0) for { if !(node != 0) { break } if XTtk_BoxContains(tls, (*TTtk_LayoutNode_)(unsafe.Pointer(node)).Fparcel, x, y) != 0 { closest = node if (*TTtk_LayoutNode_)(unsafe.Pointer(node)).Fchild != 0 && !((*TTtk_LayoutNode_)(unsafe.Pointer(node)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(TTK_UNIT)) != 0) { childNode = _IdentifyNode(tls, (*TTtk_LayoutNode_)(unsafe.Pointer(node)).Fchild, x, y) if childNode != 0 { closest = childNode } } } goto _1 _1: ; node = (*TTtk_LayoutNode_)(unsafe.Pointer(node)).Fnext } return closest } func XTtk_IdentifyElement(tls *libc.TLS, layout TTtk_Layout, x int32, y int32) (r TTtk_Element) { return _IdentifyNode(tls, (*TTtk_Layout_)(unsafe.Pointer(layout)).Froot, x, y) } // C documentation // // /* // * tail -- // * Return the last component of an element name, e.g., // * "Scrollbar.thumb" => "thumb" // */ func _tail(tls *libc.TLS, elementName uintptr) (r uintptr) { var dot, v1 uintptr _, _ = dot, v1 for { v1 = libc.Xstrchr(tls, elementName, int32('.')) dot = v1 if !(v1 != libc.UintptrFromInt32(0)) { break } elementName = dot + uintptr(1) } return elementName } // C documentation // // /* // * Ttk_FindElement -- // * Look up an element by name // */ func _FindNode(tls *libc.TLS, node TTtk_Element, nodeName uintptr) (r TTtk_Element) { var childNode TTtk_Element _ = childNode for { if !(node != 0) { break } if !(libc.Xstrcmp(tls, _tail(tls, XTtk_ElementName(tls, node)), nodeName) != 0) { return node } if (*TTtk_LayoutNode_)(unsafe.Pointer(node)).Fchild != 0 { childNode = _FindNode(tls, (*TTtk_LayoutNode_)(unsafe.Pointer(node)).Fchild, nodeName) if childNode != 0 { return childNode } } goto _1 _1: ; node = (*TTtk_LayoutNode_)(unsafe.Pointer(node)).Fnext } return uintptr(0) } func XTtk_FindElement(tls *libc.TLS, layout TTtk_Layout, nodeName uintptr) (r TTtk_Element) { return _FindNode(tls, (*TTtk_Layout_)(unsafe.Pointer(layout)).Froot, nodeName) } // C documentation // // /* // * Ttk_ClientRegion -- // * Find the internal parcel of a named element within a given layout. // * If the element is not present, use the entire window. // */ func XTtk_ClientRegion(tls *libc.TLS, layout TTtk_Layout, elementName uintptr) (r TTtk_Box) { var element TTtk_Element var v1 TTtk_Box _, _ = element, v1 element = XTtk_FindElement(tls, layout, elementName) if element != 0 { v1 = XTtk_LayoutNodeInternalParcel(tls, layout, element) } else { v1 = XTtk_MakeBox(tls, 0, 0, (*TTk_FakeWin)(unsafe.Pointer((*TTtk_Layout_)(unsafe.Pointer(layout)).Ftkwin)).Fchanges.Fwidth, (*TTk_FakeWin)(unsafe.Pointer((*TTtk_Layout_)(unsafe.Pointer(layout)).Ftkwin)).Fchanges.Fheight) } return v1 } // C documentation // // /* // * Ttk_ElementName -- // * Return the name (class name) of the element. // */ func XTtk_ElementName(tls *libc.TLS, node TTtk_Element) (r uintptr) { return XTtk_ElementClassName(tls, (*TTtk_LayoutNode_)(unsafe.Pointer(node)).Feclass) } // C documentation // // /* // * Ttk_ElementParcel -- // * Return the element's current parcel. // */ func XTtk_ElementParcel(tls *libc.TLS, node TTtk_Element) (r TTtk_Box) { return (*TTtk_LayoutNode_)(unsafe.Pointer(node)).Fparcel } // C documentation // // /* // * Ttk_PlaceElement -- // * Explicitly specify an element's parcel. // */ func XTtk_PlaceElement(tls *libc.TLS, layout TTtk_Layout, node TTtk_Element, b TTtk_Box) { (*TTtk_LayoutNode_)(unsafe.Pointer(node)).Fparcel = b if (*TTtk_LayoutNode_)(unsafe.Pointer(node)).Fchild != 0 { _Ttk_PlaceNodeList(tls, layout, (*TTtk_LayoutNode_)(unsafe.Pointer(node)).Fchild, uint32(0), XTtk_PadBox(tls, b, XTtk_LayoutNodeInternalPadding(tls, layout, node))) } } // C documentation // // /* // * AnchorToPosition -- // * Convert a Tk_Anchor enum to a position bitmask. // */ func _AnchorToPosition(tls *libc.TLS, anchor TTk_Anchor) (r TTtk_PositionSpec) { switch anchor { case int32(TK_ANCHOR_N): return libc.Uint32FromInt32(libc.Int32FromInt32(TTK_PACK_TOP)) case int32(TK_ANCHOR_S): return libc.Uint32FromInt32(libc.Int32FromInt32(TTK_PACK_BOTTOM)) case int32(TK_ANCHOR_NE): return libc.Uint32FromInt32(libc.Int32FromInt32(TTK_PACK_RIGHT) | libc.Int32FromInt32(TTK_STICK_N)) case int32(TK_ANCHOR_SE): return libc.Uint32FromInt32(libc.Int32FromInt32(TTK_PACK_RIGHT) | libc.Int32FromInt32(TTK_STICK_S)) case int32(TK_ANCHOR_E): return libc.Uint32FromInt32(libc.Int32FromInt32(TTK_PACK_RIGHT)) case int32(TK_ANCHOR_NW): return libc.Uint32FromInt32(libc.Int32FromInt32(TTK_PACK_LEFT) | libc.Int32FromInt32(TTK_STICK_N)) case int32(TK_ANCHOR_SW): return libc.Uint32FromInt32(libc.Int32FromInt32(TTK_PACK_LEFT) | libc.Int32FromInt32(TTK_STICK_S)) case int32(TK_ANCHOR_W): return libc.Uint32FromInt32(libc.Int32FromInt32(TTK_PACK_LEFT)) case int32(TK_ANCHOR_CENTER): return uint32(0) default: } return libc.Uint32FromInt32(libc.Int32FromInt32(TTK_PACK_LEFT)) } // C documentation // // /* // * Ttk_AnchorElement -- // * Explicitly specify an element's anchoring. // */ func XTtk_AnchorElement(tls *libc.TLS, node TTtk_Element, anchor TTk_Anchor) { (*TTtk_LayoutNode_)(unsafe.Pointer(node)).Fflags = _AnchorToPosition(tls, anchor) } // C documentation // // /* // * Ttk_ChangeElementState -- // */ func XTtk_ChangeElementState(tls *libc.TLS, node uintptr, set uint32, clr uint32) { (*TTtk_LayoutNode)(unsafe.Pointer(node)).Fstate = ((*TTtk_LayoutNode)(unsafe.Pointer(node)).Fstate | set) & ^clr } const CONTENT_MAPPED = 1 const MGR_RELAYOUT_REQUIRED = 4 const MGR_RESIZE_REQUIRED = 2 const MGR_UPDATE_PENDING = 1 type TTtk_Manager = struct { FmanagerSpec uintptr FmanagerData uintptr Fwindow TTk_Window Fflags uint32 FnContent TTcl_Size Fcontent uintptr } type TTtkManager_ = TTtk_Manager /* Returns: 1 if container can manage content; 0 otherwise leaving error msg */ /*------------------------------------------------------------------------ * +++ The Geometry Propagation Dance. * * When a content window requests a new size or some other parameter changes, * the manager recomputes the required size for the container window and calls * Tk_GeometryRequest(). This is scheduled as an idle handler so multiple * updates can be processed as a single batch. * * If all goes well, the container's manager will process the request * (and so on up the chain to the toplevel window), and the container * window will eventually receive a event. At this point * it recomputes the size and position of all content windows and places them. * * If all does not go well, however, the container's request may be ignored * (typically because the top-level window has a fixed, user-specified size). * Tk doesn't provide any notification when this happens; to account for this, * we also schedule an idle handler to call the layout procedure * after making a geometry request. * * +++ Content window removal <>. * * There are three conditions under which a content window is removed: * * (1) Another GM claims control * (2) Manager voluntarily relinquishes control * (3) Content window is destroyed * * In case (1), Tk calls the manager's lostContentProc. * Case (2) is performed by calling Tk_ManageGeometry(window,NULL,0); * in this case Tk does _not_ call the lostContentProc (documented behavior). * Tk doesn't handle case (3) either; to account for that we * register an event handler on the content window to track events. */ // C documentation // // /* ++ Data structures. // */ type TTtk_Content = struct { Fwindow TTk_Window Fmanager uintptr Fdata uintptr Fflags uint32 } /* forward */ // C documentation // // /* ++ ScheduleUpdate -- // * Schedule a call to recompute the size and/or layout, // * depending on flags. // */ func _ScheduleUpdate(tls *libc.TLS, mgr uintptr, flags uint32) { if !((*TTtk_Manager)(unsafe.Pointer(mgr)).Fflags&libc.Uint32FromInt32(MGR_UPDATE_PENDING) != 0) { libtcl9_0.XTcl_DoWhenIdle(tls, __ccgo_fp(_ManagerIdleProc), mgr) *(*uint32)(unsafe.Pointer(mgr + 24)) |= uint32(MGR_UPDATE_PENDING) } *(*uint32)(unsafe.Pointer(mgr + 24)) |= flags } // C documentation // // /* ++ RecomputeSize -- // * Recomputes the required size of the container window, // * makes geometry request. // */ func _RecomputeSize(tls *libc.TLS, mgr uintptr) { bp := tls.Alloc(16) defer tls.Free(16) var _ /* height at bp+4 */ int32 var _ /* width at bp+0 */ int32 *(*int32)(unsafe.Pointer(bp)) = int32(1) *(*int32)(unsafe.Pointer(bp + 4)) = int32(1) if (*(*func(*libc.TLS, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*TTtk_ManagerSpec)(unsafe.Pointer((*TTtk_Manager)(unsafe.Pointer(mgr)).FmanagerSpec)).FRequestedSize})))(tls, (*TTtk_Manager)(unsafe.Pointer(mgr)).FmanagerData, bp, bp+4) != 0 { XTk_GeometryRequest(tls, (*TTtk_Manager)(unsafe.Pointer(mgr)).Fwindow, *(*int32)(unsafe.Pointer(bp)), *(*int32)(unsafe.Pointer(bp + 4))) _ScheduleUpdate(tls, mgr, uint32(MGR_RELAYOUT_REQUIRED)) } *(*uint32)(unsafe.Pointer(mgr + 24)) &= libc.Uint32FromInt32(^libc.Int32FromInt32(MGR_RESIZE_REQUIRED)) } // C documentation // // /* ++ RecomputeLayout -- // * Recompute geometry of all content windows. // */ func _RecomputeLayout(tls *libc.TLS, mgr uintptr) { (*(*func(*libc.TLS, uintptr))(unsafe.Pointer(&struct{ uintptr }{(*TTtk_ManagerSpec)(unsafe.Pointer((*TTtk_Manager)(unsafe.Pointer(mgr)).FmanagerSpec)).FPlaceContent})))(tls, (*TTtk_Manager)(unsafe.Pointer(mgr)).FmanagerData) *(*uint32)(unsafe.Pointer(mgr + 24)) &= libc.Uint32FromInt32(^libc.Int32FromInt32(MGR_RELAYOUT_REQUIRED)) } // C documentation // // /* ++ ManagerIdleProc -- // * DoWhenIdle procedure for deferred updates. // */ func _ManagerIdleProc(tls *libc.TLS, clientData uintptr) { var mgr uintptr _ = mgr mgr = clientData *(*uint32)(unsafe.Pointer(mgr + 24)) &= libc.Uint32FromInt32(^libc.Int32FromInt32(MGR_UPDATE_PENDING)) if (*TTtk_Manager)(unsafe.Pointer(mgr)).Fflags&uint32(MGR_RESIZE_REQUIRED) != 0 { _RecomputeSize(tls, mgr) } if (*TTtk_Manager)(unsafe.Pointer(mgr)).Fflags&uint32(MGR_RELAYOUT_REQUIRED) != 0 { if (*TTtk_Manager)(unsafe.Pointer(mgr)).Fflags&uint32(MGR_UPDATE_PENDING) != 0 { /* RecomputeSize has scheduled another update; relayout later */ return } _RecomputeLayout(tls, mgr) } } /*------------------------------------------------------------------------ * +++ Event handlers. */ // C documentation // // /* ++ ManagerEventHandler -- // * Recompute content layout when container widget is resized. // * Keep the content's map state in sync with the container's. // */ var _ManagerEventMask = int32(libc.Int64FromInt64(1) << libc.Int32FromInt32(17)) func _ManagerEventHandler(tls *libc.TLS, clientData uintptr, eventPtr uintptr) { var content, content1, mgr uintptr var i TTcl_Size _, _, _, _ = content, content1, i, mgr mgr = clientData switch (*TXEvent)(unsafe.Pointer(eventPtr)).Ftype1 { case int32(ConfigureNotify): goto _1 case int32(MapNotify): goto _2 case int32(UnmapNotify): goto _3 } goto _4 _1: ; _RecomputeLayout(tls, mgr) goto _4 _2: ; i = 0 _7: ; if !(i < (*TTtk_Manager)(unsafe.Pointer(mgr)).FnContent) { goto _5 } content = *(*uintptr)(unsafe.Pointer((*TTtk_Manager)(unsafe.Pointer(mgr)).Fcontent + uintptr(i)*8)) if (*TTtk_Content)(unsafe.Pointer(content)).Fflags&uint32(CONTENT_MAPPED) != 0 { XTk_MapWindow(tls, (*TTtk_Content)(unsafe.Pointer(content)).Fwindow) } goto _6 _6: ; i++ goto _7 goto _5 _5: ; goto _4 _3: ; i = 0 for { if !(i < (*TTtk_Manager)(unsafe.Pointer(mgr)).FnContent) { break } content1 = *(*uintptr)(unsafe.Pointer((*TTtk_Manager)(unsafe.Pointer(mgr)).Fcontent + uintptr(i)*8)) XTk_UnmapWindow(tls, (*TTtk_Content)(unsafe.Pointer(content1)).Fwindow) goto _8 _8: ; i++ } goto _4 _4: } // C documentation // // /* ++ ContentLostEventHandler -- // * Notifies manager when a content window is destroyed // * (see <>). // */ func _ContentLostEventHandler(tls *libc.TLS, clientData uintptr, eventPtr uintptr) { var content uintptr _ = content content = clientData if (*TXEvent)(unsafe.Pointer(eventPtr)).Ftype1 == int32(DestroyNotify) { (*(*func(*libc.TLS, uintptr, TTk_Window))(unsafe.Pointer(&struct{ uintptr }{(*TTtk_ManagerSpec)(unsafe.Pointer((*TTtk_Manager)(unsafe.Pointer((*TTtk_Content)(unsafe.Pointer(content)).Fmanager)).FmanagerSpec)).FtkGeomMgr.FlostContentProc})))(tls, (*TTtk_Content)(unsafe.Pointer(content)).Fmanager, (*TTtk_Content)(unsafe.Pointer(content)).Fwindow) } } /*------------------------------------------------------------------------ * +++ Content initialization and cleanup. */ func _NewContent(tls *libc.TLS, mgr uintptr, window TTk_Window, data uintptr) (r uintptr) { var content uintptr _ = content content = libtcl9_0.XTcl_Alloc(tls, uint64(32)) (*TTtk_Content)(unsafe.Pointer(content)).Fwindow = window (*TTtk_Content)(unsafe.Pointer(content)).Fmanager = mgr (*TTtk_Content)(unsafe.Pointer(content)).Fflags = uint32(0) (*TTtk_Content)(unsafe.Pointer(content)).Fdata = data return content } func _DeleteContent(tls *libc.TLS, content uintptr) { libtcl9_0.XTcl_Free(tls, content) } /*------------------------------------------------------------------------ * +++ Manager initialization and cleanup. */ func XTtk_CreateManager(tls *libc.TLS, managerSpec uintptr, managerData uintptr, window TTk_Window) (r uintptr) { var mgr uintptr _ = mgr mgr = libtcl9_0.XTcl_Alloc(tls, uint64(48)) (*TTtk_Manager)(unsafe.Pointer(mgr)).FmanagerSpec = managerSpec (*TTtk_Manager)(unsafe.Pointer(mgr)).FmanagerData = managerData (*TTtk_Manager)(unsafe.Pointer(mgr)).Fwindow = window (*TTtk_Manager)(unsafe.Pointer(mgr)).FnContent = 0 (*TTtk_Manager)(unsafe.Pointer(mgr)).Fcontent = libc.UintptrFromInt32(0) (*TTtk_Manager)(unsafe.Pointer(mgr)).Fflags = uint32(0) XTk_CreateEventHandler(tls, (*TTtk_Manager)(unsafe.Pointer(mgr)).Fwindow, libc.Uint64FromInt32(_ManagerEventMask), __ccgo_fp(_ManagerEventHandler), mgr) return mgr } func XTtk_DeleteManager(tls *libc.TLS, mgr uintptr) { XTk_DeleteEventHandler(tls, (*TTtk_Manager)(unsafe.Pointer(mgr)).Fwindow, libc.Uint64FromInt32(_ManagerEventMask), __ccgo_fp(_ManagerEventHandler), mgr) for (*TTtk_Manager)(unsafe.Pointer(mgr)).FnContent > 0 { XTtk_ForgetContent(tls, mgr, (*TTtk_Manager)(unsafe.Pointer(mgr)).FnContent-int64(1)) } if (*TTtk_Manager)(unsafe.Pointer(mgr)).Fcontent != 0 { libtcl9_0.XTcl_Free(tls, (*TTtk_Manager)(unsafe.Pointer(mgr)).Fcontent) } libtcl9_0.XTcl_CancelIdleCall(tls, __ccgo_fp(_ManagerIdleProc), mgr) libtcl9_0.XTcl_Free(tls, mgr) } /*------------------------------------------------------------------------ * +++ Content window management. */ // C documentation // // /* ++ InsertContent -- // * Adds content to the list of managed windows. // */ func _InsertContent(tls *libc.TLS, mgr uintptr, content uintptr, index TTcl_Size) { var endIndex, v1 TTcl_Size var v2 uintptr _, _, _ = endIndex, v1, v2 v2 = mgr + 32 v1 = *(*TTcl_Size)(unsafe.Pointer(v2)) *(*TTcl_Size)(unsafe.Pointer(v2))++ endIndex = v1 (*TTtk_Manager)(unsafe.Pointer(mgr)).Fcontent = libtcl9_0.XTcl_Realloc(tls, (*TTtk_Manager)(unsafe.Pointer(mgr)).Fcontent, libc.Uint64FromInt64((*TTtk_Manager)(unsafe.Pointer(mgr)).FnContent)*uint64(8)) for endIndex > index { *(*uintptr)(unsafe.Pointer((*TTtk_Manager)(unsafe.Pointer(mgr)).Fcontent + uintptr(endIndex)*8)) = *(*uintptr)(unsafe.Pointer((*TTtk_Manager)(unsafe.Pointer(mgr)).Fcontent + uintptr(endIndex-int64(1))*8)) endIndex-- } *(*uintptr)(unsafe.Pointer((*TTtk_Manager)(unsafe.Pointer(mgr)).Fcontent + uintptr(index)*8)) = content XTk_ManageGeometry(tls, (*TTtk_Content)(unsafe.Pointer(content)).Fwindow, (*TTtk_Manager)(unsafe.Pointer(mgr)).FmanagerSpec, mgr) XTk_CreateEventHandler(tls, (*TTtk_Content)(unsafe.Pointer(content)).Fwindow, libc.Uint64FromInt64(libc.Int64FromInt64(1)<= 0 { reqWidth = (*TTk_FakeWin)(unsafe.Pointer(window)).FreqWidth reqHeight = (*TTk_FakeWin)(unsafe.Pointer(window)).FreqHeight if (*(*func(*libc.TLS, uintptr, TTcl_Size, int32, int32) int32)(unsafe.Pointer(&struct{ uintptr }{(*TTtk_ManagerSpec)(unsafe.Pointer((*TTtk_Manager)(unsafe.Pointer(mgr)).FmanagerSpec)).FContentRequest})))(tls, (*TTtk_Manager)(unsafe.Pointer(mgr)).FmanagerData, index, reqWidth, reqHeight) != 0 { _ScheduleUpdate(tls, mgr, uint32(MGR_RESIZE_REQUIRED)) } } } func XTtk_LostContentProc(tls *libc.TLS, clientData uintptr, window TTk_Window) { var index TTcl_Size var mgr uintptr _, _ = index, mgr mgr = clientData index = XTtk_ContentIndex(tls, mgr, window) /* ASSERT: index >= 0 */ _RemoveContent(tls, mgr, index) } /*------------------------------------------------------------------------ * +++ Public API. */ // C documentation // // /* ++ Ttk_InsertContent -- // * Add a new content window at the specified index. // */ func XTtk_InsertContent(tls *libc.TLS, mgr uintptr, index TTcl_Size, tkwin TTk_Window, data uintptr) { var content uintptr _ = content content = _NewContent(tls, mgr, tkwin, data) _InsertContent(tls, mgr, content, index) } // C documentation // // /* ++ Ttk_ForgetContent -- // * Unmanage the specified content window. // */ func XTtk_ForgetContent(tls *libc.TLS, mgr uintptr, index TTcl_Size) { var window TTk_Window _ = window window = (*TTtk_Content)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer((*TTtk_Manager)(unsafe.Pointer(mgr)).Fcontent + uintptr(index)*8)))).Fwindow _RemoveContent(tls, mgr, index) XTk_ManageGeometry(tls, window, libc.UintptrFromInt32(0), uintptr(0)) } // C documentation // // /* ++ Ttk_PlaceContent -- // * Set the position and size of the specified content window. // * // * NOTES: // * Contrary to documentation, Tk_MaintainGeometry doesn't always // * map the content window. // */ func XTtk_PlaceContent(tls *libc.TLS, mgr uintptr, index TTcl_Size, x int32, y int32, width int32, height int32) { var content uintptr _ = content content = *(*uintptr)(unsafe.Pointer((*TTtk_Manager)(unsafe.Pointer(mgr)).Fcontent + uintptr(index)*8)) XTk_MaintainGeometry(tls, (*TTtk_Content)(unsafe.Pointer(content)).Fwindow, (*TTtk_Manager)(unsafe.Pointer(mgr)).Fwindow, x, y, width, height) *(*uint32)(unsafe.Pointer(content + 24)) |= uint32(CONTENT_MAPPED) if (*TTk_FakeWin)(unsafe.Pointer((*TTtk_Manager)(unsafe.Pointer(mgr)).Fwindow)).Fflags&uint32(TK_MAPPED) != 0 { XTk_MapWindow(tls, (*TTtk_Content)(unsafe.Pointer(content)).Fwindow) } } // C documentation // // /* ++ Ttk_UnmapContent -- // * Unmap the specified content window, but leave it managed. // */ func XTtk_UnmapContent(tls *libc.TLS, mgr uintptr, index TTcl_Size) { var content uintptr _ = content content = *(*uintptr)(unsafe.Pointer((*TTtk_Manager)(unsafe.Pointer(mgr)).Fcontent + uintptr(index)*8)) XTk_UnmaintainGeometry(tls, (*TTtk_Content)(unsafe.Pointer(content)).Fwindow, (*TTtk_Manager)(unsafe.Pointer(mgr)).Fwindow) *(*uint32)(unsafe.Pointer(content + 24)) &= libc.Uint32FromInt32(^libc.Int32FromInt32(CONTENT_MAPPED)) /* Contrary to documentation, Tk_UnmaintainGeometry doesn't always * unmap the content window: */ XTk_UnmapWindow(tls, (*TTtk_Content)(unsafe.Pointer(content)).Fwindow) } // C documentation // // /* LayoutChanged, SizeChanged -- // * Schedule a relayout, resp. resize request. // */ func XTtk_ManagerLayoutChanged(tls *libc.TLS, mgr uintptr) { _ScheduleUpdate(tls, mgr, uint32(MGR_RELAYOUT_REQUIRED)) } func XTtk_ManagerSizeChanged(tls *libc.TLS, mgr uintptr) { _ScheduleUpdate(tls, mgr, uint32(MGR_RESIZE_REQUIRED)) } // C documentation // // /* +++ Accessors. // */ func XTtk_NumberContent(tls *libc.TLS, mgr uintptr) (r TTcl_Size) { return (*TTtk_Manager)(unsafe.Pointer(mgr)).FnContent } func XTtk_ContentData(tls *libc.TLS, mgr uintptr, index TTcl_Size) (r uintptr) { return (*TTtk_Content)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer((*TTtk_Manager)(unsafe.Pointer(mgr)).Fcontent + uintptr(index)*8)))).Fdata } func XTtk_ContentWindow(tls *libc.TLS, mgr uintptr, index TTcl_Size) (r TTk_Window) { return (*TTtk_Content)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer((*TTtk_Manager)(unsafe.Pointer(mgr)).Fcontent + uintptr(index)*8)))).Fwindow } /*------------------------------------------------------------------------ * +++ Utility routines. */ // C documentation // // /* ++ Ttk_ContentIndex -- // * Returns the index of specified content window, TCL_INDEX_NONE if not found. // */ func XTtk_ContentIndex(tls *libc.TLS, mgr uintptr, window TTk_Window) (r TTcl_Size) { var index TTcl_Size _ = index index = 0 for { if !(index < (*TTtk_Manager)(unsafe.Pointer(mgr)).FnContent) { break } if (*TTtk_Content)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer((*TTtk_Manager)(unsafe.Pointer(mgr)).Fcontent + uintptr(index)*8)))).Fwindow == window { return index } goto _1 _1: ; index++ } return int64(-int32(1)) } /* ++ Ttk_GetContentIndexFromObj(interp, mgr, objPtr, lastOK, indexPtr) -- * Return the index of the content window specified by objPtr. * Content windows may be specified as an integer index or * as the name of the managed window. * * The parameter lastOK should be non-0 if the resolved index can be equal to * the current size (i.e. one more than the current highest index) and 0 * otherwise. * * Returns: * Standard Tcl completion code. Leaves an error message in case of error. */ func XTtk_GetContentIndexFromObj(tls *libc.TLS, interp uintptr, mgr uintptr, objPtr uintptr, lastOK int32, indexPtr uintptr) (r int32) { bp := tls.Alloc(48) defer tls.Free(48) var string1 uintptr var tkwin, v1 TTk_Window var v2 bool var _ /* index at bp+0 */ TTcl_Size _, _, _, _ = string1, tkwin, v1, v2 string1 = libtcl9_0.XTcl_GetStringFromObj(tls, objPtr, libc.UintptrFromInt32(0)) *(*TTcl_Size)(unsafe.Pointer(bp)) = 0 /* Try interpreting as an integer first: */ if XTkGetIntForIndex(tls, objPtr, (*TTtk_Manager)(unsafe.Pointer(mgr)).FnContent-int64(1), lastOK, bp) == TCL_OK { /* * Note despite passing lastOK above, we still need to check here * as well as TkGetIntForIndex only uses lastOK for end-relative indices, * not integers. */ if *(*TTcl_Size)(unsafe.Pointer(bp)) < 0 || *(*TTcl_Size)(unsafe.Pointer(bp))-libc.BoolInt64(!!(lastOK != 0)) >= (*TTtk_Manager)(unsafe.Pointer(mgr)).FnContent { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+52550, libc.VaList(bp+16, libtcl9_0.XTcl_GetStringFromObj(tls, objPtr, libc.UintptrFromInt32(0))))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+16, __ccgo_ts+51861, __ccgo_ts+52590, __ccgo_ts+5789, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) } *(*TTcl_Size)(unsafe.Pointer(indexPtr)) = *(*TTcl_Size)(unsafe.Pointer(bp)) return TCL_OK } /* Try interpreting as a window name; */ if v2 = libc.Int32FromUint8(*(*uint8)(unsafe.Pointer(string1))) == int32('.'); v2 { v1 = XTk_NameToWindow(tls, interp, string1, (*TTtk_Manager)(unsafe.Pointer(mgr)).Fwindow) tkwin = v1 } if v2 && v1 != 0 { *(*TTcl_Size)(unsafe.Pointer(bp)) = XTtk_ContentIndex(tls, mgr, tkwin) if *(*TTcl_Size)(unsafe.Pointer(bp)) < 0 { libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+52598, libc.VaList(bp+16, string1, (*TTk_FakeWin)(unsafe.Pointer((*TTtk_Manager)(unsafe.Pointer(mgr)).Fwindow)).FpathName))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+16, __ccgo_ts+51861, __ccgo_ts+52590, __ccgo_ts+52622, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) } *(*TTcl_Size)(unsafe.Pointer(indexPtr)) = *(*TTcl_Size)(unsafe.Pointer(bp)) return TCL_OK } libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+52630, libc.VaList(bp+16, string1))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+16, __ccgo_ts+51861, __ccgo_ts+52590, __ccgo_ts+52233, libc.UintptrFromInt32(0))) return int32(TCL_ERROR) } // C documentation // // /* ++ Ttk_ReorderContent(mgr, fromIndex, toIndex) -- // * Change content window order. // */ func XTtk_ReorderContent(tls *libc.TLS, mgr uintptr, fromIndex TTcl_Size, toIndex TTcl_Size) { var moved uintptr _ = moved moved = *(*uintptr)(unsafe.Pointer((*TTtk_Manager)(unsafe.Pointer(mgr)).Fcontent + uintptr(fromIndex)*8)) /* Shuffle down: */ for fromIndex > toIndex { *(*uintptr)(unsafe.Pointer((*TTtk_Manager)(unsafe.Pointer(mgr)).Fcontent + uintptr(fromIndex)*8)) = *(*uintptr)(unsafe.Pointer((*TTtk_Manager)(unsafe.Pointer(mgr)).Fcontent + uintptr(fromIndex-int64(1))*8)) fromIndex-- } /* Or, shuffle up: */ for fromIndex < toIndex { *(*uintptr)(unsafe.Pointer((*TTtk_Manager)(unsafe.Pointer(mgr)).Fcontent + uintptr(fromIndex)*8)) = *(*uintptr)(unsafe.Pointer((*TTtk_Manager)(unsafe.Pointer(mgr)).Fcontent + uintptr(fromIndex+int64(1))*8)) fromIndex++ } /* ASSERT: fromIndex == toIndex */ *(*uintptr)(unsafe.Pointer((*TTtk_Manager)(unsafe.Pointer(mgr)).Fcontent + uintptr(fromIndex)*8)) = moved /* Schedule a relayout. In general, rearranging content * may also change the size: */ _ScheduleUpdate(tls, mgr, uint32(MGR_RESIZE_REQUIRED)) } // C documentation // // /* ++ Ttk_Maintainable(interp, window, container) -- // * Utility routine. Verifies that 'container' may be used to maintain // * the geometry of 'window' via Tk_MaintainGeometry: // * // * + 'container' is either 'window's parent -OR- // * + 'container is a descendant of 'window's parent. // * + 'window' is not a toplevel window // * + 'window' belongs to the same toplevel as 'container' // * // * Returns: 1 if OK; otherwise 0, leaving an error message in 'interp'. // */ func XTtk_Maintainable(tls *libc.TLS, interp uintptr, window TTk_Window, container TTk_Window) (r int32) { bp := tls.Alloc(48) defer tls.Free(48) var ancestor, parent TTk_Window _, _ = ancestor, parent ancestor = container parent = (*TTk_FakeWin)(unsafe.Pointer(window)).FparentPtr if (*TTk_FakeWin)(unsafe.Pointer(window)).Fflags&uint32(TK_TOP_LEVEL) != 0 || window == container { goto badWindow } for ancestor != parent { if (*TTk_FakeWin)(unsafe.Pointer(ancestor)).Fflags&uint32(TK_TOP_LEVEL) != 0 { goto badWindow } ancestor = (*TTk_FakeWin)(unsafe.Pointer(ancestor)).FparentPtr } return int32(1) goto badWindow badWindow: ; libtcl9_0.XTcl_SetObjResult(tls, interp, libtcl9_0.XTcl_ObjPrintf(tls, __ccgo_ts+52670, libc.VaList(bp+8, (*TTk_FakeWin)(unsafe.Pointer(window)).FpathName, (*TTk_FakeWin)(unsafe.Pointer(container)).FpathName))) libtcl9_0.XTcl_SetErrorCode(tls, interp, libc.VaList(bp+8, __ccgo_ts+51861, __ccgo_ts+11660, __ccgo_ts+52705, libc.UintptrFromInt32(0))) return 0 } const DEFAULT_MIN_TAB_WIDTH = 24 /* Returns: 1 if container can manage content; 0 otherwise leaving error msg */ /*------------------------------------------------------------------------ * +++ Tab resources. */ var _TabStateStrings = [4]uintptr{ 0: __ccgo_ts + 16715, 1: __ccgo_ts + 16731, 2: __ccgo_ts + 9363, } type TTAB_STATE = int32 const TAB_STATE_DISABLED = 0 const TAB_STATE_HIDDEN = 1 const TAB_STATE_NORMAL = 2 type TTab = struct { Fwidth int32 Fheight int32 Fparcel TTtk_Box Fstate TTAB_STATE FpaddingObj uintptr Fpadding TTtk_Padding FstickyObj uintptr Fsticky TTtk_Sticky FtextObj uintptr FimageObj uintptr FcompoundObj uintptr FunderlineObj uintptr } // C documentation // // /* Two different option tables are used for tabs: // * TabOptionSpecs is used to draw the tab, and only includes resources // * relevant to the tab. // * // * PaneOptionSpecs includes additional options for child window placement // * and is used to configure the pane. // */ var _TabOptionSpecs = [6]TTk_OptionSpec{ 0: { Ftype1: int32(TK_OPTION_STRING_TABLE), FoptionName: __ccgo_ts + 2957, FdbName: __ccgo_ts + 195, FdbClass: __ccgo_ts + 195, FdefValue: __ccgo_ts + 9363, FobjOffset: int64(-libc.Int32FromInt32(1)), FinternalOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 24)), FclientData: uintptr(unsafe.Pointer(&_TabStateStrings)), }, 1: { Ftype1: int32(TK_OPTION_STRING), FoptionName: __ccgo_ts + 20398, FdbName: __ccgo_ts + 17996, FdbClass: __ccgo_ts + 20404, FdefValue: __ccgo_ts + 195, FobjOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 64)), FinternalOffset: int64(-libc.Int32FromInt32(1)), FtypeMask: int32(GEOMETRY_CHANGED), }, 2: { Ftype1: int32(TK_OPTION_STRING), FoptionName: __ccgo_ts + 20294, FdbName: __ccgo_ts + 17810, FdbClass: __ccgo_ts + 20301, FobjOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 72)), FinternalOffset: int64(-libc.Int32FromInt32(1)), Fflags: int32(TCL_NULL_OK), FtypeMask: int32(GEOMETRY_CHANGED), }, 3: { Ftype1: int32(TK_OPTION_STRING_TABLE), FoptionName: __ccgo_ts + 19976, FdbName: __ccgo_ts + 19986, FdbClass: __ccgo_ts + 19995, FobjOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 80)), FinternalOffset: int64(-libc.Int32FromInt32(1)), Fflags: int32(TCL_NULL_OK), FclientData: uintptr(unsafe.Pointer(&XttkCompoundStrings)), FtypeMask: int32(GEOMETRY_CHANGED), }, 4: { Ftype1: int32(TK_OPTION_INDEX), FoptionName: __ccgo_ts + 9507, FdbName: __ccgo_ts + 9388, FdbClass: __ccgo_ts + 20445, FobjOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 88)), FinternalOffset: int64(-libc.Int32FromInt32(1)), Fflags: int32(TCL_NULL_OK), FtypeMask: int32(GEOMETRY_CHANGED), }, 5: { Ftype1: int32(TK_OPTION_END), }, } var _PaneOptionSpecs = [3]TTk_OptionSpec{ 0: { Ftype1: int32(TK_OPTION_STRING), FoptionName: __ccgo_ts + 49128, FdbName: __ccgo_ts + 49137, FdbClass: __ccgo_ts + 52718, FdefValue: __ccgo_ts + 10533, FobjOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 32)), FinternalOffset: int64(-libc.Int32FromInt32(1)), FtypeMask: int32(GEOMETRY_CHANGED), }, 1: { Ftype1: int32(TK_OPTION_STRING), FoptionName: __ccgo_ts + 12332, FdbName: __ccgo_ts + 24997, FdbClass: __ccgo_ts + 52726, FdefValue: __ccgo_ts + 25398, FobjOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 48)), FinternalOffset: int64(-libc.Int32FromInt32(1)), FtypeMask: int32(GEOMETRY_CHANGED), }, 2: { Ftype1: int32(TK_OPTION_END), FobjOffset: int64(-libc.Int32FromInt32(1)), FinternalOffset: int64(-libc.Int32FromInt32(1)), FclientData: uintptr(unsafe.Pointer(&_TabOptionSpecs)), }, } // C documentation // // /*------------------------------------------------------------------------ // * +++ Notebook resources. // */ type TNotebookPart = struct { FwidthObj uintptr FheightObj uintptr FpaddingObj uintptr Fmgr uintptr FtabOptionTable TTk_OptionTable FpaneOptionTable TTk_OptionTable FcurrentIndex TTcl_Size FactiveIndex TTcl_Size FtabLayout TTtk_Layout FclientArea TTtk_Box } type TNotebook = struct { Fcore TWidgetCore Fnotebook TNotebookPart } var _NotebookOptionSpecs = [5]TTk_OptionSpec{ 0: { Ftype1: int32(TK_OPTION_PIXELS), FoptionName: __ccgo_ts + 2987, FdbName: __ccgo_ts + 6446, FdbClass: __ccgo_ts + 20455, FdefValue: __ccgo_ts + 10533, FobjOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 88)), FinternalOffset: int64(-libc.Int32FromInt32(1)), FtypeMask: int32(GEOMETRY_CHANGED), }, 1: { Ftype1: int32(TK_OPTION_PIXELS), FoptionName: __ccgo_ts + 2870, FdbName: __ccgo_ts + 6172, FdbClass: __ccgo_ts + 20122, FdefValue: __ccgo_ts + 10533, FobjOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 88 + 8)), FinternalOffset: int64(-libc.Int32FromInt32(1)), FtypeMask: int32(GEOMETRY_CHANGED), }, 2: { Ftype1: int32(TK_OPTION_STRING), FoptionName: __ccgo_ts + 49128, FdbName: __ccgo_ts + 49137, FdbClass: __ccgo_ts + 52718, FobjOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 88 + 16)), FinternalOffset: int64(-libc.Int32FromInt32(1)), Fflags: int32(TCL_NULL_OK), FtypeMask: int32(GEOMETRY_CHANGED), }, 3: { Ftype1: int32(TK_OPTION_STRING), FoptionName: __ccgo_ts + 20367, FdbName: __ccgo_ts + 20378, FdbClass: __ccgo_ts + 20388, FdefValue: __ccgo_ts + 49241, FobjOffset: libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0) + 48)), FinternalOffset: int64(-libc.Int32FromInt32(1)), }, 4: { Ftype1: int32(TK_OPTION_END), FobjOffset: int64(-libc.Int32FromInt32(1)), FinternalOffset: int64(-libc.Int32FromInt32(1)), FclientData: uintptr(unsafe.Pointer(&XttkCoreOptionSpecs)), }, } // C documentation // // /* Notebook style options: // */ type TNotebookStyle = struct { FtabPosition TTtk_PositionSpec FtabMargins TTtk_Padding FtabPlacement TTtk_PositionSpec FtabOrient TTtk_Orient FminTabWidth int32 Fpadding TTtk_Padding } func _NotebookStyleOptions(tls *libc.TLS, nb uintptr, nbstyle uintptr, tkwin TTk_Window) { var mainInfoPtr, objPtr, v1, v2, v3, v4, v5 uintptr _, _, _, _, _, _, _ = mainInfoPtr, objPtr, v1, v2, v3, v4, v5 mainInfoPtr = (*TTkWindow)(unsafe.Pointer(tkwin)).FmainPtr (*TNotebookStyle)(unsafe.Pointer(nbstyle)).FtabPosition = libc.Uint32FromInt32(libc.Int32FromInt32(TTK_PACK_TOP) | libc.Int32FromInt32(TTK_STICK_W)) v1 = XTtk_QueryOption(tls, (*TNotebook)(unsafe.Pointer(nb)).Fcore.Flayout, __ccgo_ts+52733, uint32(0)) objPtr = v1 if v1 != uintptr(0) { XTtkGetLabelAnchorFromObj(tls, libc.UintptrFromInt32(0), objPtr, nbstyle) } /* Guess default tabPlacement as function of tabPosition: */ if (*TNotebookStyle)(unsafe.Pointer(nbstyle)).FtabPosition&libc.Uint32FromInt32(libc.Int32FromInt32(TTK_PACK_LEFT)) != 0 { (*TNotebookStyle)(unsafe.Pointer(nbstyle)).FtabPlacement = libc.Uint32FromInt32(libc.Int32FromInt32(TTK_PACK_TOP) | libc.Int32FromInt32(TTK_STICK_E)) } else { if (*TNotebookStyle)(unsafe.Pointer(nbstyle)).FtabPosition&libc.Uint32FromInt32(libc.Int32FromInt32(TTK_PACK_RIGHT)) != 0 { (*TNotebookStyle)(unsafe.Pointer(nbstyle)).FtabPlacement = libc.Uint32FromInt32(libc.Int32FromInt32(TTK_PACK_TOP) | libc.Int32FromInt32(TTK_STICK_W)) } else { if (*TNotebookStyle)(unsafe.Pointer(nbstyle)).FtabPosition&libc.Uint32FromInt32(libc.Int32FromInt32(TTK_PACK_BOTTOM)) != 0 { (*TNotebookStyle)(unsafe.Pointer(nbstyle)).FtabPlacement = libc.Uint32FromInt32(libc.Int32FromInt32(TTK_PACK_LEFT) | libc.Int32FromInt32(TTK_STICK_N)) } else { /* Assume TTK_PACK_TOP */ (*TNotebookStyle)(unsafe.Pointer(nbstyle)).FtabPlacement = libc.Uint32FromInt32(libc.Int32FromInt32(TTK_PACK_LEFT) | libc.Int32FromInt32(TTK_STICK_S)) } } } v2 = XTtk_QueryOption(tls, (*TNotebook)(unsafe.Pointer(nb)).Fcore.Flayout, __ccgo_ts+52746, uint32(0)) objPtr = v2 if v2 != uintptr(0) { XTtkGetLabelAnchorFromObj(tls, libc.UintptrFromInt32(0), objPtr, nbstyle+12) } /* Save the stick bit for later. One of the values * TTK_STICK_S, TTK_STICK_N, TTK_STICK_E, or TTK_STICK_W: */ if mainInfoPtr != libc.UintptrFromInt32(0) { (*TTkMainInfo)(unsafe.Pointer(mainInfoPtr)).FttkNbTabsStickBit = (*TNotebookStyle)(unsafe.Pointer(nbstyle)).FtabPlacement & uint32(0x0f) } /* Compute tabOrient as function of tabPlacement: */ if (*TNotebookStyle)(unsafe.Pointer(nbstyle)).FtabPlacement&libc.Uint32FromInt32(libc.Int32FromInt32(TTK_PACK_LEFT)|libc.Int32FromInt32(TTK_PACK_RIGHT)) != 0 { (*TNotebookStyle)(unsafe.Pointer(nbstyle)).FtabOrient = int32(TTK_ORIENT_HORIZONTAL) } else { (*TNotebookStyle)(unsafe.Pointer(nbstyle)).FtabOrient = int32(TTK_ORIENT_VERTICAL) } (*TNotebookStyle)(unsafe.Pointer(nbstyle)).FtabMargins = XTtk_UniformPadding(tls, 0) v3 = XTtk_QueryOption(tls, (*TNotebook)(unsafe.Pointer(nb)).Fcore.Flayout, __ccgo_ts+52760, uint32(0)) objPtr = v3 if v3 != uintptr(0) { XTtk_GetPaddingFromObj(tls, libc.UintptrFromInt32(0), tkwin, objPtr, nbstyle+4) } (*TNotebookStyle)(unsafe.Pointer(nbstyle)).Fpadding = XTtk_UniformPadding(tls, 0) v4 = XTtk_QueryOption(tls, (*TNotebook)(unsafe.Pointer(nb)).Fcore.Flayout, __ccgo_ts+49128, uint32(0)) objPtr = v4 if v4 != uintptr(0) { XTtk_GetPaddingFromObj(tls, libc.UintptrFromInt32(0), tkwin, objPtr, nbstyle+24) } (*TNotebookStyle)(unsafe.Pointer(nbstyle)).FminTabWidth = int32(DEFAULT_MIN_TAB_WIDTH) v5 = XTtk_QueryOption(tls, (*TNotebook)(unsafe.Pointer(nb)).Fcore.Flayout, __ccgo_ts+52772, uint32(0)) objPtr = v5 if v5 != uintptr(0) { XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), tkwin, objPtr, nbstyle+20) } } /*------------------------------------------------------------------------ * +++ Tab management. */ func _CreateTab(tls *libc.TLS, interp uintptr, nb uintptr, window TTk_Window) (r uintptr) { var optionTable TTk_OptionTable var record uintptr _, _ = optionTable, record optionTable = (*TNotebook)(unsafe.Pointer(nb)).Fnotebook.FpaneOptionTable record = libtcl9_0.XTcl_Alloc(tls, uint64(96)) libc.Xmemset(tls, record, 0, uint64(96)) if XTk_InitOptions(tls, interp, record, optionTable, window) != TCL_OK { libtcl9_0.XTcl_Free(tls, record) return libc.UintptrFromInt32(0) } return record } func _DestroyTab(tls *libc.TLS, nb uintptr, tab uintptr) { var record uintptr _ = record record = tab XTk_FreeConfigOptions(tls, record, (*TNotebook)(unsafe.Pointer(nb)).Fnotebook.FpaneOptionTable, (*TNotebook)(unsafe.Pointer(nb)).Fcore.Ftkwin) libtcl9_0.XTcl_Free(tls, record) } func _ConfigureTab(tls *libc.TLS, interp uintptr, nb uintptr, tab uintptr, window TTk_Window, objc TTcl_Size, objv uintptr) (r int32) { bp := tls.Alloc(544) defer tls.Free(544) var _ /* mask at bp+528 */ int32 var _ /* padding at bp+8 */ TTtk_Padding var _ /* savedOptions at bp+16 */ TTk_SavedOptions var _ /* sticky at bp+0 */ TTtk_Sticky *(*TTtk_Sticky)(unsafe.Pointer(bp)) = (*TTab)(unsafe.Pointer(tab)).Fsticky *(*TTtk_Padding)(unsafe.Pointer(bp + 8)) = (*TTab)(unsafe.Pointer(tab)).Fpadding *(*int32)(unsafe.Pointer(bp + 528)) = 0 if XTk_SetOptions(tls, interp, tab, (*TNotebook)(unsafe.Pointer(nb)).Fnotebook.FpaneOptionTable, objc, objv, window, bp+16, bp+528) != TCL_OK { return int32(TCL_ERROR) } /* Check options: * @@@ TODO: validate -image option. */ if XTtk_GetStickyFromObj(tls, interp, (*TTab)(unsafe.Pointer(tab)).FstickyObj, bp) != TCL_OK { goto error } if XTtk_GetPaddingFromObj(tls, interp, window, (*TTab)(unsafe.Pointer(tab)).FpaddingObj, bp+8) != TCL_OK { goto error } (*TTab)(unsafe.Pointer(tab)).Fsticky = *(*TTtk_Sticky)(unsafe.Pointer(bp)) (*TTab)(unsafe.Pointer(tab)).Fpadding = *(*TTtk_Padding)(unsafe.Pointer(bp + 8)) XTk_FreeSavedOptions(tls, bp+16) XTtk_ManagerSizeChanged(tls, (*TNotebook)(unsafe.Pointer(nb)).Fnotebook.Fmgr) XTtkRedisplayWidget(tls, nb) return TCL_OK goto error error: ; XTk_RestoreSavedOptions(tls, bp+16) return int32(TCL_ERROR) } // C documentation // // /* // * IdentifyTab -- // * Return the index of the tab at point x,y, // * or -1 if no tab at that point. // */ func _IdentifyTab(tls *libc.TLS, nb uintptr, x int32, y int32) (r TTcl_Size) { var index TTcl_Size var tab uintptr _, _ = index, tab index = 0 for { if !(index < XTtk_NumberContent(tls, (*TNotebook)(unsafe.Pointer(nb)).Fnotebook.Fmgr)) { break } tab = XTtk_ContentData(tls, (*TNotebook)(unsafe.Pointer(nb)).Fnotebook.Fmgr, index) if (*TTab)(unsafe.Pointer(tab)).Fstate != int32(TAB_STATE_HIDDEN) && XTtk_BoxContains(tls, (*TTab)(unsafe.Pointer(tab)).Fparcel, x, y) != 0 { return index } goto _1 _1: ; index++ } return int64(-libc.Int32FromInt32(1)) } // C documentation // // /* // * ActivateTab -- // * Set the active tab index, redisplay if necessary. // */ func _ActivateTab(tls *libc.TLS, nb uintptr, index TTcl_Size) { if index != (*TNotebook)(unsafe.Pointer(nb)).Fnotebook.FactiveIndex { (*TNotebook)(unsafe.Pointer(nb)).Fnotebook.FactiveIndex = index XTtkRedisplayWidget(tls, nb) } } // C documentation // // /* // * TabState -- // * Return the state of the specified tab, based on // * notebook state, currentIndex, activeIndex, and user-specified tab state. // * The USER1 bit is set for the leftmost visible tab, and USER2 // * is set for the rightmost visible tab. // */ func _TabState(tls *libc.TLS, nb uintptr, index TTcl_Size) (r TTtk_State) { var i TTcl_Size var itab, tab, tab1 uintptr var state TTtk_State _, _, _, _, _ = i, itab, state, tab, tab1 state = (*TNotebook)(unsafe.Pointer(nb)).Fcore.Fstate itab = XTtk_ContentData(tls, (*TNotebook)(unsafe.Pointer(nb)).Fnotebook.Fmgr, index) i = 0 if index == (*TNotebook)(unsafe.Pointer(nb)).Fnotebook.FcurrentIndex { state |= libc.Uint32FromInt32(libc.Int32FromInt32(1) << libc.Int32FromInt32(4)) } else { state &= libc.Uint32FromInt32(^(libc.Int32FromInt32(1) << libc.Int32FromInt32(2))) } if index == (*TNotebook)(unsafe.Pointer(nb)).Fnotebook.FactiveIndex { state |= libc.Uint32FromInt32(libc.Int32FromInt32(1) << libc.Int32FromInt32(0)) } i = 0 for { if !(i < XTtk_NumberContent(tls, (*TNotebook)(unsafe.Pointer(nb)).Fnotebook.Fmgr)) { break } tab = XTtk_ContentData(tls, (*TNotebook)(unsafe.Pointer(nb)).Fnotebook.Fmgr, i) if (*TTab)(unsafe.Pointer(tab)).Fstate == int32(TAB_STATE_HIDDEN) { goto _1 } if index == i { state |= libc.Uint32FromInt32(libc.Int32FromInt32(1) << libc.Int32FromInt32(18)) } break goto _1 _1: ; i++ } i = XTtk_NumberContent(tls, (*TNotebook)(unsafe.Pointer(nb)).Fnotebook.Fmgr) - int64(1) for { if !(i >= 0) { break } tab1 = XTtk_ContentData(tls, (*TNotebook)(unsafe.Pointer(nb)).Fnotebook.Fmgr, i) if (*TTab)(unsafe.Pointer(tab1)).Fstate == int32(TAB_STATE_HIDDEN) { goto _2 } if index == i { state |= libc.Uint32FromInt32(libc.Int32FromInt32(1) << libc.Int32FromInt32(19)) } break goto _2 _2: ; i-- } if (*TTab)(unsafe.Pointer(itab)).Fstate == int32(TAB_STATE_DISABLED) { state |= libc.Uint32FromInt32(libc.Int32FromInt32(1) << libc.Int32FromInt32(1)) } return state } /*------------------------------------------------------------------------ * +++ Geometry management - size computation. */ // C documentation // // /* TabrowSize -- // * Compute max height and total width of all tabs (horizontal layouts) // * or total height and max width (vertical layouts). // * The -mintabwidth style option is taken into account (for the width // * only). // * // * Side effects: // * Sets width and height fields for all tabs. // * // * Notes: // * Hidden tabs are included in the perpendicular computation // * (max height/width) but not parallel (total width/height). // */ func _TabrowSize(tls *libc.TLS, nb uintptr, orient TTtk_Orient, minTabWidth int32, widthPtr uintptr, heightPtr uintptr) { var i TTcl_Size var tab uintptr var tabLayout TTtk_Layout var tabState TTtk_State var tabrowHeight, tabrowWidth, v2, v3, v4 int32 _, _, _, _, _, _, _, _, _ = i, tab, tabLayout, tabState, tabrowHeight, tabrowWidth, v2, v3, v4 tabLayout = (*TNotebook)(unsafe.Pointer(nb)).Fnotebook.FtabLayout tabrowWidth = 0 tabrowHeight = 0 i = 0 for { if !(i < XTtk_NumberContent(tls, (*TNotebook)(unsafe.Pointer(nb)).Fnotebook.Fmgr)) { break } tab = XTtk_ContentData(tls, (*TNotebook)(unsafe.Pointer(nb)).Fnotebook.Fmgr, i) tabState = _TabState(tls, nb, i) XTtk_RebindSublayout(tls, tabLayout, tab) XTtk_LayoutSize(tls, tabLayout, tabState, tab, tab+4) if (*TTab)(unsafe.Pointer(tab)).Fwidth > minTabWidth { v2 = (*TTab)(unsafe.Pointer(tab)).Fwidth } else { v2 = minTabWidth } (*TTab)(unsafe.Pointer(tab)).Fwidth = v2 if orient == int32(TTK_ORIENT_HORIZONTAL) { if tabrowHeight > (*TTab)(unsafe.Pointer(tab)).Fheight { v3 = tabrowHeight } else { v3 = (*TTab)(unsafe.Pointer(tab)).Fheight } tabrowHeight = v3 if (*TTab)(unsafe.Pointer(tab)).Fstate != int32(TAB_STATE_HIDDEN) { tabrowWidth += (*TTab)(unsafe.Pointer(tab)).Fwidth } } else { if tabrowWidth > (*TTab)(unsafe.Pointer(tab)).Fwidth { v4 = tabrowWidth } else { v4 = (*TTab)(unsafe.Pointer(tab)).Fwidth } tabrowWidth = v4 if (*TTab)(unsafe.Pointer(tab)).Fstate != int32(TAB_STATE_HIDDEN) { tabrowHeight += (*TTab)(unsafe.Pointer(tab)).Fheight } } goto _1 _1: ; i++ } *(*int32)(unsafe.Pointer(widthPtr)) = tabrowWidth *(*int32)(unsafe.Pointer(heightPtr)) = tabrowHeight } /* NotebookSize -- GM and widget size hook. * * Total height is tab height + client area height + pane internal padding * Total width is max(client width, tab width) + pane internal padding * Client area size determined by max size of content windows, * overridden by -width and/or -height if nonzero. */ func _NotebookSize(tls *libc.TLS, clientData uintptr, widthPtr uintptr, heightPtr uintptr) (r int32) { bp := tls.Alloc(48) defer tls.Free(48) var clientHeight, clientWidth, height, width, v2, v3, v4, v5 int32 var clientNode TTtk_Element var i TTcl_Size var ipad, padding TTtk_Padding var nb, tab uintptr var nbwin, window TTk_Window var _ /* nbstyle at bp+0 */ TNotebookStyle var _ /* reqHeight at bp+36 */ int32 var _ /* reqWidth at bp+32 */ int32 var _ /* tabrowHeight at bp+44 */ int32 var _ /* tabrowWidth at bp+40 */ int32 _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = clientHeight, clientNode, clientWidth, height, i, ipad, nb, nbwin, padding, tab, width, window, v2, v3, v4, v5 nb = clientData nbwin = (*TNotebook)(unsafe.Pointer(nb)).Fcore.Ftkwin clientNode = XTtk_FindElement(tls, (*TNotebook)(unsafe.Pointer(nb)).Fcore.Flayout, __ccgo_ts+50349) clientWidth = 0 clientHeight = 0 *(*int32)(unsafe.Pointer(bp + 32)) = 0 *(*int32)(unsafe.Pointer(bp + 36)) = 0 *(*int32)(unsafe.Pointer(bp + 40)) = 0 *(*int32)(unsafe.Pointer(bp + 44)) = 0 _NotebookStyleOptions(tls, nb, bp, nbwin) /* Compute max requested size of all content windows: */ i = 0 for { if !(i < XTtk_NumberContent(tls, (*TNotebook)(unsafe.Pointer(nb)).Fnotebook.Fmgr)) { break } window = XTtk_ContentWindow(tls, (*TNotebook)(unsafe.Pointer(nb)).Fnotebook.Fmgr, i) tab = XTtk_ContentData(tls, (*TNotebook)(unsafe.Pointer(nb)).Fnotebook.Fmgr, i) width = (*TTk_FakeWin)(unsafe.Pointer(window)).FreqWidth + (int32((*TTab)(unsafe.Pointer(tab)).Fpadding.Fleft) + int32((*TTab)(unsafe.Pointer(tab)).Fpadding.Fright)) height = (*TTk_FakeWin)(unsafe.Pointer(window)).FreqHeight + (int32((*TTab)(unsafe.Pointer(tab)).Fpadding.Ftop) + int32((*TTab)(unsafe.Pointer(tab)).Fpadding.Fbottom)) if clientWidth > width { v2 = clientWidth } else { v2 = width } clientWidth = v2 if clientHeight > height { v3 = clientHeight } else { v3 = height } clientHeight = v3 goto _1 _1: ; i++ } /* Client width/height overridable by widget options: */ XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), nbwin, (*TNotebook)(unsafe.Pointer(nb)).Fnotebook.FwidthObj, bp+32) XTk_GetPixelsFromObj(tls, libc.UintptrFromInt32(0), nbwin, (*TNotebook)(unsafe.Pointer(nb)).Fnotebook.FheightObj, bp+36) if *(*int32)(unsafe.Pointer(bp + 32)) > 0 { clientWidth = *(*int32)(unsafe.Pointer(bp + 32)) } if *(*int32)(unsafe.Pointer(bp + 36)) > 0 { clientHeight = *(*int32)(unsafe.Pointer(bp + 36)) } /* Tab row: */ _TabrowSize(tls, nb, (*(*TNotebookStyle)(unsafe.Pointer(bp))).FtabOrient, (*(*TNotebookStyle)(unsafe.Pointer(bp))).FminTabWidth, bp+40, bp+44) *(*int32)(unsafe.Pointer(bp + 44)) += int32((*(*TNotebookStyle)(unsafe.Pointer(bp))).FtabMargins.Ftop) + int32((*(*TNotebookStyle)(unsafe.Pointer(bp))).FtabMargins.Fbottom) *(*int32)(unsafe.Pointer(bp + 40)) += int32((*(*TNotebookStyle)(unsafe.Pointer(bp))).FtabMargins.Fleft) + int32((*(*TNotebookStyle)(unsafe.Pointer(bp))).FtabMargins.Fright) /* Account for exterior and interior padding: */ padding = (*(*TNotebookStyle)(unsafe.Pointer(bp))).Fpadding if clientNode != 0 { ipad = XTtk_LayoutNodeInternalPadding(tls, (*TNotebook)(unsafe.Pointer(nb)).Fcore.Flayout, clientNode) padding = XTtk_AddPadding(tls, padding, ipad) } if (*(*TNotebookStyle)(unsafe.Pointer(bp))).FtabPosition&libc.Uint32FromInt32(libc.Int32FromInt32(TTK_PACK_TOP)|libc.Int32FromInt32(TTK_PACK_BOTTOM)) != 0 { if *(*int32)(unsafe.Pointer(bp + 40)) > clientWidth { v4 = *(*int32)(unsafe.Pointer(bp + 40)) } else { v4 = clientWidth } *(*int32)(unsafe.Pointer(widthPtr)) = v4 + (int32(padding.Fleft) + int32(padding.Fright)) *(*int32)(unsafe.Pointer(heightPtr)) = *(*int32)(unsafe.Pointer(bp + 44)) + clientHeight + (int32(padding.Ftop) + int32(padding.Fbottom)) } else { *(*int32)(unsafe.Pointer(widthPtr)) = *(*int32)(unsafe.Pointer(bp + 40)) + clientWidth + (int32(padding.Fleft) + int32(padding.Fright)) if *(*int32)(unsafe.Pointer(bp + 44)) > clientHeight { v5 = *(*int32)(unsafe.Pointer(bp + 44)) } else { v5 = clientHeight } *(*int32)(unsafe.Pointer(heightPtr)) = v5 + (int32(padding.Ftop) + int32(padding.Fbottom)) } return int32(1) } /*------------------------------------------------------------------------ * +++ Geometry management - layout. */ /* SqueezeTabs -- * Squeeze or stretch tabs to fit within the tab area parcel. * This happens independently of the -mintabwidth style option. * * All tabs are adjusted by an equal amount. * * @@@ <> bug: only works for horizontal orientations * @@@ <> does not account for hidden tabs. */ func _SqueezeTabs(tls *libc.TLS, nb uintptr, needed int32, available int32) { var ad, delta, slack float64 var difference, i, nTabs int32 var tab uintptr _, _, _, _, _, _, _ = ad, delta, difference, i, nTabs, slack, tab nTabs = int32(XTtk_NumberContent(tls, (*TNotebook)(unsafe.Pointer(nb)).Fnotebook.Fmgr)) if nTabs > 0 { difference = available - needed delta = float64(difference) / float64(needed) slack = libc.Float64FromInt32(0) i = 0 for { if !(i < nTabs) { break } tab = XTtk_ContentData(tls, (*TNotebook)(unsafe.Pointer(nb)).Fnotebook.Fmgr, int64(i)) ad = slack + float64(float64((*TTab)(unsafe.Pointer(tab)).Fwidth)*delta) *(*int32)(unsafe.Pointer(tab)) += int32(ad) slack = ad - float64(int32(ad)) goto _1 _1: ; i++ } } } // C documentation // // /* PlaceTabs -- // * Compute all tab parcels. // */ func _PlaceTabs(tls *libc.TLS, nb uintptr, _tabrowBox TTtk_Box, tabPlacement TTtk_PositionSpec) { bp := tls.Alloc(32) defer tls.Free(32) *(*TTtk_Box)(unsafe.Pointer(bp)) = _tabrowBox var expandObj, tab uintptr var i, nTabs int32 var tabLayout TTtk_Layout var tabState TTtk_State var _ /* expand at bp+16 */ TTtk_Padding _, _, _, _, _, _ = expandObj, i, nTabs, tab, tabLayout, tabState tabLayout = (*TNotebook)(unsafe.Pointer(nb)).Fnotebook.FtabLayout nTabs = int32(XTtk_NumberContent(tls, (*TNotebook)(unsafe.Pointer(nb)).Fnotebook.Fmgr)) i = 0 for { if !(i < nTabs) { break } tab = XTtk_ContentData(tls, (*TNotebook)(unsafe.Pointer(nb)).Fnotebook.Fmgr, int64(i)) tabState = _TabState(tls, nb, int64(i)) if (*TTab)(unsafe.Pointer(tab)).Fstate != int32(TAB_STATE_HIDDEN) { *(*TTtk_Padding)(unsafe.Pointer(bp + 16)) = XTtk_UniformPadding(tls, 0) expandObj = XTtk_QueryOption(tls, tabLayout, __ccgo_ts+15176, tabState) if expandObj != 0 { XTtk_GetPaddingFromObj(tls, libc.UintptrFromInt32(0), (*TNotebook)(unsafe.Pointer(nb)).Fcore.Ftkwin, expandObj, bp+16) } (*TTab)(unsafe.Pointer(tab)).Fparcel = XTtk_ExpandBox(tls, XTtk_PositionBox(tls, bp, (*TTab)(unsafe.Pointer(tab)).Fwidth, (*TTab)(unsafe.Pointer(tab)).Fheight, tabPlacement), *(*TTtk_Padding)(unsafe.Pointer(bp + 16))) } goto _1 _1: ; i++ } } // C documentation // // /* // * NotebookPlaceContent -- // * Set the position and size of a child widget // * based on the current client area and content window options: // */ func _NotebookPlaceContent(tls *libc.TLS, nb uintptr, index TTcl_Size) { var box TTtk_Box var tab uintptr var window TTk_Window _, _, _ = box, tab, window tab = XTtk_ContentData(tls, (*TNotebook)(unsafe.Pointer(nb)).Fnotebook.Fmgr, index) window = XTtk_ContentWindow(tls, (*TNotebook)(unsafe.Pointer(nb)).Fnotebook.Fmgr, index) box = XTtk_StickBox(tls, XTtk_PadBox(tls, (*TNotebook)(unsafe.Pointer(nb)).Fnotebook.FclientArea, (*TTab)(unsafe.Pointer(tab)).Fpadding), (*TTk_FakeWin)(unsafe.Pointer(window)).FreqWidth, (*TTk_FakeWin)(unsafe.Pointer(window)).FreqHeight, (*TTab)(unsafe.Pointer(tab)).Fsticky) XTtk_PlaceContent(tls, (*TNotebook)(unsafe.Pointer(nb)).Fnotebook.Fmgr, index, box.Fx, box.Fy, box.Fwidth, box.Fheight) } // C documentation // // /* NotebookDoLayout -- // * Computes notebook layout and places tabs. // * // * Side effects: // * Sets clientArea, used to place panes. // */ func _NotebookDoLayout(tls *libc.TLS, recordPtr uintptr) { bp := tls.Alloc(64) defer tls.Free(64) var clientNode TTtk_Element var currentIndex TTcl_Size var nb uintptr var nbwin TTk_Window var tabrowBox TTtk_Box var _ /* cavity at bp+0 */ TTtk_Box var _ /* nbstyle at bp+24 */ TNotebookStyle var _ /* tabrowHeight at bp+20 */ int32 var _ /* tabrowWidth at bp+16 */ int32 _, _, _, _, _ = clientNode, currentIndex, nb, nbwin, tabrowBox nb = recordPtr nbwin = (*TNotebook)(unsafe.Pointer(nb)).Fcore.Ftkwin *(*TTtk_Box)(unsafe.Pointer(bp)) = XTtk_MakeBox(tls, 0, 0, (*TTk_FakeWin)(unsafe.Pointer(nbwin)).Fchanges.Fwidth, (*TTk_FakeWin)(unsafe.Pointer(nbwin)).Fchanges.Fheight) *(*int32)(unsafe.Pointer(bp + 16)) = 0 *(*int32)(unsafe.Pointer(bp + 20)) = 0 clientNode = XTtk_FindElement(tls, (*TNotebook)(unsafe.Pointer(nb)).Fcore.Flayout, __ccgo_ts+50349) currentIndex = (*TNotebook)(unsafe.Pointer(nb)).Fnotebook.FcurrentIndex _NotebookStyleOptions(tls, nb, bp+24, nbwin) /* Notebook internal padding: */ *(*TTtk_Box)(unsafe.Pointer(bp)) = XTtk_PadBox(tls, *(*TTtk_Box)(unsafe.Pointer(bp)), (*(*TNotebookStyle)(unsafe.Pointer(bp + 24))).Fpadding) /* Layout for notebook background (base layout): */ XTtk_PlaceLayout(tls, (*TNotebook)(unsafe.Pointer(nb)).Fcore.Flayout, (*TNotebook)(unsafe.Pointer(nb)).Fcore.Fstate, XTtk_MakeBox(tls, 0, 0, (*TTk_FakeWin)(unsafe.Pointer(nbwin)).Fchanges.Fwidth, (*TTk_FakeWin)(unsafe.Pointer(nbwin)).Fchanges.Fheight)) /* Place tabs: * Note: TabrowSize() takes into account -mintabwidth, but the tabs will * actually have this minimum size when displayed only if there is enough * space to draw the tabs with this width. Otherwise some of the tabs can * be squeezed to a size smaller than -mintabwidth because we prefer * displaying all tabs than than honoring -mintabwidth for all of them. */ _TabrowSize(tls, nb, (*(*TNotebookStyle)(unsafe.Pointer(bp + 24))).FtabOrient, (*(*TNotebookStyle)(unsafe.Pointer(bp + 24))).FminTabWidth, bp+16, bp+20) tabrowBox = XTtk_PadBox(tls, XTtk_PositionBox(tls, bp, *(*int32)(unsafe.Pointer(bp + 16))+(int32((*(*TNotebookStyle)(unsafe.Pointer(bp + 24))).FtabMargins.Fleft)+int32((*(*TNotebookStyle)(unsafe.Pointer(bp + 24))).FtabMargins.Fright)), *(*int32)(unsafe.Pointer(bp + 20))+(int32((*(*TNotebookStyle)(unsafe.Pointer(bp + 24))).FtabMargins.Ftop)+int32((*(*TNotebookStyle)(unsafe.Pointer(bp + 24))).FtabMargins.Fbottom)), (*(*TNotebookStyle)(unsafe.Pointer(bp + 24))).FtabPosition), (*(*TNotebookStyle)(unsafe.Pointer(bp + 24))).FtabMargins) _SqueezeTabs(tls, nb, *(*int32)(unsafe.Pointer(bp + 16)), tabrowBox.Fwidth) _PlaceTabs(tls, nb, tabrowBox, (*(*TNotebookStyle)(unsafe.Pointer(bp + 24))).FtabPlacement) /* Layout for client area frame: */ if clientNode != 0 { XTtk_PlaceElement(tls, (*TNotebook)(unsafe.Pointer(nb)).Fcore.Flayout, clientNode, *(*TTtk_Box)(unsafe.Pointer(bp))) *(*TTtk_Box)(unsafe.Pointer(bp)) = XTtk_LayoutNodeInternalParcel(tls, (*TNotebook)(unsafe.Pointer(nb)).Fcore.Flayout, clientNode) } if (*(*TTtk_Box)(unsafe.Pointer(bp))).Fheight <= 0 { (*(*TTtk_Box)(unsafe.Pointer(bp))).Fheight = int32(1) } if (*(*TTtk_Box)(unsafe.Pointer(bp))).Fwidth <= 0 { (*(*TTtk_Box)(unsafe.Pointer(bp))).Fwidth = int32(1) } if !(XTtkBoxEqual(tls, (*TNotebook)(unsafe.Pointer(nb)).Fnotebook.FclientArea, *(*TTtk_Box)(unsafe.Pointer(bp))) != 0) { (*TNotebook)(unsafe.Pointer(nb)).Fnotebook.FclientArea = *(*TTtk_Box)(unsafe.Pointer(bp)) if currentIndex >= 0 { _NotebookPlaceContent(tls, nb, currentIndex) } } } // C documentation // // /* NotebookPlaceContents -- // * Geometry manager hook. // */ func _NotebookPlaceContents(tls *libc.TLS, recordPtr uintptr) { var currentIndex TTcl_Size var nb uintptr _, _ = currentIndex, nb nb = recordPtr currentIndex = (*TNotebook)(unsafe.Pointer(nb)).Fnotebook.FcurrentIndex if currentIndex >= 0 { _NotebookDoLayout(tls, nb) _NotebookPlaceContent(tls, nb, currentIndex) } } // C documentation // // /* // * SelectTab(nb, index) -- // * Change the currently-selected tab. // */ func _SelectTab(tls *libc.TLS, nb uintptr, index TTcl_Size) { var currentIndex TTcl_Size var tab uintptr _, _ = currentIndex, tab tab = XTtk_ContentData(tls, (*TNotebook)(unsafe.Pointer(nb)).Fnotebook.Fmgr, index) currentIndex = (*TNotebook)(unsafe.Pointer(nb)).Fnotebook.FcurrentIndex if index == currentIndex { return } if _TabState(tls, nb, index)&libc.Uint32FromInt32(libc.Int32FromInt32(1)<