Adding Arrow Key Functionality to a REPL written in Haskell - haskell

I am currently going through a tutorial on writing a Scheme interpreter with Haskell. I would really like to add the ability to use the arrow keys to recall previously entered lines and correct typos without deleting every preceding character.
I figure I can save previously input expressions in a list and traverse the list when the arrow keys are hit, but I am not sure how to automatically detect the key. All of my IO experience has involved the user actually pressing "Enter", so I am not sure how I would go about detecting the arrow key.
Any resources / advice would be welcome. Thanks.

Related

Additional Symbols using key combinations

I am german but switched to US layout for coding. I got myself new keycaps and will stay with them forever.
Still, sometimes i wish to enter german symbols. Ä,Ö,Ü being examples thereof.
I know there is the option to Switch layouts (Super Space) for entering one character or compose key.
But I'd prefer to be able to use just a combination i can specify by myself.
I have an "Alt Gr" Key right of my spacebar. I could imagine using it + some key to get another symbol. Alt Gr + U = Ü for example.
Like this, i could also add other symbols i need from time to time, especially mathematical symbols or greek letters.
Is there any tool that can do this? Best would be one that is available for Windows and Linux.
Many thanks in advance.

Can I replace Tab key as the trigger key in autokey?

I have recently started using Autokey on a Raspberry Pi. I have it installed and operating as expected. The one issue I have encountered for which I cannot find a solution is that I would like to use the backtick key to trigger text expansion.
I have used back tick key previously with other text expansion/hotkey utilities (namely I used it with AutoHotkey on a Windows machine for years). I prefer to have a trigger key to avoid any unexpected triggers. I am so used to using the backtick key that I hit it instead of Tab. I chose the back tick key a decade or more ago for this purpose because I seldom use it (whereas Tab I use constantly). That muscle memory is a hard thing to go against.
I cannot find this discussed anywhere in the documentation and had no luck searching for an answer around the webs. I dug around in the Autokey program files, but didn't find anything so far. Seems like choosing a custom trigger key should be doable.
I haven't been able to solve this in the way I mentioned in my question (setting the backtick key as the trigger rather than the Tab key). I have however come up with a simple work around.
In all of my abbreviations I include the backtick as the last character. Doing this in combination with using the 'trigger immediately (don't require a trigger character)' accomplishes what I was seeking to do.
I am still interested to hear if anyone knows how to do this more directly (changing a setting, rewriting part of the program, etc.).
AutoKey has an option to trigger expansions on all non-word characters. The problem is that it does not consider the backtick a non-word character. To change that, you would have to edit the source code and add the backtick to that list.
I'm not sure where that is in the source code, but if you ask on our Gitter page https://gitter.im/autokey/autokey , one of our developers or advanced users may be able to help you.
This still isn't exactly what you want, but it's closer.
You could also replace the tab key with the backtick key in the source code, but that sounds a bit more dicey and might have other side effects.

Creating a floating menu that pops like normal menu but appears at mouse position

Some context
I've recently switched to ubuntu budgie (from unity), and I am really tired of the Plank/panel menu combo. I cannot find a setting that suits me, because depending on my screen setup, there's always something in the wrong place.
I am literally unable to show the menu on certain edges if I activate auto-hide, and if I don't activate it, it's not nice at all, to the point that I have removed the plank thing altogether. (Am I having strange bugs on this OS, or is it really messy?)
My idea
With great frustrations come new ideas. I thought again about one I had in the past. I would like to have a circle menu that pops around my mouse cursor when I press a given key combination (very much the kind of thing you would find in some games).
The main use case is to get "pined" application shortcuts easily when I need them, but perhaps other things would fit well with them (commands ...).
Questions
So my questions are:
Does such a thing already exist?
If it doesn't, is it difficult to realize? (How much time, complexity, ...)
What tools/libraries are needed for such a project? I know I'll find plenty of explanations on the gnome developer website but I could really use some more help.
Since you mention a buggy behaviour on Plank, depending on the screen configuration, I suspect you are suffering from this bug. In short: Plank's returned values for the space it needs are not always correct in multi monitor setup.
A neat option to replace at least part of the functionality is Ulauncher, by default called from a shortcut, but you could trigger it from anything that is capable of running its command.
Since Ulauncher's window simply identifies in the window list, you can easily write a script to move it to the current mouse position.
In case you'd need any help in that, just leave a comment.
Not sure if you are also referring to quick access of the window list, but for that you could use the Window Previews applet, or even the Workspace Overview applet, so life without Plank is possible.

2 spaces indentation in google Docs

To prepare an exam, I have to learn coding using google docs rather than using an IDE. It may seem idiot or impratical but the teacher really insists on that. It seems that is the same thing as Google interviews for example...
So far, I really got used with using two spaces indentation (I hate using tab indendation). And I want to learn how can I do that quickly in Google docs. Is there a shortcut or a "tips" (add-on?) for that?
For example, if you have an "if-condition" starting at the position number 4 and you want to move to the following line, it can be really convenient to have the cursor position at 4. Then, you'll add two spaces to start your block at position number 6. (ALL the if block will have at least position 6). But in Docs, when you move to the following line, the cursor always start at the beginning of the line except if you use the tab indentation. And it's really shitting if you want to indent your code properly...
Do you have a solution for that please ?
I was facing the same problem.
To write Python code in google docs, my solution is:
Switch off auto-capitalization, auto-correction and smart quotes. And other auto-substitutions so that you may write code without docs like formatting.
To do this: Tools> Preferences and uncheck the above items. Screen shots attached below.
Set tab to two spaces.
Right-click on ruler on top of page. Add left-tab stop, an arrow will appear, move this tab stop to 2 spaces from left of ruler. Try adding tab in the current line and if the tab size is OK, save this formatting.
To save:
Format > Paragraph Styles > Normal Text > Update 'Normal Text' to match.
Last, to add color(synatx highlight), you may use 'code blocks extension'.
Click install.
Now, write code in docs, select the code in google doc, click on:
Add-ons > Code Block. A pop up opens up.
Choose language : 'python' for me.
Choose theme: 'atom-one-dark'
click Format.
The code looks much like IDE, and writing more code is easier too.
While I understand that sometimes a point can be made by making students do things in a way that might not seem logical, this one doesn't make any sense to me.
Students don't learn anything useful by pressing space twice instead of letting an editor or IDE do it for them.
I wonder, is it because he/she wants it delivered in Google Docs or because they want you coding that way? If it's the latter, you won't have to hide your workaround.
I can only suggest using a good text editor, I always use the excellent and free Notepad++, and copy and paste it to and from Google Docs. Your instructor will never know. In fact, I'd be hunting around to see of there was a way to access your code files directly in Google Docs from Notepad++, or to auto-sync a folder with Google docs.
Notepad++ has syntax colouring - which will save your life - and can be set to indent with tabs or spaces to whatever indent width you specify. If not using an IDE, I only use Notepad++.
Your instructor sounds like some I had, people who cross a line from being quirky but with a point to make to just being a dick. There is absolutely no point in telling a student to code only in Google docs. Google docs is a great thing, I love it, but it is by no stretch of the imagination a coding tool.
(I see that this is an aged thread, but I'll respond in case someone else with a similar issue - like this year's class for that course - comes looking for an answer.)
You could try (ab)using bulleted lists:
Insert a bulleted list
Right click on the bullet, select "More bullets..."
In the "Symbol" selection list, choose "Format & whitespace" and select one of the whitespace options as bullet char
Repeat for as many levels (of bullet sub-lists) as you think you may need in your program
Fix indentation to match whatever feels best for you
Every time you need to write a nested block, you will have to press "tab" only once, then bullet list level is kept and the indentation with it. To go back to the outer block, just press shift-tab.
However, IMHO it doesn't worth the trouble. Generally, interview question solutions are not that large and hitting spacebar a couple of times is not much of an overhead.
It's somewhat cumbersome but you can set as many tab stops as you want, and docs will move nested tabs to the next tab stop as well. For example:
You can add tab stops by right clicking on that tab bar where you want the tab stop to be and clicking Add left tab stop. You'll want to have all text in the document selected if you want the tab stop to apply everywhere.

Creating your own LaTeX keyboard layout : 1 key = multiple caracters

I've been looking for the answer for quite some time now. This is a project I have but I can't manage to find a way to do it. The main idea would be to plug an additional keyboard on my computer that write multiple letters by hitting only one key. For example, instead of writing down a (when I hit the a key), it would write \textbf{ (for example).
I already manage to find the keyboard layout file under Linux and to switch the a and b keys, but I cannot find a way to print multiple characters.
I know it exist editors (like Texmaker or Kile) that have auto-completion, but I'm most of the time working in project in groups and therefore we use writelatex.com which does not propose auto-completion in it's free user pack ! Besides, I'm doing that for my personal interest.
Thanks a lot.
Have a look at autokey. It can assign phrases to hotkeys. It requires X11.
Another option might be to use a powerful text editor like vim or emacs which both have features like this, and then copy/paste the text into writelatex.com.
Some browsers have add-ons that allow you to edit the contents of a text field on a web page with a chosen text editor.
Edit: In Xorg you can use the X KeyBoard extension to e.g. change the meaning of individual keys. While you can configure the keyboard to generate (multibyte) unicode characters, you cannot assign arbitraty character strings to one key, to the best of my knowledge.

Resources