Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Directories and Window colors #31

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 19 additions & 4 deletions src/Frontend/AutoCompleteManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,15 @@ void AutoCompleteManager::BuildFromProject(const Project* project)
{
BuildFromFile(project->GetFile(fileIndex));
}
for (unsigned int directoryIndex = 0; directoryIndex < project->GetNumDirectories(); ++directoryIndex)
{
Project::Directory const *directory = project->GetDirectory(directoryIndex);

for (unsigned int fileIndex = 0; fileIndex < directory->files.size(); ++fileIndex)
{
BuildFromFile(directory->files[fileIndex]);
}
}

// Sort the autocompletions (necessary for binary search).
std::sort(m_entries.begin(), m_entries.end());
Expand All @@ -66,20 +75,19 @@ void AutoCompleteManager::BuildFromFile(const Project::File* file)

}

void AutoCompleteManager::GetMatchingItems(const wxString& prefix, bool member, wxString& items) const
void AutoCompleteManager::GetMatchingItems(const wxString& token, const wxString& prefix, bool member, wxString& items) const
{

// Autocompletion selection is case insensitive so transform everything
// to lowercase.
wxString test = prefix.Lower();
wxString test = token.Lower();

// Add the items to the list that begin with the specified prefix. This
// could be done much fater with a binary search since our items are in
// alphabetical order.

for (unsigned int i = 0; i < m_entries.size(); ++i)
{

// Check that the scope is correct.

bool inScope = false;
Expand All @@ -89,7 +97,14 @@ void AutoCompleteManager::GetMatchingItems(const wxString& prefix, bool member,
// We've got no way of knowing the type of the variable in Lua (since
// variables don't have types, only values have types), so we display
// all members if the prefix contains a member selection operator (. or :)
inScope = (m_entries[i].scope.IsEmpty() != member);
if (!m_entries[i].scope.IsEmpty() && member)
{
inScope = m_entries[i].scope == prefix;
}
else
{
inScope = m_entries[i].scope.IsEmpty() != member;
}
}

if (inScope && m_entries[i].lowerCaseName.StartsWith(test))
Expand Down
2 changes: 1 addition & 1 deletion src/Frontend/AutoCompleteManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class AutoCompleteManager
* only autocompletions that are members of some scope are included. The return items
* string is in the format used by Scintilla to display autocompletions.
*/
void GetMatchingItems(const wxString& prefix, bool member, wxString& items) const;
void GetMatchingItems(const wxString& token, const wxString& prefix, bool member, wxString& items) const;

private:

Expand Down
20 changes: 19 additions & 1 deletion src/Frontend/BreakpointsWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,20 @@ BreakpointsWindow::BreakpointsWindow(MainFrame* mainFrame, wxWindowID winid)

fgSizer1->Add( m_buttonBar, 0, wxALL|wxEXPAND, 3 );
fgSizer1->Add( m_breakpointList, 0, wxALL|wxEXPAND, 0 );




SetSizer( fgSizer1 );
Layout();

}

void BreakpointsWindow::SetFontColorSettings(const FontColorSettings& settings)
{
m_breakpointList->SetBackgroundColour(settings.GetColors(FontColorSettings::DisplayItem_Window).backColor);
m_breakpointList->SetTextColour(settings.GetColors(FontColorSettings::DisplayItem_Window).foreColor);
}

void BreakpointsWindow::SetProject(Project* project)
{
m_project = project;
Expand All @@ -124,6 +132,16 @@ void BreakpointsWindow::UpdateBreakpoints()
{
AddBreakpointsForFile(m_project->GetFile(i));
}

for (unsigned int directoryIndex = 0; directoryIndex < m_project->GetNumDirectories(); ++directoryIndex)
{
Project::Directory *directory = m_project->GetDirectory(directoryIndex);
for (unsigned int fileIndex = 0; fileIndex < directory->files.size(); ++fileIndex)
{
Project::File *file = directory->files[fileIndex];
AddBreakpointsForFile(file);
}
}
}

m_breakpointList->Thaw();
Expand Down
6 changes: 6 additions & 0 deletions src/Frontend/BreakpointsWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ along with Decoda. If not, see <http://www.gnu.org/licenses/>.
#define BREAKPOINTS_WINDOW_H

#include "Project.h"
#include "FontColorSettings.h"

#include <wx/wx.h>
#include <wx/listctrl.h>
Expand Down Expand Up @@ -51,6 +52,11 @@ class BreakpointsWindow : public wxPanel
*/
BreakpointsWindow(MainFrame* mainFrame, wxWindowID winid);

/**
* Updates the colors of the panel to match the settings
*/
void SetFontColorSettings(const FontColorSettings& settings);

/**
* Sets the project we're displaying the breakpoints for.
*/
Expand Down
13 changes: 7 additions & 6 deletions src/Frontend/CodeEdit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -670,6 +670,7 @@ void CodeEdit::StartAutoCompletion(const wxString& token)
// If the token refers to a member, the prefix is the member name.

wxString prefix;
wxString newToken;
bool member = false;

if (GetLexer() == wxSCI_LEX_LUA)
Expand Down Expand Up @@ -702,24 +703,24 @@ void CodeEdit::StartAutoCompletion(const wxString& token)
}

int end = std::max(end1, end2);
prefix = token.Right( token.Length() - end );

newToken = token.Right(token.Length() - end);
prefix = token.Left(end - 1);
}
else
{
// No autocompletion when using the default lexer.
return;
}

if (!member && prefix.Length() < m_minAutoCompleteLength)
if (!member && newToken.Length() < m_minAutoCompleteLength)
{
// Don't pop up the auto completion if the user hasn't typed in very
// much yet.
return;
}

m_autoCompleteManager->GetMatchingItems(prefix, member, items);
m_autoCompleteManager->GetMatchingItems(newToken, prefix, member, items);

if (!AutoCompActive() || m_autoCompleteItems != items)
{

Expand All @@ -730,7 +731,7 @@ void CodeEdit::StartAutoCompletion(const wxString& token)
if (!items.IsEmpty())
{
// Show the autocomplete selection list.
AutoCompShow(prefix.Length(), items);
AutoCompShow(newToken.Length(), items);
}
else
{
Expand Down
7 changes: 6 additions & 1 deletion src/Frontend/FontColorSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ along with Decoda. If not, see <http://www.gnu.org/licenses/>.

#include <wx/xml/xml.h>

const char* FontColorSettings::s_displayItemName[] = { "Default", "Comment", "Keyword", "Operator", "String", "Number", "Error", "Warning", "Selection" };
const char* FontColorSettings::s_displayItemName[] = { "Default", "Comment", "Keyword", "Operator", "String", "Number", "Error", "Warning", "Selection", "Window" };

FontColorSettings::FontColorSettings()
{
Expand Down Expand Up @@ -77,6 +77,11 @@ FontColorSettings::FontColorSettings()
m_colors[DisplayItem_Selection].bold = false;
m_colors[DisplayItem_Selection].italic = false;

m_colors[DisplayItem_Window].foreColor = wxColor(255,255,255);
m_colors[DisplayItem_Window].backColor = wxColor(51,51,51);
m_colors[DisplayItem_Window].bold = false;
m_colors[DisplayItem_Window].italic = false;

}

unsigned int FontColorSettings::GetNumDisplayItems() const
Expand Down
1 change: 1 addition & 0 deletions src/Frontend/FontColorSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ class FontColorSettings
DisplayItem_Error,
DisplayItem_Warning,
DisplayItem_Selection,
DisplayItem_Window,
DisplayItem_Last,
};

Expand Down
5 changes: 5 additions & 0 deletions src/Frontend/ListWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,12 @@ ListWindow::ListWindow(MainFrame* mainFrame, wxWindowID winid)
imageList->Add( wxMEMORY_BITMAP(Currentline_png) );

AssignImageList(imageList, wxIMAGE_LIST_SMALL);
}

void ListWindow::SetFontColorSettings(const FontColorSettings& settings)
{
SetBackgroundColour(settings.GetColors(FontColorSettings::DisplayItem_Window).backColor);
SetTextColour(settings.GetColors(FontColorSettings::DisplayItem_Window).foreColor);
}

void ListWindow::Append(const wxString& name)
Expand Down
6 changes: 6 additions & 0 deletions src/Frontend/ListWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ along with Decoda. If not, see <http://www.gnu.org/licenses/>.
#include <wx/wx.h>

#include "ListView.h"
#include "FontColorSettings.h"

//
// Forward declarations.
Expand All @@ -52,6 +53,11 @@ class ListWindow : public ListView
*/
ListWindow(MainFrame* mainFrame, wxWindowID winid);

/**
* Updates the colors of the panel to match the settings
*/
void SetFontColorSettings(const FontColorSettings& settings);

/**
* Adds an item to the list.
*/
Expand Down
1 change: 0 additions & 1 deletion src/Frontend/MainApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ bool MainApp::OnInit()
UINT openFilesMessage = RegisterWindowMessage("Decoda_OpenFiles");

// Check to see if another instances is running.

if (!wxApp::OnInit())
{
return false;
Expand Down
Loading