VisualD modding

Johnson Jones via Digitalmars-d-ide digitalmars-d-ide at puremagic.com
Mon Aug 14 07:51:32 PDT 2017


On Monday, 14 August 2017 at 06:50:21 UTC, Rainer Schuetze wrote:
>
>
> On 14.08.2017 03:49, Johnson Jones wrote:
>> On Sunday, 13 August 2017 at 20:43:21 UTC, Johnson Jones wrote:
>>> So, I'd like to fix some of visual D's navigation and editing 
>>> logic and possibly implement something like elastic tabs: 
>>> http://nickgravgaard.com/elastic-tabstops/
>>>
>>> 1. Backspace and delete should be tab aligned and use elastic 
>>> space.
>>>
>>> 2. Indention on new line should not add spaces(it currently 
>>> does and screws things up as things are no longer aligned and 
>>> it is very difficult to realign stuff.
>>>
>>> 3. Indentation should use previous indentation when using tab 
>>> or enter, unless empty line.
>>>
>>> I've went ahead and added a property called elasticSpace to 
>>> visual D's properties(should be in the tab section I suppose 
>>> but I didn't wanna have to figure that mess out).
>>>
>>>
>>>
>>> propertypage: https://justpaste.it/1a1if
>>>
>>> dpackage: https://justpaste.it/1a1ig
>>>
>>> This do add it to the first entry and defaults it to true but 
>>> that can easily be fixed.
>>>
>>> The real work is to consume all spaces, working backwards, 
>>> when hitting backspace and to consume all spaces forward when 
>>> hitting delete. Also dealing with other the tab and enter key 
>>> appropriately.
>>>
>>> TabSanity uses the code like
>>>
>>> https://justpaste.it/1a1ij
>>>
>>> Anyways, I'm at the following location in viewfilter.d and a 
>>> little lost(well, time constraints).
>>>
>>>
>>> The backspace key is handled as so:
>>>
>>>             // Handle backspace
>>>             case ECMD_BACKSPACE:
>>>                 if(mCodeWinMgr.mSource.IsCompletorActive())
>>>                     initCompletion(false);
>>>                 if (Package.GetGlobalOptions().elasticSpace)
>>>                 {
>>>                     mView.GetCaretPos(&line, &idx);
>>>
>>>                     dchar ch = pvaIn.uiVal;
>>>                 }
>>>                 goto case;
>>>
>>> in which I've added the new code.
>>>
>>> but it's a little difficult to navigate through the code. I 
>>> think with the proper mapping maybe it is possible almost 
>>> directly copy and paste the tabsanity code.
>>>
>>> In any case, I figured I'd let you have a shot at it first if 
>>> you want since your probably more familiar with it than 
>>> me(and since debugging is extremely slow with this sorta 
>>> thing I'll probably burn a lot more time than you would).
>>>
>>> Thanks
>> 
>> So, I'm trying to implement some of this stuff but I can't 
>> seem to find a way to get the modified line before it was 
>> modified.
>> 
>> I'm using something like this
>> 
>> BSTR str;
>>                      
>> mCodeWinMgr.mSource.mBuffer.GetLengthOfLine(line, &len);
>> mCodeWinMgr.mSource.mBuffer.GetLineText(line, 0, line, len, 
>> &str);
>> 
>> while tabsanity is using something like
>> 
>> auto snapshot = TextView.TextBuffer.CurrentSnapshot;
>> 
>> which I can't seem to find an equivalent of in visual D.
>> 
>> 
>> Any ideas?
>
> You can capture the state of the line before default execution 
> with
>
> mNextTarget.Exec()
>
> Maybe your code could just be moved up there to begin with.

Moved up where?

I see 'int rc = mNextTarget.Exec(pguidCmdGroup, nCmdID, 
nCmdexecopt, pvaIn, pvaOut);'

which is about all that is used with mNextTarget.Exec, but it is 
calling it rather than overriding it in some way.

Once I get some progress I'll submit some patches, right now I'm 
just toying around with it trying to see how it's all set up. 
While I can do some things I feel like I'm gonna have to revamp 
some of the editing(all optional) because I get pretty frustrated 
in Visual D due to time consuming processes of wrangling with 
spaces.

e.g., when one hits return it always seems to take them to the 
start of the line, then tabs move one at a time instead of 
jumping to the previous tab indention. One one had many nesting 
and about 10+ tabs, this is time consuming, and must be done for 
each line. Similar issues occur with backspace, delete, etc.

I can fix the bulk of this and tweak them as I use visual D for 
my own projects once I get a handle on how to do that in visual 
D's source.  It's a bit more wacky than doing it in C# since it 
seems to use COM to do it all, which means there is little 
documentation for it.

What I've noticed is that one can run a separate window from 
visual studio using visual D and I think this will open some cool 
things for the future, such as a real time debug view window that 
can list such things as instantaneous memory usage(a graph, sort 
of like diagnostic properties, etc), performance, variable 
values, etc. Although, that's just conceptual now, but I can 
imagine it being a useful utility feature.

Right now I've got a simple console running displaying the debug 
information so I know what is going on, but eventually that could 
be turned in to something useful for actually coding and 
debugging in D.




More information about the Digitalmars-d-ide mailing list