\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.

\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 IPython}
In IPython pyreadline is automatically used if available.

\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 Ctrl-s can not be used as a bound key. It seems ctrl-s does not generate key-up events in the console. This is an issue with cygwin as well.
	  \item No vi mode is implemented
  \end{itemize}


\section{Future work}
\subsection{Near term}
  \begin{itemize}
	  \item install scripts for easyinstall and distutils
	  \item Manual
  \end{itemize}

\subsection{Middle term}
  \begin{itemize}
	  \item Refactor code
	  \item Add missing functionality
	  \item Make console layer pluggable to allow more platforms
  \end{itemize}

\subsection{Long term}
  \begin{itemize}
	  \item Add more platforms
	  \item Add 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}
