Files
pyreadline/doc/manual_base.tex
T
2007-05-24 18:11:32 +00:00

201 lines
8.3 KiB
TeX

\documentclass[11pt,twoside,english]{article}
\usepackage{palatino}
\usepackage[T1]{fontenc}
\usepackage[latin1]{inputenc}
\usepackage{geometry}
\geometry{verbose,a4paper,tmargin=1in,bmargin=1in,lmargin=1in,rmargin=1in}
\usepackage{fancyhdr}
\pagestyle{fancy}
\setlength\parskip{\medskipamount}
\setlength\parindent{0pt}
\usepackage{color}
\IfFileExists{url.sty}{\usepackage{url}}
{\newcommand{\url}{\texttt}}
\usepackage{color}
% A few colors to replace the defaults for certain link types
\definecolor{orange}{cmyk}{0,0.4,0.8,0.2}
\definecolor{darkorange}{rgb}{.71,0.21,0.01}
\definecolor{darkred}{rgb}{.52,0.08,0.01}
\definecolor{darkgreen}{rgb}{.12,.54,.11}
% Use and configure listings package for nicely formatted code
\usepackage{listings}
\lstset{
language=Python,
basicstyle=\small\ttfamily,
commentstyle=\ttfamily\color{blue},
stringstyle=\ttfamily\color{darkorange},
showstringspaces=false,
breaklines=true,
postbreak = \space\dots
}
\usepackage[%pdftex, % needed for pdflatex
breaklinks=true, % so long urls are correctly broken across lines
colorlinks=true,
urlcolor=blue,
linkcolor=darkred,
citecolor=darkgreen,
]{hyperref}
\usepackage{html}
% This helps prevent overly long lines that stretch beyond the margins
\sloppy
% Define a \codelist command which either uses listings for latex, or
% plain verbatim for html (since latex2html doesn't understand the
% listings package).
\usepackage{verbatim}
\newcommand{\codelist}[1] {
\latex{\lstinputlisting{#1}}
\html{\verbatiminput{#1}}
}
\usepackage{babel}
\begin{document}
\title{pyreadline\\
{\Large a python implementation of GNU readline}{\large }\\
{\large User Manual, v. --version--}}
\author{Jörgen Stenarson}
\maketitle
\latex{\tableofcontents{}}
\html{\bodytext{bgcolor=#ffffff}}
\newpage
\section{Overview}
The pyreadline package is a python implementation of GNU readline. At the moment it is only available for the windows platform. The package is based on the readline package by Gary Bishop. The goal is to provide the functionality of the readline package. New features:
\begin{itemize}
\item International characters
\item Cut and paste from clipboard
\begin{description}
\item[paste] Will paste first line from clipboard (multiple lines doesn't paste well).
\item[ipython\_paste] Smart paste paths, smart paste tab delimited data as list or array.
\item[multiline\_paste] Will assume text on clipobard is python code, removes all empty lines.
\end{description}
\item Bell is disabled by default
\end{itemize}
\subsection{dependencies}
\begin{itemize}
\item ctypes
\item win32all
\end{itemize}
\subsection{Conflicts}
Unfortunately the module rlcompleter, the module that provides tab completion, imports readline which means there must be an alias from readline to pyreadline for things to work properly. This means pyreadline install a file under the name readline.py in site-packages containing:
\lstinputlisting{../readline.py}
\section{Installation}
There are a few things that are not autmatically installed. For instance the configuration file and the startup code that makes sure pyreadline is activated when running python in interactive mode.
However when using ipython pyreadline is imported by default by ipython.
\subsection{Development version}
Use {\ttfamily easy\_install pyreadline==dev} to get development version. Copy pyreadlineconfig.ini from pyreadline/configuration to your HOME directory (usually c:/documents and settings/YOURNAME)
\subsection{Current release version}
\emph{Currently no release version available.}
Use {\ttfamily easy\_install pyreadline} to get development version.
\section{Usage}
The purpose of readline is to improve the interactive experience with the python interpreter by improving the line editing facilities. The most important being tab completion and copy and paste.
\subsection{Configuration file}
The configuration file is read from the users home directory and is named pyreadlineconfig.ini. The files syntax is not the same as for GNU readline but a python syntax is used instead. The available commands are:
\begin{description}
\item[bind\_exit\_key] is used to bind the keys that are used to exit the interpreter. (Ctrl-d, ctrl-z)
\item[bind\_key] is used to bind keys to editor functions
\item[un\_bind\_key] is used to unbind keys can be useful to unbind default bindings the user does not like
\item[bell\_style] is used to set bell style. (none|visible|audible)
\item[show\_all\_if\_ambiguous] is used to enable the showing of a list of all alternative for tab completion (on|off)
\item[mark\_directories] show directories (on|off)
\item[completer\_delims] Which delimeters should be used to separate words for tab completion
\item[debug\_output] Turn on debug output (on|off). Not implemented yet.
\end{description}
Here is the example config file shipped with pyreadline:
\lstinputlisting{../pyreadline/configuration/pyreadlineconfig.ini}
\subsection{pyreadline with python interpreter}
In your startup file (pointed to by environment variable PYTHONSTARTUP) add:
\lstinputlisting{../pyreadline/configuration/startup.py}
This file is included in the doc directory of the distribution.
\subsection{pyreadline with IronPython}
Pyreadline can be used together with IronPython. Unfortunately the binary installs of IronPython can not run pyreadline directly. You need to patch the source code to make PythonCommandLine a public class that we can override.
\begin{itemize}
\item In PythonCommandLine.cs you need to change class PythonCommandLine to public class PythonCommandLine and recompile.
\item Copy rlcompleter.py from a standard python install to your ironpython path (this file is not included with fepy).
\end{itemize}
\subsection{pyreadline with IPython}
In IPython pyreadline is automatically used if available.
\subsection{Clipboard}
Pyreadline can do copy/paste using the clipboard. Selections can be done using shift and arrowkeys as in most windows programs.
There are three different paste functions that can be bound.
\begin{itemize}
\item \emph{paste} Paste windows clipboard.
Assume single line strip other lines and end of line markers and trailing spaces
\item \emph{paste_mulitline_code} Paste windows clipboard as multiline code.
Removes any empty lines in the code
\item \emph{ipython_paste} Paste windows clipboard. If enable_ipython_paste_list_of_lists is
True then try to convert tabseparated data to repr of list of lists or
repr of array. If enable_ipython_paste_for_paths==True then change \\\\ to / and spaces to \\space.
\end{itemize}
\subsection{International characters}
The pyreadline package now supports international characters. However using international characters in the interactive prompt can be annoying on windows since the default codepage for the terminal is an ascii codepage (850 on swedish systems) but the filesystem often uses some other codepage (1252 on swedish systems). This means the filenames containing internationl characters entered on interactive prompt will not work. The workaround here is to change the codepage of your terminal to a more suitable one using the {\ttfamily chcp} command. For swedish systems {\ttfamily chcp 1252} does the trick but you also have to change the terminal font to ``lucida console'' using the properties dialog for the console.
\section{Known issues}
\begin{itemize}
\item If you do not want pyreadline at the standard windows prompt. Delete readline.py
from the install directory. This will not interfere with ipython usage, but you will
not be able to use the rlcompleter module which requires the readline.py module.
\end{itemize}
\section{Future work}
\subsection{Near term}
\begin{itemize}
\item Manual
\end{itemize}
\subsection{Middle term}
\begin{itemize}
\item Add missing functionality
\end{itemize}
\subsection{Long term}
\begin{itemize}
\item Add more platforms
\item Improve vi mode
\end{itemize}
\newpage
\appendix
\section{Bindable commands}
This appendix will contain descriptions of all bindable commands. For now you have to look in the sourcecode. Check the readline class of the file rlmain.py
\end{document}