aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/libghostty-vt/include/ghostty/vt/point.h
blob: 9cab2758b8492d757c80232d7a1bf80c3e66b82c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
/**
 * @file point.h
 *
 * Terminal point types for referencing locations in the terminal grid.
 */

#ifndef GHOSTTY_VT_POINT_H
#define GHOSTTY_VT_POINT_H

#include <stdint.h>

#include <ghostty/vt/types.h>

#ifdef __cplusplus
extern "C" {
#endif

/** @defgroup point Point
 *
 * Types for referencing x/y positions in the terminal grid under
 * different coordinate systems (active area, viewport, full screen,
 * scrollback history).
 *
 * @{
 */

/**
 * A coordinate in the terminal grid.
 *
 * @ingroup point
 */
typedef struct {
  /** Column (0-indexed). */
  uint16_t x;

  /** Row (0-indexed). May exceed page size for screen/history tags. */
  uint32_t y;
} GhosttyPointCoordinate;

/**
 * Point reference tag.
 *
 * Determines which coordinate system a point uses.
 *
 * @ingroup point
 */
typedef enum GHOSTTY_ENUM_TYPED {
  /** Active area where the cursor can move. */
  GHOSTTY_POINT_TAG_ACTIVE = 0,

  /** Visible viewport (changes when scrolled). */
  GHOSTTY_POINT_TAG_VIEWPORT = 1,

  /** Full screen including scrollback. */
  GHOSTTY_POINT_TAG_SCREEN = 2,

  /** Scrollback history only (before active area). */
  GHOSTTY_POINT_TAG_HISTORY = 3,
  GHOSTTY_POINT_TAG_MAX_VALUE = GHOSTTY_ENUM_MAX_VALUE,
  } GhosttyPointTag;

/**
 * Point value union.
 *
 * @ingroup point
 */
typedef union {
  /** Coordinate (used for all tag variants). */
  GhosttyPointCoordinate coordinate;

  /** Padding for ABI compatibility. Do not use. */
  uint64_t _padding[2];
} GhosttyPointValue;

/**
 * Tagged union for a point in the terminal grid.
 *
 * @ingroup point
 */
typedef struct {
  GhosttyPointTag tag;
  GhosttyPointValue value;
} GhosttyPoint;

/** @} */

#ifdef __cplusplus
}
#endif

#endif /* GHOSTTY_VT_POINT_H */