project_note
Clone
https://git.tahinli.com/Tahinli/project_note.git
0 watching0 forksRust3.6 MiBc49f5e7Tahinli1 month ago2 commits
| 1 | //! # Index |
| 2 | //! |
| 3 | //! There are several types of indexes: |
| 4 | //! |
| 5 | //! - Unicode index: the index of a unicode code point in the text. |
| 6 | //! - Entity index: unicode index + style anchor index. Each unicode code point or style anchor is an entity. |
| 7 | //! - Utf16 index |
| 8 | //! |
| 9 | //! In [crate::op::Op], we always use entity index to persist richtext ops. |
| 10 | //! |
| 11 | //! The users of this type can only operate on unicode index or utf16 index, but calculated entity index will be provided. |
| 12 | |
| 13 | pub |
| 14 | |
| 15 | pub |
| 16 | pub |
| 17 | |
| 18 | |
| 19 | |
| 20 | pub |
| 21 | |
| 22 | use crate::; |
| 23 | use *; |
| 24 | use ; |
| 25 | use ; |
| 26 | use Debug; |
| 27 | |
| 28 | pub use ; |
| 29 | pub use RichtextState; |
| 30 | pub use Styles; |
| 31 | pub use ; |
| 32 | |
| 33 | /// This is the data structure that represents a span of rich text. |
| 34 | /// It's used to communicate with the frontend. |
| 35 | |
| 36 | |
| 37 | |
| 38 | |
| 39 | |
| 40 | |
| 41 | /// This is used to communicate with the frontend. |
| 42 | |
| 43 | |
| 44 | |
| 45 | |
| 46 | |
| 47 | |
| 48 | // TODO: change visibility back to crate after #116 is done |
| 49 | |
| 50 | |
| 51 | |
| 52 | |
| 53 | |
| 54 | |
| 55 | |
| 56 | |
| 57 | |
| 58 | |
| 59 | |
| 60 | pub |
| 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 | |
| 92 | |
| 93 | |
| 94 | |
| 95 | |
| 96 | |
| 97 | |
| 98 | |
| 99 | |
| 100 | |
| 101 | |
| 102 | |
| 103 | |
| 104 | |
| 105 | |
| 106 | |
| 107 | |
| 108 | |
| 109 | |
| 110 | |
| 111 | |
| 112 | |
| 113 | |
| 114 | |
| 115 | |
| 116 | |
| 117 | |
| 118 | |
| 119 | |
| 120 | |
| 121 | |
| 122 | |
| 123 | |
| 124 | |
| 125 | |
| 126 | |
| 127 | |
| 128 | /// TODO: We can remove this type already |
| 129 | /// |
| 130 | /// A compact representation of a rich text style config. |
| 131 | /// |
| 132 | /// Note: we assume style with the same key has the same `Mergeable` and `isContainer` value. |
| 133 | /// |
| 134 | /// - 0 (1st bit) |
| 135 | /// - Expand Before (2nd bit): when inserting new text before this style, whether the new text should inherit this style. |
| 136 | /// - Expand After (3rd bit): when inserting new text after this style, whether the new text should inherit this style. |
| 137 | /// - 0 (4th bit): |
| 138 | /// - 0 (5th bit): |
| 139 | /// - 0 (6th bit) |
| 140 | /// - 0 (7th bit) |
| 141 | /// - 0 (8th bit): |
| 142 | |
| 143 | |
| 144 | |
| 145 | |
| 146 | |
| 147 | |
| 148 | |
| 149 | |
| 150 | |
| 151 | |
| 152 | |
| 153 | |
| 154 | |
| 155 | |
| 156 | |
| 157 | |
| 158 | const EXPAND_BEFORE_MASK: u8 = 0b0000_0010; |
| 159 | const EXPAND_AFTER_MASK: u8 = 0b0000_0100; |
| 160 | const ALIVE_MASK: u8 = 0b1000_0000; |
| 161 | |
| 162 | /// Whether to expand the style when inserting new text around it. |
| 163 | /// |
| 164 | /// - Before: when inserting new text before this style, the new text should inherit this style. |
| 165 | /// - After: when inserting new text after this style, the new text should inherit this style. |
| 166 | /// - Both: when inserting new text before or after this style, the new text should inherit this style. |
| 167 | /// - None: when inserting new text before or after this style, the new text should **not** inherit this style. |
| 168 | |
| 169 | |
| 170 | |
| 171 | |
| 172 | |
| 173 | |
| 174 | |
| 175 | |
| 176 | |
| 177 | |
| 178 | |
| 179 | |
| 180 | |
| 181 | |
| 182 | |
| 183 | |
| 184 | |
| 185 | |
| 186 | |
| 187 | |
| 188 | |
| 189 | |
| 190 | |
| 191 | |
| 192 | |
| 193 | |
| 194 | |
| 195 | |
| 196 | |
| 197 | |
| 198 | |
| 199 | |
| 200 | |
| 201 | |
| 202 | |
| 203 | |
| 204 | |
| 205 | |
| 206 | |
| 207 | |
| 208 | |
| 209 | |
| 210 | |
| 211 | |
| 212 | |
| 213 | |
| 214 | |
| 215 | |
| 216 | |
| 217 | |
| 218 | |
| 219 | |
| 220 | |
| 221 | |
| 222 | |
| 223 | |
| 224 | |
| 225 | |
| 226 | |
| 227 | |
| 228 | |
| 229 | |
| 230 | |
| 231 | |
| 232 | |
| 233 | |
| 234 | |
| 235 | |
| 236 | |
| 237 | |
| 238 | |
| 239 | |
| 240 | |
| 241 | |
| 242 | |
| 243 | |
| 244 | |
| 245 | |
| 246 | |
| 247 | |
| 248 | |
| 249 | |
| 250 | |
| 251 | |
| 252 | |
| 253 | |
| 254 | |
| 255 | |
| 256 | |
| 257 | |
| 258 | |
| 259 | |
| 260 | |
| 261 | |
| 262 | |
| 263 | |
| 264 | |
| 265 | |
| 266 | |
| 267 | |
| 268 | |
| 269 | |
| 270 | |
| 271 | |
| 272 | |
| 273 | |
| 274 | |
| 275 | |
| 276 | |
| 277 | |
| 278 | |
| 279 | |
| 280 | |
| 281 | |
| 282 | |
| 283 | |
| 284 | |
| 285 | |
| 286 | |
| 287 | |
| 288 | |
| 289 | |
| 290 | |
| 291 | |
| 292 | |
| 293 | |
| 294 | |
| 295 | |
| 296 | |
| 297 | |
| 298 | |
| 299 | |
| 300 |