Skip to content

Commit

Permalink
refine the hotspot navigation priority
Browse files Browse the repository at this point in the history
  • Loading branch information
erinata committed Mar 16, 2012
1 parent c2271c9 commit 05ad70b
Show file tree
Hide file tree
Showing 4 changed files with 118 additions and 21 deletions.
4 changes: 4 additions & 0 deletions Changelog.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
changelog (for developer use only, include unreleased versions)

0.5.56
- Fixed: critical bug of crashing npp when triggering snippets
- Fixed: More refined solution of hotspot navigation priority when the user trigger a snippet in the middle of another snippet

0.5.55
- Add $[0[]0] as the lowest priority hotspot
- change the automatically added hotspot to $[0[]0]
Expand Down
6 changes: 3 additions & 3 deletions Config/Version.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@

//#define TESTING

#define VERSION_TEXT "0.5.55.0"
#define VERSION_NUM 0,5,55,0
#define VERSION_LINEAR 555
#define VERSION_TEXT "0.5.56.0"
#define VERSION_NUM 0,5,56,0
#define VERSION_LINEAR 556
#define VERSION_KEEP_CONFIG_START 549
#define VERSION_STAGE "(Alpha)"
#ifdef TESTING
Expand Down
115 changes: 104 additions & 11 deletions PluginDefinition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5576,8 +5576,6 @@ bool diagActivate(char* tag)
g_selectedText = selectedText;
delete [] selectedText;




SendScintilla(SCI_REPLACESEL,0,(LPARAM)tag);

Expand All @@ -5602,26 +5600,43 @@ bool diagActivate(char* tag)
int navSpot = 0;
bool dynamicSpotTemp = false;
bool dynamicSpot = false;
bool outBound = false;
int prevHotspotPos = -1;

if (g_editorView == false)
{
int i;
if (!tagFound)
{

i = g_listLength-1;
if (posCurrent > g_lastTriggerPosition)
{
do
{
//TODO: limit the search to g_lastTriggerPosition ?
if (searchPrev(g_tagSignList[i]) >= 0)
prevHotspotPos = searchPrev(g_tagSignList[i]);



if (prevHotspotPos >= 0)
{
if (prevHotspotPos < g_lastTriggerPosition)
{
outBound = true;
}

::SendScintilla(SCI_GOTOPOS,g_lastTriggerPosition,0);
posCurrent = g_lastTriggerPosition;

//posCurrent = ::SendScintilla(SCI_GETCURRENTPOS,0,0);
//posCurrent = 0;
//g_lastTriggerPosition = posCurrent;
break;
}
i--;
} while (i>=0);

}

}
Expand All @@ -5643,7 +5658,37 @@ bool diagActivate(char* tag)

i--;
} while ((navSpot <= 0) && (i >= 0));


if (!((navSpot > 0) || (dynamicSpot)))
{
int prevPos = g_lastTriggerPosition;
do
{
g_lastTriggerPosition = prevPos;
prevPos = searchPrev("\\$\\[.\\[",true);
} while (prevPos>0);

//::SendScintilla(SCI_GOTOPOS,0,0);
//g_lastTriggerPosition = 0;
posCurrent = g_lastTriggerPosition;

i = g_listLength - 1;
do
{
if (dynamicSpot)
{
dynamicHotspot(posCurrent,g_tagSignList[i],g_tagTailList[i]);
} else
{
dynamicSpot = dynamicHotspot(posCurrent,g_tagSignList[i],g_tagTailList[i]);
}
::SendScintilla(SCI_GOTOPOS,posCurrent,0);

navSpot = hotSpotNavigation(g_tagSignList[i],g_tagTailList[i]);

i--;
} while ((navSpot <= 0) && (i >= 0));
}
//TODO: this line is position here so the priority spot can be implement, but this cause the
// 1st hotspot not undoable when the snippet is triggered. More investigation on how to
// manipulate the undo list is required to make these 2 features compatible
Expand Down Expand Up @@ -5675,7 +5720,6 @@ bool diagActivate(char* tag)
return retVal;
}


void tabActivate()
{
if (sciFocus)
Expand Down Expand Up @@ -5753,6 +5797,8 @@ void tabActivate()
int navSpot = 0;
bool dynamicSpotTemp = false;
bool dynamicSpot = false;
bool outBound = false;
int prevHotspotPos = -1;

if (g_editorView == false)
{
Expand All @@ -5765,22 +5811,36 @@ void tabActivate()
do
{
//TODO: limit the search to g_lastTriggerPosition ?
if (searchPrev(g_tagSignList[i]) >= 0)
prevHotspotPos = searchPrev(g_tagSignList[i]);



if (prevHotspotPos >= 0)
{
if (prevHotspotPos < g_lastTriggerPosition)
{
outBound = true;
}

::SendScintilla(SCI_GOTOPOS,g_lastTriggerPosition,0);
posCurrent = g_lastTriggerPosition;

//posCurrent = ::SendScintilla(SCI_GETCURRENTPOS,0,0);
//posCurrent = 0;
//g_lastTriggerPosition = posCurrent;
break;
}
i--;
} while (i>=0);
}

}
//TODO: cater more level of priority
//TODO: Params inertion will stop when navSpot is true, so it is not working properly under differnt level of priority
// Or in other words it only work for the highest existing level of priority
i = g_listLength - 1;


i = g_listLength - 1;
do
{
if (dynamicSpot)
Expand All @@ -5797,6 +5857,37 @@ void tabActivate()
i--;
} while ((navSpot <= 0) && (i >= 0));

if ((!((navSpot > 0) || (dynamicSpot))) && (outBound))
{
int prevPos = g_lastTriggerPosition;
do
{
g_lastTriggerPosition = prevPos;
prevPos = searchPrev("\\$\\[.\\[",true);
} while (prevPos>0);

//::SendScintilla(SCI_GOTOPOS,0,0);
//g_lastTriggerPosition = 0;
posCurrent = g_lastTriggerPosition;

i = g_listLength - 1;
do
{
if (dynamicSpot)
{
dynamicHotspot(posCurrent,g_tagSignList[i],g_tagTailList[i]);
} else
{
dynamicSpot = dynamicHotspot(posCurrent,g_tagSignList[i],g_tagTailList[i]);
}
::SendScintilla(SCI_GOTOPOS,posCurrent,0);

navSpot = hotSpotNavigation(g_tagSignList[i],g_tagTailList[i]);

i--;
} while ((navSpot <= 0) && (i >= 0));
}

//TODO: this line is position here so the priority spot can be implement, but this cause the
// 1st hotspot not undoable when the snippet is triggered. More investigation on how to
// manipulate the undo list is required to make these 2 features compatible
Expand Down Expand Up @@ -5913,9 +6004,11 @@ void removehook()
void testing2()
{
alert("testing2");
::SendMessage(nppData._nppHandle, NPPM_MENUCOMMAND, 0, IDM_FILE_NEW);
int importEditorBufferID = ::SendMessage(nppData._nppHandle, NPPM_GETCURRENTBUFFERID, 0, 0);
::SendMessage(nppData._nppHandle, NPPM_SETBUFFERENCODING, (WPARAM)importEditorBufferID, 4);


//::SendMessage(nppData._nppHandle, NPPM_MENUCOMMAND, 0, IDM_FILE_NEW);
//int importEditorBufferID = ::SendMessage(nppData._nppHandle, NPPM_GETCURRENTBUFFERID, 0, 0);
//::SendMessage(nppData._nppHandle, NPPM_SETBUFFERENCODING, (WPARAM)importEditorBufferID, 4);



Expand Down
14 changes: 7 additions & 7 deletions README.rdoc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
= FingerText (current version 0.5.55(Alpha))
= FingerText (current version 0.5.56(Alpha))

Tab triggered snippet plugin for Notepad++.

Expand All @@ -16,10 +16,10 @@ This plugin is still in Alpha stage so do expect that it can be buggy. However,

I guess most notepad++ users are using plugin manager. You can just go to Plugins>Plugin Manager>Show Plugin Manager and look for Fingertext to install this plugin.

However if you would like to install it manually or the plugin manager is not providing the most updated version, you can download the file "FingerText - 0.5.55.zip" at http://sourceforge.net/projects/fingertext/files/Alpha%20Releases/FingerText%20-%200.5.55.zip/download
However if you would like to install it manually or the plugin manager is not providing the most updated version, you can download the file "FingerText - 0.5.56.zip" at http://sourceforge.net/projects/fingertext/files/Alpha%20Releases/FingerText%20-%200.5.56.zip/download
Unzip the package and copy the FingerText.dll to the plugins folder of Notepad++. This is the only file you need to run FingerText in notepad++.

The readme.rdoc file is for your reference. And the FingerText0.5.55SampleSnippets.ftd is a file containing some sample snippets. (You need this if you want to follow the usage guide in this document)
The readme.rdoc file is for your reference. And the FingerText0.5.56SampleSnippets.ftd is a file containing some sample snippets. (You need this if you want to follow the usage guide in this document)

== Screenshots

Expand All @@ -37,9 +37,9 @@ http://github.com/downloads/erinata/FingerText/FingerText0.5.46_ScreenClip_4_lab

You should have FingerText installed. If you are in doubt, go to the notepad++ menu, there should be "FingerText" under "Plugins".

To import the sample snippets, go to notepad++ menu > plugin > FingerText > Import Snippets. Choose the file FingerText0.5.55SampleSnippets.ftd (which is the file you downloaded with the FingerText.dll) and all the sample snippets will be installed.
To import the sample snippets, go to notepad++ menu > plugin > FingerText > Import Snippets. Choose the file FingerText0.5.56SampleSnippets.ftd (which is the file you downloaded with the FingerText.dll) and all the sample snippets will be installed.

If you are using plugin Manager to download FingerText or you just cannot locate the sample snippet file, you can download it from http://github.com/downloads/erinata/FingerText/FingerText0.5.55SampleSnippets.ftd
If you are using plugin Manager to download FingerText or you just cannot locate the sample snippet file, you can download it from http://github.com/downloads/erinata/FingerText/FingerText0.5.56SampleSnippets.ftd

To verify you have imported the snippets correctly, go to notepad++ menu > Plugins > FingerText > Show SnippetDock. A Dialog with a list of available snippets should show up.

Expand Down Expand Up @@ -158,7 +158,7 @@ Everything is compatible.

== Upgrading from any version between 0.5.20 and 0.5.35

In version 0.5.55 after you triggered a option hotspot, you can use right/down arrow to move to next option, left/up arrow to move to previous option. Hit tab confirm the choice.
In version 0.5.56 after you triggered a option hotspot, you can use right/down arrow to move to next option, left/up arrow to move to previous option. Hit tab confirm the choice.
Also the option hotspot is not delimited by |~| anymore, it's using is simplier |. So $[![(opt)ABC|DEF|GHI]!] will define an hotspot with 3 options.

Upgrading from any version between 0.5.0 and 0.5.18
Expand Down Expand Up @@ -188,7 +188,7 @@ FingerText 0.3.5 or below use a "one snippet per file" system to store snippets,
== Change log
(for the detail change log (including the development log) please refer to the CHANGELOG file in the repository)

0.5.55
0.5.56
- use $[0[]0] to indicate final caret position in snippet. If $[0[]0] is not found in snippet, it will be added to the end of snippet automatically.
- automatically navigate to next hotspot when (lis) hotspot is chosen.
- Added: keyword hotspot LASTOPTION and LASTLISTITEM, which will yield the previously chosen option or list item respectively
Expand Down

0 comments on commit 05ad70b

Please sign in to comment.