[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Bug-readline] rl_point, multibyte strings, and the cursor position
From: |
Chet Ramey |
Subject: |
Re: [Bug-readline] rl_point, multibyte strings, and the cursor position |
Date: |
Mon, 16 Feb 2015 10:36:49 -0500 |
User-agent: |
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 |
On 2/16/15 10:26 AM, Ulf Magnusson wrote:
> Okay, I'll roll my own then.
If you dont't have invisible characters in the prompt string or handle line
wrapping, wcswidth(3) can do the job for you. Just assume the line buffer
contains multibyte characters, convert it to a wide character string with
mbstowcs(3), and compute the number of columns to get to the buffer index
indicated by rl_point. If you want to make it easier, strdup
rl_line_buffer and null-terminate the new string at rl_point before calling
mbstowcs.
Chet
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU address@hidden http://cnswww.cns.cwru.edu/~chet/
- [Bug-readline] rl_point, multibyte strings, and the cursor position, Ulf Magnusson, 2015/02/16
- Re: [Bug-readline] rl_point, multibyte strings, and the cursor position, Chet Ramey, 2015/02/16
- Re: [Bug-readline] rl_point, multibyte strings, and the cursor position, Ulf Magnusson, 2015/02/16
- Re: [Bug-readline] rl_point, multibyte strings, and the cursor position,
Chet Ramey <=
- Re: [Bug-readline] rl_point, multibyte strings, and the cursor position, Ulf Magnusson, 2015/02/16
- Re: [Bug-readline] rl_point, multibyte strings, and the cursor position, Ulf Magnusson, 2015/02/16
- Re: [Bug-readline] rl_point, multibyte strings, and the cursor position, Chet Ramey, 2015/02/17
- Re: [Bug-readline] rl_point, multibyte strings, and the cursor position, Ulf Magnusson, 2015/02/17
- Re: [Bug-readline] rl_point, multibyte strings, and the cursor position, Ulf Magnusson, 2015/02/17
- Re: [Bug-readline] rl_point, multibyte strings, and the cursor position, Ulf Magnusson, 2015/02/17
- Re: [Bug-readline] rl_point, multibyte strings, and the cursor position, Chet Ramey, 2015/02/18