fstiewitz / build-tools-cpp

Build your projects in atom
https://atom.io/packages/build-tools
MIT License
31 stars 6 forks source link

I can't add custom key binding to command #61

Open ghost opened 8 years ago

ghost commented 8 years ago

I can't add custom key binding to my "compile" command. Key Binding Resolver returns true, but the command doesn't execute.

'atom-workspace':
    'f4': 'build-tools:compile'
fstiewitz commented 8 years ago

Key Binding Resolver shows key bindings, but does not check whether their commands actually exist. Commands for built-tools are mentioned here. Just make sure that your "compile" command is the first, second or third command in your .build-tools.cson.

ghost commented 8 years ago

Should I rename my command to "first-command" and change the key in .build-tools.cson (to F4)? Can I access my command using "build-tools:commands"? How I do it?

Thanks.

fstiewitz commented 8 years ago

You can't access your commands by name. If your command is the first one in your .build-tools.cson, you execute it with build-tools:first-command. build-tools:second-command and build-tools:third-command execute the second and third command respectively. build-tools:commands displays a list of all available commands, allowing you to select and execute one.

ghost commented 8 years ago

Thanks. One more question, I'm using g++ and std::cout doesn't print on the console, only errors and warnings are appearing on the console. There is an option to enable it? (avoid running it in cmd to see result)

fstiewitz commented 8 years ago

g++ works perferctly fine on my machine. I also can't think of a configuration problem that would hide stdout but not stderr, but I also don't really have any information on your configuration. I would say it's a problem in your code until I know more.

ghost commented 8 years ago

main.cpp

#include <iostream>

using namespace std;

int main(int argc, char * argv[]) {
    int arraylength = 3;
    int input[arraylength];
    int output = 0;

    for (int i = 0; i < arraylength; i++)
        cin >> input[i];

    for (int i = 0; i < arraylength; i++)
        if (input[i] > output) output = input[i];

    cout << output << endl;

    return 0;
}

.build-tools.cson

providers: [
  {
    key: "bt"
    config:
      commands: [
        {
          project: "C:\\Users\\Danilo\\Desktop\\simple"
          source: "C:\\Users\\Danilo\\Desktop\\simple\\.build-tools.cson"
          name: "Compile"
          command: "g++ \"*.cpp\" -std=c++14 -o \"../release/simple.exe\""
          wd: "source"
          env: {}
          modifier:
            save_all: {}
          stdout:
            pty: false
            highlighting: "nh"
            ansi_option: "ignore"
          stderr:
            highlighting: "hc"
            profile: "gcc_clang"
          output:
            console:
              close_success: false
              queue_in_buffer: true
              stdin: true
            linter:
              no_trace: false
          version: 1
        }
      ]
  }
]

The input field is disappearing after a few seconds as well (impossible cin).

fstiewitz commented 8 years ago

I guess it would make sense to also start the command. g++ just compiles it. Also, stdin can be buggy if you don't use pty.js.

ghost commented 8 years ago

I got this error using pty.js:

Uncaught Error: File not found:

C:\Users\Danilo\.atom\packages\build-tools\node_modules\ptyw.js\lib\pty_win.js:56

Error: File not found: 
    at Error (native)
    at Server.<anonymous> (C:\Users\Danilo\.atom\packages\build-tools\node_modules\ptyw.js\lib\pty_win.js:56:9)
    at emitOne (events.js:77:13)
    at Server.emit (events.js:169:7)
    at Pipe.onconnection (net.js:1427:8)
fstiewitz commented 8 years ago

I guess there is something wrong with your configuration but I can't test it, since I don't use this OS. *.cpp in your command shouldn't work either, but then g++ should print an error message and not Atom. I have a modifier called Execute In Shell that probably supports patterns, but the default configuration only works for UNIXs (maybe something like cmd.exe works here). Other than that, Windows users are on their own :disappointed: .

ghost commented 8 years ago

Thanks. I will change the OS. Maybe CentOS.

fstiewitz commented 8 years ago

I'm not saying people should change their OS because of my package. I'm just saying that I do not know enough about Windows to properly support it.