From b9bbd77c7fa1c11da6b700b01b173410a760e1e9 Mon Sep 17 00:00:00 2001
From: Hamothy <58985301+sgoudham@users.noreply.github.com>
Date: Thu, 26 Jan 2023 18:53:05 +0000
Subject: [PATCH] docs: restructure & improve contrib docs (#1876)
* docs: restructure & improve contrib docs
* chore: rework samples code
* docs: fix capitalization & brand names
* docs: PR comments & try to standardise palette vs flavor
* docs: add sample-programs
* docs: update submission guidelines (refs: #1821)
* refactor: tidy up docs
Co-authored-by: winston
-Catppuccin is a community-driven pastel theme that aims to be the middle ground between low and high contrast themes. It consists of 4 soothing warm palettes with 26 eye-candy colors each, perfect for coding, designing, and much more! In addition, this repository tracks the development of the actual color palette, the project's documentation, organization-wide assets, resources and code samples for maintainers/developers.
+Catppuccin is a community-driven pastel theme that aims to be the middle ground between low and high contrast themes. It consists of 4 soothing warm flavors with 26 eye-candy colors each, perfect for coding, designing, and much more! In addition, this repository tracks the development of the actual color palette, the project's documentation, organization-wide assets, resources and code samples for maintainers/developers.
@@ -58,16 +58,18 @@ Join our community!
### π§ Design Philosophy
-- **Colorful is better than colorless**: the colorfulness of something contributes to the distinction amongst the parts of that _something_, making it marginally easier to understand how things are structured.
-- **There should be balance**: not too dull, not too bright. Suitability under various light conditions is a must.
-- **Harmony is superior to dissonance**: vivacious colors must complement each other.
+- **Colorful is better than colorless**: the colorfulness of something contributes to the distinction amongst the parts
+ of that _something_, making it marginally easier to understand how things are structured.
+- **There should be balance**: not too dull, not too bright. Suitability under various light conditions is a must.
+- **Harmony is superior to dissonance**: vivacious colors must complement each other.
-### π¨ Palettes
+### π¨ Palette
-**Catppuccin** consists of 4 beautiful pastel color palettes. All the details can be found below.
-Catppuccin is a community-driven pastel theme that aims to be the middle ground between low and high contrast themes. It consists of 4 soothing warms palette with 26 eye-candy colors each, perfect for coding, designing, and much more! In addition, this repository tracks the development of the actual color palette, organization-wide assets, resources and code samples for maintainers/developers.
+Catppuccin is a community-driven pastel theme that aims to be the middle ground between low and high contrast themes. It consists of 4 soothing warm flavors with 26 eye-candy colors each, perfect for coding, designing, and much more! In addition, this repository tracks the development of the actual color palette, organization-wide assets, resources and code samples for maintainers/developers.
-
- Palettes
+ Palette
Β·
Ports
Β·
@@ -33,7 +33,7 @@
-To make the best use of them, please refer to the [style guide](https://github.com/catppuccin/catppuccin/blob/main/docs/style-guide.md).
+**Catppuccin** consists of 4 beautiful pastel color palettes, named **flavors**. All the details can be found below.
+To make the best use of them, please refer to
+the [style guide](https://github.com/catppuccin/catppuccin/blob/main/docs/style-guide.md).
πΎ Code Editors
+πΎ Code Editors
- [Binary Ninja](https://github.com/catppuccin/binary-ninja)
- [Cutter](https://github.com/catppuccin/cutter)
@@ -880,6 +882,7 @@ Catppuccin is available for various apps and in different formats. Here is a lis
- [Visual Studio](https://github.com/catppuccin/visual-studio)
- [Xcode](https://github.com/catppuccin/xcode)
- [Xed](https://github.com/catppuccin/xed)
+
π Development
@@ -891,7 +894,8 @@ Catppuccin is available for various apps and in different formats. Here is a lis
- [Toolbox](https://github.com/catppuccin/toolbox)
- [mdBook](https://github.com/catppuccin/mdBook)
- [egui](https://github.com/catppuccin/egui)
- π§ System
@@ -932,12 +936,14 @@ Catppuccin is available for various apps and in different formats. Here is a lis
- [Waybar](https://github.com/catppuccin/waybar)
- [Xresources](https://github.com/catppuccin/xresources)
- [Rboard](https://github.com/catppuccin/rboard)
+
π Shells
- [Fish](https://github.com/catppuccin/fish)
- [zsh-syntax-highlighting](https://github.com/catppuccin/zsh-syntax-highlighting)
+
π€ Productivity
@@ -960,6 +966,7 @@ Catppuccin is available for various apps and in different formats. Here is a lis
- [Vercel](https://github.com/catppuccin/vercel)
- [Wikiwand](https://github.com/catppuccin/wikiwand)
- [Zathura](https://github.com/catppuccin/zathura)
+
π Leisure
@@ -977,9 +984,10 @@ Catppuccin is available for various apps and in different formats. Here is a lis
- [Spicetify](https://github.com/catppuccin/spicetify)
- [Spotify Player](https://github.com/catppuccin/spotify-player)
- [Spotify-TUI](https://github.com/catppuccin/spotify-tui)
-- [Stable Diffusion Web Ui](https://github.com/catppuccin/Stable-Diffusion-Web-UI)
+- [Stable Diffusion Web UI](https://github.com/catppuccin/stable-diffusion-web-ui)
- [Steam](https://github.com/catppuccin/steam)
-- [Youtube Music](https://github.com/catppuccin/youtubemusic)
+- [YouTube Music](https://github.com/catppuccin/youtubemusic)
+
π₯οΈ Browsers
@@ -988,6 +996,7 @@ Catppuccin is available for various apps and in different formats. Here is a lis
- [Firefox](https://github.com/catppuccin/firefox)
- [Vivaldi](https://github.com/catppuccin/vivaldi)
- [qutebrowser](https://github.com/catppuccin/qutebrowser)
+
π Search engines
@@ -995,8 +1004,9 @@ Catppuccin is available for various apps and in different formats. Here is a lis
- [Brave Search](https://github.com/catppuccin/brave-search)
- [DuckDuckGo](https://github.com/catppuccin/duckduckgo)
- [Whoogle](https://github.com/catppuccin/whoogle)
-- [SearxNG](https://github.com/catppuccin/searxng)
+- [SearXNG](https://github.com/catppuccin/searxng)
- [Startpage](https://github.com/catppuccin/startpage)
+
𧩠Extensions
@@ -1006,6 +1016,7 @@ Catppuccin is available for various apps and in different formats. Here is a lis
- [Sidebery](https://github.com/catppuccin/sidebery)
- [Vimium](https://github.com/catppuccin/vimium)
- [Nighttab](https://github.com/catppuccin/nighttab)
+
π¬ Messaging
@@ -1020,6 +1031,7 @@ Catppuccin is available for various apps and in different formats. Here is a lis
- [Revolt](https://github.com/catppuccin/revolt)
- [Slack](https://github.com/catppuccin/slack)
- [Telegram](https://github.com/catppuccin/telegram)
+
π Note-taking
@@ -1028,6 +1040,7 @@ Catppuccin is available for various apps and in different formats. Here is a lis
- [Joplin](https://github.com/catppuccin/joplin)
- [Obsidian](https://github.com/catppuccin/obsidian)
- [Remnote](https://github.com/catppuccin/remnote)
+
π± Terminals
@@ -1059,13 +1072,14 @@ Catppuccin is available for various apps and in different formats. Here is a lis
- [Xfce4 Terminal](https://github.com/catppuccin/xfce4-terminal)
- [Zellij](https://github.com/catppuccin/zellij)
- [Zutty](https://github.com/catppuccin/zutty)
+
β¨ Social
- [AniList](https://github.com/catppuccin/anilist)
- [Elk](https://github.com/catppuccin/elk)
-- [Github Readme Stats](https://github.com/catppuccin/github-readme-stats)
+- [GitHub Readme Stats](https://github.com/catppuccin/github-readme-stats)
- [GitHub Readme Tech Stack](https://github.com/catppuccin/github-readme-tech-stack)
- [Hacker News](https://github.com/catppuccin/hacker-news)
- [Infinity for Reddit](https://github.com/catppuccin/infinity)
@@ -1077,6 +1091,7 @@ Catppuccin is available for various apps and in different formats. Here is a lis
- [Reddit](https://github.com/catppuccin/reddit)
- [Thunderbird](https://github.com/catppuccin/thunderbird)
- [YouTube](https://github.com/catppuccin/youtube)
+
> Catppuccin staff reserve the right to remove and reject showcase additions if we determine the addition to be in
-> violation of our [CODE OF CONDUCT](https://github.com/catppuccin/.github/blob/main/CODE_OF_CONDUCT.md). Extremely
-> personal configurations will **not** be approved and added.
+> violation of our [CODE OF CONDUCT](https://github.com/catppuccin/.github/blob/main/CODE_OF_CONDUCT.md). Extremely
+> personal configurations and websites will **not** be added.
If you're making an application or tool using our palette, please let us know by adding it below!
- π [flotes.app](https://flotes.app/) - A free note-taking app enhanced with flashcard features
-- π [AnuPpuccin](https://github.com/AnubisNekhet/AnuPpuccin) - Highly customisable theme for [Obsidian](https://obsidian.md/)
-- π [name] - [short description]
+- π [AnuPpuccin](https://github.com/AnubisNekhet/AnuPpuccin) - Highly customisable theme
+ for [Obsidian](https://obsidian.md/)
-### π Contribute
+### π Contributing
+
+> **Note**
+> if you would like to submit a port or learn how to port Catppuccin to a program, please refer to
+> the [port-creation.md](https://github.com/catppuccin/catppuccin/blob/main/docs/port-creation.md).
See [CONTRIBUTING.md](https://github.com/catppuccin/catppuccin/blob/main/CONTRIBUTING.md).
+### π§ Usage
+
+If you're interested in using our palette for your own project, make sure to check
+out [catppuccin/palette](https://github.com/catppuccin/palette) where you can find integrations with popular frameworks
+and tools.
+
+If you already have a project using our palette, don't forget to add it to
+our [showcase](#-showcase) section above!
+
+
+
### π License
Catppuccin is released under the MIT license, which grants the following permissions:
diff --git a/docs/README.md b/docs/README.md
index 3a99ad0..f198fcb 100644
--- a/docs/README.md
+++ b/docs/README.md
@@ -7,7 +7,7 @@
π€ Contributing
-
- Creating Catppuccin ports -
- - - -### What's a port? - -A port is basically an adaptation of Catppuccin's palettes for an app to use. Think of it as a colorscheme for a program that styles every UI component it consists of! - - - -### Creation - -You can create ports using [this](https://github.com/catppuccin/template) public template as a blueprint. However, you must **not** create it the traditional way (by clicking **Use this template**), because this leaves a _small_ tag under the repos' name that says `generated from `. To avoid this, follow the instructions below: - -1. Create the repo and leave it empty: -``` -mkdir name_of_your_port -cd name_of_your_port -git init -``` - -2. Add this template as a remote: -``` -git remote add template https://github.com/catppuccin/template.git -``` - -3. Pull from it: -``` -git pull template main -``` - -4. Delete the remote: -``` -git remote remove template -``` - -5. Make the template its own repository by running -``` -git reset $(git commit-tree HEAD^{tree} -m "feat: initial commit") -``` - -6. Set up the rest of your port, and push it to your user repository! - - - -### Styling! - -Although you just created the repo successfully, it's important to style it properly to ensure consistency: - -- The name of the repo must be the simplest version of the app's name (e.g `nvim` instead of `NeoVim`). You may use hyphens if needed (e.g. `windows-files`). -- Put the images under `assets/`. If there are a bunch of them consider [creating an empty branch](https://gist.github.com/joncardasis/e6494afd538a400722545163eb2e1fa5) (e.g. `assets`) and storing them there. -- Format the repo's description as "`-
- How to implement Catppuccin in your own projects -
- - - -### How to - -Catppuccin comes in many formats to cover a wide range of project types and tech stacks. Its palettes have especially been designed for UI elements and code syntax highlighting often found in projects build with web technologies like websites; hence why we have a dedicated repository for storing the various formats and presentation of the palettes: [catppuccin/palette](https://github.com/catppuccin/palette). - - - -### Web Development - -Since Catppuccin is heavily used in web technology based projects, it's main installation method is therefore npm, the Node.js package manager. -Install and add it as production dependency by running `npm` from the command line: - -``` -npm install --save @catppuccin/palette -``` - - - -### Graphical Design - -Color swatches are simply a palette showing a variety of shades of the same color. Here, Catppuccin has various "swatches" in different formats to be used in software ranging from Adobe Products to graphical design apps such as Figma and InkScape. You can find them under [catppuccin/palette](https://github.com/catppuccin/palette). diff --git a/docs/port-creation.md b/docs/port-creation.md new file mode 100644 index 0000000..1c81345 --- /dev/null +++ b/docs/port-creation.md @@ -0,0 +1,96 @@ ++
+ Guidelines for submitting and creating ports +
+ + + +### What's a port? + +A port is an adaptation of Catppuccin's palette for an app to use. Think of it as a colorscheme for a program +that styles every UI component it consists of! + + + +### Submission + +Raise a discussion under main +repository [here!](https://github.com/catppuccin/catppuccin/discussions/new?category=port-requests) The title should be +the **simplest** name of the application/tool/website/etc that you are wanting ported over. + +If you have already created a repository containing the work, make sure to include it within the description for others +to see! Feel free to join our [Discord](https://discord.com/invite/r6Mdz5dpFc) and share it there too! + +The discussion will be transferred to an issue by +the [staff team](https://github.com/orgs/catppuccin/teams/staff/members) once we have deemed the port ready to be +reviewed and merged! + +All ports should conform to our [CODE OF CONDUCT](https://github.com/catppuccin/.github/blob/main/CODE_OF_CONDUCT.md) +and we, the staff team, reserve the right to choose what ports will be included under the organisation. As a +community-driven project, we want to keep a neutral environment for all users. Therefore, **we do not accept +contributions that have a religious or political context.** However, we have no issue with our palette being used in +these contexts. + + + +### Creation + +You can create ports using [this](https://github.com/catppuccin/template) public template as a blueprint. + +1. Clone template repository + + ``` + git clone https://github.com/catppuccin/template.git- Properties of the palettes + Properties of the palette
-### Palettes +### Palette -Catppuccin consists of four named color palettes: Latte, Frappe, Macchiato, and Mocha. Each palette has its use-cases and a reason to exist! (so to speak). Every palette has labels (AKA colors) that provide different syntactic meanings and color effects for dark & bright ambiance designs. Each one of them was created aiming for a clear, uncluttered, and elegant design following a minimal and flat style pattern. +Catppuccin consists of four named flavors: Latte, FrappΓ©, Macchiato, and Mocha. Each flavor has its use-cases +and a reason to exist! (so to speak). Every flavor has labels (AKA colors) that provide different syntactic meanings +and color effects for dark & bright ambiance designs. Each one of them was created aiming for a clear, uncluttered, and +elegant design following a minimal and flat style pattern. -### Subpalettes +### Sub-palettes -Every palette consists of two subpalettes: one monochromatic and one analogous. The Monochromatic subpalette consists of different shades of a purple-gray and a very pale lavender and is often used for UI components. Whereas the Analogous palette has every color in the rainbow and is often used for syntactic elements. +Every flavor consists of two sub-palettes: one monochromatic and one analogous. The monochromatic sub-palette consists +of different shades of a purple-gray and a very pale lavender and is often used for UI components. Whereas the analogous +palette has every color in the rainbow and is often used for syntactic elements. diff --git a/docs/translation_table.md b/docs/translation-table.md similarity index 100% rename from docs/translation_table.md rename to docs/translation-table.md diff --git a/samples/README.md b/samples/README.md index 1742f98..e0afae0 100644 --- a/samples/README.md +++ b/samples/README.md @@ -1,3 +1,14 @@ # Coding Samples Small samples from various programming/markup/config languages to check how Catppuccin looks on them. + +## Other Sources + +When you need samples from a wider set of languages, please look towards: + +- [kate-editor.org/syntax](kate-editor.org/syntax) +- [TheRenegadeCoder/sample-programs](https://github.com/TheRenegadeCoder/sample-programs) + +# Acknowledgement + +These samples were taken from [JetBrains Intellij IDEA](https://www.jetbrains.com/idea/)'s syntax highlighting tools. diff --git a/samples/bash.sh b/samples/bash.sh index 813077e..1aadb30 100644 --- a/samples/bash.sh +++ b/samples/bash.sh @@ -1,640 +1,23 @@ -#!/bin/bash +#!/usr/bin/env sh -#sve = System Variable Exemplifier -#This script executes whatever file you tell regardless of in which directory it's currently in. +#Sample comment +let "a=16 << 2"; +b="Sample text"; -# TO-DO -# + on recurse_dirs2() -- make it so that any file with 'Main' on its name will get compiled at the end, cuz else it's going to cause error -# + make it so that $temp_cp can be edited using this scritpt -# +,i remove one of the entries -# +,i add an entry -# + fix bugs -# +,i if entry if removed and entry is last of entries then the entry before that one will have an collon, which is something that will cause an error to the parser -# this is a simple test becas (done) -# + from $0 -ef a -> if "entry" is on $temp_cp then do not add entry, print message, else, add it (done) -# + edit --help str (done) -# + avoid compiling already compiled files -# +,i mkdir /tmp/2sve_tmp -- dir where "already compiled things" file is stored -# +,j touch /tmp/2sve_tmp/compiled_file_list.json -# +,i after first compile add all files compiled to list -# +,i if `stat --format "%Y"Implementation note: The sorting algorithm is a Dual-Pivot Quicksort
+ * by Vladimir Yaroslavskiy, Jon Bentley, and Joshua Bloch. This algorithm
+ * offers O(n log(n)) performance on many data sets that cause other
+ * quicksorts to degrade to quadratic performance, and is typically
+ * faster than traditional (one-pivot) Quicksort implementations.
+ *
+ * @param a the array to be sorted
+ */
+ public static void sort(byte[] a) {
+ DualPivotQuicksort.sort(a);
+ }
+
+Quotes
+------
+
+> This is the first level of quoting.
+>
+> > This is nested blockquote.
+>
+> Back to the first level.
+
+
+> A list within a blockquote:
+>
+> * asterisk 1
+> * asterisk 2
+> * asterisk 3
+
+
+> Formatting within a blockquote:
+>
+> ### header
+> Link: [Example](http://example.com)
+
+
+
+Html
+-------
+
+This is inline html.
+And this is an html block.
+
+
+ What is IntelliJ IDEA? · Α
+ SomeClass
+ *
+ * @param T type parameter
+ * @see Math#sin(double)
*/
-public class UIMenu {
+@Annotation(name = value)
+public class SomeClass
+
+
+Horizontal rules
+----------------
+
+---
+
+___
+
+
+***
+
+
+Lists
+-----
+
+Unordered list:
+
+* asterisk 1
+* asterisk 2
+* asterisk 3
+
+Ordered list:
+
+1. First
+2. Second
+3. Third
+
+Mixed:
+
+1. First
+2. Second:
+
+* Fee
+* Fie
+* Foe
+
+3. Third
+
+Definition list:
+
+Some term
+: First definition
+: Second definition
+
+
+Tables:
+
+| Header 1 | Header 2 |
+| -------- | -------- |
+| Data 1 | Data 2 |
diff --git a/samples/python.py b/samples/python.py
index 5666603..ee455ae 100644
--- a/samples/python.py
+++ b/samples/python.py
@@ -1,172 +1,32 @@
-import sys
-import os
-import re
-
-from i18n import _
-
-from importlib.machinery import SourceFileLoader
-
-
-class RubberStamp:
- """Howdy rubber stamp"""
-
- UI_TEXT = "ui_text"
- UI_SUBTEXT = "ui_subtext"
-
- def set_ui_text(self, text, type=None):
- """Convert an ui string to input howdy-gtk understands"""
- typedec = "M"
-
- if type == self.UI_SUBTEXT:
- typedec = "S"
-
- return self.send_ui_raw(typedec + "=" + text)
-
- def send_ui_raw(self, command):
- """Write raw command to howdy-gtk stdin"""
- if self.config.getboolean("debug", "verbose_stamps", fallback=False):
- print("Sending command to howdy-gtk: " + command)
-
- # Add a newline because the ui reads per line
- command += " \n"
- if self.gtk_proc:
- # Send the command as bytes
- self.gtk_proc.stdin.write(bytearray(command.encode("utf-8")))
- self.gtk_proc.stdin.flush()
-
-def execute(config, gtk_proc, opencv):
- verbose = config.getboolean("debug", "verbose_stamps", fallback=False)
- dir_path = os.path.dirname(os.path.realpath(__file__))
- installed_stamps = []
-
- # Go through each file in the rubberstamp folder
- for filename in os.listdir(dir_path):
- # Remove non-readable file or directories
- if not os.path.isfile(dir_path + "/" + filename):
- continue
-
- # Remove meta files
- if filename in ["__init__.py", ".gitignore"]:
- continue
-
- # Add the found file to the list of enabled rubberstamps
- installed_stamps.append(filename.split(".")[0])
-
- if verbose: print("Installed rubberstamps: " + ", ".join(installed_stamps))
-
- # Get the rules defined in the config
- raw_rules = config.get("rubberstamps", "stamp_rules")
- rules = raw_rules.split("\n")
-
- # Go through the rules one by one
- for rule in rules:
- rule = rule.strip()
-
- if len(rule) <= 1:
- continue
-
- # Parse the rule with regex
- regex_result = re.search("^(\w+)\s+([\w\.]+)\s+([a-z]+)(.*)?$", rule, re.IGNORECASE)
-
- # Error out if the regex did not match (invalid line)
- if not regex_result:
- print(_("Error parsing rubberstamp rule: {}").format(rule))
- continue
-
- type = regex_result.group(1)
-
- # Error out if the stamp name in the rule is not a file
- if type not in installed_stamps:
- print(_("Stamp not installed: {}").format(type))
- continue
-
- # Load the module from file
- module = SourceFileLoader(type, dir_path + "/" + type + ".py").load_module()
-
- # Try to get the class with the same name
- try:
- constructor = getattr(module, type)
- except AttributeError:
- print(_("Stamp error: Class {} not found").format(type))
- continue
-
- # Init the class and set common values
- instance = constructor()
- instance.verbose = verbose
- instance.config = config
- instance.gtk_proc = gtk_proc
- instance.opencv = opencv
-
- # Set some opensv shorthands
- instance.video_capture = opencv["video_capture"]
- instance.face_detector = opencv["face_detector"]
- instance.pose_predictor = opencv["pose_predictor"]
- instance.clahe = opencv["clahe"]
-
- # Parse and set the 2 required options for all rubberstamps
- instance.options = {
- "timeout": float(re.sub("[a-zA-Z]", "", regex_result.group(2))),
- "failsafe": regex_result.group(3) != "faildeadly"
- }
-
- # Try to get the class do declare its other config variables
- try:
- instance.declare_config()
- except Exception:
- print(_("Internal error in rubberstamp configuration declaration:"))
-
- import traceback
- traceback.print_exc()
- continue
-
- # Split the optional arguments at the end of the rule by spaces
- raw_options = regex_result.group(4).split()
-
- # For each of those aoptional arguments
- for option in raw_options:
- # Get the key to the left, and the value to the right of the equal sign
- key, value = option.split("=")
-
- # Error out if a key has been set that was not declared by the module before
- if key not in instance.options:
- print("Unknow config option for rubberstamp " + type + ": " + key)
- continue
-
- # Convert the argument string to an int or float if the declared option has that type
- if isinstance(instance.options[key], int):
- value = int(value)
- elif isinstance(instance.options[key], float):
- value = float(value)
-
- instance.options[key] = value
-
- if verbose:
- print("Stamp \"" + type + "\" options parsed:")
- print(instance.options)
- print("Executing stamp")
-
- # Make the stamp fail by default
- result = False
-
- # Run the stamp code
- try:
- result = instance.run()
- except Exception:
- print(_("Internal error in rubberstamp:"))
-
- import traceback
- traceback.print_exc()
- continue
-
- if verbose: print("Stamp \"" + type + "\" returned: " + str(result))
-
- # Abort authentication if the stamp returned false
- if result is False:
- if verbose: print("Authentication aborted by rubber stamp")
- sys.exit(14)
-
- # This is outside the for loop, so we've run all the rules
- if verbose: print("All rubberstamps processed, authentication successful")
-
- # Exit with no errors
- sys.exit(0)
+@decorator(param=1)
+def f(x):
+ """
+ Syntax Highlighting Demo
+ @param x Parameter
+
+ Semantic highlighting:
+ Generated spectrum to pick colors for local variables and parameters:
+ Color#1 SC1.1 SC1.2 SC1.3 SC1.4 Color#2 SC2.1 SC2.2 SC2.3 SC2.4 Color#3
+ Color#3 SC3.1 SC3.2 SC3.3 SC3.4 Color#4 SC4.1 SC4.2 SC4.3 SC4.4 Color#5
+ """
+
+ def nested_func(y):
+ print(y + 1)
+
+ s = ("Test", 2+3, {'a': 'b'}, f'{x!s:{"^10"}}') # Comment
+ f(s[0].lower())
+ nested_func(42)
+
+class Foo:
+ tags: List[str]
+
+ def __init__(self: Foo):
+ byte_string: bytes = b'newline:\n also newline:\x0a'
+ text_string = u"Cyrillic Π― is \u042f. Oops: \u042g"
+ self.make_sense(whatever=1)
+
+ def make_sense(self, whatever):
+ self.sense = whatever
+
+x = len('abc')
+print(f.__doc__)
diff --git a/samples/python1.py b/samples/python1.py
deleted file mode 100644
index d22208f..0000000
--- a/samples/python1.py
+++ /dev/null
@@ -1,815 +0,0 @@
-# source: https://github.com/gornostal/Modific
-# -*- coding: utf-8 -*-
-
-from __future__ import print_function
-
-import sublime
-import sublime_plugin
-import os
-import threading
-import subprocess
-import functools
-import re
-from copy import copy
-
-IS_ST3 = sublime.version().startswith('3') or sublime.version().startswith('4')
-
-
-def get_settings():
- return sublime.load_settings("Modific.sublime-settings")
-
-
-def get_vcs_settings():
- """
- Returns list of dictionaries
- each dict. represents settings for VCS
- """
-
- default = [
- {"name": "git", "dir": ".git", "cmd": "git"},
- {"name": "svn", "dir": ".svn", "cmd": "svn"},
- {"name": "bzr", "dir": ".bzr", "cmd": "bzr"},
- {"name": "hg", "dir": ".hg", "cmd": "hg"},
- {"name": "tf", "dir": "$tf", "cmd": "C:/Program Files (x86)/Microsoft Visual Studio 11.0/Common7/IDE/TF.exe"}
- ]
- settings = get_settings().get('vcs', default)
-
- # re-format settings array if user has old format of settings
- if type(settings[0]) == list:
- settings = [dict(name=name, cmd=cmd, dir='.'+name) for name, cmd in settings]
-
- return settings
-
-
-def get_user_command(vcs_name):
- """
- Returns command that user specified for vcs_name
- """
-
- try:
- return [vcs['cmd'] for vcs in get_vcs_settings() if vcs.get('name') == vcs_name][0]
- except IndexError:
- return None
-
-
-def tfs_root(directory):
- try:
- tf_cmd = get_user_command('tf') or 'tf'
- command = [tf_cmd, 'workfold', directory]
- p = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE,
- shell=True, universal_newlines=False)
- out, err = p.communicate()
- m = re.search(r"^ \$\S+: (\S+)$", out, re.MULTILINE)
- if m:
- return {'root': m.group(1), 'name': 'tf', 'cmd': tf_cmd}
- except:
- return None
-
-
-def get_vcs(directory):
- """
- Determines root directory for VCS and which of VCS systems should be used for a given directory
- Returns dictionary {name: .., root: .., cmd: .., dir: ..}
- """
-
- vcs_check = [(lambda vcs: lambda dir: os.path.exists(os.path.join(dir, vcs.get('dir', False)))
- and vcs)(vcs) for vcs in get_vcs_settings()]
-
- start_directory = directory
- while directory:
- available = list(filter(bool, [check(directory) for check in vcs_check]))
- if available:
- available[0]['root'] = directory
- return available[0]
-
- parent = os.path.realpath(os.path.join(directory, os.path.pardir))
- if parent == directory: # /.. == /
- # try TFS as a last resort
- # I'm not sure why we need to do this. Seems like it should find root for TFS in the main loop
- return tfs_root(start_directory)
- directory = parent
-
- return None
-
-
-def main_thread(callback, *args, **kwargs):
- # sublime.set_timeout gets used to send things onto the main thread
- # most sublime.[something] calls need to be on the main thread
- sublime.set_timeout(functools.partial(callback, *args, **kwargs), 0)
-
-
-def _make_text_safeish(text, fallback_encoding, method='decode'):
- # The unicode decode here is because sublime converts to unicode inside
- # insert in such a way that unknown characters will cause errors, which is
- # distinctly non-ideal... and there's no way to tell what's coming out of
- # git in output. So...
- try:
- unitext = getattr(text, method)('utf-8')
- except (UnicodeEncodeError, UnicodeDecodeError):
- unitext = getattr(text, method)(fallback_encoding)
- except AttributeError:
- # strongly implies we're already unicode, but just in case let's cast
- # to string
- unitext = str(text)
- return unitext
-
-
-def do_when(conditional, callback, *args, **kwargs):
- if conditional():
- return callback(*args, **kwargs)
- sublime.set_timeout(functools.partial(do_when, conditional, callback, *args, **kwargs), 50)
-
-
-def log(*args, **kwargs):
- """
- @param *args: string arguments that should be logged to console
- @param debug=True: debug log mode
- @param settings=None: instance of sublime.Settings
- """
- debug = kwargs.get('debug', True)
- settings = kwargs.get('settings', None)
-
- if not settings:
- settings = get_settings()
-
- if debug and not settings.get('debug', False):
- return
-
- print('Modific:', *args)
-
-
-class CommandThread(threading.Thread):
-
- def __init__(self, command, on_done, working_dir="", fallback_encoding="", console_encoding="", **kwargs):
- threading.Thread.__init__(self)
- self.command = command
- self.on_done = on_done
- self.working_dir = working_dir
- if 'stdin' in kwargs:
- self.stdin = kwargs['stdin'].encode()
- else:
- self.stdin = None
- self.stdout = kwargs.get('stdout', subprocess.PIPE)
- self.console_encoding = console_encoding
- self.fallback_encoding = fallback_encoding
- self.kwargs = kwargs
-
- def run(self):
- try:
- # Per http://bugs.python.org/issue8557 shell=True is required to
- # get $PATH on Windows. Yay portable code.
- shell = os.name == 'nt'
-
- if self.console_encoding:
- self.command = [s.encode(self.console_encoding) for s in self.command]
-
- proc = subprocess.Popen(self.command,
- stdout=self.stdout, stderr=subprocess.STDOUT,
- stdin=subprocess.PIPE,
- cwd=self.working_dir if self.working_dir != '' else None,
- shell=shell, universal_newlines=False)
- output = proc.communicate(self.stdin)[0]
- if not output:
- output = ''
- # if sublime's python gets bumped to 2.7 we can just do:
- # output = subprocess.check_output(self.command)
- main_thread(self.on_done,
- _make_text_safeish(output, self.fallback_encoding), **self.kwargs)
- except subprocess.CalledProcessError as e:
- main_thread(self.on_done, e.returncode)
- except OSError as e:
- if e.errno == 2:
- main_thread(sublime.error_message,
- "'%s' binary could not be found in PATH\n\nConsider using `vcs` property to specify PATH\n\nPATH is: %s" % (self.command[0], os.environ['PATH']))
- else:
- raise e
-
-
-class EditViewCommand(sublime_plugin.TextCommand):
-
- def run(self, edit, command=None, output='', begin=0, region=None):
- """
- For some reason Sublime's view.run_command() doesn't allow to pass tuples,
- therefore region must be a list
- """
- region = sublime.Region(int(region[0]), int(region[1])) if region else None
- if command == 'insert':
- self.view.insert(edit, int(begin), output)
- elif command == 'replace':
- self.view.replace(edit, region, output)
- elif command == 'erase':
- self.view.erase(edit, region)
- else:
- print('Invalid command: ', command)
- raise
-
-
-class VcsCommand(object):
- may_change_files = False
-
- def __init__(self, *args, **kwargs):
- self.settings = get_settings()
- super(VcsCommand, self).__init__(*args, **kwargs)
-
- def log(self, *args, **kwargs):
- return log(settings=self.settings, *args, **kwargs)
-
- def run_command(self, command, callback=None, show_status=False,
- filter_empty_args=True, **kwargs):
- if filter_empty_args:
- command = [arg for arg in command if arg]
- if 'working_dir' not in kwargs:
- kwargs['working_dir'] = self.get_working_dir()
- if 'fallback_encoding' not in kwargs and self.active_view() and self.active_view().settings().get('fallback_encoding'):
- kwargs['fallback_encoding'] = self.active_view().settings().get('fallback_encoding').rpartition('(')[2].rpartition(')')[0]
- kwargs['console_encoding'] = self.settings.get('console_encoding')
-
- autosave = self.settings.get('autosave', True)
- if self.active_view() and self.active_view().is_dirty() and autosave:
- self.active_view().run_command('save')
- if not callback:
- callback = self.generic_done
-
- log('run command:', ' '.join(command))
- thread = CommandThread(command, callback, **kwargs)
- thread.start()
-
- if show_status:
- message = kwargs.get('status_message', False) or ' '.join(command)
- sublime.status_message(message + 'wef')
-
- def generic_done(self, result):
- self.log('generic_done', result)
- if self.may_change_files and self.active_view() and self.active_view().file_name():
- if self.active_view().is_dirty():
- result = "WARNING: Current view is dirty.\n\n"
- else:
- # just asking the current file to be re-opened doesn't do anything
- print("reverting")
- position = self.active_view().viewport_position()
- self.active_view().run_command('revert')
- do_when(lambda: not self.active_view().is_loading(),
- lambda: self.active_view().set_viewport_position(position, False))
-
- if not result.strip():
- return
- self.panel(result)
-
- def _output_to_view(self, output_file, output, clear=False,
- syntax="Packages/Diff/Diff.tmLanguage"):
- output_file.set_syntax_file(syntax)
- if clear:
- output_file.run_command('edit_view', dict(command='replace', region=[0, self.output_view.size()], output=output))
- else:
- output_file.run_command('edit_view', dict(command='insert', output=output))
-
- def scratch(self, output, title=False, position=None, **kwargs):
- scratch_file = self.get_window().new_file()
- if title:
- scratch_file.set_name(title)
- scratch_file.set_scratch(True)
- self._output_to_view(scratch_file, output, **kwargs)
- scratch_file.set_read_only(True)
- if position:
- sublime.set_timeout(lambda: scratch_file.set_viewport_position(position), 0)
- return scratch_file
-
- def panel(self, output, **kwargs):
- if not hasattr(self, 'output_view'):
- self.output_view = self.get_window().get_output_panel("vcs")
- self.output_view.set_read_only(False)
- self._output_to_view(self.output_view, output, clear=True, **kwargs)
- self.output_view.set_read_only(True)
- self.get_window().run_command("show_panel", {"panel": "output.vcs"})
-
- def _active_file_name(self):
- view = self.active_view()
- if view and view.file_name() and len(view.file_name()) > 0:
- return view.file_name()
-
- def active_view(self):
- return self.view
-
- def get_window(self):
- if (hasattr(self, 'view') and hasattr(self.view, 'window')):
- return self.view.window()
- else:
- return sublime.active_window()
-
- def get_working_dir(self):
- return os.path.dirname(self._active_file_name())
-
- def is_enabled(self):
- file_name = self._active_file_name()
- if file_name and os.path.exists(file_name):
- return bool(get_vcs(self.get_working_dir()))
- return False
-
-
-class DiffCommand(VcsCommand):
- """ Here you can define diff commands for your VCS
- method name pattern: %(vcs_name)s_diff_command
- """
-
- def run(self, edit):
- vcs = get_vcs(self.get_working_dir())
- filepath = self.view.file_name()
- filename = os.path.basename(filepath)
- max_file_size = self.settings.get('max_file_size', 1024) * 1024
- if not os.path.exists(filepath) or os.path.getsize(filepath) > max_file_size:
- # skip large files
- return
- get_command = getattr(self, '{0}_diff_command'.format(vcs['name']), None)
- if get_command:
- self.run_command(get_command(filename), self.diff_done)
-
- def diff_done(self, result):
- self.log('diff_done', result)
-
- def git_diff_command(self, file_name):
- vcs_options = self.settings.get('vcs_options', {}).get('git') or ['--no-color', '--no-ext-diff']
- return [get_user_command('git') or 'git', 'diff'] + vcs_options + ['--', file_name]
-
- def svn_diff_command(self, file_name):
- params = [get_user_command('svn') or 'svn', 'diff']
- params.extend(self.settings.get('vcs_options', {}).get('svn', []))
-
- if '--internal-diff' not in params and self.settings.get('svn_use_internal_diff', True):
- params.append('--internal-diff')
-
- # if file starts with @, use `--revision HEAD` option
- # https://github.com/gornostal/Modific/issues/17
- if file_name.find('@') != -1:
- file_name += '@'
- params.extend(['--revision', 'HEAD'])
-
- params.append(file_name)
- return params
-
- def bzr_diff_command(self, file_name):
- vcs_options = self.settings.get('vcs_options', {}).get('bzr', [])
- return [get_user_command('bzr') or 'bzr', 'diff'] + vcs_options + [file_name]
-
- def hg_diff_command(self, file_name):
- vcs_options = self.settings.get('vcs_options', {}).get('hg', [])
- return [get_user_command('hg') or 'hg', 'diff'] + vcs_options + [file_name]
-
- def tf_diff_command(self, file_name):
- vcs_options = self.settings.get('vcs_options', {}).get('tf') or ['-format:unified']
- return [get_user_command('tf') or 'tf', 'diff'] + vcs_options + [file_name]
-
- def get_line_ending(self):
- return '\n'
-
- def join_lines(self, lines):
- """
- Join lines using os.linesep.join(), unless another method is specified in ST settings
- """
- return self.get_line_ending().join(lines)
-
-
-class ShowDiffCommand(DiffCommand, sublime_plugin.TextCommand):
- def diff_done(self, result):
- self.log('on show_diff', result)
-
- if not result.strip():
- return
-
- result = result.replace('\r\n', '\n')
- file_name = re.findall(r'([^\\\/]+)$', self.view.file_name())
- scratch = self.scratch(result, title="Diff - " + file_name[0])
-
- # Select the line in the diff output where the cursor is located.
- point = self.view.sel()[0].b
- region = self.view.line(point)
- line = self.view.substr(region)
-
- region = scratch.find(line, 0, sublime.LITERAL)
- scratch.show_at_center(region)
- scratch.sel().clear()
- # Place the cursor at the beginning of the line
- scratch.sel().add(scratch.line(region).a)
-
-
-class DiffParser(object):
- instance = None
-
- def __init__(self, diff):
- self.diff = diff
- self.chunks = None
- self.__class__.instance = self
-
- def _append_to_chunks(self, start, lines):
- self.chunks.append({
- "start": start,
- "end": start + len(lines),
- "lines": lines
- })
-
- def get_chunks(self):
- if self.chunks is None:
- self.chunks = []
- diff = self.diff.strip()
- if diff:
- re_header = re.compile(r'^@@[0-9\-, ]+\+(\d+)', re.S)
- current = None
- lines = []
- for line in diff.splitlines():
- # ignore lines with '\' at the beginning
- if line.startswith('\\'):
- continue
-
- matches = re.findall(re_header, line)
- if matches:
- if current is not None:
- self._append_to_chunks(current, lines)
- current = int(matches[0])
- lines = []
- elif current:
- lines.append(line)
- if current is not None and lines:
- self._append_to_chunks(current, lines)
-
- return self.chunks
-
- def get_lines_to_hl(self):
- inserted = []
- changed = []
- deleted = []
-
- for chunk in self.get_chunks():
- current = chunk['start']
- deleted_line = None
- for line in chunk['lines']:
- if line.startswith('-'):
- if (not deleted_line or deleted_line not in deleted):
- deleted.append(current)
- deleted_line = current
- elif line.startswith('+'):
- if deleted_line:
- deleted.pop()
- deleted_line = None
- changed.append(current)
- elif current - 1 in changed:
- changed.append(current)
- else:
- inserted.append(current)
- current += 1
- else:
- deleted_line = None
- current += 1
-
- return inserted, changed, deleted
-
- def get_original_part(self, line_num):
- """ returns a chunk of code that relates to the given line
- and was there before modifications
- return (lines list, start_line int, replace_lines int)
- """
-
- # for each chunk from diff:
- for chunk in self.get_chunks():
- # if line_num is within that chunk
- if chunk['start'] <= line_num <= chunk['end']:
- ret_lines = []
- current = chunk['start'] # line number that corresponds to current version of file
- first = None # number of the first line to change
- replace_lines = 0 # number of lines to change
- return_this_lines = False # flag shows whether we can return accumulated lines
- for line in chunk['lines']:
- if line.startswith('-') or line.startswith('+'):
- first = first or current
- if current == line_num:
- return_this_lines = True
- if line.startswith('-'):
- # if line starts with '-' we have previous version
- ret_lines.append(line[1:])
- else:
- # if line starts with '+' we only increment numbers
- replace_lines += 1
- current += 1
- elif return_this_lines:
- break
- else:
- # gap between modifications
- # reset our variables
- current += 1
- first = current
- replace_lines = 0
- ret_lines = []
- if return_this_lines:
- return ret_lines, first, replace_lines
-
- return None, None, None
-
-
-class HlChangesCommand(DiffCommand, sublime_plugin.TextCommand):
- def hl_lines(self, lines, hl_key):
- if (not len(lines) or not self.settings.get('highlight_changes')):
- self.view.erase_regions(hl_key)
- return
-
- icon = self.settings.get('region_icon') or 'modific'
- if icon == 'none':
- return
-
- if icon == 'modific':
- if IS_ST3:
- icon = 'Packages/Modific/icons/' + hl_key + '.png'
- else:
- icon = '../Modific/icons/' + hl_key
- points = [self.view.text_point(l - 1, 0) for l in lines]
- regions = [sublime.Region(p, p) for p in points]
- self.view.add_regions(hl_key, regions, "markup.%s.diff" % hl_key, icon, sublime.HIDDEN | sublime.DRAW_EMPTY)
-
- def diff_done(self, diff):
- self.log('on hl_changes:', diff)
-
- if diff and '@@' not in diff:
- # probably this is an error message
- # if print raise UnicodeEncodeError, try to encode string to utf-8 (issue #35)
- try:
- print(diff)
- except UnicodeEncodeError:
- print(diff.encode('utf-8'))
-
- diff_parser = DiffParser(diff)
- (inserted, changed, deleted) = diff_parser.get_lines_to_hl()
-
- self.log('new lines:', inserted)
- self.log('modified lines:', changed)
- self.log('deleted lines:', deleted)
-
- self.hl_lines(inserted, 'inserted')
- self.hl_lines(deleted, 'deleted')
- self.hl_lines(changed, 'changed')
-
-
-class ShowOriginalPartCommand(DiffCommand, sublime_plugin.TextCommand):
- def run(self, edit):
- diff_parser = DiffParser.instance
- if not diff_parser:
- return
-
- (row, col) = self.view.rowcol(self.view.sel()[0].begin())
- (lines, start, replace_lines) = diff_parser.get_original_part(row + 1)
- if lines is not None:
- self.panel(self.join_lines(lines))
-
-
-class ReplaceModifiedPartCommand(DiffCommand, sublime_plugin.TextCommand):
- def run(self, edit):
- self.view.run_command('save')
-
- diff_parser = DiffParser.instance
- if not diff_parser:
- return
-
- (row, col) = self.view.rowcol(self.view.sel()[0].begin())
- (lines, current, replace_lines) = diff_parser.get_original_part(row + 1)
- if self.settings.get('debug'):
- print('replace', (lines, current, replace_lines))
- if lines is not None:
- begin = self.view.text_point(current - 1, 0)
- content = self.join_lines(lines)
- if replace_lines:
- end = self.view.line(self.view.text_point(replace_lines + current - 2, 0)).end()
- region = sublime.Region(begin, end)
- if lines:
- self.view.run_command('edit_view', dict(command='replace', region=[region.begin(), region.end()], output=content))
- else:
- region = self.view.full_line(region)
- self.view.run_command('edit_view', dict(command='erase', region=[region.begin(), region.end()]))
- else:
- self.view.run_command('edit_view', dict(command='insert', begin=begin,
- output=content + self.get_line_ending()))
- self.view.run_command('save')
-
-
-class HlChangesBackground(sublime_plugin.EventListener):
- def on_load(self, view):
- if not IS_ST3:
- view.run_command('hl_changes')
-
- def on_load_async(self, view):
- view.run_command('hl_changes')
-
- def on_activated(self, view):
- if not IS_ST3:
- view.run_command('hl_changes')
-
- def on_activated_async(self, view):
- view.run_command('hl_changes')
-
- def on_post_save(self, view):
- if not IS_ST3:
- view.run_command('hl_changes')
-
- def on_post_save_async(self, view):
- view.run_command('hl_changes')
-
-
-class JumpBetweenChangesCommand(DiffCommand, sublime_plugin.TextCommand):
- def run(self, edit, direction='next'):
- lines = self._get_lines()
- if not lines:
- return
-
- if direction == 'prev':
- lines.reverse()
-
- (current_line, col) = self.view.rowcol(self.view.sel()[0].begin())
- current_line += 1
- jump_to = None
- for line in lines:
- if direction == 'next' and current_line < line:
- jump_to = line
- break
- if direction == 'prev' and current_line > line:
- jump_to = line
- break
-
- if not jump_to and self.settings.get('jump_between_changes_wraps_around', True):
- jump_to = lines[0]
-
- if jump_to is not None:
- self.goto_line(edit, jump_to)
-
- def goto_line(self, edit, line):
- # Convert from 1 based to a 0 based line number
- line = int(line) - 1
-
- # Negative line numbers count from the end of the buffer
- if line < 0:
- lines, _ = self.view.rowcol(self.view.size())
- line = lines + line + 1
-
- pt = self.view.text_point(line, 0)
-
- self.view.sel().clear()
- self.view.sel().add(sublime.Region(pt))
-
- self.view.show(pt)
-
- def _get_lines(self):
- diff_parser = DiffParser.instance
- if not diff_parser:
- return
-
- (inserted, changed, deleted) = diff_parser.get_lines_to_hl()
- lines = list(set(inserted + changed + deleted))
- lines.sort()
-
- prev = None
- ret_lines = []
- for line in lines:
- if prev != line - 1:
- ret_lines.append(line)
- prev = line
-
- return ret_lines
-
-
-class UncommittedFilesCommand(VcsCommand, sublime_plugin.WindowCommand):
- def active_view(self):
- return self.window.active_view()
-
- def is_enabled(self):
- return bool(self.get_working_dir())
-
- def get_working_dir(self):
- if self._active_file_name():
- working_dir = super(UncommittedFilesCommand, self).get_working_dir()
- if working_dir and get_vcs(working_dir):
- return working_dir
-
- # If the user has opened a vcs folder, use it.
- folders = self.window.folders()
- for folder in folders:
- if folder and os.path.exists(folder) and get_vcs(folder):
- return folder
-
- def run(self):
- self.vcs = get_vcs(self.get_working_dir())
- status_command = getattr(self, '{0}_status_command'.format(self.vcs['name']), None)
- if status_command:
- self.run_command(status_command(), self.status_done, working_dir=self.vcs['root'])
-
- def git_status_command(self):
- return [get_user_command('git') or 'git', 'status', '--porcelain']
-
- def svn_status_command(self):
- return [get_user_command('svn') or 'svn', 'status', '--quiet']
-
- def bzr_status_command(self):
- return [get_user_command('bzr') or 'bzr', 'status', '-S', '--no-pending', '-V']
-
- def hg_status_command(self):
- return [get_user_command('hg') or 'hg', 'status']
-
- def tf_status_command(self):
- return [get_user_command('tf') or 'tf', 'status']
-
- def filter_unified_status(self, result):
- return list(filter(lambda x: len(x) > 0 and not x.lstrip().startswith('>'),
- result.rstrip().replace('"', '').split('\n')))
-
- def git_filter_status(self, result):
- return self.filter_unified_status(result)
-
- def svn_filter_status(self, result):
- return self.filter_unified_status(result)
-
- def bzr_filter_status(self, result):
- return self.filter_unified_status(result)
-
- def hg_filter_status(self, result):
- return self.filter_unified_status(result)
-
- def tf_filter_status(self, result):
- filtered = []
- can_add = False
- for line in result.split('\n'):
- if line.startswith('$'):
- can_add = True
- continue
- if line == '':
- can_add = False
- continue
- if can_add:
- filtered.append(line)
-
- return filtered
-
- def git_status_file(self, file_name):
- # first 2 characters are status codes, the third is a space
- return file_name[3:]
-
- def svn_status_file(self, file_name):
- return file_name[8:]
-
- def bzr_status_file(self, file_name):
- return file_name[4:]
-
- def hg_status_file(self, file_name):
- return file_name[2:]
-
- def tf_status_file(self, file_name):
- try:
- # assume that file name should always contain colon
- return re.findall(r'\s+(\S+:.+)$', file_name)[0]
- except:
- return None
-
- def status_done(self, result):
- filter_status = getattr(self, '{0}_filter_status'.format(self.vcs['name']), None)
-
- self.results = [item.replace('\r', '') for item in filter_status(result)]
-
- if self.results:
- self.show_status_list()
- else:
- sublime.status_message("Nothing to show")
-
- def show_status_list(self):
- options = copy(self.results)
- options.insert(0, " - Open All")
- if self.settings.get('uncommitted_files_use_monospace_font', True):
- self.get_window().show_quick_panel(options, self.panel_done, sublime.MONOSPACE_FONT)
- else:
- self.get_window().show_quick_panel(options, self.panel_done)
-
- def panel_done(self, picked):
- if picked == 0:
- self.open_files(*self.results)
- return
- elif 0 > picked < len(self.results):
- return
- picked_file = self.results[picked - 1]
- self.open_files(picked_file)
-
- def open_files(self, *files):
- for f in files:
- get_file = getattr(self, '{0}_status_file'.format(self.vcs['name']), None)
- if get_file:
- fname = get_file(f)
- if os.path.isfile(os.path.join(self.vcs['root'], fname)):
- self.window.open_file(os.path.join(self.vcs['root'], fname))
- else:
- sublime.status_message("File '{0}' doesn't exist".format(fname))
-
-
-class ToggleHighlightChangesCommand(sublime_plugin.TextCommand):
- def run(self, edit):
- setting_name = "highlight_changes"
- settings = get_settings()
- is_on = settings.get(setting_name)
-
- if is_on:
- # remove highlighting
- [self.view.erase_regions(k) for k in ('inserted', 'changed', 'deleted')]
- else:
- self.view.run_command('hl_changes')
-
- settings.set(setting_name, not is_on)
- sublime.save_settings("Modific.sublime-settings")
diff --git a/samples/python2.py b/samples/python2.py
deleted file mode 100644
index d0d5ef9..0000000
--- a/samples/python2.py
+++ /dev/null
@@ -1,35 +0,0 @@
-# Simple Python Sample
-from __future__ import print_function
-
-import os
-import threading
-import sublime
-
-IS_ST3 = sublime.version().startswith('3')
-
-def get_vcs_settings():
- """Returns list of dictionaries"""
- if self.config.getboolean("verbose_stamps", fallback=False):
- print("Sending " + command)
-
- # Add a newline because the ui reads per line
- command += " \n"
- if self.gtk_proc:
- # Send the command as bytes
- self.gtk_proc.stdin.write(bytearray(command.encode("utf-8")))
- self.gtk_proc.stdin.flush()
- try:
- constructor = getattr(module, type)
- except AttributeError:
- print(_("Error: Class {} not found").format(type))
- continue
-
- else
- instance = constructor()
- instance.verbose = verbose
- instance.config = config
-
-def do_when(conditional, callback, *args, **kwargs):
- if conditional():
- return callback(*args, **kwargs)
- sublime.set_timeout(functools.partial(do_when, conditional, callback, *args, **kwargs), 50)
diff --git a/samples/rust.rs b/samples/rust.rs
new file mode 100644
index 0000000..9f53e20
--- /dev/null
+++ b/samples/rust.rs
@@ -0,0 +1,117 @@
+#[macro_use]
+extern crate log;
+
+use std::collections::HashMap;
+use std::rc::Rc;
+
+mod stuff;
+
+pub enum Flag {
+ Good,
+ Bad,
+ Ugly
+}
+
+const QUALITY: Flag = Flag::Good;
+
+struct Table
+
+ Column 1
+ Column 2
+
+
+ Row 1 Cell 1
+ Row 1 Cell 2
+
+
+Row 2 Cell 1
+ Row 2 Cell 2
+