Skip to content
This repository has been archived by the owner on Jul 22, 2020. It is now read-only.

Commit

Permalink
updated readme and build path generator
Browse files Browse the repository at this point in the history
  • Loading branch information
Southclaws committed Jul 7, 2018
1 parent 93bb433 commit b83dab3
Show file tree
Hide file tree
Showing 7 changed files with 316 additions and 42 deletions.
19 changes: 9 additions & 10 deletions IncrementSelectionCommand.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import sublime, sublime_plugin
import sublime
import sublime_plugin

class SequentialNumberInsertCommand(sublime_plugin.TextCommand):

def run(self, edit):

value = 0

for selection in self.view.sel():
self.view.erase(edit, selection)
self.view.insert(edit, selection.begin(), str(value))
value = value + 1
class SequentialNumberInsertCommand(sublime_plugin.TextCommand):
def run(self, edit):
value = 0
for selection in self.view.sel():
self.view.erase(edit, selection)
self.view.insert(edit, selection.begin(), str(value))
value = value + 1
11 changes: 6 additions & 5 deletions OpenWikiOnString.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import sublime, sublime_plugin
import sublime
import sublime_plugin
import webbrowser

class OpenWikiOnString(sublime_plugin.TextCommand):

def run(self, edit):
query = self.view.substr(self.view.sel()[0])
webbrowser.open_new("http://wiki.sa-mp.com/wiki/" + query)
class OpenWikiOnString(sublime_plugin.TextCommand):
def run(self, edit):
query = self.view.substr(self.view.sel()[0])
webbrowser.open_new("http://wiki.sa-mp.com/wiki/" + query)
2 changes: 1 addition & 1 deletion PAWN.sublime-settings
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"extensions": ["pwn", "inc", "own"]
"extensions": ["pwn", "inc"]
}
47 changes: 32 additions & 15 deletions PawnBuildPath.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,39 @@
import sublime, sublime_plugin
import json
import sublime
import sublime_plugin
from .edit import Edit


class PawnBuildPathCommand(sublime_plugin.TextCommand):
def run(self, edit):
self.view.window().show_input_panel("Set Pawn build path", "C:\\Pawno\\", self.onPawnPathDone, None, None)
def run(self, edit):
self.view.window().show_input_panel(
"Working directory that contains pawncc.exe",
"C:\\Pawno\\",
self.onPawnPathDone,
None,
None
)

def onPawnPathDone(self, path):
view = self.view.window().new_file()
path = path.replace("\\", "/")

def onPawnPathDone(self, path):
view = self.view.window().new_file()
path = path.replace("\\", "/")
obj = {
"cmd": [
"pawncc.exe",
"$file",
"-o$file_path/$file_base_name",
"-;+",
"-(+",
"-d3"
],
"file_regex": r"(.*?)\(([0-9]*)[- 0-9]*\)",
"selector": "source.pwn",
"working_dir": path
}

with Edit(view) as edit:
edit.insert(0,"""{
"cmd": ["pawncc.exe", "$file", "-o$file_path/$file_base_name", "-;+", "-(+", "-d3"],
"file_regex": "(.*?)\\\\(([0-9]*)[- 0-9]*\\\\)",
"selector": "source.pwn",
"working_dir": "%s"
}"""%(path))
with Edit(view) as edit:
edit.insert(0, json.dumps(obj, indent=4))

view.set_name("Pawn.sublime-build")
view.run_command("save");
view.set_name("Pawn.sublime-build")
view.run_command("save")
116 changes: 116 additions & 0 deletions README.bb
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
[COLOR="#FF4700"][SIZE="7"][B]Pawn Tools for Sublime Text[/B][/SIZE][/COLOR]

Sublime Text is an extremely feature-rich and customisable plain-text editor. It’s customisability is powered by Python scripting and there are a huge amount of extensions available. Sublime Text gives you an amazing toolset tailored to speeding up your writing workflow whether that is code, articles or just quick notes. (Example: I wrote this entire article in Sublime using an Evernote + Markdown extension)

[COLOR="RoyalBlue"][SIZE="6"][B]Features[/B][/SIZE][/COLOR]

Here’s a quick overview of my five favourite features.

[COLOR="DeepSkyBlue"][SIZE="5"][B]Multiple Cursors[/B][/SIZE][/COLOR]

Multiple selection By far my favourite feature. Place as many carets as you want, select as much text as you want. Hold the CTRL button and tap the LMB to place a caret. Or click-drag MMB to select a ‘rectangle’ of text. CTRL+D will select the next instance of whatever text you have selected and ALT+F3 instantly selects every instance.

[IMG]https://i.imgur.com/svE9Dsn.gif[/IMG] [IMG]https://i.imgur.com/vLtXqhj.gif[/IMG] [IMG]https://i.imgur.com/bPFhMwN.gif[/IMG]

[COLOR="DeepSkyBlue"][SIZE="5"][B]Mini Map[/B][/SIZE][/COLOR]

A zoomed out version of your code that you can use to scroll around. Very handy for large files.

[IMG]https://i.imgur.com/cGd6pDH.gif[/IMG]

[COLOR="DeepSkyBlue"][SIZE="5"][B]Snippets[/B][/SIZE][/COLOR]

Snippets are templates of commonly used phrases that you can trigger by typing a certain set of characters. For instance, I can type [FONT="courier new"]ALS[/FONT] and all the code for an ALS hook will be inserted. Then I can tap TAB to cycle through each editable part of the template (prefix, function name and parameters)

[IMG]https://i.imgur.com/sxkok4K.gif[/IMG]

[COLOR="DeepSkyBlue"][SIZE="5"][B]Conversions[/B][/SIZE][/COLOR]

Convert to tabs, tab size, encoding and syntax buttons Okay, not exactly unique to Sublime but all handily placed at the bottom right. I code with tabs, but a lot of the time I need to push somewhere that only accepts spaces so conversion is useful.

[IMG]https://i.imgur.com/kfZL6kf.gif[/IMG]

[COLOR="DeepSkyBlue"][SIZE="5"][B]Configuration[/B][/SIZE][/COLOR]

Everything is JSON, Python or XML. Settings and key bindings are all stored in JSON format files and can be overwritten with user specific sets of settings. As soon as a change is made, Sublime reloads the settings and updates before your eyes! Extension scripts are written in Python and can expand the editor a lot.

[COLOR="RoyalBlue"][SIZE="6"][B]Installation[/B][/SIZE][/COLOR]

Download and install Sublime Text for your operating system on the [URL="https://www.sublimetext.com/"]official site[/URL].

The software is available for free evaluation without any restrictions or hindrance aside from a small message box that pops up when saving sometimes. I encourage you support the development of this software if possible though!

[COLOR="RoyalBlue"][SIZE="6"][B]Pawn Language Plugin[/B][/SIZE][/COLOR]

I created a Pawn language pack for sublime text which includes a ton of useful stuff such as a build configuration, syntax highlighting (modified C syntax) and snippets for common Pawn/SA:MP boilerplate code.

[COLOR="DeepSkyBlue"][SIZE="5"][B]Install[/B][/SIZE][/COLOR]

You can quickly install this if you have [URL="https://packagecontrol.io/"]Package Control[/URL] installed. Simply open the Command Palette with CTRL+Shift+P, type [FONT="courier new"]Package Control: Install Package[/FONT]:

[IMG]https://i.imgur.com/TFsDiHyl.png[/IMG]

Once the list has loaded, search for the [FONT="courier new"]Pawn Syntax[/FONT] package and hit enter:

[IMG]https://i.imgur.com/BjiF9RIl.png[/IMG]

Now the package is installed, you need to generate a build configuration so that Sublime Text can talk to [FONT="courier new"]pawncc[/FONT] - the Pawn compiler. If you came from Pawno, the compiler is located in the Pawno directory and it’s named [FONT="courier new"]pawncc.exe[/FONT].

You can also install manually by getting the source from GitHub and dropping files from the repo into the [FONT="courier new"]Data\Packages\Pawn-Syntax\[/FONT] directory which is located either in your Documents, AppData or Program Files directory for Sublime Text.

[COLOR="DeepSkyBlue"][SIZE="5"][B]Setup[/B][/SIZE][/COLOR]

[COLOR="SlateGray"][SIZE="4"]For sampctl[/SIZE][/COLOR]

If you use [URL="http://bit.ly/sampctl-thread"]sampctl[/URL] you don’t need to do any of this, just [FONT="courier new"]sampctl package init[/FONT] and select [FONT="courier new"]Sublime Text[/FONT] as your preferred editor, a build configuration will be automatically generated for you.

[COLOR="SlateGray"][SIZE="4"]For pawncc[/SIZE][/COLOR]

If you came from Pawno, follow these instructions to get set up.

To set up the Pawn compiler, open [FONT="courier new"]Preferences > Package Settings > Pawn Compiler Settings > Build Settings[/FONT]

Type the path to your Pawn compiler in the input panel that pops up, example: [FONT="courier new"]C:\SA-MP\Server\pawno\[/FONT]

The file will be automatically named and prompt to be saved, save it in [FONT="courier new"]Data\Packages\User[/FONT] (the save window may automatically open here anyway).

[IMG]https://i.imgur.com/KRAmRh2.gif[/IMG]

The file that’s generated is a [FONT="courier new"].sublime-build[/FONT] file and I’ll go through each line explaining what it means here.

[LIST]
[*][FONT="courier new"]cmd[/FONT]: is the command to pass. You can include compiler flags such as [FONT="courier new"]-d3[/FONT]
and [FONT="courier new"]-Z+[/FONT] in their own argument strings after this.
[*][FONT="courier new"]fileregex[/FONT]: is a regex used to parse error/warning output. This allows you to
double-click errors/warnings to jump directly to the file and line.
[*][FONT="courier new"]workingdir[/FONT]: is the path to the directory where [FONT="courier new"]pawncc.exe[/FONT] is stored. This
is the string that’s set by your input.
[/LIST]

[COLOR="DeepSkyBlue"][SIZE="5"][B]Auto-Completion[/B][/SIZE][/COLOR]

The Pawn Syntax package includes auto-complete files for all SA:MP natives as well as a lot of popular libraries.

[URL="http://forum.sa-mp.com/showthread.php?t=511195"]Head over to this thread to read more about auto-complete and contribute.[/URL]

[IMG]https://i.imgur.com/Hd5qCuL.gif[/IMG]

[COLOR="DeepSkyBlue"][SIZE="5"][B]Mapping Keys[/B][/SIZE][/COLOR]

Key bindings are stored in JSON format inside [FONT="courier new"].sublime-keymap[/FONT] files. There are default key bindings, user key bindings and package specific key binds which conveniently overwrite each other in that reverse order.

In the Pawn Syntax package, I’ve included a small set of key bindings some of which emulate Pawno and others I just find useful:

[LIST]
[*][FONT="courier new"]f3[/FONT]: Find next
[*][FONT="courier new"]f4[/FONT]: Find previous
[*][FONT="courier new"]ctrl+r[/FONT]: Open the output panel (where warnings and errors appear)
[*][FONT="courier new"]f5[/FONT]: Compile the current file
[*][FONT="courier new"]pause[/FONT]: Cancels compilation (very useful if you realise you forgot something
just after compiling!)
[/LIST]

[COLOR="RoyalBlue"][SIZE="6"][B]Contributors[/B][/SIZE][/COLOR]

[URL="https://github.com/Southclaws/pawn-sublime-language/graphs/contributors"]See this page[/URL] for a list of contributors to this project.

162 changes: 151 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,155 @@
# Pawn Language Definitions and Extra Bits for Sublime Text
# Pawn Tools for Sublime Text

Please see [this post](http://forum.sa-mp.com/showthread.php?t=531379) for details on installing this plugin!
Sublime Text is an extremely feature-rich and customisable plain-text editor.
It's customisability is powered by Python scripting and there are a huge amount
of extensions available. Sublime Text gives you an amazing toolset tailored to
speeding up your writing workflow whether that is code, articles or just quick
notes. (Example: I wrote this entire article in Sublime using an Evernote +
Markdown extension)

## Features

# Credits
Here's a quick overview of my five favourite features.

- Patrik356b for some of the original ideas and discussion.
- pds2k12/Patrick for some autocompletions
- Misiur for an ALS function snippet to base the ALS snippets off
- Doreto for great autocompletion contribution
- Jessyy for some autocompletion contribution
- GtakillerIV for some autocompletion contribution
- Crayder for syntax contributions
- Everyone on the thread who suggested autocompletions
### Multiple Cursors

Multiple selection By far my favourite feature. Place as many carets as you
want, select as much text as you want. Hold the CTRL button and tap the LMB to
place a caret. Or click-drag MMB to select a 'rectangle' of text. CTRL+D will
select the next instance of whatever text you have selected and ALT+F3 instantly
selects every instance.

![https://i.imgur.com/svE9Dsn.gif](https://i.imgur.com/svE9Dsn.gif)
![https://i.imgur.com/vLtXqhj.gif](https://i.imgur.com/vLtXqhj.gif)
![https://i.imgur.com/bPFhMwN.gif](https://i.imgur.com/bPFhMwN.gif)

### Mini Map

A zoomed out version of your code that you can use to scroll around. Very handy
for large files.

![https://i.imgur.com/cGd6pDH.gif](https://i.imgur.com/cGd6pDH.gif)

### Snippets

Snippets are templates of commonly used phrases that you can trigger by typing a
certain set of characters. For instance, I can type `ALS` and all the code for
an ALS hook will be inserted. Then I can tap TAB to cycle through each editable
part of the template (prefix, function name and parameters)

![https://i.imgur.com/sxkok4K.gif](https://i.imgur.com/sxkok4K.gif)

### Conversions

Convert to tabs, tab size, encoding and syntax buttons Okay, not exactly unique
to Sublime but all handily placed at the bottom right. I code with tabs, but a
lot of the time I need to push somewhere that only accepts spaces so conversion
is useful.

![https://i.imgur.com/kfZL6kf.gif](https://i.imgur.com/kfZL6kf.gif)

### Configuration

Everything is JSON, Python or XML. Settings and key bindings are all stored in
JSON format files and can be overwritten with user specific sets of settings. As
soon as a change is made, Sublime reloads the settings and updates before your
eyes! Extension scripts are written in Python and can expand the editor a lot.

## Installation

Download and install Sublime Text for your operating system on the
[official site](https://www.sublimetext.com/).

The software is available for free evaluation without any restrictions or
hindrance aside from a small message box that pops up when saving sometimes. I
encourage you support the development of this software if possible though!

## Pawn Language Plugin

I created a Pawn language pack for sublime text which includes a ton of useful
stuff such as a build configuration, syntax highlighting (modified C syntax) and
snippets for common Pawn/SA:MP boilerplate code.

### Install

You can quickly install this if you have
[Package Control](https://packagecontrol.io/) installed. Simply open the Command
Palette with CTRL+Shift+P, type `Package Control: Install Package`:

![https://i.imgur.com/TFsDiHyl.png](https://i.imgur.com/TFsDiHyl.png)

Once the list has loaded, search for the `Pawn Syntax` package and hit enter:

![https://i.imgur.com/BjiF9RIl.png](https://i.imgur.com/BjiF9RIl.png)

Now the package is installed, you need to generate a build configuration so that
Sublime Text can talk to `pawncc` - the Pawn compiler. If you came from Pawno,
the compiler is located in the Pawno directory and it's named `pawncc.exe`.

You can also install manually by getting the source from GitHub and dropping
files from the repo into the `Data\Packages\Pawn-Syntax\` directory which is
located either in your Documents, AppData or Program Files directory for Sublime
Text.

### Setup

#### For sampctl

If you use [sampctl](http://bit.ly/sampctl-thread) you don't need to do any of
this, just `sampctl package init` and select `Sublime Text` as your preferred
editor, a build configuration will be automatically generated for you.

#### For pawncc

If you came from Pawno, follow these instructions to get set up.

To set up the Pawn compiler, open
`Preferences > Package Settings > Pawn Compiler Settings > Build Settings`

Type the path to your Pawn compiler in the input panel that pops up, example:
`C:\SA-MP\Server\pawno\`

The file will be automatically named and prompt to be saved, save it in
`Data\Packages\User` (the save window may automatically open here anyway).

![https://i.imgur.com/KRAmRh2.gif](https://i.imgur.com/KRAmRh2.gif)

The file that's generated is a `.sublime-build` file and I'll go through each
line explaining what it means here.

- `cmd`: is the command to pass. You can include compiler flags such as `-d3`
and `-Z+` in their own argument strings after this.
- `fileregex`: is a regex used to parse error/warning output. This allows you to
double-click errors/warnings to jump directly to the file and line.
- `workingdir`: is the path to the directory where `pawncc.exe` is stored. This
is the string that's set by your input.

### Auto-Completion

The Pawn Syntax package includes auto-complete files for all SA:MP natives as
well as a lot of popular libraries.

[Head over to this thread to read more about auto-complete and contribute.](http://forum.sa-mp.com/showthread.php?t=511195)

![https://i.imgur.com/Hd5qCuL.gif](https://i.imgur.com/Hd5qCuL.gif)

### Mapping Keys

Key bindings are stored in JSON format inside `.sublime-keymap` files. There are
default key bindings, user key bindings and package specific key binds which
conveniently overwrite each other in that reverse order.

In the Pawn Syntax package, I've included a small set of key bindings some of
which emulate Pawno and others I just find useful:

- `f3`: Find next
- `f4`: Find previous
- `ctrl+r`: Open the output panel (where warnings and errors appear)
- `f5`: Compile the current file
- `pause`: Cancels compilation (very useful if you realise you forgot something
just after compiling!)

## Contributors

[See this page](https://github.com/Southclaws/pawn-sublime-language/graphs/contributors)
for a list of contributors to this project.
1 change: 1 addition & 0 deletions edit.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
except AttributeError:
sublime.edit_storage = {}


def run_callback(func, *args, **kwargs):
spec = inspect.getfullargspec(func)
if spec.args or spec.varargs:
Expand Down

0 comments on commit b83dab3

Please sign in to comment.