Commit Graph

219 Commits (be9bffdf497594aa321b620093cef1f180764576)

Author SHA1 Message Date
C. McEnroe 3f3585d0f3 Fix missing include for flock(2)
On OpenBSD it's in <fcntl.h>, and it gets declared anyway on FreeBSD
and macOS. Curiously, on GNU/Linux, LOCK_* are defined, but flock(2)
isn't declared.
2021-08-09 20:14:24 -04:00
C. McEnroe 347e2b461f Don't apply uiThreshold to Network and Debug
Messages don't really need to be hidden from <network> and I think
it could be confusing. Debug messages are all Cold so everything
would be hidden, and I want to keep them that way so that <debug>
doesn't clutter the status line needlessly.
2021-07-20 12:09:24 -04:00
Klemens Nanni f8e3414af0 Add -q/quiet option to raise default message visibility threshold
Silencing all windows with `M-+' (across multiple catgirl instances)
can be cumbersome, so provide an option to hide events, JOIN/PART noise,
etc. by default (each window's threshold will persist across load/save
cycles, i.e. when using the `-s/save' option).

Started out as `-v | visibility = threshold' to set a specific level,
the idea of a simpler toggle comes from june, who also squashed other
bugs (as usual).
2021-07-20 12:03:46 -04:00
C. McEnroe 54d899196c FreeBSD: Avoid caph_stream_rights(3)
caph_stream_rights(3) doesn't exist before FreeBSD 13.0 and there's
no good reason to create that dependency. I still run servers on
FreeBSD 12.

This is a partial revert of cbc9545cb3.
2021-07-13 15:16:22 -04:00
C. McEnroe cbc9545cb3 FreeBSD: Use capsicum_helpers.h 2021-06-28 09:11:02 -04:00
C. McEnroe b48d0d607c FreeBSD: Limit rights on save file 2021-06-25 11:50:14 -04:00
C. McEnroe 1a336de95c Open save file with CLOEXEC
Otherwise a lingering process from /copy for example could hold the
lock.
2021-06-21 13:26:55 -04:00
Klemens Nanni 9c7ceb23bb /exec without controlling terminal
Otherwise "/exec sh </dev/tty" takes over and catgirl must effectively
be killed to stop the madness;  with this diff:

	catgirl  input| /exec sh </dev/tty
	catgirl output| /bin/sh: cannot open /dev/tty: Device not configured
	catgirl output| Process exits with status 1

Do the same for `-C/Copy', `-N/notify' and `-O/open' alike.
2021-06-13 16:46:34 -04:00
C. McEnroe 161c1ad680 Fix unknown file signature error 2021-06-11 21:22:03 -04:00
C. McEnroe f6e8078c46 Exclusively lock save file
Prevents two instances of catgirl from using the same save file and
clobbering each other's data.
2021-06-11 21:15:34 -04:00
C. McEnroe c6009cf13c Open save file with "a+"
Avoids another small TOCTOU. Rewind before loading since "a+" sets
the file position at the end. Remove unnecessary fseek after
truncation, since "a+" always writes at the end of the file.
2021-06-11 21:02:40 -04:00
Klemens Nanni cdd4ccf16f Open save file once in uiLoad() and keep it open until uiSave()
Opening the same file *path* twice is a TOCTOU, although not a critical
one: worst case we load from one file and save to another - the impact
depends on how and when catgirl is started the next anyway.

More importantly, keeping the file handle open at runtime allows us to
drop all filesystem related promises for `-s/save' on OpenBSD.

uiLoad() now opens "r+", meaning "Open for reading and writing." up
front so uiSave() can write to it.  In the case of a nonexistent save
file, it now opens with "w" meaning "Open for writing.  The file is
created if it does not exist.", i.e. the same write/create semantics as
"w" except uiLoad() no longer truncates. existing files.

uiSave() now truncates the save file to avoid appending in general.
2021-06-11 20:57:40 -04:00
Klemens Nanni 8e591c96f8 Rename file to saveFile
Separate churn from actual change in upcoming diff,
no functional change.
2021-06-11 12:52:07 -04:00
C. McEnroe e066a954f5 Replace catf with seprintf 2021-06-09 11:56:35 -04:00
Michael Forney 8d7460859b Avoid writing past the end of the status bar
When waddnstr is called with a string that would extend past the
end of the window, the string is truncated, the cursor remains at
the last column, and ERR is returned. If this error is ignored and
the loop continues, the next call to waddnstr overwrites the character
at this column, resulting in a slight visual artifact. When the
window is too small to fit the full status line, it is effectively
truncated by one space on the right, since the string shown for
each channel begins with a space.  Additionally, if the last window
is the current window, the space is shown with a colored background.

To fix this, when waddnstr returns ERR, exit the loop in styleAdd()
early return -1 to propogate this error down to the caller.
2021-06-05 13:23:23 -04:00
C. McEnroe f559322224 List windows with /window
Reuse the /window command to preserve /wi abbreviation.
2021-05-28 20:40:25 -04:00
C. McEnroe d7ce4b9bc6 Add C-z keys for directly inserting most color codes
So you don't have to remember those dang numbers whose order makes
no sense!
2021-03-17 16:00:06 -04:00
C. McEnroe 8d56311314 Reset style after newline in input
Reflect what will actually be sent.
2021-03-17 13:49:26 -04:00
C. McEnroe 8ea881a097 Show where too-long-messages will be automatically split 2021-03-17 13:34:33 -04:00
C. McEnroe 8f578ee73d Add bindings for C-Left and C-Right
Apparently these are common. There's no terminfo for these, so
manually define the xterm sequences.

There's no documentation in the manual for the "intuitive" keys...
I'm not sure if that should continue to be the case or not.
2021-03-07 18:18:37 -05:00
C. McEnroe d88ffd9f3f Add all window names to global completion
Don't want to be touching window names much though, otherwise query
window names would interfere with tab completion within a channel.
2021-03-02 14:45:01 -05:00
C. McEnroe f4e8f055fb Add workaround for lack of A_ITALIC in old ncurses
A_BLINK has probably always existed, but there's no good reason to
ever use it, so make it do italics instead. Normally all attributes
are set by a single set_attributes string if it's set, so clear it
to force ncurses to use the reassigned enter_blink_mode string. If
the terminal has no enter_italics_mode string, then nothing will
happen.

This makes setting multiple attributes a bit less efficient, but I
don't think it's likely to make much of a difference since using
multiple attributes at once is so uncommon.
2021-02-27 16:28:21 -05:00
C. McEnroe 4b26ae23cd Add C-z p to manually toggle paste mode
OpenBSD's xterm doesn't have bracketed paste mode, and it would be
nice to still be able to paste in several lines and collapse them
with M-q, provided one remembers to type C-z p first...
2021-02-15 19:15:38 -05:00
C. McEnroe 66c67542ff Refactor Focus and Paste mode strings 2021-02-15 19:15:38 -05:00
C. McEnroe 7807848bda Add C-z C-v for literal next
A little annoying to make it a "chord" like this, but C-v is already
used for scrolling, following Emacs-style key bindings (in order
to have a way to scroll without using "special" keys like the arrows
and page up/down), and C-z is at least already in the business of
inserting control characters. This makes it possible to manually
enter some things that are otherwise only possible with /exec printf.
2021-02-03 14:52:16 -05:00
C. McEnroe 32bf43660f Also skip marking swap window
Third time's the charm?
2021-01-31 15:33:41 -05:00
C. McEnroe beeddcb11f Actually scroll to first line for "scroll to top" 2021-01-29 23:32:47 -05:00
C. McEnroe 89a2fac05a Only skip setting swap in windowShow
With the early return, mainUpdate doesn't get called in cases where
other functions expect windowShow to call it, such as when closing
or moving windows.
2021-01-29 23:24:58 -05:00
C. McEnroe 422fe6cd29 Move threshold and mute indicators directly after number
I don't know why I ruled this out originally, it's more visually
pleasing to me now especially that threshold is likely to remain
set at "+" for a long time.
2021-01-28 01:49:41 -05:00
C. McEnroe 5dde56d692 Save window time display toggle 2021-01-27 15:35:26 -05:00
C. McEnroe b4c26a2cab Measure timestamp width using ncurses
This allows for non-ASCII characters in timestamps, and simplifies
things by including the trailing space in the width.
2021-01-27 14:55:31 -05:00
C. McEnroe d6ff9e53cf Change default timestamp format to %X
This respects the user's locale settings.
2021-01-27 14:18:20 -05:00
C. McEnroe c118c594e3 Add toggleable display of timestamps 2021-01-27 00:15:46 -05:00
C. McEnroe 604de4ff5a Only list up until scroll position with M-l 2021-01-26 23:08:58 -05:00
C. McEnroe d7d4572220 Preserve scroll position across reflows
Finally! Changing the message visibility threshold doesn't totally
screw up scroll position. Neither do horizontal resizes, but vertical
resizes drift because the value of windowTop() changes before and
after...

The scroll position is anchored to the top of the window. It's
arbitrary whether to anchor the top or the bottom, but other scrolling
commands like M-p and C-r are anchored to the top, so this is
consistent.
2021-01-26 22:33:16 -05:00
C. McEnroe a18ced53df Rename and move scroll functions closer to where they are used 2021-01-26 19:53:38 -05:00
C. McEnroe 76670b2fb1 Factor out windowReflow 2021-01-26 19:33:17 -05:00
C. McEnroe bd210e0f35 Disable notify in restricted mode
catgirl shouldn't try to execute a command if it is misconfigured
with both restrict and notify.
2021-01-25 18:27:07 -05:00
C. McEnroe 86b79096e0 Don't print timestamps for blank lines in bufferList 2021-01-25 17:27:54 -05:00
C. McEnroe 6ee0aea9e5 Simplify windowUpdate loops and factor out windowTop
No idea why I made that more complicated than it had to be looping
backwards.
2021-01-21 11:57:23 -05:00
Jeremy O'Brien 1fbc8fe394 Don't lose swapped window when navigating to current buffer 2021-01-19 12:14:43 -05:00
C. McEnroe 965b6987a9 Use Warm heat for manually inserted blank lines
Oops, forgot about these.
2021-01-19 10:50:55 -05:00
C. McEnroe 06683aa4e3 Use Warm heat for blank lines
So they're not hidden by M-+.
2021-01-17 00:35:59 -05:00
C. McEnroe 1a1fe1fb7a Save and load window visibility thresholds 2021-01-16 13:09:55 -05:00
C. McEnroe 43b1dba720 Restore toggling ignore with M--
So that pressing M-- repeatedly maintains the previous behavior.
2021-01-16 13:05:01 -05:00
C. McEnroe d05872303e Generalize ignore toggling to visibility threshold 2021-01-16 12:58:16 -05:00
C. McEnroe 51c92f94ff Save and load the URL ring in the save file 2021-01-11 18:05:22 -05:00
C. McEnroe 59006d18bb Avoid eating C-c while connecting
Split UI initialization into two steps either side of the call to
connect, so that C-c works as interrupt while it's blocked.
2020-10-12 19:25:08 -04:00
C. McEnroe c48672313b Factor out styleStrip 2020-10-09 18:45:52 -04:00
C. McEnroe ef59e235eb Silence set-but-unused warning
getyx is so annoying this way.
2020-09-09 18:04:41 -04:00