Sublime Forum

PostScript language support?

#1

I’m testing the possibility of changing my code editor. One of the candidates must be Sublime.

A substantial proportion of my code editing is of a program written in PostScript (to make placemats, if you must know). Please could I be taken through the Peter-and-Jane steps to add support for PostScript to Sublime on Mac OS X 10.10.1?

Thank you.

0 Likes

Mis-parse language-formatting bundle
#2

What do you need to support ? Code formatting, building system, displaying preview of graphics ?

Code formatting: docs.sublimetext.info/en/latest/ … xdefs.html
Custom build system: docs.sublimetext.info/en/latest/ … stems.html
Preview: Kinda tricky but can be achieved with SideBarEnhancments plugin (look in C++ project make panel and plugin documenation)

0 Likes

#3

Code formatting is what I’m seeking, but that’s a pile of work for a newbie. Please alkuzad, do you if there already is a specification file for PostScript, and if so, by what steps I can install it?

0 Likes

#4

As Sublime uses same syntax as TextMate we can import TextMate postscript support:

In sublime click Preferences>Browse Packages.

Go to Packages/User

Insert file from github.com/textmate/postscript. … tmLanguage

Go to your Postscript file, press ‘ctrl + p’ and write ‘set syntax postscript’, then file should have pretty colours. I do not know this system well but at least Wikipedia “Hello World” seems to work.

0 Likes

#5

Thank you.

We must be near, even if not quite. Bottom-right of a .ps window is a format, “Plain text”. Clicking on that lists about 40ish possible types, none of which are PostScript (even after a quit and re-start). So it isn’t installed.

The downloaded file is in

…/Library/Application\ Support/Sublime\ Text\ 2/Packages/User/Postscript.tmLanguage

and starts[code]

<title>postscript.tmbundle/Postscript.tmLanguage at master · textmate/postscript.tmbundle · GitHub</title>[/code]Does that seem correct?

[size=85]PS: Though I can program in PostScript and C and VBA, my UNIX skills are non-existent.[/size]

0 Likes

#6

Github is a service for hosting Git repositories (Git, SVN, Mercurial - services for maintaining files versioning).

This is preview of master (main) branch of this repository. I’ve linked directly to preview of this file so you can track changes (if they will come) but you have to either use Git to copy this file from repository or use “Raw” button to see only file content.

tmLanguage file is kind of XML file (plist) and you have downloaded whole Github page.

0 Likes

#7

Thank you.

Now the file begins[code]<?xml version="1.0" encoding="UTF-8"?>

fileTypes ps eps firstLineMatch ^%!PS[/code]which seems more sensible.

That leaves the small problem that on opening a .ps file the CPU whirs (according to the Mac’s Activity Monitor) but Sublime doesn’t work. Black screen, with a faint grey bar that might be a progress bar about 40% progressed. After I try to do something (such as command-A, to select all the text none of which I can see), the coloured wheel spins and Sublime is utterly unresponsive. Right-click on the dock says “Application Not Responding”. After a few minutes application Force Quit’d.

This is not yet going smoothly.

In case you want to replicate the problem, I’m opening the file a copy of which is at www.jdawiseman.com/papers/placemat/placemat.ps. It is almost 12k lines of PostScript: is it too long?

0 Likes

#8

On mine sublime on Win7 this file works smoothly. I am using Sublime Text 3 build 3065.

I’ve heard about some problems with Mac but as long as main developer - Jon Skinner - is not responding to community, we can not do much.

So I advise you too look into another editor if you do not want ST3 for specific reason.

0 Likes

#9

ST3 is described as being in beta. Do you know how beta this is? (Non-techie user wants a stable build, even if not all the complicated features are fully implemented.)

0 Likes

#10

ST3 downloaded, and — drum roll — it works. Thank you.

0 Likes

#11

Some observations from a non-expert.

• Fast and responsive application. Very important, and excellent. Me like.

• The lines showing matching tabs are a great help, and it is wisely Tufte-esque that they are faint but visible. But even better would be for the colours to rotate: 0 mod 3 the current pale grey; 1 mod 3 big very faint green; 2 mod 3 very faint red.

Weird colouring bug.

• Could PostScript be one of the standard languages? My PostScript program is used by deeply non-technical people.

"]A code editor, a good text editor, is a boon, and it should be one that understands PostScript. On a Mac Alpha X is excellent and free, and Aquamacs Emacs is suitable for Emacs experts. On a PC NotePad++ is good. The basic text editor that came pre-installed on your computer will make life harder than it needs to be. A code editor that understands PostScript will prevent many errors and save much labour.Alpha is good, but hasn’t been updated since 2008, and its interaction with the latest OS rather frays at the edges. If Sublime coped with .ps by default — surely not difficult to do — then it could be new recommendation. But presumably this aspiration is blocked by “Jon Skinner … is not responding to community”.

But the first post-installation taste is good. Thank you again for installation help.

0 Likes

Request: indent lines to tri-alternate colours
Mis-parse language-formatting bundle
#12
import shutil;import urllib.request;import os;import tempfile;l='https://raw.githubusercontent.com/textmate/postscript.tmbundle/master/Syntaxes/Postscript.tmLanguage';d=urllib.request.urlopen(l);f=d.read().decode('utf-8');p=os.path.join(sublime.packages_path(),'User','PostScript.tmLanguage');_, t = tempfile.mkstemp(dir=tempfile.gettempdir());th = open(t, 'w');th.writelines(f);th.close();shutil.move(t, p) if f.find('plist') != -1 else sublime.error_dialog('Something went wrong, file is corrupt');dh = open(p);ok = True if dh.read().find("Postscript") != "-1" else False;sublime.message_dialog('Installation completted successfully') if ok is True else sublime.error_dialog('Installation aborted - deleting file %s ' % p);os.remove(p) if not ok else print("File created successfully");

You can enter console mode with “Ctrl + ~” (tilde). Paste above code, press enter and file should download itself to /tmp and move to ST3 Packages. Will work only in ST3. This is the easiest way to do it (Package Control is easiest but it must be installed first)

Edit:
Please be sure to remove unnecessary spaces before code. This will stop python from running.

0 Likes

#13

That works — thank you — but doesn’t really address the issue. For people making placemats for a wine tasting, not always the most technical of people, it has to work out of the box. Easy for Jon Skinner to add to the box, but not if he’s busy elsewhere.

I need to master the multi-cursor thing; and also to make it stop adding matching brackets. Still testing (and doing other things).

0 Likes

#14

The manual of my PostScript software has been updated to say:

Does that seem fair?

0 Likes

#15

Indeed. But I can not understand how someone that is supposed to edit such complicated file can not download file and place it in folder.

0 Likes

#16

That is utterly fair. And some of the users I know could do that without fuss. But some ≠ all.

0 Likes

#17

ST3 is now my default application for .ps files, and a licence has been bought. Happiness!

But my .ps files are still showing the icon of their previous default editor. Please, is it easy for .ps files to have an icon appropriate to their (new) default application? Edit: solved. Edit edit: .icns file in place; Sublime the application for .ps; doesn’t work. Not solved. :frowning:

0 Likes