can you set that timeout range to be not in number but of index start and index end…
- User
can you set that timeout range to be not in number but of index start and index end range between in empty space of current caret position and the most-right side of the container?: ```
copy code .container {
display: grid; width: 100%; height: 100%;
padding-top:0px; place-items: center; }
copy code .textarea{ width:100%; height:auto; max-height:50vh; font-family: 'Courier New', monospace; font-size: 18px; font-weight: bold; color: cyan; background: rgba(1, 1, 3, 0.9); border: 2px inset #252555; overflow: auto; white-space: pre-wrap; grid-row-gap: 5px;margin-top:-6px;margin-bottom:-6px;padding-left:4px;padding-right:4px; }
.highlight-line { position: relative; height: 9px; background: linear-gradient(to right, rgba(155, 0, 0, 0.1), rgba(0, 0, 155, 0.2)); animation: shot 2.5s forwards, blink 0.05s 0.1s infinite; }
.highlight-line:before {padding:5px; content: '█'; color: white; position: absolute; left: 100%; top: 0; width: 0; height: 100%; background: linear-gradient(to right, rgba(155, 200, 55, 0.2), rgba(155, 0, 0, 0.1)); pointer-events: none; animation: shot 0.5s backwards, blink 0.05s 0.1s infinite; }
@keyframes shot { from { left: 0; width: 0; }
to { left: 100%; width: 100%; } }
@keyframes blink {
0%, 100% { opacity: 1; }
50% { opacity: 0; } }
const textarea = document.getElementById('textarea');
function insertLine() { const range = window.getSelection().getRangeAt(0); const textNode = range.startContainer; const currentPosition = range.startOffset;
const lineText = textNode.textContent.trim().slice(0, currentPosition);
const highlightedLine = document.createElement('span'); highlightedLine.classList.add('highlight-line'); highlightedLine.textContent = '█'; range.deleteContents();
const lineBreak = document.createElement('br');
const newLine = document.createElement('span'); newLine.appendChild(lineBreak); newLine.appendChild(highlightedLine);
const nextNode = textNode.splitText(currentPosition); nextNode.parentNode.insertBefore(newLine, nextNode);
copy code range.deleteContents(); range.insertNode(highlightedLine); range.collapse(); setTimeout(() => { highlightedLine.remove(); }, 2000); }
function handleKeyPress(event) { if (event.key === 'Enter' || event.key === 'Return') { event.preventDefault();
const range = window.getSelection().getRangeAt(0); const lineBreak = document.createElement('br'); insertLine(); range.deleteContents(); range.insertNode(lineBreak); range.collapse(false);
} }
copy code textarea.addEventListener('keydown', handleKeyPress);
```
Yes, the timeout range can be set based on the index start and index end range between the empty space of the current caret position and the rightmost side of the container. Here’s an updated version of the code to achieve that:
- Assistant