ui: IDE communication integration
* handled communication from VS to Coati and vice versa. * one bug still remains: Coati regards a tab as a single character while VS regards it as multiple characters. This causes offsets in communicated positions.
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
#include "component/controller/FeatureController.h"
|
||||
|
||||
#include "utility/messaging/type/MessageActivateTokens.h"
|
||||
#include "utility/messaging/type/MessageRefresh.h"
|
||||
|
||||
#include "data/access/StorageAccess.h"
|
||||
#include "settings/ApplicationSettings.h"
|
||||
|
||||
#include "utility/messaging/type/MessageActivateTokens.h"
|
||||
#include "utility/messaging/type/MessageRefresh.h"
|
||||
|
||||
FeatureController::FeatureController(StorageAccess* storageAccess)
|
||||
: m_storageAccess(storageAccess)
|
||||
, m_activationTranslator(storageAccess)
|
||||
|
||||
@@ -3,6 +3,9 @@
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "component/controller/helper/ActivationTranslator.h"
|
||||
#include "component/controller/Controller.h"
|
||||
|
||||
#include "utility/messaging/MessageListener.h"
|
||||
#include "utility/messaging/type/MessageActivateEdge.h"
|
||||
#include "utility/messaging/type/MessageActivateFile.h"
|
||||
@@ -12,9 +15,6 @@
|
||||
#include "utility/messaging/type/MessageSwitchColorScheme.h"
|
||||
#include "utility/messaging/type/MessageZoom.h"
|
||||
|
||||
#include "component/controller/Controller.h"
|
||||
#include "component/controller/helper/ActivationTranslator.h"
|
||||
|
||||
class StorageAccess;
|
||||
|
||||
class FeatureController
|
||||
|
||||
@@ -1,11 +1,15 @@
|
||||
#include "IDECommunicationController.h"
|
||||
|
||||
#include "utility/messaging/type/MessageActivateTokens.h"
|
||||
#include "component/controller/helper/NetworkProtocolHelper.h"
|
||||
#include "data/access/StorageAccess.h"
|
||||
#include "data/location/TokenLocationFile.h"
|
||||
#include "data/location/TokenLocation.h"
|
||||
|
||||
#include "utility/messaging/type/MessageActivateTokenLocations.h"
|
||||
#include "utility/logging/logging.h"
|
||||
|
||||
#include "component/controller/helper/NetworkProtocolHelper.h"
|
||||
|
||||
IDECommunicationController::IDECommunicationController()
|
||||
IDECommunicationController::IDECommunicationController(StorageAccess* storageAccess)
|
||||
: m_storageAccess(storageAccess)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -21,7 +25,31 @@ void IDECommunicationController::handleIncomingMessage(const std::string& messag
|
||||
|
||||
if (parsedMessage.valid)
|
||||
{
|
||||
// TODO: set active token
|
||||
const unsigned int cursorColumn = parsedMessage.column;
|
||||
|
||||
std::shared_ptr<TokenLocationFile> tokenLocationFile = m_storageAccess->getTokenLocationsForLinesInFile(
|
||||
parsedMessage.fileLocation, parsedMessage.row, parsedMessage.row
|
||||
);
|
||||
|
||||
std::vector<Id> selectedLocationIds;
|
||||
tokenLocationFile->forEachStartTokenLocation(
|
||||
[&](TokenLocation* startLocation)
|
||||
{
|
||||
if (startLocation->getColumnNumber() < cursorColumn)
|
||||
{
|
||||
TokenLocation* endLocation = startLocation->getOtherTokenLocation();
|
||||
if (endLocation && endLocation->getColumnNumber() > cursorColumn)
|
||||
{
|
||||
selectedLocationIds.push_back(startLocation->getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
if (selectedLocationIds.size() > 0)
|
||||
{
|
||||
MessageActivateTokenLocations(selectedLocationIds).dispatch();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,17 +3,19 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "component/controller/Controller.h"
|
||||
|
||||
#include "utility/messaging/MessageListener.h"
|
||||
#include "utility/messaging/type/MessageMoveIDECursor.h"
|
||||
|
||||
#include "component/controller/Controller.h"
|
||||
class StorageAccess;
|
||||
|
||||
class IDECommunicationController
|
||||
: public Controller
|
||||
, public MessageListener<MessageMoveIDECursor>
|
||||
{
|
||||
public:
|
||||
IDECommunicationController();
|
||||
IDECommunicationController(StorageAccess* storageAccess);
|
||||
virtual ~IDECommunicationController();
|
||||
|
||||
void handleIncomingMessage(const std::string& message);
|
||||
@@ -21,6 +23,8 @@ public:
|
||||
private:
|
||||
virtual void handleMessage(MessageMoveIDECursor* message);
|
||||
virtual void sendMessage(const std::string& message) const = 0;
|
||||
|
||||
StorageAccess* m_storageAccess;
|
||||
};
|
||||
|
||||
#endif // IDE_COMMUNICATION_CONTROLLER_H
|
||||
@@ -4,6 +4,7 @@
|
||||
#include <memory>
|
||||
|
||||
class IDECommunicationController;
|
||||
class StorageAccess;
|
||||
|
||||
class NetworkFactory
|
||||
{
|
||||
@@ -11,7 +12,7 @@ public:
|
||||
NetworkFactory();
|
||||
virtual ~NetworkFactory();
|
||||
|
||||
virtual std::shared_ptr<IDECommunicationController> createIDECommunicationController() const = 0;
|
||||
virtual std::shared_ptr<IDECommunicationController> createIDECommunicationController(StorageAccess* storageAccess) const = 0;
|
||||
};
|
||||
|
||||
#endif // NETWORK_FACTORY_H
|
||||
@@ -12,29 +12,25 @@ NetworkProtocolHelper::NetworkMessage NetworkProtocolHelper::parseMessage(const
|
||||
{
|
||||
NetworkMessage networkMessage;
|
||||
|
||||
std::string tmpMessage = removeEndOfMessageToken(message);
|
||||
|
||||
size_t pos = tmpMessage.find(m_setActiveTokenPrefix);
|
||||
size_t pos = message.find(m_setActiveTokenPrefix);
|
||||
|
||||
if(pos != std::string::npos)
|
||||
{
|
||||
tmpMessage = "";
|
||||
std::string tmpMessage = "";
|
||||
getSubstringAfterString(message, m_divider, tmpMessage); // just get rid of message type
|
||||
tmpMessage = removeEndOfMessageToken(tmpMessage);
|
||||
|
||||
std::string fileLocation = getSubstringAfterString(tmpMessage, m_divider, tmpMessage);
|
||||
std::string row = getSubstringAfterString(tmpMessage, m_divider, tmpMessage);
|
||||
std::string column = tmpMessage; // getSubstringAfterString(tmpMessage, "", tmpMessage); // there should be nothing left in the message but the column number
|
||||
std::string column = tmpMessage; // there should be nothing left in the message but the column number
|
||||
|
||||
if(fileLocation.length() <= 0
|
||||
|| row.length() <= 0
|
||||
|| column.length() <= 0
|
||||
|| isDigits(row) == false
|
||||
|| isDigits(column) == false)
|
||||
{
|
||||
return networkMessage;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(
|
||||
fileLocation.length() > 0
|
||||
&& row.length() > 0
|
||||
&& column.length() > 0
|
||||
&& isDigits(row)
|
||||
&& isDigits(column)
|
||||
){
|
||||
networkMessage.fileLocation = fileLocation;
|
||||
networkMessage.row = std::stoi(row);
|
||||
networkMessage.column = std::stoi(column);
|
||||
|
||||
Reference in New Issue
Block a user