summaryrefslogtreecommitdiff
path: root/userspace/xterm
diff options
context:
space:
mode:
authorMiguel <m.i@gmx.at>2018-10-13 00:57:28 +0200
committerMiguel <m.i@gmx.at>2018-10-13 00:57:28 +0200
commit279f3336a8f6b31ca38bdd272c73aebd68fa88fe (patch)
treeb4bb4a21a4acf38eb810768ac6c1b099e2f18a58 /userspace/xterm
parentb461c3558b2fe765a4bac512638b0acf5185b4bb (diff)
ncurses arrow keys working etc
Diffstat (limited to 'userspace/xterm')
-rw-r--r--userspace/xterm/terminal.c69
-rw-r--r--userspace/xterm/vesa.c1
-rw-r--r--userspace/xterm/xterm.c7
3 files changed, 68 insertions, 9 deletions
diff --git a/userspace/xterm/terminal.c b/userspace/xterm/terminal.c
index ba7986e..ed2b175 100644
--- a/userspace/xterm/terminal.c
+++ b/userspace/xterm/terminal.c
@@ -1,3 +1,4 @@
+// https://en.wikipedia.org/wiki/ANSI_escape_code
// http://en.wikipedia.org/wiki/VT52
// http://vt100.net/docs/vt520-rm/
// man 4 console_codes
@@ -96,7 +97,7 @@ typedef struct terminal_tty_struct
uint32_t height;
uint32_t x;
uint32_t y;
- uint32_t *data; // screen data
+ uint32_t *data; // screen data (need this for linefeed and rev linefeed)
uint8_t *command; // command line / also holds npar for escape sequences somewhere
int32_t command_l; // command line length
@@ -250,6 +251,60 @@ static void process_graphic_npar(terminal_tty *tty, terminal_settings s)
}
}
+// string needs to have leading zeroes!
+static uint32_t myatoi(char *str,int len)
+{
+ uint32_t res=0;
+
+ for(int i=0;i<len;i++)
+ {
+ res*=10;
+ res+=str[i]-'0';
+ }
+
+ return res;
+}
+
+static void process_cup(terminal_tty *tty)
+{
+
+ // the CSI CUP command:
+ //
+ // - starts at: tty->command[NPAR_START]
+ // - has length: tty->npar
+ // - has the form: row;col
+
+ char buf[10];
+ int b=0;
+ bool row=true;
+
+ for(int i=0;i<tty->npar+1;i++)
+ {
+ char c=tty->command[NPAR_START+i];
+
+ // hit the separating ';' or hit the end
+ if(i==tty->npar||c==';')
+ {
+ if(row) //row 1-based
+ {
+ tty->y=myatoi(buf,b)-1;
+ }
+ else //col 1-based
+ {
+ tty->x=myatoi(buf,b)-1;
+ }
+ row=false;
+ b=0;
+ }
+ else
+ {
+ buf[b++]=c;
+ }
+ }
+
+ tty->npar=0;
+}
+
static void process_graphic_npars(terminal_tty *tty)
{
@@ -508,7 +563,6 @@ void terminal_put(terminal_tty *tty, uint8_t c)
if(c=='8'){}// RESTORE STATE
if(c=='['){tty->escaping=2;tty->npar=0;return;} // CONTROL SEQ INTRODUCER
-
// TODO
// %, %@, %G, %8, #8, (, (B, (O, (U, (K
// ), >, =, ] (???)
@@ -521,19 +575,20 @@ void terminal_put(terminal_tty *tty, uint8_t c)
else if(tty->escaping==2)
{
//ECMA-48: TODO
-
-
-
//ECMA-48 GRAPHIC RENDITION: OK
- if(c!='m')
+ if(c!='m' && c!='H')
{
tty->command[NPAR_START+(tty->npar++)]=c;
}
- else
+ else if(c=='m')
{
process_graphic_npars(tty);
}
+ else if(c=='H')
+ {
+ process_cup(tty);
+ }
//ECMA-48 MODE SWITCHES: TODO
//ECMA-48 STATUS REPORT: TODO
diff --git a/userspace/xterm/vesa.c b/userspace/xterm/vesa.c
index 085d1b0..9e89cbe 100644
--- a/userspace/xterm/vesa.c
+++ b/userspace/xterm/vesa.c
@@ -1,7 +1,6 @@
#include <stdarg.h>
#include <stdint.h>
#include <stdio.h>
-#include "../newcalls.h"
#include "vesa.h"
#define VMEM_USER_FRAMEBUFFER 0xfc000000
diff --git a/userspace/xterm/xterm.c b/userspace/xterm/xterm.c
index fdee768..bee8d8d 100644
--- a/userspace/xterm/xterm.c
+++ b/userspace/xterm/xterm.c
@@ -3,6 +3,9 @@
extern char**environ;
+//default
+char *argv1[]={"xterm","/bin/fsh",0};
+
int main(int argc, char **argv)
{
_gui_win();
@@ -30,7 +33,9 @@ int main(int argc, char **argv)
_dup2(xterm_out[1],1);// stdout
_dup2(xterm_out[1],2);// stderr
- _execve(argv[1],argv,environ); // replace process with our foolshell or whatever
+ // replace process with our foolshell or whatever
+ if(argc==1)_execve(argv1[1],argv1,environ);
+ _execve(argv[1],argv,environ);
while(1);
}