How to make backspace work in lc3 assembly - backspace

My code is,
LOOP TRAP x20 ;get c
TRAP x21 ;out
BRnzp LOOP
It will output any letter to the consoles, it will return carriage, tab, but it won't backspace, and the delete button doesn't even show up in a register. Backspace will just show some character, looks like []. Delete shows nothing.
I tried another version without inputs where I used the delete ascii value and the start of text ascii value to move the cursor and delete but it doesn't seem to do anything. Is this a bug or am I doing something wrong?
Is there another way to clear the console out? I could work around it if I spam a bunch of new lines until it's off screen but I would rather it work normally. Any ideas?

Putting out a backspace character won't do anything to the characters already outputted, because they're already there.
The best way to achieve this is usually by setting your console to VT100-compatible (often set by default) and using VT100 escape codes to move around the screen.

Related

How to customize the look of currently selected(highlighted) completion in zsh?

Main question
I would like to add powerline characters at the start and at the end of the selected completion, like this:
Started the completion menu by inserting c and pressing the TAB key.
Moved right in the completion menu by pressing the right arrow key.
Moved down in the completion menu by pressing the down arrow key.
Is there any way to make zsh look/behave like in the pictures?
Note
Added powerline triangle + blank character at the beginning and blank character + powerline triangle at the end should somehow be accounted when columns are created to keep the alignment correct.
Bonus
Add 2 blanks at the beginning of every completion in the list, so that when the completion is selected it doesn't look like the text was moved to the right.
( This issue can be seen by comparing the completion with and without the selection. )
Alternative question
In case that previously explained behavior is impossible to get without changing the zsh source code, is it at least possible to add powerline triangle only at the end of the selected completion?
My unsuccessful attempts
I have tried using the lc, rc, and ec variables in the list-colors style but that didn't help:
Completion list was badly aligned and it created all kinds of visual problems.
Symbols were inserted in all elements of the completion list, not just the selected one.
I have also tried using the ma variable, but I couldn't properly insert a character at the beginning:
The variable expects only a number that represents a color and it is probably wrapped in some escape sequences, so the output did not look as expected.
This works for me.
zstyle ":completion:*:default" list-colors ${(s.:.)LS_COLORS} "ma=48;5;153;1"
Uses my LS_COLORS and then ma sets the background of my selection to bold and color 153 from https://jonasjacek.github.io/colors/.
Found from https://www.zsh.org/mla/users/2010/msg00811.html

Why do I see the ASCII symbols in Notepad++?

(I am new with this) I see these weird black text-boxes and, as far as I know, they are ascii symbols, but I don't know how to see it in a "normal" view, if possible. Thanks in advance!
It was a bit hard to follow your link, I included the screenshot in your question. The ESC indicates a non-printable character. In this case it is the Escape character (ASCII 27), which from the screen shot appears to be part of escape sequences to change text color.
Unfortunately, Notepad++ does not have the means to render them as intended. One option is that you select one and find/replace with nothing. If you want to get rid of not only the ESC but also its associated "parameters" you can use this regular expression to find and replace them
\x1b[^m]*m

How to replace a string pattern with different strings quickly?

For example, I have many HTML tabs to style, they use different classes, and will have different backgrounds. Background images files have names corresponding to class names.
The way I found to do it is yank:
.tab.home {
background: ...home.jpg...
}
then paste, then :s/home/about.
This is to be repeated for a few times. I found that & can be used to repeat last substitute, but only for the same target string. What is the quickest way to repeat a substitute with different target string?
Alternatively, probably there are more efficient ways to do such a thing?
I had a quick play with some vim macro magic and came up with the following idea... I apologise for the length. I thought it best to explain the steps..
First, place the text block you want to repeat into a register (I picked register z), so with the cursor at the beginning of the .tab line I pressed "z3Y (select reg z and yank 3 lines).
Then I entered the series of VIM commands I wanted into the buffer as )"zp:.,%s/home/. (Just press i and type the commands)
This translate to;
) go the end of the current '{}' block,
"zp paste a copy of the text in register z,
.,%s/home/ which has two tricks.
The .,% ensures the substitution applies to everything from the start of the .tab to the end of the closing }, and,
The command is incomplete (ie, does not have a at the end), so vim will prompt me to complete the command.
Note that while %s/// will perform a substitution across every line of the file, it is important to realise that % is an alias for range 1,$. Using 1,% as a range, causes the % to be used as the 'jump to matching parenthesis' operator, resulting in a range from the current line to the end of the % match. (which in this example, is the closing brace in the block)
Then, after placing the cursor on the ) at the beginning of the line, I typed "qy$ which means yank all characters to the end of the line into register q.
This is important, because simply yanking the line with Y will include a carriage return in the register, and will cause the macro to fail.
I then executed the content of register q with #q and I was prompted to complete the s/home/ on the command line.
After typing the replacement text and pressing enter, the pasted block (from register z) appeared in the buffer with the substitutions already applied.
At this point you can repeat the last #qby simple typing ##. You don't even need to move the cursor down to the end of the block because the ) at the start of the macro does that for you.
This effectively reduces the process of yanking the original text, inserting it, and executing two manual replace commands into a simple ##.
You can safely delete the macro string from your edit buffer when done.
This is incredibly vim-ish, and might waste a bit of time getting it right, but it could save you even more when you do.
Vim macro's might be the trick you are looking for.
From the manual, I found :s//new-replacement. Seemed to be too much typing.
Looking for a better answer.

How do I avoid this while printing to screen?

When I do a printk with "bad" characters, sometimes I scrambles my screen,
Is this unavoidable when printing them?
Type reset and Enter on your command line to get it fixed again. If you don't see it anymore, you might have to type it blindly, but it works often.
Depending on how you set up your environment, there are characters that can't be printed without messing up your command line.
You can try to print hex values %x. Like this it is usually much easier to find a logic behind the data.

Why is a % symbol appearing in my standard output?

Sometimes I echo a string to the standard output (I see it at the Kubuntu console) and a trailing % symbol gets appended with it's colors inverted (black text on white background).
I can't find any accidental additional character (or half-baked-UTF8 or anything) in the string I'm printing. The character seems to get added when the program finishes.
I'm using Go (golang) right now, but I've already seen this in the past, and I think I was using PHP back then.
What could be causing this?
what shell are you using? sounds like what happens in zsh when there is no carriage return at the end of your output

Resources