Changeset 90f067d9 in mainline


Ignore:
Timestamp:
2012-04-13T07:41:22Z (12 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
a7a7f8c
Parents:
9b0a6b4
Message:

Add filtering of ANSI escape sequences to msim

Location:
uspace/app/msim
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/msim/helenos.c

    r9b0a6b4 r90f067d9  
    3434#include "io/input.h"
    3535#include "io/output.h"
     36#include "device/dprinter.h"
    3637#include "debug/gdb.h"
    3738#include "cmd.h"
     
    4041#include <str.h>
    4142#include <malloc.h>
     43#include <ctype.h>
     44#include <stdio.h>
     45
     46/* Define when the dprinter device shall try to filter
     47 * out ANSI escape sequences.
     48 */
     49#define IGNORE_ANSI_ESCAPE_SEQUENCES
    4250
    4351extern char *input_helenos_get_next_command(void);
     
    8795
    8896
     97char *input_helenos_get_next_command(void);
     98
     99static void (*original_printer_write)(cpu_t *, device_s *, ptr_t, uint32_t);
     100static void helenos_printer_write(cpu_t *cpu, device_s *dev, ptr_t addr, uint32_t val)
     101{
     102#ifdef IGNORE_ANSI_ESCAPE_SEQUENCES
     103        static bool inside_ansi_escape = false;
     104        static bool just_ended_ansi_escape = false;
     105
     106        if (inside_ansi_escape) {
     107                fprintf(stderr, "%02" PRIx32 "'%c' ", val, val >= 32 ? val : '?');
     108                if (isalpha((int) val)) {
     109                        just_ended_ansi_escape = true;
     110                        inside_ansi_escape = false;
     111                        fprintf(stderr, " [END]\n");
     112                }
     113
     114                return;
     115        }
     116
     117        if (val == 0x1B) {
     118                inside_ansi_escape = true;
     119
     120                if (!just_ended_ansi_escape) {
     121                        fprintf(stderr, "\n");
     122                }
     123                fprintf(stderr, "ESC sequence: ");
     124
     125                return;
     126        }
     127
     128        just_ended_ansi_escape = false;
     129#endif
     130
     131        (*original_printer_write)(cpu, dev, addr, val);
     132}
     133
     134void helenos_dprinter_init(void)
     135{
     136        original_printer_write = dprinter.write;
     137        dprinter.write = helenos_printer_write;
     138}
     139
     140
  • uspace/app/msim/helenos_input.c

    r9b0a6b4 r90f067d9  
    4141
    4242char *input_helenos_get_next_command(void);
     43void helenos_dprinter_init(void);
    4344
    4445/** Terminal and readline initialization
     
    5152                die(1, "Failed to intialize input.");
    5253        }
     54        helenos_dprinter_init();
    5355}
    5456
Note: See TracChangeset for help on using the changeset viewer.