Home Download Buy Blog Forum Support

One use for showInputPanel: interactive Haskell prompt

One use for showInputPanel: interactive Haskell prompt

Postby FalconNL on Mon Feb 23, 2009 11:35 pm

Saw this function in the changelog for the latest beta and couldn't find any examples yet on how to use it yet, so I played around a little:
Code: Select all
class GhcExpressionCommand(sublimeplugin.TextCommand):
    def run(self, view, args):
        view.window().runCommand("save")
        runexpr = lambda e: view.window().runCommand("exec",["","ghc.exe -e \"" + e.replace("\"","\\\"") + "\" \"" + view.fileName() + "\""])
        view.window().showInputPanel("Run Ghc expression:", "", runexpr, lambda s:s, 0)

Bind with something like
Code: Select all
<binding key="F8" command="ghcExpression">
    <context name="selector" value="source.haskell"/>
</binding>

and voila, an interactive Haskell prompt in Sublime text. Useful for things like checking types or quickly testing the output of a function.
It should work for other languages as well, assuming they can run commands on a file from the command line.

Very useful addition, thanks jps!
FalconNL
 
Posts: 67
Joined: Thu May 29, 2008 8:17 pm

Re: One use for showInputPanel: interactive Haskell prompt

Postby SteveCooperOrg on Tue Feb 24, 2009 7:52 am

FalconNL wrote:Very useful addition, thanks jps!


Definitely. With the input panel and the quick panel, we've got some really nice tools for adding interactivity. Thumbs up from me, too!
Maybe what you're looking for is at the http://www.sublimetextwiki.com
SteveCooperOrg
 
Posts: 193
Joined: Thu Mar 20, 2008 9:53 am

Re: One use for showInputPanel: interactive Haskell prompt

Postby SteveCooperOrg on Tue Feb 24, 2009 8:02 am

This would also be useful for vi emulation; pop up a panel and type "s/search/replace<enter>" to do a vi-style search-and-replace. Our man vim will be very happy, I suspect...
Maybe what you're looking for is at the http://www.sublimetextwiki.com
SteveCooperOrg
 
Posts: 193
Joined: Thu Mar 20, 2008 9:53 am

Re: One use for showInputPanel: interactive Haskell prompt

Postby vim on Wed Mar 18, 2009 9:40 am

:D
vim
 
Posts: 298
Joined: Tue May 27, 2008 6:51 pm


Return to Plugin Announcements

Who is online

Users browsing this forum: Google [Bot] and 4 guests