Git Product home page Git Product logo

console's Introduction

Console

A console plugin for the Lite XL text editor

This version of the plugin is adapted from the console plugin for the lite editor.

gif

Install

Navigate to the data/plugins folder and run the following command:

git clone https://github.com/lite-xl/console

Alternatively the init.lua file can be renamed console.lua and dropped in the data/plugins folder.

Basic Usage

A basic command can be ran in the console by using the console:run command (ctrl+shift+.). The default console view at the bottom of the screen can be toggled with ctrl+.; additional console views can be opened with the console:open-console command.

Build Systems

Following is an example of how you can set up a build system for a project. This code should be put in the project module (accessed by running the core:open-project-module command):

local core = require "core"
local command = require "core.command"
local keymap = require "core.keymap"
local console = require "plugins.console"

command.add(nil, {
  ["project:build-project"] = function()
    core.log "Building..."
    console.run {
      command = "./build.sh",
      file_pattern = "(.*):(%d+):(%d+): (.*)$",
      cwd = ".",
      on_complete = function(retcode) core.log("Build complete with return code "..retcode) end,
    }
  end
})

keymap.add { ["ctrl+b"] = "project:build-project" }

The console.run function can be also invoked with an additional option named file_prefix. If specified the prefix will be added to the file names reported in the console to help resolve them within the project. It can be useful when the build happens in a subdirectory of the project.

License

This project is free software; you can redistribute it and/or modify it under the terms of the MIT license. See LICENSE for details.

console's People

Contributors

cfuendev avatar dev-dwarf avatar franko avatar guldoman avatar jgmdev avatar joedestroy avatar rxi 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

Watchers

 avatar  avatar  avatar

console's Issues

Node issues on Windows

When I do node --help I get:
image

The error will vary depending on the node version you use. This happened in the new lts and the latest version. On Linux, where it works, I have an older version of node but when testing that same version on windows I still get the error.

I tried using lite-xl 2.0.3 and lite.xl 2.0.0 and both had the issue on windows.

Closing opened files

Hey!

I've noticed that you basically can't close opened loop app. Ctrl-c is not working (which is obvious) but there is no option to cancel operation. Shortcut or command would be great cause for example it's impossible for me to exit npm when it's running without reseting LiteXL and killing process by default terminal.

Best wishes :)

Love.exe creates its own console, instead of using the launch console so the output is not captured

I'm not sure how to get the behavior shown in the picture, on the readme.md file?

Love.exe does not seem to use the stdout of the launching process, so if I run love --console . with lite-xl's console, I get no output.

How can I execute a Love2d project and get output, like in the picture? (Taken from readme)

https://user-images.githubusercontent.com/3920290/81343656-49325a00-90ad-11ea-8647-ff39d8f1d730.gif

REPL loop.

Hello, I want to extend this console to something more like terminal. But I can't figure out how to spawn REPL process, currently I'm
doing ...

local proc, err = process.start(command, { cwd=opt.cwd, stdin = process.REDIRECT_DISCARD, timeout=process.WAIT_INFINITE })
local text = proc:read_stdout()
while proc:running() do
  if text ~= nil then
    push_output(text, opt)
  end
  coroutine.yield(0.1)
  text = proc:read_stdout()
end
core.log("process is stopped")

but spawned process exit immediately after printing version information and >>> e.g for python it's a

Python 3.8.3 (tags/v3.8.3:6f8c832, May 13 2020, 22:20:19) [MSC v.1925 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>

Googling for REPL and reproc doesn't help, only one issue but it's unclear is it fixed or not.

Update to work with Lite XL 2.0

The mod-version tag needs to be changed but that's not enough.

When closing the documents the console remains with a broken layout.

We may also consider upgrade the plugin to use "reproc" to create processes.

No all compilers return line and col number, but a range!

Pawn language return a range where warning / error was like this

/home/SmileY/antiflood.sma(22 -- 24) : warning 215: expression has no effect

I suggest to filter column and line using string.match inside tonumber:

function ConsoleView:on_mouse_pressed(...)
  local caught = ConsoleView.super.on_mouse_pressed(self, ...)
  if caught then
    return
  end
  local item = output[self.hovered_idx]
  if item then
    local file, line, col = item.text:match(item.file_pattern)
    local resolved_file = resolve_file(item.file_prefix, file)
    if not resolved_file then
      -- fixes meson output which adds ../ for build sub directories
      resolved_file = resolve_file(
        item.file_prefix,
        file:gsub("%.%./", ""):gsub("^%./", "")
      )
    end
    if not resolved_file then
      core.error("Couldn't resolve file \"%s\"", file)
      return
    end
    core.try(function()
      core.root_view:open_doc(core.open_doc(resolved_file))
      line = tonumber(string.match(line, "%d+")) or 1
      col = tonumber(string.match(col, "%d+")) or 1
      core.add_thread(function()
        core.active_view.doc:set_selection(line, col)
      end)
    end)
  end
end

My console run command was

          -- Run console command
          console.run
          {
            command         = compileCommand,
            file_pattern    = "(.*)%((.*)%) : (.*)",
            file_prefix     = ".",
            cwd             = ".",
            error_pattern   = "error",
            warning_pattern = "warning",
            on_complete     = function()            
              core.log("AMX Mod X Compiler: Compilation Complete")
            end
          }

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.