aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPo Lu2024-04-28 12:57:33 +0000
committerPo Lu2024-04-28 12:57:33 +0000
commit9d9881aceaefef56687baeb75eef94be1c7b22af (patch)
tree44c1657b0ffa230aaf9a336c0137868c3ca6fc39 /src
parent94a9e41a9d333f946b74b175a8a7133595498805 (diff)
downloademacs-9d9881aceaefef56687baeb75eef94be1c7b22af.tar.gz
emacs-9d9881aceaefef56687baeb75eef94be1c7b22af.zip
Implement dots and dashes on Haiku
* src/doc.c (store_function_docstring): Re-enable loading doc strings of compiled functions from etc/DOC, which haiku-win, ns-win, and the like require. * src/haikuterm.c (haiku_draw_dash, haiku_fill_underline) (haiku_draw_text_decoration): Port underline code from X.
Diffstat (limited to 'src')
-rw-r--r--src/doc.c20
-rw-r--r--src/haikuterm.c96
2 files changed, 105 insertions, 11 deletions
diff --git a/src/doc.c b/src/doc.c
index b5a9ed498af..10afda73458 100644
--- a/src/doc.c
+++ b/src/doc.c
@@ -517,11 +517,27 @@ store_function_docstring (Lisp_Object obj, EMACS_INT offset)
517 if (CONSP (fun) && EQ (XCAR (fun), Qmacro)) 517 if (CONSP (fun) && EQ (XCAR (fun), Qmacro))
518 fun = XCDR (fun); 518 fun = XCDR (fun);
519 /* Lisp_Subrs have a slot for it. */ 519 /* Lisp_Subrs have a slot for it. */
520 if (SUBRP (fun) && !SUBR_NATIVE_COMPILEDP (fun)) 520 if (SUBRP (fun))
521 XSUBR (fun)->doc = offset; 521 XSUBR (fun)->doc = offset;
522 else if (COMPILEDP (fun))
523 {
524 /* This bytecode object must have a slot for the docstring, since
525 we've found a docstring for it. */
526 if (PVSIZE (fun) > COMPILED_DOC_STRING
527 /* Don't overwrite a non-docstring value placed there, such as
528 the symbols used for Oclosures. */
529 && VALID_DOCSTRING_P (AREF (fun, COMPILED_DOC_STRING)))
530 ASET (fun, COMPILED_DOC_STRING, make_fixnum (offset));
531 else
532 {
533 AUTO_STRING (format, "No doc string slot for compiled: %S");
534 CALLN (Fmessage, format, obj);
535 }
536 }
522 else 537 else
523 { 538 {
524 AUTO_STRING (format, "Ignoring DOC string on non-subr: %S"); 539 AUTO_STRING (format, "Ignoring DOC string on non-compiled"
540 "non-subr: %S");
525 CALLN (Fmessage, format, obj); 541 CALLN (Fmessage, format, obj);
526 } 542 }
527} 543}
diff --git a/src/haikuterm.c b/src/haikuterm.c
index 158ec68a44b..b960e36ef26 100644
--- a/src/haikuterm.c
+++ b/src/haikuterm.c
@@ -804,6 +804,86 @@ haiku_draw_underwave (struct glyph_string *s, int width, int x)
804 BView_EndClip (view); 804 BView_EndClip (view);
805} 805}
806 806
807/* Draw a dashed underline of thickness THICKNESS and width WIDTH onto F
808 at a vertical offset of OFFSET from the position of the glyph string
809 S, with each segment SEGMENT pixels in length. */
810
811static void
812haiku_draw_dash (struct frame *f, struct glyph_string *s, int width,
813 int segment, int offset, int thickness)
814{
815 int y_center, which, length, x, doffset;
816 void *view;
817
818 /* Configure the thickness of the view's strokes. */
819 view = FRAME_HAIKU_VIEW (s->f);
820 BView_SetPenSize (view, thickness);
821
822 /* Offset the origin of the line by half the line width. */
823 y_center = s->ybase + offset + thickness / 2;
824
825 /* Remove redundant portions of OFFSET. */
826 doffset = s->x % (segment * 2);
827
828 /* Set which to the phase of the first dash that ought to be drawn and
829 length to its length. */
830 which = doffset < segment;
831 length = segment - (s->x % segment);
832
833 /* Begin drawing this dash. */
834 for (x = s->x; x < s->x + width; x += length, length = segment)
835 {
836 if (which)
837 BView_StrokeLine (view, x, y_center,
838 min (x + length - 1,
839 s->x + width - 1),
840 y_center);
841
842 which = !which;
843 }
844}
845
846/* Draw an underline of STYLE onto F at an offset of POSITION from the
847 baseline of the glyph string S, S->WIDTH in length, and THICKNESS in
848 height. */
849
850static void
851haiku_fill_underline (struct frame *f, struct glyph_string *s,
852 enum face_underline_type style, int position,
853 int thickness)
854{
855 int segment;
856 void *view;
857
858 segment = thickness * 3;
859 view = FRAME_HAIKU_VIEW (s->f);
860
861 switch (style)
862 {
863 /* FACE_UNDERLINE_DOUBLE_LINE is treated identically to SINGLE, as
864 the second line will be filled by another invocation of this
865 function. */
866 case FACE_UNDERLINE_SINGLE:
867 case FACE_UNDERLINE_DOUBLE_LINE:
868 BView_FillRectangle (view, s->x, s->ybase + position,
869 s->width, thickness);
870 break;
871
872 case FACE_UNDERLINE_DOTS:
873 segment = thickness;
874 FALLTHROUGH;
875
876 case FACE_UNDERLINE_DASHES:
877 haiku_draw_dash (f, s, s->width, segment, position, thickness);
878 break;
879
880 case FACE_NO_UNDERLINE:
881 case FACE_UNDERLINE_WAVE:
882 default:
883 emacs_abort ();
884 }
885}
886
807static void 887static void
808haiku_draw_text_decoration (struct glyph_string *s, struct face *face, 888haiku_draw_text_decoration (struct glyph_string *s, struct face *face,
809 int width, int x) 889 int width, int x)
@@ -829,15 +909,13 @@ haiku_draw_text_decoration (struct glyph_string *s, struct face *face,
829 909
830 if (face->underline == FACE_UNDERLINE_WAVE) 910 if (face->underline == FACE_UNDERLINE_WAVE)
831 haiku_draw_underwave (s, width, x); 911 haiku_draw_underwave (s, width, x);
832 else if (face->underline == FACE_UNDERLINE_SINGLE 912 else if (face->underline >= FACE_UNDERLINE_SINGLE)
833 || face->underline == FACE_UNDERLINE_DOUBLE_LINE)
834 { 913 {
835 unsigned long thickness, position; 914 unsigned long thickness, position;
836 int y;
837 915
838 if (s->prev 916 if (s->prev
839 && (s->prev->face->underline == FACE_UNDERLINE_SINGLE 917 && (s->prev->face->underline != FACE_UNDERLINE_WAVE
840 || s->prev->face->underline == FACE_UNDERLINE_DOUBLE_LINE) 918 && s->prev->face->underline >= FACE_UNDERLINE_SINGLE)
841 && (s->prev->face->underline_at_descent_line_p 919 && (s->prev->face->underline_at_descent_line_p
842 == s->face->underline_at_descent_line_p) 920 == s->face->underline_at_descent_line_p)
843 && (s->prev->face->underline_pixels_above_descent_line 921 && (s->prev->face->underline_pixels_above_descent_line
@@ -910,9 +988,9 @@ haiku_draw_text_decoration (struct glyph_string *s, struct face *face,
910 thickness = (s->y + s->height) - (s->ybase + position); 988 thickness = (s->y + s->height) - (s->ybase + position);
911 s->underline_thickness = thickness; 989 s->underline_thickness = thickness;
912 s->underline_position = position; 990 s->underline_position = position;
913 y = s->ybase + position;
914 991
915 BView_FillRectangle (view, s->x, y, s->width, thickness); 992 haiku_fill_underline (view, s, s->face->underline,
993 position, thickness);
916 994
917 /* Place a second underline above the first if this was 995 /* Place a second underline above the first if this was
918 requested in the face specification. */ 996 requested in the face specification. */
@@ -921,8 +999,8 @@ haiku_draw_text_decoration (struct glyph_string *s, struct face *face,
921 { 999 {
922 /* Compute the position of the second underline. */ 1000 /* Compute the position of the second underline. */
923 position = position - thickness - 1; 1001 position = position - thickness - 1;
924 y = s->ybase + position; 1002 haiku_fill_underline (view, s, s->face->underline,
925 BView_FillRectangle (view, s->x, y, s->width, thickness); 1003 position, thickness);
926 } 1004 }
927 } 1005 }
928 } 1006 }