Keyboard mapping

Get help with the installation and running of the Zeus IDE. Please do not post bug reports or feature requests here. When in doubt post your question here.
Post Reply
pdxguy
Posts: 2
Joined: Sat Jan 05, 2008 12:54 am

Keyboard mapping

Post by pdxguy »

I generally use ZeusEdit for writing COBOL code and less often, C code. But what I've observed is that the keyboard mappings are at the editor level. Or, another way of thinking about them is to say that the keyboard mappings are global. Example: if I map something to F11, it is mapped to F11 no matter what type of document I am dealing with.

How then can one have non-global (i.e. document type specific) keyboard mappings? I may want one set of mappings when I deal with COBOL, but a different set when I deal with C. Unless I overlooked it (quite possible), I didn't see any functions I could use to change them programatically. If there aren't any, then I would ask that that be added to the feature list.

Alternatively, it would be nice to be able to specify keyboard mappings at either level: global (editor level) or local (document type). And any mapping at the local level overrides the same mapping (if any) at the global level - for each key. In such a fashion, I could have the majority of my non-document specific mappings defined at the editor level, and the document-specific ones defined within each document.

Does this makes sense (hopefully)? Anyone else in favor of such an approach?
jussij
Site Admin
Posts: 2650
Joined: Fri Aug 13, 2004 5:10 pm

Post by jussij »

Code: Select all

How then can one have non-global (i.e. document type specific) keyboard mappings?
The only option is to write a macro and to bind the macro to the keyboard. Then using the macro_tag function you can determing the current file extension and use this information to control the flow of the macro.

For example:

Code: Select all

function key_macro()
  -- macro only works for documents
  local document = is_document()

  if document > 0 then
    local extension = string.lower(macro_tag("$Ext"))

    -- add your extensions and comments here
    if (extension == ".cob" ) then
        -- cobol file
        message("File is cobol")
    elseif ( (extension == ".c"  ) or
             (extension == ".h") ) or
             (extension == ".cpp") or
             (extension == ".hpp") then
         -- c/c++ file
        message("File is c/c++")
    else
        -- othe files
        message("File is default.")
    end
  else
    message("This macro only works for document files!")
    beep()
  end
end

key_macro() -- run the macro
I didn't see any functions I could use to change them programatically.
There is nothing in Zeus to do this other than using the macro approach shown above.

Cheers Jussi
Post Reply