GithubHelp home page GithubHelp logo

sublimeinput's Introduction

Sublime Input

Sublime Input is a Sublime Text 2/3 plugin which gives STDIN input through comments to a program.

Installation

With the Package Control plugin (Recommended):

  1. Bring up the Command Palette (Cmd+Shift+P on OS X, Ctrl+Shift+P on Linux/Windows).
  2. Select "Package Control: Install Package", wait while Package Control fetches the latest package list, then select Sublime Input.
  3. The advantage of using this method is that Package Control will automatically keep Sublime Input up to date with the latest version.

Alternate Method:

  1. Go to Preferences | Browse Packages
  2. Browse up a folder and then into the Installed Packages/ folder
  3. Downlad and Sublime.Input.sublime-package file
  4. Rename the Sublime.Input.sublime-package file to Sublime Input.sublime-package
  5. Put the Sublime Input.sublime-package file in the Installed Packages/ folder
  6. Restart Sublime Text

Usage

Insert a multi-line comment at the top of program.

Examples, using the default format:

Python:

'''input
2
foo
bar
'''
a=input()
for i in xrange(a):
    a=raw_input()
    print a

C/C++

/*input
2
foo
bar
*/
#include <stdio.h>
int main() {
  int n,i;
  char s[10];
  scanf("%d",&n);
  for(i=0;i<n;i++) {
    scanf("%s",s);
    printf("%s\n",s);
} }

Both the programs will print the following output:

foo
bar

Configure

Set the build schemas in Preferences: Package Settings > SublimeInput > Settings โ€“ User

Example schema :

{
  "build_schemas" : {
    "cpp" : {
      "shell_cmd" : "g++ \"${file}\" -o \"${file_path}/${file_base_name}\" && \"${file_path}/${file_base_name}\"",
      "input_start" : "/*input",
      "input_end" : "*/"
    }
  }
}

build_schemas contains key-value pairs, where the key's the filetype (cpp in this example), and a dictionary as its value.

shell_cmd stores the command to execute on build.

{file} - Complete address of the file

{file_path} - The address of the directory the file is stored in

{file_base_name} - Just the filename, without the extension

{file_extension} - The extension of the file

input_start stores the start of the input comment block.

input_end stores the end of the input comment block.

The default schema can be found in Preferences: Package Settings > SublimeInput > Settings โ€“ Default

The following schemas have been included by default:

  • C
  • C++
  • Python
  • Java

Keyboard Shortcuts

  • Ctrl + Alt + B - Build/Run program
  • Ctrl + Alt + C - Cancel the running pogram

Current Status

The Plugin is in active development. Windows users may encounter some bugs.

sublimeinput's People

Contributors

alexanderrevo avatar mavidser avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

sublimeinput's Issues

Set ANSI syntax for SublimeInput build

Hi, is possible set ANSI syntax and target for SublimeInput. Can i modify input.py with different settings?

syntax="Packages/User/ANSIescape/ANSI.tmLanguage",
target="ansi_color_build",


self.output_view.settings().set("syntax", syntax)
self.output_view.settings().set("target", target)

Windows echo.

Doesn't support multiline echo. Use windows specific echo using && for multiple lines.

Program not actually terminating after selecting cancel build

This is on Mac OSX using c++, the program continues running and I have to manually terminate it using activity monitor. Can be replicated I think by simply having a c++ program with an infinite loop in it. Is there something I am doing wrong that causes this behavior? By the way thanks for the excellent plugin :)

Auto save before build

It seems that I have to save the file before I do a build, can this be done (the saving part) automatically?

Problem in taking input

i have just added sublime Input sublime package file into installed package folder and restarted sublime text and when i press ctrl+alt+b for this code
#include
#include <bits/stdc++.h>
using namespace std;
int main()
{
string s;
cin>>s;
cout<<s;
}

C:/Program Files (x86)/mingw-w64/i686-7.1.0-posix-dwarf-rt_v5-rev2/mingw32/bin/../lib/gcc/i686-w64-mingw32/7.1.0/../../../../i686-w64-mingw32/bin/ld.exe: cannot open output file C:\Users\Moti Baadror\Desktop\youtube/tet1.exe: Permission denied
collect2.exe: error: ld returned 1 exit status

Port to Atom?

I have been trying Atom since past few days, but couldnt find any package with similar functionality.

How much would it be an effort to port this to Atom?

'Build Result' panel does not show up automatically at the bottom for java files

When building with SublimeInput, the build result is not shown automatically.
The bottom panel shows "Build Finished" as shown but not the output of the program:

image

Then I have to click the bottom left icon and select Build Result button to view the output of the java file.

image

But when building with SublimeInput for a python file, this problem does not happen. The output panel shows up automatically for that.

I have tried: Uninstalling, Reinstalling from Package Control and manually, changing the "shell_cmd" command in the user file.
The behaviour remains the same. no output panel for java files, but output panel shows up for python files

I am using Sublime Text 3 v3.2.2 Build 3211

Am I missing something? Testing it in Java

class text {
    public static void main(String []args) {
        try{
                Scanner sc = new Scanner(System.in);
                /*input
                Hello
                */
                String s = sc.nextLine();
                System.out.println(s);
            } catch( Exception ex){
                    System.out.println(ex);
            }
    }
}

prints an empty line, am I missing something?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.