X-Git-Url: http://git.madism.org/?a=blobdiff_plain;f=inject.c;h=d4b05da0f09dd6710b098fbc6d76e21e7f29db01;hb=6b8dbf88373a486ad0117331cfb577b3b6010141;hp=9d3c431758b8cc054c4e773bcb6384769a8db3c0;hpb=1d26603be3c785ed147834cb7c750454a5866599;p=apps%2Fmadtty.git diff --git a/inject.c b/inject.c index 9d3c431..d4b05da 100644 --- a/inject.c +++ b/inject.c @@ -1,28 +1,30 @@ /* -LICENSE INFORMATION: -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU Lesser General Public -License (LGPL) as published by the Free Software Foundation. + LICENSE INFORMATION: + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License (LGPL) as published by the Free Software Foundation. -Please refer to the COPYING file for more information. + Please refer to the COPYING file for more information. -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. -You should have received a copy of the GNU Lesser General Public -License along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + You should have received a copy of the GNU Lesser General Public + License along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -Copyright (c) 2004 Bruno T. C. de Oliveira -*/ + Copyright © 2004 Bruno T. C. de Oliveira + Copyright © 2006 Pierre Habouzit + */ +#include +#include -#include "rote.h" +#include "madtty.h" #include "roteprivate.h" #include "inject_csi.h" -#include static void cursor_line_down(RoteTerm *rt) { int i; @@ -75,17 +77,24 @@ static void cursor_line_up(RoteTerm *rt) { } static inline void put_normal_char(RoteTerm *rt, char c) { + if (rt->ccol >= rt->cols) { + rt->ccol = 0; + cursor_line_down(rt); + } + + if (rt->insert) { + int i; + + for(i = rt->cols - 1; i >= rt->ccol+1; i--) + rt->cells[rt->crow][i] = rt->cells[rt->crow][i-1]; + } + rt->cells[rt->crow][rt->ccol].ch = c; rt->cells[rt->crow][rt->ccol].attr = rt->curattr; rt->ccol++; rt->line_dirty[rt->crow] = true; rt->curpos_dirty = true; - - if (rt->ccol >= rt->cols) { - rt->ccol = 0; - cursor_line_down(rt); - } } static inline void put_graphmode_char(RoteTerm *rt, char c) { @@ -128,7 +137,8 @@ static void handle_control_char(RoteTerm *rt, char c) { rt->curpos_dirty = true; break; case '\t': /* tab */ - while (rt->ccol % 8) put_normal_char(rt, ' '); + rt->ccol += 8 - (rt->ccol % 8); + clamp_cursor_to_bounds(rt); break; case '\x1B': /* begin escape sequence (aborting previous one if any) */ new_escape_sequence(rt);