Skip to content

Commit ebf8a6d

Browse files
committed
add cursor into the context menu
1 parent 96def73 commit ebf8a6d

2 files changed

Lines changed: 90 additions & 1 deletion

File tree

frontend/app/view/term/term-model.ts

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1033,6 +1033,91 @@ export class TermViewModel implements ViewModel {
10331033
});
10341034
},
10351035
});
1036+
const overrideCursor = blockData?.meta?.["term:cursor"] as string | null | undefined;
1037+
const overrideCursorBlink = blockData?.meta?.["term:cursorblink"] as boolean | null | undefined;
1038+
const isCursorDefault = overrideCursor == null && overrideCursorBlink == null;
1039+
// normalize for comparison: null/undefined/"block" all mean "block"
1040+
const effectiveCursor = overrideCursor === "underline" || overrideCursor === "bar" ? overrideCursor : "block";
1041+
const effectiveCursorBlink = overrideCursorBlink === true;
1042+
const cursorSubMenu: ContextMenuItem[] = [
1043+
{
1044+
label: "Default",
1045+
type: "checkbox",
1046+
checked: isCursorDefault,
1047+
click: () => {
1048+
RpcApi.SetMetaCommand(TabRpcClient, {
1049+
oref: WOS.makeORef("block", this.blockId),
1050+
meta: { "term:cursor": null, "term:cursorblink": null },
1051+
});
1052+
},
1053+
},
1054+
{
1055+
label: "Block",
1056+
type: "checkbox",
1057+
checked: !isCursorDefault && effectiveCursor === "block" && !effectiveCursorBlink,
1058+
click: () => {
1059+
RpcApi.SetMetaCommand(TabRpcClient, {
1060+
oref: WOS.makeORef("block", this.blockId),
1061+
meta: { "term:cursor": "block", "term:cursorblink": false },
1062+
});
1063+
},
1064+
},
1065+
{
1066+
label: "Block (Blinking)",
1067+
type: "checkbox",
1068+
checked: !isCursorDefault && effectiveCursor === "block" && effectiveCursorBlink,
1069+
click: () => {
1070+
RpcApi.SetMetaCommand(TabRpcClient, {
1071+
oref: WOS.makeORef("block", this.blockId),
1072+
meta: { "term:cursor": "block", "term:cursorblink": true },
1073+
});
1074+
},
1075+
},
1076+
{
1077+
label: "Bar",
1078+
type: "checkbox",
1079+
checked: !isCursorDefault && effectiveCursor === "bar" && !effectiveCursorBlink,
1080+
click: () => {
1081+
RpcApi.SetMetaCommand(TabRpcClient, {
1082+
oref: WOS.makeORef("block", this.blockId),
1083+
meta: { "term:cursor": "bar", "term:cursorblink": false },
1084+
});
1085+
},
1086+
},
1087+
{
1088+
label: "Bar (Blinking)",
1089+
type: "checkbox",
1090+
checked: !isCursorDefault && effectiveCursor === "bar" && effectiveCursorBlink,
1091+
click: () => {
1092+
RpcApi.SetMetaCommand(TabRpcClient, {
1093+
oref: WOS.makeORef("block", this.blockId),
1094+
meta: { "term:cursor": "bar", "term:cursorblink": true },
1095+
});
1096+
},
1097+
},
1098+
{
1099+
label: "Underline",
1100+
type: "checkbox",
1101+
checked: !isCursorDefault && effectiveCursor === "underline" && !effectiveCursorBlink,
1102+
click: () => {
1103+
RpcApi.SetMetaCommand(TabRpcClient, {
1104+
oref: WOS.makeORef("block", this.blockId),
1105+
meta: { "term:cursor": "underline", "term:cursorblink": false },
1106+
});
1107+
},
1108+
},
1109+
{
1110+
label: "Underline (Blinking)",
1111+
type: "checkbox",
1112+
checked: !isCursorDefault && effectiveCursor === "underline" && effectiveCursorBlink,
1113+
click: () => {
1114+
RpcApi.SetMetaCommand(TabRpcClient, {
1115+
oref: WOS.makeORef("block", this.blockId),
1116+
meta: { "term:cursor": "underline", "term:cursorblink": true },
1117+
});
1118+
},
1119+
},
1120+
];
10361121
fullMenu.push({
10371122
label: "Themes",
10381123
submenu: submenu,
@@ -1041,6 +1126,10 @@ export class TermViewModel implements ViewModel {
10411126
label: "Font Size",
10421127
submenu: fontSizeSubMenu,
10431128
});
1129+
fullMenu.push({
1130+
label: "Cursor",
1131+
submenu: cursorSubMenu,
1132+
});
10441133
fullMenu.push({
10451134
label: "Transparency",
10461135
submenu: transparencySubMenu,

frontend/app/view/term/termutil.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export function computeTheme(
4141
themeCopy.selectionBackground = applyTransparencyToColor(themeCopy.selectionBackground, termTransparency);
4242
}
4343
}
44-
let bgcolor = themeCopy.background;
44+
const bgcolor = themeCopy.background;
4545
themeCopy.background = "#00000000";
4646
return [themeCopy, bgcolor];
4747
}

0 commit comments

Comments
 (0)