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

Cannot configure Emmet in Notepad++ #2

Open
wants to merge 28 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
b6e8ab7
Moving to Emmet core
sergeche Feb 14, 2013
96c30e2
Removed *.pyc files
sergeche Feb 14, 2013
96620fb
Added compiled binary
sergeche Feb 14, 2013
13ebda1
Updated binary package
sergeche Feb 14, 2013
49ad2e5
Minor fixes and core update
sergeche Feb 18, 2013
f404b45
Updated binary
sergeche Feb 18, 2013
cca6397
Added README
sergeche Feb 18, 2013
8d35531
Minor update in file reader
sergeche Feb 18, 2013
176e771
Updated snippets
sergeche Feb 21, 2013
16c9716
Updated core and file reader
sergeche Feb 23, 2013
2d7901c
Workaround for some user-defined syntaxes detection
sergeche Feb 24, 2013
0b8da62
Added note about installation
sergeche Feb 24, 2013
497bb51
Update README.md
sergeche Feb 24, 2013
f25a288
Fixing multibyte character issues
sergeche Feb 28, 2013
036a248
Merge branch 'master' of github.com:emmetio/npp
sergeche Feb 28, 2013
bff3616
Updated to v1.0.1
sergeche Mar 3, 2013
625ada2
Allow override of empty tags
sergeche Mar 3, 2013
4aceef9
Updated snippets
sergeche Mar 3, 2013
e591cb0
Use default Plugins folder for Emmet loader
sergeche Apr 4, 2013
4efe978
Small bugfixes
sergeche Apr 22, 2013
a95a0aa
Updated JS core
sergeche Apr 22, 2013
1d81100
Possible fix for Latin encodings
sergeche Apr 23, 2013
37c63f3
Updated download location
sergeche May 10, 2013
9fa3c6c
Update README.md
sergeche May 17, 2013
0c032c0
Added CodersClan button
sergeche May 20, 2013
838ee78
Remove CodersClan support for Emmet
BadGoat Aug 7, 2016
2638986
Merge pull request #16 from CodersClan/master
sergeche Aug 8, 2016
0cc3839
Create LICENSE
sergeche Oct 25, 2016
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,6 @@ ipch/
*.sdf
*.opensdf
*.aps
*.pyc
/EmmetNPP.dll
.DS_Store
179 changes: 99 additions & 80 deletions ZenCoding-Python.cpp → EmmetNPP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ struct SCNotification


/* Info for Notepad++ */
CONST TCHAR PLUGIN_NAME[] = _T("Zen Coding - Python");
CONST TCHAR PLUGIN_NAME[] = _T("Emmet");

FuncItem *funcItem = NULL;

Expand Down Expand Up @@ -69,36 +69,44 @@ void initialise()
TCHAR configPath[MAX_PATH];
::SendMessage(nppData._nppHandle, NPPM_GETPLUGINSCONFIGDIR, MAX_PATH, reinterpret_cast<LPARAM>(configPath));

tstring my_zen_settings(configPath);
my_zen_settings.append(_T("\\ZenCodingPython\\zencoding\\my_zen_settings.py"));


if (!::PathFileExists(my_zen_settings.c_str()))
{
std::ofstream mySettingsFile(my_zen_settings.c_str());

mySettingsFile << "my_zen_settings = {\n"
" 'html': {\n"
" 'abbreviations': {\n"
" 'jq': '<script type=\"text/javascript\" src=\"http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js\"></script>',\n"
" 'demo': '<div id =\"demo\"></div>'\n"
" }\n"
" }\n"
"}\n";
mySettingsFile.close();

}

tstring zen_module(_T("sys.path.append(r'"));
zen_module.append(configPath);
zen_module.append(_T("\\ZenCodingPython')\nimport npp_zen_coding\n"));

runString(zen_module.c_str());
//tstring my_zen_settings(configPath);
//my_zen_settings.append(_T("\\ZenCodingPython\\zencoding\\my_zen_settings.py"));

//
//if (!::PathFileExists(my_zen_settings.c_str()))
//{
// std::ofstream mySettingsFile(my_zen_settings.c_str());

// mySettingsFile << "my_zen_settings = {\n"
// " 'html': {\n"
// " 'abbreviations': {\n"
// " 'jq': '<script type=\"text/javascript\" src=\"http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js\"></script>',\n"
// " 'demo': '<div id =\"demo\"></div>'\n"
// " }\n"
// " }\n"
// "}\n";
// mySettingsFile.close();

//}

tstring emmet_module(_T("from Npp import notepad, console\n"));
emmet_module.append(_T("import os.path\n"));
emmet_module.append(_T("sys.path.insert(0, os.path.join(notepad.getPluginConfigDir(), 'EmmetNPP'))\n"));
emmet_module.append(_T("sys.path.insert(0, os.path.join(notepad.getNppDir(), 'plugins', 'EmmetNPP'))\n"));
emmet_module.append(_T("console.write('Starting Emmet\\n')\n"));
emmet_module.append(_T("console.write('%s\\n' % sys.path)\n"));
emmet_module.append(_T("import npp_emmet\n"));

/*tstring emmet_module(_T("sys.path.append(r'"));
emmet_module.append(configPath);
emmet_module.append(_T("\\EmmetNPP')\nimport npp_emmet\n"));*/

runString(emmet_module.c_str());

g_initialised = true;

// Set the current profile if it's not xhtml (the default)
if (g_fiProfileHtml == g_currentProfileIndex)
/*if (g_fiProfileHtml == g_currentProfileIndex)
{
setProfile(_T("html"), g_fiProfileHtml);
}
Expand All @@ -109,7 +117,7 @@ void initialise()
else if (g_fiProfilePlain == g_currentProfileIndex)
{
setProfile(_T("plain"), g_fiProfilePlain);
}
}*/



Expand All @@ -120,11 +128,11 @@ void doExpandAbbreviation()
CHECK_INITIALISED();
if (g_expandIsTab)
{
runString(_T("npp_zen_coding.expand_abbreviation(True)"));
runString(_T("npp_emmet.expand_abbreviation(True)"));
}
else
{
runString(_T("npp_zen_coding.expand_abbreviation(False)"));
runString(_T("npp_emmet.expand_abbreviation(False)"));
}
}

Expand All @@ -133,128 +141,137 @@ void doExpandAbbreviation()
void doWrapWithAbbreviation()
{
CHECK_INITIALISED();
runString(_T("npp_zen_coding.wrap_with_abbreviation()"));
runString(_T("npp_emmet.run_action('wrap_with_abbreviation')"));
}


void doNextEditPoint()
{
CHECK_INITIALISED();
runString(_T("npp_zen_coding.next_edit_point()"));
runString(_T("npp_emmet.run_action('next_edit_point')"));
}

void doPreviousEditPoint()
{
CHECK_INITIALISED();
runString(_T("npp_zen_coding.prev_edit_point()"));
runString(_T("npp_emmet.run_action('prev_edit_point')"));
}

void doSelectNextItem()
{
CHECK_INITIALISED();
runString(_T("npp_zen_coding.select_next_item()"));
runString(_T("npp_emmet.run_action('select_next_item')"));
}

void doSelectPreviousItem()
{
CHECK_INITIALISED();
runString(_T("npp_zen_coding.select_previous_item()"));
runString(_T("npp_emmet.run_action('select_previous_item')"));
}

void doMatchPairInward()
{
CHECK_INITIALISED();
runString(_T("npp_zen_coding.match_pair_inward()"));
runString(_T("npp_emmet.run_action('match_pair_inward')"));
}

void doMatchPairOutward()
{
CHECK_INITIALISED();
runString(_T("npp_zen_coding.match_pair_outward()"));
runString(_T("npp_emmet.run_action('match_pair_outward')"));
}

void doGoToMatchingPair()
{
CHECK_INITIALISED();
runString(_T("npp_zen_coding.go_to_matching_pair()"));
runString(_T("npp_emmet.run_action('go_to_matching_pair')"));
}

void doMergeLines()
{
CHECK_INITIALISED();
runString(_T("npp_zen_coding.merge_lines()"));
runString(_T("npp_emmet.run_action('merge_lines')"));
}

void doToggleComment()
{
CHECK_INITIALISED();
runString(_T("npp_zen_coding.toggle_comment()"));
runString(_T("npp_emmet.run_action('toggle_comment')"));
}

void doSplitJoinTag()
{
CHECK_INITIALISED();
runString(_T("npp_zen_coding.split_join_tag()"));
runString(_T("npp_emmet.run_action('split_join_tag')"));
}

void doRemoveTag()
{
CHECK_INITIALISED();
runString(_T("npp_zen_coding.remove_tag()"));
runString(_T("npp_emmet.run_action('remove_tag')"));
}




void doUpdateImageSize()
{
CHECK_INITIALISED();
runString(_T("npp_zen_coding.update_image_size()"));
runString(_T("npp_emmet.run_action('update_image_size')"));
}

void doAddEntryAbbreviation()
{
CHECK_INITIALISED();
runString(_T("npp_zen_coding.add_entry('abbreviations')"));
}

void doAddEntrySnippet()
{
CHECK_INITIALISED();
runString(_T("npp_zen_coding.add_entry('snippets')"));
}
//void doAddEntryAbbreviation()
//{
// CHECK_INITIALISED();
// runString(_T("npp_zen_coding.add_entry('abbreviations')"));
//}
//
//void doAddEntrySnippet()
//{
// CHECK_INITIALISED();
// runString(_T("npp_zen_coding.add_entry('snippets')"));
//}

void doEvaluateMathExpression()
{
CHECK_INITIALISED();
runString(_T("npp_zen_coding.evaluate_math_expression()"));
runString(_T("npp_emmet.run_action('evaluate_math_expression')"));
}

void doReflectCssValue()
{
CHECK_INITIALISED();
runString(_T("npp_zen_coding.reflect_css_value()"));
runString(_T("npp_emmet.run_action('reflect_css_value')"));
}


void doAutocomplete()
void doInsertLinebreak()
{
CHECK_INITIALISED();
runString(_T("npp_zen_coding.show_autocomplete()"));
runString(_T("npp_emmet.run_action('insert_formatted_line_break_only')"));
}

void doAddAbbreviation()
void doDataURL()
{
CHECK_INITIALISED();
runString(_T("npp_zen_coding.add_entry('abbreviations')"));
runString(_T("npp_emmet.run_action('encode_decode_data_url')"));
}

void doAddSnippet()
void doAutocomplete()
{
CHECK_INITIALISED();
runString(_T("npp_zen_coding.add_entry('snippets')"));
runString(_T("npp_emmet.show_autocomplete()"));
}

//void doAddAbbreviation()
//{
// CHECK_INITIALISED();
// runString(_T("npp_zen_coding.add_entry('abbreviations')"));
//}
//
//void doAddSnippet()
//{
// CHECK_INITIALISED();
// runString(_T("npp_zen_coding.add_entry('snippets')"));
//}

void doAbout()
{
aboutDlg.doDialog();
Expand Down Expand Up @@ -298,15 +315,15 @@ void setProfile(const TCHAR *profileName, int cmdIndex)

::SendMessage(nppData._nppHandle, NPPM_SETMENUITEMCHECK, funcItem[cmdIndex]._cmdID, TRUE);

if (g_initialised)
/*if (g_initialised)
{
TCHAR cmd[150];
_tcscpy_s(cmd, 150, _T("npp_zen_coding.set_profile('"));
_tcscat_s(cmd, 150, profileName);
_tcscat_s(cmd, 150, _T("')"));

runString(cmd);
}
}*/
g_currentProfile = profileName;
g_currentProfileIndex = cmdIndex;
}
Expand Down Expand Up @@ -369,7 +386,7 @@ extern "C" __declspec(dllexport) void setInfo(NppData notepadPlusData)
aboutDlg.init(static_cast<HINSTANCE>(g_hModule), nppData);

::SendMessage(nppData._nppHandle, NPPM_GETPLUGINSCONFIGDIR, MAX_PATH, reinterpret_cast<LPARAM>(g_iniPath));
_tcscat_s(g_iniPath, MAX_PATH, _T("\\ZenCodingPython.ini"));
_tcscat_s(g_iniPath, MAX_PATH, _T("\\EmmetNPP.ini"));
}


Expand Down Expand Up @@ -407,22 +424,24 @@ extern "C" __declspec(dllexport) FuncItem * getFuncsArray(int *nbF)
g_funcItemManager->addFunction(_T("Split / join tag"), doSplitJoinTag);
g_funcItemManager->addFunction(_T("Remove tag"), doRemoveTag);
g_funcItemManager->addSplitter(); // ----------------------
g_funcItemManager->addFunction(_T("Insert formatted linebreak"), doInsertLinebreak);
g_funcItemManager->addFunction(_T("Toggle comment"), doToggleComment);
g_funcItemManager->addFunction(_T("Update image size"), doUpdateImageSize);
g_funcItemManager->addFunction(_T("Encode/decode image to data:URL"), doDataURL);
g_funcItemManager->addFunction(_T("Reflect CSS value"), doReflectCssValue);
g_funcItemManager->addFunction(_T("Evalute math expression"), doEvaluateMathExpression);
//g_funcItemManager->addSplitter(); // ----------------------
//g_funcItemManager->addFunction(_T("Add abbreviation"), doAddAbbreviation);
//g_funcItemManager->addFunction(_T("Add snippet"), doAddSnippet);
//g_funcItemManager->addSplitter(); // ----------------------
//g_funcItemManager->addFunction(_T("Autocomplete"), doAutocomplete);
g_funcItemManager->addSplitter(); // ----------------------
g_funcItemManager->addFunction(_T("Add abbreviation"), doAddAbbreviation);
g_funcItemManager->addFunction(_T("Add snippet"), doAddSnippet);
g_funcItemManager->addSplitter(); // ----------------------
g_funcItemManager->addFunction(_T("Autocomplete"), doAutocomplete);
g_funcItemManager->addSplitter(); // ----------------------
g_fiAutoProfile = g_funcItemManager->addFunction(_T("Auto select profile"), doProfileAutoSelect, NULL, true);
/*g_fiAutoProfile = g_funcItemManager->addFunction(_T("Auto select profile"), doProfileAutoSelect, NULL, true);
g_fiProfileXhtml = g_funcItemManager->addFunction(_T("Profile: xhtml"), doProfileXhtml, NULL, true);
g_fiProfileHtml = g_funcItemManager->addFunction(_T("Profile: html"), doProfileHtml);
g_fiProfileXml = g_funcItemManager->addFunction(_T("Profile: xml"), doProfileXml);
g_fiProfilePlain = g_funcItemManager->addFunction(_T("Profile: plain"), doProfilePlain);
g_funcItemManager->addSplitter(); // ----------------------
g_funcItemManager->addSplitter();*/ // ----------------------
g_funcItemManager->addFunction(_T("About"), doAbout);

funcItem = g_funcItemManager->getFuncItems(nbF);
Expand Down Expand Up @@ -486,12 +505,12 @@ extern "C" __declspec(dllexport) void beNotified(SCNotification *notifyCode)
{
if (g_initialised)
{
runString(_T("npp_zen_coding.update_settings()"));
::MessageBox(nppData._nppHandle, _T("Zen Coding settings automatically refreshed"), _T("Zen Coding for Notepad++"), MB_ICONINFORMATION);
runString(_T("npp_emmet.reload()"));
::MessageBox(nppData._nppHandle, _T("Emmet settings automatically refreshed"), _T("Emmet for Notepad++"), MB_ICONINFORMATION);
}
else
{
::MessageBox(nppData._nppHandle, _T("New Zen Coding settings have been applied"), _T("Zen Coding for Notepad++"), MB_ICONINFORMATION);
::MessageBox(nppData._nppHandle, _T("New Emmet settings have been applied"), _T("Emmet for Notepad++"), MB_ICONINFORMATION);
}
}
}
Expand Down Expand Up @@ -549,12 +568,12 @@ void runString(const TCHAR *script, int messageType /* = PYSCR_EXECSTATEMENT */)
BOOL delivery = SendMessage(nppData._nppHandle, NPPM_MSGTOPLUGIN, reinterpret_cast<WPARAM>(pluginName), reinterpret_cast<LPARAM>(&commInfo));
if (!delivery)
{
MessageBox(NULL, _T("Python Script Plugin not found. Please install the Python Script plugin from Plugin Manager"), _T("Zen Coding - Python"), 0);
MessageBox(NULL, _T("Python Script Plugin not found. Please install the Python Script plugin from Plugin Manager"), _T("Emmet"), 0);
g_pythonFailure = true;
}
else if (!pse.deliverySuccess)
{
MessageBox(NULL, _T("Python Script Plugin did not accept the script"), _T("Zen Coding - Python"), 0);
MessageBox(NULL, _T("Python Script Plugin did not accept the script"), _T("Emmet"), 0);
g_pythonFailure = true;
}
}
Expand Down
Loading