GithubHelp home page GithubHelp logo

Comments (3)

alankilborn avatar alankilborn commented on August 17, 2024

Note that the Notepad++ code for allocating indicators will NOT store a -1 in the calling argument upon failure as the corresponding marker allocation code will.

Preliminary documentation for the API is here: notepad-plus-plus/npp-usermanual#542

from pythonscript.

alankilborn avatar alankilborn commented on August 17, 2024

Here's some test code exercising the call in Notepad++:

# -*- coding: utf-8 -*-
from __future__ import print_function

from Npp import *
from ctypes import ( addressof, WinDLL )
from ctypes.wintypes import ( HWND, UINT, WPARAM, LPARAM, DWORD )

LRESULT = LPARAM

user32 = WinDLL('user32')

SendMessageW = user32.SendMessageW
SendMessageW.restype = LRESULT
SendMessageW.argtypes = [ HWND, UINT, WPARAM, LPARAM ]

WM_USER = 0x400
NPPMSG = (WM_USER + 1000)

def notepad_allocateIndicator_RAW(num_indicators_to_alloc):
    NPPM_ALLOCATEINDICATOR = (NPPMSG + 113)
    lowest_allocated_indicator_id = DWORD()  # not sure DWORD is the correct thing to use here...
    __ = SendMessageW(notepad.hwnd, NPPM_ALLOCATEINDICATOR, num_indicators_to_alloc, addressof(lowest_allocated_indicator_id))
    return None if __ == 0 else lowest_allocated_indicator_id

num_indicators_needed = 3
start_indicator_id = notepad_allocateIndicator_RAW(num_indicators_needed)
if start_indicator_id is None:
    print('could not allocate enough indicator(s) to fulfill request')
else:
    start_indicator_id = start_indicator_id.value  # c_ulong to int
    print('allocated indicator ids:', list(range(start_indicator_id, start_indicator_id + num_indicators_needed)))

from pythonscript.

alankilborn avatar alankilborn commented on August 17, 2024

Thanks @chcg Christian!

from pythonscript.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.