Question: I am using the (excellent) `readline` (version 6.3, default [non-vi] mode) library from within my own program, running in a Terminal window (on a PC). There is a problem when there is previous output not terminated by newline when `readline()` is called.

```
#include <stdio.h>
#include <readline/readline.h>

void main(void)
{
  // Previous output from some other part of application
  // which *may* have output stuff *not* terminated with a '\n'
  printf("Hello ");
  fflush(stdout);

  char *in = readline("OK> ");
}

```

So the line looks like:

```
Hello OK> <caret here>

```

If you type a small number of characters (up to 5?) and then, say, `Ctrl+U` (may be others) to delete your input so far it all seems well --- `readline()` moves the caret back to just after its own prompt. However, try typing, say:

```
123456 <Ctrl+U>

```

Now it deletes back *into* the `Hello`, leaving just `Hell` on the line, followed by the caret.

I need one of two possible solutions:

1. This does look like a bug, now that I have realised it depends on how many characters are typed on the line where it goes wrong. Any fix/workaround?
2. Alternatively, is there a `readline` library call I could make which would tell me what position/column the caret is at before I invoke `readline()`? Then at least I could recognise the fact that that I am at the end of an existing line and output a `\n` so as to position myself at the start of a new line first.

P.S.
Is this an OK place to ask about `readline` programming under Ubuntu or should I be posting at **stackoverflow.com**?

Answer: 
For the first issue you need a set of *fonts* for WPS and this should be dropped into the `/usr/share/fonts` folder for system wide access.

Now I have created a **git repo** with these fonts download it from [here](https://github.com/udoyen/wps-fonts) and add it like this:

1. download fonts from [here](https://github.com/udoyen/wps-fonts)
2. create a folder `sudo mkdir /usr/share/fonts/kingsoft`
3. copy the contents of that download to folder in (2)
4. run `sudo chown -R $USER:$USER /usr/share/fonts/kingsoft`
5. run `sudo chmod -R o+rw,g+rw /usr/share/fonts/kingsoft` or leave as is if it has `read and write permissions` for owner (you)
6. run `sudo fc-cache -vfs`

For the second issue. You could try this qalculate:

Install: `sudo apt-get install qalculate`

Qalculator resource: <https://www.maketecheasier.com/qalculate-powerful-calculator-for-linux/>
2021 update : WPS offece Has a powerful equation editor ( Chemical and Mathimatical ) on ubuntu

> 
> **INSERT > EQUATION > INSERT NEW EQUATION**
> 
> 
> [![enter image description here](https://i.stack.imgur.com/ofqnn.png)](https://i.stack.imgur.com/ofqnn.png)
> 
> 
>