cursor-icon-1.1.0/.cargo_vcs_info.json0000644000000001360000000000100132760ustar { "git": { "sha1": "9a8f7d0fea56b6d032041f83ff0142325e848ea0" }, "path_in_vcs": "" }cursor-icon-1.1.0/.github/workflows/ci.yml000064400000000000000000000020251046102023000166000ustar 00000000000000name: CI on: pull_request: push: branches: [main] env: RUST_BACKTRACE: 1 CARGO_INCREMENTAL: 0 RUSTFLAGS: "-Cdebuginfo=0 --deny=warnings" RUSTDOCFLAGS: "--deny=warnings" jobs: fmt: name: Check Formatting runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - uses: hecrj/setup-rust-action@v1 with: rust-version: nightly components: rustfmt - name: Check Formatting run: cargo +nightly fmt --all -- --check tests: name: Tests runs-on: ubuntu-latest strategy: matrix: rust_version: ["1.65", stable, nightly] steps: - uses: actions/checkout@v2 - uses: hecrj/setup-rust-action@v1 with: rust-version: ${{ matrix.rust_version }} - name: Check documentation run: cargo doc --no-deps --document-private-items - name: Run tests run: cargo test --verbose - name: Run tests with no default features run: cargo test --verbose --no-default-features --tests cursor-icon-1.1.0/.gitignore000064400000000000000000000000241046102023000140520ustar 00000000000000/target /Cargo.lock cursor-icon-1.1.0/CHANGELOG.md000064400000000000000000000006301046102023000136760ustar 00000000000000# Changelog All notable changes to cursor-icon are documented in this file. The sections should follow the order `Packaging`, `Added`, `Changed`, `Fixed` and `Removed`. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ## Unreleased ## 1.1.0 - Bump MSRV from `1.64` to `1.65`. - Add access to alternative names for cursor icons through the `CursorIcon::alt_names` method. cursor-icon-1.1.0/Cargo.toml0000644000000021340000000000100112740ustar # THIS FILE IS AUTOMATICALLY GENERATED BY CARGO # # When uploading crates to the registry Cargo will automatically # "normalize" Cargo.toml files for maximal compatibility # with all versions of Cargo and also rewrite `path` dependencies # to registry (e.g., crates.io) dependencies. # # If you are reading this file be aware that the original Cargo.toml # will likely look very different (and much more reasonable). # See Cargo.toml.orig for the original contents. [package] edition = "2021" rust-version = "1.65.0" name = "cursor-icon" version = "1.1.0" authors = ["Kirill Chibisov "] description = "Cross platform cursor icon type" readme = "README.md" keywords = [ "windowing", "cursor", ] categories = ["gui"] license = "MIT OR Apache-2.0 OR Zlib" repository = "https://github.com/rust-windowing/cursor-icon" [dependencies.serde] version = "1.0.162" features = ["derive"] optional = true default-features = false [dev-dependencies.wayland-client] version = "0.31.1" [dev-dependencies.wayland-cursor] version = "0.31.0" [features] alloc = [] default = ["std"] std = ["alloc"] cursor-icon-1.1.0/Cargo.toml.orig000064400000000000000000000011431046102023000147540ustar 00000000000000[package] name = "cursor-icon" version = "1.1.0" authors = ["Kirill Chibisov "] description = "Cross platform cursor icon type" repository = "https://github.com/rust-windowing/cursor-icon" keywords = ["windowing", "cursor"] license = "MIT OR Apache-2.0 OR Zlib" readme = "README.md" edition = "2021" categories = ["gui"] rust-version = "1.65.0" [dependencies] serde = { version = "1.0.162", default-features = false, features = ["derive"], optional = true } [features] default = ["std"] std = ["alloc"] alloc = [] [dev-dependencies] wayland-client = "0.31.1" wayland-cursor = "0.31.0" cursor-icon-1.1.0/LICENSE-APACHE000064400000000000000000000261221046102023000140150ustar 00000000000000 Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright 2023 Kirill Chibisov Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. cursor-icon-1.1.0/LICENSE-MIT000064400000000000000000000020431046102023000135210ustar 00000000000000Copyright (c) 2023 Kirill Chibisov Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. cursor-icon-1.1.0/LICENSE-ZLIB000064400000000000000000000015141046102023000136320ustar 00000000000000Copyright (c) 2023 Kirill Chibisov This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. cursor-icon-1.1.0/README.md000064400000000000000000000004331046102023000133450ustar 00000000000000# `cursor-icon`: A common cursor icon type This library provides standard type to work with the cursor icon accross multiple platforms. The transformation to the actual value used by the platform for this icon is left to the libraries like https://github.com/rust-windowing/winit. cursor-icon-1.1.0/rustfmt.toml000064400000000000000000000006651046102023000144760ustar 00000000000000format_code_in_doc_comments = true match_block_trailing_comma = true condense_wildcard_suffixes = true use_field_init_shorthand = true normalize_doc_attributes = true overflow_delimited_expr = true imports_granularity = "Module" use_small_heuristics = "Max" normalize_comments = true reorder_impl_items = true use_try_shorthand = true newline_style = "Unix" format_strings = true wrap_comments = true comment_width = 80 edition = "2021" cursor-icon-1.1.0/src/lib.rs000064400000000000000000000406751046102023000140050ustar 00000000000000// SPDX-License-Identifier: MIT OR Apache-2.0 OR Zlib #![cfg_attr(not(feature = "std"), no_std)] #![deny(rust_2018_idioms)] #![deny(rustdoc::broken_intra_doc_links)] #![deny(unsafe_op_in_unsafe_fn)] #![deny(improper_ctypes, improper_ctypes_definitions)] #![deny(clippy::all)] #![deny(missing_debug_implementations)] #![deny(missing_docs)] #![forbid(unsafe_code)] #![cfg_attr(feature = "cargo-clippy", deny(warnings))] #![cfg_attr(docsrs, feature(doc_auto_cfg))] //! The cross platform cursor icon type. //! //! This type is intended to be used as a standard interopability type between //! GUI frameworks in order to convey the cursor icon type. //! //! # Example //! //! ``` //! use cursor_icon::CursorIcon; //! //! # fn main() -> Result<(), Box> { //! // Parse a cursor icon from the string that describes it. //! let cursor_name = "pointer"; //! let cursor_icon: CursorIcon = cursor_name.parse()?; //! println!("The cursor icon is {:?}", cursor_icon); //! # Ok(()) //! # } //! ``` // This file contains a portion of the CSS Basic User Interface Module Level 3 // specification. In particular, the names for the cursor from the #cursor // section and documentation for some of the variants were taken. // // The original document is https://www.w3.org/TR/css-ui-3/#cursor. // Copyright © 2018 W3C® (MIT, ERCIM, Keio, Beihang) // // These documents were used under the terms of the following license. This W3C // license as well as the W3C short notice apply to the `CursorIcon` enum's // variants and documentation attached to them. // --------- BEGGINING OF W3C LICENSE // -------------------------------------------------------------- // // License // // By obtaining and/or copying this work, you (the licensee) agree that you have // read, understood, and will comply with the following terms and conditions. // // Permission to copy, modify, and distribute this work, with or without // modification, for any purpose and without fee or royalty is hereby granted, // provided that you include the following on ALL copies of the work or portions // thereof, including modifications: // // - The full text of this NOTICE in a location viewable to users of the // redistributed or derivative work. // - Any pre-existing intellectual property disclaimers, notices, or terms and // conditions. If none exist, the W3C Software and Document Short Notice // should be included. // - Notice of any changes or modifications, through a copyright statement on // the new code or document such as "This software or document includes // material copied from or derived from [title and URI of the W3C document]. // Copyright © [YEAR] W3C® (MIT, ERCIM, Keio, Beihang)." // // Disclaimers // // THIS WORK IS PROVIDED "AS IS," AND COPYRIGHT HOLDERS MAKE NO REPRESENTATIONS // OR WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO, WARRANTIES // OF MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF // THE SOFTWARE OR DOCUMENT WILL NOT INFRINGE ANY THIRD PARTY PATENTS, // COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS. // // COPYRIGHT HOLDERS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL OR // CONSEQUENTIAL DAMAGES ARISING OUT OF ANY USE OF THE SOFTWARE OR DOCUMENT. // // The name and trademarks of copyright holders may NOT be used in advertising // or publicity pertaining to the work without specific, written prior // permission. Title to copyright in this work will at all times remain with // copyright holders. // // --------- END OF W3C LICENSE // -------------------------------------------------------------------- // --------- BEGGINING OF W3C SHORT NOTICE // --------------------------------------------------------- // // winit: https://github.com/rust-windowing/cursor-icon // // Copyright © 2023 World Wide Web Consortium, (Massachusetts Institute of // Technology, European Research Consortium for Informatics and Mathematics, // Keio University, Beihang). All Rights Reserved. This work is distributed // under the W3C® Software License [1] in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or // FITNESS FOR A PARTICULAR PURPOSE. // // [1] http://www.w3.org/Consortium/Legal/copyright-software // // --------- END OF W3C SHORT NOTICE // -------------------------------------------------------------- #[cfg(feature = "serde")] #[macro_use] extern crate serde; // XXX for forwards compatibility. #[cfg(feature = "alloc")] extern crate alloc as _; /// Describes the appearance of the (usually mouse) cursor icon. /// /// The names are taken from the CSS W3C specification: /// /// /// # Examples /// /// ``` /// use cursor_icon::CursorIcon; /// /// // Get the cursor icon for the default cursor. /// let cursor_icon = CursorIcon::Default; /// ``` #[non_exhaustive] #[derive(Debug, Default, Copy, Clone, PartialEq, Eq, Hash)] #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] pub enum CursorIcon { /// The platform-dependent default cursor. Often rendered as arrow. #[default] Default, /// A context menu is available for the object under the cursor. Often /// rendered as an arrow with a small menu-like graphic next to it. ContextMenu, /// Help is available for the object under the cursor. Often rendered as a /// question mark or a balloon. Help, /// The cursor is a pointer that indicates a link. Often rendered as the /// backside of a hand with the index finger extended. Pointer, /// A progress indicator. The program is performing some processing, but is /// different from [`CursorIcon::Wait`] in that the user may still interact /// with the program. Progress, /// Indicates that the program is busy and the user should wait. Often /// rendered as a watch or hourglass. Wait, /// Indicates that a cell or set of cells may be selected. Often rendered as /// a thick plus-sign with a dot in the middle. Cell, /// A simple crosshair (e.g., short line segments resembling a "+" sign). /// Often used to indicate a two dimensional bitmap selection mode. Crosshair, /// Indicates text that may be selected. Often rendered as an I-beam. Text, /// Indicates vertical-text that may be selected. Often rendered as a /// horizontal I-beam. VerticalText, /// Indicates an alias of/shortcut to something is to be created. Often /// rendered as an arrow with a small curved arrow next to it. Alias, /// Indicates something is to be copied. Often rendered as an arrow with a /// small plus sign next to it. Copy, /// Indicates something is to be moved. Move, /// Indicates that the dragged item cannot be dropped at the current cursor /// location. Often rendered as a hand or pointer with a small circle with a /// line through it. NoDrop, /// Indicates that the requested action will not be carried out. Often /// rendered as a circle with a line through it. NotAllowed, /// Indicates that something can be grabbed (dragged to be moved). Often /// rendered as the backside of an open hand. Grab, /// Indicates that something is being grabbed (dragged to be moved). Often /// rendered as the backside of a hand with fingers closed mostly out of /// view. Grabbing, /// The east border to be moved. EResize, /// The north border to be moved. NResize, /// The north-east corner to be moved. NeResize, /// The north-west corner to be moved. NwResize, /// The south border to be moved. SResize, /// The south-east corner to be moved. SeResize, /// The south-west corner to be moved. SwResize, /// The west border to be moved. WResize, /// The east and west borders to be moved. EwResize, /// The south and north borders to be moved. NsResize, /// The north-east and south-west corners to be moved. NeswResize, /// The north-west and south-east corners to be moved. NwseResize, /// Indicates that the item/column can be resized horizontally. Often /// rendered as arrows pointing left and right with a vertical bar /// separating them. ColResize, /// Indicates that the item/row can be resized vertically. Often rendered as /// arrows pointing up and down with a horizontal bar separating them. RowResize, /// Indicates that the something can be scrolled in any direction. Often /// rendered as arrows pointing up, down, left, and right with a dot in the /// middle. AllScroll, /// Indicates that something can be zoomed in. Often rendered as a /// magnifying glass with a "+" in the center of the glass. ZoomIn, /// Indicates that something can be zoomed in. Often rendered as a /// magnifying glass with a "-" in the center of the glass. ZoomOut, } impl CursorIcon { /// The name of the cursor icon as defined in w3c standard. /// /// This name most of the time could be passed as is to cursor loading /// libraries on X11/Wayland and could be used as-is on web. /// /// # Examples /// /// ```no_run /// use cursor_icon::CursorIcon; /// use wayland_cursor::CursorTheme; /// /// # use wayland_client::Connection; /// # use wayland_client::protocol::wl_shm::WlShm; /// # fn test(conn: &Connection, shm: WlShm) -> Result<(), Box> { /// // Choose a cursor to load. /// let cursor = CursorIcon::Help; /// /// // Load the Wayland cursor theme. /// let mut cursor_theme = CursorTheme::load(conn, shm, 32)?; /// /// // Load the cursor. /// let cursor = cursor_theme.get_cursor(cursor.name()); /// if let Some(cursor) = cursor { /// println!("Total number of images: {}", cursor.image_count()); /// } /// # Ok(()) /// # } /// ``` pub fn name(&self) -> &'static str { match self { CursorIcon::Default => "default", CursorIcon::ContextMenu => "context-menu", CursorIcon::Help => "help", CursorIcon::Pointer => "pointer", CursorIcon::Progress => "progress", CursorIcon::Wait => "wait", CursorIcon::Cell => "cell", CursorIcon::Crosshair => "crosshair", CursorIcon::Text => "text", CursorIcon::VerticalText => "vertical-text", CursorIcon::Alias => "alias", CursorIcon::Copy => "copy", CursorIcon::Move => "move", CursorIcon::NoDrop => "no-drop", CursorIcon::NotAllowed => "not-allowed", CursorIcon::Grab => "grab", CursorIcon::Grabbing => "grabbing", CursorIcon::EResize => "e-resize", CursorIcon::NResize => "n-resize", CursorIcon::NeResize => "ne-resize", CursorIcon::NwResize => "nw-resize", CursorIcon::SResize => "s-resize", CursorIcon::SeResize => "se-resize", CursorIcon::SwResize => "sw-resize", CursorIcon::WResize => "w-resize", CursorIcon::EwResize => "ew-resize", CursorIcon::NsResize => "ns-resize", CursorIcon::NeswResize => "nesw-resize", CursorIcon::NwseResize => "nwse-resize", CursorIcon::ColResize => "col-resize", CursorIcon::RowResize => "row-resize", CursorIcon::AllScroll => "all-scroll", CursorIcon::ZoomIn => "zoom-in", CursorIcon::ZoomOut => "zoom-out", } } /// A list of alternative names for the cursor icon as commonly found in /// legacy Xcursor themes. /// /// This should only be used as a fallback in case the cursor theme does not /// adhere to the w3c standard. pub fn alt_names(&self) -> &[&'static str] { match self { CursorIcon::Default => &["left_ptr", "arrow", "top_left_arrow", "left_arrow"], CursorIcon::ContextMenu => &[], CursorIcon::Help => &["question_arrow", "whats_this"], CursorIcon::Pointer => &["hand2", "hand1", "hand", "pointing_hand"], CursorIcon::Progress => &["left_ptr_watch", "half-busy"], CursorIcon::Wait => &["watch"], CursorIcon::Cell => &["plus"], CursorIcon::Crosshair => &["cross"], CursorIcon::Text => &["xterm", "ibeam"], CursorIcon::VerticalText => &[], CursorIcon::Alias => &["link"], CursorIcon::Copy => &[], CursorIcon::Move => &[], CursorIcon::NoDrop => &["circle"], CursorIcon::NotAllowed => &["crossed_circle", "forbidden"], CursorIcon::Grab => &["openhand", "fleur"], CursorIcon::Grabbing => &["closedhand"], CursorIcon::EResize => &["right_side"], CursorIcon::NResize => &["top_side"], CursorIcon::NeResize => &["top_right_corner"], CursorIcon::NwResize => &["top_left_corner"], CursorIcon::SResize => &["bottom_side"], CursorIcon::SeResize => &["bottom_right_corner"], CursorIcon::SwResize => &["bottom_left_corner"], CursorIcon::WResize => &["left_side"], CursorIcon::EwResize => &["h_double_arrow", "size_hor"], CursorIcon::NsResize => &["v_double_arrow", "size_ver"], CursorIcon::NeswResize => &["fd_double_arrow", "size_bdiag"], CursorIcon::NwseResize => &["bd_double_arrow", "size_fdiag"], CursorIcon::ColResize => &["split_h", "h_double_arrow", "sb_h_double_arrow"], CursorIcon::RowResize => &["split_v", "v_double_arrow", "sb_v_double_arrow"], CursorIcon::AllScroll => &["size_all"], CursorIcon::ZoomIn => &[], CursorIcon::ZoomOut => &[], } } } impl core::fmt::Display for CursorIcon { fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { f.write_str(self.name()) } } impl core::str::FromStr for CursorIcon { type Err = ParseError; /// Parse a string slice into [`CursorIcon`]. /// /// The `name` is a lower kebab case [`CursorIcon`] varaint name, e.g. /// `nesw-resize`. The set of possible valid `name` values matches exactly /// the set of [`CursorIcon::name`] outputs. fn from_str(name: &str) -> Result { match name { "default" => Ok(CursorIcon::Default), "context-menu" => Ok(CursorIcon::ContextMenu), "help" => Ok(CursorIcon::Help), "pointer" => Ok(CursorIcon::Pointer), "progress" => Ok(CursorIcon::Progress), "wait" => Ok(CursorIcon::Wait), "cell" => Ok(CursorIcon::Cell), "crosshair" => Ok(CursorIcon::Crosshair), "text" => Ok(CursorIcon::Text), "vertical-text" => Ok(CursorIcon::VerticalText), "alias" => Ok(CursorIcon::Alias), "copy" => Ok(CursorIcon::Copy), "move" => Ok(CursorIcon::Move), "no-drop" => Ok(CursorIcon::NoDrop), "not-allowed" => Ok(CursorIcon::NotAllowed), "grab" => Ok(CursorIcon::Grab), "grabbing" => Ok(CursorIcon::Grabbing), "e-resize" => Ok(CursorIcon::EResize), "n-resize" => Ok(CursorIcon::NResize), "ne-resize" => Ok(CursorIcon::NeResize), "nw-resize" => Ok(CursorIcon::NwResize), "s-resize" => Ok(CursorIcon::SResize), "se-resize" => Ok(CursorIcon::SeResize), "sw-resize" => Ok(CursorIcon::SwResize), "w-resize" => Ok(CursorIcon::WResize), "ew-resize" => Ok(CursorIcon::EwResize), "ns-resize" => Ok(CursorIcon::NsResize), "nesw-resize" => Ok(CursorIcon::NeswResize), "nwse-resize" => Ok(CursorIcon::NwseResize), "col-resize" => Ok(CursorIcon::ColResize), "row-resize" => Ok(CursorIcon::RowResize), "all-scroll" => Ok(CursorIcon::AllScroll), "zoom-in" => Ok(CursorIcon::ZoomIn), "zoom-out" => Ok(CursorIcon::ZoomOut), _ => Err(ParseError { _private: () }), } } } /// An error which could be returned when parsing [`CursorIcon`]. /// /// This occurs when the [`FromStr`] implementation of [`CursorIcon`] fails. /// /// [`FromStr`]: core::str::FromStr #[derive(Debug, PartialEq, Eq)] pub struct ParseError { _private: (), } impl core::fmt::Display for ParseError { fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { f.write_str("failed to parse cursor icon") } } #[cfg(feature = "std")] impl std::error::Error for ParseError {}