From fd471e6b8e49fcbf0730e8030276fac6b3dff7bb Mon Sep 17 00:00:00 2001 From: Kevin Daily Date: Mon, 25 Nov 2024 14:10:09 -0800 Subject: [PATCH 1/7] Add string resource template for workspace insert-evaluate tooltip --- FrontEnd/TextResources/ChatbookStrings.tr | 1 + FrontEnd/TextResources/ChineseSimplified/ChatbookStrings.tr | 1 + FrontEnd/TextResources/ChineseTraditional/ChatbookStrings.tr | 1 + FrontEnd/TextResources/French/ChatbookStrings.tr | 1 + FrontEnd/TextResources/Japanese/ChatbookStrings.tr | 1 + FrontEnd/TextResources/Korean/ChatbookStrings.tr | 1 + FrontEnd/TextResources/Spanish/ChatbookStrings.tr | 1 + 7 files changed, 7 insertions(+) diff --git a/FrontEnd/TextResources/ChatbookStrings.tr b/FrontEnd/TextResources/ChatbookStrings.tr index 4137518f..687b7666 100644 --- a/FrontEnd/TextResources/ChatbookStrings.tr +++ b/FrontEnd/TextResources/ChatbookStrings.tr @@ -62,6 +62,7 @@ "FormattingCopyToClipboardLabel" -> "Copy", "FormattingInsertContentLabel" -> "Insert", "FormattingInsertContentAndEvaluateTooltip" -> "Insert content as new input cell below and evaluate", +"FormattingInsertContentAndEvaluateWorkspaceChatTooltip" -> "Insert this into `1` and evaluate.", "FormattingCopyToClipboardTooltip" -> "Copy to clipboard", "FormattingInsertContentTooltip" -> "Insert content as new input cell below", "FormattingToolUsing" -> "Using ", diff --git a/FrontEnd/TextResources/ChineseSimplified/ChatbookStrings.tr b/FrontEnd/TextResources/ChineseSimplified/ChatbookStrings.tr index 0d8865c8..c0e94c23 100644 --- a/FrontEnd/TextResources/ChineseSimplified/ChatbookStrings.tr +++ b/FrontEnd/TextResources/ChineseSimplified/ChatbookStrings.tr @@ -62,6 +62,7 @@ "FormattingCopyToClipboardLabel" -> "\:590D\:5236", "FormattingInsertContentLabel" -> "\:63D2\:5165", "FormattingInsertContentAndEvaluateTooltip" -> "\:5728\:4E0B\:9762\:63D2\:5165\:5185\:5BB9\:4F5C\:4E3A\:65B0\:7684\:8F93\:5165\:5355\:5143\:5E76\:8BA1\:7B97", +"FormattingInsertContentAndEvaluateWorkspaceChatTooltip" -> "Insert this into `1` and evaluate.", "FormattingCopyToClipboardTooltip" -> "\:590D\:5236\:5230\:526A\:8D34\:677F", "FormattingInsertContentTooltip" -> "\:5728\:4E0B\:9762\:63D2\:5165\:5185\:5BB9\:4F5C\:4E3A\:65B0\:7684\:8F93\:5165\:5355\:5143", "FormattingToolUsing" -> "\:4F7F\:7528 ", diff --git a/FrontEnd/TextResources/ChineseTraditional/ChatbookStrings.tr b/FrontEnd/TextResources/ChineseTraditional/ChatbookStrings.tr index 8a655209..cf7d804d 100644 --- a/FrontEnd/TextResources/ChineseTraditional/ChatbookStrings.tr +++ b/FrontEnd/TextResources/ChineseTraditional/ChatbookStrings.tr @@ -62,6 +62,7 @@ "FormattingCopyToClipboardLabel" -> "\:8907\:88FD", "FormattingInsertContentLabel" -> "\:63D2\:5165", "FormattingInsertContentAndEvaluateTooltip" -> "\:63D2\:5165\:5982\:540C\:5728\:4E0B\:65B9\:65B0\:589E\:8F38\:5165\:5132\:5B58\:683C\:7684\:5167\:5BB9\:4E26\:9032\:884C\:8A08\:7B97", +"FormattingInsertContentAndEvaluateWorkspaceChatTooltip" -> "Insert this into `1` and evaluate.", "FormattingCopyToClipboardTooltip" -> "\:8907\:88FD\:81F3\:526A\:8CBC\:7C3F", "FormattingInsertContentTooltip" -> "\:63D2\:5165\:5982\:540C\:5728\:4E0B\:65B9\:65B0\:589E\:8F38\:5165\:5132\:5B58\:683C\:7684\:5167\:5BB9", "FormattingToolUsing" -> "\:6B63\:5728\:4F7F\:7528 ", diff --git a/FrontEnd/TextResources/French/ChatbookStrings.tr b/FrontEnd/TextResources/French/ChatbookStrings.tr index d810ef90..a45bc53a 100644 --- a/FrontEnd/TextResources/French/ChatbookStrings.tr +++ b/FrontEnd/TextResources/French/ChatbookStrings.tr @@ -62,6 +62,7 @@ "FormattingCopyToClipboardLabel" -> "Copier", "FormattingInsertContentLabel" -> "Ins\[EAcute]rer", "FormattingInsertContentAndEvaluateTooltip" -> "Ins\[EAcute]rer le contenu en tant que nouvelle cellule d\[CloseCurlyQuote]entr\[EAcute]e ci-dessous et l\[CloseCurlyQuote]\[EAcute]valuer", +"FormattingInsertContentAndEvaluateWorkspaceChatTooltip" -> "Insert this into `1` and evaluate.", "FormattingCopyToClipboardTooltip" -> "Copier dans le presse-papiers", "FormattingInsertContentTooltip" -> "Ins\[EAcute]rer le contenu en tant que nouvelle cellule d\[CloseCurlyQuote]entr\[EAcute]e ci-dessous", "FormattingToolUsing" -> "Utilisation de ", diff --git a/FrontEnd/TextResources/Japanese/ChatbookStrings.tr b/FrontEnd/TextResources/Japanese/ChatbookStrings.tr index 4150aa64..7dcd4f86 100644 --- a/FrontEnd/TextResources/Japanese/ChatbookStrings.tr +++ b/FrontEnd/TextResources/Japanese/ChatbookStrings.tr @@ -62,6 +62,7 @@ "FormattingCopyToClipboardLabel" -> "\:30b3\:30d4\:30fc", "FormattingInsertContentLabel" -> "\:633f\:5165", "FormattingInsertContentAndEvaluateTooltip" -> "\:30b3\:30f3\:30c6\:30f3\:30c4\:3092\:65b0\:898f\:306e\:5165\:529b\:30bb\:30eb\:3068\:3057\:3066\:4e0b\:306b\:633f\:5165\:3057\:8a55\:4fa1\:3059\:308b", +"FormattingInsertContentAndEvaluateWorkspaceChatTooltip" -> "Insert this into `1` and evaluate.", "FormattingCopyToClipboardTooltip" -> "\:30af\:30ea\:30c3\:30d7\:30dc\:30fc\:30c9\:306b\:30b3\:30d4\:30fc", "FormattingInsertContentTooltip" -> "\:30b3\:30f3\:30c6\:30f3\:30c4\:3092\:65b0\:898f\:306e\:5165\:529b\:30bb\:30eb\:3068\:3057\:3066\:4e0b\:306b\:633f\:5165\:3059\:308b", "FormattingToolUsing" -> "\:4f7f\:7528\:4e2d\:ff1a", diff --git a/FrontEnd/TextResources/Korean/ChatbookStrings.tr b/FrontEnd/TextResources/Korean/ChatbookStrings.tr index cd35e825..63cd4d82 100644 --- a/FrontEnd/TextResources/Korean/ChatbookStrings.tr +++ b/FrontEnd/TextResources/Korean/ChatbookStrings.tr @@ -63,6 +63,7 @@ "FormattingInsertContentLabel" -> "\:633F\:5165", "FormattingInsertContentAndEvaluateTooltip" -> "\:C544\:B798\:C5D0 \:CF58\:D150\:CE20\:B97C \:C0C8 \:C785\:B825 \ \:C140\:B85C \:C0BD\:C785\:D558\:ACE0 \:D3C9\:AC00", +"FormattingInsertContentAndEvaluateWorkspaceChatTooltip" -> "Insert this into `1` and evaluate.", "FormattingCopyToClipboardTooltip" -> "\:D074\:B9BD\:BCF4\:B4DC\:C5D0 \:BCF5\:C0AC", "FormattingInsertContentTooltip" -> "\:CF58\:D150\:CE20\:B97C \:C0C8 \:C785\:B825 \:C140\:B85C \:C544\:B798\:C5D0 \:C0BD\:C785", "FormattingToolUsing" -> "\:C0AC\:C6A9\:C911 ", diff --git a/FrontEnd/TextResources/Spanish/ChatbookStrings.tr b/FrontEnd/TextResources/Spanish/ChatbookStrings.tr index 73d5ba5a..bc6fd064 100644 --- a/FrontEnd/TextResources/Spanish/ChatbookStrings.tr +++ b/FrontEnd/TextResources/Spanish/ChatbookStrings.tr @@ -62,6 +62,7 @@ "FormattingCopyToClipboardLabel" -> "Copiar", "FormattingInsertContentLabel" -> "Insertar", "FormattingInsertContentAndEvaluateTooltip" -> "Insertar contenido como una nueva celda de entrada debajo y evaluar", +"FormattingInsertContentAndEvaluateWorkspaceChatTooltip" -> "Insert this into `1` and evaluate.", "FormattingCopyToClipboardTooltip" -> "Copiar al portapapeles", "FormattingInsertContentTooltip" -> "Insertar contenido como una nueva celda de entrada debajo", "FormattingToolUsing" -> "Utilizando ", From 3432e69e7d2268be3247005f860017b07ccaa7b6 Mon Sep 17 00:00:00 2001 From: Kevin Daily Date: Mon, 25 Nov 2024 14:11:27 -0800 Subject: [PATCH 2/7] Add updated workspace code block icons --- .../CodeBlocks/WorkspaceCodeBlockCopy.wl | 50 ++++++++++++++ .../WorkspaceCodeBlockInsertAndEvaluate.wl | 32 +++++++++ FrontEnd/TextResources/ChatbookResources.tr | 67 ++++++++++++++++++- 3 files changed, 148 insertions(+), 1 deletion(-) create mode 100644 Developer/Resources/FrontEndResources/WorkspaceChat/CodeBlocks/WorkspaceCodeBlockCopy.wl create mode 100644 Developer/Resources/FrontEndResources/WorkspaceChat/CodeBlocks/WorkspaceCodeBlockInsertAndEvaluate.wl diff --git a/Developer/Resources/FrontEndResources/WorkspaceChat/CodeBlocks/WorkspaceCodeBlockCopy.wl b/Developer/Resources/FrontEndResources/WorkspaceChat/CodeBlocks/WorkspaceCodeBlockCopy.wl new file mode 100644 index 00000000..1edede37 --- /dev/null +++ b/Developer/Resources/FrontEndResources/WorkspaceChat/CodeBlocks/WorkspaceCodeBlockCopy.wl @@ -0,0 +1,50 @@ +(* Created with the Wolfram Language : www.wolfram.com *) +RawBoxes @ ToBoxes @ +Graphics[{Thickness[0.125], + Style[{FilledCurve[{{{0, 2, 0}, {0, 1, 0}, {0, 1, 0}, {0, 1, 0}}, + {{0, 2, 0}, {0, 1, 0}, {0, 1, 0}, {0, 1, 0}}, {{0, 2, 0}, {0, 1, 0}, + {0, 1, 0}, {0, 1, 0}}, {{0, 2, 0}, {0, 1, 0}, {0, 1, 0}, {0, 1, 0}}, + {{0, 2, 0}, {0, 1, 0}, {0, 1, 0}, {0, 1, 0}}, {{0, 2, 0}, {1, 3, 3}, + {0, 1, 0}, {1, 3, 3}, {0, 1, 0}, {0, 1, 0}, {0, 1, 0}, {0, 1, 0}, + {0, 1, 0}, {1, 3, 3}, {0, 1, 0}, {1, 3, 3}, {0, 1, 0}, {1, 3, 3}, + {0, 1, 0}, {1, 3, 3}, {0, 1, 0}, {1, 3, 3}, {0, 1, 0}, {1, 3, 3}}}, + {{{6.822000026702881, 6.291999816894531}, {1.1779999732971191, + 6.291999816894531}, {1.1779999732971191, 7.008999824523926}, + {6.822000026702881, 7.008999824523926}, {6.822000026702881, + 6.291999816894531}}, {{6.822000026702881, 4.8580002784729}, + {1.1779999732971191, 4.8580002784729}, {1.1779999732971191, + 5.575000286102295}, {6.822000026702881, 5.575000286102295}, + {6.822000026702881, 4.8580002784729}}, + {{6.822000026702881, 3.4250001907348633}, {1.1779999732971191, + 3.4250001907348633}, {1.1779999732971191, 4.142000198364258}, + {6.822000026702881, 4.142000198364258}, {6.822000026702881, + 3.4250001907348633}}, {{6.822000026702881, 1.9910001754760742}, + {1.1779999732971191, 1.9910001754760742}, {1.1779999732971191, + 2.7080001831054688}, {6.822000026702881, 2.7080001831054688}, + {6.822000026702881, 1.9910001754760742}}, + {{2.800999879837036, 9.597000122070312}, {5.199999809265137, + 9.597000122070312}, {5.599999904632568, 8.79699993133545}, + {2.4010000228881836, 8.79699993133545}, {2.800999879837036, + 9.597000122070312}}, {{7.5, 9.}, {6.357000350952148, 9.}, + {6.3429999351501465, 9.052000045776367}, {6.340000152587891, + 9.105000495910645}, {6.315000534057617, 9.155000686645508}, + {5.914000511169434, 9.955999374389648}, {5.779999732971191, + 10.22700023651123}, {5.501999855041504, 10.398000717163086}, + {5.198999881744385, 10.397000312805176}, {4.801000118255615, + 10.397000312805176}, {4.801000118255615, 11.197000503540039}, + {3.2009999752044678, 11.197000503540039}, {3.2009999752044678, + 10.397000312805176}, {2.800999879837036, 10.397000312805176}, + {2.497999906539917, 10.398000717163086}, {2.2209999561309814, + 10.22700023651123}, {2.0850000381469727, 9.954999923706055}, + {1.6850000619888306, 9.155000686645508}, {1.6610000133514404, + 9.105999946594238}, {1.6660000085830688, 9.052000045776367}, + {1.6519999504089355, 9.}, {0.5, 9.}, {0.2239999920129776, 9.}, + {0., 8.775999069213867}, {0., 8.5}, {0., 0.5}, + {0., 0.2239999920129776}, {0.2239999920129776, 0.}, {0.5, 0.}, + {7.5, 0.}, {7.776000022888184, 0.}, {8., 0.2239999920129776}, + {8., 0.5}, {8., 8.5}, {8., 8.775999069213867}, + {7.776000022888184, 9.}, {7.5, 9.}}}]}, + FaceForm[RGBColor[0.2901960784313726, 0.5843137254901961, 0.8, 1.]]]}, + ImageSize -> {9., 13.}, PlotRange -> {{-0.5, 8.5}, + {-0.5, 11.697400093078613}}, AspectRatio -> Automatic, + BaselinePosition -> Center -> Center] diff --git a/Developer/Resources/FrontEndResources/WorkspaceChat/CodeBlocks/WorkspaceCodeBlockInsertAndEvaluate.wl b/Developer/Resources/FrontEndResources/WorkspaceChat/CodeBlocks/WorkspaceCodeBlockInsertAndEvaluate.wl new file mode 100644 index 00000000..6a6f4e22 --- /dev/null +++ b/Developer/Resources/FrontEndResources/WorkspaceChat/CodeBlocks/WorkspaceCodeBlockInsertAndEvaluate.wl @@ -0,0 +1,32 @@ +(* Created with the Wolfram Language : www.wolfram.com *) +RawBoxes @ ToBoxes @ +Graphics[{Thickness[0.07016411257027613], + Style[{JoinedCurve[{{{0, 2, 0}, {0, 1, 0}, {0, 1, 0}, {0, 1, 0}, {0, 1, 0}, + {0, 1, 0}, {0, 1, 0}, {0, 1, 0}, {0, 1, 0}, {0, 1, 0}, {0, 1, 0}, + {0, 1, 0}, {0, 1, 0}, {0, 1, 0}, {0, 1, 0}, {0, 1, 0}, {0, 1, 0}, + {0, 1, 0}, {0, 1, 0}, {0, 1, 0}}}, + {{{7.126100063323975, 14.347000122070312}, {5.716100096702576, + 11.91700005531311}, {3.158100128173828, 13.049000024795532}, + {3.4361002445220947, 10.248000144958496}, {0.7041001319885254, + 9.64900016784668}, {2.5631003379821777, 7.548000335693359}, + {0.7041001319885254, 5.446000099182129}, {3.4351003170013428, + 4.8470001220703125}, {3.156100034713745, 2.045999526977539}, + {5.716100096702576, 3.177000045776367}, {7.126100063323975, + 0.7469997406005859}, {8.536100029945374, 3.175999641418457}, + {11.094099998474121, 2.0450000762939453}, {10.816099882125854, + 4.845000267028809}, {13.548099994659424, 5.445000648498535}, + {11.689099788665771, 7.546000003814697}, {13.548099994659424, + 9.648000240325928}, {10.817099809646606, 10.247000217437744}, + {11.096100091934204, 13.04800009727478}, {8.536100029945374, + 11.91700005531311}, {7.126100063323975, 14.347000122070312}}}, + CurveClosed -> {1}]}, CapForm["Butt"], JoinForm[{"Miter", 1.}], + Thickness[0.05262308442770709], RGBColor[0.2901960784313726, + 0.5843137254901961, 0.8, 1.]], + Style[{FilledCurve[{{{0, 2, 0}, {0, 1, 0}, {0, 1, 0}}}, + {{{5.526100158691406, 10.766900062561035}, {5.526100158691406, + 4.3668999671936035}, {10.32610034942627, 7.582900285720825}, + {5.526100158691406, 10.766900062561035}}}]}, + FaceForm[RGBColor[0.2901960784313726, 0.5843137254901961, 0.8, 1.]]]}, + ImageSize -> {16., 17.}, PlotRange -> {{-0.5, 14.752300262451172}, + {-0.5, 15.594200134277344}}, AspectRatio -> Automatic, + BaselinePosition -> Center -> Center] diff --git a/FrontEnd/TextResources/ChatbookResources.tr b/FrontEnd/TextResources/ChatbookResources.tr index 2f719cc3..9aa582d8 100644 --- a/FrontEnd/TextResources/ChatbookResources.tr +++ b/FrontEnd/TextResources/ChatbookResources.tr @@ -6282,7 +6282,72 @@ TD2Mb3lNEkxzlMqBaSGoOMw9MD7MvTC+5EEUPjx8oOahhB8ACaE9/g== Background->GrayLevel[1, 0], BaseStyle->GrayLevel[1, 0], ImageSize->{168., 78.}, - PlotRange->{{-0.5, 167.5}, {-0.5, 77.5}}] + PlotRange->{{-0.5, 167.5}, {-0.5, 77.5}}], + +"WorkspaceCodeBlockCopy" -> GraphicsBox[ + {Thickness[0.125], FaceForm[{RGBColor[ + 0.2901960784313726, 0.5843137254901961, 0.8], Opacity[1.]}], + FilledCurveBox[{{{0, 2, 0}, {0, 1, 0}, {0, 1, 0}, {0, 1, 0}}, {{0, 2, 0}, { + 0, 1, 0}, {0, 1, 0}, {0, 1, 0}}, {{0, 2, 0}, {0, 1, 0}, {0, 1, 0}, {0, 1, + 0}}, {{0, 2, 0}, {0, 1, 0}, {0, 1, 0}, {0, 1, 0}}, {{0, 2, 0}, {0, 1, + 0}, {0, 1, 0}, {0, 1, 0}}, {{0, 2, 0}, {1, 3, 3}, {0, 1, 0}, {1, 3, 3}, { + 0, 1, 0}, {0, 1, 0}, {0, 1, 0}, {0, 1, 0}, {0, 1, 0}, {1, 3, 3}, {0, 1, + 0}, {1, 3, 3}, {0, 1, 0}, {1, 3, 3}, {0, 1, 0}, {1, 3, 3}, {0, 1, 0}, {1, + 3, 3}, {0, 1, 0}, {1, 3, 3}}}, {{{6.822000026702881, + 6.291999816894531}, {1.1779999732971191`, 6.291999816894531}, { + 1.1779999732971191`, 7.008999824523926}, {6.822000026702881, + 7.008999824523926}, {6.822000026702881, 6.291999816894531}}, {{ + 6.822000026702881, 4.8580002784729}, {1.1779999732971191`, + 4.8580002784729}, {1.1779999732971191`, 5.575000286102295}, { + 6.822000026702881, 5.575000286102295}, {6.822000026702881, + 4.8580002784729}}, {{6.822000026702881, 3.4250001907348633`}, { + 1.1779999732971191`, 3.4250001907348633`}, {1.1779999732971191`, + 4.142000198364258}, {6.822000026702881, 4.142000198364258}, { + 6.822000026702881, 3.4250001907348633`}}, {{6.822000026702881, + 1.9910001754760742`}, {1.1779999732971191`, 1.9910001754760742`}, { + 1.1779999732971191`, 2.7080001831054688`}, {6.822000026702881, + 2.7080001831054688`}, {6.822000026702881, 1.9910001754760742`}}, {{ + 2.800999879837036, 9.597000122070312}, {5.199999809265137, + 9.597000122070312}, {5.599999904632568, 8.79699993133545}, { + 2.4010000228881836`, 8.79699993133545}, {2.800999879837036, + 9.597000122070312}}, CompressedData[" +1:eJxTTMoPSmViYGBQBWIQDQFyDhBaCUQ3TMyVROYnWMeD+QfmS4H5DJoxYP6C +Q6YQ9f1OYL5DjD+Yf+D9cnEwXfFSGSy+Qw7MT7AsUQHzeZjEwPLHToP5C46d +FgHTzhB+gqWJMDa+w90UNRD9YOlsTmx8mPoFRRlsKPqf/2ZGsW/2EUZk9zSI +rGMAy399oQzx19df9sj+KZkM5i9wNQPzF7xfDubDwqNheh6YDwsvkJOQ+Qoc +a86gyYPBAf9eRWQ+EKDzYeaAAcwcJPOwqmNAxCfEnvlS8mjmKqC5SwHN3TA+ +zD1gPsy9SObB/INIPwC/b2f2 + "]}]}, + AspectRatio->Automatic, + BaselinePosition->(Center -> Center), + ImageSize->{9., 13.}, + PlotRange->{{-0.5, 8.5}, {-0.5, 11.697400093078613`}}], + +"WorkspaceCodeBlockInsertAndEvaluate" -> GraphicsBox[ + {Thickness[0.07016411257027613], + {RGBColor[0.2901960784313726, 0.5843137254901961, 0.8], Thickness[ + 0.05262308442770709], Opacity[1.], CapForm["Butt"], + JoinForm[{"Miter", 1.}], + JoinedCurveBox[{{{0, 2, 0}, {0, 1, 0}, {0, 1, 0}, {0, 1, 0}, {0, 1, 0}, { + 0, 1, 0}, {0, 1, 0}, {0, 1, 0}, {0, 1, 0}, {0, 1, 0}, {0, 1, 0}, {0, 1, + 0}, {0, 1, 0}, {0, 1, 0}, {0, 1, 0}, {0, 1, 0}, {0, 1, 0}, {0, 1, 0}, {0, + 1, 0}, {0, 1, 0}}}, CompressedData[" +1:eJxTTMoPSmVmYGBgBGJRIGZiAIMEhUYZBxBj1UYdEB3heVcMRHM0XlUHi59y +5gTRHWKSWiBaQamWG0Q/+FmnApb/2/7MHkgd8PRRBvEPWDWygMXVDeWQ5R22 +nBAF6xOtButnCEkWBtEJG+3B5jOYxjEg289QnwUWh7sv5/lzkDlbqoUUQfyG +ogyw/ANdAzWwvGYMWP+N6wtVwe5wTwSbP2GBhDaIdlh3HGz/hosJYH8tkNKX +Q5bfcMwb7P4XUYvA+i+UQfzHYWIINr9isgTY/zD7YeGDEn4ArS1I9w== + "], + CurveClosed->{1}]}, + {FaceForm[{RGBColor[0.2901960784313726, 0.5843137254901961, 0.8], Opacity[ + 1.]}], FilledCurveBox[{{{0, 2, 0}, {0, 1, 0}, {0, 1, 0}}}, {{{ + 5.526100158691406, 10.766900062561035`}, {5.526100158691406, + 4.3668999671936035`}, {10.32610034942627, 7.582900285720825}, { + 5.526100158691406, 10.766900062561035`}}}]}}, + AspectRatio->Automatic, + BaselinePosition->(Center -> Center), + ImageSize->{16., 17.}, + PlotRange->{{-0.5, 14.752300262451172`}, {-0.5, 15.594200134277344`}}] } @| @| From 24144b4fca1f9d575b8bf4179fab3724af760350 Mon Sep 17 00:00:00 2001 From: Kevin Daily Date: Mon, 25 Nov 2024 14:12:20 -0800 Subject: [PATCH 3/7] Remove NA insert button, update insert-evaluate tooltip --- Source/Chatbook/ChatModes/UI.wl | 3 ++ Source/Chatbook/Formatting.wl | 63 +++++++++++++++++++++++++++------ 2 files changed, 55 insertions(+), 11 deletions(-) diff --git a/Source/Chatbook/ChatModes/UI.wl b/Source/Chatbook/ChatModes/UI.wl index 903a09ff..8bcc9dd1 100644 --- a/Source/Chatbook/ChatModes/UI.wl +++ b/Source/Chatbook/ChatModes/UI.wl @@ -505,6 +505,9 @@ focusedNotebookDisplay[ chatNB_ ] := Enclose[ current = ConfirmBy[ First @ info, AssociationQ, "Current" ]; focused = FirstCase[ info, KeyValuePattern[ "Focused" -> True ], current ]; + (* focusedNotebookDisplay is dynamically updated so this TaggingRules value should be kept current *) + CurrentValue[ chatNB, { TaggingRules, "FocusWindowTitle" } ] = Lookup[ focused, "WindowTitle", None ]; + label = Grid[ { { Toggler[ diff --git a/Source/Chatbook/Formatting.wl b/Source/Chatbook/Formatting.wl index c51ed9bc..533cfd79 100644 --- a/Source/Chatbook/Formatting.wl +++ b/Source/Chatbook/Formatting.wl @@ -618,13 +618,17 @@ floatingButtonGrid[ cell_Cell, lang_ ] := cellObj = topParentCell @ EvaluationCell[ ]; Grid[ { - checkTemplateBoxes @ { - button[ evaluateLanguageLabel @ lang, insertCodeBelow[ cell, True ] ], - button[ - If[ TrueQ @ CurrentChatSettings[ cellObj, "WorkspaceChat" ], $insertInputButtonLabelWorkspaceChat, $insertInputButtonLabel ], - insertCodeBelow[ cell, False ] ], - button[ $copyToClipboardButtonLabel, copyCodeBlock @ cell ] - } + checkTemplateBoxes @ If[ TrueQ @ CurrentChatSettings[ cellObj, "WorkspaceChat" ], + { + button[ $copyToClipboardButtonLabelWorkspaceChat, copyCodeBlock @ cell ], + button[ evaluateLanguageLabel[ lang, True ], insertCodeBelow[ cell, True ] ] + }, + { + button[ evaluateLanguageLabel[ lang, False ], insertCodeBelow[ cell, True ] ], + button[ $insertInputButtonLabel, insertCodeBelow[ cell, False ] ], + button[ $copyToClipboardButtonLabel, copyCodeBlock @ cell ] + } + ] }, Alignment -> Top, Spacings -> 0.2, @@ -639,7 +643,7 @@ floatingButtonGrid[ string_, lang_ ] := RawBoxes @ TemplateBox[ ToBoxes @ Grid[ { checkTemplateBoxes @ { - button[ evaluateLanguageLabel @ lang, insertCodeBelow[ string, True ] ], + button[ evaluateLanguageLabel[ lang, False ], insertCodeBelow[ string, True ] ], button[ $insertInputButtonLabel, insertCodeBelow[ string, False ] ], button[ $copyToClipboardButtonLabel, copyCodeBlock @ string ] } @@ -666,7 +670,7 @@ checkTemplateBoxes // endDefinition; (* ::**************************************************************************************************************:: *) (* ::Subsubsection::Closed:: *) (*evaluateLanguageLabel*) -evaluateLanguageLabel[ name_String ] := +evaluateLanguageLabel[ name_String, False ] := With[ { icon = $languageIcons @ name }, fancyTooltip[ MouseAppearance[ @@ -680,6 +684,26 @@ evaluateLanguageLabel[ name_String ] := ] /; MatchQ[ icon, _Graphics | _Image ] ]; +evaluateLanguageLabel[ name_String, True ] := + With[ { icon = If[ name === "Wolfram", chatbookIcon[ "WorkspaceCodeBlockInsertAndEvaluate", False ], $languageIcons @ name ] }, + fancyTooltip[ + MouseAppearance[ + buttonMouseover[ + buttonFrameDefault[ labeledIcon[ { "WorkspaceCodeBlockInsertAndEvaluate", False }, "FormattingInsertContentAndEvaluateLabel" ], True ], + buttonFrameActive[ labeledIcon[ { "WorkspaceCodeBlockInsertAndEvaluate", False }, "FormattingInsertContentAndEvaluateLabel" ], True ] + ], + "LinkHand" + ], + Row[ Flatten @ { + trExprTemplate[ "FormattingInsertContentAndEvaluateWorkspaceChatTooltip" ][ <| "1" -> + { + chatbookIcon[ "WorkspaceFocusIndicatorNotebook", False ], + Style[ CurrentValue[ EvaluationNotebook[], { TaggingRules, "FocusWindowTitle" } ], FontWeight -> Bold ] + } |> ] + } ] + ] /; MatchQ[ icon, _Graphics | _Dynamic | _Image ] + ]; + evaluateLanguageLabel[ ___ ] := $insertEvaluateButtonLabel; (* ::**************************************************************************************************************:: *) @@ -705,6 +729,20 @@ $copyToClipboardButtonLabel := $copyToClipboardButtonLabel = fancyTooltip[ tr[ "FormattingCopyToClipboardTooltip" ] ]; +(* ::**************************************************************************************************************:: *) +(* ::Subsubsection::Closed:: *) +(*$copyToClipboardButtonLabelWorkspaceChat*) +$copyToClipboardButtonLabelWorkspaceChat := $copyToClipboardButtonLabelWorkspaceChat = fancyTooltip[ + MouseAppearance[ + buttonMouseover[ + buttonFrameDefault @ labeledIcon[ { "WorkspaceCodeBlockCopy", False }, "FormattingCopyToClipboardLabel" ], + buttonFrameActive @ labeledIcon[ { "WorkspaceCodeBlockCopy", False }, "FormattingCopyToClipboardLabel" ] + ], + "LinkHand" + ], + tr[ "FormattingCopyToClipboardTooltip" ] +]; + (* ::**************************************************************************************************************:: *) (* ::Subsubsection::Closed:: *) (*$insertInputButtonLabel*) @@ -1042,10 +1080,12 @@ buttonPane[ expr_ ] := (* ::**************************************************************************************************************:: *) (* ::Subsubsection::Closed:: *) (*labeledIcon*) -labeledIcon[ iconTemplateName_String, textResource_String ] := +labeledIcon[ iconTemplateName_String, textResource_String ] := labeledIcon[ { iconTemplateName, True }, textResource ] + +labeledIcon[ { iconTemplateName_String, useTemplateBoxQ_ }, textResource_String ] := Grid[ { { - buttonPane @ RawBoxes @ TemplateBox[ { }, iconTemplateName ], + buttonPane @ If[ useTemplateBoxQ, RawBoxes @ TemplateBox[ { }, iconTemplateName ], chatbookIcon[ iconTemplateName, False ] ], Style[ tr @ textResource, FontSize -> 12, FontColor -> RGBColor[ "#333333" ], FontFamily -> "Source Sans Pro" ] } }, BaselinePosition -> { 1, 2 }, Alignment -> { Left, Baseline }, Spacings -> { 0, 0 } ]; @@ -2926,6 +2966,7 @@ userMessageBox // endDefinition; (*Package Footer*) addToMXInitialization[ $copyToClipboardButtonLabel; + $copyToClipboardButtonLabelWorkspaceChat; $insertInputButtonLabel; $insertInputButtonLabelWorkspaceChat; $insertEvaluateButtonLabel; From eedc353476c62e19f98e165b4e03dc851434f1cf Mon Sep 17 00:00:00 2001 From: Kevin Daily Date: Mon, 25 Nov 2024 15:49:34 -0800 Subject: [PATCH 4/7] Corrections to design elements --- .../WorkspaceChat/CodeBlocks/WorkspaceCodeBlockCopy.wl | 2 +- FrontEnd/TextResources/ChatbookResources.tr | 2 +- Source/Chatbook/Formatting.wl | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Developer/Resources/FrontEndResources/WorkspaceChat/CodeBlocks/WorkspaceCodeBlockCopy.wl b/Developer/Resources/FrontEndResources/WorkspaceChat/CodeBlocks/WorkspaceCodeBlockCopy.wl index 1edede37..d6f9e35d 100644 --- a/Developer/Resources/FrontEndResources/WorkspaceChat/CodeBlocks/WorkspaceCodeBlockCopy.wl +++ b/Developer/Resources/FrontEndResources/WorkspaceChat/CodeBlocks/WorkspaceCodeBlockCopy.wl @@ -45,6 +45,6 @@ Graphics[{Thickness[0.125], {8., 0.5}, {8., 8.5}, {8., 8.775999069213867}, {7.776000022888184, 9.}, {7.5, 9.}}}]}, FaceForm[RGBColor[0.2901960784313726, 0.5843137254901961, 0.8, 1.]]]}, - ImageSize -> {9., 13.}, PlotRange -> {{-0.5, 8.5}, + ImageSize -> {11., 16.}, PlotRange -> {{-0.5, 8.5}, {-0.5, 11.697400093078613}}, AspectRatio -> Automatic, BaselinePosition -> Center -> Center] diff --git a/FrontEnd/TextResources/ChatbookResources.tr b/FrontEnd/TextResources/ChatbookResources.tr index 9aa582d8..60c1d81b 100644 --- a/FrontEnd/TextResources/ChatbookResources.tr +++ b/FrontEnd/TextResources/ChatbookResources.tr @@ -6320,7 +6320,7 @@ zD1gPsy9SObB/INIPwC/b2f2 "]}]}, AspectRatio->Automatic, BaselinePosition->(Center -> Center), - ImageSize->{9., 13.}, + ImageSize->{11., 16.}, PlotRange->{{-0.5, 8.5}, {-0.5, 11.697400093078613`}}], "WorkspaceCodeBlockInsertAndEvaluate" -> GraphicsBox[ diff --git a/Source/Chatbook/Formatting.wl b/Source/Chatbook/Formatting.wl index 533cfd79..e4bfd3c6 100644 --- a/Source/Chatbook/Formatting.wl +++ b/Source/Chatbook/Formatting.wl @@ -698,6 +698,7 @@ evaluateLanguageLabel[ name_String, True ] := trExprTemplate[ "FormattingInsertContentAndEvaluateWorkspaceChatTooltip" ][ <| "1" -> { chatbookIcon[ "WorkspaceFocusIndicatorNotebook", False ], + "\[ThinSpace]", Style[ CurrentValue[ EvaluationNotebook[], { TaggingRules, "FocusWindowTitle" } ], FontWeight -> Bold ] } |> ] } ] From 833db80d5c6dabef8f1adf73c39af37bc7abe9ee Mon Sep 17 00:00:00 2001 From: Rick Hennigan Date: Tue, 26 Nov 2024 11:34:48 -0500 Subject: [PATCH 5/7] Fixed my merge mistake --- FrontEnd/TextResources/ChatbookResources.tr | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/FrontEnd/TextResources/ChatbookResources.tr b/FrontEnd/TextResources/ChatbookResources.tr index 6bd4ee5e..d5217f5a 100644 --- a/FrontEnd/TextResources/ChatbookResources.tr +++ b/FrontEnd/TextResources/ChatbookResources.tr @@ -6298,8 +6298,7 @@ TD2Mb3lNEkxzlMqBaSGoOMw9MD7MvTC+5EEUPjx8oOahhB8ACaE9/g== AspectRatio->Automatic, BaselinePosition->(Center -> Center), ImageSize->{8., 7.}, - PlotRange->{{-0.5, 7.5}, {-0.5, 6.5}}] - PlotRange->{{-0.5, 167.5}, {-0.5, 77.5}}], + PlotRange->{{-0.5, 7.5}, {-0.5, 6.5}}], "WorkspaceCodeBlockCopy" -> GraphicsBox[ {Thickness[0.125], FaceForm[{RGBColor[ From 0c8bc4801a0555098d35a606ba874cca9eda2dfc Mon Sep 17 00:00:00 2001 From: Kevin Daily Date: Tue, 26 Nov 2024 09:11:51 -0800 Subject: [PATCH 6/7] Small fix with icon generality of copy-evaluate button --- Source/Chatbook/Formatting.wl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/Chatbook/Formatting.wl b/Source/Chatbook/Formatting.wl index e4bfd3c6..53d86cc5 100644 --- a/Source/Chatbook/Formatting.wl +++ b/Source/Chatbook/Formatting.wl @@ -689,8 +689,8 @@ evaluateLanguageLabel[ name_String, True ] := fancyTooltip[ MouseAppearance[ buttonMouseover[ - buttonFrameDefault[ labeledIcon[ { "WorkspaceCodeBlockInsertAndEvaluate", False }, "FormattingInsertContentAndEvaluateLabel" ], True ], - buttonFrameActive[ labeledIcon[ { "WorkspaceCodeBlockInsertAndEvaluate", False }, "FormattingInsertContentAndEvaluateLabel" ], True ] + buttonFrameDefault[ labeledIcon[ If[ name === "Wolfram", { "WorkspaceCodeBlockInsertAndEvaluate", False }, name ], "FormattingInsertContentAndEvaluateLabel" ], True ], + buttonFrameActive[ labeledIcon[ If[ name === "Wolfram", { "WorkspaceCodeBlockInsertAndEvaluate", False }, name ], "FormattingInsertContentAndEvaluateLabel" ], True ] ], "LinkHand" ], From a8ab2c424fb178ae2a5a9849470763281ab827ff Mon Sep 17 00:00:00 2001 From: Rick Hennigan Date: Tue, 26 Nov 2024 14:56:43 -0500 Subject: [PATCH 7/7] Added `GetFocusedNotebook` --- FrontEnd/TextResources/ChatbookStrings.tr | 1 + .../ChineseSimplified/ChatbookStrings.tr | 1 + .../ChineseTraditional/ChatbookStrings.tr | 1 + .../TextResources/French/ChatbookStrings.tr | 1 + .../TextResources/Japanese/ChatbookStrings.tr | 1 + .../TextResources/Korean/ChatbookStrings.tr | 1 + .../TextResources/Spanish/ChatbookStrings.tr | 1 + Source/Chatbook/ChatModes/ChatModes.wl | 1 + Source/Chatbook/ChatModes/Common.wl | 1 + Source/Chatbook/ChatModes/NotebookFocus.wl | 274 ++++++++++++++++++ .../ChatModes/ShowNotebookAssistance.wl | 58 +++- Source/Chatbook/ChatModes/UI.wl | 222 +------------- Source/Chatbook/CommonSymbols.wl | 1 + Source/Chatbook/Formatting.wl | 38 ++- Source/Chatbook/Main.wl | 2 + 15 files changed, 370 insertions(+), 234 deletions(-) create mode 100644 Source/Chatbook/ChatModes/NotebookFocus.wl diff --git a/FrontEnd/TextResources/ChatbookStrings.tr b/FrontEnd/TextResources/ChatbookStrings.tr index 90be4bf1..7aea1e0b 100644 --- a/FrontEnd/TextResources/ChatbookStrings.tr +++ b/FrontEnd/TextResources/ChatbookStrings.tr @@ -63,6 +63,7 @@ "FormattingInsertContentLabel" -> "Insert", "FormattingInsertContentAndEvaluateTooltip" -> "Insert content as new input cell below and evaluate", "FormattingInsertContentAndEvaluateWorkspaceChatTooltip" -> "Insert this into `1` and evaluate.", +"FormattingInsertContentAndEvaluateWorkspaceChatTooltipNew" -> "Insert this into a new notebook and evaluate.", "FormattingCopyToClipboardTooltip" -> "Copy to clipboard", "FormattingInsertContentTooltip" -> "Insert content as new input cell below", "FormattingToolUsing" -> "Using ", diff --git a/FrontEnd/TextResources/ChineseSimplified/ChatbookStrings.tr b/FrontEnd/TextResources/ChineseSimplified/ChatbookStrings.tr index 4933b4fb..c10c4813 100644 --- a/FrontEnd/TextResources/ChineseSimplified/ChatbookStrings.tr +++ b/FrontEnd/TextResources/ChineseSimplified/ChatbookStrings.tr @@ -63,6 +63,7 @@ "FormattingInsertContentLabel" -> "\:63D2\:5165", "FormattingInsertContentAndEvaluateTooltip" -> "\:5728\:4E0B\:9762\:63D2\:5165\:5185\:5BB9\:4F5C\:4E3A\:65B0\:7684\:8F93\:5165\:5355\:5143\:5E76\:8BA1\:7B97", "FormattingInsertContentAndEvaluateWorkspaceChatTooltip" -> "Insert this into `1` and evaluate.", +"FormattingInsertContentAndEvaluateWorkspaceChatTooltipNew" -> "Insert this into a new notebook and evaluate.", "FormattingCopyToClipboardTooltip" -> "\:590D\:5236\:5230\:526A\:8D34\:677F", "FormattingInsertContentTooltip" -> "\:5728\:4E0B\:9762\:63D2\:5165\:5185\:5BB9\:4F5C\:4E3A\:65B0\:7684\:8F93\:5165\:5355\:5143", "FormattingToolUsing" -> "\:4F7F\:7528 ", diff --git a/FrontEnd/TextResources/ChineseTraditional/ChatbookStrings.tr b/FrontEnd/TextResources/ChineseTraditional/ChatbookStrings.tr index dc34fd32..6280ee6c 100644 --- a/FrontEnd/TextResources/ChineseTraditional/ChatbookStrings.tr +++ b/FrontEnd/TextResources/ChineseTraditional/ChatbookStrings.tr @@ -63,6 +63,7 @@ "FormattingInsertContentLabel" -> "\:63D2\:5165", "FormattingInsertContentAndEvaluateTooltip" -> "\:63D2\:5165\:5982\:540C\:5728\:4E0B\:65B9\:65B0\:589E\:8F38\:5165\:5132\:5B58\:683C\:7684\:5167\:5BB9\:4E26\:9032\:884C\:8A08\:7B97", "FormattingInsertContentAndEvaluateWorkspaceChatTooltip" -> "Insert this into `1` and evaluate.", +"FormattingInsertContentAndEvaluateWorkspaceChatTooltipNew" -> "Insert this into a new notebook and evaluate.", "FormattingCopyToClipboardTooltip" -> "\:8907\:88FD\:81F3\:526A\:8CBC\:7C3F", "FormattingInsertContentTooltip" -> "\:63D2\:5165\:5982\:540C\:5728\:4E0B\:65B9\:65B0\:589E\:8F38\:5165\:5132\:5B58\:683C\:7684\:5167\:5BB9", "FormattingToolUsing" -> "\:6B63\:5728\:4F7F\:7528 ", diff --git a/FrontEnd/TextResources/French/ChatbookStrings.tr b/FrontEnd/TextResources/French/ChatbookStrings.tr index f14a24e7..4dca5bbc 100644 --- a/FrontEnd/TextResources/French/ChatbookStrings.tr +++ b/FrontEnd/TextResources/French/ChatbookStrings.tr @@ -63,6 +63,7 @@ "FormattingInsertContentLabel" -> "Ins\[EAcute]rer", "FormattingInsertContentAndEvaluateTooltip" -> "Ins\[EAcute]rer le contenu en tant que nouvelle cellule d\[CloseCurlyQuote]entr\[EAcute]e ci-dessous et l\[CloseCurlyQuote]\[EAcute]valuer", "FormattingInsertContentAndEvaluateWorkspaceChatTooltip" -> "Insert this into `1` and evaluate.", +"FormattingInsertContentAndEvaluateWorkspaceChatTooltipNew" -> "Insert this into a new notebook and evaluate.", "FormattingCopyToClipboardTooltip" -> "Copier dans le presse-papiers", "FormattingInsertContentTooltip" -> "Ins\[EAcute]rer le contenu en tant que nouvelle cellule d\[CloseCurlyQuote]entr\[EAcute]e ci-dessous", "FormattingToolUsing" -> "Utilisation de ", diff --git a/FrontEnd/TextResources/Japanese/ChatbookStrings.tr b/FrontEnd/TextResources/Japanese/ChatbookStrings.tr index a025131d..55f283e6 100644 --- a/FrontEnd/TextResources/Japanese/ChatbookStrings.tr +++ b/FrontEnd/TextResources/Japanese/ChatbookStrings.tr @@ -63,6 +63,7 @@ "FormattingInsertContentLabel" -> "\:633f\:5165", "FormattingInsertContentAndEvaluateTooltip" -> "\:30b3\:30f3\:30c6\:30f3\:30c4\:3092\:65b0\:898f\:306e\:5165\:529b\:30bb\:30eb\:3068\:3057\:3066\:4e0b\:306b\:633f\:5165\:3057\:8a55\:4fa1\:3059\:308b", "FormattingInsertContentAndEvaluateWorkspaceChatTooltip" -> "Insert this into `1` and evaluate.", +"FormattingInsertContentAndEvaluateWorkspaceChatTooltipNew" -> "Insert this into a new notebook and evaluate.", "FormattingCopyToClipboardTooltip" -> "\:30af\:30ea\:30c3\:30d7\:30dc\:30fc\:30c9\:306b\:30b3\:30d4\:30fc", "FormattingInsertContentTooltip" -> "\:30b3\:30f3\:30c6\:30f3\:30c4\:3092\:65b0\:898f\:306e\:5165\:529b\:30bb\:30eb\:3068\:3057\:3066\:4e0b\:306b\:633f\:5165\:3059\:308b", "FormattingToolUsing" -> "\:4f7f\:7528\:4e2d\:ff1a", diff --git a/FrontEnd/TextResources/Korean/ChatbookStrings.tr b/FrontEnd/TextResources/Korean/ChatbookStrings.tr index 4b23f289..e9568335 100644 --- a/FrontEnd/TextResources/Korean/ChatbookStrings.tr +++ b/FrontEnd/TextResources/Korean/ChatbookStrings.tr @@ -64,6 +64,7 @@ "FormattingInsertContentAndEvaluateTooltip" -> "\:C544\:B798\:C5D0 \:CF58\:D150\:CE20\:B97C \:C0C8 \:C785\:B825 \ \:C140\:B85C \:C0BD\:C785\:D558\:ACE0 \:D3C9\:AC00", "FormattingInsertContentAndEvaluateWorkspaceChatTooltip" -> "Insert this into `1` and evaluate.", +"FormattingInsertContentAndEvaluateWorkspaceChatTooltipNew" -> "Insert this into a new notebook and evaluate.", "FormattingCopyToClipboardTooltip" -> "\:D074\:B9BD\:BCF4\:B4DC\:C5D0 \:BCF5\:C0AC", "FormattingInsertContentTooltip" -> "\:CF58\:D150\:CE20\:B97C \:C0C8 \:C785\:B825 \:C140\:B85C \:C544\:B798\:C5D0 \:C0BD\:C785", "FormattingToolUsing" -> "\:C0AC\:C6A9\:C911 ", diff --git a/FrontEnd/TextResources/Spanish/ChatbookStrings.tr b/FrontEnd/TextResources/Spanish/ChatbookStrings.tr index 72d632a9..a2bd5a85 100644 --- a/FrontEnd/TextResources/Spanish/ChatbookStrings.tr +++ b/FrontEnd/TextResources/Spanish/ChatbookStrings.tr @@ -63,6 +63,7 @@ "FormattingInsertContentLabel" -> "Insertar", "FormattingInsertContentAndEvaluateTooltip" -> "Insertar contenido como una nueva celda de entrada debajo y evaluar", "FormattingInsertContentAndEvaluateWorkspaceChatTooltip" -> "Insert this into `1` and evaluate.", +"FormattingInsertContentAndEvaluateWorkspaceChatTooltipNew" -> "Insert this into a new notebook and evaluate.", "FormattingCopyToClipboardTooltip" -> "Copiar al portapapeles", "FormattingInsertContentTooltip" -> "Insertar contenido como una nueva celda de entrada debajo", "FormattingToolUsing" -> "Utilizando ", diff --git a/Source/Chatbook/ChatModes/ChatModes.wl b/Source/Chatbook/ChatModes/ChatModes.wl index b96d9ffb..7af72f1d 100644 --- a/Source/Chatbook/ChatModes/ChatModes.wl +++ b/Source/Chatbook/ChatModes/ChatModes.wl @@ -39,6 +39,7 @@ $subcontexts = { "Wolfram`Chatbook`ChatModes`Context`", "Wolfram`Chatbook`ChatModes`Evaluate`", "Wolfram`Chatbook`ChatModes`NotebookAssistanceInstructions`", + "Wolfram`Chatbook`ChatModes`NotebookFocus`", "Wolfram`Chatbook`ChatModes`ShowNotebookAssistance`", "Wolfram`Chatbook`ChatModes`UI`" }; diff --git a/Source/Chatbook/ChatModes/Common.wl b/Source/Chatbook/ChatModes/Common.wl index a4d82b9e..df4b56cc 100644 --- a/Source/Chatbook/ChatModes/Common.wl +++ b/Source/Chatbook/ChatModes/Common.wl @@ -11,6 +11,7 @@ HoldComplete[ `createWorkspaceChat, `evaluateAttachedInlineChat, `findCurrentWorkspaceChat, + `focusedNotebookDisplay, `getContextFromSelection, `getNotebookAssistanceInput, `getSelectionInfo, diff --git a/Source/Chatbook/ChatModes/NotebookFocus.wl b/Source/Chatbook/ChatModes/NotebookFocus.wl new file mode 100644 index 00000000..b76a4b40 --- /dev/null +++ b/Source/Chatbook/ChatModes/NotebookFocus.wl @@ -0,0 +1,274 @@ +(* ::Section::Closed:: *) +(*Package Header*) +BeginPackage[ "Wolfram`Chatbook`ChatModes`NotebookFocus`" ]; +Begin[ "`Private`" ]; + +Needs[ "Wolfram`Chatbook`" ]; +Needs[ "Wolfram`Chatbook`Common`" ]; +Needs[ "Wolfram`Chatbook`ChatModes`Common`" ]; + +(* ::**************************************************************************************************************:: *) +(* ::Section::Closed:: *) +(*Configuration*) + +(* ::**************************************************************************************************************:: *) +(* ::Section::Closed:: *) +(*GetFocusedNotebook*) +GetFocusedNotebook // beginDefinition; +GetFocusedNotebook[ ] := catchMine @ GetFocusedNotebook @ EvaluationNotebook[ ]; +GetFocusedNotebook[ obj: $$feObj ] := catchMine @ getFocusedNotebook @ obj; +GetFocusedNotebook[ app: _String | All ] := catchMine @ GetFocusedNotebook @ findCurrentWorkspaceChat @ app; +GetFocusedNotebook[ _Missing ] := None; +GetFocusedNotebook // endExportedDefinition; + +(* ::**************************************************************************************************************:: *) +(* ::Subsection::Closed:: *) +(*getFocusedNotebook*) +getFocusedNotebook // beginDefinition; + +getFocusedNotebook[ obj: $$feObj ] /; ! TrueQ @ CurrentChatSettings[ obj, "WorkspaceChat" ] := + If[ MatchQ[ obj, _NotebookObject ], obj, parentNotebook @ obj ]; + +getFocusedNotebook[ obj: $$feObj ] := Enclose[ + Module[ { locked }, + locked = ConfirmMatch[ getLockedNotebook @ obj, _NotebookObject | None, "Locked" ]; + If[ notebookObjectQ @ locked, locked, getUserNotebook[ ] ] + ], + throwInternalFailure +]; + +getFocusedNotebook // endDefinition; + +(* ::**************************************************************************************************************:: *) +(* ::Section::Closed:: *) +(*Notebook Focus Indicator*) + +(* ::**************************************************************************************************************:: *) +(* ::Subsection::Closed:: *) +(*focusedNotebookDisplay*) +focusedNotebookDisplay // beginDefinition; + +focusedNotebookDisplay[ chatNB_ ] := Enclose[ + Catch @ Module[ { locked, notebooks, info, current, focused, label }, + + locked = getLockedNotebook @ chatNB; + + notebooks = ConfirmMatch[ + Cases[ SourceNotebookObjectInformation[ ], KeyValuePattern[ "Included" -> True ] ], + { ___Association }, + "Notebooks" + ]; + + If[ notebooks === { }, Throw @ Spacer[ 0 ] ]; + + info = ConfirmMatch[ addFocusInfo[ locked, notebooks ], { __Association }, "Info" ]; + current = ConfirmBy[ First @ info, AssociationQ, "Current" ]; + focused = FirstCase[ info, KeyValuePattern[ "Focused" -> True ], current ]; + + (* focusedNotebookDisplay is dynamically updated so this TaggingRules value should be kept current *) + CurrentValue[ chatNB, { TaggingRules, "FocusWindowTitle" } ] = Lookup[ focused, "WindowTitle", None ]; + + label = Grid[ + { { + Toggler[ + Dynamic @ CurrentChatSettings[ chatNB, "AllowSelectionContext" ], + { + True -> $disableNotebookFocusLabel, + False -> $enableNotebookFocusLabel + }, + BaselinePosition -> Baseline + ], + tr[ "WorkspaceFocusIndicatorFocus" ], + focusedNotebookDisplay0[ chatNB, focused, locked, info ] + } }, + Alignment -> { Left, Baseline }, + BaseStyle -> { "Text", FontColor -> GrayLevel[ 0.5 ], FontSize -> 13 }, + BaselinePosition -> { 1, 2 } (* align to the text *) + ]; + + Pane[ label, ImageMargins -> { { 0, 0 }, { 0, 0 } } ] + ], + throwInternalFailure +]; + +focusedNotebookDisplay // endDefinition; + + + +focusedNotebookDisplay0 // beginDefinition; + +focusedNotebookDisplay0[ chatNB_, focused_, locked_, info_ ] := Grid[ + { { + currentNotebookButton @ focused, + selectNotebookFocusMenu[ chatNB, locked, info ] + } }, + Alignment -> { Left, Baseline }, + BaselinePosition -> { 1, 1 }, (* align to the button *) + Dividers -> Center, + FrameStyle -> GrayLevel[ 0.75 ] +]; + +focusedNotebookDisplay0 // endDefinition; + + +$enableNotebookFocusLabel := $enableNotebookFocusLabel = Tooltip[ + chatbookIcon[ "WorkspaceFocusIndicatorUncheck", False ], + tr[ "WorkspaceFocusIndicatorEnableTooltip" ] +]; + +$disableNotebookFocusLabel := $disableNotebookFocusLabel = Tooltip[ + chatbookIcon[ "WorkspaceFocusIndicatorCheck", False ], + tr[ "WorkspaceFocusIndicatorDisableTooltip" ] +]; + +(* ::**************************************************************************************************************:: *) +(* ::Subsubsection::Closed:: *) +(*addFocusInfo*) +addFocusInfo // beginDefinition; + +addFocusInfo[ locked_, notebooks_List ] := + MapIndexed[ addFocusInfo[ locked, #1, #2 ] &, notebooks ]; + +addFocusInfo[ locked_, as_Association, { idx_ } ] := <| + "Current" -> idx === 1, + "Focused" -> as[ "NotebookObject" ] === locked, + as +|>; + +addFocusInfo // endDefinition; + +(* ::**************************************************************************************************************:: *) +(* ::Subsubsection::Closed:: *) +(*currentNotebookButton*) +currentNotebookButton // beginDefinition; + +currentNotebookButton[ as: KeyValuePattern @ { "NotebookObject" -> nbo_NotebookObject, "WindowTitle" -> title_ } ] := + Button[ + currentNotebookButtonLabel @ Replace[ + formatNotebookTitle @ title, + s_String :> FE`Evaluate @ FEPrivate`TruncateStringToWidth[ s, "Text", 200, Right ] + ], + SetSelectedNotebook @ nbo, + Appearance -> "Suppressed", + BaseStyle -> { "Text", FontColor -> GrayLevel[ 0.5 ], FontSize -> 13 }, + BaselinePosition -> Baseline + ]; + +currentNotebookButton // endDefinition; + +(* ::**************************************************************************************************************:: *) +(* ::Subsubsection::Closed:: *) +(*currentNotebookButtonLabel*) +currentNotebookButtonLabel // beginDefinition; + +currentNotebookButtonLabel[ title_ ] := Mouseover[ + Row[ + { + chatbookIcon[ "WorkspaceFocusIndicatorNotebook", False ], + Spacer[ 3 ], + title + }, + BaselinePosition -> Baseline + ], + Row[ + { + chatbookIcon[ "WorkspaceFocusIndicatorNotebookActive", False ], + Spacer[ 3 ], + Style[ title, FontColor -> RGBColor[ 0.2, 0.51373, 0.67451, 1.0 ] ] + }, + BaselinePosition -> Baseline + ], + BaselinePosition -> Baseline +]; + +currentNotebookButtonLabel // endDefinition; + +$smallNotebookIcon := $smallNotebookIcon = chatbookIcon[ "WorkspaceFocusIndicatorNotebook", False ]; + +(* ::**************************************************************************************************************:: *) +(* ::Subsubsection::Closed:: *) +(*selectNotebookFocusMenu*) +selectNotebookFocusMenu // beginDefinition; + +selectNotebookFocusMenu[ chatNB_, locked_, items: { current_Association, ___Association } ] := + selectNotebookFocusMenu[ chatNB, locked, current, SortBy[ items, Lookup[ "WindowTitle" ] ] ]; + +selectNotebookFocusMenu[ chatNB_, locked_, first_, rest_ ] := Tooltip[ + ActionMenu[ + chatbookIcon[ "WorkspaceFocusIndicatorCaret", False ], + Flatten @ { + currentNotebookAction[ chatNB, locked, first ], + Delimiter, + otherNotebookActions[ chatNB, locked, rest ] + }, + Appearance -> "Suppressed", + BaseStyle -> { "Text", FontColor -> GrayLevel[ 0.5 ], FontSize -> 13, Magnification -> Inherited / 0.85 }, + BaselinePosition -> Baseline + ], + tr[ "WorkspaceFocusIndicatorMenuTooltip" ] +]; + +selectNotebookFocusMenu // endDefinition; + +(* ::**************************************************************************************************************:: *) +(* ::Subsubsection::Closed:: *) +(*currentNotebookAction*) +currentNotebookAction // beginDefinition; + +currentNotebookAction[ chatNB_, locked_, as_Association ] := + currentNotebookAction[ chatNB, locked, as[ "WindowTitle" ], as[ "NotebookObject" ] ]; + +currentNotebookAction[ chatNB_, locked_, title_, nbo_ ] := + Row @ { + Style[ "\[Checkmark] ", ShowContents -> locked === None ], + tr[ "WorkspaceFocusIndicatorMenuAutomatic" ], + " (", + formatNotebookTitle @ title, + ")" + } :> ( + CurrentChatSettings[ chatNB, "AllowSelectionContext" ] = True; + CurrentChatSettings[ chatNB, "FocusedNotebook" ] = Inherited + ); + +currentNotebookAction // endDefinition; + +(* ::**************************************************************************************************************:: *) +(* ::Subsubsection::Closed:: *) +(*otherNotebookActions*) +otherNotebookActions // beginDefinition; +otherNotebookActions[ chatNB_, locked_, items_List ] := otherNotebookAction[ chatNB, locked, # ] & /@ items; +otherNotebookActions // endDefinition; + +(* ::**************************************************************************************************************:: *) +(* ::Subsubsubsection::Closed:: *) +(*otherNotebookAction*) +otherNotebookAction // beginDefinition; + +otherNotebookAction[ chatNB_, locked_, as_Association ] := + otherNotebookAction[ chatNB, locked, as[ "WindowTitle" ], as[ "NotebookObject" ] ]; + +otherNotebookAction[ chatNB_, locked_, title_, nbo_ ] := + Row @ { Style[ "\[Checkmark] ", ShowContents -> locked === nbo ], formatNotebookTitle @ title } :> ( + CurrentChatSettings[ chatNB, "AllowSelectionContext" ] = True; + CurrentChatSettings[ chatNB, "FocusedNotebook" ] = nbo + ); + +otherNotebookAction // endDefinition; + +(* ::**************************************************************************************************************:: *) +(* ::Subsubsection::Closed:: *) +(*getLockedNotebook*) +getLockedNotebook // beginDefinition; +getLockedNotebook[ nbo_ ] := getLockedNotebook[ nbo, CurrentChatSettings[ nbo, "FocusedNotebook" ] ]; +getLockedNotebook[ nbo_, focused_ ] := If[ TrueQ @ notebookObjectQ @ focused, focused, None ]; +getLockedNotebook // endDefinition; + +(* ::**************************************************************************************************************:: *) +(* ::Section::Closed:: *) +(*Package Footer*) +addToMXInitialization[ + Null +]; + +End[ ]; +EndPackage[ ]; diff --git a/Source/Chatbook/ChatModes/ShowNotebookAssistance.wl b/Source/Chatbook/ChatModes/ShowNotebookAssistance.wl index d7ed27d1..c1ba64ad 100644 --- a/Source/Chatbook/ChatModes/ShowNotebookAssistance.wl +++ b/Source/Chatbook/ChatModes/ShowNotebookAssistance.wl @@ -464,7 +464,7 @@ showNotebookAssistanceWindow[ source_NotebookObject, input_, evaluate_, new_ ] : Module[ { current, nbo, movedLastChatToSourcesIndicatorQ }, current = ConfirmMatch[ - LogChatTiming @ findCurrentWorkspaceChat[ ], + LogChatTiming @ findCurrentWorkspaceChat[ "NotebookAssistance" ], _NotebookObject | Missing[ "NotFound" ], "Existing" ]; @@ -507,7 +507,12 @@ showNotebookAssistanceWindow[ source_NotebookObject, input_, evaluate_, new_ ] : showNotebookAssistanceWindow[ None, input_, evaluate_, new_ ] := Enclose[ Module[ { current, nbo }, - current = ConfirmMatch[ findCurrentWorkspaceChat[ ], _NotebookObject | Missing[ "NotFound" ], "Existing" ]; + + current = ConfirmMatch[ + findCurrentWorkspaceChat[ "NotebookAssistance" ], + _NotebookObject | Missing[ "NotFound" ], + "Existing" + ]; If[ TrueQ @ new, Quiet @ NotebookClose @ current; @@ -621,12 +626,57 @@ windowMargins // endDefinition; (*findCurrentWorkspaceChat*) findCurrentWorkspaceChat // beginDefinition; -findCurrentWorkspaceChat[ ] := FirstCase[ - selectByCurrentValue[ Notebooks[ ], { TaggingRules, "ChatNotebookSettings", "WorkspaceChat" }, "Absolute" -> True ], + +findCurrentWorkspaceChat[ ] := + findCurrentWorkspaceChat[ All, Notebooks[ ] ]; + + +findCurrentWorkspaceChat[ appName_String ] := + findCurrentWorkspaceChat[ appName, Notebooks[ ] ]; + + +findCurrentWorkspaceChat[ All | _String, { } ] := + Missing[ "NotFound" ]; + + +findCurrentWorkspaceChat[ All, notebooks: { __NotebookObject } ] := FirstCase[ + selectByCurrentValue[ notebooks, { TaggingRules, "ChatNotebookSettings", "WorkspaceChat" }, "Absolute" -> True ], _NotebookObject, Missing[ "NotFound" ] ]; + +findCurrentWorkspaceChat[ appName_String, notebooks: { __NotebookObject } ] := Enclose[ + Catch @ Module[ { wsNotebooks, appNotebooks }, + + wsNotebooks = ConfirmMatch[ + selectByCurrentValue[ + notebooks, + { TaggingRules, "ChatNotebookSettings", "WorkspaceChat" }, + "Absolute" -> True + ], + { ___NotebookObject }, + "WorkspaceNotebooks" + ]; + + If[ wsNotebooks === { }, Throw @ Missing[ "NotFound" ] ]; + + appNotebooks = ConfirmMatch[ + selectByCurrentValue[ + wsNotebooks, + { TaggingRules, "ChatNotebookSettings", "AppName" }, + SameAs @ appName, + "Absolute" -> True + ], + { ___NotebookObject }, + "AppNotebooks" + ]; + + FirstCase[ appNotebooks, _NotebookObject, Missing[ "NotFound" ] ] + ] +]; + + findCurrentWorkspaceChat // endDefinition; (* ::**************************************************************************************************************:: *) diff --git a/Source/Chatbook/ChatModes/UI.wl b/Source/Chatbook/ChatModes/UI.wl index 8bcc9dd1..b3c59b69 100644 --- a/Source/Chatbook/ChatModes/UI.wl +++ b/Source/Chatbook/ChatModes/UI.wl @@ -483,226 +483,6 @@ moveChatInputToBottom[ nbo_NotebookObject ] := moveChatInputToBottom // endDefinition; -(* ::**************************************************************************************************************:: *) -(* ::Subsection::Closed:: *) -(*focusedNotebookDisplay*) -focusedNotebookDisplay // beginDefinition; - -focusedNotebookDisplay[ chatNB_ ] := Enclose[ - Catch @ Module[ { locked, notebooks, info, current, focused, label }, - - locked = getLockedNotebook @ chatNB; - - notebooks = ConfirmMatch[ - Cases[ SourceNotebookObjectInformation[ ], KeyValuePattern[ "Included" -> True ] ], - { ___Association }, - "Notebooks" - ]; - - If[ notebooks === { }, Throw @ Spacer[ 0 ] ]; - - info = ConfirmMatch[ addFocusInfo[ locked, notebooks ], { __Association }, "Info" ]; - current = ConfirmBy[ First @ info, AssociationQ, "Current" ]; - focused = FirstCase[ info, KeyValuePattern[ "Focused" -> True ], current ]; - - (* focusedNotebookDisplay is dynamically updated so this TaggingRules value should be kept current *) - CurrentValue[ chatNB, { TaggingRules, "FocusWindowTitle" } ] = Lookup[ focused, "WindowTitle", None ]; - - label = Grid[ - { { - Toggler[ - Dynamic @ CurrentChatSettings[ chatNB, "AllowSelectionContext" ], - { - True -> $disableNotebookFocusLabel, - False -> $enableNotebookFocusLabel - }, - BaselinePosition -> Baseline - ], - tr[ "WorkspaceFocusIndicatorFocus" ], - focusedNotebookDisplay0[ chatNB, focused, locked, info ] - } }, - Alignment -> { Left, Baseline }, - BaseStyle -> { "Text", FontColor -> GrayLevel[ 0.5 ], FontSize -> 13 }, - BaselinePosition -> { 1, 2 } (* align to the text *) - ]; - - Pane[ label, ImageMargins -> { { 0, 0 }, { 0, 0 } } ] - ], - throwInternalFailure -]; - -focusedNotebookDisplay // endDefinition; - - - -focusedNotebookDisplay0 // beginDefinition; - -focusedNotebookDisplay0[ chatNB_, focused_, locked_, info_ ] := Grid[ - { { - currentNotebookButton @ focused, - selectNotebookFocusMenu[ chatNB, locked, info ] - } }, - Alignment -> { Left, Baseline }, - BaselinePosition -> { 1, 1 }, (* align to the button *) - Dividers -> Center, - FrameStyle -> GrayLevel[ 0.75 ] -]; - -focusedNotebookDisplay0 // endDefinition; - - -$enableNotebookFocusLabel := $enableNotebookFocusLabel = Tooltip[ - chatbookIcon[ "WorkspaceFocusIndicatorUncheck", False ], - tr[ "WorkspaceFocusIndicatorEnableTooltip" ] -]; - -$disableNotebookFocusLabel := $disableNotebookFocusLabel = Tooltip[ - chatbookIcon[ "WorkspaceFocusIndicatorCheck", False ], - tr[ "WorkspaceFocusIndicatorDisableTooltip" ] -]; - -(* ::**************************************************************************************************************:: *) -(* ::Subsubsection::Closed:: *) -(*addFocusInfo*) -addFocusInfo // beginDefinition; - -addFocusInfo[ locked_, notebooks_List ] := - MapIndexed[ addFocusInfo[ locked, #1, #2 ] &, notebooks ]; - -addFocusInfo[ locked_, as_Association, { idx_ } ] := <| - "Current" -> idx === 1, - "Focused" -> as[ "NotebookObject" ] === locked, - as -|>; - -addFocusInfo // endDefinition; - -(* ::**************************************************************************************************************:: *) -(* ::Subsubsection::Closed:: *) -(*currentNotebookButton*) -currentNotebookButton // beginDefinition; - -currentNotebookButton[ as: KeyValuePattern @ { "NotebookObject" -> nbo_NotebookObject, "WindowTitle" -> title_ } ] := - Button[ - currentNotebookButtonLabel @ Replace[ - formatNotebookTitle @ title, - s_String :> FE`Evaluate @ FEPrivate`TruncateStringToWidth[ s, "Text", 200, Right ] - ], - SetSelectedNotebook @ nbo, - Appearance -> "Suppressed", - BaseStyle -> { "Text", FontColor -> GrayLevel[ 0.5 ], FontSize -> 13 }, - BaselinePosition -> Baseline - ]; - -currentNotebookButton // endDefinition; - -(* ::**************************************************************************************************************:: *) -(* ::Subsubsection::Closed:: *) -(*currentNotebookButtonLabel*) -currentNotebookButtonLabel // beginDefinition; - -currentNotebookButtonLabel[ title_ ] := Mouseover[ - Row[ - { - chatbookIcon[ "WorkspaceFocusIndicatorNotebook", False ], - Spacer[ 3 ], - title - }, - BaselinePosition -> Baseline - ], - Row[ - { - chatbookIcon[ "WorkspaceFocusIndicatorNotebookActive", False ], - Spacer[ 3 ], - Style[ title, FontColor -> RGBColor[ 0.2, 0.51373, 0.67451, 1.0 ] ] - }, - BaselinePosition -> Baseline - ], - BaselinePosition -> Baseline -]; - -currentNotebookButtonLabel // endDefinition; - -$smallNotebookIcon := $smallNotebookIcon = chatbookIcon[ "WorkspaceFocusIndicatorNotebook", False ]; - -(* ::**************************************************************************************************************:: *) -(* ::Subsubsection::Closed:: *) -(*selectNotebookFocusMenu*) -selectNotebookFocusMenu // beginDefinition; - -selectNotebookFocusMenu[ chatNB_, locked_, items: { current_Association, ___Association } ] := - selectNotebookFocusMenu[ chatNB, locked, current, SortBy[ items, Lookup[ "WindowTitle" ] ] ]; - -selectNotebookFocusMenu[ chatNB_, locked_, first_, rest_ ] := Tooltip[ - ActionMenu[ - chatbookIcon[ "WorkspaceFocusIndicatorCaret", False ], - Flatten @ { - currentNotebookAction[ chatNB, locked, first ], - Delimiter, - otherNotebookActions[ chatNB, locked, rest ] - }, - Appearance -> "Suppressed", - BaseStyle -> { "Text", FontColor -> GrayLevel[ 0.5 ], FontSize -> 13, Magnification -> Inherited / 0.85 }, - BaselinePosition -> Baseline - ], - tr[ "WorkspaceFocusIndicatorMenuTooltip" ] -]; - -selectNotebookFocusMenu // endDefinition; - -(* ::**************************************************************************************************************:: *) -(* ::Subsubsection::Closed:: *) -(*currentNotebookAction*) -currentNotebookAction // beginDefinition; - -currentNotebookAction[ chatNB_, locked_, as_Association ] := - currentNotebookAction[ chatNB, locked, as[ "WindowTitle" ], as[ "NotebookObject" ] ]; - -currentNotebookAction[ chatNB_, locked_, title_, nbo_ ] := - Row @ { - Style[ "\[Checkmark] ", ShowContents -> locked === None ], - tr[ "WorkspaceFocusIndicatorMenuAutomatic" ], - " (", - formatNotebookTitle @ title, - ")" - } :> ( - CurrentChatSettings[ chatNB, "AllowSelectionContext" ] = True; - CurrentChatSettings[ chatNB, "FocusedNotebook" ] = Inherited - ); - -currentNotebookAction // endDefinition; - -(* ::**************************************************************************************************************:: *) -(* ::Subsubsection::Closed:: *) -(*otherNotebookActions*) -otherNotebookActions // beginDefinition; -otherNotebookActions[ chatNB_, locked_, items_List ] := otherNotebookAction[ chatNB, locked, # ] & /@ items; -otherNotebookActions // endDefinition; - -(* ::**************************************************************************************************************:: *) -(* ::Subsubsubsection::Closed:: *) -(*otherNotebookAction*) -otherNotebookAction // beginDefinition; - -otherNotebookAction[ chatNB_, locked_, as_Association ] := - otherNotebookAction[ chatNB, locked, as[ "WindowTitle" ], as[ "NotebookObject" ] ]; - -otherNotebookAction[ chatNB_, locked_, title_, nbo_ ] := - Row @ { Style[ "\[Checkmark] ", ShowContents -> locked === nbo ], formatNotebookTitle @ title } :> ( - CurrentChatSettings[ chatNB, "AllowSelectionContext" ] = True; - CurrentChatSettings[ chatNB, "FocusedNotebook" ] = nbo - ); - -otherNotebookAction // endDefinition; - -(* ::**************************************************************************************************************:: *) -(* ::Subsubsection::Closed:: *) -(*getLockedNotebook*) -getLockedNotebook // beginDefinition; -getLockedNotebook[ nbo_ ] := getLockedNotebook[ nbo, CurrentChatSettings[ nbo, "FocusedNotebook" ] ]; -getLockedNotebook[ nbo_, focused_ ] := If[ TrueQ @ notebookObjectQ @ focused, focused, None ]; -getLockedNotebook // endDefinition; - (* ::**************************************************************************************************************:: *) (* ::Section::Closed:: *) (*Inline Chat*) @@ -1871,8 +1651,8 @@ notebookSources // endDefinition; (* ::Subsubsection::Closed:: *) (*formatNotebookTitle*) formatNotebookTitle // beginDefinition; +formatNotebookTitle[ None|"" ] := Style[ "Unnamed Notebook", FontColor -> GrayLevel[ 0.6 ], FontSlant -> Italic ]; formatNotebookTitle[ title_String ] := title; -formatNotebookTitle[ None ] := Style[ "Unnamed Notebook", FontColor -> GrayLevel[ 0.6 ], FontSlant -> Italic ]; formatNotebookTitle // endDefinition; (* ::**************************************************************************************************************:: *) diff --git a/Source/Chatbook/CommonSymbols.wl b/Source/Chatbook/CommonSymbols.wl index 53bd7a40..12b33157 100644 --- a/Source/Chatbook/CommonSymbols.wl +++ b/Source/Chatbook/CommonSymbols.wl @@ -164,6 +164,7 @@ BeginPackage[ "Wolfram`Chatbook`Common`" ]; `fixLineEndings; `floatingButtonGrid; `forceRefreshCloudPreferences; +`formatNotebookTitle; `functionTemplateBoxes; `getAvailableServiceNames; `getBoxObjectFromBoxID; diff --git a/Source/Chatbook/Formatting.wl b/Source/Chatbook/Formatting.wl index 53d86cc5..078b9bb4 100644 --- a/Source/Chatbook/Formatting.wl +++ b/Source/Chatbook/Formatting.wl @@ -694,19 +694,39 @@ evaluateLanguageLabel[ name_String, True ] := ], "LinkHand" ], - Row[ Flatten @ { - trExprTemplate[ "FormattingInsertContentAndEvaluateWorkspaceChatTooltip" ][ <| "1" -> - { - chatbookIcon[ "WorkspaceFocusIndicatorNotebook", False ], - "\[ThinSpace]", - Style[ CurrentValue[ EvaluationNotebook[], { TaggingRules, "FocusWindowTitle" } ], FontWeight -> Bold ] - } |> ] - } ] + targetNotebookLabel @ EvaluationNotebook[ ] ] /; MatchQ[ icon, _Graphics | _Dynamic | _Image ] ]; evaluateLanguageLabel[ ___ ] := $insertEvaluateButtonLabel; +(* ::**************************************************************************************************************:: *) +(* ::Subsubsection::Closed:: *) +(*targetNotebookLabel*) +targetNotebookLabel // beginDefinition; + +targetNotebookLabel[ nbo_NotebookObject ] := + targetNotebookLabel[ nbo, GetFocusedNotebook @ nbo ]; + +targetNotebookLabel[ nbo_, None ] := + tr[ "FormattingInsertContentAndEvaluateWorkspaceChatTooltipNew" ]; + +targetNotebookLabel[ nbo_, focused_NotebookObject ] := + targetNotebookLabel[ nbo, focused, AbsoluteCurrentValue[ focused, WindowTitle ] ]; + +targetNotebookLabel[ nbo_, focused_NotebookObject, title_ ] := + Row @ Flatten @ { + trExprTemplate[ "FormattingInsertContentAndEvaluateWorkspaceChatTooltip" ][ <| + "1" -> { + chatbookIcon[ "WorkspaceFocusIndicatorNotebook", False ], + "\[ThinSpace]", + Style[ formatNotebookTitle @ title, FontWeight -> Bold ] + } + |> ] + }; + +targetNotebookLabel // endDefinition; + (* ::**************************************************************************************************************:: *) (* ::Section::Closed:: *) (*Buttons*) @@ -871,7 +891,7 @@ copyCodeBlock // endDefinition; (* ::Subsubsection::Closed:: *) (*getNotebookForCodeInsertion*) getNotebookForCodeInsertion // beginDefinition; -getNotebookForCodeInsertion[ chatNB_NotebookObject ] := getNotebookForCodeInsertion[ chatNB, getUserNotebook[ ] ]; +getNotebookForCodeInsertion[ chatNB_NotebookObject ] := getNotebookForCodeInsertion[ chatNB, GetFocusedNotebook @ chatNB ]; getNotebookForCodeInsertion[ _, userNB_NotebookObject ] := userNB; getNotebookForCodeInsertion[ _, None ] := CreateNotebook[ ]; getNotebookForCodeInsertion // endDefinition; diff --git a/Source/Chatbook/Main.wl b/Source/Chatbook/Main.wl index 50fcda8d..48d7f371 100644 --- a/Source/Chatbook/Main.wl +++ b/Source/Chatbook/Main.wl @@ -63,6 +63,7 @@ BeginPackage[ "Wolfram`Chatbook`" ]; `GetChatHistory; `GetExpressionURI; `GetExpressionURIs; +`GetFocusedNotebook; `InlineTemplateBoxes; `InvalidateServiceCache; `ListSavedChats; @@ -227,6 +228,7 @@ $ChatbookProtectedNames = "Wolfram`Chatbook`" <> # & /@ { "GetChatHistory", "GetExpressionURI", "GetExpressionURIs", + "GetFocusedNotebook", "InlineTemplateBoxes", "ListSavedChats", "LoadChat",