Twemoji everywhere: messages, status, polls, previews, names and inputs draw our own emoji pictures, unknown emoji dropped
Browse files at this commit567968898eb939f39572950d071261b88c73efdaParent: 8b99908- feat
- Twemoji everywhere: messages, status, polls, previews, names and inputs draw our own emoji pictures, unknown emoji dropped
- picker in composer and status editor
23 changed files +1068 -83
- crates/client/Cargo.toml +2 -0
- crates/client/assets/emoji/LICENSE-Twemoji.txt +393 -0
- crates/client/assets/emoji/twemoji.bin.gz +0 -0
- crates/client/design/emoji.py +10 -0
- crates/client/src/emoji.rs +242 -0
- crates/client/src/gui.rs +13 -2
- crates/client/src/gui/builder/messages.rs +4 -1
- crates/client/src/gui/builder/server.rs +2 -1
- crates/client/src/gui/builder/storage.rs +5 -2
- crates/client/src/gui/chat.rs +46 -12
- crates/client/src/gui/composer.rs +5 -4
- crates/client/src/gui/glyph.rs +257 -0
- crates/client/src/gui/media_view.rs +9 -8
- crates/client/src/gui/message_actions.rs +16 -17
- crates/client/src/gui/parts.rs +9 -5
- crates/client/src/gui/poll.rs +18 -22
- crates/client/src/gui/profile.rs +21 -4
- crates/client/src/gui/sidebar.rs +4 -1
- crates/client/src/gui/snippet.rs +4 -1
- crates/client/src/gui/social.rs +1 -1
- crates/client/src/gui/widget.rs +5 -2
- crates/client/src/lib.rs +1 -0
- crates/client/src/main.rs +1 -0
crates/client/Cargo.tomlmodified+2 -0
| @@ -35,6 +35,8 @@ rtrb = "0.4.1" | |||
| 35 | gethostname = "1.1.0" | 35 | gethostname = "1.1.0" |
| 36 | rustls-platform-verifier = "0.7.1" | 36 | rustls-platform-verifier = "0.7.1" |
| 37 | sysinfo = { version = "0.40.4", default-features = false, features = ["system"] } | 37 | sysinfo = { version = "0.40.4", default-features = false, features = ["system"] } |
| 38 | +flate2 = "1.1.11" | ||
| 39 | +emojis = "0.9.1" | ||
| 38 | 40 | ||
| 39 | [target.'cfg(any(target_os = "linux", target_os = "windows"))'.dependencies] | 41 | [target.'cfg(any(target_os = "linux", target_os = "windows"))'.dependencies] |
| 40 | nokhwa = { version = "0.10.11", default-features = false, features = ["input-native"] } | 42 | nokhwa = { version = "0.10.11", default-features = false, features = ["input-native"] } |
crates/client/assets/emoji/LICENSE-Twemoji.txtadded+393 -0
| @@ -0,0 +1,393 @@ | |||
| 1 | +Attribution 4.0 International | ||
| 2 | + | ||
| 3 | +======================================================================= | ||
| 4 | + | ||
| 5 | +Creative Commons Corporation ("Creative Commons") is not a law firm and | ||
| 6 | +does not provide legal services or legal advice. Distribution of | ||
| 7 | +Creative Commons public licenses does not create a lawyer-client or | ||
| 8 | +other relationship. Creative Commons makes its licenses and related | ||
| 9 | +information available on an "as-is" basis. Creative Commons gives no | ||
| 10 | +warranties regarding its licenses, any material licensed under their | ||
| 11 | +terms and conditions, or any related information. Creative Commons | ||
| 12 | +disclaims all liability for damages resulting from their use to the | ||
| 13 | +fullest extent possible. | ||
| 14 | + | ||
| 15 | +Using Creative Commons Public Licenses | ||
| 16 | + | ||
| 17 | +Creative Commons public licenses provide a standard set of terms and | ||
| 18 | +conditions that creators and other rights holders may use to share | ||
| 19 | +original works of authorship and other material subject to copyright | ||
| 20 | +and certain other rights specified in the public license below. The | ||
| 21 | +following considerations are for informational purposes only, are not | ||
| 22 | +exhaustive, and do not form part of our licenses. | ||
| 23 | + | ||
| 24 | + Considerations for licensors: Our public licenses are | ||
| 25 | + intended for use by those authorized to give the public | ||
| 26 | + permission to use material in ways otherwise restricted by | ||
| 27 | + copyright and certain other rights. Our licenses are | ||
| 28 | + irrevocable. Licensors should read and understand the terms | ||
| 29 | + and conditions of the license they choose before applying it. | ||
| 30 | + Licensors should also secure all rights necessary before | ||
| 31 | + applying our licenses so that the public can reuse the | ||
| 32 | + material as expected. Licensors should clearly mark any | ||
| 33 | + material not subject to the license. This includes other CC- | ||
| 34 | + licensed material, or material used under an exception or | ||
| 35 | + limitation to copyright. More considerations for licensors: | ||
| 36 | + wiki.creativecommons.org/Considerations_for_licensors | ||
| 37 | + | ||
| 38 | + Considerations for the public: By using one of our public | ||
| 39 | + licenses, a licensor grants the public permission to use the | ||
| 40 | + licensed material under specified terms and conditions. If | ||
| 41 | + the licensor's permission is not necessary for any reason--for | ||
| 42 | + example, because of any applicable exception or limitation to | ||
| 43 | + copyright--then that use is not regulated by the license. Our | ||
| 44 | + licenses grant only permissions under copyright and certain | ||
| 45 | + other rights that a licensor has authority to grant. Use of | ||
| 46 | + the licensed material may still be restricted for other | ||
| 47 | + reasons, including because others have copyright or other | ||
| 48 | + rights in the material. A licensor may make special requests, | ||
| 49 | + such as asking that all changes be marked or described. | ||
| 50 | + Although not required by our licenses, you are encouraged to | ||
| 51 | + respect those requests where reasonable. More_considerations | ||
| 52 | + for the public: | ||
| 53 | + wiki.creativecommons.org/Considerations_for_licensees | ||
| 54 | + | ||
| 55 | +======================================================================= | ||
| 56 | + | ||
| 57 | +Creative Commons Attribution 4.0 International Public License | ||
| 58 | + | ||
| 59 | +By exercising the Licensed Rights (defined below), You accept and agree | ||
| 60 | +to be bound by the terms and conditions of this Creative Commons | ||
| 61 | +Attribution 4.0 International Public License ("Public License"). To the | ||
| 62 | +extent this Public License may be interpreted as a contract, You are | ||
| 63 | +granted the Licensed Rights in consideration of Your acceptance of | ||
| 64 | +these terms and conditions, and the Licensor grants You such rights in | ||
| 65 | +consideration of benefits the Licensor receives from making the | ||
| 66 | +Licensed Material available under these terms and conditions. | ||
| 67 | + | ||
| 68 | + | ||
| 69 | +Section 1 -- Definitions. | ||
| 70 | + | ||
| 71 | + a. Adapted Material means material subject to Copyright and Similar | ||
| 72 | + Rights that is derived from or based upon the Licensed Material | ||
| 73 | + and in which the Licensed Material is translated, altered, | ||
| 74 | + arranged, transformed, or otherwise modified in a manner requiring | ||
| 75 | + permission under the Copyright and Similar Rights held by the | ||
| 76 | + Licensor. For purposes of this Public License, where the Licensed | ||
| 77 | + Material is a musical work, performance, or sound recording, | ||
| 78 | + Adapted Material is always produced where the Licensed Material is | ||
| 79 | + synched in timed relation with a moving image. | ||
| 80 | + | ||
| 81 | + b. Adapter's License means the license You apply to Your Copyright | ||
| 82 | + and Similar Rights in Your contributions to Adapted Material in | ||
| 83 | + accordance with the terms and conditions of this Public License. | ||
| 84 | + | ||
| 85 | + c. Copyright and Similar Rights means copyright and/or similar rights | ||
| 86 | + closely related to copyright including, without limitation, | ||
| 87 | + performance, broadcast, sound recording, and Sui Generis Database | ||
| 88 | + Rights, without regard to how the rights are labeled or | ||
| 89 | + categorized. For purposes of this Public License, the rights | ||
| 90 | + specified in Section 2(b)(1)-(2) are not Copyright and Similar | ||
| 91 | + Rights. | ||
| 92 | + | ||
| 93 | + d. Effective Technological Measures means those measures that, in the | ||
| 94 | + absence of proper authority, may not be circumvented under laws | ||
| 95 | + fulfilling obligations under Article 11 of the WIPO Copyright | ||
| 96 | + Treaty adopted on December 20, 1996, and/or similar international | ||
| 97 | + agreements. | ||
| 98 | + | ||
| 99 | + e. Exceptions and Limitations means fair use, fair dealing, and/or | ||
| 100 | + any other exception or limitation to Copyright and Similar Rights | ||
| 101 | + that applies to Your use of the Licensed Material. | ||
| 102 | + | ||
| 103 | + f. Licensed Material means the artistic or literary work, database, | ||
| 104 | + or other material to which the Licensor applied this Public | ||
| 105 | + License. | ||
| 106 | + | ||
| 107 | + g. Licensed Rights means the rights granted to You subject to the | ||
| 108 | + terms and conditions of this Public License, which are limited to | ||
| 109 | + all Copyright and Similar Rights that apply to Your use of the | ||
| 110 | + Licensed Material and that the Licensor has authority to license. | ||
| 111 | + | ||
| 112 | + h. Licensor means the individual(s) or entity(ies) granting rights | ||
| 113 | + under this Public License. | ||
| 114 | + | ||
| 115 | + i. Share means to provide material to the public by any means or | ||
| 116 | + process that requires permission under the Licensed Rights, such | ||
| 117 | + as reproduction, public display, public performance, distribution, | ||
| 118 | + dissemination, communication, or importation, and to make material | ||
| 119 | + available to the public including in ways that members of the | ||
| 120 | + public may access the material from a place and at a time | ||
| 121 | + individually chosen by them. | ||
| 122 | + | ||
| 123 | + j. Sui Generis Database Rights means rights other than copyright | ||
| 124 | + resulting from Directive 96/9/EC of the European Parliament and of | ||
| 125 | + the Council of 11 March 1996 on the legal protection of databases, | ||
| 126 | + as amended and/or succeeded, as well as other essentially | ||
| 127 | + equivalent rights anywhere in the world. | ||
| 128 | + | ||
| 129 | + k. You means the individual or entity exercising the Licensed Rights | ||
| 130 | + under this Public License. Your has a corresponding meaning. | ||
| 131 | + | ||
| 132 | + | ||
| 133 | +Section 2 -- Scope. | ||
| 134 | + | ||
| 135 | + a. License grant. | ||
| 136 | + | ||
| 137 | + 1. Subject to the terms and conditions of this Public License, | ||
| 138 | + the Licensor hereby grants You a worldwide, royalty-free, | ||
| 139 | + non-sublicensable, non-exclusive, irrevocable license to | ||
| 140 | + exercise the Licensed Rights in the Licensed Material to: | ||
| 141 | + | ||
| 142 | + a. reproduce and Share the Licensed Material, in whole or | ||
| 143 | + in part; and | ||
| 144 | + | ||
| 145 | + b. produce, reproduce, and Share Adapted Material. | ||
| 146 | + | ||
| 147 | + 2. Exceptions and Limitations. For the avoidance of doubt, where | ||
| 148 | + Exceptions and Limitations apply to Your use, this Public | ||
| 149 | + License does not apply, and You do not need to comply with | ||
| 150 | + its terms and conditions. | ||
| 151 | + | ||
| 152 | + 3. Term. The term of this Public License is specified in Section | ||
| 153 | + 6(a). | ||
| 154 | + | ||
| 155 | + 4. Media and formats; technical modifications allowed. The | ||
| 156 | + Licensor authorizes You to exercise the Licensed Rights in | ||
| 157 | + all media and formats whether now known or hereafter created, | ||
| 158 | + and to make technical modifications necessary to do so. The | ||
| 159 | + Licensor waives and/or agrees not to assert any right or | ||
| 160 | + authority to forbid You from making technical modifications | ||
| 161 | + necessary to exercise the Licensed Rights, including | ||
| 162 | + technical modifications necessary to circumvent Effective | ||
| 163 | + Technological Measures. For purposes of this Public License, | ||
| 164 | + simply making modifications authorized by this Section 2(a) | ||
| 165 | + (4) never produces Adapted Material. | ||
| 166 | + | ||
| 167 | + 5. Downstream recipients. | ||
| 168 | + | ||
| 169 | + a. Offer from the Licensor -- Licensed Material. Every | ||
| 170 | + recipient of the Licensed Material automatically | ||
| 171 | + receives an offer from the Licensor to exercise the | ||
| 172 | + Licensed Rights under the terms and conditions of this | ||
| 173 | + Public License. | ||
| 174 | + | ||
| 175 | + b. No downstream restrictions. You may not offer or impose | ||
| 176 | + any additional or different terms or conditions on, or | ||
| 177 | + apply any Effective Technological Measures to, the | ||
| 178 | + Licensed Material if doing so restricts exercise of the | ||
| 179 | + Licensed Rights by any recipient of the Licensed | ||
| 180 | + Material. | ||
| 181 | + | ||
| 182 | + 6. No endorsement. Nothing in this Public License constitutes or | ||
| 183 | + may be construed as permission to assert or imply that You | ||
| 184 | + are, or that Your use of the Licensed Material is, connected | ||
| 185 | + with, or sponsored, endorsed, or granted official status by, | ||
| 186 | + the Licensor or others designated to receive attribution as | ||
| 187 | + provided in Section 3(a)(1)(A)(i). | ||
| 188 | + | ||
| 189 | + b. Other rights. | ||
| 190 | + | ||
| 191 | + 1. Moral rights, such as the right of integrity, are not | ||
| 192 | + licensed under this Public License, nor are publicity, | ||
| 193 | + privacy, and/or other similar personality rights; however, to | ||
| 194 | + the extent possible, the Licensor waives and/or agrees not to | ||
| 195 | + assert any such rights held by the Licensor to the limited | ||
| 196 | + extent necessary to allow You to exercise the Licensed | ||
| 197 | + Rights, but not otherwise. | ||
| 198 | + | ||
| 199 | + 2. Patent and trademark rights are not licensed under this | ||
| 200 | + Public License. | ||
| 201 | + | ||
| 202 | + 3. To the extent possible, the Licensor waives any right to | ||
| 203 | + collect royalties from You for the exercise of the Licensed | ||
| 204 | + Rights, whether directly or through a collecting society | ||
| 205 | + under any voluntary or waivable statutory or compulsory | ||
| 206 | + licensing scheme. In all other cases the Licensor expressly | ||
| 207 | + reserves any right to collect such royalties. | ||
| 208 | + | ||
| 209 | + | ||
| 210 | +Section 3 -- License Conditions. | ||
| 211 | + | ||
| 212 | +Your exercise of the Licensed Rights is expressly made subject to the | ||
| 213 | +following conditions. | ||
| 214 | + | ||
| 215 | + a. Attribution. | ||
| 216 | + | ||
| 217 | + 1. If You Share the Licensed Material (including in modified | ||
| 218 | + form), You must: | ||
| 219 | + | ||
| 220 | + a. retain the following if it is supplied by the Licensor | ||
| 221 | + with the Licensed Material: | ||
| 222 | + | ||
| 223 | + i. identification of the creator(s) of the Licensed | ||
| 224 | + Material and any others designated to receive | ||
| 225 | + attribution, in any reasonable manner requested by | ||
| 226 | + the Licensor (including by pseudonym if | ||
| 227 | + designated); | ||
| 228 | + | ||
| 229 | + ii. a copyright notice; | ||
| 230 | + | ||
| 231 | + iii. a notice that refers to this Public License; | ||
| 232 | + | ||
| 233 | + iv. a notice that refers to the disclaimer of | ||
| 234 | + warranties; | ||
| 235 | + | ||
| 236 | + v. a URI or hyperlink to the Licensed Material to the | ||
| 237 | + extent reasonably practicable; | ||
| 238 | + | ||
| 239 | + b. indicate if You modified the Licensed Material and | ||
| 240 | + retain an indication of any previous modifications; and | ||
| 241 | + | ||
| 242 | + c. indicate the Licensed Material is licensed under this | ||
| 243 | + Public License, and include the text of, or the URI or | ||
| 244 | + hyperlink to, this Public License. | ||
| 245 | + | ||
| 246 | + 2. You may satisfy the conditions in Section 3(a)(1) in any | ||
| 247 | + reasonable manner based on the medium, means, and context in | ||
| 248 | + which You Share the Licensed Material. For example, it may be | ||
| 249 | + reasonable to satisfy the conditions by providing a URI or | ||
| 250 | + hyperlink to a resource that includes the required | ||
| 251 | + information. | ||
| 252 | + | ||
| 253 | + 3. If requested by the Licensor, You must remove any of the | ||
| 254 | + information required by Section 3(a)(1)(A) to the extent | ||
| 255 | + reasonably practicable. | ||
| 256 | + | ||
| 257 | + 4. If You Share Adapted Material You produce, the Adapter's | ||
| 258 | + License You apply must not prevent recipients of the Adapted | ||
| 259 | + Material from complying with this Public License. | ||
| 260 | + | ||
| 261 | + | ||
| 262 | +Section 4 -- Sui Generis Database Rights. | ||
| 263 | + | ||
| 264 | +Where the Licensed Rights include Sui Generis Database Rights that | ||
| 265 | +apply to Your use of the Licensed Material: | ||
| 266 | + | ||
| 267 | + a. for the avoidance of doubt, Section 2(a)(1) grants You the right | ||
| 268 | + to extract, reuse, reproduce, and Share all or a substantial | ||
| 269 | + portion of the contents of the database; | ||
| 270 | + | ||
| 271 | + b. if You include all or a substantial portion of the database | ||
| 272 | + contents in a database in which You have Sui Generis Database | ||
| 273 | + Rights, then the database in which You have Sui Generis Database | ||
| 274 | + Rights (but not its individual contents) is Adapted Material; and | ||
| 275 | + | ||
| 276 | + c. You must comply with the conditions in Section 3(a) if You Share | ||
| 277 | + all or a substantial portion of the contents of the database. | ||
| 278 | + | ||
| 279 | +For the avoidance of doubt, this Section 4 supplements and does not | ||
| 280 | +replace Your obligations under this Public License where the Licensed | ||
| 281 | +Rights include other Copyright and Similar Rights. | ||
| 282 | + | ||
| 283 | + | ||
| 284 | +Section 5 -- Disclaimer of Warranties and Limitation of Liability. | ||
| 285 | + | ||
| 286 | + a. UNLESS OTHERWISE SEPARATELY UNDERTAKEN BY THE LICENSOR, TO THE | ||
| 287 | + EXTENT POSSIBLE, THE LICENSOR OFFERS THE LICENSED MATERIAL AS-IS | ||
| 288 | + AND AS-AVAILABLE, AND MAKES NO REPRESENTATIONS OR WARRANTIES OF | ||
| 289 | + ANY KIND CONCERNING THE LICENSED MATERIAL, WHETHER EXPRESS, | ||
| 290 | + IMPLIED, STATUTORY, OR OTHER. THIS INCLUDES, WITHOUT LIMITATION, | ||
| 291 | + WARRANTIES OF TITLE, MERCHANTABILITY, FITNESS FOR A PARTICULAR | ||
| 292 | + PURPOSE, NON-INFRINGEMENT, ABSENCE OF LATENT OR OTHER DEFECTS, | ||
| 293 | + ACCURACY, OR THE PRESENCE OR ABSENCE OF ERRORS, WHETHER OR NOT | ||
| 294 | + KNOWN OR DISCOVERABLE. WHERE DISCLAIMERS OF WARRANTIES ARE NOT | ||
| 295 | + ALLOWED IN FULL OR IN PART, THIS DISCLAIMER MAY NOT APPLY TO YOU. | ||
| 296 | + | ||
| 297 | + b. TO THE EXTENT POSSIBLE, IN NO EVENT WILL THE LICENSOR BE LIABLE | ||
| 298 | + TO YOU ON ANY LEGAL THEORY (INCLUDING, WITHOUT LIMITATION, | ||
| 299 | + NEGLIGENCE) OR OTHERWISE FOR ANY DIRECT, SPECIAL, INDIRECT, | ||
| 300 | + INCIDENTAL, CONSEQUENTIAL, PUNITIVE, EXEMPLARY, OR OTHER LOSSES, | ||
| 301 | + COSTS, EXPENSES, OR DAMAGES ARISING OUT OF THIS PUBLIC LICENSE OR | ||
| 302 | + USE OF THE LICENSED MATERIAL, EVEN IF THE LICENSOR HAS BEEN | ||
| 303 | + ADVISED OF THE POSSIBILITY OF SUCH LOSSES, COSTS, EXPENSES, OR | ||
| 304 | + DAMAGES. WHERE A LIMITATION OF LIABILITY IS NOT ALLOWED IN FULL OR | ||
| 305 | + IN PART, THIS LIMITATION MAY NOT APPLY TO YOU. | ||
| 306 | + | ||
| 307 | + c. The disclaimer of warranties and limitation of liability provided | ||
| 308 | + above shall be interpreted in a manner that, to the extent | ||
| 309 | + possible, most closely approximates an absolute disclaimer and | ||
| 310 | + waiver of all liability. | ||
| 311 | + | ||
| 312 | + | ||
| 313 | +Section 6 -- Term and Termination. | ||
| 314 | + | ||
| 315 | + a. This Public License applies for the term of the Copyright and | ||
| 316 | + Similar Rights licensed here. However, if You fail to comply with | ||
| 317 | + this Public License, then Your rights under this Public License | ||
| 318 | + terminate automatically. | ||
| 319 | + | ||
| 320 | + b. Where Your right to use the Licensed Material has terminated under | ||
| 321 | + Section 6(a), it reinstates: | ||
| 322 | + | ||
| 323 | + 1. automatically as of the date the violation is cured, provided | ||
| 324 | + it is cured within 30 days of Your discovery of the | ||
| 325 | + violation; or | ||
| 326 | + | ||
| 327 | + 2. upon express reinstatement by the Licensor. | ||
| 328 | + | ||
| 329 | + For the avoidance of doubt, this Section 6(b) does not affect any | ||
| 330 | + right the Licensor may have to seek remedies for Your violations | ||
| 331 | + of this Public License. | ||
| 332 | + | ||
| 333 | + c. For the avoidance of doubt, the Licensor may also offer the | ||
| 334 | + Licensed Material under separate terms or conditions or stop | ||
| 335 | + distributing the Licensed Material at any time; however, doing so | ||
| 336 | + will not terminate this Public License. | ||
| 337 | + | ||
| 338 | + d. Sections 1, 5, 6, 7, and 8 survive termination of this Public | ||
| 339 | + License. | ||
| 340 | + | ||
| 341 | + | ||
| 342 | +Section 7 -- Other Terms and Conditions. | ||
| 343 | + | ||
| 344 | + a. The Licensor shall not be bound by any additional or different | ||
| 345 | + terms or conditions communicated by You unless expressly agreed. | ||
| 346 | + | ||
| 347 | + b. Any arrangements, understandings, or agreements regarding the | ||
| 348 | + Licensed Material not stated herein are separate from and | ||
| 349 | + independent of the terms and conditions of this Public License. | ||
| 350 | + | ||
| 351 | + | ||
| 352 | +Section 8 -- Interpretation. | ||
| 353 | + | ||
| 354 | + a. For the avoidance of doubt, this Public License does not, and | ||
| 355 | + shall not be interpreted to, reduce, limit, restrict, or impose | ||
| 356 | + conditions on any use of the Licensed Material that could lawfully | ||
| 357 | + be made without permission under this Public License. | ||
| 358 | + | ||
| 359 | + b. To the extent possible, if any provision of this Public License is | ||
| 360 | + deemed unenforceable, it shall be automatically reformed to the | ||
| 361 | + minimum extent necessary to make it enforceable. If the provision | ||
| 362 | + cannot be reformed, it shall be severed from this Public License | ||
| 363 | + without affecting the enforceability of the remaining terms and | ||
| 364 | + conditions. | ||
| 365 | + | ||
| 366 | + c. No term or condition of this Public License will be waived and no | ||
| 367 | + failure to comply consented to unless expressly agreed to by the | ||
| 368 | + Licensor. | ||
| 369 | + | ||
| 370 | + d. Nothing in this Public License constitutes or may be interpreted | ||
| 371 | + as a limitation upon, or waiver of, any privileges and immunities | ||
| 372 | + that apply to the Licensor or You, including from the legal | ||
| 373 | + processes of any jurisdiction or authority. | ||
| 374 | + | ||
| 375 | + | ||
| 376 | +======================================================================= | ||
| 377 | + | ||
| 378 | +Creative Commons is not a party to its public licenses. | ||
| 379 | +Notwithstanding, Creative Commons may elect to apply one of its public | ||
| 380 | +licenses to material it publishes and in those instances will be | ||
| 381 | +considered the "Licensor." Except for the limited purpose of indicating | ||
| 382 | +that material is shared under a Creative Commons public license or as | ||
| 383 | +otherwise permitted by the Creative Commons policies published at | ||
| 384 | +creativecommons.org/policies, Creative Commons does not authorize the | ||
| 385 | +use of the trademark "Creative Commons" or any other trademark or logo | ||
| 386 | +of Creative Commons without its prior written consent including, | ||
| 387 | +without limitation, in connection with any unauthorized modifications | ||
| 388 | +to any of its public licenses or any other arrangements, | ||
| 389 | +understandings, or agreements concerning use of licensed material. For | ||
| 390 | +the avoidance of doubt, this paragraph does not form part of the public | ||
| 391 | +licenses. | ||
| 392 | + | ||
| 393 | +Creative Commons may be contacted at creativecommons.org. | ||
crates/client/assets/emoji/twemoji.bin.gzadded+0 -0
Binary file changed
crates/client/design/emoji.pyadded+10 -0
| @@ -0,0 +1,10 @@ | |||
| 1 | +import gzip, os, struct, sys | ||
| 2 | +source, target = sys.argv[1], sys.argv[2] | ||
| 3 | +out = bytearray() | ||
| 4 | +for name in sorted(os.listdir(source)): | ||
| 5 | + if not name.endswith(".svg"): | ||
| 6 | + continue | ||
| 7 | + key = name[:-4].encode() | ||
| 8 | + data = open(os.path.join(source, name), "rb").read() | ||
| 9 | + out += struct.pack("<B", len(key)) + key + struct.pack("<I", len(data)) + data | ||
| 10 | +open(target, "wb").write(gzip.compress(bytes(out), 9, mtime=0)) | ||
crates/client/src/emoji.rsadded+242 -0
| @@ -0,0 +1,242 @@ | |||
| 1 | +use std::{ | ||
| 2 | + collections::HashMap, | ||
| 3 | + io::Read, | ||
| 4 | + ops::Range, | ||
| 5 | + sync::{Arc, LazyLock, Mutex}, | ||
| 6 | +}; | ||
| 7 | + | ||
| 8 | +use gpui_kit::{Image, ImageFormat}; | ||
| 9 | + | ||
| 10 | +const PACK: &[u8] = include_bytes!("../assets/emoji/twemoji.bin.gz"); | ||
| 11 | +const LONGEST: usize = 12; | ||
| 12 | +const VARIATION: char = '\u{FE0F}'; | ||
| 13 | +const JOINER: char = '\u{200D}'; | ||
| 14 | +const KEYCAP: char = '\u{20E3}'; | ||
| 15 | +const EMOJI_BY_DEFAULT: &[char] = &[ | ||
| 16 | + '⌚', '⌛', '⏩', '⏪', '⏫', '⏬', '⏰', '⏳', '◽', '◾', '☔', '☕', '♈', '♉', '♊', '♋', | ||
| 17 | + '♌', '♍', '♎', '♏', '♐', '♑', '♒', '♓', '♿', '⚓', '⚡', '⚪', '⚫', '⚽', '⚾', '⛄', | ||
| 18 | + '⛅', '⛎', '⛔', '⛪', '⛲', '⛳', '⛵', '⛺', '⛽', '✅', '✊', '✋', '✨', '❌', '❎', '❓', | ||
| 19 | + '❔', '❕', '❗', '➕', '➖', '➗', '➰', '➿', '⬛', '⬜', '⭐', '⭕', | ||
| 20 | +]; | ||
| 21 | + | ||
| 22 | +struct Pack { | ||
| 23 | + data: Vec<u8>, | ||
| 24 | + index: HashMap<String, Range<usize>>, | ||
| 25 | +} | ||
| 26 | + | ||
| 27 | +static PACKED: LazyLock<Pack> = LazyLock::new(|| { | ||
| 28 | + let mut data = Vec::new(); | ||
| 29 | + let _ = flate2::read::GzDecoder::new(PACK).read_to_end(&mut data); | ||
| 30 | + let mut index = HashMap::new(); | ||
| 31 | + let mut at = 0; | ||
| 32 | + while at < data.len() { | ||
| 33 | + let key_len = data[at] as usize; | ||
| 34 | + let key = String::from_utf8_lossy(&data[at + 1..at + 1 + key_len]).into_owned(); | ||
| 35 | + at += 1 + key_len; | ||
| 36 | + let len = u32::from_le_bytes(data[at..at + 4].try_into().unwrap_or_default()) as usize; | ||
| 37 | + at += 4; | ||
| 38 | + index.insert(key, at..at + len); | ||
| 39 | + at += len; | ||
| 40 | + } | ||
| 41 | + Pack { data, index } | ||
| 42 | +}); | ||
| 43 | + | ||
| 44 | +static IMAGES: LazyLock<Mutex<HashMap<String, Arc<Image>>>> = LazyLock::new(Mutex::default); | ||
| 45 | + | ||
| 46 | +#[derive(Debug, PartialEq, Eq)] | ||
| 47 | +pub enum Piece<'a> { | ||
| 48 | + Text(&'a str), | ||
| 49 | + Emoji(&'a str), | ||
| 50 | +} | ||
| 51 | + | ||
| 52 | +pub fn warm() { | ||
| 53 | + std::thread::spawn(|| LazyLock::force(&PACKED)); | ||
| 54 | +} | ||
| 55 | + | ||
| 56 | +pub fn key(emoji: &str) -> String { | ||
| 57 | + let keep_variation = emoji.contains(JOINER); | ||
| 58 | + emoji | ||
| 59 | + .chars() | ||
| 60 | + .filter(|c| keep_variation || *c != VARIATION) | ||
| 61 | + .map(|c| format!("{:x}", c as u32)) | ||
| 62 | + .collect::<Vec<_>>() | ||
| 63 | + .join("-") | ||
| 64 | +} | ||
| 65 | + | ||
| 66 | +pub fn known(emoji: &str) -> bool { | ||
| 67 | + PACKED.index.contains_key(&key(emoji)) | ||
| 68 | +} | ||
| 69 | + | ||
| 70 | +pub fn image(emoji: &str) -> Option<Arc<Image>> { | ||
| 71 | + let key = key(emoji); | ||
| 72 | + let mut images = IMAGES.lock().ok()?; | ||
| 73 | + if let Some(image) = images.get(&key) { | ||
| 74 | + return Some(image.clone()); | ||
| 75 | + } | ||
| 76 | + let range = PACKED.index.get(&key)?.clone(); | ||
| 77 | + let image = Arc::new(Image::from_bytes( | ||
| 78 | + ImageFormat::Svg, | ||
| 79 | + PACKED.data[range].to_vec(), | ||
| 80 | + )); | ||
| 81 | + images.insert(key, image.clone()); | ||
| 82 | + Some(image) | ||
| 83 | +} | ||
| 84 | + | ||
| 85 | +fn starts_emoji(sequence: &str) -> bool { | ||
| 86 | + let Some(first) = sequence.chars().next() else { | ||
| 87 | + return false; | ||
| 88 | + }; | ||
| 89 | + first as u32 >= 0x1F000 | ||
| 90 | + || EMOJI_BY_DEFAULT.contains(&first) | ||
| 91 | + || sequence.contains([VARIATION, KEYCAP, JOINER]) | ||
| 92 | +} | ||
| 93 | + | ||
| 94 | +fn stray(c: char) -> bool { | ||
| 95 | + matches!(c as u32, 0x1F000..=0x1FAFF | 0xE0020..=0xE007F) | ||
| 96 | + || matches!(c, VARIATION | JOINER | KEYCAP) | ||
| 97 | +} | ||
| 98 | + | ||
| 99 | +fn longest_at(text: &str) -> Option<usize> { | ||
| 100 | + let ends: Vec<usize> = text | ||
| 101 | + .char_indices() | ||
| 102 | + .skip(1) | ||
| 103 | + .map(|(at, _)| at) | ||
| 104 | + .chain(std::iter::once(text.len())) | ||
| 105 | + .take(LONGEST) | ||
| 106 | + .collect(); | ||
| 107 | + ends.into_iter() | ||
| 108 | + .rev() | ||
| 109 | + .find(|end| starts_emoji(&text[..*end]) && known(&text[..*end])) | ||
| 110 | +} | ||
| 111 | + | ||
| 112 | +pub fn pieces(text: &str) -> Vec<Piece<'_>> { | ||
| 113 | + let mut pieces = Vec::new(); | ||
| 114 | + let mut plain = 0; | ||
| 115 | + let mut at = 0; | ||
| 116 | + while at < text.len() { | ||
| 117 | + let rest = &text[at..]; | ||
| 118 | + let Some(c) = rest.chars().next() else { | ||
| 119 | + break; | ||
| 120 | + }; | ||
| 121 | + if let Some(len) = longest_at(rest) { | ||
| 122 | + if plain < at { | ||
| 123 | + pieces.push(Piece::Text(&text[plain..at])); | ||
| 124 | + } | ||
| 125 | + pieces.push(Piece::Emoji(&rest[..len])); | ||
| 126 | + at += len; | ||
| 127 | + plain = at; | ||
| 128 | + } else if stray(c) { | ||
| 129 | + if plain < at { | ||
| 130 | + pieces.push(Piece::Text(&text[plain..at])); | ||
| 131 | + } | ||
| 132 | + at += c.len_utf8(); | ||
| 133 | + plain = at; | ||
| 134 | + } else { | ||
| 135 | + at += c.len_utf8(); | ||
| 136 | + } | ||
| 137 | + } | ||
| 138 | + if plain < text.len() { | ||
| 139 | + pieces.push(Piece::Text(&text[plain..])); | ||
| 140 | + } | ||
| 141 | + pieces | ||
| 142 | +} | ||
| 143 | + | ||
| 144 | +pub fn plain(text: &str) -> bool { | ||
| 145 | + text.is_ascii() | ||
| 146 | +} | ||
| 147 | + | ||
| 148 | +pub fn markdown(text: &str) -> String { | ||
| 149 | + if plain(text) { | ||
| 150 | + return text.to_string(); | ||
| 151 | + } | ||
| 152 | + let mut out = String::with_capacity(text.len()); | ||
| 153 | + let mut fenced = false; | ||
| 154 | + for line in text.split_inclusive('\n') { | ||
| 155 | + if line.trim_start().starts_with("```") { | ||
| 156 | + fenced = !fenced; | ||
| 157 | + out.push_str(line); | ||
| 158 | + continue; | ||
| 159 | + } | ||
| 160 | + if fenced { | ||
| 161 | + out.push_str(line); | ||
| 162 | + continue; | ||
| 163 | + } | ||
| 164 | + for (index, part) in line.split('`').enumerate() { | ||
| 165 | + if index > 0 { | ||
| 166 | + out.push('`'); | ||
| 167 | + } | ||
| 168 | + if index % 2 == 1 { | ||
| 169 | + out.push_str(part); | ||
| 170 | + continue; | ||
| 171 | + } | ||
| 172 | + for piece in pieces(part) { | ||
| 173 | + match piece { | ||
| 174 | + Piece::Text(text) => out.push_str(text), | ||
| 175 | + Piece::Emoji(emoji) => { | ||
| 176 | + out.push_str(&format!("", key(emoji))); | ||
| 177 | + } | ||
| 178 | + } | ||
| 179 | + } | ||
| 180 | + } | ||
| 181 | + } | ||
| 182 | + out | ||
| 183 | +} | ||
| 184 | + | ||
| 185 | +pub const GROUPS: [emojis::Group; 9] = [ | ||
| 186 | + emojis::Group::SmileysAndEmotion, | ||
| 187 | + emojis::Group::PeopleAndBody, | ||
| 188 | + emojis::Group::AnimalsAndNature, | ||
| 189 | + emojis::Group::FoodAndDrink, | ||
| 190 | + emojis::Group::TravelAndPlaces, | ||
| 191 | + emojis::Group::Activities, | ||
| 192 | + emojis::Group::Objects, | ||
| 193 | + emojis::Group::Symbols, | ||
| 194 | + emojis::Group::Flags, | ||
| 195 | +]; | ||
| 196 | + | ||
| 197 | +static GROUPED: LazyLock<Vec<Vec<&'static str>>> = LazyLock::new(|| { | ||
| 198 | + GROUPS | ||
| 199 | + .iter() | ||
| 200 | + .map(|group| { | ||
| 201 | + group | ||
| 202 | + .emojis() | ||
| 203 | + .filter(|emoji| { | ||
| 204 | + emoji | ||
| 205 | + .skin_tone() | ||
| 206 | + .is_none_or(|tone| tone == emojis::SkinTone::Default) | ||
| 207 | + }) | ||
| 208 | + .map(|emoji| emoji.as_str()) | ||
| 209 | + .filter(|emoji| known(emoji)) | ||
| 210 | + .collect() | ||
| 211 | + }) | ||
| 212 | + .collect() | ||
| 213 | +}); | ||
| 214 | + | ||
| 215 | +pub fn group(index: usize) -> &'static [&'static str] { | ||
| 216 | + GROUPED.get(index).map_or(&[], Vec::as_slice) | ||
| 217 | +} | ||
| 218 | + | ||
| 219 | +#[cfg(test)] | ||
| 220 | +mod tests { | ||
| 221 | + use super::*; | ||
| 222 | + | ||
| 223 | + #[test] | ||
| 224 | + fn splits_known_and_drops_unknown() { | ||
| 225 | + assert_eq!( | ||
| 226 | + pieces("hi 🇹🇷 there"), | ||
| 227 | + vec![ | ||
| 228 | + Piece::Text("hi "), | ||
| 229 | + Piece::Emoji("🇹🇷"), | ||
| 230 | + Piece::Text(" there") | ||
| 231 | + ] | ||
| 232 | + ); | ||
| 233 | + assert_eq!(pieces("© 2026"), vec![Piece::Text("© 2026")]); | ||
| 234 | + assert_eq!( | ||
| 235 | + pieces("a\u{1FAFF}b"), | ||
| 236 | + vec![Piece::Text("a"), Piece::Text("b")] | ||
| 237 | + ); | ||
| 238 | + assert_eq!(pieces("👍🏽"), vec![Piece::Emoji("👍🏽")]); | ||
| 239 | + assert_eq!(pieces("❤️x"), vec![Piece::Emoji("❤️"), Piece::Text("x")]); | ||
| 240 | + assert_eq!(markdown("`🇹🇷` 🇹🇷"), "`🇹🇷` "); | ||
| 241 | + } | ||
| 242 | +} | ||
crates/client/src/gui.rsmodified+13 -2
| @@ -1,3 +1,4 @@ | |||
| 1 | +use crate::gui::glyph::Fill as _; | ||
| 1 | use common::model::{Hue, Id}; | 2 | use common::model::{Hue, Id}; |
| 2 | use std::{collections::HashMap, fmt::Display, rc::Rc, sync::Arc, time::Instant}; | 3 | use std::{collections::HashMap, fmt::Display, rc::Rc, sync::Arc, time::Instant}; |
| 3 | 4 | ||
| @@ -45,6 +46,7 @@ mod composer; | |||
| 45 | mod dock; | 46 | mod dock; |
| 46 | mod forward; | 47 | mod forward; |
| 47 | pub mod gallery; | 48 | pub mod gallery; |
| 49 | +pub mod glyph; | ||
| 48 | mod jump; | 50 | mod jump; |
| 49 | mod media_view; | 51 | mod media_view; |
| 50 | mod message_actions; | 52 | mod message_actions; |
| @@ -610,6 +612,7 @@ pub struct Yumush { | |||
| 610 | share_apps_task: Option<gpui_kit::Task<()>>, | 612 | share_apps_task: Option<gpui_kit::Task<()>>, |
| 611 | wordmark_flips: u32, | 613 | wordmark_flips: u32, |
| 612 | zoom: Option<Rc<Zoom>>, | 614 | zoom: Option<Rc<Zoom>>, |
| 615 | + emoji_group: usize, | ||
| 613 | share_tab: common::share::Kind, | 616 | share_tab: common::share::Kind, |
| 614 | camera_modes: Vec<common::share::Mode>, | 617 | camera_modes: Vec<common::share::Mode>, |
| 615 | camera_devices: Vec<String>, | 618 | camera_devices: Vec<String>, |
| @@ -681,6 +684,7 @@ impl Yumush { | |||
| 681 | share_apps_task: None, | 684 | share_apps_task: None, |
| 682 | wordmark_flips: 0, | 685 | wordmark_flips: 0, |
| 683 | zoom: None, | 686 | zoom: None, |
| 687 | + emoji_group: 0, | ||
| 684 | share_tab: common::share::Kind::Screen, | 688 | share_tab: common::share::Kind::Screen, |
| 685 | camera_modes: Vec::new(), | 689 | camera_modes: Vec::new(), |
| 686 | camera_devices: Vec::new(), | 690 | camera_devices: Vec::new(), |
| @@ -856,7 +860,7 @@ impl Yumush { | |||
| 856 | .update(cx, |input, cx| input.set_value(username, window, cx)); | 860 | .update(cx, |input, cx| input.set_value(username, window, cx)); |
| 857 | self.chat | 861 | self.chat |
| 858 | .status_input | 862 | .status_input |
| 859 | - .update(cx, |input, cx| input.set_value(status, window, cx)); | 863 | + .update(cx, |input, cx| input.fill(status, window, cx)); |
| 860 | } | 864 | } |
| 861 | if view == View::Builder { | 865 | if view == View::Builder { |
| 862 | self.load_builder(window, cx); | 866 | self.load_builder(window, cx); |
| @@ -1352,12 +1356,19 @@ pub(super) fn new_input( | |||
| 1352 | window: &mut Window, | 1356 | window: &mut Window, |
| 1353 | cx: &mut Context<Yumush>, | 1357 | cx: &mut Context<Yumush>, |
| 1354 | ) -> Entity<InputState> { | 1358 | ) -> Entity<InputState> { |
| 1355 | - cx.new(|cx| { | 1359 | + let input = cx.new(|cx| { |
| 1356 | let mut input_state = InputState::new(window, cx); | 1360 | let mut input_state = InputState::new(window, cx); |
| 1357 | input_state.set_placeholder(placeholder, window, cx); | 1361 | input_state.set_placeholder(placeholder, window, cx); |
| 1358 | 1362 | ||
| 1359 | input_state | 1363 | input_state |
| 1364 | + }); | ||
| 1365 | + cx.subscribe(&input, |_, input, event: &InputEvent, cx| { | ||
| 1366 | + if matches!(event, InputEvent::Change) { | ||
| 1367 | + input.update(cx, |state, cx| state.mark(cx)); | ||
| 1368 | + } | ||
| 1360 | }) | 1369 | }) |
| 1370 | + .detach(); | ||
| 1371 | + input | ||
| 1361 | } | 1372 | } |
| 1362 | 1373 | ||
| 1363 | impl Render for Yumush { | 1374 | impl Render for Yumush { |
crates/client/src/gui/builder/messages.rsmodified+4 -1
| @@ -150,7 +150,10 @@ fn message_hit_row( | |||
| 150 | .text_size(text(text::BODY)) | 150 | .text_size(text(text::BODY)) |
| 151 | .text_color(palette.body) | 151 | .text_color(palette.body) |
| 152 | .line_clamp(2) | 152 | .line_clamp(2) |
| 153 | - .child(hit.message.body.clone()), | 153 | + .child(super::super::glyph::wrapped( |
| 154 | + hit.message.body.clone().into(), | ||
| 155 | + super::super::text(super::super::style::text::BODY), | ||
| 156 | + )), | ||
| 154 | }), | 157 | }), |
| 155 | ) | 158 | ) |
| 156 | .child( | 159 | .child( |
crates/client/src/gui/builder/server.rsmodified+2 -1
| @@ -1,3 +1,4 @@ | |||
| 1 | +use crate::gui::glyph::Fill as _; | ||
| 1 | use common::{call::UpdateServerSettings, model::ServerSettings}; | 2 | use common::{call::UpdateServerSettings, model::ServerSettings}; |
| 2 | use gpui_kit::{ | 3 | use gpui_kit::{ |
| 3 | AnyElement, App, Context, Entity, IntoElement, Window, | 4 | AnyElement, App, Context, Entity, IntoElement, Window, |
| @@ -20,7 +21,7 @@ fn input_bytes(input: &Entity<InputState>, unit: u64, cx: &App) -> Option<u64> { | |||
| 20 | } | 21 | } |
| 21 | 22 | ||
| 22 | fn set_input(input: &Entity<InputState>, text: &str, window: &mut Window, cx: &mut App) { | 23 | fn set_input(input: &Entity<InputState>, text: &str, window: &mut Window, cx: &mut App) { |
| 23 | - input.update(cx, |input, cx| input.set_value(text, window, cx)); | 24 | + input.update(cx, |input, cx| input.fill(text, window, cx)); |
| 24 | } | 25 | } |
| 25 | 26 | ||
| 26 | impl Yumush { | 27 | impl Yumush { |
crates/client/src/gui/builder/storage.rsmodified+5 -2
| @@ -120,10 +120,13 @@ fn attachment_row( | |||
| 120 | .gap(px(space::XXS)) | 120 | .gap(px(space::XXS)) |
| 121 | .child( | 121 | .child( |
| 122 | div() | 122 | div() |
| 123 | - .truncate() | 123 | + .min_w_0() |
| 124 | .text_size(text(text::LABEL)) | 124 | .text_size(text(text::LABEL)) |
| 125 | .text_color(palette.text) | 125 | .text_color(palette.text) |
| 126 | - .child(info.attachment.name.clone()), | 126 | + .child(super::super::glyph::line( |
| 127 | + info.attachment.name.clone().into(), | ||
| 128 | + super::super::text(super::super::style::text::LABEL), | ||
| 129 | + )), | ||
| 127 | ) | 130 | ) |
| 128 | .child( | 131 | .child( |
| 129 | div() | 132 | div() |
crates/client/src/gui/chat.rsmodified+46 -12
| @@ -1,6 +1,7 @@ | |||
| 1 | use super::style::{self, radius, size, space, stroke, text}; | 1 | use super::style::{self, radius, size, space, stroke, text}; |
| 2 | use super::text; | 2 | use super::text; |
| 3 | use crate::gui::CLOCK; | 3 | use crate::gui::CLOCK; |
| 4 | +use crate::gui::glyph::Fill as _; | ||
| 4 | use std::{ | 5 | use std::{ |
| 5 | collections::{BTreeMap, HashMap, HashSet, VecDeque}, | 6 | collections::{BTreeMap, HashMap, HashSet, VecDeque}, |
| 6 | sync::Arc, | 7 | sync::Arc, |
| @@ -317,7 +318,10 @@ impl Chat { | |||
| 317 | InputEvent::PressEnter { shift: false, .. } => { | 318 | InputEvent::PressEnter { shift: false, .. } => { |
| 318 | this.submit_composer(input, window, cx) | 319 | this.submit_composer(input, window, cx) |
| 319 | } | 320 | } |
| 320 | - InputEvent::Change => this.send_typing(cx), | 321 | + InputEvent::Change => { |
| 322 | + input.update(cx, |state, cx| state.mark(cx)); | ||
| 323 | + this.send_typing(cx) | ||
| 324 | + } | ||
| 321 | _ => {} | 325 | _ => {} |
| 322 | }, | 326 | }, |
| 323 | ) | 327 | ) |
| @@ -1464,14 +1468,19 @@ impl Yumush { | |||
| 1464 | let text = self.announcement()?; | 1468 | let text = self.announcement()?; |
| 1465 | 1469 | ||
| 1466 | Some( | 1470 | Some( |
| 1467 | - accent_bar(palette).child(text.to_string()).child( | 1471 | + accent_bar(palette) |
| 1468 | - clickable( | 1472 | + .child(super::glyph::line( |
| 1469 | - "dismiss_announcement", | 1473 | + text.to_string().into(), |
| 1470 | - palette, | 1474 | + super::text(super::style::text::UI), |
| 1471 | - entity_action(entity, |yumush, _, cx| yumush.dismiss_announcement(cx)), | 1475 | + )) |
| 1472 | - ) | 1476 | + .child( |
| 1473 | - .child("×"), | 1477 | + clickable( |
| 1474 | - ), | 1478 | + "dismiss_announcement", |
| 1479 | + palette, | ||
| 1480 | + entity_action(entity, |yumush, _, cx| yumush.dismiss_announcement(cx)), | ||
| 1481 | + ) | ||
| 1482 | + .child("×"), | ||
| 1483 | + ), | ||
| 1475 | ) | 1484 | ) |
| 1476 | } | 1485 | } |
| 1477 | 1486 | ||
| @@ -1768,8 +1777,27 @@ impl Yumush { | |||
| 1768 | .gap(px(space::SM)) | 1777 | .gap(px(space::SM)) |
| 1769 | .child(composer::plus_popover(&self.chat, &entity, palette)) | 1778 | .child(composer::plus_popover(&self.chat, &entity, palette)) |
| 1770 | .child(composer::format_popover(palette)) | 1779 | .child(composer::format_popover(palette)) |
| 1780 | + .child(super::glyph::picker_button( | ||
| 1781 | + "composer_emoji", | ||
| 1782 | + &entity, | ||
| 1783 | + palette, | ||
| 1784 | + std::rc::Rc::new({ | ||
| 1785 | + let entity = entity.clone(); | ||
| 1786 | + move |emoji, window, cx| { | ||
| 1787 | + entity.update(cx, |yumush, cx| { | ||
| 1788 | + let input = yumush.chat.message_input.clone(); | ||
| 1789 | + input.update(cx, |state, cx| { | ||
| 1790 | + state.insert(emoji, window, cx); | ||
| 1791 | + state.focus(window, cx); | ||
| 1792 | + }); | ||
| 1793 | + input.update(cx, |state, cx| state.mark(cx)); | ||
| 1794 | + }) | ||
| 1795 | + } | ||
| 1796 | + }), | ||
| 1797 | + )) | ||
| 1771 | .child( | 1798 | .child( |
| 1772 | Textarea::new(&self.chat.message_input) | 1799 | Textarea::new(&self.chat.message_input) |
| 1800 | + .token(super::glyph::token) | ||
| 1773 | .appearance(false) | 1801 | .appearance(false) |
| 1774 | .text_size(text(text::BODY)) | 1802 | .text_size(text(text::BODY)) |
| 1775 | .text_color(palette.text) | 1803 | .text_color(palette.text) |
| @@ -2897,8 +2925,11 @@ fn members_column( | |||
| 2897 | div() | 2925 | div() |
| 2898 | .text_size(text(text::CAPTION)) | 2926 | .text_size(text(text::CAPTION)) |
| 2899 | .text_color(palette.muted) | 2927 | .text_color(palette.muted) |
| 2900 | - .truncate() | 2928 | + .min_w_0() |
| 2901 | - .child(user.status.clone()) | 2929 | + .child(super::glyph::line( |
| 2930 | + user.status.clone().into(), | ||
| 2931 | + super::text(super::style::text::CAPTION), | ||
| 2932 | + )) | ||
| 2902 | })), | 2933 | })), |
| 2903 | ), | 2934 | ), |
| 2904 | palette, | 2935 | palette, |
| @@ -3193,8 +3224,11 @@ fn render_message( | |||
| 3193 | .child( | 3224 | .child( |
| 3194 | TextView::markdown( | 3225 | TextView::markdown( |
| 3195 | format!("message-body-{}", message.id), | 3226 | format!("message-body-{}", message.id), |
| 3196 | - hard_breaks(&message.body), | 3227 | + crate::emoji::markdown(&hard_breaks( |
| 3228 | + &message.body, | ||
| 3229 | + )), | ||
| 3197 | ) | 3230 | ) |
| 3231 | + .markdown_extensions(super::glyph::extensions()) | ||
| 3198 | .selectable(true), | 3232 | .selectable(true), |
| 3199 | ), | 3233 | ), |
| 3200 | ) | 3234 | ) |
crates/client/src/gui/composer.rsmodified+5 -4
| @@ -1,6 +1,7 @@ | |||
| 1 | use super::style::{radius, size, space, stroke, text}; | 1 | use super::style::{radius, size, space, stroke, text}; |
| 2 | use super::text; | 2 | use super::text; |
| 3 | use super::widget::{compact_field, icon_button, panel, spawn_done}; | 3 | use super::widget::{compact_field, icon_button, panel, spawn_done}; |
| 4 | +use crate::gui::glyph::Fill as _; | ||
| 4 | use common::model::Id; | 5 | use common::model::Id; |
| 5 | use std::time::{Duration, Instant}; | 6 | use std::time::{Duration, Instant}; |
| 6 | 7 | ||
| @@ -329,7 +330,7 @@ impl Yumush { | |||
| 329 | return; | 330 | return; |
| 330 | } | 331 | } |
| 331 | if input.read(cx).text().len() == 0 { | 332 | if input.read(cx).text().len() == 0 { |
| 332 | - input.update(cx, |state, cx| state.set_value(body, window, cx)); | 333 | + input.update(cx, |state, cx| state.fill(body, window, cx)); |
| 333 | } | 334 | } |
| 334 | if self.chat.media.pending.is_empty() { | 335 | if self.chat.media.pending.is_empty() { |
| 335 | self.chat.media.pending = pending; | 336 | self.chat.media.pending = pending; |
| @@ -380,7 +381,7 @@ impl Yumush { | |||
| 380 | { | 381 | { |
| 381 | let _ = this.update_in(cx, |yumush, window, cx| { | 382 | let _ = this.update_in(cx, |yumush, window, cx| { |
| 382 | if restore.read(cx).text().len() == 0 { | 383 | if restore.read(cx).text().len() == 0 { |
| 383 | - restore.update(cx, |state, cx| state.set_value(body, window, cx)); | 384 | + restore.update(cx, |state, cx| state.fill(body, window, cx)); |
| 384 | yumush.chat.composer = Composer::Edit { message_id }; | 385 | yumush.chat.composer = Composer::Edit { message_id }; |
| 385 | cx.notify(); | 386 | cx.notify(); |
| 386 | } | 387 | } |
| @@ -421,7 +422,7 @@ impl Yumush { | |||
| 421 | .unwrap_or_default(); | 422 | .unwrap_or_default(); |
| 422 | self.chat | 423 | self.chat |
| 423 | .message_input | 424 | .message_input |
| 424 | - .update(cx, |input, cx| input.set_value(text, window, cx)); | 425 | + .update(cx, |input, cx| input.fill(text, window, cx)); |
| 425 | } | 426 | } |
| 426 | 427 | ||
| 427 | pub(super) fn reply(&mut self, message_id: Id, window: &mut Window, cx: &mut Context<Self>) { | 428 | pub(super) fn reply(&mut self, message_id: Id, window: &mut Window, cx: &mut Context<Self>) { |
| @@ -445,7 +446,7 @@ impl Yumush { | |||
| 445 | 446 | ||
| 446 | self.chat | 447 | self.chat |
| 447 | .message_input | 448 | .message_input |
| 448 | - .update(cx, |input, cx| input.set_value(body, window, cx)); | 449 | + .update(cx, |input, cx| input.fill(body, window, cx)); |
| 449 | self.chat.composer = Composer::Edit { message_id }; | 450 | self.chat.composer = Composer::Edit { message_id }; |
| 450 | self.chat.focus(window, cx); | 451 | self.chat.focus(window, cx); |
| 451 | cx.notify(); | 452 | cx.notify(); |
crates/client/src/gui/glyph.rsadded+257 -0
| @@ -0,0 +1,257 @@ | |||
| 1 | +use gpui_kit::{ | ||
| 2 | + AnyElement, App, Context, Div, Entity, IntoElement, ParentElement, Pixels, Rems, SharedString, | ||
| 3 | + Styled, Window, | ||
| 4 | + component::input::{InlineToken, InlineTokenContext, InputContent, InputState, TextareaState}, | ||
| 5 | + component::text::{ | ||
| 6 | + InlineElement, InlineRenderContext, MarkdownExtensions, MarkdownNode, MarkdownParseContext, | ||
| 7 | + MarkdownPlugin, markdown_ast, | ||
| 8 | + }, | ||
| 9 | + div, img, rems, | ||
| 10 | +}; | ||
| 11 | + | ||
| 12 | +use gpui_kit::{ | ||
| 13 | + Anchor, InteractiveElement as _, StatefulInteractiveElement as _, assets::IconName, | ||
| 14 | + component::popover::Popover, prelude::FluentBuilder as _, px, | ||
| 15 | +}; | ||
| 16 | + | ||
| 17 | +use super::{ | ||
| 18 | + Palette, Yumush, clickable, | ||
| 19 | + style::{radius, size, space}, | ||
| 20 | +}; | ||
| 21 | +use crate::emoji::{self, Piece}; | ||
| 22 | + | ||
| 23 | +const SCALE: f32 = 1.25; | ||
| 24 | +const SCHEME: &str = "emoji:"; | ||
| 25 | + | ||
| 26 | +pub fn picture(emoji: &str, size: impl Into<gpui_kit::AbsoluteLength> + Copy) -> AnyElement { | ||
| 27 | + match emoji::image(emoji) { | ||
| 28 | + Some(image) => img(image).size(size.into()).flex_none().into_any_element(), | ||
| 29 | + None => div().child(emoji.to_string()).into_any_element(), | ||
| 30 | + } | ||
| 31 | +} | ||
| 32 | + | ||
| 33 | +pub fn sized(text: Rems) -> Rems { | ||
| 34 | + rems(text.0 * SCALE) | ||
| 35 | +} | ||
| 36 | + | ||
| 37 | +pub fn line(content: SharedString, text: Rems) -> Div { | ||
| 38 | + let row = div().flex().items_center().min_w_0().overflow_hidden(); | ||
| 39 | + if emoji::plain(&content) { | ||
| 40 | + return row.child(div().min_w_0().truncate().child(content)); | ||
| 41 | + } | ||
| 42 | + let size = sized(text); | ||
| 43 | + row.children(emoji::pieces(&content).into_iter().map(|piece| { | ||
| 44 | + match piece { | ||
| 45 | + Piece::Text(text) => div() | ||
| 46 | + .min_w_0() | ||
| 47 | + .truncate() | ||
| 48 | + .whitespace_nowrap() | ||
| 49 | + .child(text.to_string()) | ||
| 50 | + .into_any_element(), | ||
| 51 | + Piece::Emoji(emoji) => picture(emoji, size), | ||
| 52 | + } | ||
| 53 | + })) | ||
| 54 | +} | ||
| 55 | + | ||
| 56 | +pub fn wrapped(content: SharedString, text: Rems) -> Div { | ||
| 57 | + let flow = div().flex().flex_wrap().items_center().min_w_0(); | ||
| 58 | + if emoji::plain(&content) { | ||
| 59 | + return div().min_w_0().child(content); | ||
| 60 | + } | ||
| 61 | + let size = sized(text); | ||
| 62 | + flow.children(emoji::pieces(&content).into_iter().flat_map(|piece| { | ||
| 63 | + match piece { | ||
| 64 | + Piece::Text(text) => text | ||
| 65 | + .split_inclusive(' ') | ||
| 66 | + .map(|word| { | ||
| 67 | + div() | ||
| 68 | + .whitespace_nowrap() | ||
| 69 | + .child(word.replace(' ', "\u{a0}")) | ||
| 70 | + .into_any_element() | ||
| 71 | + }) | ||
| 72 | + .collect::<Vec<_>>(), | ||
| 73 | + Piece::Emoji(emoji) => vec![picture(emoji, size)], | ||
| 74 | + } | ||
| 75 | + })) | ||
| 76 | +} | ||
| 77 | + | ||
| 78 | +const TOKEN: f32 = 0.85; | ||
| 79 | + | ||
| 80 | +pub fn content(text: &str) -> InputContent { | ||
| 81 | + let base = text.as_ptr() as usize; | ||
| 82 | + emoji::pieces(text) | ||
| 83 | + .into_iter() | ||
| 84 | + .filter_map(|piece| match piece { | ||
| 85 | + Piece::Emoji(emoji) => Some(emoji), | ||
| 86 | + Piece::Text(_) => None, | ||
| 87 | + }) | ||
| 88 | + .fold(InputContent::new(text.to_string()), |content, emoji| { | ||
| 89 | + let start = emoji.as_ptr() as usize - base; | ||
| 90 | + let token = InlineToken::new(emoji::key(emoji), emoji.to_string()); | ||
| 91 | + match content | ||
| 92 | + .clone() | ||
| 93 | + .with_token(start..start + emoji.len(), token) | ||
| 94 | + { | ||
| 95 | + Ok(content) => content, | ||
| 96 | + Err(_) => content, | ||
| 97 | + } | ||
| 98 | + }) | ||
| 99 | +} | ||
| 100 | + | ||
| 101 | +pub fn token(context: &InlineTokenContext, _: &mut Window, _: &mut App) -> AnyElement { | ||
| 102 | + let size: Pixels = context.line_height() * TOKEN; | ||
| 103 | + picture(context.token().text(), size) | ||
| 104 | +} | ||
| 105 | + | ||
| 106 | +pub trait Fill { | ||
| 107 | + fn fill(&mut self, text: impl Into<SharedString>, window: &mut Window, cx: &mut Context<Self>) | ||
| 108 | + where | ||
| 109 | + Self: Sized; | ||
| 110 | + fn mark(&mut self, cx: &mut Context<Self>) | ||
| 111 | + where | ||
| 112 | + Self: Sized; | ||
| 113 | +} | ||
| 114 | + | ||
| 115 | +macro_rules! fill { | ||
| 116 | + ($state:ty) => { | ||
| 117 | + impl Fill for $state { | ||
| 118 | + fn fill( | ||
| 119 | + &mut self, | ||
| 120 | + text: impl Into<SharedString>, | ||
| 121 | + window: &mut Window, | ||
| 122 | + cx: &mut Context<Self>, | ||
| 123 | + ) { | ||
| 124 | + self.set_value(content(&text.into()), window, cx); | ||
| 125 | + } | ||
| 126 | + | ||
| 127 | + fn mark(&mut self, cx: &mut Context<Self>) { | ||
| 128 | + let content = content(&self.text().to_string()); | ||
| 129 | + let _ = self.set_tokens(content, cx); | ||
| 130 | + } | ||
| 131 | + } | ||
| 132 | + }; | ||
| 133 | +} | ||
| 134 | + | ||
| 135 | +fill!(InputState); | ||
| 136 | +fill!(TextareaState); | ||
| 137 | + | ||
| 138 | +struct Glyphs; | ||
| 139 | + | ||
| 140 | +impl MarkdownPlugin for Glyphs { | ||
| 141 | + fn name(&self) -> &str { | ||
| 142 | + "emoji" | ||
| 143 | + } | ||
| 144 | + | ||
| 145 | + fn parse( | ||
| 146 | + &self, | ||
| 147 | + node: &markdown_ast::Node, | ||
| 148 | + _: &MarkdownParseContext<'_>, | ||
| 149 | + ) -> Option<MarkdownNode> { | ||
| 150 | + let markdown_ast::Node::Image(image) = node else { | ||
| 151 | + return None; | ||
| 152 | + }; | ||
| 153 | + image.url.strip_prefix(SCHEME)?; | ||
| 154 | + Some(MarkdownNode::new("emoji", image.alt.clone()).text(image.alt.clone())) | ||
| 155 | + } | ||
| 156 | + | ||
| 157 | + fn render_inline( | ||
| 158 | + &self, | ||
| 159 | + node: &MarkdownNode, | ||
| 160 | + context: &InlineRenderContext, | ||
| 161 | + _: &mut Window, | ||
| 162 | + _: &mut App, | ||
| 163 | + ) -> Option<InlineElement> { | ||
| 164 | + let size: Pixels = context.font_size() * SCALE; | ||
| 165 | + Some(InlineElement::new(picture(node.as_text(), size))) | ||
| 166 | + } | ||
| 167 | +} | ||
| 168 | + | ||
| 169 | +pub fn extensions() -> MarkdownExtensions { | ||
| 170 | + MarkdownExtensions::default().plugin(Glyphs) | ||
| 171 | +} | ||
| 172 | + | ||
| 173 | +pub type Pick = std::rc::Rc<dyn Fn(&'static str, &mut Window, &mut App)>; | ||
| 174 | + | ||
| 175 | +pub fn picker_button( | ||
| 176 | + id: &'static str, | ||
| 177 | + entity: &Entity<Yumush>, | ||
| 178 | + palette: Palette, | ||
| 179 | + pick: Pick, | ||
| 180 | +) -> impl IntoElement { | ||
| 181 | + let entity = entity.clone(); | ||
| 182 | + Popover::new(id) | ||
| 183 | + .anchor(Anchor::BottomLeft) | ||
| 184 | + .appearance(false) | ||
| 185 | + .trigger(super::composer::trigger_icon( | ||
| 186 | + SharedString::from(format!("{id}_trigger")), | ||
| 187 | + IconName::FaceSlightlySmiling, | ||
| 188 | + size::CONTROL_SM, | ||
| 189 | + palette, | ||
| 190 | + )) | ||
| 191 | + .content(move |_, _, cx| { | ||
| 192 | + let popover = cx.entity(); | ||
| 193 | + let pick = pick.clone(); | ||
| 194 | + let close: Pick = std::rc::Rc::new(move |emoji, window, cx| { | ||
| 195 | + popover.update(cx, |state, cx| state.dismiss(window, cx)); | ||
| 196 | + pick(emoji, window, cx); | ||
| 197 | + }); | ||
| 198 | + picker(&entity, entity.read(cx).emoji_group, palette, close) | ||
| 199 | + }) | ||
| 200 | +} | ||
| 201 | + | ||
| 202 | +pub fn picker(entity: &Entity<Yumush>, group: usize, palette: Palette, pick: Pick) -> Div { | ||
| 203 | + let t = palette.tokens; | ||
| 204 | + let tabs = emoji::GROUPS.iter().enumerate().map(|(index, _)| { | ||
| 205 | + let entity = entity.clone(); | ||
| 206 | + let face = emoji::group(index).first().copied().unwrap_or_default(); | ||
| 207 | + clickable(("emoji_group", index), palette, move |_, cx| { | ||
| 208 | + entity.update(cx, |yumush, cx| { | ||
| 209 | + yumush.emoji_group = index; | ||
| 210 | + cx.notify(); | ||
| 211 | + }) | ||
| 212 | + }) | ||
| 213 | + .size(px(size::CONTROL_SM)) | ||
| 214 | + .flex() | ||
| 215 | + .items_center() | ||
| 216 | + .justify_center() | ||
| 217 | + .rounded(px(radius::MD)) | ||
| 218 | + .when(index == group, |tab| tab.bg(t.press())) | ||
| 219 | + .child(picture(face, px(size::ICON))) | ||
| 220 | + }); | ||
| 221 | + let grid = emoji::group(group).iter().map(|emoji| { | ||
| 222 | + let pick = pick.clone(); | ||
| 223 | + let emoji: &'static str = emoji; | ||
| 224 | + clickable( | ||
| 225 | + SharedString::from(format!("emoji_{emoji}")), | ||
| 226 | + palette, | ||
| 227 | + move |window, cx| pick(emoji, window, cx), | ||
| 228 | + ) | ||
| 229 | + .size(px(size::CONTROL_SM)) | ||
| 230 | + .flex() | ||
| 231 | + .items_center() | ||
| 232 | + .justify_center() | ||
| 233 | + .rounded(px(radius::MD)) | ||
| 234 | + .child(picture(emoji, px(size::ICON))) | ||
| 235 | + }); | ||
| 236 | + super::parts::popover(t) | ||
| 237 | + .w(px(size::POPOVER + space::XL)) | ||
| 238 | + .gap(px(space::SM)) | ||
| 239 | + .child(div().flex().flex_wrap().children(tabs)) | ||
| 240 | + .child(super::parts::thread(t)) | ||
| 241 | + .child( | ||
| 242 | + div() | ||
| 243 | + .id("emoji_grid") | ||
| 244 | + .h(px(size::POPOVER)) | ||
| 245 | + .overflow_y_scroll() | ||
| 246 | + .flex() | ||
| 247 | + .flex_wrap() | ||
| 248 | + .content_start() | ||
| 249 | + .children(grid), | ||
| 250 | + ) | ||
| 251 | + .child( | ||
| 252 | + div() | ||
| 253 | + .text_size(super::text(super::style::text::CAPTION)) | ||
| 254 | + .text_color(palette.muted) | ||
| 255 | + .child("Twemoji · CC-BY 4.0"), | ||
| 256 | + ) | ||
| 257 | +} | ||
crates/client/src/gui/media_view.rsmodified+9 -8
| @@ -619,9 +619,12 @@ fn name_block(attachment: &Attachment, detail: String, palette: Palette) -> impl | |||
| 619 | .flex_col() | 619 | .flex_col() |
| 620 | .child( | 620 | .child( |
| 621 | div() | 621 | div() |
| 622 | - .truncate() | 622 | + .min_w_0() |
| 623 | .text_color(palette.text) | 623 | .text_color(palette.text) |
| 624 | - .child(attachment.name.clone()), | 624 | + .child(super::glyph::line( |
| 625 | + attachment.name.clone().into(), | ||
| 626 | + super::text(super::style::text::UI), | ||
| 627 | + )), | ||
| 625 | ) | 628 | ) |
| 626 | .child( | 629 | .child( |
| 627 | div() | 630 | div() |
| @@ -891,12 +894,10 @@ pub fn pending_row( | |||
| 891 | .rounded(px(radius::MD)) | 894 | .rounded(px(radius::MD)) |
| 892 | .bg(palette.hover) | 895 | .bg(palette.hover) |
| 893 | .text_size(text(text::CAPTION)) | 896 | .text_size(text(text::CAPTION)) |
| 894 | - .child( | 897 | + .child(div().max_w(px(size::SIDEBAR)).child(super::glyph::line( |
| 895 | - div() | 898 | + attachment.name.clone().into(), |
| 896 | - .max_w(px(size::SIDEBAR)) | 899 | + super::text(super::style::text::CAPTION), |
| 897 | - .truncate() | 900 | + ))) |
| 898 | - .child(attachment.name.clone()), | ||
| 899 | - ) | ||
| 900 | .child( | 901 | .child( |
| 901 | clickable( | 902 | clickable( |
| 902 | format!("unattach_{}", attachment.id), | 903 | format!("unattach_{}", attachment.id), |
crates/client/src/gui/message_actions.rsmodified+16 -17
| @@ -75,7 +75,7 @@ pub fn reactions( | |||
| 75 | palette.panel | 75 | palette.panel |
| 76 | }) | 76 | }) |
| 77 | .text_size(text(text::CAPTION)) | 77 | .text_size(text(text::CAPTION)) |
| 78 | - .child(chip_emoji) | 78 | + .child(super::glyph::picture(&chip_emoji, px(size::ICON_SM))) |
| 79 | .child(div().text_color(palette.muted).child(count.to_string())) | 79 | .child(div().text_color(palette.muted).child(count.to_string())) |
| 80 | })) | 80 | })) |
| 81 | } | 81 | } |
| @@ -121,8 +121,7 @@ pub fn react_popover( | |||
| 121 | .items_center() | 121 | .items_center() |
| 122 | .justify_center() | 122 | .justify_center() |
| 123 | .rounded(px(radius::MD)) | 123 | .rounded(px(radius::MD)) |
| 124 | - .text_size(text(text::BODY)) | 124 | + .child(super::glyph::picture(emoji, px(size::ICON))) |
| 125 | - .child(emoji) | ||
| 126 | })) | 125 | })) |
| 127 | }) | 126 | }) |
| 128 | } | 127 | } |
| @@ -172,13 +171,10 @@ pub fn quote_line(message: &Message, chat: &Chat, palette: Palette) -> Option<im | |||
| 172 | .text_color(palette.tinted(user.id)) | 171 | .text_color(palette.tinted(user.id)) |
| 173 | .child(user.username.clone()) | 172 | .child(user.username.clone()) |
| 174 | })) | 173 | })) |
| 175 | - .child( | 174 | + .child(div().flex_1().min_w_0().child(super::glyph::line( |
| 176 | - div() | 175 | + quote_text("e.body, quote.attachments).into(), |
| 177 | - .flex_1() | 176 | + super::text(super::style::text::LABEL), |
| 178 | - .min_w_0() | 177 | + ))), |
| 179 | - .truncate() | ||
| 180 | - .child(quote_text("e.body, quote.attachments)), | ||
| 181 | - ), | ||
| 182 | ) | 178 | ) |
| 183 | } | 179 | } |
| 184 | 180 | ||
| @@ -275,7 +271,10 @@ pub fn search_popover(chat: &Chat, entity: &Entity<Yumush>, palette: Palette) -> | |||
| 275 | .text_color(palette.muted) | 271 | .text_color(palette.muted) |
| 276 | .child(time.clone()) | 272 | .child(time.clone()) |
| 277 | })) | 273 | })) |
| 278 | - .child(div().flex_1().min_w_0().truncate().child(hit.body.clone())) | 274 | + .child(div().flex_1().min_w_0().child(super::glyph::line( |
| 275 | + hit.body.clone().into(), | ||
| 276 | + super::text(super::style::text::UI), | ||
| 277 | + ))) | ||
| 279 | })) | 278 | })) |
| 280 | }) | 279 | }) |
| 281 | } | 280 | } |
| @@ -310,12 +309,12 @@ pub fn pins_popover(chat: &Chat, entity: &Entity<Yumush>, palette: Palette) -> i | |||
| 310 | .gap(px(space::XXS)) | 309 | .gap(px(space::XXS)) |
| 311 | .children(pins.iter().map(|hit| { | 310 | .children(pins.iter().map(|hit| { |
| 312 | jump_row("pin_hit", hit, &entity, &popover, palette).child( | 311 | jump_row("pin_hit", hit, &entity, &popover, palette).child( |
| 313 | - div() | 312 | + div().flex_1().min_w_0().text_color(palette.muted).child( |
| 314 | - .flex_1() | 313 | + super::glyph::line( |
| 315 | - .min_w_0() | 314 | + hit.body.clone().into(), |
| 316 | - .truncate() | 315 | + super::text(super::style::text::UI), |
| 317 | - .text_color(palette.muted) | 316 | + ), |
| 318 | - .child(hit.body.clone()), | 317 | + ), |
| 319 | ) | 318 | ) |
| 320 | })) | 319 | })) |
| 321 | }) | 320 | }) |
crates/client/src/gui/parts.rsmodified+9 -5
| @@ -56,14 +56,18 @@ pub fn words(content: impl Into<SharedString>, style: Text, ink: Ink, t: Tokens) | |||
| 56 | Text::Title => FontWeight::SEMIBOLD, | 56 | Text::Title => FontWeight::SEMIBOLD, |
| 57 | _ => FontWeight::NORMAL, | 57 | _ => FontWeight::NORMAL, |
| 58 | }; | 58 | }; |
| 59 | - div() | 59 | + let content = content.into(); |
| 60 | - .text_size(t.text(style.size())) | 60 | + let size = t.text(style.size()); |
| 61 | + let base = div() | ||
| 62 | + .text_size(size) | ||
| 61 | .line_height(gpui_kit::relative(leading::TEXT)) | 63 | .line_height(gpui_kit::relative(leading::TEXT)) |
| 62 | .font_weight(weight) | 64 | .font_weight(weight) |
| 63 | .text_color(ink.color(t)) | 65 | .text_color(ink.color(t)) |
| 64 | - .min_w_0() | 66 | + .min_w_0(); |
| 65 | - .truncate() | 67 | + if crate::emoji::plain(&content) { |
| 66 | - .child(content.into()) | 68 | + return base.truncate().child(content); |
| 69 | + } | ||
| 70 | + base.child(super::glyph::line(content, size)) | ||
| 67 | } | 71 | } |
| 68 | 72 | ||
| 69 | pub fn strong(content: impl Into<SharedString>, style: Text, t: Tokens) -> Div { | 73 | pub fn strong(content: impl Into<SharedString>, style: Text, t: Tokens) -> Div { |
crates/client/src/gui/poll.rsmodified+18 -22
| @@ -105,13 +105,10 @@ fn voters_popover(key: &str, poll: &Poll, entity: &Entity<Yumush>, palette: Pale | |||
| 105 | .gap(px(space::SM)) | 105 | .gap(px(space::SM)) |
| 106 | .text_size(text(text::CAPTION)) | 106 | .text_size(text(text::CAPTION)) |
| 107 | .text_color(palette.muted) | 107 | .text_color(palette.muted) |
| 108 | - .child( | 108 | + .child(div().flex_1().min_w_0().child(super::glyph::line( |
| 109 | - div() | 109 | + option.text.clone().into(), |
| 110 | - .flex_1() | 110 | + super::text(super::style::text::UI), |
| 111 | - .min_w_0() | 111 | + ))) |
| 112 | - .truncate() | ||
| 113 | - .child(option.text.clone()), | ||
| 114 | - ) | ||
| 115 | .child( | 112 | .child( |
| 116 | div() | 113 | div() |
| 117 | .flex_shrink_0() | 114 | .flex_shrink_0() |
| @@ -270,13 +267,10 @@ pub fn poll_card( | |||
| 270 | .child(Icon::new(IconName::Check).size(px(size::ICON_SM))) | 267 | .child(Icon::new(IconName::Check).size(px(size::ICON_SM))) |
| 271 | }), | 268 | }), |
| 272 | ) | 269 | ) |
| 273 | - .child( | 270 | + .child(div().flex_1().min_w_0().child(super::glyph::line( |
| 274 | - div() | 271 | + option.text.clone().into(), |
| 275 | - .flex_1() | 272 | + super::text(super::style::text::UI), |
| 276 | - .min_w_0() | 273 | + ))) |
| 277 | - .truncate() | ||
| 278 | - .child(option.text.clone()), | ||
| 279 | - ) | ||
| 280 | .children((!voters_here.is_empty()).then(|| { | 274 | .children((!voters_here.is_empty()).then(|| { |
| 281 | div() | 275 | div() |
| 282 | .flex() | 276 | .flex() |
| @@ -388,7 +382,10 @@ pub fn poll_card( | |||
| 388 | .min_w_0() | 382 | .min_w_0() |
| 389 | .font_weight(FontWeight::SEMIBOLD) | 383 | .font_weight(FontWeight::SEMIBOLD) |
| 390 | .text_size(text(text::UI)) | 384 | .text_size(text(text::UI)) |
| 391 | - .child(poll.question.clone()), | 385 | + .child(super::glyph::wrapped( |
| 386 | + poll.question.clone().into(), | ||
| 387 | + super::text(super::style::text::UI), | ||
| 388 | + )), | ||
| 392 | ) | 389 | ) |
| 393 | .child( | 390 | .child( |
| 394 | div() | 391 | div() |
| @@ -480,13 +477,12 @@ impl Yumush { | |||
| 480 | .text_color(palette.muted) | 477 | .text_color(palette.muted) |
| 481 | .child(Icon::new(IconName::ChartBar).size(px(size::ICON_SM))), | 478 | .child(Icon::new(IconName::ChartBar).size(px(size::ICON_SM))), |
| 482 | ) | 479 | ) |
| 483 | - .child( | 480 | + .child(div().min_w_0().font_weight(FontWeight::SEMIBOLD).child( |
| 484 | - div() | 481 | + super::glyph::line( |
| 485 | - .min_w_0() | 482 | + poll.question.clone().into(), |
| 486 | - .truncate() | 483 | + super::text(super::style::text::UI), |
| 487 | - .font_weight(FontWeight::SEMIBOLD) | 484 | + ), |
| 488 | - .child(poll.question.clone()), | 485 | + )) |
| 489 | - ) | ||
| 490 | .child( | 486 | .child( |
| 491 | div() | 487 | div() |
| 492 | .flex_shrink_0() | 488 | .flex_shrink_0() |
crates/client/src/gui/profile.rsmodified+21 -4
| @@ -1,3 +1,4 @@ | |||
| 1 | +use crate::gui::glyph::Fill as _; | ||
| 1 | use common::model::Id; | 2 | use common::model::Id; |
| 2 | use gpui_kit::prelude::FluentBuilder as _; | 3 | use gpui_kit::prelude::FluentBuilder as _; |
| 3 | use std::collections::VecDeque; | 4 | use std::collections::VecDeque; |
| @@ -340,8 +341,11 @@ impl Card { | |||
| 340 | )); | 341 | )); |
| 341 | } | 342 | } |
| 342 | if self.card_menu == CardMenu::Status { | 343 | if self.card_menu == CardMenu::Status { |
| 344 | + let status = self.status.clone(); | ||
| 343 | return names.child( | 345 | return names.child( |
| 344 | div() | 346 | div() |
| 347 | + .flex() | ||
| 348 | + .items_center() | ||
| 345 | .border_b(px(stroke::LINE)) | 349 | .border_b(px(stroke::LINE)) |
| 346 | .border_color(t.paper()) | 350 | .border_color(t.paper()) |
| 347 | .child( | 351 | .child( |
| @@ -349,12 +353,25 @@ impl Card { | |||
| 349 | palette, | 353 | palette, |
| 350 | gpui_kit::component::input::Input::new( | 354 | gpui_kit::component::input::Input::new( |
| 351 | &self.status, | 355 | &self.status, |
| 352 | - ), | 356 | + ) |
| 357 | + .token(super::glyph::token), | ||
| 353 | ) | 358 | ) |
| 354 | .text_size(text(text::CAPTION)) | 359 | .text_size(text(text::CAPTION)) |
| 355 | .px_0() | 360 | .px_0() |
| 356 | - .w_full(), | 361 | + .flex_1(), |
| 357 | - ), | 362 | + ) |
| 363 | + .child(super::glyph::picker_button( | ||
| 364 | + "status_emoji", | ||
| 365 | + entity, | ||
| 366 | + palette, | ||
| 367 | + std::rc::Rc::new(move |emoji, window, cx| { | ||
| 368 | + status.update(cx, |state, cx| { | ||
| 369 | + state.insert(emoji, window, cx); | ||
| 370 | + state.focus(window, cx); | ||
| 371 | + }); | ||
| 372 | + status.update(cx, |state, cx| state.mark(cx)); | ||
| 373 | + }), | ||
| 374 | + )), | ||
| 358 | ); | 375 | ); |
| 359 | } | 376 | } |
| 360 | names.child( | 377 | names.child( |
| @@ -661,7 +678,7 @@ fn edit_status(entity: &Entity<Yumush>, status: &str, palette: Palette) -> impl | |||
| 661 | entity_action(entity, move |yumush, window, cx| { | 678 | entity_action(entity, move |yumush, window, cx| { |
| 662 | yumush.chat.card_menu = CardMenu::Status; | 679 | yumush.chat.card_menu = CardMenu::Status; |
| 663 | yumush.chat.status_input.update(cx, |input, cx| { | 680 | yumush.chat.status_input.update(cx, |input, cx| { |
| 664 | - input.set_value(status.clone(), window, cx); | 681 | + input.fill(status.clone(), window, cx); |
| 665 | input.focus(window, cx); | 682 | input.focus(window, cx); |
| 666 | }); | 683 | }); |
| 667 | cx.notify(); | 684 | cx.notify(); |
crates/client/src/gui/sidebar.rsmodified+4 -1
| @@ -1238,7 +1238,10 @@ pub(super) fn input_box(input: &Entity<InputState>, palette: Palette) -> Div { | |||
| 1238 | .gap(px(space::SM)) | 1238 | .gap(px(space::SM)) |
| 1239 | .text_color(palette.muted) | 1239 | .text_color(palette.muted) |
| 1240 | .child(Icon::new(IconName::Search).size(px(size::ICON_SM))) | 1240 | .child(Icon::new(IconName::Search).size(px(size::ICON_SM))) |
| 1241 | - .child(bare_input(palette, Input::new(input))) | 1241 | + .child(bare_input( |
| 1242 | + palette, | ||
| 1243 | + Input::new(input).token(super::glyph::token), | ||
| 1244 | + )) | ||
| 1242 | } | 1245 | } |
| 1243 | 1246 | ||
| 1244 | fn group(title: &'static str, palette: Palette, rows: Vec<AnyElement>) -> Option<Div> { | 1247 | fn group(title: &'static str, palette: Palette, rows: Vec<AnyElement>) -> Option<Div> { |
crates/client/src/gui/snippet.rsmodified+4 -1
| @@ -108,7 +108,10 @@ fn snippet_row( | |||
| 108 | div() | 108 | div() |
| 109 | .line_height(relative(1.5)) | 109 | .line_height(relative(1.5)) |
| 110 | .text_color(palette.body) | 110 | .text_color(palette.body) |
| 111 | - .child(item.body.clone()), | 111 | + .child(super::glyph::wrapped( |
| 112 | + item.body.clone().into(), | ||
| 113 | + super::text(super::style::text::UI), | ||
| 114 | + )), | ||
| 112 | ) | 115 | ) |
| 113 | }) | 116 | }) |
| 114 | .children(media_view::attachments( | 117 | .children(media_view::attachments( |
crates/client/src/gui/social.rsmodified+1 -1
| @@ -333,7 +333,7 @@ impl Yumush { | |||
| 333 | .flex() | 333 | .flex() |
| 334 | .flex_col() | 334 | .flex_col() |
| 335 | .gap(px(space::MD)) | 335 | .gap(px(space::MD)) |
| 336 | - .child(Input::new(&dialog_input)) | 336 | + .child(Input::new(&dialog_input).token(super::glyph::token)) |
| 337 | .children(result), | 337 | .children(result), |
| 338 | ) | 338 | ) |
| 339 | }); | 339 | }); |
crates/client/src/gui/widget.rsmodified+5 -2
| @@ -37,7 +37,7 @@ pub(super) fn panel(palette: Palette) -> Div { | |||
| 37 | } | 37 | } |
| 38 | 38 | ||
| 39 | pub(super) fn field(palette: Palette, input: &Entity<InputState>) -> Div { | 39 | pub(super) fn field(palette: Palette, input: &Entity<InputState>) -> Div { |
| 40 | - frame(palette, Input::new(input)) | 40 | + frame(palette, Input::new(input).token(super::glyph::token)) |
| 41 | } | 41 | } |
| 42 | 42 | ||
| 43 | pub(super) fn compact_frame(palette: Palette) -> Div { | 43 | pub(super) fn compact_frame(palette: Palette) -> Div { |
| @@ -50,7 +50,10 @@ pub(super) fn compact_frame(palette: Palette) -> Div { | |||
| 50 | } | 50 | } |
| 51 | 51 | ||
| 52 | pub(super) fn compact_field(palette: Palette, input: &Entity<InputState>) -> Div { | 52 | pub(super) fn compact_field(palette: Palette, input: &Entity<InputState>) -> Div { |
| 53 | - compact_frame(palette).child(bare_input(palette, Input::new(input))) | 53 | + compact_frame(palette).child(bare_input( |
| 54 | + palette, | ||
| 55 | + Input::new(input).token(super::glyph::token), | ||
| 56 | + )) | ||
| 54 | } | 57 | } |
| 55 | 58 | ||
| 56 | pub(super) fn frame(palette: Palette, input: Input) -> Div { | 59 | pub(super) fn frame(palette: Palette, input: Input) -> Div { |
crates/client/src/lib.rsmodified+1 -0
| @@ -6,6 +6,7 @@ use tracing::warn; | |||
| 6 | pub mod accounts; | 6 | pub mod accounts; |
| 7 | pub mod avatar; | 7 | pub mod avatar; |
| 8 | pub mod embed; | 8 | pub mod embed; |
| 9 | +pub mod emoji; | ||
| 9 | pub mod gui; | 10 | pub mod gui; |
| 10 | pub mod media; | 11 | pub mod media; |
| 11 | pub mod mutes; | 12 | pub mod mutes; |
crates/client/src/main.rsmodified+1 -0
| @@ -34,6 +34,7 @@ fn main() { | |||
| 34 | ), | 34 | ), |
| 35 | ) | 35 | ) |
| 36 | .init(); | 36 | .init(); |
| 37 | + client::emoji::warm(); | ||
| 37 | 38 | ||
| 38 | if let Ok(spec) = std::env::var("YUMUSH_GALLERY") { | 39 | if let Ok(spec) = std::env::var("YUMUSH_GALLERY") { |
| 39 | gallery(spec); | 40 | gallery(spec); |