32#ifndef EVALUATIONQUEUE_H
33#define EVALUATIONQUEUE_H
38#include <wx/stopwatch.h>
56 Command(
const wxString &strng,
long start,
long index)
57 : m_start(start), m_indexStart(index), m_command(strng) {}
59 const wxString &GetString()
const {
return m_command; }
62 wxString trimmed = m_command;
64 if (!trimmed.EndsWith(wxS(
";")) && !trimmed.EndsWith(wxS(
"$")))
68 int GetIndex()
const {
return m_indexStart; }
70 long GetStart()
const {
return m_start; }
73 long m_indexStart = -1;
87 std::vector<EvaluationQueue::Command> m_commands;
89 wxString m_pendingText;
94 long m_cellConsumedChars = 0;
108 wxStopWatch m_commandStopwatch;
111 bool m_commandTimerRunning =
false;
117 wxString textAtEnqueue;
120 std::vector<QueuedCell> m_queue;
131 bool m_integrityFailure =
false;
132 wxString m_integrityFailureEnqueuedText;
133 wxString m_integrityFailureCurrentText;
141 void ProduceNextCommand();
151 {
return m_userLabel; }
155 if (!m_commands.empty())
156 return m_commands.front().GetIndex();
182 long end, std::size_t offset,
185 long GetCommandStart()
const
187 if (!m_commands.empty())
188 return m_commands.front().GetStart();
193 bool m_workingGroupChanged =
false;
199 if (!m_commands.empty())
200 m_commands.back().AddEnding();
209 return !m_queue.empty() && (gr == m_queue.front().cell);
250 {
return m_integrityFailureEnqueuedText; }
254 {
return m_integrityFailureCurrentText; }
257 int Size()
const {
return m_size; }
270 m_commandStopwatch.Start();
271 m_commandTimerRunning =
true;
279 return m_commandTimerRunning ? m_commandStopwatch.Time() : -1;
This file defines the class GroupCell that bundles input and output in the worksheet.
A weak non-owning pointer that becomes null whenever the observed object is destroyed.
Definition: CellPtr.h:539
The configuration storage for the current worksheet.
Definition: Configuration.h:101
A simple FIFO queue with manual removal of elements.
Definition: EvaluationQueue.h:44
void Remove(GroupCell *gr)
Remove a GroupCell from the evaluation queue.
Definition: EvaluationQueue.cpp:64
wxString GetUserLabel() const
Query for the label the user has assigned to the current command.
Definition: EvaluationQueue.h:150
bool IsLastInQueue(GroupCell const *gr)
Is GroupCell gr part of the evaluation queue?
Definition: EvaluationQueue.h:207
long GetCommandElapsedMilliseconds() const
Milliseconds since MarkCommandSent() was last called for the command currently in flight,...
Definition: EvaluationQueue.h:277
bool IsInQueue(GroupCell *gr) const
Is GroupCell gr part of the evaluation queue?
Definition: EvaluationQueue.cpp:58
void Clear()
Clear the queue.
Definition: EvaluationQueue.cpp:44
bool Empty() const
Is the queue empty?
Definition: EvaluationQueue.cpp:35
void AddHiddenTreeToQueue(const GroupCell *gr)
Adds all hidden cells attached to the GroupCell gr to the evaluation queue.
Definition: EvaluationQueue.cpp:105
void AddToQueue(GroupCell *gr)
Adds a GroupCell to the evaluation queue.
Definition: EvaluationQueue.cpp:81
wxString GetCommand()
Return the next command that needs to be evaluated.
Definition: EvaluationQueue.cpp:397
void RemoveFirst()
Removes the first command in the queue.
Definition: EvaluationQueue.cpp:115
static long CommandPositionInCell(const wxString &cellText, long start, long end, std::size_t offset, Configuration *configuration)
Where in its cell the current command starts.
Definition: EvaluationQueue.cpp:341
GroupCell * GetCell()
Gets the cell the next command in the queue belongs to.
Definition: EvaluationQueue.cpp:390
bool HasIntegrityFailure() const
Did the cell that just became current (see GetCell()) have different text than what was captured when...
Definition: EvaluationQueue.h:246
int CommandsLeftInCell() const
Roughly how many commands are still to be run in the current cell. Because commands are tokenized laz...
Definition: EvaluationQueue.cpp:368
const wxString & GetIntegrityFailureCurrentText() const
The cell's text as AddTokens() actually read it, valid only while HasIntegrityFailure() is true for t...
Definition: EvaluationQueue.h:253
const wxString & GetIntegrityFailureEnqueuedText() const
The cell's text as it was when AddToQueue() was called, valid only while HasIntegrityFailure() is tru...
Definition: EvaluationQueue.h:249
int Size() const
Get the size of the queue [in cells].
Definition: EvaluationQueue.h:257
void MarkCommandSent()
Call exactly once, right after the current command's text is actually written to Maxima's socket – st...
Definition: EvaluationQueue.h:268
A cell grouping input (and, if there is one, also the output) cell to a foldable item.
Definition: GroupCell.h:88