Fossil SCM

Minor tweaks to the Copy Buttons: restore the flipped button look, and shorten the sequence "copy-copy-button" for auto-generated IDs.

florian 2026-04-17 12:09 UTC trunk
Commit 2ce9ca95f79829056daa8f509f5fe04f7a44b061a2542f9b1388938a81b6c7b3
1 file changed +5 -3
+5 -3
--- src/style.c
+++ src/style.c
@@ -527,10 +527,11 @@
527527
va_list ap;
528528
char *zText;
529529
char *zResult = 0;
530530
char *zId = 0;
531531
Blob btn;
532
+ const char *zBtnClass = "copy-button";
532533
533534
va_start(ap,zTextFmt);
534535
zText = vmprintf(zTextFmt/*works-like:?*/,ap);
535536
va_end(ap);
536537
@@ -541,24 +542,25 @@
541542
}
542543
blob_init(&btn, 0, 0);
543544
blob_append_string(&btn, "<span class=\"nobr\">");
544545
if( zTargetId==0 ){
545546
static unsigned int cnt = 0;
546
- zId = mprintf("copy-button-id-%u", ++cnt);
547
+ zId = mprintf("content-id-%u", ++cnt);
547548
zTargetId = zId;
548549
}
549550
if( bAfter ){
550551
blob_appendf(&btn, "<span id=\"%h\">%s</span>",
551552
zTargetId, zText);
553
+ zBtnClass = "copy-button copy-button-flipped";
552554
}
553555
blob_appendf(&btn,
554556
"<button "
555
- "class=\"copy-button\" "
557
+ "class=\"%s\" "
556558
"id=\"copy-%h\" "
557559
"data-copytarget=\"%h\" "
558560
"data-copylength=\"%d\"",
559
- zTargetId, zTargetId, mxLength);
561
+ zBtnClass, zTargetId, zTargetId, mxLength);
560562
if( zToCopy ){
561563
blob_appendf(&btn," data-content=\"%h\"", zToCopy);
562564
}
563565
blob_append_string(&btn, "><span></span></button>");
564566
if( !bAfter ){
565567
--- src/style.c
+++ src/style.c
@@ -527,10 +527,11 @@
527 va_list ap;
528 char *zText;
529 char *zResult = 0;
530 char *zId = 0;
531 Blob btn;
 
532
533 va_start(ap,zTextFmt);
534 zText = vmprintf(zTextFmt/*works-like:?*/,ap);
535 va_end(ap);
536
@@ -541,24 +542,25 @@
541 }
542 blob_init(&btn, 0, 0);
543 blob_append_string(&btn, "<span class=\"nobr\">");
544 if( zTargetId==0 ){
545 static unsigned int cnt = 0;
546 zId = mprintf("copy-button-id-%u", ++cnt);
547 zTargetId = zId;
548 }
549 if( bAfter ){
550 blob_appendf(&btn, "<span id=\"%h\">%s</span>",
551 zTargetId, zText);
 
552 }
553 blob_appendf(&btn,
554 "<button "
555 "class=\"copy-button\" "
556 "id=\"copy-%h\" "
557 "data-copytarget=\"%h\" "
558 "data-copylength=\"%d\"",
559 zTargetId, zTargetId, mxLength);
560 if( zToCopy ){
561 blob_appendf(&btn," data-content=\"%h\"", zToCopy);
562 }
563 blob_append_string(&btn, "><span></span></button>");
564 if( !bAfter ){
565
--- src/style.c
+++ src/style.c
@@ -527,10 +527,11 @@
527 va_list ap;
528 char *zText;
529 char *zResult = 0;
530 char *zId = 0;
531 Blob btn;
532 const char *zBtnClass = "copy-button";
533
534 va_start(ap,zTextFmt);
535 zText = vmprintf(zTextFmt/*works-like:?*/,ap);
536 va_end(ap);
537
@@ -541,24 +542,25 @@
542 }
543 blob_init(&btn, 0, 0);
544 blob_append_string(&btn, "<span class=\"nobr\">");
545 if( zTargetId==0 ){
546 static unsigned int cnt = 0;
547 zId = mprintf("content-id-%u", ++cnt);
548 zTargetId = zId;
549 }
550 if( bAfter ){
551 blob_appendf(&btn, "<span id=\"%h\">%s</span>",
552 zTargetId, zText);
553 zBtnClass = "copy-button copy-button-flipped";
554 }
555 blob_appendf(&btn,
556 "<button "
557 "class=\"%s\" "
558 "id=\"copy-%h\" "
559 "data-copytarget=\"%h\" "
560 "data-copylength=\"%d\"",
561 zBtnClass, zTargetId, zTargetId, mxLength);
562 if( zToCopy ){
563 blob_appendf(&btn," data-content=\"%h\"", zToCopy);
564 }
565 blob_append_string(&btn, "><span></span></button>");
566 if( !bAfter ){
567

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button