Scite Autocompletion Information

1. Discussion on Google Group.

    http://groups.google.com/group/scintilla-interest/browse_thread/thread/8cfd7ab494c8b04c

   

wackzingo wrote:
> [snip]
> Then in main I go to create one and reference it.

> int main()
> {
>      stud one;

>      one.(As soon as I hit the dot I want it to bring up a menu of the
> variables I created in the struct)

> Is this possible?

Nope, SciTE cannot gather such dynamic information. It is
bare-bones for the most part, and caters for lots of languages,
while the Visual Studio interface is very highly optimized for a
few particular languages. So yeah, be aware that many of the more
nifty features will be missing. But experienced programmers
usually have many editor and shell windows open, so most of us are
quite happy without those features. As always, YMMV.

> The second question is can Scite use visual studios 2005 or 2008 to
> compile the code? I got it working for php but not C.

You need to configure the command.* settings accordingly, set it
in your user properties file or a per-directory properties file.

Visual Studio has an integrated C/C++ compiler. PHP code is never
compiled, unless you are using a Zend optimizer? So you are always
just editing PHP code.

To configure C/C++ settings, you need to know what the
command-line options are, then set the property files accordingly.
The other way is the old school method: just use SciTE as an
editor, and run "make" or "nmake" using a separate command line
window.

HTH,
--
Cheers,
Kein-Hong Man (esq.)
Kuala Lumpur, Malaysia

 

 

wackzingo wrote:

> So as soon as I type the dot I can hit ctrl+enter and then it would
> bring up all variables. I'm thinking that there might be a setting
> where I can make the . operator act like a first letter to all
> variables.

For this to work, SciTE would need to know what a variable is,
therefore it should compile the file with an internal compiler
(a more complicated lexer might be enough) for every supported
language. At the momoent, this isn't so.

Maybe the attached LUA file (dabbrev.lua) can help you.
It will search for all words in the current buffer that begin
with the word at the cursor and display a list of such words.
You have to type at least the first char of the
variable/function/... you want to insert.
(the list is currently unsorted)

To use dabbrev, save it to your scite directory.
You will need to download SciteExtMan and put it
in the scite directory.
Then create a file named "startup.lua" and add:
    require('extman')
    require('dabbrev')
    scite_Command 'Complete symbol (dynamic)|dabbrev|Ctrl+J'

Finally edit your SciTeUser.properties and
    ext.lua.startup.script=$(SciteDefaultHome)/startup.lua

You can modify the shortcut as you see fit.
Now open the file from your first example, type
   ln
and press Ctrl-J. "ln" should expand to lname.
If you type
   st
and press Ctrl-J, scite should display a list:
   struct
   stud

Possible improvements of dabbrev are:
    - sort list
    - search all loaded buffers for possible completions
    - search a ctags file
    - case-sensitive search
    - create the list based on current syntax context, for
      example do not include words from comments when in code
    - ...

Marko

[ dabbrev.lua 2K ]
-- encoding: UTF-8
-- Dynamic autocompletion for SciTE
-- author: Marko MahniÄ
-- created: 2007-11-19
--
-- Reads the word (tag) that is preceeding the current position
-- and collects all words in the current buffer that begin with the tag.
-- Autocomplete is then performed with the collected words.
--
-- Installation:
--    * requires extman.lua (http://lua-users.org/wiki/SciteExtMan)
--    * put the following line in your LUA startup script :
--      scite_Command 'Complete symbol (dynamic)|dabbrev|Ctrl+J'
--

require ('extman')

-- return the word that is before the cursor position
function dab_get_tag()
   local epos = editor.CurrentPos
   local ln = editor:LineFromPosition(epos)
   local lnpos = editor:PositionFromLine(ln)
   local spos = epos - 1
   while spos > lnpos and spos > 0 do
      local ch = string.char(editor.CharAt[spos])
      if not (ch == "_" or (ch >= 'a' and ch <= 'z') or (ch >= 'A' and ch <= 'Z') or (ch >= '0' and ch <= '9'))
      then
         spos = spos + 1
         break
      end
      spos = spos - 1
   end
   editor:SetSel(spos, epos)
   local tag = editor:GetSelText()
   editor:GotoPos(epos)
   return tag
end

function dabbrev()
   local tag = dab_get_tag()
   if tag == nil or tag == "" then return end

   -- find all maching words in current buffer
   local m
   local taglist = {}
   for m in editor:match("\\<"..tag.."[a-zA-Z0-9_]+", SCFIND_REGEXP, 0) do
      taglist[m.text] = 1
   end

   -- count the matches returned
   local cslist = ""
   local count = 0
   for k,v in pairs(taglist) do
      count = count + 1
      if count > 1 then break end
      cslist = k
   end

   if count == 1 and props['autocomplete.choose.single'] ~= "0" then
      -- replace the current word with the only possible expansion found
      editor.SelectionStart = editor.CurrentPos - string.len(tag)
      editor:ReplaceSel(cslist)
   else
      -- create a list of possible matches and autocomplete
      cslist = nil
      for k,v in pairs(taglist) do
         if cslist == nil then cslist = k
         else cslist = cslist.." "..k end
      end
      editor:AutoCShow(string.len(tag), cslist)
   end
end

2. SciTE Review

    http://www.php-editors.com/review/scite.htm

    * Auto-complete isn't very easy to use, and instead of only auto-completing keywords/functions it tries to match what you're typing with anything you've already typed. I just turned the auto-complete option off.

3. An trying to do auto completion via script.

    http://lua-users.org/wiki/SciteAutoCompleteAnyLanguage

posted on 2009-01-13 21:39  南柯之石  阅读(650)  评论(0编辑  收藏  举报

导航