Package: kaaedit
Kaa is a small and easy CUI text editor for console/terminal emulator environments.ContentsOverviewKaa is easy!CustomizableCross platformSetupRequirementsInstallationTerminal settingKeyboard settingColor settingCommand line optionsUsageUsing menuKey bindingsReplace dialogGrep dialogPython consoleSpell checkerMakePython debuggerVi bindingCustomizationChange default color paletteCustomize editor modeFile type customization hookHackingAcknowledgmentsLinksVersion history0.54.0 - 2023.1.140.53.0 - 2016.8.80.52.0 - 2016.2.60.51.0 - 2016.2.40.50.0 - 2016.2.20.49.0 - 2016.1.160.48.0 - 2015.12.280.47.0 - 2015.12.100.46.0 - 2015.11.060.45.0 - 2015.10.27CopyrightOverviewKaa is an easy yet powerful text editor for console user interface, providing numerous features likeMacro recording.Undo/Redo.Multiple windows/frames.Syntax highlighting.Grep.Python console.Python debugger.Open source software(MIT).More to come!Seehttp://kaaedit.github.iofor more screen shots.Kaa is easy!Kaa is very easy to learn in spite of its rich functionality. Only thing you need to remember is“To display menu, hit F1 key or alt+’m’ key”. Most of basic features could be accessed from fancy menus by hitting underlined character in the menu items. You can use kaa as easy as you are with Notepad on MS-Windows.CustomizableKaa is written inPython. So, you can easily customize many aspects of kaa through simple Python scripts.Cross platformKaa is a CUI editor that runs on most of modern UN*X flavor operating systems like Linux or Mac OS X. Kaa requires Unicode friendly environment both platform running kaa and terminal emulator/console to interact with kaa.Cygwin environment on Windows platform is not supported at this time, but will be tested after they provide Python 3.3 package.SetupRequirementsTo run kaa, you need following component:Python 3.3 or laterDevelopment files for Python 3.3. For recent Debian/Ubuntu, you can install required libraries by$ sudo apt-get install python3-devIf your Python installation is not system-supplied package but built by yourself, please ensure you have installed ncurses library with wide character support before you built Python. Consult documentation of your platform for details. For recent Debian/Ubuntu, you can install required libraries by$ sudo apt-get install libncursesw5 libncurses5-dev libncursesw5-devAfter theses packages are installed, rebuild Python installation to take effect.Kaa can use system clipboard. To use clipboard on Unix platform,xclipcommand should be installed. For Ubuntu Linux, following command installsxclipcommand.$sudoapt-getinstallxclipUTF-8 locales(optional) CythonInstallationUse easy_install3 or pip3 to install kaa from PyPI$ sudo easy_install3 -U kaaeditTerminal settingKeyboard settingKaa uses alt key for keyboard shortcut likealt+k. On most of recent Windows or Linux terminal, alt key works out of box. But on Mac OS X, Terminal app should be configured:Select Preferences menu.Open the Settings tab.Open the keyboard tab.CheckUse option as meta key.Or, if you use iTerm2 on Mac, you should configure:Select Preferences menu.Open the Profiles tab.Open the Keys tab.CheckLeft option Key acts as: +Esc.andRight option Key acts as: +Esc.button.If you use Gnome terminal and wishes to access menu by F1 key, you should configure:Select Edit | Keyboard shortcuts menu.Scroll to the Help/Contents shortcut and change key from F1 to some another key.Color settingKaa looks better with 256 color mode of terminal emulator. For Terminal.app on Mac OS X, you can set 256 color mode with following procedure:Select Preferences menu.Open the Settings tab.Selectxterm-256colorfor“Declare terminal as”field.For iTerm2, you can set 256 color mode with following procedure:Select Preferences menu.Open the Profiles tab.Open the Terminal tab.Selectxterm-256colorfor“Report terminal type”field.Otherwise, you should manually update terminal setting. e.g., If you use bash, add following line to~/.bashrcfile:$exportTERM=xterm-256colorFor detail, seehttp://www.pixelbeat.org/docs/terminal_colours/#256to enable 256 color on your terminal.Command line optionskaa [-h] [--version] [--no-init] [--init-script INIT_SCRIPT]
    [--palette PALETTE] [--term TERM] [file [file ...]]-h,--helpshow this help message and exit--versionshow version info and exit--no-initskip loading initialization script--init-scriptINIT_SCRIPTexecute file as initialization script instead of default initialization file--palettePALETTEcolor palette. available values: dark, light.--termTERM,-tTERMspecify terminal type--commandcommand,-xcommandspefify kaa command id to execute at start-up e.g: kaa -x python.console / kaa -x tools.grepUsageUsing kaa is intuitive. Typing alphabet keys will update file as you expected. Functional keys like arrow or delete keys also works.Using menuTo display menu, type F1 key or alt+m (type ‘m’ key with alt key). Each items in the menu has one underlined character. The menu item is executed by typing the underlined key with or without pressing alt key.Typing escape key hides menu.File menuNewCreate new file.OpenOpen existing file.File infoShow file information. Also update per file
settings of tab or indentation.View DiffShow difference between original file and current
buffer.SaveSave current file.Save AsSave current file as new file.CloseClose current frame.Save allSave all current files.Close allClose all frames.[Recently]Show recently used files menu.QuitTerminate kaa.Recently used files menuRecently used filesShow list of recently used files.Recently used dirsShow list of recently used directories.Edit menuCutCut selected text.CopyCopy selected text.PastePaste from clipboard.Paste HistoryPaste from clipboard history.UndoUndo last modification.RedoRedo last undo.SearchSearch text.ReplaceReplace text.CompleteWord completion.[Convert]Show text convert menu.Text convert menuUpperConvert selected text to upper case.LowerConvert selected text to lower case.NormalizationConvert selected text to Unicode Normalization
Forms(NFKC).Full-widthConvert alphabet and numbers in the selected text
to full-width character.Code menuCode menu differs among file types. Following items are typical in programming languages.CommentInsert line comment character at top of lines in
selected region.UncommentDelete line comment character at top of lines in
selected region.Table of
contentsShow table of contents to move cursor.Macro menuStart recordStart macro recording.End recordEnd macro recording.Run macroRun last macro.Tools menuGrepSearch text from disk.Paste linesInsert lines of text without auto indentation.Shell commandExecute external shell command and insert the
output.MakeRunmaketo compile source files and capture
error  messages. Use f9/10 key to traverse errors.Spell checkerRun English spell checker.Python consoleStart python console.Python debuggerStart Python debugger.Python debugger
serverWait for external debugger connection.Window menuFrame listShow list of frame windows. Use left/right
arrow key to change active frame.Split vertSplit current window vertically.Split horzSplit current window horizontally.Move separatorMove window separator. Use left/right arrow key
to move separator.Next windowActivate next window.Prev windowActivate previous window.Join windowJoin split window.[Switch file]Show switch window menu.Switch file menuSwitch fileSwitch content of active window.New file hereCreate new file to active window.open file hereOpen existing file to active window.Recently used filesShow list of recently used files.Recently used dirsShow list of recently used directories.Key bindingsMenu keysF1, alt+mShow menu.Alt-wShow switch file menu.Cursor keysleft, Control+bCursor left.right, Control+fCursor right.upCursor up.downCursor down.Control+pMove cursor to previous physical line.Control+nMove cursor to next physical line.Control+left,
Alt+bMove cursor to previous word boundary.Control+right,
Alt+fMove cursor to next word boundary.Alt+p, Page upPrevious page.Alt+n, Page downNext page.Control+a, HomeMove cursor to top of line.Control+^Move cursor to first letter of line.Control+e, EndMove cursor to end of line.Alt+<, Control+HomeMove cursor to top of file.Alt+>, Control+EndMove cursor to end of file.Control+gGo to line number.Control+tTable of contents.Text selectionShift+leftSelect to previous character.Shift+rightSelect to next character.Shift+upSelect to previous line.Shift+downSelect to next line.Shift+HomeSelect text to top of line.Shift+EndSelect text to end of line.Control+Shift+HomeSelects text to top of file.Control+Shift+EndSelect text to end of file.Control+Space,
Control+@Set mark to select text region.Alt+#Set mark to select text rectangularly.Alt+aSelect all text.Alt+cSelect current word at first press. Subsequent
press selects entire current line, and the
third press selects entire textText deletionBackspace,
Control+hDelete the character to the left.Delete,
Control+dDelete the character at the cursor.Control+backspace,
Alt+hDelete the word to the left.Control+Delete,
Alt+dDelete the word to the right.Control+kDelete the line to the right.Alt+kDelete the current line.ClipboardControl+vPaste from clipboard.Control+xCut selection.Control+cCopy selection.Alt+vPaste from clipboard history.Undo/RedoControl+zUndo last change.Control+yRedo last undo.Search/ReplaceControl+sSearch text.Alt+sReplace text.F2Search prev.F3Search next.OtherF6Toggle macro recording on/off.F5Run macro.Alt+.Run last executed edit command again.TabIndent selected lines.Shift+TabDedent selected lines.Control+oWord completion.Control+u Alt+!Execute command and insert the output.Alt+zSuspend kaa and back to shell.Replace dialogWhenregexbutton is checked,Replacestring is also regular expression string. In this case, special characters like\tor\nare converted to tab character and newline character. Also, back-reference character will be replaced to sub-string matched group in the search string. For example, when search string is‘(a+)(b+)’and replace string is‘\2\1’,  matched string‘aabb’will be replaced to‘bbaa’.Grep dialogGrep dialog has three input field.Searchis a plain text or regular expression string to search.Directoryis a directory to start searching. IfTreebutton was checked, files are searched recursively.Filenamesis space separated list of file spec in shell-style wild-cards (e.g.,*.txt *.py *.doc). Up arrow key displays history of each input field.In the grep result window, use F9 and F10 key to traverse matches forward/backward.Python consoleYou can type Python script as normal Python interpreter. To execute script, you should hit enter key at very last of the script. Otherwise, newline character is inserted as text editor. You can move cursor upper or below to edit multiline script.To show script history window, hit alt+Enter key on the console.Spell checkerTo use spell checker,PyEnchantmodule should be installed.On MAC OS-X installenchantwith homebrew before installing PyEnchant.$brewinstallenchant$pip-3.3installPyEnchantMake[Tools]|Makeexecutesmakecommand to build your files. You can alter command and options to build. To retrieve previous command and options, hit up cursor key to display history window.Output ofmakedisplayed on the window. You can traverse source files cause of the error forth and back with f9 and f10 key.Python debuggerWarningPython debugger is experimental at this point.Kaa can be used as front-end of Python debugger module(bdb) running in another process. Although kaa itself requires Python 3.3 or later, you can use Python 2.6 or later in the target process.Starting debuggerThere are three ways to start debugger.kaadbg.run moduleKaadbgpackage executes your Python script with Python debugger connected to debugger window of kaa. Usually,kaadbgis Python package installed as a part of kaa. To use another Python interpreter than kaa installed, you can installkaadbgseparately.$ sudo pip install -U kaadbgCurrently,kaadbgsupports from Python 2.6 to Python 3.x.To activate kaa remote debugger, select[Tools]|Pythondebugger serverand enter port number to connect debugger(default 28110).Next, open new terminal window and run following command in the terminal window.$ python -m kaadbg.run my_test_stript.py arg1 argsIf you need use other port than28110, you should provide port number with-poption.$ python -m kaadbg.run -p 29000 my_test_stript.py arg1 argsset_traceLike Python’s standardpdbmodule, you can importkaadbgpackage and callset_trace()to start debug session.You should start activate kaa remote debugger by menu[Tools]|Pythondebugger serverand enter port number to connect debugger(default 28110).To connect kaa remote debugger, open your target script and insert following lines of code.importkaadbg.debugkaadbg.debug.set_trace()If you need use other port than28110, you should provide port number toset_trace().importkaadbg.debugkaadbg.debug.set_trace(29000)Now you can start your target script. Kaa remote debugger will be opened whenkaadbg.debug.set_trace()is hit.Run child processYou can run your target script as child process of kaa to debug.To start child process, select[Tools]|Pythondebuggerin kaa menu and specify command line as follow.python2.7 -m kaadbg.run myscript.py arg1 arg2Command line should starts with Python interpreter you use and-mkaadbg.run. Name of target script and arguments follows.Note that kaa doesn’t capture standard output and standard error of target process, so you cannot see outputs of the target script. Also, standard input of the target process is closed just after command started.BreakpointsTo set/unset breakpoints, select[Code]|ToggleBreakpointin menu in editor. By default,f8key is bounded to this menu item.While debugger window is opened, you can suspend the debugger window by escape key. After you finish to update breakpoints in editor window, select[Tools]|Pythondebuggermenu again to resume debugger. To view list of current breakpoints, selectbreakpointsbutton withalt+Ekey.Inspect variablesTo see value of variables, selectExpron the debugger window by pressingalt+Ekey and enter Python expression you want to inspect likeself.spam.Vi bindingWarningPython debugger is experimental at this point.Kaa currentry supports some basic vi-like key bindings, but are disabled by default. To activate vi bindings, create~/.kaa/__kaa__.pyfile with following lines.fromkaa.filetype.default.defaultmodeimportDefaultModeDefaultMode.VI_COMMAND_MODE=TrueCommand modeUnlike vi, kaa is in insert-mode at start up. Hit escape key to move to command mode.mode commandsiInsert mode.RReplace mode.AAppend text after the end of line.vCharacterwise visual mode.VLinewise visual mode.cursor commandshCursor right.lCursor left.kCursor up.jCursor down.wCursor word right.bCursor word left.0Cursor to top of line.^Cursor to first character of line.$Cursor to end of line.ggCursor to top of file.GCursor to end of file.Control+bPage up.Control+fPage down.Edit commandsrReplace a character.xDelete a character.dDelete to next move.uUndo last edit.Control+rRedo last undo.yCopy selection.CustomizationKaa executes a Python script file at~/.kaa/__kaa__.pyon start up. You can write Python script to customize kaa as you like.Change default color paletteTo change default color palette, you can modify kaa.app.DEFAULT_PALETTE.importkaakaa.app.DEFAULT_PALETTE='light'# Use `light' palette. Default is `dark'Customize editor modeEach file type has file editor mode.kaa.filetype.default import defaultmodeis base class of all text file modes. You can change attributes of filetype classes.Show line numbersTo show line number in editor screen, you can updateSHOW_LINENOattribute of file mode classes.fromkaa.filetype.defaultimportdefaultmodedefaultmode.DefaultMode.SHOW_LINENO=TrueTo show line number in HTML mode, you should change attribute of htmlmode.HTMLMode class.# Show line number in HTML modefromkaa.filetype.htmlimporthtmlmodehtmlmode.HTMLMode.SHOW_LINENO=TrueFile type customization hookEach mode object calls setup function to customize.kaa.addon.setup()decorator registers setup function.setup(filemode='kaa.filetype.default.defaultmode.DefaultMode')Setup function is called when mode object is created. In the setup function, you can customize various aspect of file type object.Customize keybindmode.add_keybinds()method registers custom key bind.add_keybinds(self,editmode='input',keys=None):editmodeis a name of editmode which should be one ofinput,command,visualorvisualline.keymapis a dictionary of keybind and command name.Following example assignControl+x 2key to split window as Emacs.fromkaa.addonimport*@setup('kaa.filetype.default.defaultmode.DefaultMode')defmy_keybind(mode):mode.add_keybinds(keys={((ctrl,'x'),'2'):'editor.splithorz'# Assign C-x 2 to split window.})Create custom commandkaa.command.commandid()decorator declare a function as kaa’s editor command.commandid(commandid)commandidis a unique command name in string.Command functions can be registered to mode objects.To register commands to mode, useadd_command()method.add_command(command)commandis a command function.fromkaa.addonimport*# sample command to insert text at the top of file.@commandid('test.command')deftestcommand(wnd):wnd.cursor.setpos(0)wnd.document.mode.put_string(wnd,'sample text\n')@setup('kaa.filetype.default.defaultmode.DefaultMode')defcommand_sample(mode):# register command to the modemode.add_command(testcommand)# add key bind th execute 'test.command'mode.add_keybinds(keys={(alt,'1'):'test.command'# Assign alt-1 to test.command})Change color themeFunctionmode.add_theme()could be used to customize color theme.defadd_theme(theme)themeis a dictionary of theme name and list of styles. Currently, the only valid theme name isbasic.@setup('kaa.filetype.default.defaultmode.DefaultMode')deftheme_sample(mode):# update foreground color of comments to red.mode.add_theme({'basic':[Style('default','red',None),]}HackingYou can get the recent source code fromgithub.$gitclonehttps://github.com/kaaedit/kaa.gitTo run test, you need to installpy.test$pip-3.3install-Upytest$cdkaa$py.testThere is an experimental script to run freeze to build standalone kaa binary file.
To freeze kaa,  You must proceed with the following steps:Apply following two patches to your Python 3.3 installation.http://bugs.python.org/issue11824http://bugs.python.org/issue16047Clone kaa source code.$gitclonehttps://github.com/kaaedit/kaa.gitIn source directory of kaa, cd to kaa/freezing directory.$cdkaa/freezingEdit PYTHON variable in build.sh for your environment.run build.sh$./build.shCheck if freezing/dist/kaa exists.AcknowledgmentsI really appreciate for your help.Allan ClarkLinksGithub project pageGithub repositoryPython Package Index(PyPI)Twitter account to notify new releasesVersion history0.54.0 - 2023.1.14Support Python 3.100.53.0 - 2016.8.8Display git log.Display unmerged diffs in git status screen.Fix clipboard error in Linux.Autocomplete around puctuation now works better.0.52.0 - 2016.2.6Display result of git commit command.Stage/unstage in no-commit repogitory now works.0.51.0 - 2016.2.4git status doesn’t work if git has no commit.Stop Emacs-style set-mark command to clear ongoing-selection.Normalize Short-key of menu items. Now you can use double-width-F letter to open File menu.0.50.0 - 2016.2.2Add git support.[Markdown] Recognize nested lists.0.49.0 - 2016.1.16[CSS] Improve syntax highlight.Deprecate old addon functions. Use kaa.addon.setup() instead.Add suspend command to send kaa to the background. Bound toalt-Zkey by default.0.48.0 - 2015.12.28Pasting long text to Python console was failed.[CSS] Highlight real number without preceding digits.Fix bug if diaog size is greater than screen size.0.47.0 - 2015.12.10Range of word in word completion is fixed.Use X11 clipboard only if environment variableDISPLAYis provided.Fix bug if diaog size is greater than screen size.0.46.0 - 2015.11.06Cursor word-right/left now skips white-space.Initial directory of file-open dialog is same directory as file now active.Various highlighting bugs.0.45.0 - 2015.10.27Handle terminal resize in Python 3.5.Reworked syntax highligh.[CSS mode] Highlight @media rules.CopyrightCopyright (c) 2013 - 2016 Atsuo IshimotoPermission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the “Software”), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.