VisualD modding

Rainer Schuetze via Digitalmars-d-ide digitalmars-d-ide at puremagic.com
Sun Aug 13 23:50:21 PDT 2017



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.


More information about the Digitalmars-d-ide mailing list