Commit graph

3897 commits

Author SHA1 Message Date
Russ Cox
43f1873709 acme: drop trailing spaces during Put of auto-indent window
Auto-indent mode leaves trailing spaces on blank lines
as you type past them, so silently elide them from the
window content as it gets written back to disk.

Another option would be to remove them from the
window entirely during Put, but they're actually nice
to have while editing, and to date Put has never
modified the window content.
2019-02-01 13:20:46 -05:00
Xiao-Yong
2607cc565e INSTALL: use cc to check for fontsrv on non-Darwin (#203)
FreeBSD 11.2 by default does not have gcc.
2018-11-16 10:14:49 -05:00
Xiao-Yong
74223e0b4f unix: fix for tar on FreeBSD (#202)
Use the widely accepted /dev/stdout.
2018-11-16 10:14:02 -05:00
Russ Cox
ad2d49503b INSTALL: set $NPROC on macOS
My MacBook Pro has hw.ncpu=12, so set NPROC=12.
Speeds up INSTALL dramatically.
Should probably add similar code to other OSes.

Also silence rio warning from earlier commit.
2018-11-16 00:03:24 -05:00
Russ Cox
16d0081989 libdraw: redo default font construction to be hidpi-safe
If $font is not set, the default font is constructed from
font data linked into every libdraw binary. That process
was different from the usual openfont code, and so it was
not hidpi-aware, resulting in very tiny fonts out of the box
on hidpi systems, until users set $font.

Fix this by using openfont to construct the default font,
by recognizing the name *default* when looking for
font and subfont file contents. Then all the hidpi scaling
applies automatically.

As a side effect, the concept of a 'default subfont' is gone,
as are display->defaultsubfont, getdefont, and memgetdefont.
2018-11-16 00:03:24 -05:00
Martin Kühl
3ebbb99ce3 file: recognize Mach-O binaries and Java class files 2018-11-15 22:12:48 -05:00
Martin Kühl
3ae09bee86 file: add missing newlines to file types 2018-11-15 22:11:47 -05:00
Tobias Heinicke
a309537fdc paint: add drawing program from 9front (#112)
Paint first appeared in 9front. The 9front license is reproduced
in the related source files - the original repository is located at
https://code.9front.org/hg/plan9front.
2018-11-15 22:10:26 -05:00
Russ Cox
c63d31a8c1 rio: make 'mk all' explain why it does nothing on non-x11 systems
Fixes #98.
2018-11-15 22:05:53 -05:00
Jacob Vosmaer
3d6fc088f0 devdraw: remove os x 10.5 compatibility code 2018-11-15 22:03:27 -05:00
Mat Kovach
4e2ac7657b unix: fix tar use in mkfile to allow Plan 9 tar 2018-11-15 22:00:49 -05:00
Russ Cox
43b0d532bd acme: add 32x32 boxcursor
The only difference from the upscaled 16x16
is a one-pixel adjustment in the offset position,
but this at least exercises setcursor2.
2018-11-15 20:52:18 -05:00
Russ Cox
fe92b4a0b1 INSTALL: set CC9 on macOS to use xcrun clang
Using plain 'clang' does not work well for the new devdraw on macOS 10.14.
But 'xcrun --sdk macosx clang' does work, for reasons no one understands.
Hopefully this will be OK on all macOS systems.
2018-11-15 20:39:35 -05:00
Russ Cox
7d43dde539 devdraw: add Cursor2 support on macOS 10.14 Mojave
This replaces the pixel-art scaling algorithm used for upscaling before.
The results were not crisp enough to serve as everyday cursors.
2018-11-15 20:39:35 -05:00
Russ Cox
be0a15c47b tweak: add support for Cursor2 2018-11-15 20:39:35 -05:00
Russ Cox
8581c2b567 libdraw: add Cursor2, a 32x32 high-res cursor
Also add setcursor2, esetcursor2, and draw protocol encoding.
Calls to the old setcursor, esetcursor create a 32x32 by
pixel doubling when needed.
2018-11-15 20:39:35 -05:00
Xiao-Yong Jin
9af9ceca26 devdraw: rewrite the Cocoa screen using Metal
Add a new macOS cocoa screen, cocoa-screen-metal.m.
Rewrite the macOS cocoa drawing code to use the builtin runloop,
and use Metal to push pixels with CAMetalLayer.

Remove all of the deprecated code, and simplify some of the logic.
Modify mkwsysrules.sh such that the new code is used only when
the system version is equal or higher than 10.14.

Allow touch events to simulate mouse clicks:
three finger tap for the middle mouse button;
four finger tap for the 2-1 chord.

Support Tresize.

Scale 16x16 Cursor up to 32x32 with an EPX algorithm.

Support macOS input sources including the basic dead keys and the
advanced CJK input methods.

Increase the communication buffers in cocoa-srv.c to allow more
input, especially for long sentences prepared by the macOS input
souces.
2018-11-15 20:39:35 -05:00
Zach Scott
de43b1629d upas/smtp: fix TLS connections (#163)
Both `upas/nfs` and `upas/smtp` call the currently broken `tlsClient()`
from libsec. This commit copies a fix from upas/nfs into upas/smtp.

In `imapdial()`, upas/nfs replaces a process call for tlsClient with
`stunnel3` when not on Plan 9. upas/smtp calls tlsClient directly
as a function, so imapdial was copied into mxdial.c as `smtpdial()`,
and tlsClient+dial replaced with a call to smtpdial.
2018-11-14 00:24:07 -05:00
Francis Conti
9c38253d1d INSTALL: fix compiler detection on FreeBSD+clang (#177) 2018-11-14 00:23:40 -05:00
Gabriel Díaz
000c1a3b19 devdraw: set displaydpi on devdraw x11 attach (#178)
See https://plan9port-review.googlesource.com/c/plan9/+/1470
for discussion of the approach, especially Michael Stapleberg's comment:

Note that chromium, firefox and others have tried this and then switched to using the Xft.dpi X resource, see e.g. https://code.google.com/p/chromium/codesearch#chromium/src/chrome/browser/ui/libgtk2ui/gtk2_ui.cc and especially http://sources.debian.net/src/gnome-settings-daemon/3.18.2-1/plugins/xsettings/gsd-xsettings-manager.c/?hl=824#L80 for some anecdata about why this approach doesn’t work out.

The Xft.dpi resource is being set accurately by desktop environments (GNOME, KDE, …) and can easily be changed by users of niche window managers by editing ~/.Xresources.

I suggest we check only Xft.dpi, without considering the DPI environment variable or the monitor width/height.
2018-11-14 00:19:29 -05:00
Russ Cox
a791787a38 mac/9term.app: invoke 9term with -l
This seems to match Terminal.

Fixes #145.
2018-11-14 00:13:01 -05:00
Russ Cox
d3f21b709e 9term: make 9term -l invoke $SHELL with -l 2018-11-14 00:13:01 -05:00
Russ Cox
2ba6fa9a65 web: allow any $BROWSER
Fixes #118.
2018-11-14 00:04:07 -05:00
iru-
ed959cfba3 fontsrv: increase x11 font height scale (#111) 2018-11-14 00:01:04 -05:00
KADOTA, Kyohei
f3ed5754b1 9term.app: add $PLAN9/bin to $PATH if not already in $PATH (#144)
9term set $PLAN9 if PLAN9 is not set. But $PATH is not set.
As a result, 9term exits with "exec devdraw: No such file or directory"
2018-11-13 23:59:49 -05:00
Martin Kühl
73ea36569e plumb/basic: avoid wrap around in file:1:2 (#158)
Fixes #122, #140.

As reported in #122, `file:1:1` moves to the end of the file,
and `file:1:2` fails with “address out of range”.

I’ll use file:2:3 as an example so we can tell the line and column number apart.

What’s happening is this:
plumb/basic matches `2:3` using twocolonaddr (from plumb/fileaddr),
then sets addr to `2-#1+#3`
(the 1 is constant and was introduced because column numbers are 1-based).
Acme interprets this in three steps:

1. find the range (q0, q1) that contains line 2
2. create the range (q2, q2) where q2 = q0 - 1
3. create the range (q3, q3) where q3 = q2 + 3

The second step has a branch where if q0 == 0 and 1 > 0
(remember that 1 is constant and comes form plumb/basic),
q0 is set to the end of the file.
This makes addressing things at the end of the file easier.

The problem then is that if we select line 1,
which starts at the beginning of the file,
q0 is always 0 and the branch in step 2) will always be used.
`1:1` is interpreted as `1-#1+#1` which starts at 0, wraps around to the end of the file, then moves 1 character backwards and then forwards again, ending at the end of the file.
`1:2` is interpretes as `1-#1+#2` which starts at 0, wraps around to the end od the file, then moves 1 character backwards and tries moving 2 characters forwards beyond the end of the file, resulting in the out of range error.

In #140 @rsc proposed transforming `:X:Y` into `:X-#0+#Y-#1` instead since that
avoids wrapping around by not moving backwards at first.
This change modifies `plumb/basic` to do that.
2018-11-13 23:59:04 -05:00
Xiao-Yong
a9e66ffa4e devdraw: make ctrl generate 1-click while mouse down (#119)
This makes 2-1 chords possible with touchpad on a mac laptop.
2018-11-13 23:57:56 -05:00
thisrod
931c590611 keyboard: add compose sequences lc and rc for ceiling brackets (#126)
Change-Id: Ice1c8c9d15cc6febf32dc2b7c449d457acc319b6
2018-11-13 23:14:20 -05:00
Martin Kühl
c38ae2afb5 keyboard: add tab/untab symbols (#160) 2018-11-13 23:13:39 -05:00
Xiao-Yong
c82e11b24e fontsrv: x11 uses FC_POSTSCRIPT_NAME (#174)
This makes fontsrv use the PostScript font names on X11.
The PostScript font names contains only alphanumeric and
hyphens.  This allows us to use the Font command in acme.
It also matches the font names used by fontsrv on macOS,
which has been using PostScript font names.
2018-11-13 23:13:15 -05:00
Fazlul Shahriar
76b9347a5f acme: avoid division by zero when resizing col (#189)
To reproduce, create a column with at least two windows and resize
acme to have almost zero height.
2018-11-13 23:11:31 -05:00
Xiao-Yong
2419c93438 fontsrv: disable font smoothing on osx (#196)
macOS Mojave version 10.14 starts to disable font smoothing.
We disable font smoothing for OSX_VERSION >= 101400 to match the
system default font rendering.
It also makes the font rendering on macOS similar to that on X11.
2018-11-13 23:09:59 -05:00
Xiao-Yong
014fd65a5c 9term: fix getpts on FreeBSD 11.2 (#199)
Opening /dev/ptyXX files fails on recent
FreeBSD versions.

Following the same fix being applied to
Linux, OpenBSD, and Darwin, we use openpty
to open a pseudoterminal in openpts.
2018-11-13 23:09:10 -05:00
Russ Cox
13ed1c423e 9l: drop xcode text-based stub warning 2018-11-12 11:09:39 -05:00
Russ Cox
82abcd6fd6 plumb: allow @ in file names
Helps Go module download cache, Upspin, maybe others.
2018-11-12 11:09:39 -05:00
Fazlul Shahriar
48da9bd71d fontsrv: copy some fixes from OS X to X11
* Avoid allocating empty images by adding 1 to width/height. This was
  crashing fontsrv. The total width of the subfont image can be zero
  even if the characters are present in the font. For example, all the
  characters in x0300.bit (part of "Combining Diacritical Marks" Unicode
  block) have zero width.
* Make sure U+0000 is always present in the font, otherwise libdraw
  complains with: "stringwidth: bad character set for rune 0x0000 in ..."
* Use the same fallback glyph (pjw face) as OS X. This also fixes a bug
  where advance was set to the total width of subfont instead of the
  character.

Update #125 (most likely fixes the crash if in X11)

Change-Id: Icdc2b641b8b0c08644569006e91cf613b4d5477f
2018-10-05 23:38:31 +02:00
Charles Collicutt
db27122d39 upas/nfs: correctly quote IMAP LOGIN arguments
According to RFC 3501 the arguments to the LOGIN command should be
quoted strings (or length prefixed string literals). Without quoting,
authentication to some IMAP servers (e.g. Dovecot) will fail.
2018-10-05 18:15:28 +02:00
David du Colombier
93c75d2bad grep: update from Plan 9
This change fixes a segfault in grep -e when no argument
has been provided. Thanks to Sean Hinchee for reporting
this issue.

Fixes #186.
2018-10-01 17:20:35 +02:00
David du Colombier
de3b6d5848 libregexp: include stddef.h in lib9.std.h
Commit 2d82ef9d98 added ptrdiff_t in regcomp.c.
However, this change broke the build of the Unix
package because ptrdiff_t is defined in stddef.h.
2018-09-29 15:59:31 +02:00
Martin Kühl
a82a8b6368 acme: Apply each -/+ only once (#156)
When plumbing an address like `3-`, Acme selects line 1,
and similarly `3+` selects line 5.
The same problem can be observed for character addresses (`#123+`)
but _not_ for ones like `+`, `.+` or `/foo/+`:
The problem only occurs when a number is followed by a direction (`-`/`+`).

Following along with the example `3-` through `address` (in addr.c):
We read `3` into `c` and match the `case` on line 239.
The `while` loop on line 242ff reads additional digits into `c`
and puts the first non-digit back by decrementing the index `q`.
Then we find the range for line 3 on line 251 and continue.

On the next iteration, we set `prevc` to the last `c`,
but since that part read ahead _into `c`_,
`c` is currently the _next_ character we will read, `-`,
and now `prevc` is too.

Then in the case block (line 210) the condition on line 211 holds
and Acme believes that it has read two `-` in sequence
and modifies the range to account for the “first” `-`.
The “second” `-` gets applied after the loop is done, on line 292.

So the general problem is:
While reading numbers, Acme reads the next character after the number into `c`.
It decrements the counter to ensure it will read it again on the next iteration,
but it still uses it to update `prevc`.

This change solves the problem by reading digits into `nc` instead.
This variable is used to similar effect in the block for directions (line 212)
and fills the role of “local `c` that we can safely use to read ahead” nicely.
2018-09-19 23:19:36 +10:00
Igor Burago
df2d9ec9d1 fontsrv: omit box-drawing characters from line struts on macOS
For some fonts, using box-drawing characters in the representative
text for computing the line height results in it being uncomfortably
high. Replace them with accented capitals and tall lower-case letters
which lead to a more conservative increase in the line height.

Fixes #162.
2018-06-26 23:24:22 +02:00
Xiao-Yong Jin
03a8ec739a libdraw: fix error in the previous commit 2018-03-27 18:11:37 +02:00
Xiao-Yong Jin
96025b1ec8 mc: fix crash in acme with hidpi display 2018-03-27 15:16:10 +02:00
Xiao-Yong Jin
75ea8515a5 samterm: free some getenv results 2018-03-27 15:03:12 +02:00
Xiao-Yong Jin
edfe3c016f sam: freetmpstr instead of free 2018-03-27 15:03:12 +02:00
Xiao-Yong Jin
dc2a17b95c libdraw: fix some memory leaks in font handling 2018-03-27 15:03:12 +02:00
Xiao-Yong Jin
a3ec102dc7 fontsrv: fix some memory leaks 2018-03-27 15:03:12 +02:00
Xiao-Yong Jin
b2f6769830 devdraw: fix some memory leaks in x11 2018-03-27 15:03:12 +02:00
Xiao-Yong Jin
7ca1c90109 acme: fix some memory leaks 2018-03-27 15:03:12 +02:00
Xiao-Yong Jin
96dc233091 fontsrv: enlarge drawing buffer for subfonts on macOS
Double the width returned by CTFontGetBoundingBox when drawing.
Add box drawing characters for determining the line height.
Call freememimage(1) for the character memimage.

Fixes #18.
Fixes #120.
Fixes #146.
2018-03-27 15:02:33 +02:00