# Terminal gets ruined after using charterm

**URL:** https://racket.discourse.group/t/terminal-gets-ruined-after-using-charterm/2760
**Category:** Questions & Answers
**Created:** [March 3, 2024, 3:31pm UTC](https://racket.discourse.group/t/terminal-gets-ruined-after-using-charterm/2760 "2024-03-03T15:31:01Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![mskoh52](https://avatars.discourse-cdn.com/v4/letter/m/90db22/32.png) [@mskoh52](https://racket.discourse.group/u/mskoh52)
#### Post date: [March 3, 2024, 3:31pm UTC](https://racket.discourse.group/t/terminal-gets-ruined-after-using-charterm/2760/1 "2024-03-03T15:31:01Z")

</div>

I'm trying to use [charterm](https://docs.racket-lang.org/charterm/index.html) to build a roguelike. I'm using iTerm2 with zsh on a mac. After exiting my racket program, terminal outputs every new line indented starting at the end of the previous line, like this:

```scheme
$ ls -1
actions
       input.rkt
                level.rkt
                         loop.rkt
                                 pos.rkt
                                        render
                                              %

```

Those are actual spaces and the % sign at the end is also added to every output. Here's a screenshot:

 ![image](https://global.discourse-cdn.com/free1/uploads/racket/original/2X/9/940969aa10ab249a1125968de65fc23666d039b3.png)

If I pipe that into less, the output looks normal for what that's worth.

This isn't a huge deal but it is kind of annoying. Anybody know what's going on?

Here's the screen drawing code: [rkt/roguelike/engine/render/term.rkt at main · mskoh52/rkt · GitHub](https://github.com/mskoh52/rkt/blob/main/roguelike/engine/render/term.rkt)

I modified charterm to use utf-8 instead of latin-8 but this issue appeared before I did that as well.

---

<div class="post-metadata">

### Author: ![benknoble](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/benknoble/32/16_2.png) [@benknoble](https://racket.discourse.group/u/benknoble)
#### Post date: [March 3, 2024, 6:05pm UTC](https://racket.discourse.group/t/terminal-gets-ruined-after-using-charterm/2760/2 "2024-03-03T18:05:19Z")

</div>

You’re probably missing some cleanup exit sequences. Try running the command `reset` to fix the terminal.

---

<div class="post-metadata">

### Author: ![dominik.pantucek](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/dominik.pantucek/32/144_2.png) [@dominik.pantucek](https://racket.discourse.group/u/dominik.pantucek)
#### Post date: [March 3, 2024, 7:54pm UTC](https://racket.discourse.group/t/terminal-gets-ruined-after-using-charterm/2760/3 "2024-03-03T19:54:04Z")

</div>

[rkt/roguelike/engine/loop.rkt at main · mskoh52/rkt · GitHub](https://github.com/mskoh52/rkt/blob/main/roguelike/engine/loop.rkt#L12) is the source of your problem. The `dynamic-wind` inside charterm - [rkt/roguelike/engine/render/charterm.rkt at main · mskoh52/rkt · GitHub](https://github.com/mskoh52/rkt/blob/main/roguelike/engine/render/charterm.rkt#L1815) - doesn't get the chance to run `close-charterm` which would perform the necessary cleanup.

I would use `(void)` instead of `(exit)` in your particular case.

---

<div class="post-metadata">

### Author: ![mskoh52](https://avatars.discourse-cdn.com/v4/letter/m/90db22/32.png) [@mskoh52](https://racket.discourse.group/u/mskoh52)
#### Post date: [March 3, 2024, 9:08pm UTC](https://racket.discourse.group/t/terminal-gets-ruined-after-using-charterm/2760/4 "2024-03-03T21:08:12Z")

</div>

> [@dominik.pantucek](#):
>
> I would use `(void)` instead of `(exit)` in your particular case.

That did the trick, thank you!
