deadpixi / sam

An updated version of the sam text editor.
Other
433 stars 47 forks source link

unifying ˆ and ^ #69

Open spaskalev opened 6 years ago

spaskalev commented 6 years ago

ˆ is a non-ascii character that's hard to type with a standard 104 us keyboard - it would be nice if ^ can be used in its place

realwhz commented 6 years ago

^ (code 94 in ascii) is indeed used in Sam's regex for bol or reverse. Not sure what you mean by ˆ.

spaskalev commented 6 years ago

ˆ is used as the address qualifier for start of line. It would be good if ^ can be used in its place in the address qualifier as well.

ckeen commented 6 years ago

@solarsea Where is ˆ mentioned? ^ should be correct.

spaskalev commented 6 years ago

See the reference card at http://sam.cat-v.org/cheatsheet/sam-refcard.pdf

Test it, using ^ as a start of line address does not work, while using ˆ works alright.

ckeen commented 6 years ago

Can you give me an example?

If I do this is sam:

a One line is good Two lines are better Three lines are best . s/^/ -> /g

I get

-> One line is good -> Two lines are better -> Three lines are best

as expected. So I must be missing something.

-- May you be peaceful, may you live in safety, may you be free from suffering, and may you live with ease.

spaskalev commented 6 years ago

I want to select from dot to the start of the line - or select the whole line. In sam's graphical terminal I create a new file with a single line, 'testing' and click in the middle of it.

Then in the command window typing ^ replies with ?unknown command `^'. Typing ˆ seems to select the whole line.

I want to be able to use ^ in dot's address range, not just in regexp address.

ckeen commented 6 years ago

Ah I see. Now, which version is this? I cannot reproduce this on master here. Also I don't see any code handling that so far. The command tab and the address loop do not contain support for this AFAICS.

I must be missing something....

-- May you be peaceful, may you live in safety, may you be free from suffering, and may you live with ease.

spaskalev commented 6 years ago

Weird, I think I have this particular sam installed, commit 51693780fb1457913389db6634163998f9b775b8 I'll check if I'm not running something else.

Still, is there a way to select up to the start of the current line in this version ? I was trying to make a shortcut for that, e.g. home and end buttons

ckeen commented 6 years ago

If you want to move the cursor to those there are commands 'bol' and 'eol' as in:

bind C a command bol bind C e command eol

But I am not sure how to set the selection with any command, since that's not part of the command set. If you are really running this, I'd like to know what exactly I need to enter here to be able to reproduce the behaviour you see.

I am sorry that I don't know of an easy solution, mabye someone else does?

-- May you be peaceful, may you live in safety, may you be free from suffering, and may you live with ease.

ckeen commented 6 years ago

I have hacked a POC for a ^ address command, however I am unsure on how to deal with $: When should it mean end of line and when end of file?

You can test the ^ command here: https://github.com/ckeen/sam.git

ckeen commented 6 years ago

The plan 9 man page also does not mention it, it does mention ^ meaning beginning of line in the context of regular expressions: http://man.cat-v.org/plan_9/1/sam

spaskalev commented 6 years ago

Thanks a lot, I'll give it a try. $ means end of line (up to next new line) and end of file (if on last line and the file does not end with a new line)

ckeen commented 6 years ago

Well in the current implementation $ means 'end of file' unless used in a regular expression. So 5,$ will select everything from line 5 until end of file.