aboutsummaryrefslogtreecommitdiff
path: root/modules/cpp/commands.lua
blob: f01561c40f59760b5a12c5f9a8e06e37b765a9dd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
-- Copyright 2007-2010 Mitchell mitchell<att>caladbolg.net. See LICENSE.

local textadept = _G.textadept

---
-- Commands for the cpp module.
module('_m.cpp.commands', package.seeall)

local run = _m.textadept.run
if run then
  run.compile_command.c = 'gcc -pedantic -Os -o "%(filename_noext)" %(filename)'
  run.compile_command.cpp = 'g++ -pedantic -Os -o "%(filename_noext)" %(filename)'
  run.run_command.c = '%(filedir)%(filename_noext)'
  run.run_command.cpp = '%(filedir)%(filename_noext)'
  run.error_detail.c = {
    pattern = '^(.-):(%d+): (.+)$',
    filename = 1, line = 2, message = 3
  }
end

-- C++-specific key commands.
local keys = _G.keys
if type(keys) == 'table' then
  local m_editing = _m.textadept.editing
  keys.cpp = {
    al = {
      m = { textadept.io.open,
            textadept.iconv(_HOME..'/modules/cpp/init.lua',
                            'UTF-8', _CHARSET) },
    },
    ['s\n'] = { function()
      buffer:line_end()
      buffer:add_text(';')
      buffer:new_line()
    end },
  }
end