platform/upstream/kmscon.git
12 years agoinput: fix log-messages
David Herrmann [Sat, 24 Mar 2012 12:19:02 +0000 (13:19 +0100)]
input: fix log-messages

Remove newline from log-messages and set LOG_SUBSYSTEM to "input". Also
fix some small indentation issues.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
12 years agoconf: add --xkb-XY options
David Herrmann [Sat, 24 Mar 2012 12:02:48 +0000 (13:02 +0100)]
conf: add --xkb-XY options

Allow setting XKB options on the command line.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
12 years agoinput: do not wake up if we are not asleep
David Herrmann [Sat, 24 Mar 2012 11:27:25 +0000 (12:27 +0100)]
input: do not wake up if we are not asleep

Check for state == INPUT_AWAKE before performing wakeup.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
12 years agoconf: add --silent
David Herrmann [Fri, 23 Mar 2012 17:38:24 +0000 (18:38 +0100)]
conf: add --silent

Suppress debug, info, notice and warning messages if --silent is given.
This is overwritten by --debug and --verbose.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
12 years agomain: print strerror() on failure
David Herrmann [Fri, 23 Mar 2012 17:33:08 +0000 (18:33 +0100)]
main: print strerror() on failure

Print error-string if we cannot initialize kmscon.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
12 years agomain: add proper main application
David Herrmann [Fri, 23 Mar 2012 17:29:21 +0000 (18:29 +0100)]
main: add proper main application

This is not finished and only implements the basic VT handling +
application initialization.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
12 years agovt: fix log messages
David Herrmann [Fri, 23 Mar 2012 17:29:01 +0000 (18:29 +0100)]
vt: fix log messages

Add new improved log messages to the VT subsystem.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
12 years agoFix time calculations
David Herrmann [Fri, 23 Mar 2012 17:27:29 +0000 (18:27 +0100)]
Fix time calculations

eloop.c and log.c use struct timeval to calculate time-diffs but
incorrectly use "-" instead of "+" as the value is already negative.
They also use unsigned integers so fix both occurences.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
12 years agobuild: add conf.c to build
David Herrmann [Fri, 23 Mar 2012 17:26:50 +0000 (18:26 +0100)]
build: add conf.c to build

conf.c was recently added so add it to the build-script now.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
12 years agoeloop: correctly set ->exit
David Herrmann [Fri, 23 Mar 2012 16:58:19 +0000 (17:58 +0100)]
eloop: correctly set ->exit

When exiting a child eloop we should forward the exit to the parent. Also,
we should reset ->exit on ev_eloop_run() otherwise we cannot run multiple
times.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
12 years agoeloop: add debug messages
David Herrmann [Fri, 23 Mar 2012 16:57:53 +0000 (17:57 +0100)]
eloop: add debug messages

Add two debug messages to track eloop behavior.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
12 years agoconf: add --switchvt
David Herrmann [Fri, 23 Mar 2012 16:42:39 +0000 (17:42 +0100)]
conf: add --switchvt

--switchvt enables kmscon to automatically switch to the new VT that was
opened by kmscon. If this is the current VT, then this has obviously no
effect.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
12 years agoconf: fix --help handling
David Herrmann [Fri, 23 Mar 2012 16:41:52 +0000 (17:41 +0100)]
conf: fix --help handling

Handle --help same way as -h.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
12 years agoconf: remove unneeded global initialization
David Herrmann [Fri, 23 Mar 2012 16:40:56 +0000 (17:40 +0100)]
conf: remove unneeded global initialization

Global variables are initialized to 0 automatically. So remove the
initialization.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
12 years agoeloop: add ev_eloop_run() function
David Herrmann [Fri, 23 Mar 2012 16:32:45 +0000 (17:32 +0100)]
eloop: add ev_eloop_run() function

ev_eloop_run() runs the eloop for a given fixed time. If the dispatcher
returns and the timeout isn't reached, then the dispatcher is called
again.
This also adds the *_exit() function which allows to exit the main-loop
and can be called from anywhere (including the callbacks).

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
12 years agoeloop: several fixes
David Herrmann [Fri, 23 Mar 2012 16:13:01 +0000 (17:13 +0100)]
eloop: several fixes

Fix parameter validation, fix log_* statements, fix indentation and print
messages on HUP/ERR.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
12 years agoeloop: remove fd from epoll-set on HUP
David Herrmann [Fri, 23 Mar 2012 15:59:42 +0000 (16:59 +0100)]
eloop: remove fd from epoll-set on HUP

If a handler does not correctly remove itself on HUP, the epoll-loop will
never sleep again because the fd will always be notified as HUP.
Therefore, remove the fd from the epoll-set directly on HUP. This doesn't
change application behavior so it is safe here.

This also allows other subsystems to ignore HUP/ERR events if they are not
fatal. The FD won't be readded but that may not bother.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
12 years agoeloop: remove ev_eloop_get_fd()
David Herrmann [Fri, 23 Mar 2012 15:46:22 +0000 (16:46 +0100)]
eloop: remove ev_eloop_get_fd()

This function was never used so remove it.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
12 years agovt: fix callback enum type
David Herrmann [Fri, 23 Mar 2012 15:42:04 +0000 (16:42 +0100)]
vt: fix callback enum type

We should use the enum type instead of plain "int" to be more verbose
here.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
12 years agoconf: add configuration subsystem
David Herrmann [Fri, 23 Mar 2012 15:13:50 +0000 (16:13 +0100)]
conf: add configuration subsystem

The conf-subsystem is used throughout the whole source and provides a
global static read-only configuration. The configuration is read on
startup from the command-line and filesystem and then provided to the
other subsystems.

This is no database, that is, the data is not written to a file on
shutdown!

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
12 years agoeloop: allow an eloop to be an event source
David Herrmann [Fri, 23 Mar 2012 15:10:53 +0000 (16:10 +0100)]
eloop: allow an eloop to be an event source

This allows to add one eloop object into another eloop. This is useful if
we want to run a single event source isolated (for instance VT on exit).

The internal epoll-descriptor allows polling so this is a fairly
straightforward implementation.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
12 years agoconsole: merge console_cell.c into console.c
David Herrmann [Fri, 23 Mar 2012 13:34:55 +0000 (14:34 +0100)]
console: merge console_cell.c into console.c

We currently have too much layers in the console subsystem. This reduces
performance and produces ugly hacks like our "*_clear_region" function. We
now merge both files so we can directly access the buffer-structure.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
12 years agoRemove old output subsystem
David Herrmann [Fri, 23 Mar 2012 13:29:25 +0000 (14:29 +0100)]
Remove old output subsystem

This subsystem is no longer used so remove it.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
12 years agoMove to new uterm infrastructure
David Herrmann [Fri, 23 Mar 2012 13:18:50 +0000 (14:18 +0100)]
Move to new uterm infrastructure

This fixes all compositor/output/context/etc. uses and replaces them by
the new uterm API.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
12 years agogl: add viewport helper
David Herrmann [Fri, 23 Mar 2012 13:18:28 +0000 (14:18 +0100)]
gl: add viewport helper

This helper correctly sets the viewport to the size of a screen.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
12 years agotest_output: use new uterm/log/etc. subsystems
David Herrmann [Fri, 23 Mar 2012 12:35:02 +0000 (13:35 +0100)]
test_output: use new uterm/log/etc. subsystems

Convert the test_output test to use the new subsystems.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
12 years agouterm_video: add *_screen_height/width() helpers
David Herrmann [Fri, 23 Mar 2012 12:34:20 +0000 (13:34 +0100)]
uterm_video: add *_screen_height/width() helpers

A screen may have a different size than the displays so add these two
hooks.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
12 years agobuild: define LOG_ENABLE_DEBUG if debugging
David Herrmann [Fri, 23 Mar 2012 12:30:36 +0000 (13:30 +0100)]
build: define LOG_ENABLE_DEBUG if debugging

Define LOG_ENABLE_DEBUG if we enabled debugging. The log subsystem uses
this to enable the log_debug() statements.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
12 years agogl: add debug statements
David Herrmann [Fri, 23 Mar 2012 12:30:05 +0000 (13:30 +0100)]
gl: add debug statements

Add messages about new shader objects.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
12 years agouterm_video: take ref-cnt of display in screen object
David Herrmann [Fri, 23 Mar 2012 11:53:59 +0000 (12:53 +0100)]
uterm_video: take ref-cnt of display in screen object

Inside a screen object we are independent of the lifetime of the displays
so we need to correctly keep references to them.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
12 years agogl: add GL subsystem
David Herrmann [Fri, 23 Mar 2012 11:50:35 +0000 (12:50 +0100)]
gl: add GL subsystem

The GL subsystem is copied from the old output_context subsystem and now
provides shader and GL-math. It will replace the old output_context subs
soon.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
12 years agouterm_video: include GLES2 headers instead of GL
David Herrmann [Fri, 23 Mar 2012 10:49:17 +0000 (11:49 +0100)]
uterm_video: include GLES2 headers instead of GL

We use GLES2 for drawing. There is currently no reason to provide full GL
inside kmscon as we use the basic operations only.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
12 years agouterm_video: add dummy fbdev backend
David Herrmann [Fri, 23 Mar 2012 10:46:39 +0000 (11:46 +0100)]
uterm_video: add dummy fbdev backend

The fbdev backend is non-functional, but we add it for documentational
purposes. It is not built as part of kmscon.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
12 years agouterm_video: add DRM backend
David Herrmann [Fri, 23 Mar 2012 10:45:49 +0000 (11:45 +0100)]
uterm_video: add DRM backend

uterm_video can work with any backend so we need a DRM backend to get the
same functionality as our previous compositor/output API.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
12 years agouterm: new video backend
David Herrmann [Fri, 23 Mar 2012 10:26:04 +0000 (11:26 +0100)]
uterm: new video backend

Our old backend was hacked together and hadn't have any structure. This is
a new approach to create the uterm-library inside kmscon. The
uterm-library will contain everything that is needed to run an application
on Linux DRM devices without X11 or Wayland support.

The idea is to move the input subsystem to uterm, too. No other stuff is
currently planned to be included in uterm.

Although uterm is supposed to be a separate library, we do not build it as
such library. We currently include the log-subsystem and the
eloop-handlers in the library so we cannot build it as stand-alone
library. However, we try to keep it separate so if we ever need to export
it, then it should be a one-hour job to do it so.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
12 years agolog: rewrite log subsystem
David Herrmann [Fri, 23 Mar 2012 10:11:46 +0000 (11:11 +0100)]
log: rewrite log subsystem

The new logger is much more powerful, allows online log-filter
modifications and precise debugging. We still avoid heavy file-operations
as we rely on the caller to forward stderr to a log-file and perform
log-rotations. However, we now provide a simple way to perform this
forward inside the application.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
12 years agoeloop: move prefix to "ev_" instead of "kmscon_"
David Herrmann [Tue, 20 Mar 2012 18:08:29 +0000 (19:08 +0100)]
eloop: move prefix to "ev_" instead of "kmscon_"

The long "kmscon_" prefix is horrible so move everything to "ev_" now.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
12 years agoeloop: rename from kmscon_ to ev_
David Herrmann [Thu, 15 Mar 2012 19:06:19 +0000 (20:06 +0100)]
eloop: rename from kmscon_ to ev_

We don't need the long kmscon_ prefix so make it shorter.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
12 years agovte: constify global tables
Ran Benita [Sun, 4 Mar 2012 17:06:34 +0000 (19:06 +0200)]
vte: constify global tables

Signed-off-by: Ran Benita <ran234@gmail.com>
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
12 years agoinput: test for LED feature and use it
Ran Benita [Fri, 20 Jan 2012 17:07:00 +0000 (19:07 +0200)]
input: test for LED feature and use it

Add probing for LEDs in the input devices, and move the ioctl for the
LEDs state from the keyboard backends to the input subsystem itself
(thus not exposing the device's file descriptor unnecessarily).

Signed-off-by: Ran Benita <ran234@gmail.com>
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
12 years agoinput: add features mechanism
Ran Benita [Sun, 4 Mar 2012 16:43:19 +0000 (18:43 +0200)]
input: add features mechanism

This commit discards the simplistic udev check for the ID_KEYBOARD
property in favor of a more direct "feature" probing. This is done for
the following reasons:

- We will need to use input devices which are not necessarily keyboards,
  for example the PC speaker to sound the bell.

- To differentiate between keyboard with certain capabilities, such as
  LEDs (indicators). We can then perform actions on devices according to
  their feature bits.

- We check directly for what we need, i.e. the ability to send/receive
  certain evdev events, without relying on logic in udev. This also
  reduces our dependency on udev if we ever want to make it optional.

Signed-off-by: Ran Benita <ran234@gmail.com>
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
12 years agobuild: implicitly include config.h
Ran Benita [Sun, 4 Mar 2012 16:38:54 +0000 (18:38 +0200)]
build: implicitly include config.h

config.h is meant to be around in all files, as it contains stuff like
_GNU_SOURCE, NDEBUG and HAVE_*.

Make these definitions available without needing to #include config.h
every single time.

Signed-off-by: Ran Benita <ran234@gmail.com>
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
12 years agoFix copyright year
David Herrmann [Fri, 2 Mar 2012 10:19:50 +0000 (11:19 +0100)]
Fix copyright year

Add 2012 to copyright and remove University of Tuebingen from new files as
copyright holder. It will still remain in the old files, though.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
12 years agovte: improve docs
David Herrmann [Thu, 1 Mar 2012 10:37:27 +0000 (11:37 +0100)]
vte: improve docs

Add parser-links to the docs and add summary comment to the vte.c source file.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
12 years agovte: add 8bit C1 7bit equivalents (dummy)
David Herrmann [Wed, 29 Feb 2012 16:21:53 +0000 (17:21 +0100)]
vte: add 8bit C1 7bit equivalents (dummy)

Many 8bit C1 codes have 7bit escape sequences as equivalents. This adds handlers
for all of them with comments what they are supposed to do. They are dummies for
now but they will be implemented later.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
12 years agovte: add 8-bit C1 code handlers (dummy)
David Herrmann [Wed, 29 Feb 2012 16:11:25 +0000 (17:11 +0100)]
vte: add 8-bit C1 code handlers (dummy)

Add handlers for C1 codes with a description what they are supposed to do. They
are not yet implemented and are no-ops.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
12 years agovte: new state machine implementation
David Herrmann [Wed, 29 Feb 2012 14:25:53 +0000 (15:25 +0100)]
vte: new state machine implementation

This is now a fully vt500-series compliant state machine that parses escape
sequences. See vt100.net/emu for information on this state-machine. This is
written from scratch, though.

It now handles all kind of escape sequences that we every want to support. It
correctly ignores all unsupported ones right now.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
12 years agokbd_xkb: use new xkbcommon version
David Herrmann [Mon, 27 Feb 2012 16:49:15 +0000 (17:49 +0100)]
kbd_xkb: use new xkbcommon version

The header file moved and the xkb_keycode_t type was introduced.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
12 years agooutput: drop drm-master on open() to avoid Xserver bugs
David Herrmann [Sun, 5 Feb 2012 17:40:31 +0000 (18:40 +0100)]
output: drop drm-master on open() to avoid Xserver bugs

The xserver currently crashes if we switch to its VT and it cannot claim
drm-master. This normally does not happen as we drop drm-master on
VT-leave. However, after calling open() on the drm char-dev we are
automatically drm-master so we should drop it right away as our VT is
not guaranteed to be opened at this time.

There is currently no way to call open() on the drm char-dev without
getting drm-master so there is still a short time-period when we have no
active VT but are drm-master. Switching to X in this short time-period
will still kill the X-server but we are not responsible for horrible
X-server bugs so we ignore this 10ms time-span.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
12 years agovte: extend CSI debug message
David Herrmann [Sun, 5 Feb 2012 15:03:13 +0000 (16:03 +0100)]
vte: extend CSI debug message

Print the CSI command in debug messages so we can better understand what
escape commands were sent.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
12 years agovte: implement backspace control
David Herrmann [Sun, 5 Feb 2012 15:02:21 +0000 (16:02 +0100)]
vte: implement backspace control

Add new helper to console subsystem which performs a backspace
operation. We must take care of auto-wrap mode so we cannot simply use
the *_move_left() function.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
12 years agovte: implement basic cursor movement CSI
David Herrmann [Sun, 5 Feb 2012 15:01:12 +0000 (16:01 +0100)]
vte: implement basic cursor movement CSI

The A, B, C and D CSIs are used to move the cursor in the scroll-region
without scrolling the buffer when reaching the margins.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
12 years agovte: implement CSI-J
David Herrmann [Sun, 5 Feb 2012 14:55:22 +0000 (15:55 +0100)]
vte: implement CSI-J

The J CSI is used to erase parts of the screen.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
12 years agovte: implement CSI-K
David Herrmann [Sun, 5 Feb 2012 14:52:34 +0000 (15:52 +0100)]
vte: implement CSI-K

The K CSI is used to erase parts of the current line.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
12 years agovte: implement basic cursor-movement controls
David Herrmann [Sun, 5 Feb 2012 14:45:43 +0000 (15:45 +0100)]
vte: implement basic cursor-movement controls

This adds support for line-feed and carriage-return controls. The two
special line-feed controls which are not \n do not take care NL-mode so
they must be handled separately.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
12 years agoconsole: fix bug in buffer-erase helper
David Herrmann [Sun, 5 Feb 2012 14:44:20 +0000 (15:44 +0100)]
console: fix bug in buffer-erase helper

We didn't check for NULL line so we got segfaults when erasing empty
lines. Fix this.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
12 years agoconsole: add helper to erase current position
David Herrmann [Sun, 5 Feb 2012 14:14:45 +0000 (15:14 +0100)]
console: add helper to erase current position

This helper erases the current cursor position.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
12 years agoconsole: fix pending-wrap bug in erase helpers
David Herrmann [Sun, 5 Feb 2012 14:11:34 +0000 (15:11 +0100)]
console: fix pending-wrap bug in erase helpers

When erasing from the cursor position to line/screen end we must include
the current cursor position in the clear-region. We already did this but
missed the fact that there might be a pending-wrap so we might miss the
current position. Fix this.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
12 years agoconsole: enable auto_wrap by default
David Herrmann [Sun, 5 Feb 2012 14:10:12 +0000 (15:10 +0100)]
console: enable auto_wrap by default

vt100 have auto_wrap enabled by default so we should do so, too.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
12 years agoconsole: fix bug in *_erase_screen()
David Herrmann [Sun, 5 Feb 2012 14:06:06 +0000 (15:06 +0100)]
console: fix bug in *_erase_screen()

We must erase the whole screen and not only until the current cursor
position. Probably a copy-paste typo.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
12 years agoconsole: fix bug in *_move_left()
David Herrmann [Sun, 5 Feb 2012 14:04:43 +0000 (15:04 +0100)]
console: fix bug in *_move_left()

We must take care of pending-wraps when moving left so we do not miss a
single character.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
12 years agoconsole: add to line movement helpers
David Herrmann [Sun, 5 Feb 2012 13:36:32 +0000 (14:36 +0100)]
console: add to line movement helpers

Add two helpers to move to the end or home of the current line.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
12 years agoconsole: add erase-helpers
David Herrmann [Sat, 4 Feb 2012 17:31:10 +0000 (18:31 +0100)]
console: add erase-helpers

Add functions to erase several parts of the screen.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
12 years agoring: fix is_empty
Ran Benita [Sat, 4 Feb 2012 13:19:33 +0000 (15:19 +0200)]
ring: fix is_empty

Signed-off-by: Ran Benita <ran234@gmail.com>
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
12 years agoconsole: add function to erase buffer
David Herrmann [Sat, 4 Feb 2012 15:24:01 +0000 (16:24 +0100)]
console: add function to erase buffer

New function which helps erasing a whole region of the buffer.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
12 years agoconsole: add basic cursor movements
David Herrmann [Sat, 4 Feb 2012 14:50:03 +0000 (15:50 +0100)]
console: add basic cursor movements

Add functions to move the cursor up/down/left/right. We must take care
of integer overflows here as the application may send us arbitrarily big
numbers.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
12 years agoconsole: add auto-wrap mode
David Herrmann [Sat, 4 Feb 2012 14:49:14 +0000 (15:49 +0100)]
console: add auto-wrap mode

If auto-wrap mode is enabled we automatically advance the cursor to the
next line if we hit the end of line. Otherwise, we simply continue
overwriting the last character in the line.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
12 years agoconsole: add *_move_to() function
David Herrmann [Sat, 4 Feb 2012 14:25:44 +0000 (15:25 +0100)]
console: add *_move_to() function

*_move_to() can be used to position the pointer at an arbitrary position
inside the buffer. If in relative-addressing mode, you cannot position
it outside the scroll-region, though.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
12 years agoconsole: make console wrapper margin aware
David Herrmann [Sat, 4 Feb 2012 13:49:06 +0000 (14:49 +0100)]
console: make console wrapper margin aware

Keep reference to top-most and bottom-most line of scroll buffer in
console wrapper. The margin_top and margin_bottom indexes are different
from them used in the buffer handler! We use indexes now instead of line
counts. This makes the handling much easier.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
12 years agoconsole: remove *_buffer_newline()
David Herrmann [Sat, 4 Feb 2012 13:34:33 +0000 (14:34 +0100)]
console: remove *_buffer_newline()

This function is no longer needed as we now have proper scrolling
functions. This also adjusts the buffer tests to be more appropriate.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
12 years agoconsole: fix bug in console resizing
David Herrmann [Sat, 4 Feb 2012 13:32:09 +0000 (14:32 +0100)]
console: fix bug in console resizing

When resizing the scroll buffer to a bigger size we try to get lines
from the scroll-back buffer into our current buffer. However, we do not
know how many lines we can get so we start filling the bottom of the
buffer and when no more lines are available, we simply move these lines
to the top of the buffer.
However, we didn't clear the bottom of the buffer after that operation
so if the scroll-back buffer is too small to get us enough lines for
resizing, we currently have a corrupted buffer-bottom. This fixes this
bug by simply setting those lines to NULL as anyone would expect.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
12 years agoconsole: implement proper scrolling
David Herrmann [Fri, 3 Feb 2012 22:47:09 +0000 (23:47 +0100)]
console: implement proper scrolling

Add two new functions to rotate the scroll-area of the buffer. We push
lines to the scroll-back buffer if they are pushed out to the top. Lines
pushed out to the bottom are simply freed.
We never take back lines from the scrollback buffer as applications
expect the new lines to be empty.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
12 years agotest_buffer: add margin tests
David Herrmann [Fri, 3 Feb 2012 17:43:56 +0000 (18:43 +0100)]
test_buffer: add margin tests

Modify the buffer test to add margin tests.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
12 years agoconsole: add margin API
David Herrmann [Fri, 3 Feb 2012 16:48:09 +0000 (17:48 +0100)]
console: add margin API

Allow external subsystems to modify the margin sizes. When setting the
margins we must take care to first perform the shrink operation and then
the grow operations. For instance, if our current top margin is 10 and
the bottom margin is 0 and the application requests to swap the margin
sizes, we should *first* shrink the top margin to 0 and then grow the
bottom margin to 10. Otherwise, we might end up with garbled margins on
a buffer which is smaller than 20 lines.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
12 years agoconsole: add margin support
David Herrmann [Fri, 3 Feb 2012 16:16:50 +0000 (17:16 +0100)]
console: add margin support

Margins are a method to stick lines to the top and bottom of a buffer
and ignore them during console-rotations. We keep 3 different buffers,
two static buffers for the top and bottom margin and one buffer for the
scroll region. The scroll region is always big enough to hold all three
buffers even though it does not contain them. This allows us to merge
the margins back to the scroll-buffer very fast without reallocations.

The buffer layout is the top-margin at the top. The scroll region is
below and the bottom margin is at the bottom. If we rotate the buffer,
we do not touch the margins but simply rotate the scroll buffer. This
may corrupt the scroll-back buffer but there is no sane way to implement
this. The original VTs did not support this either.

Even though we have multiple buffers we keep the buffer-fill logic. That
is, the scroll buffer is not always fully filled. However, if we merge
back the bottom buffer to the scroll buffer, we set the scroll buffer to
be fully filled. Otherwise, we would have artifacts at the bottom.
The top margin does not show this behavior as it is not affected by
rotations below the fill-line.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
12 years agoconsole: rename buffer to scroll-buffer
David Herrmann [Fri, 3 Feb 2012 14:22:36 +0000 (15:22 +0100)]
console: rename buffer to scroll-buffer

The main buffer of the console buffer is now renamed to scroll-buffer.
This allows us to add other buffers like a margin-buffer to the same
buffer object.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
12 years agoconsole: do not fill buffer if not required
David Herrmann [Thu, 2 Feb 2012 16:52:54 +0000 (17:52 +0100)]
console: do not fill buffer if not required

We allow NULL lines in the buffer so we no longer have to create empty
lines when writing anywhere in the buffer.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
12 years agoconsole: allow NULL lines in buffer
David Herrmann [Thu, 2 Feb 2012 16:44:54 +0000 (17:44 +0100)]
console: allow NULL lines in buffer

If we see a NULL line inside the buffer we assume the line is empty.
That is, we now longer abort the drawing but continue with the next
line.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
12 years agoconsole: allow to push empty lines to scrollback buffer
David Herrmann [Thu, 2 Feb 2012 16:41:43 +0000 (17:41 +0100)]
console: allow to push empty lines to scrollback buffer

When pushing a line=NULL to the scrollback buffer we now assume that the
line was empty and we allocate a new empty line. If the allocation fails
we simply drop that line.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
12 years agoconsole: move kmscon_console_rotate to *_newline
David Herrmann [Thu, 2 Feb 2012 16:01:54 +0000 (17:01 +0100)]
console: move kmscon_console_rotate to *_newline

We do no rotation so rename the function to the more appropriate name
kmscon_console_newline.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
12 years agoconsole: add function to clear scrollback buffer
David Herrmann [Thu, 2 Feb 2012 15:47:43 +0000 (16:47 +0100)]
console: add function to clear scrollback buffer

The new function can be used by the UI to clear the current scrollback
buffer to free resources or whatever. It will also be used by the CSI
handler to reset the console.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
12 years agoconsole: add function to set max scrollback buffer size
David Herrmann [Thu, 2 Feb 2012 15:43:15 +0000 (16:43 +0100)]
console: add function to set max scrollback buffer size

The maximum scrollback-buffer size can now be changed on the fly. We
also reduce the current buffer size to the new size so we do not need to
clear the console to flush the scrollback buffer.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
12 years agoconsole: set sb_max to 0 by default
David Herrmann [Thu, 2 Feb 2012 15:33:00 +0000 (16:33 +0100)]
console: set sb_max to 0 by default

The scrollback-buffer maximum is 0 by default to avoid strange
hard-coded default values.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
12 years agoconsole: allow scrollback-buffer maximum = 0
David Herrmann [Thu, 2 Feb 2012 15:30:18 +0000 (16:30 +0100)]
console: allow scrollback-buffer maximum = 0

The scrollback buffer has a variable maximum of lines which can be set
by the application. We currently require it to be greater than 0. This
allows sb_max to be 0 so we can have a console buffer without a
scroll-back buffer.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
12 years agoeloop: add timer support
Ran Benita [Wed, 1 Feb 2012 21:35:02 +0000 (22:35 +0100)]
eloop: add timer support

Add support for dispatching events every given interval. timerfd is used
for hooking up to the event loop, similar to how signalfd is used.

Only relative, monotonic and possibly repeating timer events are
supported. It can be enhanced if there's ever a need.

Signed-off-by: Ran Benita <ran234@gmail.com>
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
12 years agovte: add stub CSI parser
David Herrmann [Wed, 1 Feb 2012 18:33:38 +0000 (19:33 +0100)]
vte: add stub CSI parser

The new parser reads CSI parameters correctly and saves them in an array
for later evaluation. We currently do not handle the CSI commands. This
needs to be added now.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
12 years agovte: parse basic control codes
David Herrmann [Wed, 1 Feb 2012 16:13:22 +0000 (17:13 +0100)]
vte: parse basic control codes

This adds a parser for basic control codes but does not implement their
functionality, yet. Only the newline handler is kept.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
12 years agovte: first check for special keys then for ucs4 char
David Herrmann [Wed, 1 Feb 2012 15:03:54 +0000 (16:03 +0100)]
vte: first check for special keys then for ucs4 char

We should first check whether we recognize the XK_* identifier before we
rely on the converted UCS4 character.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
12 years agovte: implement basic key mappings
David Herrmann [Wed, 1 Feb 2012 14:59:53 +0000 (15:59 +0100)]
vte: implement basic key mappings

The system keys are mapped to their ASCII equivalents. We do not support
CR/NL mode nor scroll-lock yet (is this supported by any term?).

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
12 years agodoc: add VTE links and resources
David Herrmann [Tue, 31 Jan 2012 18:59:02 +0000 (19:59 +0100)]
doc: add VTE links and resources

The vte.txt file will contain information about the terminal emulator
used by KMSCON. Our main goal is xterm-compatibility but for now it
might be easier to try to be linux-console compatible.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
12 years agopty: avoid 4KB buffers on the stack
David Herrmann [Mon, 30 Jan 2012 21:01:32 +0000 (22:01 +0100)]
pty: avoid 4KB buffers on the stack

Allocate the IO-buffer dynamically on the heap for every pty object to
avoid 4KB objects on the stack. This may not be a problem now but we
might get stack overflows later if we continue to use such huge arrays
on the stack.

This doesn't affect the runtime performance as the buffer is still
allocated only once on pty-creation.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
12 years agopty: increase input buffer size
Ran Benita [Mon, 30 Jan 2012 16:50:28 +0000 (18:50 +0200)]
pty: increase input buffer size

Increase the buffer size to match the kernel's. This should guarantee
(practically) that we read() everything queued up for us.

This speeds us up considerably when running something like
$ find /
Such a process spends most of its time blocking on write() waiting for
us. By increasing the buffer size we avoid repeated
read pty -> draw screen -> read pty
cycles, which take most of our time.

To time it, before:
real  0m22.588s
user  0m00.000s
sys   0m00.020s

After:
real  0m00.680s
user  0m00.023s
sys   0m00.000s

Signed-off-by: Ran Benita <ran234@gmail.com>
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
12 years agokbd: correctly initialize refcount
Ran Benita [Sat, 28 Jan 2012 19:51:40 +0000 (21:51 +0200)]
kbd: correctly initialize refcount

The ->ref field was always zero and so the object was never released.

Signed-off-by: Ran Benita <ran234@gmail.com>
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
12 years agoxkb: fix invalid read from uninitialized memory
Ran Benita [Sat, 28 Jan 2012 19:21:44 +0000 (21:21 +0200)]
xkb: fix invalid read from uninitialized memory

The memset was missing a sizeof(..) multiplication.

Really the entire function is more complex than need be, so simplify it.

Signed-off-by: Ran Benita <ran234@gmail.com>
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
12 years agoRemove TODO
David Herrmann [Sun, 29 Jan 2012 16:10:51 +0000 (17:10 +0100)]
Remove TODO

The TODO is now located in the wiki at github.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
12 years agovte: handle keyboard "return"/linefeed
David Herrmann [Sun, 29 Jan 2012 13:51:35 +0000 (14:51 +0100)]
vte: handle keyboard "return"/linefeed

This makes the VTE subsystem emulate a linefeed if XK_Return is read
from the keyboard.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
12 years agoterminal: use UTF8 state machine
David Herrmann [Sun, 29 Jan 2012 13:23:27 +0000 (14:23 +0100)]
terminal: use UTF8 state machine

This adds a converter from UTF8 stream to UCS4 data so the VTE subsystem
can handle the input correctly without complicated UTF8 input.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
12 years agopty: change callback parameters to "const xy"
David Herrmann [Sun, 29 Jan 2012 13:22:48 +0000 (14:22 +0100)]
pty: change callback parameters to "const xy"

There is no reason to allow the callbacks to modify our internal data so
make it constant.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
12 years agotest_buffer: add utf8 state machine test
David Herrmann [Sun, 29 Jan 2012 13:21:19 +0000 (14:21 +0100)]
test_buffer: add utf8 state machine test

Add trivial test to show how to use the utf8 state machine.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
12 years agounicode: add utf8 state machine
David Herrmann [Sun, 29 Jan 2012 13:19:49 +0000 (14:19 +0100)]
unicode: add utf8 state machine

The state machine is used to convert a stream of UTF8 data into UCS4
characters. It is slightly based on the machine found in the
wayland-compositor demos.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>